From f1615d60d6b65dd1c1322a997d18e14f646d2637 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Fri, 28 Jun 2024 17:48:46 -0400 Subject: [PATCH 01/26] CCIP-2645: Introducing leader lane and setting PriceReportingDisabled --- .../ccip-tests/actions/ccip_helpers.go | 53 ++++++++++++------ .../ccip-tests/testconfig/global.go | 6 ++ .../testconfig/tomls/ccip-default.toml | 5 ++ .../ccip-tests/testsetups/ccip.go | 56 +++++++++++++++++-- 4 files changed, 97 insertions(+), 23 deletions(-) diff --git a/integration-tests/ccip-tests/actions/ccip_helpers.go b/integration-tests/ccip-tests/actions/ccip_helpers.go index 88cd28876c..af57afcbec 100644 --- a/integration-tests/ccip-tests/actions/ccip_helpers.go +++ b/integration-tests/ccip-tests/actions/ccip_helpers.go @@ -44,7 +44,6 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver" "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/reorg" "github.com/smartcontractkit/chainlink-testing-framework/networks" - "github.com/smartcontractkit/chainlink/integration-tests/ccip-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/ccip-tests/contracts/laneconfig" "github.com/smartcontractkit/chainlink/integration-tests/ccip-tests/testconfig" @@ -2605,23 +2604,24 @@ func CCIPRequestFromTxHash(txHash common.Hash, chainClient blockchain.EVMClient) } type CCIPLane struct { - Test *testing.T - Logger *zerolog.Logger - SourceNetworkName string - DestNetworkName string - SourceChain blockchain.EVMClient - DestChain blockchain.EVMClient - Source *SourceCCIPModule - Dest *DestCCIPModule - NumberOfReq int - Reports *testreporters.CCIPLaneStats - Balance *BalanceSheet - SentReqs map[common.Hash][]CCIPRequest - TotalFee *big.Int // total fee for all the requests. Used for balance validation. - ValidationTimeout time.Duration - Context context.Context - SrcNetworkLaneCfg *laneconfig.LaneConfig - DstNetworkLaneCfg *laneconfig.LaneConfig + Test *testing.T + Logger *zerolog.Logger + SourceNetworkName string + DestNetworkName string + SourceChain blockchain.EVMClient + DestChain blockchain.EVMClient + Source *SourceCCIPModule + Dest *DestCCIPModule + NumberOfReq int + Reports *testreporters.CCIPLaneStats + Balance *BalanceSheet + SentReqs map[common.Hash][]CCIPRequest + TotalFee *big.Int // total fee for all the requests. Used for balance validation. + ValidationTimeout time.Duration + Context context.Context + SrcNetworkLaneCfg *laneconfig.LaneConfig + DstNetworkLaneCfg *laneconfig.LaneConfig + PriceReportingDisabled bool } func (lane *CCIPLane) TokenPricesConfig() (string, error) { @@ -3642,6 +3642,23 @@ func (lane *CCIPLane) DeployNewCCIPLane( } jobParams.P2PV2Bootstrappers = []string{p2pBootstrappersCommit.P2PV2Bootstrapper()} + if lane.PriceReportingDisabled { + reportingPluginConfig, err := json.Marshal([]byte(`{"PriceReportingDisabled": true,}`)) + if err != nil { + return fmt.Errorf("error encoding report plugin config: %w", err) + } + if testConf.CommitOCRParams == nil { + bTime, err := lane.Dest.Common.AvgBlockTime(lane.Context) + if err != nil { + return fmt.Errorf("error getting block time for report plugin: %w", err) + } + OCRCommitParams := contracts.OCR2ParamsForCommit(bTime) + OCRCommitParams.ReportingPluginConfig = reportingPluginConfig + testConf.CommitOCRParams = &OCRCommitParams + } else { + testConf.CommitOCRParams.ReportingPluginConfig = reportingPluginConfig + } + } err = SetOCR2Config(lane.Context, lane.Logger, *testConf, commitNodes, execNodes, *lane.Dest) if err != nil { diff --git a/integration-tests/ccip-tests/testconfig/global.go b/integration-tests/ccip-tests/testconfig/global.go index 331737c5fb..c8e896ff16 100644 --- a/integration-tests/ccip-tests/testconfig/global.go +++ b/integration-tests/ccip-tests/testconfig/global.go @@ -172,6 +172,7 @@ type Common struct { Mockserver *string `toml:",omitempty"` NewCLCluster *ChainlinkDeployment `toml:",omitempty"` // NewCLCluster is the new chainlink cluster to create, if specified along with ExistingCLCluster this will be ignored Network *ctfconfig.NetworkConfig `toml:",omitempty"` + Lane *Lane `toml:",omitempty"` PrivateEthereumNetworks map[string]*ctfconfig.EthereumNetworkConfig `toml:",omitempty"` Logging *ctfconfig.LoggingConfig `toml:",omitempty"` } @@ -455,3 +456,8 @@ func (n *Node) Merge(from *Node) { } } } + +type Lane struct { + LeaderLaneEnabled bool + Leaders [][]string `toml:",omitempty"` +} diff --git a/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml b/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml index f62612996c..be30478ca4 100644 --- a/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml +++ b/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml @@ -19,6 +19,10 @@ TTL = '5h' [CCIP.Env.Network] selected_networks = ['SIMULATED_1', 'SIMULATED_2'] +[CCIP.Env.Lane] +LeaderLaneEnabled=false +Leaders = [['SIMULATED_1', 'SIMULATED_2'], ['SIMULATED_2', 'SIMULATED_1']] + # PrivateEthereumNetworks.NETWORK_NAME contains the configuration of private ethereum network that includes ethereum version, evm node client, chain id, # certain chain configurations, addresses to fund or custom docker images to be used. These are non-dev networks, but they all run just a single node. [CCIP.Env.PrivateEthereumNetworks.SIMULATED_1] @@ -284,6 +288,7 @@ CCIPOwnerTokens = false # if true, the test will use deploy the tokens by the CC # ['SIMULATED_1', 'SIMULATED_2'], ['SIMULATED_1', 'SIMULATED_3'], ['SIMULATED_2', 'SIMULATED_3'] #MaxNoOfLanes = # maximum number of lanes to be added in the test; mainly used for scalability tests + [CCIP.Groups.load] # uncomment the following with specific values of lane combinations to be tested, if you want to run your tests to run only on these specific network pairs # if specific network pairs are not mentioned, then all the network pairs will be tested based on values in CCIP.Env.NetworkPairs and CCIP.Groups..NoOfNetworks diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 9a892a667a..d1771cb958 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -68,6 +68,12 @@ type NetworkPair struct { NetworkB blockchain.EVMNetwork ChainClientA blockchain.EVMClient ChainClientB blockchain.EVMClient + Leader Leader +} + +type Leader struct { + BiDirectional bool + UniDirectional bool } type CCIPTestConfig struct { @@ -289,11 +295,42 @@ func (c *CCIPTestConfig) SetNetworkPairs(lggr zerolog.Logger) error { c.NetworkPairs = c.NetworkPairs[:c.TestGroupInput.MaxNoOfLanes] } + // setting leader lane details to network pairs if it is enabled + if c.EnvInput.Lane.LeaderLaneEnabled { + // the way we are doing this is to set first found network as leader bidirectionally and whichever the pair + //has the same network A will be uni-directionally marked as leader + firstNetworkA := "" + for idx, n := range c.NetworkPairs { + if firstNetworkA == "" { + firstNetworkA = n.NetworkA.Name + c.NetworkPairs[idx].Leader.BiDirectional = true + continue + } + if n.NetworkA.Name == firstNetworkA { + c.NetworkPairs[idx].Leader.UniDirectional = true + } + } + } for _, n := range c.NetworkPairs { - lggr.Info(). - Str("NetworkA", fmt.Sprintf("%s-%d", n.NetworkA.Name, n.NetworkA.ChainID)). - Str("NetworkB", fmt.Sprintf("%s-%d", n.NetworkB.Name, n.NetworkB.ChainID)). - Msg("Network Pairs") + if n.Leader.BiDirectional { + lggr.Info(). + Str("NetworkA", fmt.Sprintf("%s-%d", n.NetworkA.Name, n.NetworkA.ChainID)). + Str("NetworkB", fmt.Sprintf("%s-%d", n.NetworkB.Name, n.NetworkB.ChainID)). + Str("Leader Lane", "Bidirectional"). + Msg("Network Pairs") + } else if n.Leader.UniDirectional { + lggr.Info(). + Str("NetworkA", fmt.Sprintf("%s-%d", n.NetworkA.Name, n.NetworkA.ChainID)). + Str("NetworkB", fmt.Sprintf("%s-%d", n.NetworkB.Name, n.NetworkB.ChainID)). + Str("Leader Lane", "Unidirectional"). + Msg("Network Pairs") + } else { + lggr.Info(). + Str("NetworkA", fmt.Sprintf("%s-%d", n.NetworkA.Name, n.NetworkA.ChainID)). + Str("NetworkB", fmt.Sprintf("%s-%d", n.NetworkB.Name, n.NetworkB.ChainID)). + Str("Leader Lane", "False"). + Msg("Network Pairs") + } } lggr.Info().Int("Pairs", len(c.NetworkPairs)).Msg("No Of Lanes") @@ -550,6 +587,7 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( lggr *zerolog.Logger, networkA, networkB blockchain.EVMNetwork, chainClientA, chainClientB blockchain.EVMClient, + leader Leader, ) error { var ( t = o.Cfg.Test @@ -602,6 +640,10 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( Balance: o.Balance, Context: testcontext.Get(t), } + // if it non leader lane, disable the price reporting + if !(leader.UniDirectional || leader.BiDirectional) { + ccipLaneA2B.PriceReportingDisabled = true + } contractsA, ok := o.LaneContractsByNetwork.Load(networkA.Name) if !ok { return errors.WithStack(fmt.Errorf("failed to load lane contracts for %s", networkA.Name)) @@ -656,6 +698,10 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( SrcNetworkLaneCfg: ccipLaneA2B.DstNetworkLaneCfg, DstNetworkLaneCfg: ccipLaneA2B.SrcNetworkLaneCfg, } + // if it non leader lane, disable the price reporting + if !leader.BiDirectional { + ccipLaneB2A.PriceReportingDisabled = true + } b2aLogger := lggr.With().Str("env", namespace).Str("Lane", fmt.Sprintf("%s-->%s", ccipLaneB2A.SourceNetworkName, ccipLaneB2A.DestNetworkName)).Logger() ccipLaneB2A.Logger = &b2aLogger @@ -1005,7 +1051,7 @@ func CCIPDefaultTestSetUp( laneAddGrp.Go(func() error { return setUpArgs.AddLanesForNetworkPair( lggr, n.NetworkA, n.NetworkB, - chainClientByChainID[n.NetworkA.ChainID], chainClientByChainID[n.NetworkB.ChainID], + chainClientByChainID[n.NetworkA.ChainID], chainClientByChainID[n.NetworkB.ChainID], n.Leader, ) }) } From 21d833fa9711475cdb08735c2f3244a396e40331 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Tue, 2 Jul 2024 13:13:25 -0400 Subject: [PATCH 02/26] CCIP-2645: Add price reporting disabled variable to offchainconfig --- .../ccip/testhelpers/ccip_contracts.go | 4 +++- .../ocr2/plugins/ccip/testhelpers/config.go | 1 + .../testhelpers_1_4_0/ccip_contracts_1_4_0.go | 4 +++- .../testhelpers_1_4_0/config_1_4_0.go | 1 + .../ccip-tests/actions/ccip_helpers.go | 21 +++---------------- .../ccip-tests/contracts/contract_deployer.go | 5 ++++- .../ccip-tests/testconfig/global.go | 1 - .../testconfig/tomls/ccip-default.toml | 1 - .../ccip-tests/testsetups/ccip.go | 20 ++++++++---------- 9 files changed, 24 insertions(+), 34 deletions(-) diff --git a/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go b/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go index 805c49d91a..e3d24bd45b 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go @@ -97,7 +97,8 @@ func NewCommitOffchainConfig( ExecGasPriceDeviationPPB uint32, TokenPriceHeartBeat config.Duration, TokenPriceDeviationPPB uint32, - InflightCacheExpiry config.Duration) CommitOffchainConfig { + InflightCacheExpiry config.Duration, + priceReportingDisabled bool) CommitOffchainConfig { return CommitOffchainConfig{v1_2_0.JSONCommitOffchainConfig{ GasPriceHeartBeat: GasPriceHeartBeat, DAGasPriceDeviationPPB: DAGasPriceDeviationPPB, @@ -105,6 +106,7 @@ func NewCommitOffchainConfig( TokenPriceHeartBeat: TokenPriceHeartBeat, TokenPriceDeviationPPB: TokenPriceDeviationPPB, InflightCacheExpiry: InflightCacheExpiry, + PriceReportingDisabled: priceReportingDisabled, }} } diff --git a/core/services/ocr2/plugins/ccip/testhelpers/config.go b/core/services/ocr2/plugins/ccip/testhelpers/config.go index f70f1954f1..58cf50b94e 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/config.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/config.go @@ -37,6 +37,7 @@ func (c *CCIPContracts) createCommitOffchainConfig(t *testing.T, feeUpdateHearBe *config.MustNewDuration(feeUpdateHearBeat), 1, *config.MustNewDuration(inflightCacheExpiry), + false, ).Encode() require.NoError(t, err) return config 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 index 4ea5bb18d7..47eb8bc62c 100644 --- 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 @@ -96,7 +96,8 @@ func NewCommitOffchainConfig( ExecGasPriceDeviationPPB uint32, TokenPriceHeartBeat config.Duration, TokenPriceDeviationPPB uint32, - InflightCacheExpiry config.Duration) CommitOffchainConfig { + InflightCacheExpiry config.Duration, + priceReportingDisabled bool) CommitOffchainConfig { return CommitOffchainConfig{v1_2_0.JSONCommitOffchainConfig{ GasPriceHeartBeat: GasPriceHeartBeat, DAGasPriceDeviationPPB: DAGasPriceDeviationPPB, @@ -104,6 +105,7 @@ func NewCommitOffchainConfig( TokenPriceHeartBeat: TokenPriceHeartBeat, TokenPriceDeviationPPB: TokenPriceDeviationPPB, InflightCacheExpiry: InflightCacheExpiry, + PriceReportingDisabled: priceReportingDisabled, }} } 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 index 751ae5c1a9..666ad79e59 100644 --- 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 @@ -38,6 +38,7 @@ func (c *CCIPContracts) createCommitOffchainConfig(t *testing.T, feeUpdateHearBe *config.MustNewDuration(feeUpdateHearBeat), 1, *config.MustNewDuration(inflightCacheExpiry), + false, ).Encode() require.NoError(t, err) return config diff --git a/integration-tests/ccip-tests/actions/ccip_helpers.go b/integration-tests/ccip-tests/actions/ccip_helpers.go index af57afcbec..679fd34b43 100644 --- a/integration-tests/ccip-tests/actions/ccip_helpers.go +++ b/integration-tests/ccip-tests/actions/ccip_helpers.go @@ -3642,25 +3642,8 @@ func (lane *CCIPLane) DeployNewCCIPLane( } jobParams.P2PV2Bootstrappers = []string{p2pBootstrappersCommit.P2PV2Bootstrapper()} - if lane.PriceReportingDisabled { - reportingPluginConfig, err := json.Marshal([]byte(`{"PriceReportingDisabled": true,}`)) - if err != nil { - return fmt.Errorf("error encoding report plugin config: %w", err) - } - if testConf.CommitOCRParams == nil { - bTime, err := lane.Dest.Common.AvgBlockTime(lane.Context) - if err != nil { - return fmt.Errorf("error getting block time for report plugin: %w", err) - } - OCRCommitParams := contracts.OCR2ParamsForCommit(bTime) - OCRCommitParams.ReportingPluginConfig = reportingPluginConfig - testConf.CommitOCRParams = &OCRCommitParams - } else { - testConf.CommitOCRParams.ReportingPluginConfig = reportingPluginConfig - } - } - err = SetOCR2Config(lane.Context, lane.Logger, *testConf, commitNodes, execNodes, *lane.Dest) + err = SetOCR2Config(lane.Context, lane.Logger, *testConf, commitNodes, execNodes, *lane.Dest, lane.PriceReportingDisabled) if err != nil { return fmt.Errorf("failed to set ocr2 config: %w", err) } @@ -3698,6 +3681,7 @@ func SetOCR2Config( commitNodes, execNodes []*client.CLNodesWithKeys, destCCIP DestCCIPModule, + priceReportingDisabled bool, ) error { inflightExpiryExec := commonconfig.MustNewDuration(InflightExpiryExec) inflightExpiryCommit := commonconfig.MustNewDuration(InflightExpiryCommit) @@ -3734,6 +3718,7 @@ func SetOCR2Config( *commonconfig.MustNewDuration(5 * time.Second), 1e6, *inflightExpiryCommit, + priceReportingDisabled, ) if err != nil { return fmt.Errorf("failed to create commit offchain config: %w", err) diff --git a/integration-tests/ccip-tests/contracts/contract_deployer.go b/integration-tests/ccip-tests/contracts/contract_deployer.go index c1698adeb3..25fc6e708e 100644 --- a/integration-tests/ccip-tests/contracts/contract_deployer.go +++ b/integration-tests/ccip-tests/contracts/contract_deployer.go @@ -1401,7 +1401,8 @@ func NewCommitOffchainConfig( ExecGasPriceDeviationPPB uint32, TokenPriceHeartBeat config.Duration, TokenPriceDeviationPPB uint32, - InflightCacheExpiry config.Duration) (ccipconfig.OffchainConfig, error) { + InflightCacheExpiry config.Duration, + priceReportingDisabled bool) (ccipconfig.OffchainConfig, error) { switch VersionMap[CommitStoreContract] { case Latest: return testhelpers.NewCommitOffchainConfig( @@ -1411,6 +1412,7 @@ func NewCommitOffchainConfig( TokenPriceHeartBeat, TokenPriceDeviationPPB, InflightCacheExpiry, + priceReportingDisabled, ), nil case V1_2_0: return testhelpers_1_4_0.NewCommitOffchainConfig( @@ -1420,6 +1422,7 @@ func NewCommitOffchainConfig( TokenPriceHeartBeat, TokenPriceDeviationPPB, InflightCacheExpiry, + priceReportingDisabled, ), nil default: return nil, fmt.Errorf("version not supported: %s", VersionMap[CommitStoreContract]) diff --git a/integration-tests/ccip-tests/testconfig/global.go b/integration-tests/ccip-tests/testconfig/global.go index c8e896ff16..8a77cd3c1f 100644 --- a/integration-tests/ccip-tests/testconfig/global.go +++ b/integration-tests/ccip-tests/testconfig/global.go @@ -459,5 +459,4 @@ func (n *Node) Merge(from *Node) { type Lane struct { LeaderLaneEnabled bool - Leaders [][]string `toml:",omitempty"` } diff --git a/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml b/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml index be30478ca4..ee9bd01975 100644 --- a/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml +++ b/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml @@ -21,7 +21,6 @@ selected_networks = ['SIMULATED_1', 'SIMULATED_2'] [CCIP.Env.Lane] LeaderLaneEnabled=false -Leaders = [['SIMULATED_1', 'SIMULATED_2'], ['SIMULATED_2', 'SIMULATED_1']] # PrivateEthereumNetworks.NETWORK_NAME contains the configuration of private ethereum network that includes ethereum version, evm node client, chain id, # certain chain configurations, addresses to fund or custom docker images to be used. These are non-dev networks, but they all run just a single node. diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index d1771cb958..97e33d15f2 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -68,7 +68,7 @@ type NetworkPair struct { NetworkB blockchain.EVMNetwork ChainClientA blockchain.EVMClient ChainClientB blockchain.EVMClient - Leader Leader + Leader *Leader } type Leader struct { @@ -303,22 +303,20 @@ func (c *CCIPTestConfig) SetNetworkPairs(lggr zerolog.Logger) error { for idx, n := range c.NetworkPairs { if firstNetworkA == "" { firstNetworkA = n.NetworkA.Name - c.NetworkPairs[idx].Leader.BiDirectional = true - continue - } - if n.NetworkA.Name == firstNetworkA { - c.NetworkPairs[idx].Leader.UniDirectional = true + c.NetworkPairs[idx].Leader = &Leader{BiDirectional: true} + } else if n.NetworkA.Name == firstNetworkA { + c.NetworkPairs[idx].Leader = &Leader{UniDirectional: true} } } } for _, n := range c.NetworkPairs { - if n.Leader.BiDirectional { + if n.Leader != nil && n.Leader.BiDirectional { lggr.Info(). Str("NetworkA", fmt.Sprintf("%s-%d", n.NetworkA.Name, n.NetworkA.ChainID)). Str("NetworkB", fmt.Sprintf("%s-%d", n.NetworkB.Name, n.NetworkB.ChainID)). Str("Leader Lane", "Bidirectional"). Msg("Network Pairs") - } else if n.Leader.UniDirectional { + } else if n.Leader != nil && n.Leader.UniDirectional { lggr.Info(). Str("NetworkA", fmt.Sprintf("%s-%d", n.NetworkA.Name, n.NetworkA.ChainID)). Str("NetworkB", fmt.Sprintf("%s-%d", n.NetworkB.Name, n.NetworkB.ChainID)). @@ -587,7 +585,7 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( lggr *zerolog.Logger, networkA, networkB blockchain.EVMNetwork, chainClientA, chainClientB blockchain.EVMClient, - leader Leader, + leader *Leader, ) error { var ( t = o.Cfg.Test @@ -641,7 +639,7 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( Context: testcontext.Get(t), } // if it non leader lane, disable the price reporting - if !(leader.UniDirectional || leader.BiDirectional) { + if leader != nil && !(leader.UniDirectional || leader.BiDirectional) { ccipLaneA2B.PriceReportingDisabled = true } contractsA, ok := o.LaneContractsByNetwork.Load(networkA.Name) @@ -699,7 +697,7 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( DstNetworkLaneCfg: ccipLaneA2B.SrcNetworkLaneCfg, } // if it non leader lane, disable the price reporting - if !leader.BiDirectional { + if leader != nil && !leader.BiDirectional { ccipLaneB2A.PriceReportingDisabled = true } b2aLogger := lggr.With().Str("env", namespace).Str("Lane", From f02ac50eaf08cc22c41fee444a785211d2dea922 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Tue, 2 Jul 2024 14:34:21 -0400 Subject: [PATCH 03/26] Add explicit non leader case --- integration-tests/ccip-tests/testsetups/ccip.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 97e33d15f2..9dda09bf2c 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -306,6 +306,8 @@ func (c *CCIPTestConfig) SetNetworkPairs(lggr zerolog.Logger) error { c.NetworkPairs[idx].Leader = &Leader{BiDirectional: true} } else if n.NetworkA.Name == firstNetworkA { c.NetworkPairs[idx].Leader = &Leader{UniDirectional: true} + } else { + c.NetworkPairs[idx].Leader = &Leader{} } } } From d6ced58b670f5a5fc24b210374449ca86a8e8369 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Tue, 2 Jul 2024 16:21:04 -0400 Subject: [PATCH 04/26] Adding to integration-tests list --- .github/workflows/integration-tests.yml | 7 +++++++ .../ccip-tests/testconfig/tomls/leader-lane.toml | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index a5ea517456..b0ac72c1aa 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -372,6 +372,13 @@ jobs: os: ubuntu-latest file: ccip run: -run ^TestSmokeCCIPOffRampAggRateLimit$ + - name: ccip-smoke-leader-lane + nodes: 1 + dir: ccip-tests/smoke + os: ubuntu-latest + file: ccip + run: -run ^TestSmokeCCIPForBidirectionalLane$ + config_path: ./integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml - name: runlog id: runlog nodes: 2 diff --git a/integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml b/integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml new file mode 100644 index 0000000000..faf9f2f70a --- /dev/null +++ b/integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml @@ -0,0 +1,6 @@ +[CCIP] +[CCIP.Env.Lane] +LeaderLaneEnabled=true + +[CCIP.Groups.smoke] +NoOfNetworks = 3 \ No newline at end of file From 40002ad12ced4fdb1411941c37db777cc7b97c52 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Fri, 5 Jul 2024 12:42:12 -0400 Subject: [PATCH 05/26] Adding more checks --- .../ccip-tests/actions/ccip_helpers.go | 22 +++++- .../ccip-tests/testsetups/ccip.go | 69 +++++++++++++++++++ 2 files changed, 89 insertions(+), 2 deletions(-) diff --git a/integration-tests/ccip-tests/actions/ccip_helpers.go b/integration-tests/ccip-tests/actions/ccip_helpers.go index 0d6d5ccc98..d7b5396d02 100644 --- a/integration-tests/ccip-tests/actions/ccip_helpers.go +++ b/integration-tests/ccip-tests/actions/ccip_helpers.go @@ -184,6 +184,15 @@ type CCIPCommon struct { tokenPriceUpdateWatcher map[common.Address]*big.Int // key - token; value - timestamp of update gasUpdateWatcherMu *sync.Mutex gasUpdateWatcher map[uint64]*big.Int // key - destchain id; value - timestamp of update + GasUpdater []gasUpdateInfo +} + +type gasUpdateInfo struct { + Sender string + Tx string + Value *big.Int + DestChain uint64 + ChainSelector uint64 } // FreeUpUnusedSpace sets nil to various elements of ccipModule which are only used @@ -555,13 +564,21 @@ func (ccipModule *CCIPCommon) WatchForPriceUpdates(ctx context.Context, lggr *ze if tokenUpdateSub == nil { return fmt.Errorf("no event subscription found") } - processEvent := func(timestamp *big.Int, destChainSelector uint64) error { + processEvent := func(value, timestamp *big.Int, destChainSelector uint64, raw types.Log) error { destChain, err := chainselectors.ChainIdFromSelector(destChainSelector) if err != nil { return err } ccipModule.gasUpdateWatcherMu.Lock() ccipModule.gasUpdateWatcher[destChain] = timestamp + + ccipModule.GasUpdater = append(ccipModule.GasUpdater, gasUpdateInfo{ + Sender: raw.Address.Hex(), + Tx: raw.TxHash.Hex(), + Value: value, + DestChain: destChain, + ChainSelector: destChainSelector, + }) ccipModule.gasUpdateWatcherMu.Unlock() lggr.Info(). Uint64("chainSelector", destChainSelector). @@ -578,13 +595,14 @@ func (ccipModule *CCIPCommon) WatchForPriceUpdates(ctx context.Context, lggr *ze tokenUpdateSub.Unsubscribe() ccipModule.gasUpdateWatcher = nil ccipModule.gasUpdateWatcherMu = nil + ccipModule.GasUpdater = nil ccipModule.tokenPriceUpdateWatcher = nil ccipModule.tokenPriceUpdateWatcherMu = nil }() for { select { case e := <-gasUpdateEventLatest: - err := processEvent(e.Timestamp, e.DestChain) + err := processEvent(e.Value, e.Timestamp, e.DestChain, e.Raw) if err != nil { continue } diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 9dda09bf2c..0de777aae0 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -868,6 +868,72 @@ func (o *CCIPTestSetUpOutputs) WaitForPriceUpdates() { require.NoError(t, priceUpdateGrp.Wait()) } +func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction() error { + txCount := make(map[string]map[uint64]string) + for _, lanes := range o.ReadLanes() { + lanes := lanes + for _, g := range lanes.ForwardLane.Source.Common.GasUpdater { + if g.Value == nil { + return fmt.Errorf("gas update value should not be nil for chain selected %s in tx %s", g.ChainSelector, g.Tx) + } + if v, ok := txCount[g.Tx]; ok { + v[g.ChainSelector] = g.Value.String() + txCount[g.Tx] = v + } else { + txCount[g.Tx] = map[uint64]string{ + g.ChainSelector: g.Value.String(), + } + } + + lanes.ForwardLane.Logger.Debug(). + Str("Sender", g.Sender). + Str("Tx Hash", g.Tx). + Uint64("Dest", g.DestChain). + Bool("PR disabled", lanes.ForwardLane.PriceReportingDisabled). + Uint64("ChainSelector", g.ChainSelector). + Str("Value", g.Value.String()). + Msg("Gas price Updater details") + } + if lanes.ReverseLane != nil { + for _, g := range lanes.ReverseLane.Source.Common.GasUpdater { + if g.Value == nil { + return fmt.Errorf("gas update value should not be nil for chain selected %s in tx %s", g.ChainSelector, g.Tx) + } + if v, ok := txCount[g.Tx]; ok { + v[g.ChainSelector] = g.Value.String() + txCount[g.Tx] = v + } else { + txCount[g.Tx] = map[uint64]string{ + g.ChainSelector: g.Value.String(), + } + } + lanes.ReverseLane.Logger.Debug(). + Str("Sender", g.Sender). + Str("Tx Hash", g.Tx). + Uint64("Dest", g.DestChain). + Bool("PR disabled", lanes.ReverseLane.PriceReportingDisabled). + Uint64("ChainSelector", g.ChainSelector). + Str("Value", g.Value.String()). + Msg("Gas price Updater details") + } + } + } + // when leader lane setup is enabled, number of transaction should match the number of network and each transaction + // should have number of network - 1 chain selectors and corresponding gas values + if len(txCount) != len(o.Cfg.AllNetworks) { + return fmt.Errorf("transaction count %d shouldn't be more than the number of networks %d when "+ + "leader lane feature is on", len(txCount), len(o.Cfg.AllNetworks)) + } + for _, v := range txCount { + if len(v) != len(o.Cfg.AllNetworks)-1 { + return fmt.Errorf("number of chain selector count %d shouldn't be more than the number of "+ + "all networks minus one %d", len(v), len(o.Cfg.AllNetworks)-1) + } + } + log.Info().Interface("Token list", txCount).Msg("List of transaction hash:") + return nil +} + // CCIPDefaultTestSetUp sets up the environment for CCIP tests // if configureCLNode is set as false, it assumes: // 1. contracts are already deployed on live networks @@ -1070,6 +1136,9 @@ func CCIPDefaultTestSetUp( require.NoError(t, setUpArgs.JobAddGrp.Wait(), "Creating jobs shouldn't fail") // wait for price updates to be available setUpArgs.WaitForPriceUpdates() + if setUpArgs.Cfg.EnvInput.Lane.LeaderLaneEnabled { + require.NoError(t, setUpArgs.CheckGasUpdateTransaction(), "gas update transaction check shouldn't fail") + } // if dynamic price update is required if setUpArgs.Cfg.TestGroupInput.TokenConfig.IsDynamicPriceUpdate() { require.NoError(t, setUpArgs.SetupDynamicTokenPriceUpdates(), "setting up dynamic price update should not fail") From 4e437e818640a2f8e7783193bf2af3d4fd1ad352 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Mon, 8 Jul 2024 12:41:38 -0400 Subject: [PATCH 06/26] Clean up --- integration-tests/ccip-tests/actions/ccip_helpers.go | 8 ++++---- integration-tests/ccip-tests/testsetups/ccip.go | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/integration-tests/ccip-tests/actions/ccip_helpers.go b/integration-tests/ccip-tests/actions/ccip_helpers.go index 6b59696abe..d796970e83 100644 --- a/integration-tests/ccip-tests/actions/ccip_helpers.go +++ b/integration-tests/ccip-tests/actions/ccip_helpers.go @@ -184,10 +184,10 @@ type CCIPCommon struct { tokenPriceUpdateWatcher map[common.Address]*big.Int // key - token; value - timestamp of update gasUpdateWatcherMu *sync.Mutex gasUpdateWatcher map[uint64]*big.Int // key - destchain id; value - timestamp of update - GasUpdater []gasUpdateInfo + GasUpdateEvents []gasUpdateEvent } -type gasUpdateInfo struct { +type gasUpdateEvent struct { Sender string Tx string Value *big.Int @@ -565,7 +565,7 @@ func (ccipModule *CCIPCommon) WatchForPriceUpdates(ctx context.Context, lggr *ze ccipModule.gasUpdateWatcherMu.Lock() ccipModule.gasUpdateWatcher[destChain] = timestamp - ccipModule.GasUpdater = append(ccipModule.GasUpdater, gasUpdateInfo{ + ccipModule.GasUpdateEvents = append(ccipModule.GasUpdateEvents, gasUpdateEvent{ Sender: raw.Address.Hex(), Tx: raw.TxHash.Hex(), Value: value, @@ -588,7 +588,7 @@ func (ccipModule *CCIPCommon) WatchForPriceUpdates(ctx context.Context, lggr *ze tokenUpdateSub.Unsubscribe() ccipModule.gasUpdateWatcher = nil ccipModule.gasUpdateWatcherMu = nil - ccipModule.GasUpdater = nil + ccipModule.GasUpdateEvents = nil ccipModule.tokenPriceUpdateWatcher = nil ccipModule.tokenPriceUpdateWatcherMu = nil }() diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 86da7fc1ae..98826a1461 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -873,7 +873,7 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction() error { txCount := make(map[string]map[uint64]string) for _, lanes := range o.ReadLanes() { lanes := lanes - for _, g := range lanes.ForwardLane.Source.Common.GasUpdater { + for _, g := range lanes.ForwardLane.Source.Common.GasUpdateEvents { if g.Value == nil { return fmt.Errorf("gas update value should not be nil for chain selected %s in tx %s", g.ChainSelector, g.Tx) } @@ -890,13 +890,12 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction() error { Str("Sender", g.Sender). Str("Tx Hash", g.Tx). Uint64("Dest", g.DestChain). - Bool("PR disabled", lanes.ForwardLane.PriceReportingDisabled). Uint64("ChainSelector", g.ChainSelector). Str("Value", g.Value.String()). Msg("Gas price Updater details") } if lanes.ReverseLane != nil { - for _, g := range lanes.ReverseLane.Source.Common.GasUpdater { + for _, g := range lanes.ReverseLane.Source.Common.GasUpdateEvents { if g.Value == nil { return fmt.Errorf("gas update value should not be nil for chain selected %s in tx %s", g.ChainSelector, g.Tx) } @@ -912,7 +911,6 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction() error { Str("Sender", g.Sender). Str("Tx Hash", g.Tx). Uint64("Dest", g.DestChain). - Bool("PR disabled", lanes.ReverseLane.PriceReportingDisabled). Uint64("ChainSelector", g.ChainSelector). Str("Value", g.Value.String()). Msg("Gas price Updater details") From fe43a233542a7d43f012d80045d6e10c8ee83774 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Mon, 8 Jul 2024 13:15:28 -0400 Subject: [PATCH 07/26] Adding details to test config readme --- .../ccip-tests/testconfig/README.md | 3 + .../testconfig/tomls/ccip-default.toml | 1 + .../testconfig/tomls/leader-lane.toml | 1 + .../ccip-tests/testsetups/ccip.go | 69 ++++++++----------- 4 files changed, 35 insertions(+), 39 deletions(-) diff --git a/integration-tests/ccip-tests/testconfig/README.md b/integration-tests/ccip-tests/testconfig/README.md index a402c218d0..e0b9fca1c9 100644 --- a/integration-tests/ccip-tests/testconfig/README.md +++ b/integration-tests/ccip-tests/testconfig/README.md @@ -393,6 +393,9 @@ base_url = "https://grafana..../" dashboard_url = "/d/6vjVx-1V8/ccip-long-running-tests" ``` +### CCIP.Env.Lane.LeaderLaneEnabled +Specifies whether to enable the leader lane feature. This setting is only applicable for new deployments. + ## CCIP.Groups Specifies the test config specific to each test type. Available test types are: - **CCIP.Groups.load** diff --git a/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml b/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml index ee9bd01975..64c625a7ef 100644 --- a/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml +++ b/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml @@ -20,6 +20,7 @@ TTL = '5h' selected_networks = ['SIMULATED_1', 'SIMULATED_2'] [CCIP.Env.Lane] +# To enable the leader lane feature. This setting is only applicable for new deployments. LeaderLaneEnabled=false # PrivateEthereumNetworks.NETWORK_NAME contains the configuration of private ethereum network that includes ethereum version, evm node client, chain id, diff --git a/integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml b/integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml index faf9f2f70a..3b5745f3d4 100644 --- a/integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml +++ b/integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml @@ -1,5 +1,6 @@ [CCIP] [CCIP.Env.Lane] +# To enable the leader lane feature. This setting is only applicable for new deployments. LeaderLaneEnabled=true [CCIP.Groups.smoke] diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 98826a1461..f64342a45c 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -296,10 +296,11 @@ func (c *CCIPTestConfig) SetNetworkPairs(lggr zerolog.Logger) error { c.NetworkPairs = c.NetworkPairs[:c.TestGroupInput.MaxNoOfLanes] } - // setting leader lane details to network pairs if it is enabled - if c.EnvInput.Lane.LeaderLaneEnabled { - // the way we are doing this is to set first found network as leader bidirectionally and whichever the pair - //has the same network A will be uni-directionally marked as leader + // setting leader lane details to network pairs if it is enabled and only in simulated environments + if c.EnvInput.Lane.LeaderLaneEnabled && !pointer.GetBool(c.TestGroupInput.ExistingDeployment) { + // the way we are doing this is to set first found network pair as leader lanes (ex: A - B) in both the direction + // and any network pair has same network (A) will be uni-directionally marked as leader. Like, A - C, A - D. + // by this we will make sure all required leader lanes will be defined. firstNetworkA := "" for idx, n := range c.NetworkPairs { if firstNetworkA == "" { @@ -870,23 +871,22 @@ func (o *CCIPTestSetUpOutputs) WaitForPriceUpdates() { } func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction() error { - txCount := make(map[string]map[uint64]string) - for _, lanes := range o.ReadLanes() { - lanes := lanes - for _, g := range lanes.ForwardLane.Source.Common.GasUpdateEvents { + transactions := make(map[string]map[uint64]string) + readGasUpdateTx := func(lane *actions.CCIPLane) error { + for _, g := range lane.Source.Common.GasUpdateEvents { if g.Value == nil { return fmt.Errorf("gas update value should not be nil for chain selected %s in tx %s", g.ChainSelector, g.Tx) } - if v, ok := txCount[g.Tx]; ok { + if v, ok := transactions[g.Tx]; ok { v[g.ChainSelector] = g.Value.String() - txCount[g.Tx] = v + transactions[g.Tx] = v } else { - txCount[g.Tx] = map[uint64]string{ + transactions[g.Tx] = map[uint64]string{ g.ChainSelector: g.Value.String(), } } - lanes.ForwardLane.Logger.Debug(). + lane.Logger.Debug(). Str("Sender", g.Sender). Str("Tx Hash", g.Tx). Uint64("Dest", g.DestChain). @@ -894,42 +894,33 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction() error { Str("Value", g.Value.String()). Msg("Gas price Updater details") } + return nil + } + for _, lanes := range o.ReadLanes() { + lanes := lanes + if err := readGasUpdateTx(lanes.ForwardLane); err != nil { + return err + } if lanes.ReverseLane != nil { - for _, g := range lanes.ReverseLane.Source.Common.GasUpdateEvents { - if g.Value == nil { - return fmt.Errorf("gas update value should not be nil for chain selected %s in tx %s", g.ChainSelector, g.Tx) - } - if v, ok := txCount[g.Tx]; ok { - v[g.ChainSelector] = g.Value.String() - txCount[g.Tx] = v - } else { - txCount[g.Tx] = map[uint64]string{ - g.ChainSelector: g.Value.String(), - } - } - lanes.ReverseLane.Logger.Debug(). - Str("Sender", g.Sender). - Str("Tx Hash", g.Tx). - Uint64("Dest", g.DestChain). - Uint64("ChainSelector", g.ChainSelector). - Str("Value", g.Value.String()). - Msg("Gas price Updater details") + if err := readGasUpdateTx(lanes.ReverseLane); err != nil { + return err } - } } - // when leader lane setup is enabled, number of transaction should match the number of network and each transaction - // should have number of network - 1 chain selectors and corresponding gas values - if len(txCount) != len(o.Cfg.AllNetworks) { + // when leader lane setup is enabled, number of transaction should match the number of network. + // Say we have 3 networks, then we expect 3 transactions in total from six events. + if len(transactions) != len(o.Cfg.AllNetworks) { return fmt.Errorf("transaction count %d shouldn't be more than the number of networks %d when "+ - "leader lane feature is on", len(txCount), len(o.Cfg.AllNetworks)) + "leader lane feature is on", len(transactions), len(o.Cfg.AllNetworks)) } - for _, v := range txCount { + // each transaction should have number of network - 1 chain selectors and corresponding gas values. + // Say we have 3 networks, then we have expect every transaction to have 2 chain selectors + for _, v := range transactions { if len(v) != len(o.Cfg.AllNetworks)-1 { return fmt.Errorf("number of chain selector count %d shouldn't be more than the number of "+ "all networks minus one %d", len(v), len(o.Cfg.AllNetworks)-1) } } - log.Info().Interface("Token list", txCount).Msg("List of transaction hash:") + log.Debug().Interface("Gas update transactions", transactions).Msg("List of transaction hash:") return nil } @@ -1135,7 +1126,7 @@ func CCIPDefaultTestSetUp( require.NoError(t, setUpArgs.JobAddGrp.Wait(), "Creating jobs shouldn't fail") // wait for price updates to be available setUpArgs.WaitForPriceUpdates() - if setUpArgs.Cfg.EnvInput.Lane.LeaderLaneEnabled { + if setUpArgs.Cfg.EnvInput.Lane.LeaderLaneEnabled && !pointer.GetBool(setUpArgs.Cfg.TestGroupInput.ExistingDeployment) { require.NoError(t, setUpArgs.CheckGasUpdateTransaction(), "gas update transaction check shouldn't fail") } // if dynamic price update is required From 91cc5d65877256d255f5942e2e48a9e041d923c1 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Mon, 8 Jul 2024 13:35:57 -0400 Subject: [PATCH 08/26] fix error --- integration-tests/ccip-tests/testsetups/ccip.go | 1 + 1 file changed, 1 insertion(+) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index f64342a45c..45db37843d 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -905,6 +905,7 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction() error { if err := readGasUpdateTx(lanes.ReverseLane); err != nil { return err } + } } // when leader lane setup is enabled, number of transaction should match the number of network. // Say we have 3 networks, then we expect 3 transactions in total from six events. From fbeec1d20ba66368378bcefe2a2ed33d4a9c98c4 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Mon, 8 Jul 2024 14:29:47 -0400 Subject: [PATCH 09/26] Lint fixes --- integration-tests/ccip-tests/testsetups/ccip.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 45db37843d..c31b4c44a4 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -875,7 +875,7 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction() error { readGasUpdateTx := func(lane *actions.CCIPLane) error { for _, g := range lane.Source.Common.GasUpdateEvents { if g.Value == nil { - return fmt.Errorf("gas update value should not be nil for chain selected %s in tx %s", g.ChainSelector, g.Tx) + return fmt.Errorf("gas update value should not be nil for chain selected %v in tx %s", g.ChainSelector, g.Tx) } if v, ok := transactions[g.Tx]; ok { v[g.ChainSelector] = g.Value.String() From 2844fb029e11be831e44b8c222e96ef71c2f2887 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Tue, 9 Jul 2024 10:35:09 -0400 Subject: [PATCH 10/26] Review comments --- .../testconfig/tomls/leader-lane.toml | 3 +- .../ccip-tests/testsetups/ccip.go | 112 ++++++++++-------- 2 files changed, 65 insertions(+), 50 deletions(-) diff --git a/integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml b/integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml index 3b5745f3d4..087b732cad 100644 --- a/integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml +++ b/integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml @@ -4,4 +4,5 @@ LeaderLaneEnabled=true [CCIP.Groups.smoke] -NoOfNetworks = 3 \ No newline at end of file +NoOfNetworks = 4 +NoOfRoutersPerPair = 2 \ No newline at end of file diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index c31b4c44a4..ad2efe10ce 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -67,12 +67,11 @@ type NetworkPair struct { NetworkB blockchain.EVMNetwork ChainClientA blockchain.EVMClient ChainClientB blockchain.EVMClient - Leader *Leader } -type Leader struct { - BiDirectional bool - UniDirectional bool +type LeaderLane struct { + source string + dest string } type CCIPTestConfig struct { @@ -84,6 +83,7 @@ type CCIPTestConfig struct { AllNetworks map[string]blockchain.EVMNetwork SelectedNetworks []blockchain.EVMNetwork NetworkPairs []NetworkPair + LeaderLanes []LeaderLane GethResourceProfile map[string]interface{} } @@ -298,47 +298,63 @@ func (c *CCIPTestConfig) SetNetworkPairs(lggr zerolog.Logger) error { // setting leader lane details to network pairs if it is enabled and only in simulated environments if c.EnvInput.Lane.LeaderLaneEnabled && !pointer.GetBool(c.TestGroupInput.ExistingDeployment) { - // the way we are doing this is to set first found network pair as leader lanes (ex: A - B) in both the direction - // and any network pair has same network (A) will be uni-directionally marked as leader. Like, A - C, A - D. - // by this we will make sure all required leader lanes will be defined. - firstNetworkA := "" - for idx, n := range c.NetworkPairs { - if firstNetworkA == "" { - firstNetworkA = n.NetworkA.Name - c.NetworkPairs[idx].Leader = &Leader{BiDirectional: true} - } else if n.NetworkA.Name == firstNetworkA { - c.NetworkPairs[idx].Leader = &Leader{UniDirectional: true} - } else { - c.NetworkPairs[idx].Leader = &Leader{} - } - } + c.DefineLeaderLanes() } for _, n := range c.NetworkPairs { - if n.Leader != nil && n.Leader.BiDirectional { - lggr.Info(). - Str("NetworkA", fmt.Sprintf("%s-%d", n.NetworkA.Name, n.NetworkA.ChainID)). - Str("NetworkB", fmt.Sprintf("%s-%d", n.NetworkB.Name, n.NetworkB.ChainID)). - Str("Leader Lane", "Bidirectional"). - Msg("Network Pairs") - } else if n.Leader != nil && n.Leader.UniDirectional { - lggr.Info(). - Str("NetworkA", fmt.Sprintf("%s-%d", n.NetworkA.Name, n.NetworkA.ChainID)). - Str("NetworkB", fmt.Sprintf("%s-%d", n.NetworkB.Name, n.NetworkB.ChainID)). - Str("Leader Lane", "Unidirectional"). - Msg("Network Pairs") - } else { - lggr.Info(). - Str("NetworkA", fmt.Sprintf("%s-%d", n.NetworkA.Name, n.NetworkA.ChainID)). - Str("NetworkB", fmt.Sprintf("%s-%d", n.NetworkB.Name, n.NetworkB.ChainID)). - Str("Leader Lane", "False"). - Msg("Network Pairs") - } + lggr.Info(). + Str("NetworkA", fmt.Sprintf("%s-%d", n.NetworkA.Name, n.NetworkA.ChainID)). + Str("NetworkB", fmt.Sprintf("%s-%d", n.NetworkB.Name, n.NetworkB.ChainID)). + Msg("Network Pairs") + } + for _, lane := range c.LeaderLanes { + lggr.Info(). + Str("Source", lane.source). + Str("Destination", lane.dest). + Msg("Leader Lane: ") } lggr.Info().Int("Pairs", len(c.NetworkPairs)).Msg("No Of Lanes") return allError } +func (c *CCIPTestConfig) DefineLeaderLanes() { + // the way we are doing this is by creating a map with key as destination network name and value as list of source network name. + // Once map is available, picking every first source network name from the list to form the leader lanes + sourceLanes := make(map[string][]string) + for _, n := range c.NetworkPairs { + if val, ok := sourceLanes[n.NetworkB.Name]; ok { + sourceLanes[n.NetworkB.Name] = append(val, n.NetworkA.Name) + } else { + sourceLanes[n.NetworkB.Name] = []string{n.NetworkA.Name} + } + if pointer.GetBool(c.TestGroupInput.BiDirectionalLane) { + if val, ok := sourceLanes[n.NetworkA.Name]; ok { + sourceLanes[n.NetworkA.Name] = append(val, n.NetworkB.Name) + } else { + sourceLanes[n.NetworkA.Name] = []string{n.NetworkB.Name} + } + } + } + for k, v := range sourceLanes { + c.LeaderLanes = append(c.LeaderLanes, LeaderLane{ + source: v[0], + dest: k, + }) + } +} + +func (c *CCIPTestConfig) isLeaderLane(lane *actions.CCIPLane) bool { + if len(c.LeaderLanes) == 0 { + return false + } + for _, leader := range c.LeaderLanes { + if leader.source == lane.SourceNetworkName && leader.dest == lane.DestNetworkName { + return true + } + } + return false +} + func (c *CCIPTestConfig) FormNetworkPairCombinations() { for i := 0; i < c.TestGroupInput.NoOfNetworks; i++ { for j := i + 1; j < c.TestGroupInput.NoOfNetworks; j++ { @@ -589,7 +605,6 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( lggr *zerolog.Logger, networkA, networkB blockchain.EVMNetwork, chainClientA, chainClientB blockchain.EVMClient, - leader *Leader, ) error { var ( t = o.Cfg.Test @@ -643,7 +658,7 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( Context: testcontext.Get(t), } // if it non leader lane, disable the price reporting - if leader != nil && !(leader.UniDirectional || leader.BiDirectional) { + if !o.Cfg.isLeaderLane(ccipLaneA2B) { ccipLaneA2B.PriceReportingDisabled = true } contractsA, ok := o.LaneContractsByNetwork.Load(networkA.Name) @@ -701,7 +716,7 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( DstNetworkLaneCfg: ccipLaneA2B.SrcNetworkLaneCfg, } // if it non leader lane, disable the price reporting - if leader != nil && !leader.BiDirectional { + if !o.Cfg.isLeaderLane(ccipLaneB2A) { ccipLaneB2A.PriceReportingDisabled = true } b2aLogger := lggr.With().Str("env", namespace).Str("Lane", @@ -907,18 +922,17 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction() error { } } } - // when leader lane setup is enabled, number of transaction should match the number of network. - // Say we have 3 networks, then we expect 3 transactions in total from six events. - if len(transactions) != len(o.Cfg.AllNetworks) { - return fmt.Errorf("transaction count %d shouldn't be more than the number of networks %d when "+ - "leader lane feature is on", len(transactions), len(o.Cfg.AllNetworks)) + // when leader lane setup is enabled, number of transaction should match the number of leader lanes defined. + if len(transactions) != len(o.Cfg.LeaderLanes) { + return fmt.Errorf("transaction count %d should match the number of leader lanes %d", + len(transactions), len(o.Cfg.LeaderLanes)) } // each transaction should have number of network - 1 chain selectors and corresponding gas values. // Say we have 3 networks, then we have expect every transaction to have 2 chain selectors for _, v := range transactions { - if len(v) != len(o.Cfg.AllNetworks)-1 { - return fmt.Errorf("number of chain selector count %d shouldn't be more than the number of "+ - "all networks minus one %d", len(v), len(o.Cfg.AllNetworks)-1) + if len(v) != o.Cfg.TestGroupInput.NoOfNetworks-1 { + return fmt.Errorf("number of chain selector count %d should match the number of "+ + "networks minus one %d", len(v), o.Cfg.TestGroupInput.NoOfNetworks-1) } } log.Debug().Interface("Gas update transactions", transactions).Msg("List of transaction hash:") @@ -1108,7 +1122,7 @@ func CCIPDefaultTestSetUp( laneAddGrp.Go(func() error { return setUpArgs.AddLanesForNetworkPair( lggr, n.NetworkA, n.NetworkB, - chainClientByChainID[n.NetworkA.ChainID], chainClientByChainID[n.NetworkB.ChainID], n.Leader, + chainClientByChainID[n.NetworkA.ChainID], chainClientByChainID[n.NetworkB.ChainID], ) }) } From 7ba8113294240ad279e1a8634f68214699325117 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Tue, 9 Jul 2024 12:47:57 -0400 Subject: [PATCH 11/26] Fix is leader lane logic --- integration-tests/ccip-tests/testsetups/ccip.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 10cd60277d..26188e2654 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -344,9 +344,6 @@ func (c *CCIPTestConfig) DefineLeaderLanes() { } func (c *CCIPTestConfig) isLeaderLane(lane *actions.CCIPLane) bool { - if len(c.LeaderLanes) == 0 { - return false - } for _, leader := range c.LeaderLanes { if leader.source == lane.SourceNetworkName && leader.dest == lane.DestNetworkName { return true @@ -658,7 +655,7 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( Context: testcontext.Get(t), } // if it non leader lane, disable the price reporting - if !o.Cfg.isLeaderLane(ccipLaneA2B) { + if len(o.Cfg.LeaderLanes) > 0 && !o.Cfg.isLeaderLane(ccipLaneA2B) { ccipLaneA2B.PriceReportingDisabled = true } contractsA, ok := o.LaneContractsByNetwork.Load(networkA.Name) @@ -703,7 +700,7 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( ccipLaneB2A = &actions.CCIPLane{ Test: t, - SourceNetworkName: actions.NetworkName(networkB.Name), + SourceNetworkName: actions.NetworkName(networkB.Name),t DestNetworkName: actions.NetworkName(networkA.Name), SourceChain: sourceChainClientB2A, DestChain: destChainClientB2A, @@ -716,7 +713,7 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( DstNetworkLaneCfg: ccipLaneA2B.SrcNetworkLaneCfg, } // if it non leader lane, disable the price reporting - if !o.Cfg.isLeaderLane(ccipLaneB2A) { + if len(o.Cfg.LeaderLanes) > 0 && !o.Cfg.isLeaderLane(ccipLaneB2A) { ccipLaneB2A.PriceReportingDisabled = true } b2aLogger := lggr.With().Str("env", namespace).Str("Lane", From 732438210185b9965ea99e00bfc0d58029b25c98 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Tue, 9 Jul 2024 14:02:52 -0400 Subject: [PATCH 12/26] Fix error --- integration-tests/ccip-tests/testsetups/ccip.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 26188e2654..d6f3b631d9 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -700,7 +700,7 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( ccipLaneB2A = &actions.CCIPLane{ Test: t, - SourceNetworkName: actions.NetworkName(networkB.Name),t + SourceNetworkName: actions.NetworkName(networkB.Name), DestNetworkName: actions.NetworkName(networkA.Name), SourceChain: sourceChainClientB2A, DestChain: destChainClientB2A, From 01ce5958fa18c9a0062d4ae1a10f526a3b613274 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Tue, 9 Jul 2024 17:23:26 -0400 Subject: [PATCH 13/26] Review comments --- .../ccip-tests/actions/ccip_helpers.go | 3 + .../ccip-tests/testconfig/global.go | 5 -- .../testconfig/tomls/ccip-default.toml | 4 -- .../testconfig/tomls/leader-lane.toml | 4 -- .../ccip-tests/testsetups/ccip.go | 58 +++++++++++-------- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/integration-tests/ccip-tests/actions/ccip_helpers.go b/integration-tests/ccip-tests/actions/ccip_helpers.go index 62ce2996c9..e9df87c606 100644 --- a/integration-tests/ccip-tests/actions/ccip_helpers.go +++ b/integration-tests/ccip-tests/actions/ccip_helpers.go @@ -532,6 +532,9 @@ func (ccipModule *CCIPCommon) WaitForPriceUpdates( } } +// WatchForPriceUpdates helps to ensure the price updates are happening in price registry by subscribing to a couple +// of price update events and add the event details to watchers. It subscribes to 'UsdPerUnitGasUpdated' +// and 'UsdPerTokenUpdated' event. func (ccipModule *CCIPCommon) WatchForPriceUpdates(ctx context.Context, lggr *zerolog.Logger) error { gasUpdateEventLatest := make(chan *price_registry.PriceRegistryUsdPerUnitGasUpdated) tokenUpdateEvent := make(chan *price_registry.PriceRegistryUsdPerTokenUpdated) diff --git a/integration-tests/ccip-tests/testconfig/global.go b/integration-tests/ccip-tests/testconfig/global.go index 8a77cd3c1f..331737c5fb 100644 --- a/integration-tests/ccip-tests/testconfig/global.go +++ b/integration-tests/ccip-tests/testconfig/global.go @@ -172,7 +172,6 @@ type Common struct { Mockserver *string `toml:",omitempty"` NewCLCluster *ChainlinkDeployment `toml:",omitempty"` // NewCLCluster is the new chainlink cluster to create, if specified along with ExistingCLCluster this will be ignored Network *ctfconfig.NetworkConfig `toml:",omitempty"` - Lane *Lane `toml:",omitempty"` PrivateEthereumNetworks map[string]*ctfconfig.EthereumNetworkConfig `toml:",omitempty"` Logging *ctfconfig.LoggingConfig `toml:",omitempty"` } @@ -456,7 +455,3 @@ func (n *Node) Merge(from *Node) { } } } - -type Lane struct { - LeaderLaneEnabled bool -} diff --git a/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml b/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml index 64c625a7ef..77dc97f77f 100644 --- a/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml +++ b/integration-tests/ccip-tests/testconfig/tomls/ccip-default.toml @@ -19,10 +19,6 @@ TTL = '5h' [CCIP.Env.Network] selected_networks = ['SIMULATED_1', 'SIMULATED_2'] -[CCIP.Env.Lane] -# To enable the leader lane feature. This setting is only applicable for new deployments. -LeaderLaneEnabled=false - # PrivateEthereumNetworks.NETWORK_NAME contains the configuration of private ethereum network that includes ethereum version, evm node client, chain id, # certain chain configurations, addresses to fund or custom docker images to be used. These are non-dev networks, but they all run just a single node. [CCIP.Env.PrivateEthereumNetworks.SIMULATED_1] diff --git a/integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml b/integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml index 087b732cad..76b97ad97b 100644 --- a/integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml +++ b/integration-tests/ccip-tests/testconfig/tomls/leader-lane.toml @@ -1,8 +1,4 @@ [CCIP] -[CCIP.Env.Lane] -# To enable the leader lane feature. This setting is only applicable for new deployments. -LeaderLaneEnabled=true - [CCIP.Groups.smoke] NoOfNetworks = 4 NoOfRoutersPerPair = 2 \ No newline at end of file diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 6fd7d82005..fdd67171eb 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -71,6 +71,7 @@ type NetworkPair struct { ChainClientB blockchain.EVMClient } +// LeaderLane is to hold the details of leader lane source and destination network type LeaderLane struct { source string dest string @@ -329,8 +330,8 @@ func (c *CCIPTestConfig) SetNetworkPairs(lggr zerolog.Logger) error { } // setting leader lane details to network pairs if it is enabled and only in simulated environments - if c.EnvInput.Lane.LeaderLaneEnabled && !pointer.GetBool(c.TestGroupInput.ExistingDeployment) { - c.DefineLeaderLanes() + if !pointer.GetBool(c.TestGroupInput.ExistingDeployment) { + c.defineLeaderLanes(lggr) } for _, n := range c.NetworkPairs { lggr.Info(). @@ -339,7 +340,7 @@ func (c *CCIPTestConfig) SetNetworkPairs(lggr zerolog.Logger) error { Msg("Network Pairs") } for _, lane := range c.LeaderLanes { - lggr.Info(). + lggr.Debug(). Str("Source", lane.source). Str("Destination", lane.dest). Msg("Leader Lane: ") @@ -349,35 +350,41 @@ func (c *CCIPTestConfig) SetNetworkPairs(lggr zerolog.Logger) error { return allError } -func (c *CCIPTestConfig) DefineLeaderLanes() { - // the way we are doing this is by creating a map with key as destination network name and value as list of source network name. +// defineLeaderLanes goes over the available network pairs and define one leader lane per destination +func (c *CCIPTestConfig) defineLeaderLanes(lggr zerolog.Logger) { + // the way we are doing this is by creating a map with key as destination network name and value as source network name. // Once map is available, picking every first source network name from the list to form the leader lanes - sourceLanes := make(map[string][]string) + if err := contracts.MatchContractVersionsOrAbove(map[contracts.Name]contracts.Version{ + contracts.OffRampContract: contracts.V1_2_0, + contracts.OnRampContract: contracts.V1_2_0, + }); err != nil { + lggr.Info().Str("Required contract version", contracts.V1_2_0.String()).Msg("Leader lane feature is not enabled") + return + } + + leaderLanes := make(map[string]string) for _, n := range c.NetworkPairs { - if val, ok := sourceLanes[n.NetworkB.Name]; ok { - sourceLanes[n.NetworkB.Name] = append(val, n.NetworkA.Name) - } else { - sourceLanes[n.NetworkB.Name] = []string{n.NetworkA.Name} + if _, ok := leaderLanes[n.NetworkB.Name]; !ok { + leaderLanes[n.NetworkB.Name] = n.NetworkA.Name } if pointer.GetBool(c.TestGroupInput.BiDirectionalLane) { - if val, ok := sourceLanes[n.NetworkA.Name]; ok { - sourceLanes[n.NetworkA.Name] = append(val, n.NetworkB.Name) - } else { - sourceLanes[n.NetworkA.Name] = []string{n.NetworkB.Name} + if _, ok := leaderLanes[n.NetworkA.Name]; !ok { + leaderLanes[n.NetworkA.Name] = n.NetworkB.Name } } } - for k, v := range sourceLanes { + for k, v := range leaderLanes { c.LeaderLanes = append(c.LeaderLanes, LeaderLane{ - source: v[0], + source: v, dest: k, }) } } -func (c *CCIPTestConfig) isLeaderLane(lane *actions.CCIPLane) bool { +// isLeaderLane checks the given lane is leader lane and return boolean accordingly +func (c *CCIPTestConfig) isLeaderLane(source, dest string) bool { for _, leader := range c.LeaderLanes { - if leader.source == lane.SourceNetworkName && leader.dest == lane.DestNetworkName { + if leader.source == source && leader.dest == dest { return true } } @@ -687,7 +694,7 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( Context: testcontext.Get(t), } // if it non leader lane, disable the price reporting - if len(o.Cfg.LeaderLanes) > 0 && !o.Cfg.isLeaderLane(ccipLaneA2B) { + if len(o.Cfg.LeaderLanes) > 0 && !o.Cfg.isLeaderLane(ccipLaneA2B.SourceNetworkName, ccipLaneA2B.DestNetworkName) { ccipLaneA2B.PriceReportingDisabled = true } contractsA, ok := o.LaneContractsByNetwork.Load(networkA.Name) @@ -745,7 +752,8 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( DstNetworkLaneCfg: ccipLaneA2B.SrcNetworkLaneCfg, } // if it non leader lane, disable the price reporting - if len(o.Cfg.LeaderLanes) > 0 && !o.Cfg.isLeaderLane(ccipLaneB2A) { + if len(o.Cfg.LeaderLanes) > 0 && + !o.Cfg.isLeaderLane(ccipLaneB2A.SourceNetworkName, ccipLaneB2A.DestNetworkName) { ccipLaneB2A.PriceReportingDisabled = true } b2aLogger := lggr.With().Str("env", namespace).Str("Lane", @@ -941,7 +949,6 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction() error { return nil } for _, lanes := range o.ReadLanes() { - lanes := lanes if err := readGasUpdateTx(lanes.ForwardLane); err != nil { return err } @@ -957,14 +964,14 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction() error { len(transactions), len(o.Cfg.LeaderLanes)) } // each transaction should have number of network - 1 chain selectors and corresponding gas values. - // Say we have 3 networks, then we have expect every transaction to have 2 chain selectors + // Say we have 3 networks, then we have expected every transaction to have 2 chain selectors for _, v := range transactions { if len(v) != o.Cfg.TestGroupInput.NoOfNetworks-1 { return fmt.Errorf("number of chain selector count %d should match the number of "+ "networks minus one %d", len(v), o.Cfg.TestGroupInput.NoOfNetworks-1) } } - log.Debug().Interface("Gas update transactions", transactions).Msg("List of transaction hash:") + log.Debug().Interface("Tx hashes", transactions).Msg("Checked Gas Update Transactions") return nil } @@ -1170,7 +1177,10 @@ func CCIPDefaultTestSetUp( require.NoError(t, setUpArgs.JobAddGrp.Wait(), "Creating jobs shouldn't fail") // wait for price updates to be available setUpArgs.WaitForPriceUpdates() - if setUpArgs.Cfg.EnvInput.Lane.LeaderLaneEnabled && !pointer.GetBool(setUpArgs.Cfg.TestGroupInput.ExistingDeployment) { + if err := contracts.MatchContractVersionsOrAbove(map[contracts.Name]contracts.Version{ + contracts.OffRampContract: contracts.V1_2_0, + contracts.OnRampContract: contracts.V1_2_0, + }); err != nil && !pointer.GetBool(setUpArgs.Cfg.TestGroupInput.ExistingDeployment) { require.NoError(t, setUpArgs.CheckGasUpdateTransaction(), "gas update transaction check shouldn't fail") } // if dynamic price update is required From 981158e781c9c52f4bd4b9631b193d7fa8f5bdd5 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Tue, 9 Jul 2024 18:36:43 -0400 Subject: [PATCH 14/26] Changing it to Info back --- integration-tests/ccip-tests/testsetups/ccip.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index fdd67171eb..ca4a601056 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -340,7 +340,7 @@ func (c *CCIPTestConfig) SetNetworkPairs(lggr zerolog.Logger) error { Msg("Network Pairs") } for _, lane := range c.LeaderLanes { - lggr.Debug(). + lggr.Info(). Str("Source", lane.source). Str("Destination", lane.dest). Msg("Leader Lane: ") @@ -696,6 +696,10 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( // if it non leader lane, disable the price reporting if len(o.Cfg.LeaderLanes) > 0 && !o.Cfg.isLeaderLane(ccipLaneA2B.SourceNetworkName, ccipLaneA2B.DestNetworkName) { ccipLaneA2B.PriceReportingDisabled = true + lggr.Info(). + Str("Source", ccipLaneA2B.SourceNetworkName). + Str("Destination", ccipLaneA2B.DestNetworkName). + Msg("Non-leader lane") } contractsA, ok := o.LaneContractsByNetwork.Load(networkA.Name) if !ok { @@ -755,6 +759,10 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( if len(o.Cfg.LeaderLanes) > 0 && !o.Cfg.isLeaderLane(ccipLaneB2A.SourceNetworkName, ccipLaneB2A.DestNetworkName) { ccipLaneB2A.PriceReportingDisabled = true + lggr.Info(). + Str("Source", ccipLaneB2A.SourceNetworkName). + Str("Destination", ccipLaneB2A.DestNetworkName). + Msg("Non-leader lane") } b2aLogger := lggr.With().Str("env", namespace).Str("Lane", fmt.Sprintf("%s-->%s", ccipLaneB2A.SourceNetworkName, ccipLaneB2A.DestNetworkName)).Logger() @@ -971,7 +979,7 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction() error { "networks minus one %d", len(v), o.Cfg.TestGroupInput.NoOfNetworks-1) } } - log.Debug().Interface("Tx hashes", transactions).Msg("Checked Gas Update Transactions") + log.Info().Interface("Tx hashes", transactions).Msg("Checked Gas Update Transactions") return nil } From 21f97ce680ada8d43bc2077c58ce0506401af33d Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Wed, 10 Jul 2024 11:07:01 -0400 Subject: [PATCH 15/26] Review comments --- integration-tests/ccip-tests/testsetups/ccip.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index ca4a601056..338c509a80 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -930,6 +930,8 @@ func (o *CCIPTestSetUpOutputs) WaitForPriceUpdates() { require.NoError(t, priceUpdateGrp.Wait()) } +// CheckGasUpdateTransaction checks the gas update transactions count, and it has required number of +// events as per leader lane definitions. func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction() error { transactions := make(map[string]map[uint64]string) readGasUpdateTx := func(lane *actions.CCIPLane) error { From 0aa9a3e0bc26a51021a655c3facc54bc7471d038 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Wed, 10 Jul 2024 15:52:52 -0400 Subject: [PATCH 16/26] Fix condition --- .../ccip-tests/testsetups/ccip.go | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 338c509a80..0d0396507e 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -932,7 +932,7 @@ func (o *CCIPTestSetUpOutputs) WaitForPriceUpdates() { // CheckGasUpdateTransaction checks the gas update transactions count, and it has required number of // events as per leader lane definitions. -func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction() error { +func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) error { transactions := make(map[string]map[uint64]string) readGasUpdateTx := func(lane *actions.CCIPLane) error { for _, g := range lane.Source.Common.GasUpdateEvents { @@ -972,16 +972,27 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction() error { if len(transactions) != len(o.Cfg.LeaderLanes) { return fmt.Errorf("transaction count %d should match the number of leader lanes %d", len(transactions), len(o.Cfg.LeaderLanes)) + } else { + lggr.Info(). + Int("Tx hashes", len(transactions)). + Int("Leader lanes count", len(o.Cfg.LeaderLanes)). + Msg("Checked Gas Update transactions count matches") } // each transaction should have number of network - 1 chain selectors and corresponding gas values. // Say we have 3 networks, then we have expected every transaction to have 2 chain selectors - for _, v := range transactions { + for k, v := range transactions { if len(v) != o.Cfg.TestGroupInput.NoOfNetworks-1 { return fmt.Errorf("number of chain selector count %d should match the number of "+ "networks minus one %d", len(v), o.Cfg.TestGroupInput.NoOfNetworks-1) + } else { + lggr.Info(). + Str("Tx hash", k). + Interface("Chain selectors", v). + Int("Event emitted count", len(v)). + Msg("Checked Gas Update transaction events count") } } - log.Info().Interface("Tx hashes", transactions).Msg("Checked Gas Update Transactions") + lggr.Info().Interface("Tx hashes", transactions).Msg("Checked Gas Update Transactions") return nil } @@ -1190,8 +1201,8 @@ func CCIPDefaultTestSetUp( if err := contracts.MatchContractVersionsOrAbove(map[contracts.Name]contracts.Version{ contracts.OffRampContract: contracts.V1_2_0, contracts.OnRampContract: contracts.V1_2_0, - }); err != nil && !pointer.GetBool(setUpArgs.Cfg.TestGroupInput.ExistingDeployment) { - require.NoError(t, setUpArgs.CheckGasUpdateTransaction(), "gas update transaction check shouldn't fail") + }); err == nil && !pointer.GetBool(setUpArgs.Cfg.TestGroupInput.ExistingDeployment) { + require.NoError(t, setUpArgs.CheckGasUpdateTransaction(lggr), "gas update transaction check shouldn't fail") } // if dynamic price update is required if setUpArgs.Cfg.TestGroupInput.TokenConfig.IsDynamicPriceUpdate() { From 2ed238746f9e486fc2095fccb3ef634fb955f09d Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Thu, 11 Jul 2024 16:43:14 -0400 Subject: [PATCH 17/26] debug --- .../ccip-tests/testsetups/ccip.go | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 0d0396507e..2f889129b8 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -968,10 +968,15 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e } } } + lggr.Info().Interface("Tx hashes", transactions).Msg("Checked Gas Update Transactions") // when leader lane setup is enabled, number of transaction should match the number of leader lanes defined. if len(transactions) != len(o.Cfg.LeaderLanes) { - return fmt.Errorf("transaction count %d should match the number of leader lanes %d", - len(transactions), len(o.Cfg.LeaderLanes)) + lggr.Warn(). + Int("Tx hashes", len(transactions)). + Int("Leader lanes count", len(o.Cfg.LeaderLanes)). + Msg("Checked Gas Update transactions count doesn't match") + //return fmt.Errorf("transaction count %d should match the number of leader lanes %d", + // len(transactions), len(o.Cfg.LeaderLanes)) } else { lggr.Info(). Int("Tx hashes", len(transactions)). @@ -980,10 +985,16 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e } // each transaction should have number of network - 1 chain selectors and corresponding gas values. // Say we have 3 networks, then we have expected every transaction to have 2 chain selectors + failed := false for k, v := range transactions { if len(v) != o.Cfg.TestGroupInput.NoOfNetworks-1 { - return fmt.Errorf("number of chain selector count %d should match the number of "+ - "networks minus one %d", len(v), o.Cfg.TestGroupInput.NoOfNetworks-1) + lggr.Warn(). + Str("Tx hash", k). + Interface("Chain selectors", v). + Int("Event emitted count", len(v)). + Msg("Checked Gas Update transaction events count doesn't match") + failed = true + } else { lggr.Info(). Str("Tx hash", k). @@ -992,7 +1003,10 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e Msg("Checked Gas Update transaction events count") } } - lggr.Info().Interface("Tx hashes", transactions).Msg("Checked Gas Update Transactions") + if failed { + return fmt.Errorf("number of chain selector count should match the number of " + + "networks minus one ") + } return nil } From 87154b122c6f56c2f5ca43d625215f05ec9cf7e0 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Thu, 11 Jul 2024 18:10:43 -0400 Subject: [PATCH 18/26] Debug --- integration-tests/ccip-tests/testsetups/ccip.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 2f889129b8..81a06f2d2d 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -985,7 +985,7 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e } // each transaction should have number of network - 1 chain selectors and corresponding gas values. // Say we have 3 networks, then we have expected every transaction to have 2 chain selectors - failed := false + //failed := false for k, v := range transactions { if len(v) != o.Cfg.TestGroupInput.NoOfNetworks-1 { lggr.Warn(). @@ -993,7 +993,7 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e Interface("Chain selectors", v). Int("Event emitted count", len(v)). Msg("Checked Gas Update transaction events count doesn't match") - failed = true + //failed = true } else { lggr.Info(). @@ -1003,10 +1003,10 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e Msg("Checked Gas Update transaction events count") } } - if failed { - return fmt.Errorf("number of chain selector count should match the number of " + - "networks minus one ") - } + //if failed { + // return fmt.Errorf("number of chain selector count should match the number of " + + // "networks minus one ") + //} return nil } From 583c2e2374ab553b18c67c40088757b73ffe8265 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Fri, 12 Jul 2024 00:33:14 -0400 Subject: [PATCH 19/26] Debug tx count --- .../ccip-tests/actions/ccip_helpers.go | 27 ++++----- .../ccip-tests/testsetups/ccip.go | 56 ++++++++++++++----- 2 files changed, 57 insertions(+), 26 deletions(-) diff --git a/integration-tests/ccip-tests/actions/ccip_helpers.go b/integration-tests/ccip-tests/actions/ccip_helpers.go index e9df87c606..4f247ed090 100644 --- a/integration-tests/ccip-tests/actions/ccip_helpers.go +++ b/integration-tests/ccip-tests/actions/ccip_helpers.go @@ -184,15 +184,15 @@ type CCIPCommon struct { tokenPriceUpdateWatcher map[common.Address]*big.Int // key - token; value - timestamp of update gasUpdateWatcherMu *sync.Mutex gasUpdateWatcher map[uint64]*big.Int // key - destchain id; value - timestamp of update - GasUpdateEvents []gasUpdateEvent + GasUpdateEvents []GasUpdateEvent } -type gasUpdateEvent struct { - Sender string - Tx string - Value *big.Int - DestChain uint64 - ChainSelector uint64 +type GasUpdateEvent struct { + Sender string + Tx string + Value *big.Int + DestChain uint64 + Source string } // FreeUpUnusedSpace sets nil to various elements of ccipModule which are only used @@ -568,12 +568,12 @@ func (ccipModule *CCIPCommon) WatchForPriceUpdates(ctx context.Context, lggr *ze ccipModule.gasUpdateWatcherMu.Lock() ccipModule.gasUpdateWatcher[destChain] = timestamp - ccipModule.GasUpdateEvents = append(ccipModule.GasUpdateEvents, gasUpdateEvent{ - Sender: raw.Address.Hex(), - Tx: raw.TxHash.Hex(), - Value: value, - DestChain: destChain, - ChainSelector: destChainSelector, + ccipModule.GasUpdateEvents = append(ccipModule.GasUpdateEvents, GasUpdateEvent{ + Sender: raw.Address.Hex(), + Tx: raw.TxHash.Hex(), + Value: value, + DestChain: destChain, + Source: ccipModule.ChainClient.GetNetworkName(), }) ccipModule.gasUpdateWatcherMu.Unlock() lggr.Info(). @@ -581,6 +581,7 @@ func (ccipModule *CCIPCommon) WatchForPriceUpdates(ctx context.Context, lggr *ze Str("source_chain", ccipModule.ChainClient.GetNetworkName()). Uint64("dest_chain", destChain). Str("price_registry", ccipModule.PriceRegistry.Address()). + Str("tx hash", raw.TxHash.Hex()). Msgf("UsdPerUnitGasUpdated event received for dest chain %d source chain %s", destChain, ccipModule.ChainClient.GetNetworkName()) return nil diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 81a06f2d2d..e8da29cfc3 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -933,31 +933,48 @@ func (o *CCIPTestSetUpOutputs) WaitForPriceUpdates() { // CheckGasUpdateTransaction checks the gas update transactions count, and it has required number of // events as per leader lane definitions. func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) error { - transactions := make(map[string]map[uint64]string) + transactions := make(map[string]map[uint64]actions.GasUpdateEvent) + destToSourcesList := make(map[string][]string) + for _, n := range o.Cfg.NetworkPairs { + if _, ok := destToSourcesList[n.NetworkB.Name]; ok { + destToSourcesList[n.NetworkB.Name] = append(destToSourcesList[n.NetworkB.Name], n.NetworkA.Name) + } else { + destToSourcesList[n.NetworkB.Name] = []string{n.NetworkA.Name} + } + if pointer.GetBool(o.Cfg.TestGroupInput.BiDirectionalLane) { + if _, ok := destToSourcesList[n.NetworkA.Name]; ok { + destToSourcesList[n.NetworkA.Name] = append(destToSourcesList[n.NetworkA.Name], n.NetworkB.Name) + } else { + destToSourcesList[n.NetworkA.Name] = []string{n.NetworkB.Name} + } + } + } + lggr.Info().Interface("list", destToSourcesList).Msg("Dest to Source") readGasUpdateTx := func(lane *actions.CCIPLane) error { for _, g := range lane.Source.Common.GasUpdateEvents { if g.Value == nil { - return fmt.Errorf("gas update value should not be nil for chain selected %v in tx %s", g.ChainSelector, g.Tx) + return fmt.Errorf("gas update value should not be nil in tx %s", g.Tx) } if v, ok := transactions[g.Tx]; ok { - v[g.ChainSelector] = g.Value.String() + + v[g.DestChain] = g transactions[g.Tx] = v } else { - transactions[g.Tx] = map[uint64]string{ - g.ChainSelector: g.Value.String(), + transactions[g.Tx] = map[uint64]actions.GasUpdateEvent{ + g.DestChain: g, } } - lane.Logger.Debug(). + lane.Logger.Info(). Str("Sender", g.Sender). Str("Tx Hash", g.Tx). Uint64("Dest", g.DestChain). - Uint64("ChainSelector", g.ChainSelector). Str("Value", g.Value.String()). Msg("Gas price Updater details") } return nil } + for _, lanes := range o.ReadLanes() { if err := readGasUpdateTx(lanes.ForwardLane); err != nil { return err @@ -986,20 +1003,33 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e // each transaction should have number of network - 1 chain selectors and corresponding gas values. // Say we have 3 networks, then we have expected every transaction to have 2 chain selectors //failed := false - for k, v := range transactions { - if len(v) != o.Cfg.TestGroupInput.NoOfNetworks-1 { + for k, chainsReceivesPriceUpdate := range transactions { + var ( + priceReceivedFromChain string + sender string + ) + for _, chain := range chainsReceivesPriceUpdate { + priceReceivedFromChain = chain.Source + sender = chain.Sender + break + } + if len(chainsReceivesPriceUpdate) != len(destToSourcesList[priceReceivedFromChain]) { lggr.Warn(). Str("Tx hash", k). - Interface("Chain selectors", v). - Int("Event emitted count", len(v)). + Str("Source", priceReceivedFromChain). + Str("Sender", sender). + Int("Expected event count", len(destToSourcesList[priceReceivedFromChain])). + Int("Event emitted count", len(chainsReceivesPriceUpdate)). Msg("Checked Gas Update transaction events count doesn't match") //failed = true } else { lggr.Info(). Str("Tx hash", k). - Interface("Chain selectors", v). - Int("Event emitted count", len(v)). + Str("Source", priceReceivedFromChain). + Str("Sender", sender). + Int("Expected event count", len(destToSourcesList[priceReceivedFromChain])). + Int("Event emitted count", len(chainsReceivesPriceUpdate)). Msg("Checked Gas Update transaction events count") } } From 9d59fee5b58db4099fd1e79158ba1871a50fac87 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Fri, 12 Jul 2024 11:22:28 -0400 Subject: [PATCH 20/26] Fix assertion part --- .../ccip-tests/testsetups/ccip.go | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index e8da29cfc3..71edd05da5 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -934,6 +934,7 @@ func (o *CCIPTestSetUpOutputs) WaitForPriceUpdates() { // events as per leader lane definitions. func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) error { transactions := make(map[string]map[uint64]actions.GasUpdateEvent) + transactionsBySource := make(map[string]string) destToSourcesList := make(map[string][]string) for _, n := range o.Cfg.NetworkPairs { if _, ok := destToSourcesList[n.NetworkB.Name]; ok { @@ -950,7 +951,7 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e } } lggr.Info().Interface("list", destToSourcesList).Msg("Dest to Source") - readGasUpdateTx := func(lane *actions.CCIPLane) error { + filterGasUpdateByTx := func(lane *actions.CCIPLane) error { for _, g := range lane.Source.Common.GasUpdateEvents { if g.Value == nil { return fmt.Errorf("gas update value should not be nil in tx %s", g.Tx) @@ -976,20 +977,32 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e } for _, lanes := range o.ReadLanes() { - if err := readGasUpdateTx(lanes.ForwardLane); err != nil { + if err := filterGasUpdateByTx(lanes.ForwardLane); err != nil { return err } if lanes.ReverseLane != nil { - if err := readGasUpdateTx(lanes.ReverseLane); err != nil { + if err := filterGasUpdateByTx(lanes.ReverseLane); err != nil { return err } } } + + // filter the transaction hashes by source as there may be more than one transaction from the same source + // this could more likely happen in load test + for key, transactionDetails := range transactions { + for _, event := range transactionDetails { + if _, ok := transactionsBySource[event.Source]; !ok { + transactionsBySource[event.Source] = key + } + } + } lggr.Info().Interface("Tx hashes", transactions).Msg("Checked Gas Update Transactions") + lggr.Info().Interface("Tx hashes by source", transactionsBySource).Msg("Checked Gas Update Transactions by Source") // when leader lane setup is enabled, number of transaction should match the number of leader lanes defined. - if len(transactions) != len(o.Cfg.LeaderLanes) { + if len(transactionsBySource) != len(o.Cfg.LeaderLanes) { lggr.Warn(). Int("Tx hashes", len(transactions)). + Int("Tx hashes", len(transactionsBySource)). Int("Leader lanes count", len(o.Cfg.LeaderLanes)). Msg("Checked Gas Update transactions count doesn't match") //return fmt.Errorf("transaction count %d should match the number of leader lanes %d", @@ -997,46 +1010,33 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e } else { lggr.Info(). Int("Tx hashes", len(transactions)). + Int("Tx hashes", len(transactionsBySource)). Int("Leader lanes count", len(o.Cfg.LeaderLanes)). Msg("Checked Gas Update transactions count matches") } // each transaction should have number of network - 1 chain selectors and corresponding gas values. // Say we have 3 networks, then we have expected every transaction to have 2 chain selectors - //failed := false - for k, chainsReceivesPriceUpdate := range transactions { - var ( - priceReceivedFromChain string - sender string - ) - for _, chain := range chainsReceivesPriceUpdate { - priceReceivedFromChain = chain.Source - sender = chain.Sender - break + for source, tx := range transactionsBySource { + l, ok := destToSourcesList[source] + if !ok { + lggr.Warn().Str("Tx hash", tx).Msg("this transaction is probably from non-leader lane which is not expected") } - if len(chainsReceivesPriceUpdate) != len(destToSourcesList[priceReceivedFromChain]) { + if len(transactions[tx]) != len(l) { lggr.Warn(). - Str("Tx hash", k). - Str("Source", priceReceivedFromChain). - Str("Sender", sender). - Int("Expected event count", len(destToSourcesList[priceReceivedFromChain])). - Int("Event emitted count", len(chainsReceivesPriceUpdate)). + Str("Tx hash", tx). + Str("Source", source). + Int("Expected event count", len(l)). + Int("Event emitted count", len(transactions[tx])). Msg("Checked Gas Update transaction events count doesn't match") - //failed = true - } else { lggr.Info(). - Str("Tx hash", k). - Str("Source", priceReceivedFromChain). - Str("Sender", sender). - Int("Expected event count", len(destToSourcesList[priceReceivedFromChain])). - Int("Event emitted count", len(chainsReceivesPriceUpdate)). + Str("Tx hash", tx). + Str("Source", source). + Int("Expected event count", len(l)). + Int("Event emitted count", len(transactions[tx])). Msg("Checked Gas Update transaction events count") } } - //if failed { - // return fmt.Errorf("number of chain selector count should match the number of " + - // "networks minus one ") - //} return nil } From 2543383f0aa902b3fff680e7f61761fc96382268 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Fri, 12 Jul 2024 12:31:14 -0400 Subject: [PATCH 21/26] Clean up --- .../ccip-tests/testsetups/ccip.go | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 71edd05da5..b947906252 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -936,6 +936,7 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e transactions := make(map[string]map[uint64]actions.GasUpdateEvent) transactionsBySource := make(map[string]string) destToSourcesList := make(map[string][]string) + // create a map to hold the unique destination with list of sources for _, n := range o.Cfg.NetworkPairs { if _, ok := destToSourcesList[n.NetworkB.Name]; ok { destToSourcesList[n.NetworkB.Name] = append(destToSourcesList[n.NetworkB.Name], n.NetworkA.Name) @@ -951,13 +952,13 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e } } lggr.Info().Interface("list", destToSourcesList).Msg("Dest to Source") + // a function to read the events and create a map by tx hash with the event details filterGasUpdateByTx := func(lane *actions.CCIPLane) error { for _, g := range lane.Source.Common.GasUpdateEvents { if g.Value == nil { return fmt.Errorf("gas update value should not be nil in tx %s", g.Tx) } if v, ok := transactions[g.Tx]; ok { - v[g.DestChain] = g transactions[g.Tx] = v } else { @@ -965,13 +966,6 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e g.DestChain: g, } } - - lane.Logger.Info(). - Str("Sender", g.Sender). - Str("Tx Hash", g.Tx). - Uint64("Dest", g.DestChain). - Str("Value", g.Value.String()). - Msg("Gas price Updater details") } return nil } @@ -996,17 +990,18 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e } } } - lggr.Info().Interface("Tx hashes", transactions).Msg("Checked Gas Update Transactions") + lggr.Debug().Interface("Tx hashes", transactions).Msg("Checked Gas Update Transactions") lggr.Info().Interface("Tx hashes by source", transactionsBySource).Msg("Checked Gas Update Transactions by Source") - // when leader lane setup is enabled, number of transaction should match the number of leader lanes defined. + // when leader lane setup is enabled, number of unique transaction from the source + //should match the number of leader lanes defined. + var failed bool if len(transactionsBySource) != len(o.Cfg.LeaderLanes) { - lggr.Warn(). - Int("Tx hashes", len(transactions)). - Int("Tx hashes", len(transactionsBySource)). + lggr.Error(). + Int("Tx hashes expected", len(o.Cfg.LeaderLanes)). + Int("Tx hashes received", len(transactionsBySource)). Int("Leader lanes count", len(o.Cfg.LeaderLanes)). Msg("Checked Gas Update transactions count doesn't match") - //return fmt.Errorf("transaction count %d should match the number of leader lanes %d", - // len(transactions), len(o.Cfg.LeaderLanes)) + failed = true } else { lggr.Info(). Int("Tx hashes", len(transactions)). @@ -1019,17 +1014,19 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e for source, tx := range transactionsBySource { l, ok := destToSourcesList[source] if !ok { - lggr.Warn().Str("Tx hash", tx).Msg("this transaction is probably from non-leader lane which is not expected") + lggr.Error().Str("Tx hash", tx).Msg("this transaction is probably " + + "from non-leader lane which is not expected") } if len(transactions[tx]) != len(l) { - lggr.Warn(). + lggr.Error(). Str("Tx hash", tx). Str("Source", source). Int("Expected event count", len(l)). Int("Event emitted count", len(transactions[tx])). Msg("Checked Gas Update transaction events count doesn't match") + failed = true } else { - lggr.Info(). + lggr.Debug(). Str("Tx hash", tx). Str("Source", source). Int("Expected event count", len(l)). @@ -1037,6 +1034,9 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e Msg("Checked Gas Update transaction events count") } } + if failed { + return fmt.Errorf("gas update transaction verification failed. Refer the logs for the errors") + } return nil } From b77d561e6fcbbbe771c5c62cfb6392ddfc8dbcca Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Tue, 16 Jul 2024 11:39:22 -0400 Subject: [PATCH 22/26] Removing event count assertion --- .../ccip-tests/actions/ccip_helpers.go | 3 +- .../ccip-tests/testsetups/ccip.go | 34 ++----------------- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/integration-tests/ccip-tests/actions/ccip_helpers.go b/integration-tests/ccip-tests/actions/ccip_helpers.go index 4f247ed090..bc349f86d1 100644 --- a/integration-tests/ccip-tests/actions/ccip_helpers.go +++ b/integration-tests/ccip-tests/actions/ccip_helpers.go @@ -578,11 +578,10 @@ func (ccipModule *CCIPCommon) WatchForPriceUpdates(ctx context.Context, lggr *ze ccipModule.gasUpdateWatcherMu.Unlock() lggr.Info(). Uint64("chainSelector", destChainSelector). - Str("source_chain", ccipModule.ChainClient.GetNetworkName()). Uint64("dest_chain", destChain). Str("price_registry", ccipModule.PriceRegistry.Address()). Str("tx hash", raw.TxHash.Hex()). - Msgf("UsdPerUnitGasUpdated event received for dest chain %d source chain %s", + Msgf("UsdPerUnitGasUpdated event received for dest chain: %d, source chain: %s", destChain, ccipModule.ChainClient.GetNetworkName()) return nil } diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index b947906252..b7e89b331d 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -951,7 +951,7 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e } } } - lggr.Info().Interface("list", destToSourcesList).Msg("Dest to Source") + lggr.Debug().Interface("list", destToSourcesList).Msg("Dest to Source") // a function to read the events and create a map by tx hash with the event details filterGasUpdateByTx := func(lane *actions.CCIPLane) error { for _, g := range lane.Source.Common.GasUpdateEvents { @@ -990,18 +990,16 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e } } } - lggr.Debug().Interface("Tx hashes", transactions).Msg("Checked Gas Update Transactions") lggr.Info().Interface("Tx hashes by source", transactionsBySource).Msg("Checked Gas Update Transactions by Source") // when leader lane setup is enabled, number of unique transaction from the source //should match the number of leader lanes defined. - var failed bool if len(transactionsBySource) != len(o.Cfg.LeaderLanes) { lggr.Error(). Int("Tx hashes expected", len(o.Cfg.LeaderLanes)). Int("Tx hashes received", len(transactionsBySource)). Int("Leader lanes count", len(o.Cfg.LeaderLanes)). Msg("Checked Gas Update transactions count doesn't match") - failed = true + return fmt.Errorf("checked Gas Update transactions count doesn't match") } else { lggr.Info(). Int("Tx hashes", len(transactions)). @@ -1009,34 +1007,6 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e Int("Leader lanes count", len(o.Cfg.LeaderLanes)). Msg("Checked Gas Update transactions count matches") } - // each transaction should have number of network - 1 chain selectors and corresponding gas values. - // Say we have 3 networks, then we have expected every transaction to have 2 chain selectors - for source, tx := range transactionsBySource { - l, ok := destToSourcesList[source] - if !ok { - lggr.Error().Str("Tx hash", tx).Msg("this transaction is probably " + - "from non-leader lane which is not expected") - } - if len(transactions[tx]) != len(l) { - lggr.Error(). - Str("Tx hash", tx). - Str("Source", source). - Int("Expected event count", len(l)). - Int("Event emitted count", len(transactions[tx])). - Msg("Checked Gas Update transaction events count doesn't match") - failed = true - } else { - lggr.Debug(). - Str("Tx hash", tx). - Str("Source", source). - Int("Expected event count", len(l)). - Int("Event emitted count", len(transactions[tx])). - Msg("Checked Gas Update transaction events count") - } - } - if failed { - return fmt.Errorf("gas update transaction verification failed. Refer the logs for the errors") - } return nil } From ea10cf6ecc257a755e349703078cd0487c87f101 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Tue, 16 Jul 2024 12:18:33 -0400 Subject: [PATCH 23/26] fix lint error --- .../ccip-tests/testsetups/ccip.go | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index b7e89b331d..1d1f38db04 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -938,17 +938,9 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e destToSourcesList := make(map[string][]string) // create a map to hold the unique destination with list of sources for _, n := range o.Cfg.NetworkPairs { - if _, ok := destToSourcesList[n.NetworkB.Name]; ok { - destToSourcesList[n.NetworkB.Name] = append(destToSourcesList[n.NetworkB.Name], n.NetworkA.Name) - } else { - destToSourcesList[n.NetworkB.Name] = []string{n.NetworkA.Name} - } + destToSourcesList[n.NetworkB.Name] = append(destToSourcesList[n.NetworkB.Name], n.NetworkA.Name) if pointer.GetBool(o.Cfg.TestGroupInput.BiDirectionalLane) { - if _, ok := destToSourcesList[n.NetworkA.Name]; ok { - destToSourcesList[n.NetworkA.Name] = append(destToSourcesList[n.NetworkA.Name], n.NetworkB.Name) - } else { - destToSourcesList[n.NetworkA.Name] = []string{n.NetworkB.Name} - } + destToSourcesList[n.NetworkA.Name] = append(destToSourcesList[n.NetworkA.Name], n.NetworkB.Name) } } lggr.Debug().Interface("list", destToSourcesList).Msg("Dest to Source") @@ -1000,13 +992,13 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e Int("Leader lanes count", len(o.Cfg.LeaderLanes)). Msg("Checked Gas Update transactions count doesn't match") return fmt.Errorf("checked Gas Update transactions count doesn't match") - } else { - lggr.Info(). - Int("Tx hashes", len(transactions)). - Int("Tx hashes", len(transactionsBySource)). - Int("Leader lanes count", len(o.Cfg.LeaderLanes)). - Msg("Checked Gas Update transactions count matches") } + lggr.Info(). + Int("Tx hashes", len(transactions)). + Int("Tx hashes", len(transactionsBySource)). + Int("Leader lanes count", len(o.Cfg.LeaderLanes)). + Msg("Checked Gas Update transactions count matches") + return nil } From c7c4c64238152016dff4b1338b5490f19cfc2dcb Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Thu, 1 Aug 2024 08:59:39 -0400 Subject: [PATCH 24/26] Increase parallel running --- .github/workflows/integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 476ef5c73c..21ba0afddb 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -367,7 +367,7 @@ jobs: file: ccip run: -run ^TestSmokeCCIPOffRampAggRateLimit$ - name: ccip-smoke-leader-lane - nodes: 1 + nodes: 15 dir: ccip-tests/smoke os: ubuntu-latest file: ccip From e219080bed5cb27c7ce01f41a2cea4a2e6bf4631 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Mon, 5 Aug 2024 14:14:33 -0400 Subject: [PATCH 25/26] Review comments --- .../ccip-tests/actions/ccip_helpers.go | 12 +- .../ccip-tests/contracts/contract_models.go | 9 ++ .../ccip-tests/testsetups/ccip.go | 104 ++++++++---------- 3 files changed, 54 insertions(+), 71 deletions(-) diff --git a/integration-tests/ccip-tests/actions/ccip_helpers.go b/integration-tests/ccip-tests/actions/ccip_helpers.go index 740a440378..384b240649 100644 --- a/integration-tests/ccip-tests/actions/ccip_helpers.go +++ b/integration-tests/ccip-tests/actions/ccip_helpers.go @@ -184,15 +184,7 @@ type CCIPCommon struct { tokenPriceUpdateWatcher map[common.Address]*big.Int // key - token; value - timestamp of update gasUpdateWatcherMu *sync.Mutex gasUpdateWatcher map[uint64]*big.Int // key - destchain id; value - timestamp of update - GasUpdateEvents []GasUpdateEvent -} - -type GasUpdateEvent struct { - Sender string - Tx string - Value *big.Int - DestChain uint64 - Source string + GasUpdateEvents []contracts.GasUpdateEvent } // FreeUpUnusedSpace sets nil to various elements of ccipModule which are only used @@ -568,7 +560,7 @@ func (ccipModule *CCIPCommon) WatchForPriceUpdates(ctx context.Context, lggr *ze ccipModule.gasUpdateWatcherMu.Lock() ccipModule.gasUpdateWatcher[destChain] = timestamp - ccipModule.GasUpdateEvents = append(ccipModule.GasUpdateEvents, GasUpdateEvent{ + ccipModule.GasUpdateEvents = append(ccipModule.GasUpdateEvents, contracts.GasUpdateEvent{ Sender: raw.Address.Hex(), Tx: raw.TxHash.Hex(), Value: value, diff --git a/integration-tests/ccip-tests/contracts/contract_models.go b/integration-tests/ccip-tests/contracts/contract_models.go index 0ec55a1e54..7008d51b62 100644 --- a/integration-tests/ccip-tests/contracts/contract_models.go +++ b/integration-tests/ccip-tests/contracts/contract_models.go @@ -61,6 +61,15 @@ type Version struct { semver.Version } +// GasUpdateEvent holds the event details of Gas price update +type GasUpdateEvent struct { + Sender string + Tx string + Value *big.Int + DestChain uint64 + Source string +} + // MustVersion creates a new Version object from a semver string and panics if it fails func MustVersion(version string) Version { v := semver.MustParse(version) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 1d1f38db04..b42070802f 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -352,16 +352,11 @@ func (c *CCIPTestConfig) SetNetworkPairs(lggr zerolog.Logger) error { // defineLeaderLanes goes over the available network pairs and define one leader lane per destination func (c *CCIPTestConfig) defineLeaderLanes(lggr zerolog.Logger) { - // the way we are doing this is by creating a map with key as destination network name and value as source network name. - // Once map is available, picking every first source network name from the list to form the leader lanes - if err := contracts.MatchContractVersionsOrAbove(map[contracts.Name]contracts.Version{ - contracts.OffRampContract: contracts.V1_2_0, - contracts.OnRampContract: contracts.V1_2_0, - }); err != nil { - lggr.Info().Str("Required contract version", contracts.V1_2_0.String()).Msg("Leader lane feature is not enabled") + if !isLeaderLaneFeatureEnabled(&lggr) { return } - + // the way we are defining leader lane is simply by tagging the destination as key along with the first source network + // as value to the map. leaderLanes := make(map[string]string) for _, n := range c.NetworkPairs { if _, ok := leaderLanes[n.NetworkB.Name]; !ok { @@ -381,16 +376,31 @@ func (c *CCIPTestConfig) defineLeaderLanes(lggr zerolog.Logger) { } } -// isLeaderLane checks the given lane is leader lane and return boolean accordingly -func (c *CCIPTestConfig) isLeaderLane(source, dest string) bool { +// isPriceReportingDisabled checks the given lane is leader lane and return boolean accordingly +func (c *CCIPTestConfig) isPriceReportingDisabled(lggr *zerolog.Logger, source, dest string) bool { for _, leader := range c.LeaderLanes { if leader.source == source && leader.dest == dest { + lggr.Debug(). + Str("Source", source). + Str("Destination", dest). + Msg("Non-leader lane") return true } } return false } +func isLeaderLaneFeatureEnabled(lggr *zerolog.Logger) bool { + if err := contracts.MatchContractVersionsOrAbove(map[contracts.Name]contracts.Version{ + contracts.OffRampContract: contracts.V1_2_0, + contracts.OnRampContract: contracts.V1_2_0, + }); err != nil { + lggr.Info().Str("Required contract version", contracts.V1_2_0.String()).Msg("Leader lane feature is not enabled") + return false + } + return true +} + func (c *CCIPTestConfig) FormNetworkPairCombinations() { for i := 0; i < c.TestGroupInput.NoOfNetworks; i++ { for j := i + 1; j < c.TestGroupInput.NoOfNetworks; j++ { @@ -694,13 +704,9 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( Context: testcontext.Get(t), } // if it non leader lane, disable the price reporting - if len(o.Cfg.LeaderLanes) > 0 && !o.Cfg.isLeaderLane(ccipLaneA2B.SourceNetworkName, ccipLaneA2B.DestNetworkName) { - ccipLaneA2B.PriceReportingDisabled = true - lggr.Info(). - Str("Source", ccipLaneA2B.SourceNetworkName). - Str("Destination", ccipLaneA2B.DestNetworkName). - Msg("Non-leader lane") - } + ccipLaneA2B.PriceReportingDisabled = len(o.Cfg.LeaderLanes) > 0 && + !o.Cfg.isPriceReportingDisabled(lggr, ccipLaneA2B.SourceNetworkName, ccipLaneA2B.DestNetworkName) + contractsA, ok := o.LaneContractsByNetwork.Load(networkA.Name) if !ok { return errors.WithStack(fmt.Errorf("failed to load lane contracts for %s", networkA.Name)) @@ -756,14 +762,8 @@ func (o *CCIPTestSetUpOutputs) AddLanesForNetworkPair( DstNetworkLaneCfg: ccipLaneA2B.SrcNetworkLaneCfg, } // if it non leader lane, disable the price reporting - if len(o.Cfg.LeaderLanes) > 0 && - !o.Cfg.isLeaderLane(ccipLaneB2A.SourceNetworkName, ccipLaneB2A.DestNetworkName) { - ccipLaneB2A.PriceReportingDisabled = true - lggr.Info(). - Str("Source", ccipLaneB2A.SourceNetworkName). - Str("Destination", ccipLaneB2A.DestNetworkName). - Msg("Non-leader lane") - } + ccipLaneB2A.PriceReportingDisabled = len(o.Cfg.LeaderLanes) > 0 && + !o.Cfg.isPriceReportingDisabled(lggr, ccipLaneB2A.SourceNetworkName, ccipLaneB2A.DestNetworkName) b2aLogger := lggr.With().Str("env", namespace).Str("Lane", fmt.Sprintf("%s-->%s", ccipLaneB2A.SourceNetworkName, ccipLaneB2A.DestNetworkName)).Logger() ccipLaneB2A.Logger = &b2aLogger @@ -930,10 +930,8 @@ func (o *CCIPTestSetUpOutputs) WaitForPriceUpdates() { require.NoError(t, priceUpdateGrp.Wait()) } -// CheckGasUpdateTransaction checks the gas update transactions count, and it has required number of -// events as per leader lane definitions. +// CheckGasUpdateTransaction checks the gas update transactions count func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) error { - transactions := make(map[string]map[uint64]actions.GasUpdateEvent) transactionsBySource := make(map[string]string) destToSourcesList := make(map[string][]string) // create a map to hold the unique destination with list of sources @@ -944,47 +942,35 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e } } lggr.Debug().Interface("list", destToSourcesList).Msg("Dest to Source") - // a function to read the events and create a map by tx hash with the event details - filterGasUpdateByTx := func(lane *actions.CCIPLane) error { + // a function to read the gas update events and create a map with unique source and store the tx hash + filterGasUpdateEventTxBySource := func(lane *actions.CCIPLane) error { for _, g := range lane.Source.Common.GasUpdateEvents { if g.Value == nil { return fmt.Errorf("gas update value should not be nil in tx %s", g.Tx) } - if v, ok := transactions[g.Tx]; ok { - v[g.DestChain] = g - transactions[g.Tx] = v - } else { - transactions[g.Tx] = map[uint64]actions.GasUpdateEvent{ - g.DestChain: g, - } + if _, ok := transactionsBySource[g.Source]; !ok { + transactionsBySource[g.Source] = g.Tx } } return nil } - for _, lanes := range o.ReadLanes() { - if err := filterGasUpdateByTx(lanes.ForwardLane); err != nil { - return err + for _, lane := range o.ReadLanes() { + if err := filterGasUpdateEventTxBySource(lane.ForwardLane); err != nil { + return fmt.Errorf("error in filtering gas update transactions in the lane source: %s and destination: %s, error: %v", + lane.ForwardLane.SourceNetworkName, lane.ForwardLane.DestNetworkName, err) } - if lanes.ReverseLane != nil { - if err := filterGasUpdateByTx(lanes.ReverseLane); err != nil { - return err + if lane.ReverseLane != nil { + if err := filterGasUpdateEventTxBySource(lane.ReverseLane); err != nil { + return fmt.Errorf("error in filtering gas update transactions in the lane source: %s and destination: %s, error: %v", + lane.ReverseLane.SourceNetworkName, lane.ReverseLane.DestNetworkName, err) } } } - // filter the transaction hashes by source as there may be more than one transaction from the same source - // this could more likely happen in load test - for key, transactionDetails := range transactions { - for _, event := range transactionDetails { - if _, ok := transactionsBySource[event.Source]; !ok { - transactionsBySource[event.Source] = key - } - } - } - lggr.Info().Interface("Tx hashes by source", transactionsBySource).Msg("Checked Gas Update Transactions by Source") + lggr.Debug().Interface("Tx hashes by source", transactionsBySource).Msg("Checked Gas Update Transactions by Source") // when leader lane setup is enabled, number of unique transaction from the source - //should match the number of leader lanes defined. + // should match the number of leader lanes defined. if len(transactionsBySource) != len(o.Cfg.LeaderLanes) { lggr.Error(). Int("Tx hashes expected", len(o.Cfg.LeaderLanes)). @@ -993,9 +979,8 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e Msg("Checked Gas Update transactions count doesn't match") return fmt.Errorf("checked Gas Update transactions count doesn't match") } - lggr.Info(). - Int("Tx hashes", len(transactions)). - Int("Tx hashes", len(transactionsBySource)). + lggr.Debug(). + Int("Tx hashes by source", len(transactionsBySource)). Int("Leader lanes count", len(o.Cfg.LeaderLanes)). Msg("Checked Gas Update transactions count matches") @@ -1204,10 +1189,7 @@ func CCIPDefaultTestSetUp( require.NoError(t, setUpArgs.JobAddGrp.Wait(), "Creating jobs shouldn't fail") // wait for price updates to be available setUpArgs.WaitForPriceUpdates() - if err := contracts.MatchContractVersionsOrAbove(map[contracts.Name]contracts.Version{ - contracts.OffRampContract: contracts.V1_2_0, - contracts.OnRampContract: contracts.V1_2_0, - }); err == nil && !pointer.GetBool(setUpArgs.Cfg.TestGroupInput.ExistingDeployment) { + if isLeaderLaneFeatureEnabled(lggr) && !pointer.GetBool(setUpArgs.Cfg.TestGroupInput.ExistingDeployment) { require.NoError(t, setUpArgs.CheckGasUpdateTransaction(lggr), "gas update transaction check shouldn't fail") } // if dynamic price update is required From c585e4fc7e10419b407e2a11b54fdab6e06cd646 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Mon, 5 Aug 2024 14:26:14 -0400 Subject: [PATCH 26/26] Fix lint --- integration-tests/ccip-tests/testsetups/ccip.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index b42070802f..3fb25bc675 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -957,12 +957,12 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e for _, lane := range o.ReadLanes() { if err := filterGasUpdateEventTxBySource(lane.ForwardLane); err != nil { - return fmt.Errorf("error in filtering gas update transactions in the lane source: %s and destination: %s, error: %v", + return fmt.Errorf("error in filtering gas update transactions in the lane source: %s and destination: %s, error: %w", lane.ForwardLane.SourceNetworkName, lane.ForwardLane.DestNetworkName, err) } if lane.ReverseLane != nil { if err := filterGasUpdateEventTxBySource(lane.ReverseLane); err != nil { - return fmt.Errorf("error in filtering gas update transactions in the lane source: %s and destination: %s, error: %v", + return fmt.Errorf("error in filtering gas update transactions in the lane source: %s and destination: %s, error: %w", lane.ReverseLane.SourceNetworkName, lane.ReverseLane.DestNetworkName, err) } }