Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
asoliman92 committed Jul 16, 2024
1 parent ec53a30 commit d635398
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 44 deletions.
2 changes: 1 addition & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ require (
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/shirou/gopsutil/v3 v3.24.3 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716113537-c4ab63b630d9 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716140948-e39aca330d3a // indirect
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240621143432-85370a54b141 // indirect
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240702144807-761f63e7b527 // indirect
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240522213638-159fb2d99917 // indirect
Expand Down
3 changes: 3 additions & 0 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,9 @@ github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5Xiayf
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716103219-8ce5cf3daa0e h1:+nxnYA9VSU12zHjPxgBpcJhUK3IsJb2L3BMxWY7ZbXI=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716103219-8ce5cf3daa0e/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716113537-c4ab63b630d9/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716125744-c4748dc93ff3/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716131321-c210e1f71bb3/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716140948-e39aca330d3a/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240708180634-24440372521a h1:0HUP3qmHejg7FyFdY+R+8iFg0kNtrvnAxaQ//+fuZfc=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240708180634-24440372521a/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240621143432-85370a54b141 h1:TMOoYaeSDkkI3jkCH7lKHOZaLkeDuxFTNC+XblD6M0M=
Expand Down
2 changes: 1 addition & 1 deletion core/services/ccipcapability/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, spec job.Job) (services
hcr := ccipreaderpkg.NewHomeChainReader(
homeChainContractReader,
d.lggr.Named("HomeChainReader"),
12*time.Second,
100*time.Millisecond,
)

oracleCreator := oraclecreator.New(
Expand Down
32 changes: 19 additions & 13 deletions core/services/chainlink/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,22 +210,14 @@ func NewApplication(opts ApplicationOpts) (Application, error) {
var externalPeerWrapper p2ptypes.PeerWrapper
var getLocalNode func(ctx context.Context) (pkgcapabilities.Node, error)
var capabilityRegistrySyncer registrysyncer.Syncer
if cfg.Capabilities().Peering().Enabled() {
externalPeer := externalp2p.NewExternalPeerWrapper(keyStore.P2P(), cfg.Capabilities().Peering(), opts.DS, globalLogger)
signer := externalPeer
externalPeerWrapper = externalPeer

srvcs = append(srvcs, externalPeerWrapper)

dispatcher := remote.NewDispatcher(externalPeerWrapper, signer, opts.CapabilitiesRegistry, globalLogger)

if cfg.Capabilities().ExternalRegistry().Address() != "" {
rid := cfg.Capabilities().ExternalRegistry().RelayID()
registryAddress := cfg.Capabilities().ExternalRegistry().Address()
relayer, err := relayerChainInterops.Get(rid)
if err != nil {
return nil, fmt.Errorf("could not fetch relayer %s configured for capabilities registry: %w", rid, err)
}

registrySyncer, err := registrysyncer.New(
globalLogger,
relayer,
Expand All @@ -235,18 +227,32 @@ func NewApplication(opts ApplicationOpts) (Application, error) {
return nil, fmt.Errorf("could not configure syncer: %w", err)
}

capabilityRegistrySyncer = registrySyncer
srvcs = append(srvcs, capabilityRegistrySyncer)
}

if cfg.Capabilities().Peering().Enabled() {
if capabilityRegistrySyncer == nil {
return nil, errors.Errorf("peering enabled but no capability registry found")
}
externalPeer := externalp2p.NewExternalPeerWrapper(keyStore.P2P(), cfg.Capabilities().Peering(), opts.DS, globalLogger)
signer := externalPeer
externalPeerWrapper = externalPeer

srvcs = append(srvcs, externalPeerWrapper)

dispatcher := remote.NewDispatcher(externalPeerWrapper, signer, opts.CapabilitiesRegistry, globalLogger)

wfLauncher := capabilities.NewLauncher(
globalLogger,
externalPeerWrapper,
dispatcher,
opts.CapabilitiesRegistry,
)
registrySyncer.AddLauncher(wfLauncher)

capabilityRegistrySyncer = registrySyncer

capabilityRegistrySyncer.AddLauncher(wfLauncher)
srvcs = append(srvcs, dispatcher, wfLauncher)
getLocalNode = wfLauncher.LocalNode
srvcs = append(srvcs, dispatcher, wfLauncher, registrySyncer)
}

// LOOPs can be created as options, in the case of LOOP relayers, or
Expand Down
25 changes: 17 additions & 8 deletions core/services/ocr3/plugins/ccip_integration_tests/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,27 +317,36 @@ func (h *homeChain) AddNodes(
h.backend.Commit()
}

func (h *homeChain) AddDON(
func AddChainConfig(
t *testing.T,
ccipCapabilityID [32]byte,
h homeChain,
chainSelector uint64,
OfframpAddress []byte,
f uint8,
bootstrapP2PID [32]byte,
p2pIDs [][32]byte,
oracles []confighelper2.OracleIdentityExtra,
) {
f uint8,
) ccip_config.CCIPConfigTypesChainConfigInfo {
// Need to sort, otherwise _checkIsValidUniqueSubset onChain will fail
sortP2PIDS(p2pIDs)
// First Add ChainConfig that includes all p2pIDs as readers
chainConfig := integrationhelpers.SetupConfigInfo(chainSelector, p2pIDs, integrationhelpers.FChainA, []byte(strconv.FormatUint(chainSelector, 10)))
chainConfig := integrationhelpers.SetupConfigInfo(chainSelector, p2pIDs, f, []byte(strconv.FormatUint(chainSelector, 10)))
inputConfig := []ccip_config.CCIPConfigTypesChainConfigInfo{
chainConfig,
}
_, err := h.ccipConfig.ApplyChainConfigUpdates(h.owner, nil, inputConfig)
require.NoError(t, err)
h.backend.Commit()
return chainConfig
}

func (h *homeChain) AddDON(
t *testing.T,
ccipCapabilityID [32]byte,
chainSelector uint64,
OfframpAddress []byte,
f uint8,
bootstrapP2PID [32]byte,
p2pIDs [][32]byte,
oracles []confighelper2.OracleIdentityExtra,
) {
// Get OCR3 Config from helper
var schedule []int
for range oracles {
Expand Down
39 changes: 25 additions & 14 deletions core/services/ocr3/plugins/ccip_integration_tests/ocr3_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ func TestIntegration_OCR3Nodes(t *testing.T) {
numNodes := 4
t.Log("creating ocr3 nodes")
var (
oracles = make(map[uint64][]confighelper2.OracleIdentityExtra)
transmitters = make(map[uint64][]common.Address)
apps []chainlink.Application
nodes []*ocr3Node
p2pIDs [][32]byte
oracles = make(map[uint64][]confighelper2.OracleIdentityExtra)
apps []chainlink.Application
nodes []*ocr3Node
p2pIDs [][32]byte

// The bootstrap node will be the first node (index 0)
bootstrapPort int
Expand All @@ -56,7 +55,6 @@ func TestIntegration_OCR3Nodes(t *testing.T) {
ConfigEncryptionPublicKey: node.keybundle.ConfigEncryptionPublicKey(),
}
oracles[chainID] = append(oracles[chainID], identity)
t.Logf("OCR3_TEST_TRANSMITTERS %+v", transmitters)
}
nodes = append(nodes, node)
peerID, err := p2pkey.MakePeerID(node.peerID)
Expand All @@ -81,6 +79,27 @@ func TestIntegration_OCR3Nodes(t *testing.T) {
commitBlocksBackground(t, universes, tick)

ctx := testutils.Context(t)

ccipCapabilityID, err := homeChainUni.capabilityRegistry.GetHashedCapabilityId(&bind.CallOpts{
Context: ctx,
}, CapabilityLabelledName, CapabilityVersion)
require.NoError(t, err, "failed to get hashed capability id for ccip")
require.NotEqual(t, [32]byte{}, ccipCapabilityID, "ccip capability id is empty")

// Need to Add nodes and assign capabilities to them before creating DONS

homeChainUni.AddNodes(t, p2pIDs, [][32]byte{ccipCapabilityID})

// Add homechain configs
for _, uni := range universes {
AddChainConfig(t, homeChainUni, getSelector(uni.chainID), p2pIDs, 1)
}

cfgs, err3 := homeChainUni.ccipConfig.GetAllChainConfigs(&bind.CallOpts{})
require.NoError(t, err3)
t.Logf("homechain_configs %+v", cfgs)
require.Len(t, cfgs, numChains)

t.Log("creating ocr3 jobs")
for i := 0; i < len(nodes); i++ {
err := nodes[i].app.Start(ctx)
Expand All @@ -94,14 +113,6 @@ func TestIntegration_OCR3Nodes(t *testing.T) {
require.NoErrorf(t, tApp.AddJobV2(ctx, &jb), "Wasn't able to create ccip job for node %d", i)
}

ccipCapabilityID, err := homeChainUni.capabilityRegistry.GetHashedCapabilityId(&bind.CallOpts{
Context: ctx,
}, CapabilityLabelledName, CapabilityVersion)
require.NoError(t, err, "failed to get hashed capability id for ccip")
require.NotEqual(t, [32]byte{}, ccipCapabilityID, "ccip capability id is empty")

// Need to Add nodes and assign capabilities to them before creating DONS
homeChainUni.AddNodes(t, p2pIDs, [][32]byte{ccipCapabilityID})
// Create a DON for each chain
for _, uni := range universes {
// Add nodes and give them the capability
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ func setupNodeOCR3(

// Enable Capabilities, This is a pre-requisite for registrySyncer to work.
// Same values as P2P.V2 except for the listen address.
c.Capabilities.Peering.V2 = c.P2P.V2
c.Capabilities.Peering.V2.ListenAddresses = &[]string{fmt.Sprintf("127.0.0.1:%d", capabilitiesPort)}
//c.Capabilities.Peering.V2.Enabled = ptr(true)
//c.Capabilities.Peering.V2 = c.P2P.V2
//c.Capabilities.Peering.V2.ListenAddresses = &[]string{fmt.Sprintf("127.0.0.1:%d", capabilitiesPort)}
c.Capabilities.ExternalRegistry.NetworkID = ptr(relay.NetworkEVM)
c.Capabilities.ExternalRegistry.ChainID = ptr(strconv.FormatUint(homeChainUniverse.chainID, 10))
c.Capabilities.ExternalRegistry.Address = ptr(homeChainUniverse.capabilityRegistry.Address().String())
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ require (
github.com/shopspring/decimal v1.3.1
github.com/smartcontractkit/chain-selectors v1.0.18
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716113537-c4ab63b630d9
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716140948-e39aca330d3a
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240708180634-24440372521a
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240621143432-85370a54b141
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240702144807-761f63e7b527
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,8 @@ github.com/smartcontractkit/chain-selectors v1.0.18 h1:ackCMDOlWuwULAyBNj9fQeQme
github.com/smartcontractkit/chain-selectors v1.0.18/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716113537-c4ab63b630d9 h1:hEnryY8azUVijAf6a5yCuJrvGUHh44X07MoDEL3e154=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716113537-c4ab63b630d9/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716140948-e39aca330d3a h1:O1FCLgYwBTn4ArTQUZQ752ETrG6qMJDaSX6XLC+4H8Q=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716140948-e39aca330d3a/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240708180634-24440372521a h1:0HUP3qmHejg7FyFdY+R+8iFg0kNtrvnAxaQ//+fuZfc=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240708180634-24440372521a/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240621143432-85370a54b141 h1:TMOoYaeSDkkI3jkCH7lKHOZaLkeDuxFTNC+XblD6M0M=
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ require (
github.com/shirou/gopsutil/v3 v3.24.3 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716113537-c4ab63b630d9 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716140948-e39aca330d3a // indirect
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240621143432-85370a54b141 // indirect
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240702144807-761f63e7b527 // indirect
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240522213638-159fb2d99917 // indirect
Expand Down
3 changes: 3 additions & 0 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,9 @@ github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5Xiayf
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716103219-8ce5cf3daa0e h1:+nxnYA9VSU12zHjPxgBpcJhUK3IsJb2L3BMxWY7ZbXI=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716103219-8ce5cf3daa0e/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716113537-c4ab63b630d9/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716125744-c4748dc93ff3/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716131321-c210e1f71bb3/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716140948-e39aca330d3a/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240708180634-24440372521a h1:0HUP3qmHejg7FyFdY+R+8iFg0kNtrvnAxaQ//+fuZfc=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240708180634-24440372521a/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240621143432-85370a54b141 h1:TMOoYaeSDkkI3jkCH7lKHOZaLkeDuxFTNC+XblD6M0M=
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/load/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ require (
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/smartcontractkit/chain-selectors v1.0.18 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716113537-c4ab63b630d9 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716140948-e39aca330d3a // indirect
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240621143432-85370a54b141 // indirect
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240702144807-761f63e7b527 // indirect
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240522213638-159fb2d99917 // indirect
Expand Down
3 changes: 3 additions & 0 deletions integration-tests/load/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,9 @@ github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5Xiayf
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716103219-8ce5cf3daa0e h1:+nxnYA9VSU12zHjPxgBpcJhUK3IsJb2L3BMxWY7ZbXI=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716103219-8ce5cf3daa0e/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716113537-c4ab63b630d9/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716125744-c4748dc93ff3/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716131321-c210e1f71bb3/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240716140948-e39aca330d3a/go.mod h1:gyODeD1uMobe5VWRwVRiEXzL9wUzFTI80VvyCNLqWcw=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240708180634-24440372521a h1:0HUP3qmHejg7FyFdY+R+8iFg0kNtrvnAxaQ//+fuZfc=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240708180634-24440372521a/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240621143432-85370a54b141 h1:TMOoYaeSDkkI3jkCH7lKHOZaLkeDuxFTNC+XblD6M0M=
Expand Down

0 comments on commit d635398

Please sign in to comment.