Skip to content

Commit

Permalink
Using the peer group common logic (#15048)
Browse files Browse the repository at this point in the history
* use peergroup

* cl-ccip

* main branch commit
  • Loading branch information
0xnogo authored Oct 31, 2024
1 parent 8a9dbf4 commit a1e4f8e
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 28 deletions.
27 changes: 14 additions & 13 deletions core/capabilities/ccip/oraclecreator/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
ccipreaderpkg "github.com/smartcontractkit/chainlink-ccip/pkg/reader"
cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"

"github.com/smartcontractkit/chainlink-ccip/commit/merkleroot/rmn"
"github.com/smartcontractkit/chainlink-ccip/pkg/peergroup"
"github.com/smartcontractkit/chainlink-common/pkg/types"

"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ocrimpls"
Expand Down Expand Up @@ -230,15 +230,15 @@ func (i *bootstrapOracleCreator) getRmnHomeReader(ctx context.Context, config cc
type peerGroupDialer struct {
lggr logger.Logger

peerGroupFactory rmn.PeerGroupFactory
peerGroupCreator *peergroup.Creator
rmnHomeReader ccipreaderpkg.RMNHome

// common oracle config
bootstrapLocators []commontypes.BootstrapperLocator
oraclePeerIDs []ragep2ptypes.PeerID
commitConfigDigest [32]byte

activePeerGroups []rmn.PeerGroup
activePeerGroups []peergroup.PeerGroup
activeConfigDigests []cciptypes.Bytes32

syncInterval time.Duration
Expand All @@ -261,7 +261,7 @@ const (

func newPeerGroupDialer(
lggr logger.Logger,
peerGroupFactory rmn.PeerGroupFactory,
peerGroupFactory peergroup.PeerGroupFactory,
rmnHomeReader ccipreaderpkg.RMNHome,
bootstrapLocators []commontypes.BootstrapperLocator,
oraclePeerIDs []ragep2ptypes.PeerID,
Expand All @@ -270,14 +270,14 @@ func newPeerGroupDialer(
return &peerGroupDialer{
lggr: lggr,

peerGroupFactory: peerGroupFactory,
peerGroupCreator: peergroup.NewCreator(lggr, peerGroupFactory, bootstrapLocators),
rmnHomeReader: rmnHomeReader,

bootstrapLocators: bootstrapLocators,
oraclePeerIDs: oraclePeerIDs,
commitConfigDigest: commitConfigDigest,

activePeerGroups: []rmn.PeerGroup{},
activePeerGroups: []peergroup.PeerGroup{},

syncInterval: 12 * time.Second, // todo: make it configurable

Expand Down Expand Up @@ -444,17 +444,18 @@ func (d *peerGroupDialer) createPeerGroup(rmnHomeConfigDigest cciptypes.Bytes32)
)

lggr.Infow("Creating new peer group")
peerGroup, err := d.peerGroupFactory.NewPeerGroup(
[32]byte(genericEndpointConfigDigest),
peerIDs,
d.bootstrapLocators,
)
peerGroup, err := d.peerGroupCreator.Create(peergroup.CreateOpts{
CommitConfigDigest: cciptypes.Bytes32(d.commitConfigDigest),
RMNHomeConfigDigest: rmnHomeConfigDigest,
OraclePeerIDs: d.oraclePeerIDs,
RMNNodes: rmnNodesInfo,
})
if err != nil {
return fmt.Errorf("new peer group: %w", err)
}
lggr.Infow("Created new peer group successfully")

d.activePeerGroups = append(d.activePeerGroups, peerGroup)
d.activePeerGroups = append(d.activePeerGroups, peerGroup.PeerGroup)
d.activeConfigDigests = append(d.activeConfigDigests, genericEndpointConfigDigest)

return nil
Expand All @@ -470,7 +471,7 @@ func (d *peerGroupDialer) closeExistingPeerGroups() {
d.lggr.Infow("Closed peer group successfully")
}

d.activePeerGroups = []rmn.PeerGroup{}
d.activePeerGroups = []peergroup.PeerGroup{}
d.activeConfigDigests = []cciptypes.Bytes32{}
}

Expand Down
2 changes: 1 addition & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ require (
github.com/shirou/gopsutil/v3 v3.24.3 // indirect
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-20240926212305-a6deabdfce86 // indirect
github.com/smartcontractkit/chain-selectors v1.0.27 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031095646-6d86812d0db9 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031135640-ac3278008a73 // indirect
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f // indirect
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20241018134907-a00ba3729b5e // indirect
github.com/smartcontractkit/chainlink-feeds v0.1.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1090,8 +1090,8 @@ github.com/smartcontractkit/chain-selectors v1.0.27 h1:VE/ftX9Aae4gnw67yR1raKi+3
github.com/smartcontractkit/chain-selectors v1.0.27/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU=
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031095646-6d86812d0db9 h1:PFPFFfFeihXnvB0gcwX32VgVtzmthxngxM4Pn4R3YEs=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031095646-6d86812d0db9/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031135640-ac3278008a73 h1:F+WjcRCHZ4lVk69qDXMb4GpZ2+8kx/j93PreuK+8xe8=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031135640-ac3278008a73/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis=
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241025132045-cfad02139595 h1:H6i0LEvXB0se/63E3jE9N0/7TugOYLpK4e6TT6a0omc=
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241025132045-cfad02139595/go.mod h1:TQ9/KKXZ9vr8QAlUquqGpSvDCpR+DtABKPXZY4CiRns=
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f h1:BwrIaQIx5Iy6eT+DfLhFfK2XqjxRm74mVdlX8gbu4dw=
Expand Down
2 changes: 1 addition & 1 deletion deployment/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/sethvargo/go-retry v0.2.4
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-20240926212305-a6deabdfce86
github.com/smartcontractkit/chain-selectors v1.0.27
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031095646-6d86812d0db9
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031135640-ac3278008a73
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241025132045-cfad02139595
github.com/smartcontractkit/chainlink-protos/job-distributor v0.4.0
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.12
Expand Down
4 changes: 2 additions & 2 deletions deployment/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1385,8 +1385,8 @@ github.com/smartcontractkit/chain-selectors v1.0.27 h1:VE/ftX9Aae4gnw67yR1raKi+3
github.com/smartcontractkit/chain-selectors v1.0.27/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU=
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031095646-6d86812d0db9 h1:PFPFFfFeihXnvB0gcwX32VgVtzmthxngxM4Pn4R3YEs=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031095646-6d86812d0db9/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031135640-ac3278008a73 h1:F+WjcRCHZ4lVk69qDXMb4GpZ2+8kx/j93PreuK+8xe8=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031135640-ac3278008a73/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis=
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241025132045-cfad02139595 h1:H6i0LEvXB0se/63E3jE9N0/7TugOYLpK4e6TT6a0omc=
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241025132045-cfad02139595/go.mod h1:TQ9/KKXZ9vr8QAlUquqGpSvDCpR+DtABKPXZY4CiRns=
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f h1:BwrIaQIx5Iy6eT+DfLhFfK2XqjxRm74mVdlX8gbu4dw=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ require (
github.com/shopspring/decimal v1.4.0
github.com/smartcontractkit/chain-selectors v1.0.27
github.com/smartcontractkit/chainlink-automation v0.8.1
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031095646-6d86812d0db9
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031135640-ac3278008a73
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241025132045-cfad02139595
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20241018134907-a00ba3729b5e
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,8 @@ github.com/smartcontractkit/chain-selectors v1.0.27 h1:VE/ftX9Aae4gnw67yR1raKi+3
github.com/smartcontractkit/chain-selectors v1.0.27/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU=
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031095646-6d86812d0db9 h1:PFPFFfFeihXnvB0gcwX32VgVtzmthxngxM4Pn4R3YEs=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031095646-6d86812d0db9/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031135640-ac3278008a73 h1:F+WjcRCHZ4lVk69qDXMb4GpZ2+8kx/j93PreuK+8xe8=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031135640-ac3278008a73/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis=
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241025132045-cfad02139595 h1:H6i0LEvXB0se/63E3jE9N0/7TugOYLpK4e6TT6a0omc=
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241025132045-cfad02139595/go.mod h1:TQ9/KKXZ9vr8QAlUquqGpSvDCpR+DtABKPXZY4CiRns=
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f h1:BwrIaQIx5Iy6eT+DfLhFfK2XqjxRm74mVdlX8gbu4dw=
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ require (
github.com/slack-go/slack v0.15.0
github.com/smartcontractkit/chain-selectors v1.0.27
github.com/smartcontractkit/chainlink-automation v0.8.1
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031095646-6d86812d0db9
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031135640-ac3278008a73
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241025132045-cfad02139595
github.com/smartcontractkit/chainlink-protos/job-distributor v0.4.0
github.com/smartcontractkit/chainlink-testing-framework/havoc v1.50.2
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1403,8 +1403,8 @@ github.com/smartcontractkit/chain-selectors v1.0.27 h1:VE/ftX9Aae4gnw67yR1raKi+3
github.com/smartcontractkit/chain-selectors v1.0.27/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU=
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031095646-6d86812d0db9 h1:PFPFFfFeihXnvB0gcwX32VgVtzmthxngxM4Pn4R3YEs=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031095646-6d86812d0db9/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031135640-ac3278008a73 h1:F+WjcRCHZ4lVk69qDXMb4GpZ2+8kx/j93PreuK+8xe8=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031135640-ac3278008a73/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis=
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241025132045-cfad02139595 h1:H6i0LEvXB0se/63E3jE9N0/7TugOYLpK4e6TT6a0omc=
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241025132045-cfad02139595/go.mod h1:TQ9/KKXZ9vr8QAlUquqGpSvDCpR+DtABKPXZY4CiRns=
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f h1:BwrIaQIx5Iy6eT+DfLhFfK2XqjxRm74mVdlX8gbu4dw=
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 @@ -64,7 +64,7 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031095646-6d86812d0db9 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031135640-ac3278008a73 // indirect
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f // indirect
github.com/smartcontractkit/chainlink-testing-framework/havoc v1.50.2 // indirect
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 // indirect
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/load/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1392,8 +1392,8 @@ github.com/smartcontractkit/chain-selectors v1.0.27 h1:VE/ftX9Aae4gnw67yR1raKi+3
github.com/smartcontractkit/chain-selectors v1.0.27/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU=
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031095646-6d86812d0db9 h1:PFPFFfFeihXnvB0gcwX32VgVtzmthxngxM4Pn4R3YEs=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031095646-6d86812d0db9/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031135640-ac3278008a73 h1:F+WjcRCHZ4lVk69qDXMb4GpZ2+8kx/j93PreuK+8xe8=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241031135640-ac3278008a73/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis=
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241025132045-cfad02139595 h1:H6i0LEvXB0se/63E3jE9N0/7TugOYLpK4e6TT6a0omc=
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241025132045-cfad02139595/go.mod h1:TQ9/KKXZ9vr8QAlUquqGpSvDCpR+DtABKPXZY4CiRns=
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f h1:BwrIaQIx5Iy6eT+DfLhFfK2XqjxRm74mVdlX8gbu4dw=
Expand Down

0 comments on commit a1e4f8e

Please sign in to comment.