Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into bump-rmn-home
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-sekara committed Jan 23, 2025
2 parents 77335d4 + c682bd7 commit a5610fe
Show file tree
Hide file tree
Showing 29 changed files with 1,177 additions and 101 deletions.
2 changes: 1 addition & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ require (
github.com/shirou/gopsutil/v3 v3.24.3 // indirect
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-salt-fix // indirect
github.com/smartcontractkit/chain-selectors v1.0.36 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250123130533-22d38c3cf6b4 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250123132536-c4e873a15101 // indirect
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b // indirect
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20250121210000-2a9675d7a1b4 // 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 @@ -1168,8 +1168,8 @@ github.com/smartcontractkit/chain-selectors v1.0.36 h1:KSpO8I+JOiuyN4FuXsV471sPo
github.com/smartcontractkit/chain-selectors v1.0.36/go.mod h1:xsKM0aN3YGcQKTPRPDDtPx2l4mlTN1Djmg0VVXV40b8=
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-20250123130533-22d38c3cf6b4 h1:6neMkkR1hHyQTzqp14cs2liP3yERf/1xbPZSVVViuaU=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250123130533-22d38c3cf6b4/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250123132536-c4e873a15101 h1:E2bZmNuU978huK+Fi8NSx/jmTcZcSou4L3F1Cs2rZSk=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250123132536-c4e873a15101/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250121163309-3e179a73cb92 h1:9zmJi4TctSNvmVdmRh2UpbNRDnrWKYn4o+PZDAIhqqc=
Expand Down
20 changes: 0 additions & 20 deletions core/services/llo/channel_definition_cache_factory.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package llo

import (
"fmt"
"net/http"
"sync"

"github.com/ethereum/go-ethereum/common"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
llotypes "github.com/smartcontractkit/chainlink-common/pkg/types/llo"
Expand All @@ -26,8 +22,6 @@ func NewChannelDefinitionCacheFactory(lggr logger.Logger, orm ChannelDefinitionC
orm,
lp,
client,
make(map[common.Address]map[uint32]struct{}),
sync.Mutex{},
}
}

Expand All @@ -36,9 +30,6 @@ type channelDefinitionCacheFactory struct {
orm ChannelDefinitionCacheORM
lp logpoller.LogPoller
client *http.Client

caches map[common.Address]map[uint32]struct{}
mu sync.Mutex
}

func (f *channelDefinitionCacheFactory) NewCache(cfg lloconfig.PluginConfig) (llotypes.ChannelDefinitionCache, error) {
Expand All @@ -50,16 +41,5 @@ func (f *channelDefinitionCacheFactory) NewCache(cfg lloconfig.PluginConfig) (ll
fromBlock := cfg.ChannelDefinitionsContractFromBlock
donID := cfg.DonID

f.mu.Lock()
defer f.mu.Unlock()

if _, exists := f.caches[addr][donID]; exists {
// This shouldn't really happen and isn't supported
return nil, fmt.Errorf("cache already exists for contract address %s and don ID %d", addr.Hex(), donID)
}
if _, exists := f.caches[addr]; !exists {
f.caches[addr] = make(map[uint32]struct{})
}
f.caches[addr][donID] = struct{}{}
return NewChannelDefinitionCache(f.lggr, f.orm, f.client, f.lp, addr, donID, fromBlock), nil
}
7 changes: 4 additions & 3 deletions core/services/llo/channel_definition_cache_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ func Test_ChannelDefinitionCacheFactory(t *testing.T) {
require.NoError(t, err)
require.IsType(t, &channelDefinitionCache{}, cdc)

// returns error if you try to do it again with the same addr/donID
_, err = cdcFactory.NewCache(lloconfig.PluginConfig{
// creates another one if you try to do it again with the same addr/donID
cdc, err = cdcFactory.NewCache(lloconfig.PluginConfig{
ChannelDefinitionsContractAddress: common.HexToAddress("0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
DonID: 1,
})
require.EqualError(t, err, "cache already exists for contract address 0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa and don ID 1")
require.NoError(t, err)
require.IsType(t, &channelDefinitionCache{}, cdc)

// is fine if you do it again with different addr
cdc, err = cdcFactory.NewCache(lloconfig.PluginConfig{
Expand Down
12 changes: 6 additions & 6 deletions deployment/ccip/changeset/testhelpers/test_assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,21 @@ func ConfirmCommitForAllWithExpectedSeqNums(
)
}

type commitReportTracker struct {
type CommitReportTracker struct {
seenMessages map[uint64]map[uint64]bool
}

func newCommitReportTracker(sourceChainSelector uint64, seqNrs ccipocr3.SeqNumRange) commitReportTracker {
func NewCommitReportTracker(sourceChainSelector uint64, seqNrs ccipocr3.SeqNumRange) CommitReportTracker {
seenMessages := make(map[uint64]map[uint64]bool)
seenMessages[sourceChainSelector] = make(map[uint64]bool)

for i := seqNrs.Start(); i <= seqNrs.End(); i++ {
seenMessages[sourceChainSelector][uint64(i)] = false
}
return commitReportTracker{seenMessages: seenMessages}
return CommitReportTracker{seenMessages: seenMessages}
}

func (c *commitReportTracker) visitCommitReport(sourceChainSelector uint64, minSeqNr uint64, maxSeqNr uint64) {
func (c *CommitReportTracker) visitCommitReport(sourceChainSelector uint64, minSeqNr uint64, maxSeqNr uint64) {
if _, ok := c.seenMessages[sourceChainSelector]; !ok {
return
}
Expand All @@ -255,7 +255,7 @@ func (c *commitReportTracker) visitCommitReport(sourceChainSelector uint64, minS
}
}

func (c *commitReportTracker) allCommited(sourceChainSelector uint64) bool {
func (c *CommitReportTracker) allCommited(sourceChainSelector uint64) bool {
for _, v := range c.seenMessages[sourceChainSelector] {
if !v {
return false
Expand Down Expand Up @@ -319,7 +319,7 @@ func ConfirmCommitWithExpectedSeqNumRange(
return nil, fmt.Errorf("error to subscribe CommitReportAccepted : %w", err)
}

seenMessages := newCommitReportTracker(src.Selector, expectedSeqNumRange)
seenMessages := NewCommitReportTracker(src.Selector, expectedSeqNumRange)

defer subscription.Unsubscribe()
var duration time.Duration
Expand Down
163 changes: 124 additions & 39 deletions deployment/environment/crib/ccip_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import (
"fmt"
"math/big"

"github.com/smartcontractkit/chainlink-ccip/chainconfig"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types"

"github.com/ethereum/go-ethereum/common"

"github.com/smartcontractkit/ccip-owner-contracts/pkg/config"

"github.com/smartcontractkit/chainlink-ccip/chainconfig"
cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"

"github.com/smartcontractkit/chainlink/deployment"
Expand Down Expand Up @@ -40,7 +42,24 @@ func DeployHomeChainContracts(ctx context.Context, lggr logger.Logger, envConfig
return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("failed to get node info from env: %w", err)
}
p2pIds := nodes.NonBootstraps().PeerIDs()
cfg := make(map[uint64]commontypes.MCMSWithTimelockConfig)
for _, chain := range e.AllChainSelectors() {
mcmsConfig, err := config.NewConfig(1, []common.Address{e.Chains[chain].DeployerKey.From}, []config.Config{})
if err != nil {
return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("failed to create mcms config: %w", err)
}
cfg[chain] = commontypes.MCMSWithTimelockConfig{
Canceller: *mcmsConfig,
Bypasser: *mcmsConfig,
Proposer: *mcmsConfig,
TimelockMinDelay: big.NewInt(0),
}
}
*e, err = commonchangeset.ApplyChangesets(nil, *e, nil, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployMCMSWithTimelock),
Config: cfg,
},
{
Changeset: commonchangeset.WrapChangeSet(changeset.DeployHomeChainChangeset),
Config: changeset.DeployHomeChainConfig{
Expand Down Expand Up @@ -73,25 +92,14 @@ func DeployHomeChainContracts(ctx context.Context, lggr logger.Logger, envConfig

// DeployCCIPAndAddLanes is the actual ccip setup once the nodes are initialized.
func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig devenv.EnvironmentConfig, homeChainSel, feedChainSel uint64, ab deployment.AddressBook) (DeployCCIPOutput, error) {
e, _, err := devenv.NewEnvironment(func() context.Context { return ctx }, lggr, envConfig)
e, don, err := devenv.NewEnvironment(func() context.Context { return ctx }, lggr, envConfig)
if err != nil {
return DeployCCIPOutput{}, fmt.Errorf("failed to initiate new environment: %w", err)
}
e.ExistingAddresses = ab
chainSelectors := e.AllChainSelectors()
cfg := make(map[uint64]commontypes.MCMSWithTimelockConfig)
var prereqCfgs []changeset.DeployPrerequisiteConfigPerChain
for _, chain := range e.AllChainSelectors() {
mcmsConfig, err := config.NewConfig(1, []common.Address{e.Chains[chain].DeployerKey.From}, []config.Config{})
if err != nil {
return DeployCCIPOutput{}, fmt.Errorf("failed to create mcms config: %w", err)
}
cfg[chain] = commontypes.MCMSWithTimelockConfig{
Canceller: *mcmsConfig,
Bypasser: *mcmsConfig,
Proposer: *mcmsConfig,
TimelockMinDelay: big.NewInt(0),
}
prereqCfgs = append(prereqCfgs, changeset.DeployPrerequisiteConfigPerChain{
ChainSelector: chain,
})
Expand Down Expand Up @@ -139,17 +147,19 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de
Configs: prereqCfgs,
},
},
{
Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployMCMSWithTimelock),
Config: cfg,
},
{
Changeset: commonchangeset.WrapChangeSet(changeset.DeployChainContractsChangeset),
Config: changeset.DeployChainContractsConfig{
HomeChainSelector: homeChainSel,
ContractParamsPerChain: contractParams,
},
},
{
Changeset: commonchangeset.WrapChangeSet(changeset.SetRMNRemoteOnRMNProxyChangeset),
Config: changeset.SetRMNRemoteOnRMNProxyConfig{
ChainSelectors: chainSelectors,
},
},
{
Changeset: commonchangeset.WrapChangeSet(changeset.CCIPCapabilityJobspecChangeset),
Config: struct{}{},
Expand All @@ -159,20 +169,88 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de
if err != nil {
return DeployCCIPOutput{}, fmt.Errorf("failed to load onchain state: %w", err)
}

var ocrConfigPerSelector = make(map[uint64]changeset.CCIPOCRParams)
for selector := range e.Chains {
ocrConfigPerSelector[selector] = changeset.DeriveCCIPOCRParams(changeset.WithDefaultCommitOffChainConfig(feedChainSel, nil),
changeset.WithDefaultExecuteOffChainConfig(nil),
)
}

*e, err = commonchangeset.ApplyChangesets(nil, *e, nil, []commonchangeset.ChangesetApplication{
{
// Add the DONs and candidate commit OCR instances for the chain.
Changeset: commonchangeset.WrapChangeSet(changeset.AddDonAndSetCandidateChangeset),
Config: changeset.AddDonAndSetCandidateChangesetConfig{
SetCandidateConfigBase: changeset.SetCandidateConfigBase{
HomeChainSelector: homeChainSel,
FeedChainSelector: feedChainSel,
},
PluginInfo: changeset.SetCandidatePluginInfo{
OCRConfigPerRemoteChainSelector: ocrConfigPerSelector,
PluginType: types.PluginTypeCCIPCommit,
},
},
},
{
// Add the exec OCR instances for the new chains.
Changeset: commonchangeset.WrapChangeSet(changeset.SetCandidateChangeset),
Config: changeset.SetCandidateChangesetConfig{
SetCandidateConfigBase: changeset.SetCandidateConfigBase{
HomeChainSelector: homeChainSel,
FeedChainSelector: feedChainSel,
},
PluginInfo: []changeset.SetCandidatePluginInfo{
{
OCRConfigPerRemoteChainSelector: ocrConfigPerSelector,
PluginType: types.PluginTypeCCIPExec,
},
},
},
},
{
// Promote everything
Changeset: commonchangeset.WrapChangeSet(changeset.PromoteCandidateChangeset),
Config: changeset.PromoteCandidateChangesetConfig{
HomeChainSelector: homeChainSel,
PluginInfo: []changeset.PromoteCandidatePluginInfo{
{
RemoteChainSelectors: chainSelectors,
PluginType: types.PluginTypeCCIPCommit,
},
{
RemoteChainSelectors: chainSelectors,
PluginType: types.PluginTypeCCIPExec,
},
},
},
},
{
// Enable the OCR config on the remote chains.
Changeset: commonchangeset.WrapChangeSet(changeset.SetOCR3OffRampChangeset),
Config: changeset.SetOCR3OffRampConfig{
HomeChainSel: homeChainSel,
RemoteChainSels: chainSelectors,
},
},
})
if err != nil {
return DeployCCIPOutput{}, fmt.Errorf("failed to apply changesets: %w", err)
}

// Add all lanes
for from := range e.Chains {
for to := range e.Chains {
if from != to {
stateChain1 := state.Chains[from]
for src := range e.Chains {
for dst := range e.Chains {
if src != dst {
stateChain1 := state.Chains[src]
newEnv, err := commonchangeset.ApplyChangesets(nil, *e, nil, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(changeset.UpdateOnRampsDestsChangeset),
Config: changeset.UpdateOnRampDestsConfig{
UpdatesByChain: map[uint64]map[uint64]changeset.OnRampDestinationUpdate{
from: {
to: {
src: {
dst: {
IsEnabled: true,
TestRouter: false,
AllowListEnabled: false,
},
},
Expand All @@ -183,13 +261,13 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de
Changeset: commonchangeset.WrapChangeSet(changeset.UpdateFeeQuoterPricesChangeset),
Config: changeset.UpdateFeeQuoterPricesConfig{
PricesByChain: map[uint64]changeset.FeeQuoterPriceUpdatePerSource{
from: {
src: {
TokenPrices: map[common.Address]*big.Int{
stateChain1.LinkToken.Address(): testhelpers.DefaultLinkPrice,
stateChain1.Weth9.Address(): testhelpers.DefaultWethPrice,
},
GasPrices: map[uint64]*big.Int{
to: testhelpers.DefaultGasPrice,
dst: testhelpers.DefaultGasPrice,
},
},
},
Expand All @@ -199,8 +277,8 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de
Changeset: commonchangeset.WrapChangeSet(changeset.UpdateFeeQuoterDestsChangeset),
Config: changeset.UpdateFeeQuoterDestsConfig{
UpdatesByChain: map[uint64]map[uint64]fee_quoter.FeeQuoterDestChainConfig{
from: {
to: changeset.DefaultFeeQuoterDestChainConfig(),
src: {
dst: changeset.DefaultFeeQuoterDestChainConfig(),
},
},
},
Expand All @@ -209,10 +287,9 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de
Changeset: commonchangeset.WrapChangeSet(changeset.UpdateOffRampSourcesChangeset),
Config: changeset.UpdateOffRampSourcesConfig{
UpdatesByChain: map[uint64]map[uint64]changeset.OffRampSourceUpdate{
to: {
from: {
IsEnabled: true,
TestRouter: true,
dst: {
src: {
IsEnabled: true,
},
},
},
Expand All @@ -221,18 +298,21 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de
{
Changeset: commonchangeset.WrapChangeSet(changeset.UpdateRouterRampsChangeset),
Config: changeset.UpdateRouterRampsConfig{
TestRouter: true,
UpdatesByChain: map[uint64]changeset.RouterUpdates{
// onRamp update on source chain
from: {
src: {
OffRampUpdates: map[uint64]bool{
dst: true,
},
OnRampUpdates: map[uint64]bool{
to: true,
dst: true,
},
},
// off
from: {
dst: {
OffRampUpdates: map[uint64]bool{
to: true,
src: true,
},
OnRampUpdates: map[uint64]bool{
src: true,
},
},
},
Expand All @@ -247,6 +327,11 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de
}
}

// distribute funds to transmitters
// we need to use the nodeinfo from the envConfig here, because multiAddr is not
// populated in the environment variable
distributeFunds(lggr, don.PluginNodes(), *e)

addresses, err := e.ExistingAddresses.Addresses()
if err != nil {
return DeployCCIPOutput{}, fmt.Errorf("failed to get convert address book to address book map: %w", err)
Expand Down
Loading

0 comments on commit a5610fe

Please sign in to comment.