From a7074338e708ee79b9a8d5baa2223b84ccc70347 Mon Sep 17 00:00:00 2001 From: Makram Date: Mon, 9 Dec 2024 20:01:08 +0200 Subject: [PATCH] core/services/ocr2/plugins/ccip: fix racey TestIntegration_CCIP (#15572) Wrap simulated backend with an object that synchronizes Commit() calls --- .../ocr2/plugins/ccip/integration_test.go | 2 - .../ccip/testhelpers/ccip_contracts.go | 28 +- .../ccip/testhelpers/integration/chainlink.go | 3 +- .../ccip/testhelpers/simulated_backend.go | 2 +- .../testhelpers_1_4_0/ccip_contracts_1_4_0.go | 1620 ----------------- .../testhelpers_1_4_0/chainlink.go | 1053 ----------- .../testhelpers_1_4_0/config_1_4_0.go | 75 - .../ccip-tests/contracts/contract_deployer.go | 31 - 8 files changed, 27 insertions(+), 2787 deletions(-) delete mode 100644 core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/ccip_contracts_1_4_0.go delete mode 100644 core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/chainlink.go delete mode 100644 core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/config_1_4_0.go diff --git a/core/services/ocr2/plugins/ccip/integration_test.go b/core/services/ocr2/plugins/ccip/integration_test.go index 15934a261c5..e644a3e6f4a 100644 --- a/core/services/ocr2/plugins/ccip/integration_test.go +++ b/core/services/ocr2/plugins/ccip/integration_test.go @@ -29,8 +29,6 @@ import ( ) func TestIntegration_CCIP(t *testing.T) { - t.Skip("racey test, need to sync backend.Commit() calls") - // Run tke batches of tests for both pipeline and dynamic price getter setups. // We will remove the pipeline batch once the feature is deleted from the code. tests := []struct { diff --git a/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go b/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go index 6a220ececf7..c2fec2903e8 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go @@ -5,6 +5,7 @@ import ( "fmt" "math" "math/big" + "sync" "testing" "time" @@ -168,11 +169,32 @@ type MaybeRevertReceiver struct { Strict bool } +// Backend wraps a simulated backend with a mutex to make it safe for concurrent use +// Commit() in particular has caused races. +type Backend struct { + mu sync.Mutex + *simulated.Backend +} + +func NewBackend(sim *simulated.Backend) *Backend { + return &Backend{ + mu: sync.Mutex{}, + Backend: sim, + } +} + +func (b *Backend) Commit() common.Hash { + b.mu.Lock() + defer b.mu.Unlock() + + return b.Backend.Commit() +} + type Common struct { ChainID uint64 ChainSelector uint64 User *bind.TransactOpts - Chain *simulated.Backend + Chain *Backend LinkToken *link_token_interface.LinkToken LinkTokenPool *lock_release_token_pool.LockReleaseTokenPool CustomToken *link_token_interface.LinkToken @@ -1194,7 +1216,7 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh ChainID: sourceChainID, ChainSelector: sourceChainSelector, User: sourceUser, - Chain: sourceChain, + Chain: NewBackend(sourceChain), LinkToken: sourceLinkToken, LinkTokenPool: sourceLinkPool, CustomToken: sourceCustomToken, @@ -1214,7 +1236,7 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh ChainID: destChainID, ChainSelector: destChainSelector, User: destUser, - Chain: destChain, + Chain: NewBackend(destChain), LinkToken: destLinkToken, LinkTokenPool: destLinkPool, CustomToken: destCustomToken, diff --git a/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go b/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go index ddae5241883..d21c5b12513 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go @@ -17,7 +17,6 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" types3 "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/ethclient/simulated" "github.com/google/uuid" "github.com/hashicorp/consul/sdk/freeport" "github.com/jmoiron/sqlx" @@ -369,7 +368,7 @@ func setupNodeCCIP( owner *bind.TransactOpts, port int64, dbName string, - sourceChain *simulated.Backend, destChain *simulated.Backend, + sourceChain *testhelpers.Backend, destChain *testhelpers.Backend, sourceChainID *big.Int, destChainID *big.Int, bootstrapPeerID string, bootstrapPort int64, diff --git a/core/services/ocr2/plugins/ccip/testhelpers/simulated_backend.go b/core/services/ocr2/plugins/ccip/testhelpers/simulated_backend.go index 58206d37427..699af7e14dc 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/simulated_backend.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/simulated_backend.go @@ -56,7 +56,7 @@ func (ks EthKeyStoreSim) Eth() keystore.Eth { var _ keystore.Eth = EthKeyStoreSim{}.ETHKS -func ConfirmTxs(t *testing.T, txs []*ethtypes.Transaction, chain *simulated.Backend) { +func ConfirmTxs(t *testing.T, txs []*ethtypes.Transaction, chain *Backend) { chain.Commit() ctx := tests.Context(t) for _, tx := range txs { diff --git a/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/ccip_contracts_1_4_0.go b/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/ccip_contracts_1_4_0.go deleted file mode 100644 index 5ed20875498..00000000000 --- a/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/ccip_contracts_1_4_0.go +++ /dev/null @@ -1,1620 +0,0 @@ -package testhelpers_1_4_0 - -import ( - "context" - "fmt" - "math" - "math/big" - "testing" - "time" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/ethclient/simulated" - "github.com/pkg/errors" - "github.com/rs/zerolog/log" - "github.com/stretchr/testify/require" - - "github.com/smartcontractkit/libocr/offchainreporting2/confighelper" - ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2/types" - ocr2types "github.com/smartcontractkit/libocr/offchainreporting2plus/types" - - "github.com/smartcontractkit/chainlink-common/pkg/config" - "github.com/smartcontractkit/chainlink-common/pkg/hashutil" - "github.com/smartcontractkit/chainlink-common/pkg/merklemulti" - cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" - "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" - - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" - burn_mint_token_pool "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/burn_mint_token_pool_1_4_0" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store_1_2_0" - evm_2_evm_offramp "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_offramp_1_2_0" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_onramp_1_2_0" - evm_2_evm_onramp "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_onramp_1_2_0" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/lock_release_token_pool_1_0_0" - lock_release_token_pool "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/lock_release_token_pool_1_4_0" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/maybe_revert_message_receiver" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/mock_rmn_contract" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/price_registry_1_2_0" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_proxy_contract" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/weth9" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/link_token_interface" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/burn_mint_erc677" - "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/testhelpers" -) - -var ( - // Source - SourcePool = "source Link pool" - SourcePriceRegistry = "source PriceRegistry" - OnRamp = "onramp" - OnRampNative = "onramp-native" - SourceRouter = "source router" - - // Dest - OffRamp = "offramp" - DestPool = "dest Link pool" - - Receiver = "receiver" - Sender = "sender" - Link = func(amount int64) *big.Int { return new(big.Int).Mul(big.NewInt(1e18), big.NewInt(amount)) } - HundredLink = Link(100) - LinkUSDValue = func(amount int64) *big.Int { return new(big.Int).Mul(big.NewInt(1e18), big.NewInt(amount)) } - SourceChainID = uint64(1000) - SourceChainSelector = uint64(11787463284727550157) - DestChainID = uint64(1337) - DestChainSelector = uint64(3379446385462418246) -) - -// Backwards compat, in principle these statuses are version dependent -// TODO: Adjust integration tests to be version agnostic using readers -var ( - ExecutionStateSuccess = MessageExecutionState(cciptypes.ExecutionStateSuccess) - ExecutionStateFailure = MessageExecutionState(cciptypes.ExecutionStateFailure) -) - -type MessageExecutionState cciptypes.MessageExecutionState -type CommitOffchainConfig struct { - v1_2_0.JSONCommitOffchainConfig -} - -func (c CommitOffchainConfig) Encode() ([]byte, error) { - return ccipconfig.EncodeOffchainConfig(c.JSONCommitOffchainConfig) -} - -func NewCommitOffchainConfig( - GasPriceHeartBeat config.Duration, - DAGasPriceDeviationPPB uint32, - ExecGasPriceDeviationPPB uint32, - TokenPriceHeartBeat config.Duration, - TokenPriceDeviationPPB uint32, - InflightCacheExpiry config.Duration, - priceReportingDisabled bool) CommitOffchainConfig { - return CommitOffchainConfig{v1_2_0.JSONCommitOffchainConfig{ - GasPriceHeartBeat: GasPriceHeartBeat, - DAGasPriceDeviationPPB: DAGasPriceDeviationPPB, - ExecGasPriceDeviationPPB: ExecGasPriceDeviationPPB, - TokenPriceHeartBeat: TokenPriceHeartBeat, - TokenPriceDeviationPPB: TokenPriceDeviationPPB, - InflightCacheExpiry: InflightCacheExpiry, - PriceReportingDisabled: priceReportingDisabled, - }} -} - -type CommitOnchainConfig struct { - ccipdata.CommitOnchainConfig -} - -func NewCommitOnchainConfig( - PriceRegistry common.Address, -) CommitOnchainConfig { - return CommitOnchainConfig{ccipdata.CommitOnchainConfig{ - PriceRegistry: PriceRegistry, - }} -} - -type ExecOnchainConfig struct { - v1_2_0.ExecOnchainConfig -} - -func NewExecOnchainConfig( - PermissionLessExecutionThresholdSeconds uint32, - Router common.Address, - PriceRegistry common.Address, - MaxNumberOfTokensPerMsg uint16, - MaxDataBytes uint32, - MaxPoolReleaseOrMintGas uint32, -) ExecOnchainConfig { - return ExecOnchainConfig{v1_2_0.ExecOnchainConfig{ - PermissionLessExecutionThresholdSeconds: PermissionLessExecutionThresholdSeconds, - Router: Router, - PriceRegistry: PriceRegistry, - MaxNumberOfTokensPerMsg: MaxNumberOfTokensPerMsg, - MaxDataBytes: MaxDataBytes, - MaxPoolReleaseOrMintGas: MaxPoolReleaseOrMintGas, - }} -} - -type ExecOffchainConfig struct { - v1_2_0.JSONExecOffchainConfig -} - -func (c ExecOffchainConfig) Encode() ([]byte, error) { - return ccipconfig.EncodeOffchainConfig(c.JSONExecOffchainConfig) -} - -func NewExecOffchainConfig( - DestOptimisticConfirmations uint32, - BatchGasLimit uint32, - RelativeBoostPerWaitHour float64, - InflightCacheExpiry config.Duration, - RootSnoozeTime config.Duration, - BatchingStrategyID uint32, -) ExecOffchainConfig { - return ExecOffchainConfig{v1_2_0.JSONExecOffchainConfig{ - DestOptimisticConfirmations: DestOptimisticConfirmations, - BatchGasLimit: BatchGasLimit, - RelativeBoostPerWaitHour: RelativeBoostPerWaitHour, - InflightCacheExpiry: InflightCacheExpiry, - RootSnoozeTime: RootSnoozeTime, - BatchingStrategyID: BatchingStrategyID, - }} -} - -type MaybeRevertReceiver struct { - Receiver *maybe_revert_message_receiver.MaybeRevertMessageReceiver - Strict bool -} - -type Common struct { - ChainID uint64 - ChainSelector uint64 - User *bind.TransactOpts - Chain *simulated.Backend - LinkToken *link_token_interface.LinkToken - LinkTokenPool *lock_release_token_pool.LockReleaseTokenPool - CustomToken *link_token_interface.LinkToken - WrappedNative *weth9.WETH9 - WrappedNativePool *lock_release_token_pool_1_0_0.LockReleaseTokenPool - ARM *mock_rmn_contract.MockRMNContract - ARMProxy *rmn_proxy_contract.RMNProxyContract - PriceRegistry *price_registry_1_2_0.PriceRegistry -} - -type SourceChain struct { - Common - Router *router.Router - OnRamp *evm_2_evm_onramp.EVM2EVMOnRamp -} - -type DestinationChain struct { - Common - - CommitStore *commit_store_1_2_0.CommitStore - Router *router.Router - OffRamp *evm_2_evm_offramp.EVM2EVMOffRamp - Receivers []MaybeRevertReceiver -} - -type OCR2Config struct { - Signers []common.Address - Transmitters []common.Address - F uint8 - OnchainConfig []byte - OffchainConfigVersion uint64 - OffchainConfig []byte -} - -type BalanceAssertion struct { - Name string - Address common.Address - Expected string - Getter func(t *testing.T, addr common.Address) *big.Int - Within string -} - -type BalanceReq struct { - Name string - Addr common.Address - Getter func(t *testing.T, addr common.Address) *big.Int -} - -type CCIPContracts struct { - Source SourceChain - Dest DestinationChain - Oracles []confighelper.OracleIdentityExtra - - commitOCRConfig, execOCRConfig *OCR2Config -} - -func (c *CCIPContracts) DeployNewOffRamp(t *testing.T) { - prevOffRamp := common.HexToAddress("") - if c.Dest.OffRamp != nil { - prevOffRamp = c.Dest.OffRamp.Address() - } - offRampAddress, _, _, err := evm_2_evm_offramp.DeployEVM2EVMOffRamp( - c.Dest.User, - c.Dest.Chain.Client(), - evm_2_evm_offramp.EVM2EVMOffRampStaticConfig{ - CommitStore: c.Dest.CommitStore.Address(), - ChainSelector: c.Dest.ChainSelector, - SourceChainSelector: c.Source.ChainSelector, - OnRamp: c.Source.OnRamp.Address(), - PrevOffRamp: prevOffRamp, - ArmProxy: c.Dest.ARMProxy.Address(), - }, - []common.Address{c.Source.LinkToken.Address()}, // source tokens - []common.Address{c.Dest.LinkTokenPool.Address()}, // pools - evm_2_evm_offramp.RateLimiterConfig{ - IsEnabled: true, - Capacity: LinkUSDValue(100), - Rate: LinkUSDValue(1), - }, - ) - require.NoError(t, err) - c.Dest.Chain.Commit() - - c.Dest.OffRamp, err = evm_2_evm_offramp.NewEVM2EVMOffRamp(offRampAddress, c.Dest.Chain.Client()) - require.NoError(t, err) - - c.Dest.Chain.Commit() - c.Source.Chain.Commit() -} - -func (c *CCIPContracts) EnableOffRamp(t *testing.T) { - _, err := c.Dest.Router.ApplyRampUpdates(c.Dest.User, nil, nil, []router.RouterOffRamp{{SourceChainSelector: SourceChainSelector, OffRamp: c.Dest.OffRamp.Address()}}) - require.NoError(t, err) - c.Dest.Chain.Commit() - - onChainConfig := c.CreateDefaultExecOnchainConfig(t) - offChainConfig := c.CreateDefaultExecOffchainConfig(t) - - c.SetupExecOCR2Config(t, onChainConfig, offChainConfig) -} - -func (c *CCIPContracts) EnableCommitStore(t *testing.T) { - onChainConfig := c.CreateDefaultCommitOnchainConfig(t) - offChainConfig := c.CreateDefaultCommitOffchainConfig(t) - - c.SetupCommitOCR2Config(t, onChainConfig, offChainConfig) - - _, err := c.Dest.PriceRegistry.ApplyPriceUpdatersUpdates(c.Dest.User, []common.Address{c.Dest.CommitStore.Address()}, []common.Address{}) - require.NoError(t, err) - c.Dest.Chain.Commit() -} - -func (c *CCIPContracts) DeployNewOnRamp(t *testing.T) { - t.Log("Deploying new onRamp") - // find the last onRamp - prevOnRamp := common.HexToAddress("") - if c.Source.OnRamp != nil { - prevOnRamp = c.Source.OnRamp.Address() - } - onRampAddress, _, _, err := evm_2_evm_onramp.DeployEVM2EVMOnRamp( - c.Source.User, // user - c.Source.Chain.Client(), // client - evm_2_evm_onramp.EVM2EVMOnRampStaticConfig{ - LinkToken: c.Source.LinkToken.Address(), - ChainSelector: c.Source.ChainSelector, - DestChainSelector: c.Dest.ChainSelector, - DefaultTxGasLimit: 200_000, - MaxNopFeesJuels: big.NewInt(0).Mul(big.NewInt(100_000_000), big.NewInt(1e18)), - PrevOnRamp: prevOnRamp, - ArmProxy: c.Source.ARM.Address(), // ARM - }, - evm_2_evm_onramp.EVM2EVMOnRampDynamicConfig{ - Router: c.Source.Router.Address(), - MaxNumberOfTokensPerMsg: 5, - DestGasOverhead: 350_000, - DestGasPerPayloadByte: 16, - DestDataAvailabilityOverheadGas: 33_596, - DestGasPerDataAvailabilityByte: 16, - DestDataAvailabilityMultiplierBps: 6840, // 0.684 - PriceRegistry: c.Source.PriceRegistry.Address(), - MaxDataBytes: 1e5, - MaxPerMsgGasLimit: 4_000_000, - }, - []evm_2_evm_onramp.InternalPoolUpdate{ - { - Token: c.Source.LinkToken.Address(), - Pool: c.Source.LinkTokenPool.Address(), - }, - }, - evm_2_evm_onramp.RateLimiterConfig{ - IsEnabled: true, - Capacity: LinkUSDValue(100), - Rate: LinkUSDValue(1), - }, - []evm_2_evm_onramp.EVM2EVMOnRampFeeTokenConfigArgs{ - { - Token: c.Source.LinkToken.Address(), - NetworkFeeUSDCents: 1_00, - GasMultiplierWeiPerEth: 1e18, - PremiumMultiplierWeiPerEth: 9e17, - Enabled: true, - }, - { - Token: c.Source.WrappedNative.Address(), - NetworkFeeUSDCents: 1_00, - GasMultiplierWeiPerEth: 1e18, - PremiumMultiplierWeiPerEth: 1e18, - Enabled: true, - }, - }, - []evm_2_evm_onramp.EVM2EVMOnRampTokenTransferFeeConfigArgs{ - { - Token: c.Source.LinkToken.Address(), - MinFeeUSDCents: 50, // $0.5 - MaxFeeUSDCents: 1_000_000_00, // $ 1 million - DeciBps: 5_0, // 5 bps - DestGasOverhead: 34_000, - DestBytesOverhead: 32, - }, - }, - []evm_2_evm_onramp.EVM2EVMOnRampNopAndWeight{}, - ) - - require.NoError(t, err) - c.Source.Chain.Commit() - c.Dest.Chain.Commit() - c.Source.OnRamp, err = evm_2_evm_onramp.NewEVM2EVMOnRamp(onRampAddress, c.Source.Chain.Client()) - require.NoError(t, err) - c.Source.Chain.Commit() - c.Dest.Chain.Commit() -} - -func (c *CCIPContracts) EnableOnRamp(t *testing.T) { - t.Log("Setting onRamp on source router") - _, err := c.Source.Router.ApplyRampUpdates(c.Source.User, []router.RouterOnRamp{{DestChainSelector: c.Dest.ChainSelector, OnRamp: c.Source.OnRamp.Address()}}, nil, nil) - require.NoError(t, err) - c.Source.Chain.Commit() - c.Dest.Chain.Commit() -} - -func (c *CCIPContracts) DeployNewCommitStore(t *testing.T) { - commitStoreAddress, _, _, err := commit_store_1_2_0.DeployCommitStore( - c.Dest.User, // user - c.Dest.Chain.Client(), // client - commit_store_1_2_0.CommitStoreStaticConfig{ - ChainSelector: c.Dest.ChainSelector, - SourceChainSelector: c.Source.ChainSelector, - OnRamp: c.Source.OnRamp.Address(), - ArmProxy: c.Dest.ARMProxy.Address(), - }, - ) - require.NoError(t, err) - c.Dest.Chain.Commit() - // since CommitStoreHelper derives from CommitStore, it's safe to instantiate both on same address - c.Dest.CommitStore, err = commit_store_1_2_0.NewCommitStore(commitStoreAddress, c.Dest.Chain.Client()) - require.NoError(t, err) -} - -func (c *CCIPContracts) DeployNewPriceRegistry(t *testing.T) { - t.Log("Deploying new Price Registry") - destPricesAddress, _, _, err := price_registry_1_2_0.DeployPriceRegistry( - c.Dest.User, - c.Dest.Chain.Client(), - []common.Address{c.Dest.CommitStore.Address()}, - []common.Address{c.Dest.LinkToken.Address()}, - 60*60*24*14, // two weeks - ) - require.NoError(t, err) - c.Source.Chain.Commit() - c.Dest.Chain.Commit() - c.Dest.PriceRegistry, err = price_registry_1_2_0.NewPriceRegistry(destPricesAddress, c.Dest.Chain.Client()) - require.NoError(t, err) - - priceUpdates := price_registry_1_2_0.InternalPriceUpdates{ - TokenPriceUpdates: []price_registry_1_2_0.InternalTokenPriceUpdate{ - { - SourceToken: c.Dest.LinkToken.Address(), - UsdPerToken: big.NewInt(8e18), // 8usd - }, - { - SourceToken: c.Dest.WrappedNative.Address(), - UsdPerToken: big.NewInt(1e18), // 1usd - }, - }, - GasPriceUpdates: []price_registry_1_2_0.InternalGasPriceUpdate{ - { - DestChainSelector: c.Source.ChainSelector, - UsdPerUnitGas: big.NewInt(2000e9), // $2000 per eth * 1gwei = 2000e9 - }, - }, - } - _, err = c.Dest.PriceRegistry.UpdatePrices(c.Dest.User, priceUpdates) - require.NoError(t, err) - - c.Source.Chain.Commit() - c.Dest.Chain.Commit() - - t.Logf("New Price Registry deployed at %s", destPricesAddress.String()) -} - -func (c *CCIPContracts) SetNopsOnRamp(t *testing.T, nopsAndWeights []evm_2_evm_onramp.EVM2EVMOnRampNopAndWeight) { - tx, err := c.Source.OnRamp.SetNops(c.Source.User, nopsAndWeights) - require.NoError(t, err) - c.Source.Chain.Commit() - _, err = bind.WaitMined(tests.Context(t), c.Source.Chain.Client(), tx) - require.NoError(t, err) -} - -func (c *CCIPContracts) GetSourceLinkBalance(t *testing.T, addr common.Address) *big.Int { - return GetBalance(t, c.Source.Chain.Client(), c.Source.LinkToken.Address(), addr) -} - -func (c *CCIPContracts) GetDestLinkBalance(t *testing.T, addr common.Address) *big.Int { - return GetBalance(t, c.Dest.Chain.Client(), c.Dest.LinkToken.Address(), addr) -} - -func (c *CCIPContracts) GetSourceWrappedTokenBalance(t *testing.T, addr common.Address) *big.Int { - return GetBalance(t, c.Source.Chain.Client(), c.Source.WrappedNative.Address(), addr) -} - -func (c *CCIPContracts) GetDestWrappedTokenBalance(t *testing.T, addr common.Address) *big.Int { - return GetBalance(t, c.Dest.Chain.Client(), c.Dest.WrappedNative.Address(), addr) -} - -func (c *CCIPContracts) AssertBalances(t *testing.T, bas []BalanceAssertion) { - for _, b := range bas { - actual := b.Getter(t, b.Address) - t.Log("Checking balance for", b.Name, "at", b.Address.Hex(), "got", actual) - require.NotNil(t, actual, "%v getter return nil", b.Name) - if b.Within == "" { - require.Equal(t, b.Expected, actual.String(), "wrong balance for %s got %s want %s", b.Name, actual, b.Expected) - } else { - bi, _ := big.NewInt(0).SetString(b.Expected, 10) - withinI, _ := big.NewInt(0).SetString(b.Within, 10) - high := big.NewInt(0).Add(bi, withinI) - low := big.NewInt(0).Sub(bi, withinI) - require.Equal(t, -1, actual.Cmp(high), "wrong balance for %s got %s outside expected range [%s, %s]", b.Name, actual, low, high) - require.Equal(t, 1, actual.Cmp(low), "wrong balance for %s got %s outside expected range [%s, %s]", b.Name, actual, low, high) - } - } -} - -func AccountToAddress(accounts []ocr2types.Account) (addresses []common.Address, err error) { - for _, signer := range accounts { - bytes, err := hexutil.Decode(string(signer)) - if err != nil { - return []common.Address{}, errors.Wrap(err, fmt.Sprintf("given address is not valid %s", signer)) - } - if len(bytes) != 20 { - return []common.Address{}, errors.Errorf("address is not 20 bytes %s", signer) - } - addresses = append(addresses, common.BytesToAddress(bytes)) - } - return addresses, nil -} - -func OnchainPublicKeyToAddress(publicKeys []ocrtypes.OnchainPublicKey) (addresses []common.Address, err error) { - for _, signer := range publicKeys { - if len(signer) != 20 { - return []common.Address{}, errors.Errorf("address is not 20 bytes %s", signer) - } - addresses = append(addresses, common.BytesToAddress(signer)) - } - return addresses, nil -} - -func (c *CCIPContracts) DeriveOCR2Config(t *testing.T, oracles []confighelper.OracleIdentityExtra, rawOnchainConfig []byte, rawOffchainConfig []byte) *OCR2Config { - signers, transmitters, threshold, onchainConfig, offchainConfigVersion, offchainConfig, err := confighelper.ContractSetConfigArgsForTests( - 2*time.Second, // deltaProgress - 1*time.Second, // deltaResend - 1*time.Second, // deltaRound - 500*time.Millisecond, // deltaGrace - 2*time.Second, // deltaStage - 3, - []int{1, 1, 1, 1}, - oracles, - rawOffchainConfig, - nil, - 50*time.Millisecond, // Max duration query - 1*time.Second, // Max duration observation - 100*time.Millisecond, - 100*time.Millisecond, - 100*time.Millisecond, - 1, // faults - rawOnchainConfig, - ) - require.NoError(t, err) - lggr := logger.TestLogger(t) - lggr.Infow("Setting Config on Oracle Contract", - "signers", signers, - "transmitters", transmitters, - "threshold", threshold, - "onchainConfig", onchainConfig, - "encodedConfigVersion", offchainConfigVersion, - ) - signerAddresses, err := OnchainPublicKeyToAddress(signers) - require.NoError(t, err) - transmitterAddresses, err := AccountToAddress(transmitters) - require.NoError(t, err) - - return &OCR2Config{ - Signers: signerAddresses, - Transmitters: transmitterAddresses, - F: threshold, - OnchainConfig: onchainConfig, - OffchainConfigVersion: offchainConfigVersion, - OffchainConfig: offchainConfig, - } -} - -func (c *CCIPContracts) SetupCommitOCR2Config(t *testing.T, commitOnchainConfig, commitOffchainConfig []byte) { - c.commitOCRConfig = c.DeriveOCR2Config(t, c.Oracles, commitOnchainConfig, commitOffchainConfig) - // Set the DON on the commit store - _, err := c.Dest.CommitStore.SetOCR2Config( - c.Dest.User, - c.commitOCRConfig.Signers, - c.commitOCRConfig.Transmitters, - c.commitOCRConfig.F, - c.commitOCRConfig.OnchainConfig, - c.commitOCRConfig.OffchainConfigVersion, - c.commitOCRConfig.OffchainConfig, - ) - require.NoError(t, err) - c.Dest.Chain.Commit() -} - -func (c *CCIPContracts) SetupExecOCR2Config(t *testing.T, execOnchainConfig, execOffchainConfig []byte) { - c.execOCRConfig = c.DeriveOCR2Config(t, c.Oracles, execOnchainConfig, execOffchainConfig) - // Same DON on the offramp - _, err := c.Dest.OffRamp.SetOCR2Config( - c.Dest.User, - c.execOCRConfig.Signers, - c.execOCRConfig.Transmitters, - c.execOCRConfig.F, - c.execOCRConfig.OnchainConfig, - c.execOCRConfig.OffchainConfigVersion, - c.execOCRConfig.OffchainConfig, - ) - require.NoError(t, err) - c.Dest.Chain.Commit() -} - -func (c *CCIPContracts) SetupOnchainConfig(t *testing.T, commitOnchainConfig, commitOffchainConfig, execOnchainConfig, execOffchainConfig []byte) int64 { - // Note We do NOT set the payees, payment is done in the OCR2Base implementation - blockBeforeConfig, err := c.Dest.Chain.Client().BlockByNumber(tests.Context(t), nil) - require.NoError(t, err) - - c.SetupCommitOCR2Config(t, commitOnchainConfig, commitOffchainConfig) - c.SetupExecOCR2Config(t, execOnchainConfig, execOffchainConfig) - - return blockBeforeConfig.Number().Int64() -} - -func (c *CCIPContracts) SetupLockAndMintTokenPool( - sourceTokenAddress common.Address, - wrappedTokenName, - wrappedTokenSymbol string) (common.Address, *burn_mint_erc677.BurnMintERC677, error) { - // Deploy dest token & pool - destTokenAddress, _, _, err := burn_mint_erc677.DeployBurnMintERC677(c.Dest.User, c.Dest.Chain.Client(), wrappedTokenName, wrappedTokenSymbol, 18, big.NewInt(0)) - if err != nil { - return [20]byte{}, nil, err - } - c.Dest.Chain.Commit() - - destToken, err := burn_mint_erc677.NewBurnMintERC677(destTokenAddress, c.Dest.Chain.Client()) - if err != nil { - return [20]byte{}, nil, err - } - - destPoolAddress, _, destPool, err := burn_mint_token_pool.DeployBurnMintTokenPool( - c.Dest.User, - c.Dest.Chain.Client(), - destTokenAddress, - []common.Address{}, // pool originalSender allowList - c.Dest.ARMProxy.Address(), - c.Dest.Router.Address(), - ) - if err != nil { - return [20]byte{}, nil, err - } - c.Dest.Chain.Commit() - - _, err = destToken.GrantMintAndBurnRoles(c.Dest.User, destPoolAddress) - if err != nil { - return [20]byte{}, nil, err - } - - _, err = destPool.ApplyChainUpdates(c.Dest.User, - []burn_mint_token_pool.TokenPoolChainUpdate{ - { - RemoteChainSelector: c.Source.ChainSelector, - Allowed: true, - OutboundRateLimiterConfig: burn_mint_token_pool.RateLimiterConfig{ - IsEnabled: true, - Capacity: HundredLink, - Rate: big.NewInt(1e18), - }, - InboundRateLimiterConfig: burn_mint_token_pool.RateLimiterConfig{ - IsEnabled: true, - Capacity: HundredLink, - Rate: big.NewInt(1e18), - }, - }, - }) - if err != nil { - return [20]byte{}, nil, err - } - c.Dest.Chain.Commit() - - sourcePoolAddress, _, sourcePool, err := lock_release_token_pool.DeployLockReleaseTokenPool( - c.Source.User, - c.Source.Chain.Client(), - sourceTokenAddress, - []common.Address{}, // empty allowList at deploy time indicates pool has no original sender restrictions - c.Source.ARMProxy.Address(), - true, - c.Source.Router.Address(), - ) - if err != nil { - return [20]byte{}, nil, err - } - c.Source.Chain.Commit() - - // set onRamp as valid caller for source pool - _, err = sourcePool.ApplyChainUpdates(c.Source.User, []lock_release_token_pool.TokenPoolChainUpdate{ - { - RemoteChainSelector: c.Dest.ChainSelector, - Allowed: true, - OutboundRateLimiterConfig: lock_release_token_pool.RateLimiterConfig{ - IsEnabled: true, - Capacity: HundredLink, - Rate: big.NewInt(1e18), - }, - InboundRateLimiterConfig: lock_release_token_pool.RateLimiterConfig{ - IsEnabled: true, - Capacity: HundredLink, - Rate: big.NewInt(1e18), - }, - }, - }) - if err != nil { - return [20]byte{}, nil, err - } - c.Source.Chain.Commit() - - wrappedNativeAddress, err := c.Source.Router.GetWrappedNative(nil) - if err != nil { - return [20]byte{}, nil, err - } - - // native token is used as fee token - _, err = c.Source.PriceRegistry.UpdatePrices(c.Source.User, price_registry_1_2_0.InternalPriceUpdates{ - TokenPriceUpdates: []price_registry_1_2_0.InternalTokenPriceUpdate{ - { - SourceToken: sourceTokenAddress, - UsdPerToken: big.NewInt(5), - }, - }, - GasPriceUpdates: []price_registry_1_2_0.InternalGasPriceUpdate{}, - }) - if err != nil { - return [20]byte{}, nil, err - } - c.Source.Chain.Commit() - - _, err = c.Source.PriceRegistry.ApplyFeeTokensUpdates(c.Source.User, []common.Address{wrappedNativeAddress}, nil) - if err != nil { - return [20]byte{}, nil, err - } - c.Source.Chain.Commit() - - // add new token pool created above - _, err = c.Source.OnRamp.ApplyPoolUpdates(c.Source.User, nil, []evm_2_evm_onramp.InternalPoolUpdate{ - { - Token: sourceTokenAddress, - Pool: sourcePoolAddress, - }, - }) - if err != nil { - return [20]byte{}, nil, err - } - - _, err = c.Dest.OffRamp.ApplyPoolUpdates(c.Dest.User, nil, []evm_2_evm_offramp.InternalPoolUpdate{ - { - Token: sourceTokenAddress, - Pool: destPoolAddress, - }, - }) - if err != nil { - return [20]byte{}, nil, err - } - c.Dest.Chain.Commit() - - return sourcePoolAddress, destToken, err -} - -func (c *CCIPContracts) SendMessage(t *testing.T, gasLimit, tokenAmount *big.Int, receiverAddr common.Address) { - extraArgs, err := GetEVMExtraArgsV1(gasLimit, false) - require.NoError(t, err) - msg := router.ClientEVM2AnyMessage{ - Receiver: MustEncodeAddress(t, receiverAddr), - Data: []byte("hello"), - TokenAmounts: []router.ClientEVMTokenAmount{ - { - Token: c.Source.LinkToken.Address(), - Amount: tokenAmount, - }, - }, - FeeToken: c.Source.LinkToken.Address(), - ExtraArgs: extraArgs, - } - fee, err := c.Source.Router.GetFee(nil, c.Dest.ChainSelector, msg) - require.NoError(t, err) - // Currently no overhead and 1gwei dest gas price. So fee is simply gasLimit * gasPrice. - // require.Equal(t, new(big.Int).Mul(gasLimit, gasPrice).String(), fee.String()) - // Approve the fee amount + the token amount - _, err = c.Source.LinkToken.Approve(c.Source.User, c.Source.Router.Address(), new(big.Int).Add(fee, tokenAmount)) - require.NoError(t, err) - c.Source.Chain.Commit() - c.SendRequest(t, msg) -} - -func GetBalances(t *testing.T, brs []BalanceReq) (map[string]*big.Int, error) { - m := make(map[string]*big.Int) - for _, br := range brs { - m[br.Name] = br.Getter(t, br.Addr) - if m[br.Name] == nil { - return nil, fmt.Errorf("%v getter return nil", br.Name) - } - } - return m, nil -} - -func MustAddBigInt(a *big.Int, b string) *big.Int { - bi, _ := big.NewInt(0).SetString(b, 10) - return big.NewInt(0).Add(a, bi) -} - -func MustSubBigInt(a *big.Int, b string) *big.Int { - bi, _ := big.NewInt(0).SetString(b, 10) - return big.NewInt(0).Sub(a, bi) -} - -func MustEncodeAddress(t *testing.T, address common.Address) []byte { - bts, err := utils.ABIEncode(`[{"type":"address"}]`, address) - require.NoError(t, err) - return bts -} - -func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destChainID, destChainSelector uint64) CCIPContracts { - sourceChain, sourceUser := testhelpers.SetupChain(t) - destChain, destUser := testhelpers.SetupChain(t) - - sourceChain.Commit() - destChain.Commit() - - armSourceAddress, _, _, err := mock_rmn_contract.DeployMockRMNContract( - sourceUser, - sourceChain.Client(), - ) - require.NoError(t, err) - sourceChain.Commit() - - sourceARM, err := mock_rmn_contract.NewMockRMNContract(armSourceAddress, sourceChain.Client()) - require.NoError(t, err) - armProxySourceAddress, _, _, err := rmn_proxy_contract.DeployRMNProxyContract( - sourceUser, - sourceChain.Client(), - armSourceAddress, - ) - require.NoError(t, err) - sourceChain.Commit() - - sourceARMProxy, err := rmn_proxy_contract.NewRMNProxyContract(armProxySourceAddress, sourceChain.Client()) - require.NoError(t, err) - - armDestAddress, _, _, err := mock_rmn_contract.DeployMockRMNContract( - destUser, - destChain.Client(), - ) - require.NoError(t, err) - destChain.Commit() - - armProxyDestAddress, _, _, err := rmn_proxy_contract.DeployRMNProxyContract( - destUser, - destChain.Client(), - armDestAddress, - ) - require.NoError(t, err) - destChain.Commit() - - destARM, err := mock_rmn_contract.NewMockRMNContract(armDestAddress, destChain.Client()) - require.NoError(t, err) - destARMProxy, err := rmn_proxy_contract.NewRMNProxyContract(armProxyDestAddress, destChain.Client()) - require.NoError(t, err) - - // Deploy link token and pool on source chain - sourceLinkTokenAddress, _, _, err := link_token_interface.DeployLinkToken(sourceUser, sourceChain.Client()) - require.NoError(t, err) - sourceChain.Commit() - sourceLinkToken, err := link_token_interface.NewLinkToken(sourceLinkTokenAddress, sourceChain.Client()) - require.NoError(t, err) - - // Create router - sourceWeth9addr, _, _, err := weth9.DeployWETH9(sourceUser, sourceChain.Client()) - require.NoError(t, err) - sourceChain.Commit() - - sourceWrapped, err := weth9.NewWETH9(sourceWeth9addr, sourceChain.Client()) - require.NoError(t, err) - - sourceRouterAddress, _, _, err := router.DeployRouter(sourceUser, sourceChain.Client(), sourceWeth9addr, armProxySourceAddress) - require.NoError(t, err) - sourceChain.Commit() - - sourceRouter, err := router.NewRouter(sourceRouterAddress, sourceChain.Client()) - require.NoError(t, err) - - sourceWeth9PoolAddress, _, _, err := lock_release_token_pool_1_0_0.DeployLockReleaseTokenPool( - sourceUser, - sourceChain.Client(), - sourceWeth9addr, - []common.Address{}, - armProxySourceAddress, - ) - require.NoError(t, err) - sourceChain.Commit() - - sourceWeth9Pool, err := lock_release_token_pool_1_0_0.NewLockReleaseTokenPool(sourceWeth9PoolAddress, sourceChain.Client()) - require.NoError(t, err) - - sourcePoolAddress, _, _, err := lock_release_token_pool.DeployLockReleaseTokenPool( - sourceUser, - sourceChain.Client(), - sourceLinkTokenAddress, - []common.Address{}, - armProxySourceAddress, - true, - sourceRouterAddress, - ) - require.NoError(t, err) - sourceChain.Commit() - sourcePool, err := lock_release_token_pool.NewLockReleaseTokenPool(sourcePoolAddress, sourceChain.Client()) - require.NoError(t, err) - - // Deploy custom token pool source - sourceCustomTokenAddress, _, _, err := link_token_interface.DeployLinkToken(sourceUser, sourceChain.Client()) // Just re-use this, it's an ERC20. - require.NoError(t, err) - sourceCustomToken, err := link_token_interface.NewLinkToken(sourceCustomTokenAddress, sourceChain.Client()) - require.NoError(t, err) - destChain.Commit() - - // Deploy custom token pool dest - destCustomTokenAddress, _, _, err := link_token_interface.DeployLinkToken(destUser, destChain.Client()) // Just re-use this, it's an ERC20. - require.NoError(t, err) - destCustomToken, err := link_token_interface.NewLinkToken(destCustomTokenAddress, destChain.Client()) - require.NoError(t, err) - destChain.Commit() - - // Deploy and configure onramp - sourcePricesAddress, _, _, err := price_registry_1_2_0.DeployPriceRegistry( - sourceUser, - sourceChain.Client(), - nil, - []common.Address{sourceLinkTokenAddress, sourceWeth9addr}, - 60*60*24*14, // two weeks - ) - require.NoError(t, err) - sourceChain.Commit() - - srcPriceRegistry, err := price_registry_1_2_0.NewPriceRegistry(sourcePricesAddress, sourceChain.Client()) - require.NoError(t, err) - - _, err = srcPriceRegistry.UpdatePrices(sourceUser, price_registry_1_2_0.InternalPriceUpdates{ - TokenPriceUpdates: []price_registry_1_2_0.InternalTokenPriceUpdate{ - { - SourceToken: sourceLinkTokenAddress, - UsdPerToken: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(20)), - }, - { - SourceToken: sourceWeth9addr, - UsdPerToken: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(2000)), - }, - }, - GasPriceUpdates: []price_registry_1_2_0.InternalGasPriceUpdate{ - { - DestChainSelector: destChainSelector, - UsdPerUnitGas: big.NewInt(20000e9), - }, - }, - }) - require.NoError(t, err) - sourceChain.Commit() - - onRampAddress, _, _, err := evm_2_evm_onramp.DeployEVM2EVMOnRamp( - sourceUser, // user - sourceChain.Client(), // client - evm_2_evm_onramp.EVM2EVMOnRampStaticConfig{ - LinkToken: sourceLinkTokenAddress, - ChainSelector: sourceChainSelector, - DestChainSelector: destChainSelector, - DefaultTxGasLimit: 200_000, - MaxNopFeesJuels: big.NewInt(0).Mul(big.NewInt(100_000_000), big.NewInt(1e18)), - PrevOnRamp: common.HexToAddress(""), - ArmProxy: armProxySourceAddress, // ARM - }, - evm_2_evm_onramp.EVM2EVMOnRampDynamicConfig{ - Router: sourceRouterAddress, - MaxNumberOfTokensPerMsg: 5, - DestGasOverhead: 350_000, - DestGasPerPayloadByte: 16, - DestDataAvailabilityOverheadGas: 33_596, - DestGasPerDataAvailabilityByte: 16, - DestDataAvailabilityMultiplierBps: 6840, // 0.684 - PriceRegistry: sourcePricesAddress, - MaxDataBytes: 1e5, - MaxPerMsgGasLimit: 4_000_000, - }, - []evm_2_evm_onramp.InternalPoolUpdate{ - { - Token: sourceLinkTokenAddress, - Pool: sourcePoolAddress, - }, - { - Token: sourceWeth9addr, - Pool: sourceWeth9PoolAddress, - }, - }, - evm_2_evm_onramp.RateLimiterConfig{ - IsEnabled: true, - Capacity: LinkUSDValue(100), - Rate: LinkUSDValue(1), - }, - []evm_2_evm_onramp.EVM2EVMOnRampFeeTokenConfigArgs{ - { - Token: sourceLinkTokenAddress, - NetworkFeeUSDCents: 1_00, - GasMultiplierWeiPerEth: 1e18, - PremiumMultiplierWeiPerEth: 9e17, - Enabled: true, - }, - { - Token: sourceWeth9addr, - NetworkFeeUSDCents: 1_00, - GasMultiplierWeiPerEth: 1e18, - PremiumMultiplierWeiPerEth: 1e18, - Enabled: true, - }, - }, - []evm_2_evm_onramp.EVM2EVMOnRampTokenTransferFeeConfigArgs{ - { - Token: sourceLinkTokenAddress, - MinFeeUSDCents: 50, // $0.5 - MaxFeeUSDCents: 1_000_000_00, // $ 1 million - DeciBps: 5_0, // 5 bps - DestGasOverhead: 34_000, - DestBytesOverhead: 32, - }, - }, - []evm_2_evm_onramp.EVM2EVMOnRampNopAndWeight{}, - ) - require.NoError(t, err) - sourceChain.Commit() - - onRamp, err := evm_2_evm_onramp.NewEVM2EVMOnRamp(onRampAddress, sourceChain.Client()) - require.NoError(t, err) - _, err = sourcePool.ApplyChainUpdates( - sourceUser, - []lock_release_token_pool.TokenPoolChainUpdate{{ - RemoteChainSelector: DestChainSelector, - Allowed: true, - OutboundRateLimiterConfig: lock_release_token_pool.RateLimiterConfig{ - IsEnabled: true, - Capacity: HundredLink, - Rate: big.NewInt(1e18), - }, - InboundRateLimiterConfig: lock_release_token_pool.RateLimiterConfig{ - IsEnabled: true, - Capacity: HundredLink, - Rate: big.NewInt(1e18), - }, - }}, - ) - require.NoError(t, err) - _, err = sourceWeth9Pool.ApplyRampUpdates(sourceUser, - []lock_release_token_pool_1_0_0.TokenPoolRampUpdate{{Ramp: onRampAddress, Allowed: true, - RateLimiterConfig: lock_release_token_pool_1_0_0.RateLimiterConfig{ - IsEnabled: true, - Capacity: HundredLink, - Rate: big.NewInt(1e18), - }, - }}, - []lock_release_token_pool_1_0_0.TokenPoolRampUpdate{}, - ) - require.NoError(t, err) - sourceChain.Commit() - _, err = sourceRouter.ApplyRampUpdates(sourceUser, []router.RouterOnRamp{{DestChainSelector: destChainSelector, OnRamp: onRampAddress}}, nil, nil) - require.NoError(t, err) - sourceChain.Commit() - - destWethaddr, _, _, err := weth9.DeployWETH9(destUser, destChain.Client()) - require.NoError(t, err) - destChain.Commit() - destWrapped, err := weth9.NewWETH9(destWethaddr, destChain.Client()) - require.NoError(t, err) - - // Create dest router - destRouterAddress, _, _, err := router.DeployRouter(destUser, destChain.Client(), destWethaddr, armProxyDestAddress) - require.NoError(t, err) - destChain.Commit() - destRouter, err := router.NewRouter(destRouterAddress, destChain.Client()) - require.NoError(t, err) - - // Deploy link token and pool on destination chain - destLinkTokenAddress, _, _, err := link_token_interface.DeployLinkToken(destUser, destChain.Client()) - require.NoError(t, err) - destChain.Commit() - destLinkToken, err := link_token_interface.NewLinkToken(destLinkTokenAddress, destChain.Client()) - require.NoError(t, err) - destPoolAddress, _, _, err := lock_release_token_pool.DeployLockReleaseTokenPool( - destUser, - destChain.Client(), - destLinkTokenAddress, - []common.Address{}, - armProxyDestAddress, - true, - destRouterAddress, - ) - require.NoError(t, err) - destChain.Commit() - destPool, err := lock_release_token_pool.NewLockReleaseTokenPool(destPoolAddress, destChain.Client()) - require.NoError(t, err) - destChain.Commit() - - // Float the offramp pool - o, err := destPool.Owner(nil) - require.NoError(t, err) - require.Equal(t, destUser.From.String(), o.String()) - _, err = destPool.SetRebalancer(destUser, destUser.From) - require.NoError(t, err) - _, err = destLinkToken.Approve(destUser, destPoolAddress, Link(200)) - require.NoError(t, err) - destChain.Commit() - _, err = destPool.ProvideLiquidity(destUser, Link(200)) - require.NoError(t, err) - destChain.Commit() - - destWrappedPoolAddress, _, _, err := lock_release_token_pool_1_0_0.DeployLockReleaseTokenPool( - destUser, - destChain.Client(), - destWethaddr, - []common.Address{}, - armProxyDestAddress, - ) - require.NoError(t, err) - destChain.Commit() - destWrappedPool, err := lock_release_token_pool_1_0_0.NewLockReleaseTokenPool(destWrappedPoolAddress, destChain.Client()) - require.NoError(t, err) - - poolFloatValue := big.NewInt(1e18) - - destUser.Value = poolFloatValue - _, err = destWrapped.Deposit(destUser) - require.NoError(t, err) - destChain.Commit() - destUser.Value = nil - - _, err = destWrapped.Transfer(destUser, destWrappedPool.Address(), poolFloatValue) - require.NoError(t, err) - destChain.Commit() - - // Deploy and configure ge offramp. - destPricesAddress, _, _, err := price_registry_1_2_0.DeployPriceRegistry( - destUser, - destChain.Client(), - nil, - []common.Address{destLinkTokenAddress}, - 60*60*24*14, // two weeks - ) - require.NoError(t, err) - destChain.Commit() - - destPriceRegistry, err := price_registry_1_2_0.NewPriceRegistry(destPricesAddress, destChain.Client()) - require.NoError(t, err) - - // Deploy commit store. - commitStoreAddress, _, _, err := commit_store_1_2_0.DeployCommitStore( - destUser, // user - destChain.Client(), // client - commit_store_1_2_0.CommitStoreStaticConfig{ - ChainSelector: destChainSelector, - SourceChainSelector: sourceChainSelector, - OnRamp: onRamp.Address(), - ArmProxy: destARMProxy.Address(), - }, - ) - require.NoError(t, err) - destChain.Commit() - commitStore, err := commit_store_1_2_0.NewCommitStore(commitStoreAddress, destChain.Client()) - require.NoError(t, err) - - offRampAddress, _, _, err := evm_2_evm_offramp.DeployEVM2EVMOffRamp( - destUser, - destChain.Client(), - evm_2_evm_offramp.EVM2EVMOffRampStaticConfig{ - CommitStore: commitStore.Address(), - ChainSelector: destChainSelector, - SourceChainSelector: sourceChainSelector, - OnRamp: onRampAddress, - PrevOffRamp: common.HexToAddress(""), - ArmProxy: armProxyDestAddress, - }, - []common.Address{sourceLinkTokenAddress, sourceWeth9addr}, - []common.Address{destPoolAddress, destWrappedPool.Address()}, - evm_2_evm_offramp.RateLimiterConfig{ - IsEnabled: true, - Capacity: LinkUSDValue(100), - Rate: LinkUSDValue(1), - }, - ) - require.NoError(t, err) - destChain.Commit() - - offRamp, err := evm_2_evm_offramp.NewEVM2EVMOffRamp(offRampAddress, destChain.Client()) - require.NoError(t, err) - _, err = destPool.ApplyChainUpdates(destUser, - []lock_release_token_pool.TokenPoolChainUpdate{{ - RemoteChainSelector: sourceChainSelector, - Allowed: true, - OutboundRateLimiterConfig: lock_release_token_pool.RateLimiterConfig{ - IsEnabled: true, - Capacity: HundredLink, - Rate: big.NewInt(1e18), - }, - InboundRateLimiterConfig: lock_release_token_pool.RateLimiterConfig{ - IsEnabled: true, - Capacity: HundredLink, - Rate: big.NewInt(1e18), - }, - }}, - ) - require.NoError(t, err) - - _, err = destWrappedPool.ApplyRampUpdates(destUser, - []lock_release_token_pool_1_0_0.TokenPoolRampUpdate{}, - []lock_release_token_pool_1_0_0.TokenPoolRampUpdate{{ - Ramp: offRampAddress, - Allowed: true, - RateLimiterConfig: lock_release_token_pool_1_0_0.RateLimiterConfig{ - IsEnabled: true, - Capacity: HundredLink, - Rate: big.NewInt(1e18), - }, - }}, - ) - require.NoError(t, err) - - destChain.Commit() - _, err = destPriceRegistry.ApplyPriceUpdatersUpdates(destUser, []common.Address{commitStoreAddress}, []common.Address{}) - require.NoError(t, err) - destChain.Commit() - - _, err = destRouter.ApplyRampUpdates(destUser, nil, - nil, []router.RouterOffRamp{{SourceChainSelector: sourceChainSelector, OffRamp: offRampAddress}}) - require.NoError(t, err) - destChain.Commit() - - // Deploy 2 revertable (one SS one non-SS) - revertingMessageReceiver1Address, _, _, err := maybe_revert_message_receiver.DeployMaybeRevertMessageReceiver(destUser, destChain.Client(), false) - require.NoError(t, err) - revertingMessageReceiver1, _ := maybe_revert_message_receiver.NewMaybeRevertMessageReceiver(revertingMessageReceiver1Address, destChain.Client()) - revertingMessageReceiver2Address, _, _, err := maybe_revert_message_receiver.DeployMaybeRevertMessageReceiver(destUser, destChain.Client(), false) - require.NoError(t, err) - revertingMessageReceiver2, _ := maybe_revert_message_receiver.NewMaybeRevertMessageReceiver(revertingMessageReceiver2Address, destChain.Client()) - // Need to commit here, or we will hit the block gas limit when deploying the executor - sourceChain.Commit() - destChain.Commit() - - // Ensure we have at least finality blocks. - for i := 0; i < 50; i++ { - sourceChain.Commit() - destChain.Commit() - } - - source := SourceChain{ - Common: Common{ - ChainID: sourceChainID, - ChainSelector: sourceChainSelector, - User: sourceUser, - Chain: sourceChain, - LinkToken: sourceLinkToken, - LinkTokenPool: sourcePool, - CustomToken: sourceCustomToken, - ARM: sourceARM, - ARMProxy: sourceARMProxy, - PriceRegistry: srcPriceRegistry, - WrappedNative: sourceWrapped, - WrappedNativePool: sourceWeth9Pool, - }, - Router: sourceRouter, - OnRamp: onRamp, - } - dest := DestinationChain{ - Common: Common{ - ChainID: destChainID, - ChainSelector: destChainSelector, - User: destUser, - Chain: destChain, - LinkToken: destLinkToken, - LinkTokenPool: destPool, - CustomToken: destCustomToken, - ARM: destARM, - ARMProxy: destARMProxy, - PriceRegistry: destPriceRegistry, - WrappedNative: destWrapped, - WrappedNativePool: destWrappedPool, - }, - CommitStore: commitStore, - Router: destRouter, - OffRamp: offRamp, - Receivers: []MaybeRevertReceiver{{Receiver: revertingMessageReceiver1, Strict: false}, {Receiver: revertingMessageReceiver2, Strict: true}}, - } - - return CCIPContracts{ - Source: source, - Dest: dest, - } -} - -func (c *CCIPContracts) SendRequest(t *testing.T, msg router.ClientEVM2AnyMessage) *types.Transaction { - tx, err := c.Source.Router.CcipSend(c.Source.User, c.Dest.ChainSelector, msg) - require.NoError(t, err) - testhelpers.ConfirmTxs(t, []*types.Transaction{tx}, c.Source.Chain) - return tx -} - -func (c *CCIPContracts) AssertExecState(t *testing.T, log logpoller.Log, state MessageExecutionState, offRampOpts ...common.Address) { - var offRamp *evm_2_evm_offramp.EVM2EVMOffRamp - var err error - if len(offRampOpts) > 0 { - offRamp, err = evm_2_evm_offramp.NewEVM2EVMOffRamp(offRampOpts[0], c.Dest.Chain.Client()) - require.NoError(t, err) - } else { - require.NotNil(t, c.Dest.OffRamp, "no offRamp configured") - offRamp = c.Dest.OffRamp - } - executionStateChanged, err := offRamp.ParseExecutionStateChanged(log.ToGethLog()) - require.NoError(t, err) - if MessageExecutionState(executionStateChanged.State) != state { - t.Log("Execution failed", hexutil.Encode(executionStateChanged.ReturnData)) - t.Fail() - } -} - -func GetEVMExtraArgsV1(gasLimit *big.Int, strict bool) ([]byte, error) { - EVMV1Tag := []byte{0x97, 0xa6, 0x57, 0xc9} - - encodedArgs, err := utils.ABIEncode(`[{"type":"uint256"},{"type":"bool"}]`, gasLimit, strict) - if err != nil { - return nil, err - } - - return append(EVMV1Tag, encodedArgs...), nil -} - -type ManualExecArgs struct { - SourceChainID, DestChainID uint64 - DestUser *bind.TransactOpts - SourceChain, DestChain bind.ContractBackend - SourceStartBlock *big.Int // the block in/after which failed ccip-send transaction was triggered - DestStartBlock uint64 // the start block for filtering ReportAccepted event (including the failed seq num) - // in destination chain. if not provided to be derived by ApproxDestStartBlock method - DestLatestBlockNum uint64 // current block number in destination - DestDeployedAt uint64 // destination block number for the initial destination contract deployment. - // Can be any number before the tx was reverted in destination chain. Preferably this needs to be set up with - // a value greater than zero to avoid performance issue in locating approximate destination block - SendReqLogIndex uint // log index of the CCIPSendRequested log in source chain - SendReqTxHash string // tx hash of the ccip-send transaction for which execution was reverted - CommitStore string - OnRamp string - OffRamp string - SeqNr uint64 - GasLimit *big.Int -} - -// ApproxDestStartBlock attempts to locate a block in destination chain with timestamp closest to the timestamp of the block -// in source chain in which ccip-send transaction was included -// it uses binary search to locate the block with the closest timestamp -// if the block located has a timestamp greater than the timestamp of mentioned source block -// it just returns the first block found with lesser timestamp of the source block -// providing a value of args.DestDeployedAt ensures better performance by reducing the range of block numbers to be traversed -func (args *ManualExecArgs) ApproxDestStartBlock(ctx context.Context) error { - sourceBlockHdr, err := args.SourceChain.HeaderByNumber(ctx, args.SourceStartBlock) - if err != nil { - return err - } - sendTxTime := sourceBlockHdr.Time - maxBlockNum := args.DestLatestBlockNum - // setting this to an approx value of 1000 considering destination chain would have at least 1000 blocks before the transaction started - minBlockNum := args.DestDeployedAt - closestBlockNum := uint64(math.Floor((float64(maxBlockNum) + float64(minBlockNum)) / 2)) - var closestBlockHdr *types.Header - closestBlockHdr, err = args.DestChain.HeaderByNumber(ctx, new(big.Int).SetUint64(closestBlockNum)) - if err != nil { - return err - } - // to reduce the number of RPC calls increase the value of blockOffset - blockOffset := uint64(10) - for { - blockNum := closestBlockHdr.Number.Uint64() - if minBlockNum > maxBlockNum { - break - } - timeDiff := math.Abs(float64(closestBlockHdr.Time - sendTxTime)) - // break if the difference in timestamp is lesser than 1 minute - if timeDiff < 60 { - break - } else if closestBlockHdr.Time > sendTxTime { - maxBlockNum = blockNum - 1 - } else { - minBlockNum = blockNum + 1 - } - closestBlockNum = uint64(math.Floor((float64(maxBlockNum) + float64(minBlockNum)) / 2)) - closestBlockHdr, err = args.DestChain.HeaderByNumber(ctx, new(big.Int).SetUint64(closestBlockNum)) - if err != nil { - return err - } - } - - for closestBlockHdr.Time > sendTxTime { - closestBlockNum = closestBlockNum - blockOffset - if closestBlockNum <= 0 { - return fmt.Errorf("approx destination blocknumber not found") - } - closestBlockHdr, err = args.DestChain.HeaderByNumber(ctx, new(big.Int).SetUint64(closestBlockNum)) - if err != nil { - return err - } - } - args.DestStartBlock = closestBlockHdr.Number.Uint64() - fmt.Println("using approx destination start block number", args.DestStartBlock) - return nil -} - -func (args *ManualExecArgs) FindSeqNrFromCCIPSendRequested() (uint64, error) { - var seqNr uint64 - onRampContract, err := evm_2_evm_onramp.NewEVM2EVMOnRamp(common.HexToAddress(args.OnRamp), args.SourceChain) - if err != nil { - return seqNr, err - } - iterator, err := onRampContract.FilterCCIPSendRequested(&bind.FilterOpts{ - Start: args.SourceStartBlock.Uint64(), - }) - if err != nil { - return seqNr, err - } - for iterator.Next() { - if iterator.Event.Raw.Index == args.SendReqLogIndex && - iterator.Event.Raw.TxHash.Hex() == args.SendReqTxHash { - seqNr = iterator.Event.Message.SequenceNumber - break - } - } - if seqNr == 0 { - return seqNr, - fmt.Errorf("no CCIPSendRequested logs found for logIndex %d starting from block number %d", args.SendReqLogIndex, args.SourceStartBlock) - } - return seqNr, nil -} - -func (args *ManualExecArgs) ExecuteManually(ctx context.Context) (*types.Transaction, error) { - if args.SourceChainID == 0 || - args.DestChainID == 0 || - args.DestUser == nil { - return nil, fmt.Errorf("chain ids and owners are mandatory for source and dest chain") - } - if !common.IsHexAddress(args.CommitStore) || - !common.IsHexAddress(args.OffRamp) || - !common.IsHexAddress(args.OnRamp) { - return nil, fmt.Errorf("contract addresses must be valid hex address") - } - if args.SendReqTxHash == "" { - return nil, fmt.Errorf("tx hash of ccip-send request are required") - } - if args.SourceStartBlock == nil { - return nil, fmt.Errorf("must provide the value of source block in/after which ccip-send tx was included") - } - if args.SeqNr == 0 { - if args.SendReqLogIndex == 0 { - return nil, fmt.Errorf("must provide the value of log index of ccip-send request") - } - // locate seq nr from CCIPSendRequested log - seqNr, err := args.FindSeqNrFromCCIPSendRequested() - if err != nil { - return nil, err - } - args.SeqNr = seqNr - } - commitStore, err := commit_store_1_2_0.NewCommitStore(common.HexToAddress(args.CommitStore), args.DestChain) - if err != nil { - return nil, err - } - if args.DestStartBlock < 1 { - err = args.ApproxDestStartBlock(ctx) - if err != nil { - return nil, err - } - } - iterator, err := commitStore.FilterReportAccepted(&bind.FilterOpts{Start: args.DestStartBlock}) - if err != nil { - return nil, err - } - - var commitReport *commit_store_1_2_0.CommitStoreCommitReport - for iterator.Next() { - if iterator.Event.Report.Interval.Min <= args.SeqNr && iterator.Event.Report.Interval.Max >= args.SeqNr { - commitReport = &iterator.Event.Report - fmt.Println("Found root") - break - } - } - if commitReport == nil { - return nil, fmt.Errorf("unable to find seq num %d in commit report", args.SeqNr) - } - - return args.execute(commitReport) -} - -func (args *ManualExecArgs) execute(report *commit_store_1_2_0.CommitStoreCommitReport) (*types.Transaction, error) { - log.Info().Msg("Executing request manually") - seqNr := args.SeqNr - // Build a merkle tree for the report - mctx := hashutil.NewKeccak() - onRampContract, err := evm_2_evm_onramp_1_2_0.NewEVM2EVMOnRamp(common.HexToAddress(args.OnRamp), args.SourceChain) - if err != nil { - return nil, err - } - leafHasher := v1_2_0.NewLeafHasher(args.SourceChainID, args.DestChainID, common.HexToAddress(args.OnRamp), mctx, onRampContract) - if leafHasher == nil { - return nil, fmt.Errorf("unable to create leaf hasher") - } - - var leaves [][32]byte - var curr, prove int - var msgs []evm_2_evm_offramp.InternalEVM2EVMMessage - var manualExecGasLimits []*big.Int - var tokenData [][][]byte - sendRequestedIterator, err := onRampContract.FilterCCIPSendRequested(&bind.FilterOpts{ - Start: args.SourceStartBlock.Uint64(), - }) - if err != nil { - return nil, err - } - for sendRequestedIterator.Next() { - if sendRequestedIterator.Event.Message.SequenceNumber <= report.Interval.Max && - sendRequestedIterator.Event.Message.SequenceNumber >= report.Interval.Min { - fmt.Println("Found seq num", sendRequestedIterator.Event.Message.SequenceNumber, report.Interval) - hash, err2 := leafHasher.HashLeaf(sendRequestedIterator.Event.Raw) - if err2 != nil { - return nil, err2 - } - leaves = append(leaves, hash) - if sendRequestedIterator.Event.Message.SequenceNumber == seqNr { - fmt.Printf("Found proving %d %+v\n", curr, sendRequestedIterator.Event.Message) - var tokensAndAmounts []evm_2_evm_offramp.ClientEVMTokenAmount - for _, tokenAndAmount := range sendRequestedIterator.Event.Message.TokenAmounts { - tokensAndAmounts = append(tokensAndAmounts, evm_2_evm_offramp.ClientEVMTokenAmount{ - Token: tokenAndAmount.Token, - Amount: tokenAndAmount.Amount, - }) - } - msg := evm_2_evm_offramp.InternalEVM2EVMMessage{ - SourceChainSelector: sendRequestedIterator.Event.Message.SourceChainSelector, - Sender: sendRequestedIterator.Event.Message.Sender, - Receiver: sendRequestedIterator.Event.Message.Receiver, - SequenceNumber: sendRequestedIterator.Event.Message.SequenceNumber, - GasLimit: sendRequestedIterator.Event.Message.GasLimit, - Strict: sendRequestedIterator.Event.Message.Strict, - Nonce: sendRequestedIterator.Event.Message.Nonce, - FeeToken: sendRequestedIterator.Event.Message.FeeToken, - FeeTokenAmount: sendRequestedIterator.Event.Message.FeeTokenAmount, - Data: sendRequestedIterator.Event.Message.Data, - TokenAmounts: tokensAndAmounts, - SourceTokenData: sendRequestedIterator.Event.Message.SourceTokenData, - MessageId: sendRequestedIterator.Event.Message.MessageId, - } - msgs = append(msgs, msg) - if args.GasLimit != nil { - msg.GasLimit = args.GasLimit - } - manualExecGasLimits = append(manualExecGasLimits, msg.GasLimit) - var msgTokenData [][]byte - for range sendRequestedIterator.Event.Message.TokenAmounts { - msgTokenData = append(msgTokenData, []byte{}) - } - - tokenData = append(tokenData, msgTokenData) - prove = curr - } - curr++ - } - } - sendRequestedIterator.Close() - if msgs == nil { - return nil, fmt.Errorf("unable to find msg with seqNr %d", seqNr) - } - tree, err := merklemulti.NewTree(mctx, leaves) - if err != nil { - return nil, err - } - if tree.Root() != report.MerkleRoot { - return nil, fmt.Errorf("root doesn't match") - } - - proof, err := tree.Prove([]int{prove}) - if err != nil { - return nil, err - } - - offRampProof := evm_2_evm_offramp.InternalExecutionReport{ - Messages: msgs, - OffchainTokenData: tokenData, - Proofs: proof.Hashes, - ProofFlagBits: abihelpers.ProofFlagsToBits(proof.SourceFlags), - } - offRamp, err := evm_2_evm_offramp.NewEVM2EVMOffRamp(common.HexToAddress(args.OffRamp), args.DestChain) - if err != nil { - return nil, err - } - // Execute. - return offRamp.ManuallyExecute(args.DestUser, offRampProof, manualExecGasLimits) -} - -func (c *CCIPContracts) ExecuteMessage( - t *testing.T, - req logpoller.Log, - txHash common.Hash, - destStartBlock uint64, -) uint64 { - t.Log("Executing request manually") - ctx := tests.Context(t) - sendReqReceipt, err := c.Source.Chain.Client().TransactionReceipt(ctx, txHash) - require.NoError(t, err) - destLatest, err := c.Dest.Chain.Client().BlockByNumber(context.Background(), nil) - require.NoError(t, err) - args := ManualExecArgs{ - SourceChainID: c.Source.ChainID, - DestChainID: c.Dest.ChainID, - DestUser: c.Dest.User, - SourceChain: c.Source.Chain.Client(), - DestChain: c.Dest.Chain.Client(), - SourceStartBlock: sendReqReceipt.BlockNumber, - DestStartBlock: destStartBlock, - DestLatestBlockNum: destLatest.NumberU64(), - SendReqLogIndex: uint(req.LogIndex), - SendReqTxHash: txHash.String(), - CommitStore: c.Dest.CommitStore.Address().String(), - OnRamp: c.Source.OnRamp.Address().String(), - OffRamp: c.Dest.OffRamp.Address().String(), - } - tx, err := args.ExecuteManually(ctx) - require.NoError(t, err) - c.Dest.Chain.Commit() - c.Source.Chain.Commit() - rec, err := c.Dest.Chain.Client().TransactionReceipt(tests.Context(t), tx.Hash()) - require.NoError(t, err) - require.Equal(t, uint64(1), rec.Status, "manual execution failed") - t.Logf("Manual Execution completed for seqNum %d", args.SeqNr) - return args.SeqNr -} - -func GetBalance(t *testing.T, chain bind.ContractBackend, tokenAddr common.Address, addr common.Address) *big.Int { - token, err := link_token_interface.NewLinkToken(tokenAddr, chain) - require.NoError(t, err) - bal, err := token.BalanceOf(nil, addr) - require.NoError(t, err) - return bal -} diff --git a/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/chainlink.go b/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/chainlink.go deleted file mode 100644 index 30aaebd4e9e..00000000000 --- a/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/chainlink.go +++ /dev/null @@ -1,1053 +0,0 @@ -package testhelpers_1_4_0 - -import ( - "context" - "encoding/hex" - "fmt" - "math" - "math/big" - "net/http" - "net/http/httptest" - "strconv" - "strings" - "testing" - "time" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - types3 "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/ethclient/simulated" - "github.com/google/uuid" - "github.com/hashicorp/consul/sdk/freeport" - "github.com/jmoiron/sqlx" - "github.com/onsi/gomega" - "github.com/pkg/errors" - "k8s.io/utils/ptr" - - "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/require" - "go.uber.org/zap" - - "github.com/smartcontractkit/libocr/commontypes" - "github.com/smartcontractkit/libocr/offchainreporting2/confighelper" - types4 "github.com/smartcontractkit/libocr/offchainreporting2plus/types" - - "github.com/smartcontractkit/chainlink-common/pkg/config" - "github.com/smartcontractkit/chainlink-common/pkg/loop" - "github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox" - "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" - - cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" - coretypes "github.com/smartcontractkit/chainlink-common/pkg/types/core/mocks" - - pb "github.com/smartcontractkit/chainlink-protos/orchestrator/feedsmanager" - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" - v2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" - evmUtils "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" - "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" - configv2 "github.com/smartcontractkit/chainlink/v2/core/config/toml" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store_1_2_0" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_offramp_1_2_0" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_onramp_1_2_0" - "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/logger/audit" - "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - feeds2 "github.com/smartcontractkit/chainlink/v2/core/services/feeds" - feedsMocks "github.com/smartcontractkit/chainlink/v2/core/services/feeds/mocks" - "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/csakey" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocr2key" - ksMocks "github.com/smartcontractkit/chainlink/v2/core/services/keystore/mocks" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/testhelpers" - integrationtesthelpers "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/testhelpers/integration" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/validate" - "github.com/smartcontractkit/chainlink/v2/core/services/ocrbootstrap" - evmrelay "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm" - clutils "github.com/smartcontractkit/chainlink/v2/core/utils" - "github.com/smartcontractkit/chainlink/v2/core/utils/crypto" - "github.com/smartcontractkit/chainlink/v2/core/utils/testutils/heavyweight" - "github.com/smartcontractkit/chainlink/v2/plugins" -) - -const ( - execSpecTemplate = ` - type = "offchainreporting2" - schemaVersion = 1 - name = "ccip-exec-1" - externalJobID = "67ffad71-d90f-4fe3-b4e4-494924b707fb" - forwardingAllowed = false - maxTaskDuration = "0s" - contractID = "%s" - contractConfigConfirmations = 1 - contractConfigTrackerPollInterval = "20s" - ocrKeyBundleID = "%s" - relay = "evm" - pluginType = "ccip-execution" - transmitterID = "%s" - - [relayConfig] - chainID = 1_337 - - [pluginConfig] - destStartBlock = 50 - - [pluginConfig.USDCConfig] - AttestationAPI = "http://blah.com" - SourceMessageTransmitterAddress = "%s" - SourceTokenAddress = "%s" - AttestationAPITimeoutSeconds = 10 - ` - commitSpecTemplatePipeline = ` - type = "offchainreporting2" - schemaVersion = 1 - name = "ccip-commit-1" - externalJobID = "13c997cf-1a14-4ab7-9068-07ee6d2afa55" - forwardingAllowed = false - maxTaskDuration = "0s" - contractID = "%s" - contractConfigConfirmations = 1 - contractConfigTrackerPollInterval = "20s" - ocrKeyBundleID = "%s" - relay = "evm" - pluginType = "ccip-commit" - transmitterID = "%s" - - [relayConfig] - chainID = 1_337 - - [pluginConfig] - destStartBlock = 50 - offRamp = "%s" - tokenPricesUSDPipeline = """ - %s - """ - ` - commitSpecTemplateDynamicPriceGetter = ` - type = "offchainreporting2" - schemaVersion = 1 - name = "ccip-commit-1" - externalJobID = "13c997cf-1a14-4ab7-9068-07ee6d2afa55" - forwardingAllowed = false - maxTaskDuration = "0s" - contractID = "%s" - contractConfigConfirmations = 1 - contractConfigTrackerPollInterval = "20s" - ocrKeyBundleID = "%s" - relay = "evm" - pluginType = "ccip-commit" - transmitterID = "%s" - - [relayConfig] - chainID = 1_337 - - [pluginConfig] - destStartBlock = 50 - offRamp = "%s" - priceGetterConfig = """ - %s - """ - ` -) - -type Node struct { - App chainlink.Application - Transmitter common.Address - PaymentReceiver common.Address - KeyBundle ocr2key.KeyBundle -} - -func (node *Node) FindJobIDForContract(t *testing.T, addr common.Address) int32 { - jobs := node.App.JobSpawner().ActiveJobs() - for _, j := range jobs { - if j.Type == job.OffchainReporting2 && j.OCR2OracleSpec.ContractID == addr.Hex() { - return j.ID - } - } - t.Fatalf("Could not find job for contract %s", addr.Hex()) - return 0 -} - -func (node *Node) EventuallyNodeUsesUpdatedPriceRegistry(t *testing.T, ccipContracts CCIPIntegrationTestHarness) logpoller.Log { - c, err := node.App.GetRelayers().LegacyEVMChains().Get(strconv.FormatUint(ccipContracts.Dest.ChainID, 10)) - require.NoError(t, err) - var log logpoller.Log - gomega.NewGomegaWithT(t).Eventually(func() bool { - ccipContracts.Source.Chain.Commit() - ccipContracts.Dest.Chain.Commit() - log, err := c.LogPoller().LatestLogByEventSigWithConfs( - testutils.Context(t), - v1_2_0.UsdPerUnitGasUpdated, - ccipContracts.Dest.PriceRegistry.Address(), - 0, - ) - // err can be transient errors such as sql row set empty - if err != nil { - return false - } - return log != nil - }, testutils.WaitTimeout(t), 1*time.Second).Should(gomega.BeTrue(), "node is not using updated price registry %s", ccipContracts.Dest.PriceRegistry.Address().Hex()) - return log -} - -func (node *Node) EventuallyNodeUsesNewCommitConfig(t *testing.T, ccipContracts CCIPIntegrationTestHarness, commitCfg ccipdata.CommitOnchainConfig) logpoller.Log { - c, err := node.App.GetRelayers().LegacyEVMChains().Get(strconv.FormatUint(ccipContracts.Dest.ChainID, 10)) - require.NoError(t, err) - var log logpoller.Log - gomega.NewGomegaWithT(t).Eventually(func() bool { - ccipContracts.Source.Chain.Commit() - ccipContracts.Dest.Chain.Commit() - log, err := c.LogPoller().LatestLogByEventSigWithConfs( - testutils.Context(t), - evmrelay.OCR2AggregatorLogDecoder.EventSig(), - ccipContracts.Dest.CommitStore.Address(), - 0, - ) - require.NoError(t, err) - var latestCfg ccipdata.CommitOnchainConfig - if log != nil { - latestCfg, err = DecodeCommitOnChainConfig(log.Data) - require.NoError(t, err) - return latestCfg == commitCfg - } - return false - }, testutils.WaitTimeout(t), 1*time.Second).Should(gomega.BeTrue(), "node is using old cfg") - return log -} - -func (node *Node) EventuallyNodeUsesNewExecConfig(t *testing.T, ccipContracts CCIPIntegrationTestHarness, execCfg v1_2_0.ExecOnchainConfig) logpoller.Log { - c, err := node.App.GetRelayers().LegacyEVMChains().Get(strconv.FormatUint(ccipContracts.Dest.ChainID, 10)) - require.NoError(t, err) - var log logpoller.Log - gomega.NewGomegaWithT(t).Eventually(func() bool { - ccipContracts.Source.Chain.Commit() - ccipContracts.Dest.Chain.Commit() - log, err := c.LogPoller().LatestLogByEventSigWithConfs( - testutils.Context(t), - evmrelay.OCR2AggregatorLogDecoder.EventSig(), - ccipContracts.Dest.OffRamp.Address(), - 0, - ) - require.NoError(t, err) - var latestCfg v1_2_0.ExecOnchainConfig - if log != nil { - latestCfg, err = DecodeExecOnChainConfig(log.Data) - require.NoError(t, err) - return latestCfg == execCfg - } - return false - }, testutils.WaitTimeout(t), 1*time.Second).Should(gomega.BeTrue(), "node is using old cfg") - return log -} - -func (node *Node) EventuallyHasReqSeqNum(t *testing.T, ccipContracts *CCIPIntegrationTestHarness, onRamp common.Address, seqNum int) logpoller.Log { - c, err := node.App.GetRelayers().LegacyEVMChains().Get(strconv.FormatUint(ccipContracts.Source.ChainID, 10)) - require.NoError(t, err) - var log logpoller.Log - gomega.NewGomegaWithT(t).Eventually(func() bool { - ccipContracts.Source.Chain.Commit() - ccipContracts.Dest.Chain.Commit() - lgs, err := c.LogPoller().LogsDataWordRange( - testutils.Context(t), - v1_2_0.CCIPSendRequestEventSig, - onRamp, - v1_2_0.CCIPSendRequestSeqNumIndex, - abihelpers.EvmWord(uint64(seqNum)), - abihelpers.EvmWord(uint64(seqNum)), - 1, - ) - require.NoError(t, err) - t.Log("Send requested", len(lgs)) - if len(lgs) == 1 { - log = lgs[0] - return true - } - return false - }, testutils.WaitTimeout(t), 1*time.Second).Should(gomega.BeTrue(), "eventually has seq num") - return log -} - -func (node *Node) EventuallyHasExecutedSeqNums(t *testing.T, ccipContracts *CCIPIntegrationTestHarness, offRamp common.Address, minSeqNum int, maxSeqNum int) []logpoller.Log { - c, err := node.App.GetRelayers().LegacyEVMChains().Get(strconv.FormatUint(ccipContracts.Dest.ChainID, 10)) - require.NoError(t, err) - var logs []logpoller.Log - gomega.NewGomegaWithT(t).Eventually(func() bool { - ccipContracts.Source.Chain.Commit() - ccipContracts.Dest.Chain.Commit() - lgs, err := c.LogPoller().IndexedLogsTopicRange( - testutils.Context(t), - v1_2_0.ExecutionStateChangedEvent, - offRamp, - v1_2_0.ExecutionStateChangedSeqNrIndex, - abihelpers.EvmWord(uint64(minSeqNum)), - abihelpers.EvmWord(uint64(maxSeqNum)), - 1, - ) - require.NoError(t, err) - t.Logf("Have executed logs %d want %d", len(lgs), maxSeqNum-minSeqNum+1) - if len(lgs) == maxSeqNum-minSeqNum+1 { - logs = lgs - t.Logf("Seq Num %d-%d executed", minSeqNum, maxSeqNum) - return true - } - return false - }, testutils.WaitTimeout(t), 1*time.Second).Should(gomega.BeTrue(), "eventually has not executed seq num") - return logs -} - -func (node *Node) ConsistentlySeqNumHasNotBeenExecuted(t *testing.T, ccipContracts *CCIPIntegrationTestHarness, offRamp common.Address, seqNum int) logpoller.Log { - c, err := node.App.GetRelayers().LegacyEVMChains().Get(strconv.FormatUint(ccipContracts.Dest.ChainID, 10)) - require.NoError(t, err) - var log logpoller.Log - gomega.NewGomegaWithT(t).Consistently(func() bool { - ccipContracts.Source.Chain.Commit() - ccipContracts.Dest.Chain.Commit() - lgs, err := c.LogPoller().IndexedLogsTopicRange( - testutils.Context(t), - v1_2_0.ExecutionStateChangedEvent, - offRamp, - v1_2_0.ExecutionStateChangedSeqNrIndex, - abihelpers.EvmWord(uint64(seqNum)), - abihelpers.EvmWord(uint64(seqNum)), - 1, - ) - require.NoError(t, err) - t.Log("Executed logs", lgs) - if len(lgs) == 1 { - log = lgs[0] - return true - } - return false - }, 10*time.Second, 1*time.Second).Should(gomega.BeFalse(), "seq number got executed") - return log -} - -func (node *Node) AddJob(t *testing.T, spec *integrationtesthelpers.OCR2TaskJobSpec) { - specString, err := spec.String() - require.NoError(t, err) - ccipJob, err := validate.ValidatedOracleSpecToml( - testutils.Context(t), - node.App.GetConfig().OCR2(), - node.App.GetConfig().Insecure(), - specString, - // FIXME Ani - nil, - ) - require.NoError(t, err) - err = node.App.AddJobV2(tests.Context(t), &ccipJob) - require.NoError(t, err) -} - -func (node *Node) AddBootstrapJob(t *testing.T, spec *integrationtesthelpers.OCR2TaskJobSpec) { - specString, err := spec.String() - require.NoError(t, err) - ccipJob, err := ocrbootstrap.ValidatedBootstrapSpecToml(specString) - require.NoError(t, err) - err = node.App.AddJobV2(tests.Context(t), &ccipJob) - require.NoError(t, err) -} - -func (node *Node) AddJobsWithSpec(t *testing.T, jobSpec *integrationtesthelpers.OCR2TaskJobSpec) { - // set node specific values - jobSpec.OCR2OracleSpec.OCRKeyBundleID.SetValid(node.KeyBundle.ID()) - jobSpec.OCR2OracleSpec.TransmitterID.SetValid(node.Transmitter.Hex()) - node.AddJob(t, jobSpec) -} - -func setupNodeCCIP( - t *testing.T, - owner *bind.TransactOpts, - port int64, - dbName string, - sourceChain *simulated.Backend, destChain *simulated.Backend, - sourceChainID *big.Int, destChainID *big.Int, - bootstrapPeerID string, - bootstrapPort int64, -) (chainlink.Application, string, common.Address, ocr2key.KeyBundle) { - trueRef, falseRef := true, false - - // Do not want to load fixtures as they contain a dummy chainID. - loglevel := configv2.LogLevel(zap.DebugLevel) - config, db := heavyweight.FullTestDBNoFixturesV2(t, func(c *chainlink.Config, _ *chainlink.Secrets) { - p2pAddresses := []string{ - fmt.Sprintf("127.0.0.1:%d", port), - } - c.Log.Level = &loglevel - c.Feature.UICSAKeys = &trueRef - c.Feature.FeedsManager = &trueRef - c.OCR.Enabled = &falseRef - c.OCR.DefaultTransactionQueueDepth = ptr.To[uint32](200) - c.OCR2.Enabled = &trueRef - c.Feature.LogPoller = &trueRef - c.P2P.V2.Enabled = &trueRef - - dur, err := config.NewDuration(500 * time.Millisecond) - if err != nil { - panic(err) - } - c.P2P.V2.DeltaDial = &dur - - dur2, err := config.NewDuration(5 * time.Second) - if err != nil { - panic(err) - } - - c.P2P.V2.DeltaReconcile = &dur2 - c.P2P.V2.ListenAddresses = &p2pAddresses - c.P2P.V2.AnnounceAddresses = &p2pAddresses - - c.EVM = []*v2.EVMConfig{createConfigV2Chain(sourceChainID), createConfigV2Chain(destChainID)} - - if bootstrapPeerID != "" { - // Supply the bootstrap IP and port as a V2 peer address - c.P2P.V2.DefaultBootstrappers = &[]commontypes.BootstrapperLocator{ - { - PeerID: bootstrapPeerID, Addrs: []string{ - fmt.Sprintf("127.0.0.1:%d", bootstrapPort), - }, - }, - } - } - }) - - lggr := logger.TestLogger(t) - - // The in-memory geth sim does not let you create a custom ChainID, it will always be 1337. - // In particular this means that if you sign an eip155 tx, the chainID used MUST be 1337 - // and the CHAINID op code will always emit 1337. To work around this to simulate a "multichain" - // test, we fake different chainIDs using the wrapped sim cltest.SimulatedBackend so the RPC - // appears to operate on different chainIDs and we use an EthKeyStoreSim wrapper which always - // signs 1337 see https://github.com/smartcontractkit/chainlink-ccip/blob/a24dd436810250a458d27d8bb3fb78096afeb79c/core/services/ocr2/plugins/ccip/testhelpers/simulated_backend.go#L35 - sourceClient := client.NewSimulatedBackendClient(t, sourceChain, sourceChainID) - destClient := client.NewSimulatedBackendClient(t, destChain, destChainID) - csaKeyStore := ksMocks.NewCSA(t) - - key, err := csakey.NewV2() - require.NoError(t, err) - csaKeyStore.On("GetAll").Return([]csakey.KeyV2{key}, nil) - keyStore := NewKsa(db, lggr, csaKeyStore) - - simEthKeyStore := testhelpers.EthKeyStoreSim{ - ETHKS: keyStore.Eth(), - CSAKS: keyStore.CSA(), - } - mailMon := mailbox.NewMonitor("CCIP", lggr.Named("Mailbox")) - evmOpts := chainlink.EVMFactoryConfig{ - ChainOpts: legacyevm.ChainOpts{ - AppConfig: config, - GenEthClient: func(chainID *big.Int) client.Client { - if chainID.String() == sourceChainID.String() { - return sourceClient - } else if chainID.String() == destChainID.String() { - return destClient - } - t.Fatalf("invalid chain ID %v", chainID.String()) - return nil - }, - MailMon: mailMon, - DS: db, - }, - CSAETHKeystore: simEthKeyStore, - } - - beholderAuthHeaders, csaPubKeyHex, err := keystore.BuildBeholderAuth(keyStore) - require.NoError(t, err) - - loopRegistry := plugins.NewLoopRegistry(lggr.Named("LoopRegistry"), config.Tracing(), config.Telemetry(), beholderAuthHeaders, csaPubKeyHex) - relayerFactory := chainlink.RelayerFactory{ - Logger: lggr, - LoopRegistry: loopRegistry, - GRPCOpts: loop.GRPCOpts{}, - CapabilitiesRegistry: coretypes.NewCapabilitiesRegistry(t), - } - testCtx := testutils.Context(t) - // evm alway enabled for backward compatibility - initOps := []chainlink.CoreRelayerChainInitFunc{ - chainlink.InitEVM(testCtx, relayerFactory, evmOpts), - } - - relayChainInterops, err := chainlink.NewCoreRelayerChainInteroperators(initOps...) - if err != nil { - t.Fatal(err) - } - - app, err := chainlink.NewApplication(chainlink.ApplicationOpts{ - Config: config, - DS: db, - KeyStore: keyStore, - RelayerChainInteroperators: relayChainInterops, - Logger: lggr, - ExternalInitiatorManager: nil, - CloseLogger: lggr.Sync, - UnrestrictedHTTPClient: &http.Client{}, - RestrictedHTTPClient: &http.Client{}, - AuditLogger: audit.NoopLogger, - MailMon: mailMon, - LoopRegistry: plugins.NewLoopRegistry(lggr, config.Tracing(), config.Telemetry(), beholderAuthHeaders, csaPubKeyHex), - }) - ctx := testutils.Context(t) - require.NoError(t, err) - require.NoError(t, app.GetKeyStore().Unlock(ctx, "password")) - _, err = app.GetKeyStore().P2P().Create(ctx) - require.NoError(t, err) - - p2pIDs, err := app.GetKeyStore().P2P().GetAll() - require.NoError(t, err) - require.Len(t, p2pIDs, 1) - peerID := p2pIDs[0].PeerID() - - _, err = app.GetKeyStore().Eth().Create(testCtx, destChainID) - require.NoError(t, err) - sendingKeys, err := app.GetKeyStore().Eth().EnabledKeysForChain(testCtx, destChainID) - require.NoError(t, err) - require.Len(t, sendingKeys, 1) - transmitter := sendingKeys[0].Address - s, err := app.GetKeyStore().Eth().GetState(testCtx, sendingKeys[0].ID(), destChainID) - require.NoError(t, err) - lggr.Debug(fmt.Sprintf("Transmitter address %s chainID %s", transmitter, s.EVMChainID.String())) - - // Fund the commitTransmitter address with some ETH - destChain.Commit() - n, err := destChain.Client().NonceAt(tests.Context(t), owner.From, nil) - require.NoError(t, err) - tx := types3.NewTransaction(n, transmitter, big.NewInt(1000000000000000000), 21000, big.NewInt(1000000000), nil) - signedTx, err := owner.Signer(owner.From, tx) - require.NoError(t, err) - err = destChain.Client().SendTransaction(tests.Context(t), signedTx) - require.NoError(t, err) - destChain.Commit() - - kb, err := app.GetKeyStore().OCR2().Create(ctx, chaintype.EVM) - require.NoError(t, err) - return app, peerID.Raw(), transmitter, kb -} - -func createConfigV2Chain(chainId *big.Int) *v2.EVMConfig { - // NOTE: For the executor jobs, the default of 500k is insufficient for a 3 message batch - defaultGasLimit := uint64(5000000) - tr := true - - sourceC := v2.Defaults((*evmUtils.Big)(chainId)) - sourceC.GasEstimator.LimitDefault = &defaultGasLimit - fixedPrice := "FixedPrice" - sourceC.GasEstimator.Mode = &fixedPrice - d, _ := config.NewDuration(100 * time.Millisecond) - sourceC.LogPollInterval = &d - fd := uint32(2) - sourceC.FinalityDepth = &fd - return &v2.EVMConfig{ - ChainID: (*evmUtils.Big)(chainId), - Enabled: &tr, - Chain: sourceC, - Nodes: v2.EVMNodes{&v2.Node{}}, - } -} - -type CCIPIntegrationTestHarness struct { - CCIPContracts - Nodes []Node - Bootstrap Node -} - -func SetupCCIPIntegrationTH(t *testing.T, sourceChainID, sourceChainSelector, destChainId, destChainSelector uint64) CCIPIntegrationTestHarness { - return CCIPIntegrationTestHarness{ - CCIPContracts: SetupCCIPContracts(t, sourceChainID, sourceChainSelector, destChainId, destChainSelector), - } -} - -func (c *CCIPIntegrationTestHarness) CreatePricesPipeline(t *testing.T) (string, *httptest.Server, *httptest.Server) { - linkUSD := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { - _, err := w.Write([]byte(`{"UsdPerLink": "8000000000000000000"}`)) - require.NoError(t, err) - })) - ethUSD := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { - _, err := w.Write([]byte(`{"UsdPerETH": "1700000000000000000000"}`)) - require.NoError(t, err) - })) - sourceWrappedNative, err := c.Source.Router.GetWrappedNative(nil) - require.NoError(t, err) - destWrappedNative, err := c.Dest.Router.GetWrappedNative(nil) - require.NoError(t, err) - tokenPricesUSDPipeline := fmt.Sprintf(` -// Price 1 -link [type=http method=GET url="%s"]; -link_parse [type=jsonparse path="UsdPerLink"]; -link->link_parse; -eth [type=http method=GET url="%s"]; -eth_parse [type=jsonparse path="UsdPerETH"]; -eth->eth_parse; -merge [type=merge left="{}" right="{\\\"%s\\\":$(link_parse), \\\"%s\\\":$(eth_parse), \\\"%s\\\":$(eth_parse)}"];`, - linkUSD.URL, ethUSD.URL, c.Dest.LinkToken.Address(), sourceWrappedNative, destWrappedNative) - - return tokenPricesUSDPipeline, linkUSD, ethUSD -} - -func (c *CCIPIntegrationTestHarness) AddAllJobs(t *testing.T, jobParams integrationtesthelpers.CCIPJobSpecParams) { - jobParams.OffRamp = c.Dest.OffRamp.Address() - - commitSpec, err := jobParams.CommitJobSpec() - require.NoError(t, err) - geExecutionSpec, err := jobParams.ExecutionJobSpec() - require.NoError(t, err) - nodes := c.Nodes - for _, node := range nodes { - node.AddJobsWithSpec(t, commitSpec) - node.AddJobsWithSpec(t, geExecutionSpec) - } -} - -func (c *CCIPIntegrationTestHarness) jobSpecProposal(t *testing.T, specTemplate string, f func() (*integrationtesthelpers.OCR2TaskJobSpec, error), feedsManagerId int64, version int32, opts ...any) feeds2.ProposeJobArgs { - spec, err := f() - require.NoError(t, err) - - args := []any{spec.OCR2OracleSpec.ContractID} - args = append(args, opts...) - - return feeds2.ProposeJobArgs{ - FeedsManagerID: feedsManagerId, - RemoteUUID: uuid.New(), - Multiaddrs: nil, - Version: version, - Spec: fmt.Sprintf(specTemplate, args...), - } -} - -func (c *CCIPIntegrationTestHarness) SetupFeedsManager(t *testing.T) { - ctx := testutils.Context(t) - for _, node := range c.Nodes { - f := node.App.GetFeedsService() - - managers, err := f.ListManagers(ctx) - require.NoError(t, err) - if len(managers) > 0 { - // Use at most one feeds manager, don't register if one already exists - continue - } - - secret := utils.RandomBytes32() - pkey, err := crypto.PublicKeyFromHex(hex.EncodeToString(secret[:])) - require.NoError(t, err) - - m := feeds2.RegisterManagerParams{ - Name: "CCIP", - URI: "http://localhost:8080", - PublicKey: *pkey, - } - - _, err = f.RegisterManager(testutils.Context(t), m) - require.NoError(t, err) - - connManager := feedsMocks.NewConnectionsManager(t) - connManager.On("GetClient", mock.Anything).Maybe().Return(NoopFeedsClient{}, nil) - connManager.On("Close").Maybe().Return() - connManager.On("IsConnected", mock.Anything).Maybe().Return(true) - f.Unsafe_SetConnectionsManager(connManager) - } -} - -func (c *CCIPIntegrationTestHarness) ApproveJobSpecs(t *testing.T, jobParams integrationtesthelpers.CCIPJobSpecParams) { - ctx := testutils.Context(t) - - for _, node := range c.Nodes { - f := node.App.GetFeedsService() - managers, err := f.ListManagers(ctx) - require.NoError(t, err) - require.Len(t, managers, 1, "expected exactly one feeds manager") - - execSpec := c.jobSpecProposal( - t, - execSpecTemplate, - jobParams.ExecutionJobSpec, - managers[0].ID, - 1, - node.KeyBundle.ID(), - node.Transmitter.Hex(), - utils.RandomAddress().String(), - utils.RandomAddress().String(), - ) - execId, err := f.ProposeJob(ctx, &execSpec) - require.NoError(t, err) - - err = f.ApproveSpec(ctx, execId, true) - require.NoError(t, err) - - var commitSpec feeds2.ProposeJobArgs - if jobParams.TokenPricesUSDPipeline != "" { - commitSpec = c.jobSpecProposal( - t, - commitSpecTemplatePipeline, - jobParams.CommitJobSpec, - managers[0].ID, - 2, - node.KeyBundle.ID(), - node.Transmitter.Hex(), - jobParams.OffRamp.String(), - jobParams.TokenPricesUSDPipeline, - ) - } else { - commitSpec = c.jobSpecProposal( - t, - commitSpecTemplateDynamicPriceGetter, - jobParams.CommitJobSpec, - managers[0].ID, - 2, - node.KeyBundle.ID(), - node.Transmitter.Hex(), - jobParams.OffRamp.String(), - jobParams.PriceGetterConfig, - ) - } - - commitId, err := f.ProposeJob(ctx, &commitSpec) - require.NoError(t, err) - - err = f.ApproveSpec(ctx, commitId, true) - require.NoError(t, err) - } -} - -func (c *CCIPIntegrationTestHarness) AllNodesHaveReqSeqNum(t *testing.T, seqNum int, onRampOpts ...common.Address) logpoller.Log { - var log logpoller.Log - nodes := c.Nodes - var onRamp common.Address - if len(onRampOpts) > 0 { - onRamp = onRampOpts[0] - } else { - require.NotNil(t, c.Source.OnRamp, "no onramp configured") - onRamp = c.Source.OnRamp.Address() - } - for _, node := range nodes { - log = node.EventuallyHasReqSeqNum(t, c, onRamp, seqNum) - } - return log -} - -func (c *CCIPIntegrationTestHarness) AllNodesHaveExecutedSeqNums(t *testing.T, minSeqNum int, maxSeqNum int, offRampOpts ...common.Address) []logpoller.Log { - var logs []logpoller.Log - nodes := c.Nodes - var offRamp common.Address - - if len(offRampOpts) > 0 { - offRamp = offRampOpts[0] - } else { - require.NotNil(t, c.Dest.OffRamp, "no offramp configured") - offRamp = c.Dest.OffRamp.Address() - } - for _, node := range nodes { - logs = node.EventuallyHasExecutedSeqNums(t, c, offRamp, minSeqNum, maxSeqNum) - } - return logs -} - -func (c *CCIPIntegrationTestHarness) NoNodesHaveExecutedSeqNum(t *testing.T, seqNum int, offRampOpts ...common.Address) logpoller.Log { - var log logpoller.Log - nodes := c.Nodes - var offRamp common.Address - if len(offRampOpts) > 0 { - offRamp = offRampOpts[0] - } else { - require.NotNil(t, c.Dest.OffRamp, "no offramp configured") - offRamp = c.Dest.OffRamp.Address() - } - for _, node := range nodes { - log = node.ConsistentlySeqNumHasNotBeenExecuted(t, c, offRamp, seqNum) - } - return log -} - -func (c *CCIPIntegrationTestHarness) EventuallyCommitReportAccepted(t *testing.T, currentBlock uint64, commitStoreOpts ...common.Address) commit_store_1_2_0.CommitStoreCommitReport { - var commitStore *commit_store_1_2_0.CommitStore - var err error - if len(commitStoreOpts) > 0 { - commitStore, err = commit_store_1_2_0.NewCommitStore(commitStoreOpts[0], c.Dest.Chain.Client()) - require.NoError(t, err) - } else { - require.NotNil(t, c.Dest.CommitStore, "no commitStore configured") - commitStore = c.Dest.CommitStore - } - g := gomega.NewGomegaWithT(t) - var report commit_store_1_2_0.CommitStoreCommitReport - g.Eventually(func() bool { - it, err := commitStore.FilterReportAccepted(&bind.FilterOpts{Start: currentBlock}) - g.Expect(err).NotTo(gomega.HaveOccurred(), "Error filtering ReportAccepted event") - g.Expect(it.Next()).To(gomega.BeTrue(), "No ReportAccepted event found") - report = it.Event.Report - if report.MerkleRoot != [32]byte{} { - t.Log("Report Accepted by commitStore") - return true - } - return false - }, testutils.WaitTimeout(t), 1*time.Second).Should(gomega.BeTrue(), "report has not been committed") - return report -} - -func (c *CCIPIntegrationTestHarness) EventuallyExecutionStateChangedToSuccess(t *testing.T, seqNum []uint64, blockNum uint64, offRampOpts ...common.Address) { - var offRamp *evm_2_evm_offramp_1_2_0.EVM2EVMOffRamp - var err error - if len(offRampOpts) > 0 { - offRamp, err = evm_2_evm_offramp_1_2_0.NewEVM2EVMOffRamp(offRampOpts[0], c.Dest.Chain.Client()) - require.NoError(t, err) - } else { - require.NotNil(t, c.Dest.OffRamp, "no offRamp configured") - offRamp = c.Dest.OffRamp - } - gomega.NewGomegaWithT(t).Eventually(func() bool { - it, err := offRamp.FilterExecutionStateChanged(&bind.FilterOpts{Start: blockNum}, seqNum, [][32]byte{}) - require.NoError(t, err) - for it.Next() { - if cciptypes.MessageExecutionState(it.Event.State) == cciptypes.ExecutionStateSuccess { - t.Logf("ExecutionStateChanged event found for seqNum %d", it.Event.SequenceNumber) - return true - } - } - c.Source.Chain.Commit() - c.Dest.Chain.Commit() - return false - }, testutils.WaitTimeout(t), time.Second). - Should(gomega.BeTrue(), "ExecutionStateChanged Event") -} - -func (c *CCIPIntegrationTestHarness) EventuallyReportCommitted(t *testing.T, max int, commitStoreOpts ...common.Address) uint64 { - var commitStore *commit_store_1_2_0.CommitStore - var err error - var committedSeqNum uint64 - if len(commitStoreOpts) > 0 { - commitStore, err = commit_store_1_2_0.NewCommitStore(commitStoreOpts[0], c.Dest.Chain.Client()) - require.NoError(t, err) - } else { - require.NotNil(t, c.Dest.CommitStore, "no commitStore configured") - commitStore = c.Dest.CommitStore - } - gomega.NewGomegaWithT(t).Eventually(func() bool { - minSeqNum, err := commitStore.GetExpectedNextSequenceNumber(nil) - require.NoError(t, err) - c.Source.Chain.Commit() - c.Dest.Chain.Commit() - t.Log("next expected seq num reported", minSeqNum) - committedSeqNum = minSeqNum - return minSeqNum > uint64(max) - }, testutils.WaitTimeout(t), time.Second).Should(gomega.BeTrue(), "report has not been committed") - return committedSeqNum -} - -func (c *CCIPIntegrationTestHarness) EventuallySendRequested(t *testing.T, seqNum uint64, onRampOpts ...common.Address) { - var onRamp *evm_2_evm_onramp_1_2_0.EVM2EVMOnRamp - var err error - if len(onRampOpts) > 0 { - onRamp, err = evm_2_evm_onramp_1_2_0.NewEVM2EVMOnRamp(onRampOpts[0], c.Source.Chain.Client()) - require.NoError(t, err) - } else { - require.NotNil(t, c.Source.OnRamp, "no onRamp configured") - onRamp = c.Source.OnRamp - } - gomega.NewGomegaWithT(t).Eventually(func() bool { - it, err := onRamp.FilterCCIPSendRequested(nil) - require.NoError(t, err) - for it.Next() { - if it.Event.Message.SequenceNumber == seqNum { - t.Log("sendRequested generated for", seqNum) - return true - } - } - c.Source.Chain.Commit() - c.Dest.Chain.Commit() - return false - }, testutils.WaitTimeout(t), time.Second).Should(gomega.BeTrue(), "sendRequested has not been generated") -} - -func (c *CCIPIntegrationTestHarness) ConsistentlyReportNotCommitted(t *testing.T, max int, commitStoreOpts ...common.Address) { - var commitStore *commit_store_1_2_0.CommitStore - var err error - if len(commitStoreOpts) > 0 { - commitStore, err = commit_store_1_2_0.NewCommitStore(commitStoreOpts[0], c.Dest.Chain.Client()) - require.NoError(t, err) - } else { - require.NotNil(t, c.Dest.CommitStore, "no commitStore configured") - commitStore = c.Dest.CommitStore - } - gomega.NewGomegaWithT(t).Consistently(func() bool { - minSeqNum, err := commitStore.GetExpectedNextSequenceNumber(nil) - require.NoError(t, err) - c.Source.Chain.Commit() - c.Dest.Chain.Commit() - t.Log("min seq num reported", minSeqNum) - require.GreaterOrEqual(t, max, 0) - return minSeqNum > uint64(max) //nolint:gosec // G115 false positive - }, testutils.WaitTimeout(t), time.Second).Should(gomega.BeFalse(), "report has been committed") -} - -func (c *CCIPIntegrationTestHarness) SetupAndStartNodes(ctx context.Context, t *testing.T, bootstrapNodePort int64) (Node, []Node, uint64) { - appBootstrap, bootstrapPeerID, bootstrapTransmitter, bootstrapKb := setupNodeCCIP(t, c.Dest.User, bootstrapNodePort, - "bootstrap_ccip", c.Source.Chain, c.Dest.Chain, big.NewInt(0).SetUint64(c.Source.ChainID), - big.NewInt(0).SetUint64(c.Dest.ChainID), "", 0) - var ( - oracles []confighelper.OracleIdentityExtra - nodes []Node - ) - err := appBootstrap.Start(ctx) - require.NoError(t, err) - t.Cleanup(func() { - require.NoError(t, appBootstrap.Stop()) - }) - bootstrapNode := Node{ - App: appBootstrap, - Transmitter: bootstrapTransmitter, - KeyBundle: bootstrapKb, - } - // Set up the minimum 4 oracles all funded with destination ETH - for i := int64(0); i < 4; i++ { - app, peerID, transmitter, kb := setupNodeCCIP( - t, - c.Dest.User, - int64(freeport.GetOne(t)), - fmt.Sprintf("oracle_ccip%d", i), - c.Source.Chain, - c.Dest.Chain, - big.NewInt(0).SetUint64(c.Source.ChainID), - big.NewInt(0).SetUint64(c.Dest.ChainID), - bootstrapPeerID, - bootstrapNodePort, - ) - nodes = append(nodes, Node{ - App: app, - Transmitter: transmitter, - KeyBundle: kb, - }) - offchainPublicKey, _ := hex.DecodeString(strings.TrimPrefix(kb.OnChainPublicKey(), "0x")) - oracles = append(oracles, confighelper.OracleIdentityExtra{ - OracleIdentity: confighelper.OracleIdentity{ - OnchainPublicKey: offchainPublicKey, - TransmitAccount: types4.Account(transmitter.String()), - OffchainPublicKey: kb.OffchainPublicKey(), - PeerID: peerID, - }, - ConfigEncryptionPublicKey: kb.ConfigEncryptionPublicKey(), - }) - err = app.Start(ctx) - require.NoError(t, err) - t.Cleanup(func() { - require.NoError(t, app.Stop()) - }) - } - - c.Oracles = oracles - commitOnchainConfig := c.CreateDefaultCommitOnchainConfig(t) - commitOffchainConfig := c.CreateDefaultCommitOffchainConfig(t) - execOnchainConfig := c.CreateDefaultExecOnchainConfig(t) - execOffchainConfig := c.CreateDefaultExecOffchainConfig(t) - - configBlock := c.SetupOnchainConfig(t, commitOnchainConfig, commitOffchainConfig, execOnchainConfig, execOffchainConfig) - c.Nodes = nodes - c.Bootstrap = bootstrapNode - //nolint:gosec // G115 - return bootstrapNode, nodes, uint64(configBlock) -} - -func (c *CCIPIntegrationTestHarness) SetUpNodesAndJobs(t *testing.T, pricePipeline string, priceGetterConfig string, usdcAttestationAPI string) integrationtesthelpers.CCIPJobSpecParams { - // setup Jobs - ctx := tests.Context(t) - // Starts nodes and configures them in the OCR contracts. - bootstrapNode, _, configBlock := c.SetupAndStartNodes(ctx, t, int64(freeport.GetOne(t))) - - jobParams := c.NewCCIPJobSpecParams(pricePipeline, priceGetterConfig, configBlock, usdcAttestationAPI) - - // Add the bootstrap job - c.Bootstrap.AddBootstrapJob(t, jobParams.BootstrapJob(c.Dest.CommitStore.Address().Hex())) - c.AddAllJobs(t, jobParams) - - // Replay for bootstrap. - bc, err := bootstrapNode.App.GetRelayers().LegacyEVMChains().Get(strconv.FormatUint(c.Dest.ChainID, 10)) - require.NoError(t, err) - require.LessOrEqual(t, configBlock, uint64(math.MaxInt64)) - require.NoError(t, bc.LogPoller().Replay(tests.Context(t), int64(configBlock))) //nolint:gosec // G115 false positive - c.Dest.Chain.Commit() - - return jobParams -} - -func (c *CCIPIntegrationTestHarness) NewCCIPJobSpecParams(tokenPricesUSDPipeline string, priceGetterConfig string, configBlock uint64, usdcAttestationAPI string) integrationtesthelpers.CCIPJobSpecParams { - return integrationtesthelpers.CCIPJobSpecParams{ - CommitStore: c.Dest.CommitStore.Address(), - OffRamp: c.Dest.OffRamp.Address(), - DestEvmChainId: c.Dest.ChainID, - SourceChainName: "SimulatedSource", - DestChainName: "SimulatedDest", - TokenPricesUSDPipeline: tokenPricesUSDPipeline, - PriceGetterConfig: priceGetterConfig, - DestStartBlock: configBlock, - USDCAttestationAPI: usdcAttestationAPI, - } -} - -func DecodeCommitOnChainConfig(encoded []byte) (ccipdata.CommitOnchainConfig, error) { - var onchainConfig ccipdata.CommitOnchainConfig - unpacked, err := abihelpers.DecodeOCR2Config(encoded) - if err != nil { - return onchainConfig, err - } - onChainCfg := unpacked.OnchainConfig - onchainConfig, err = abihelpers.DecodeAbiStruct[ccipdata.CommitOnchainConfig](onChainCfg) - if err != nil { - return onchainConfig, err - } - return onchainConfig, nil -} - -func DecodeExecOnChainConfig(encoded []byte) (v1_2_0.ExecOnchainConfig, error) { - var onchainConfig v1_2_0.ExecOnchainConfig - unpacked, err := abihelpers.DecodeOCR2Config(encoded) - if err != nil { - return onchainConfig, errors.Wrap(err, "failed to unpack log data") - } - onChainCfg := unpacked.OnchainConfig - onchainConfig, err = abihelpers.DecodeAbiStruct[v1_2_0.ExecOnchainConfig](onChainCfg) - if err != nil { - return onchainConfig, err - } - return onchainConfig, nil -} - -type ksa struct { - keystore.Master - csa keystore.CSA -} - -func (k *ksa) CSA() keystore.CSA { - return k.csa -} - -func NewKsa(db *sqlx.DB, lggr logger.Logger, csa keystore.CSA) *ksa { - return &ksa{ - Master: keystore.New(db, clutils.FastScryptParams, lggr), - csa: csa, - } -} - -type NoopFeedsClient struct{} - -func (n NoopFeedsClient) ApprovedJob(context.Context, *pb.ApprovedJobRequest) (*pb.ApprovedJobResponse, error) { - return &pb.ApprovedJobResponse{}, nil -} - -func (n NoopFeedsClient) Healthcheck(context.Context, *pb.HealthcheckRequest) (*pb.HealthcheckResponse, error) { - return &pb.HealthcheckResponse{}, nil -} - -func (n NoopFeedsClient) UpdateNode(context.Context, *pb.UpdateNodeRequest) (*pb.UpdateNodeResponse, error) { - return &pb.UpdateNodeResponse{}, nil -} - -func (n NoopFeedsClient) RejectedJob(context.Context, *pb.RejectedJobRequest) (*pb.RejectedJobResponse, error) { - return &pb.RejectedJobResponse{}, nil -} - -func (n NoopFeedsClient) CancelledJob(context.Context, *pb.CancelledJobRequest) (*pb.CancelledJobResponse, error) { - return &pb.CancelledJobResponse{}, nil -} diff --git a/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/config_1_4_0.go b/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/config_1_4_0.go deleted file mode 100644 index 087c21e9333..00000000000 --- a/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/config_1_4_0.go +++ /dev/null @@ -1,75 +0,0 @@ -// Package with set of configs that should be used only within tests suites - -package testhelpers_1_4_0 - -import ( - "testing" - "time" - - "github.com/stretchr/testify/require" - - "github.com/smartcontractkit/chainlink-common/pkg/config" - - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/testhelpers" -) - -var PermissionLessExecutionThresholdSeconds = uint32(testhelpers.FirstBlockAge.Seconds()) - -func (c *CCIPContracts) CreateDefaultCommitOnchainConfig(t *testing.T) []byte { - config, err := abihelpers.EncodeAbiStruct(ccipdata.CommitOnchainConfig{ - PriceRegistry: c.Dest.PriceRegistry.Address(), - }) - require.NoError(t, err) - return config -} - -func (c *CCIPContracts) CreateDefaultCommitOffchainConfig(t *testing.T) []byte { - return c.createCommitOffchainConfig(t, 10*time.Second, 5*time.Second) -} - -func (c *CCIPContracts) createCommitOffchainConfig(t *testing.T, feeUpdateHearBeat time.Duration, inflightCacheExpiry time.Duration) []byte { - config, err := NewCommitOffchainConfig( - *config.MustNewDuration(feeUpdateHearBeat), - 1, - 1, - *config.MustNewDuration(feeUpdateHearBeat), - 1, - *config.MustNewDuration(inflightCacheExpiry), - false, - ).Encode() - require.NoError(t, err) - return config -} - -func (c *CCIPContracts) CreateDefaultExecOnchainConfig(t *testing.T) []byte { - config, err := abihelpers.EncodeAbiStruct(v1_2_0.ExecOnchainConfig{ - PermissionLessExecutionThresholdSeconds: PermissionLessExecutionThresholdSeconds, - Router: c.Dest.Router.Address(), - PriceRegistry: c.Dest.PriceRegistry.Address(), - MaxDataBytes: 1e5, - MaxNumberOfTokensPerMsg: 5, - MaxPoolReleaseOrMintGas: 200_000, - }) - require.NoError(t, err) - return config -} - -func (c *CCIPContracts) CreateDefaultExecOffchainConfig(t *testing.T) []byte { - return c.createExecOffchainConfig(t, 1*time.Minute, 1*time.Minute) -} - -func (c *CCIPContracts) createExecOffchainConfig(t *testing.T, inflightCacheExpiry time.Duration, rootSnoozeTime time.Duration) []byte { - config, err := NewExecOffchainConfig( - 1, - 5_000_000, - 0.07, - *config.MustNewDuration(inflightCacheExpiry), - *config.MustNewDuration(rootSnoozeTime), - uint32(0), - ).Encode() - require.NoError(t, err) - return config -} diff --git a/integration-tests/ccip-tests/contracts/contract_deployer.go b/integration-tests/ccip-tests/contracts/contract_deployer.go index c97e7bbc0aa..1f2859ae0db 100644 --- a/integration-tests/ccip-tests/contracts/contract_deployer.go +++ b/integration-tests/ccip-tests/contracts/contract_deployer.go @@ -57,7 +57,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/testhelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0" "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm" ) @@ -1415,16 +1414,6 @@ func NewCommitOffchainConfig( InflightCacheExpiry, priceReportingDisabled, ), nil - case V1_2_0: - return testhelpers_1_4_0.NewCommitOffchainConfig( - GasPriceHeartBeat, - DAGasPriceDeviationPPB, - ExecGasPriceDeviationPPB, - TokenPriceHeartBeat, - TokenPriceDeviationPPB, - InflightCacheExpiry, - priceReportingDisabled, - ), nil default: return nil, fmt.Errorf("version not supported: %s", VersionMap[CommitStoreContract]) } @@ -1436,8 +1425,6 @@ func NewCommitOnchainConfig( switch VersionMap[CommitStoreContract] { case Latest: return testhelpers.NewCommitOnchainConfig(PriceRegistry), nil - case V1_2_0: - return testhelpers_1_4_0.NewCommitOnchainConfig(PriceRegistry), nil default: return nil, fmt.Errorf("version not supported: %s", VersionMap[CommitStoreContract]) } @@ -1454,15 +1441,6 @@ func NewExecOnchainConfig( switch VersionMap[OffRampContract] { case Latest: return testhelpers.NewExecOnchainConfig(PermissionLessExecutionThresholdSeconds, Router, PriceRegistry, MaxNumberOfTokensPerMsg, MaxDataBytes), nil - case V1_2_0: - return testhelpers_1_4_0.NewExecOnchainConfig( - PermissionLessExecutionThresholdSeconds, - Router, - PriceRegistry, - MaxNumberOfTokensPerMsg, - MaxDataBytes, - MaxPoolReleaseOrMintGas, - ), nil default: return nil, fmt.Errorf("version not supported: %s", VersionMap[OffRampContract]) } @@ -1487,15 +1465,6 @@ func NewExecOffchainConfig( rootSnoozeTime, batchingStrategyID, ), nil - case V1_2_0: - return testhelpers_1_4_0.NewExecOffchainConfig( - destOptimisticConfirmations, - batchGasLimit, - relativeBoostPerWaitHour, - inflightCacheExpiry, - rootSnoozeTime, - batchingStrategyID, - ), nil default: return nil, fmt.Errorf("version not supported: %s", VersionMap[OffRampContract]) }