From 0ff7c547dc6a1400e252fd2933def72324dbecb3 Mon Sep 17 00:00:00 2001 From: Adam Hamrick Date: Wed, 7 Aug 2024 17:11:55 -0400 Subject: [PATCH] Fixes CI conflicts --- .github/workflows/integration-tests.yml | 105 ++- .../ccip-tests/actions/ccip_helpers.go | 12 +- .../ccip-tests/actions/lm_helpers.go | 31 - .../ccip-tests/contracts/contract_deployer.go | 120 +-- .../ccip-tests/contracts/lm_contracts.go | 320 ------- integration-tests/ccip-tests/smoke/lm_test.go | 49 - .../ccip-tests/testsetups/ccip.go | 11 +- .../ccip-tests/testsetups/lm_setup.go | 845 ------------------ .../ccip-tests/testsetups/test_env.go | 13 +- integration-tests/go.mod | 18 +- 10 files changed, 193 insertions(+), 1331 deletions(-) delete mode 100644 integration-tests/ccip-tests/actions/lm_helpers.go delete mode 100644 integration-tests/ccip-tests/contracts/lm_contracts.go delete mode 100644 integration-tests/ccip-tests/smoke/lm_test.go delete mode 100644 integration-tests/ccip-tests/testsetups/lm_setup.go diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 96a2a7a39f9..5f772e3ac02 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -531,6 +531,82 @@ jobs: fail-fast: false matrix: product: + - name: ccip-smoke + nodes: 1 + os: ubuntu-latest + file: ccip + dir: ccip-tests/smoke + run: -run ^TestSmokeCCIPForBidirectionalLane$ + - name: ccip-smoke-1.4-pools + nodes: 1 + os: ubuntu-latest + file: ccip + dir: ccip-tests/smoke + run: -run ^TestSmokeCCIPForBidirectionalLane$ + config_path: ./integration-tests/ccip-tests/testconfig/tomls/contract-version1.4.toml + - name: ccip-smoke-usdc + nodes: 1 + os: ubuntu-latest + file: ccip + dir: ccip-tests/smoke + run: -run ^TestSmokeCCIPForBidirectionalLane$ + config_path: ./integration-tests/ccip-tests/testconfig/tomls/usdc_mock_deployment.toml + - name: ccip-smoke-db-compatibility + nodes: 1 + os: ubuntu-latest + file: ccip + dir: ccip-tests/smoke + run: -run ^TestSmokeCCIPForBidirectionalLane$ + config_path: ./integration-tests/ccip-tests/testconfig/tomls/db-compatibility.toml + - name: ccip-smoke-rate-limit + nodes: 1 + dir: ccip-tests/smoke + os: ubuntu-latest + file: ccip + run: -run ^TestSmokeCCIPRateLimit$ + - name: ccip-smoke-rate-limit + nodes: 1 + dir: ccip-tests/smoke + os: ubuntu-latest + file: ccip + run: -run ^TestSmokeCCIPTokenPoolRateLimits$ + - name: ccip-smoke-multicall + nodes: 1 + dir: ccip-tests/smoke + os: ubuntu-latest + file: ccip + run: -run ^TestSmokeCCIPMulticall$ + - name: ccip-smoke-manual-exec + nodes: 1 + dir: ccip-tests/smoke + os: ubuntu-latest + file: ccip + run: -run ^TestSmokeCCIPManuallyExecuteAfterExecutionFailingDueToInsufficientGas$ + - name: ccip-smoke-on-ramp-limits + nodes: 1 + dir: ccip-tests/smoke + os: ubuntu-latest + file: ccip + run: -run ^TestSmokeCCIPOnRampLimits$ + - name: ccip-smoke-off-ramp-capacity + nodes: 1 + dir: ccip-tests/smoke + os: ubuntu-latest + file: ccip + run: -run ^TestSmokeCCIPOffRampCapacityLimit$ + - name: ccip-smoke-off-ramp-agg-rate-limit + nodes: 1 + dir: ccip-tests/smoke + os: ubuntu-latest + file: ccip + run: -run ^TestSmokeCCIPOffRampAggRateLimit$ + - name: ccip-smoke-leader-lane + nodes: 15 + 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 @@ -621,11 +697,17 @@ jobs: - name: Build Go Test Command id: build-go-test-command run: | + # if dir is provided use it, otherwise use the smoke dir + if [ "${{ matrix.product.dir }}" != "" ]; then + dir=${{ matrix.product.dir }} + else + dir=smoke + fi # if the matrix.product.run is set, use it for a different command if [ "${{ matrix.product.run }}" != "" ]; then - echo "run_command=${{ matrix.product.run }} ./smoke/${{ matrix.product.file }}_test.go" >> "$GITHUB_OUTPUT" + echo "run_command=${{ matrix.product.run }} ./${dir}/${{ matrix.product.file }}_test.go" >> "$GITHUB_OUTPUT" else - echo "run_command=./smoke/${{ matrix.product.name }}_test.go" >> "$GITHUB_OUTPUT" + echo "run_command=./${dir}/${{ matrix.product.name }}_test.go" >> "$GITHUB_OUTPUT" fi - name: Check for "enable tracing" label id: check-label @@ -693,6 +775,25 @@ jobs: # other inputs duplicate-authorization-header: "true" + - name: Prepare Base64 CCIP TOML secrets + uses: ./.github/actions/setup-create-base64-config-ccip + with: + runId: ${{ github.run_id }} + pyroscopeServer: ${{ matrix.product.pyroscope_env == '' && '' || !startsWith(github.ref, 'refs/tags/') && '' || secrets.QA_PYROSCOPE_INSTANCE }} # Avoid sending blank envs https://github.com/orgs/community/discussions/25725 + pyroscopeEnvironment: ${{ matrix.product.pyroscope_env }} + pyroscopeKey: ${{ secrets.QA_PYROSCOPE_KEY }} + testLogCollect: ${{ vars.TEST_LOG_COLLECT }} + selectedNetworks: SIMULATED_1,SIMULATED_2 + chainlinkImage: ${{ env.CHAINLINK_IMAGE }} + chainlinkVersion: ${{ github.sha }} + lokiEndpoint: https://${{ secrets.GRAFANA_INTERNAL_HOST }}/loki/api/v1/push + lokiTenantId: ${{ vars.LOKI_TENANT_ID }} + lokiBasicAuth: ${{ secrets.LOKI_BASIC_AUTH }} + logstreamLogTargets: ${{ vars.LOGSTREAM_LOG_TARGETS }} + grafanaUrl: "http://localhost:8080/primary" + grafanaDashboardUrl: "/d/ddf75041-1e39-42af-aa46-361fe4c36e9e/ci-e2e-tests-logs" + grafanaBearerToken: ${{ secrets.GRAFANA_INTERNAL_URL_SHORTENER_TOKEN }} + ## Run this step when changes that require tests to be run are made - name: Run Tests if: needs.changes.outputs.src == 'true' || github.event_name == 'workflow_dispatch' diff --git a/integration-tests/ccip-tests/actions/ccip_helpers.go b/integration-tests/ccip-tests/actions/ccip_helpers.go index 384b240649d..7594a9dc447 100644 --- a/integration-tests/ccip-tests/actions/ccip_helpers.go +++ b/integration-tests/ccip-tests/actions/ccip_helpers.go @@ -4022,7 +4022,6 @@ func (c *CCIPTestEnv) ConnectToExistingNodes(envConfig *testconfig.Common) error if err != nil { return fmt.Errorf("failed to create chainlink client: %w for node %d config %v", err, i+1, cfg) } - clClient.ChainlinkClient.WithRetryCount(3) c.CLNodes = append(c.CLNodes, clClient) c.nodeMutexes = append(c.nodeMutexes, &sync.Mutex{}) } @@ -4036,7 +4035,7 @@ func (c *CCIPTestEnv) ConnectToDeployedNodes() error { for _, chainlinkNode := range c.LocalCluster.ClCluster.Nodes { c.nodeMutexes = append(c.nodeMutexes, &sync.Mutex{}) c.CLNodes = append(c.CLNodes, &client.ChainlinkK8sClient{ - ChainlinkClient: chainlinkNode.API.WithRetryCount(3), + ChainlinkClient: chainlinkNode.API, }) } } else { @@ -4050,17 +4049,12 @@ func (c *CCIPTestEnv) ConnectToDeployedNodes() error { return fmt.Errorf("no CL node found") } - for i := range chainlinkK8sNodes { - chainlinkK8sNodes[i].ChainlinkClient.WithRetryCount(3) + for range chainlinkK8sNodes { c.nodeMutexes = append(c.nodeMutexes, &sync.Mutex{}) } c.CLNodes = chainlinkK8sNodes if _, exists := c.K8Env.URLs[mockserver.InternalURLsKey]; exists { - mockServer, err := ctfClient.ConnectMockServer(c.K8Env) - if err != nil { - return fmt.Errorf("failed to connect to mock server: %w", err) - } - c.MockServer = mockServer + c.MockServer = ctfClient.ConnectMockServer(c.K8Env) } } return nil diff --git a/integration-tests/ccip-tests/actions/lm_helpers.go b/integration-tests/ccip-tests/actions/lm_helpers.go deleted file mode 100644 index 1ec02e313fd..00000000000 --- a/integration-tests/ccip-tests/actions/lm_helpers.go +++ /dev/null @@ -1,31 +0,0 @@ -package actions - -import ( - "math/big" - - "github.com/ethereum/go-ethereum/common" - - "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink/integration-tests/ccip-tests/contracts" -) - -type LMCommon struct { - ChainClient blockchain.EVMClient - MockArm *common.Address - ArmProxy *contracts.ArmProxy - CcipRouter *contracts.Router - LM *contracts.LiquidityManager - TokenPool *contracts.TokenPool - BridgeAdapterAddr *common.Address - WrapperNative *common.Address - MinimumLiquidity *big.Int - ChainSelectror uint64 -} - -func DefaultLMModule(chainClient blockchain.EVMClient, minimumLiquidity *big.Int, chainSelector uint64) (*LMCommon, error) { - return &LMCommon{ - ChainClient: chainClient, - MinimumLiquidity: minimumLiquidity, - ChainSelectror: chainSelector, - }, nil -} diff --git a/integration-tests/ccip-tests/contracts/contract_deployer.go b/integration-tests/ccip-tests/contracts/contract_deployer.go index 043c1d4422f..8656656e0b2 100644 --- a/integration-tests/ccip-tests/contracts/contract_deployer.go +++ b/integration-tests/ccip-tests/contracts/contract_deployer.go @@ -1044,6 +1044,7 @@ func (e *CCIPContractsDeployer) DeployOnRamp( MaxPerMsgGasLimit: 4_000_000, DefaultTokenFeeUSDCents: 50, DefaultTokenDestGasOverhead: 125_000, + DefaultTokenDestBytesOverhead: 500, }, evm_2_evm_onramp.RateLimiterConfig{ Capacity: opts.Capacity, @@ -1288,30 +1289,30 @@ func OCR2ParamsForCommit(blockTime time.Duration) contracts.OffChainAggregatorV2 // slow blocktime chains like Ethereum if blockTime >= 10*time.Second { return contracts.OffChainAggregatorV2Config{ - DeltaProgress: config.MustNewDuration(2 * time.Minute), - DeltaResend: config.MustNewDuration(5 * time.Second), - DeltaRound: config.MustNewDuration(90 * time.Second), - DeltaGrace: config.MustNewDuration(5 * time.Second), - DeltaStage: config.MustNewDuration(60 * time.Second), - MaxDurationQuery: config.MustNewDuration(100 * time.Millisecond), - MaxDurationObservation: config.MustNewDuration(35 * time.Second), - MaxDurationReport: config.MustNewDuration(10 * time.Second), - MaxDurationShouldAcceptFinalizedReport: config.MustNewDuration(5 * time.Second), - MaxDurationShouldTransmitAcceptedReport: config.MustNewDuration(10 * time.Second), + DeltaProgress: 2 * time.Minute, + DeltaResend: 5 * time.Second, + DeltaRound: 90 * time.Second, + DeltaGrace: 5 * time.Second, + DeltaStage: 60 * time.Second, + MaxDurationQuery: 100 * time.Millisecond, + MaxDurationObservation: 35 * time.Second, + MaxDurationReport: 10 * time.Second, + MaxDurationShouldAcceptFinalizedReport: 5 * time.Second, + MaxDurationShouldTransmitAcceptedReport: 10 * time.Second, } } // fast blocktime chains like Avalanche return contracts.OffChainAggregatorV2Config{ - DeltaProgress: config.MustNewDuration(2 * time.Minute), - DeltaResend: config.MustNewDuration(5 * time.Second), - DeltaRound: config.MustNewDuration(60 * time.Second), - DeltaGrace: config.MustNewDuration(5 * time.Second), - DeltaStage: config.MustNewDuration(25 * time.Second), - MaxDurationQuery: config.MustNewDuration(100 * time.Millisecond), - MaxDurationObservation: config.MustNewDuration(35 * time.Second), - MaxDurationReport: config.MustNewDuration(10 * time.Second), - MaxDurationShouldAcceptFinalizedReport: config.MustNewDuration(5 * time.Second), - MaxDurationShouldTransmitAcceptedReport: config.MustNewDuration(10 * time.Second), + DeltaProgress: 2 * time.Minute, + DeltaResend: 5 * time.Second, + DeltaRound: 60 * time.Second, + DeltaGrace: 5 * time.Second, + DeltaStage: 25 * time.Second, + MaxDurationQuery: 100 * time.Millisecond, + MaxDurationObservation: 35 * time.Second, + MaxDurationReport: 10 * time.Second, + MaxDurationShouldAcceptFinalizedReport: 5 * time.Second, + MaxDurationShouldTransmitAcceptedReport: 10 * time.Second, } } @@ -1319,30 +1320,30 @@ func OCR2ParamsForExec(blockTime time.Duration) contracts.OffChainAggregatorV2Co // slow blocktime chains like Ethereum if blockTime >= 10*time.Second { return contracts.OffChainAggregatorV2Config{ - DeltaProgress: config.MustNewDuration(2 * time.Minute), - DeltaResend: config.MustNewDuration(5 * time.Second), - DeltaRound: config.MustNewDuration(90 * time.Second), - DeltaGrace: config.MustNewDuration(5 * time.Second), - DeltaStage: config.MustNewDuration(60 * time.Second), - MaxDurationQuery: config.MustNewDuration(100 * time.Millisecond), - MaxDurationObservation: config.MustNewDuration(35 * time.Second), - MaxDurationReport: config.MustNewDuration(10 * time.Second), - MaxDurationShouldAcceptFinalizedReport: config.MustNewDuration(5 * time.Second), - MaxDurationShouldTransmitAcceptedReport: config.MustNewDuration(10 * time.Second), + DeltaProgress: 2 * time.Minute, + DeltaResend: 5 * time.Second, + DeltaRound: 90 * time.Second, + DeltaGrace: 5 * time.Second, + DeltaStage: 60 * time.Second, + MaxDurationQuery: 100 * time.Millisecond, + MaxDurationObservation: 35 * time.Second, + MaxDurationReport: 10 * time.Second, + MaxDurationShouldAcceptFinalizedReport: 5 * time.Second, + MaxDurationShouldTransmitAcceptedReport: 10 * time.Second, } } // fast blocktime chains like Avalanche return contracts.OffChainAggregatorV2Config{ - DeltaProgress: config.MustNewDuration(120 * time.Second), - DeltaResend: config.MustNewDuration(5 * time.Second), - DeltaRound: config.MustNewDuration(30 * time.Second), - DeltaGrace: config.MustNewDuration(5 * time.Second), - DeltaStage: config.MustNewDuration(10 * time.Second), - MaxDurationQuery: config.MustNewDuration(100 * time.Millisecond), - MaxDurationObservation: config.MustNewDuration(35 * time.Second), - MaxDurationReport: config.MustNewDuration(10 * time.Second), - MaxDurationShouldAcceptFinalizedReport: config.MustNewDuration(5 * time.Second), - MaxDurationShouldTransmitAcceptedReport: config.MustNewDuration(10 * time.Second), + DeltaProgress: 120 * time.Second, + DeltaResend: 5 * time.Second, + DeltaRound: 30 * time.Second, + DeltaGrace: 5 * time.Second, + DeltaStage: 10 * time.Second, + MaxDurationQuery: 100 * time.Millisecond, + MaxDurationObservation: 35 * time.Second, + MaxDurationReport: 10 * time.Second, + MaxDurationShouldAcceptFinalizedReport: 5 * time.Second, + MaxDurationShouldTransmitAcceptedReport: 10 * time.Second, } } @@ -1363,8 +1364,8 @@ func OffChainAggregatorV2ConfigWithNodes(numberNodes int, inflightExpiry time.Du if faultyNodes == 0 { faultyNodes = 1 } - if cfg.DeltaStage == nil { - cfg.DeltaStage = config.MustNewDuration(inflightExpiry) + if cfg.DeltaStage == 0 { + cfg.DeltaStage = inflightExpiry } return contracts.OffChainAggregatorV2Config{ DeltaProgress: cfg.DeltaProgress, @@ -1400,7 +1401,8 @@ func NewCommitOffchainConfig( TokenPriceHeartBeat config.Duration, TokenPriceDeviationPPB uint32, InflightCacheExpiry config.Duration, - priceReportingDisabled bool) (ccipconfig.OffchainConfig, error) { + _ bool, // TODO: priceReportingDisabled added after this merge +) (ccipconfig.OffchainConfig, error) { switch VersionMap[CommitStoreContract] { case Latest: return testhelpers.NewCommitOffchainConfig( @@ -1410,7 +1412,6 @@ func NewCommitOffchainConfig( TokenPriceHeartBeat, TokenPriceDeviationPPB, InflightCacheExpiry, - priceReportingDisabled, ), nil case V1_2_0: return testhelpers_1_4_0.NewCommitOffchainConfig( @@ -1420,7 +1421,6 @@ func NewCommitOffchainConfig( TokenPriceHeartBeat, TokenPriceDeviationPPB, InflightCacheExpiry, - priceReportingDisabled, ), nil default: return nil, fmt.Errorf("version not supported: %s", VersionMap[CommitStoreContract]) @@ -1450,7 +1450,15 @@ func NewExecOnchainConfig( ) (abihelpers.AbiDefined, error) { switch VersionMap[OffRampContract] { case Latest: - return testhelpers.NewExecOnchainConfig(PermissionLessExecutionThresholdSeconds, Router, PriceRegistry, MaxNumberOfTokensPerMsg, MaxDataBytes), nil + return testhelpers.NewExecOnchainConfig( + PermissionLessExecutionThresholdSeconds, + Router, + PriceRegistry, + MaxNumberOfTokensPerMsg, + MaxDataBytes, + MaxPoolReleaseOrMintGas, // TODO: obsolete soon after this merge + 50_000, // TODO: MaxTokenTransferGas, obsolete soon after this merge + ), nil case V1_2_0: return testhelpers_1_4_0.NewExecOnchainConfig( PermissionLessExecutionThresholdSeconds, @@ -1557,20 +1565,20 @@ func NewOffChainAggregatorV2ConfigForCCIPPlugin[T ccipconfig.OffchainConfig]( } _, _, f_, onchainConfig_, offchainConfigVersion, offchainConfig, err = ocrconfighelper2.ContractSetConfigArgsForTests( - ocrConfig.DeltaProgress.Duration(), - ocrConfig.DeltaResend.Duration(), - ocrConfig.DeltaRound.Duration(), - ocrConfig.DeltaGrace.Duration(), - ocrConfig.DeltaStage.Duration(), + ocrConfig.DeltaProgress, + ocrConfig.DeltaResend, + ocrConfig.DeltaRound, + ocrConfig.DeltaGrace, + ocrConfig.DeltaStage, ocrConfig.RMax, ocrConfig.S, ocrConfig.Oracles, ocrConfig.ReportingPluginConfig, - ocrConfig.MaxDurationQuery.Duration(), - ocrConfig.MaxDurationObservation.Duration(), - ocrConfig.MaxDurationReport.Duration(), - ocrConfig.MaxDurationShouldAcceptFinalizedReport.Duration(), - ocrConfig.MaxDurationShouldTransmitAcceptedReport.Duration(), + ocrConfig.MaxDurationQuery, + ocrConfig.MaxDurationObservation, + ocrConfig.MaxDurationReport, + ocrConfig.MaxDurationShouldAcceptFinalizedReport, + ocrConfig.MaxDurationShouldTransmitAcceptedReport, ocrConfig.F, ocrConfig.OnchainConfig, ) diff --git a/integration-tests/ccip-tests/contracts/lm_contracts.go b/integration-tests/ccip-tests/contracts/lm_contracts.go deleted file mode 100644 index cb3b8ac388f..00000000000 --- a/integration-tests/ccip-tests/contracts/lm_contracts.go +++ /dev/null @@ -1,320 +0,0 @@ -package contracts - -import ( - "fmt" - "math/big" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/rs/zerolog" - - "github.com/smartcontractkit/chainlink/integration-tests/wrappers" - - "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/arm_proxy_contract" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/liquiditymanager/generated/arbitrum_l1_bridge_adapter" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/liquiditymanager/generated/arbitrum_l2_bridge_adapter" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/liquiditymanager/generated/liquiditymanager" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/liquiditymanager/generated/mock_l1_bridge_adapter" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/liquiditymanager/generated/mock_l2_bridge_adapter" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/liquiditymanager/generated/optimism_l1_bridge_adapter" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/liquiditymanager/generated/optimism_l2_bridge_adapter" -) - -type ArmProxy struct { - client blockchain.EVMClient - Instance *arm_proxy_contract.ARMProxyContract - EthAddress *common.Address -} - -func (e *CCIPContractsDeployer) DeployArmProxy(arm common.Address) (*ArmProxy, error) { - address, _, instance, err := e.evmClient.DeployContract("ARMProxy", func( - auth *bind.TransactOpts, - _ bind.ContractBackend, - ) (common.Address, *types.Transaction, interface{}, error) { - return arm_proxy_contract.DeployARMProxyContract( - auth, - wrappers.MustNewWrappedContractBackend(e.evmClient, nil), - arm, - ) - }) - if err != nil { - return nil, err - } - return &ArmProxy{ - client: e.evmClient, - Instance: instance.(*arm_proxy_contract.ARMProxyContract), - EthAddress: address, - }, err -} - -type LiquidityManager struct { - client blockchain.EVMClient - logger *zerolog.Logger - Instance *liquiditymanager.LiquidityManager - EthAddress *common.Address -} - -func (e *CCIPContractsDeployer) DeployLiquidityManager( - token common.Address, - localChainSelector uint64, - localLiquidityContainer common.Address, - minimumLiquidity *big.Int, -) (*LiquidityManager, error) { - address, _, instance, err := e.evmClient.DeployContract("LiquidityManager", func( - auth *bind.TransactOpts, - _ bind.ContractBackend, - ) (common.Address, *types.Transaction, interface{}, error) { - return liquiditymanager.DeployLiquidityManager( - auth, - wrappers.MustNewWrappedContractBackend(e.evmClient, nil), - token, - localChainSelector, - localLiquidityContainer, - minimumLiquidity, - common.Address{}, - ) - }) - if err != nil { - return nil, err - } - return &LiquidityManager{ - client: e.evmClient, - logger: e.logger, - Instance: instance.(*liquiditymanager.LiquidityManager), - EthAddress: address, - }, err -} - -func (v *LiquidityManager) GetLiquidity() (*big.Int, error) { - return v.Instance.GetLiquidity(nil) -} - -func (v *LiquidityManager) SetCrossChainRebalancer( - crossChainRebalancerArgs liquiditymanager.ILiquidityManagerCrossChainRebalancerArgs, -) error { - v.logger.Info(). - Str("Liquidity Manager", v.EthAddress.String()). - Msg("Setting crosschain rebalancer on liquidity manager") - opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) - if err != nil { - return fmt.Errorf("failed to get transaction opts: %w", err) - } - tx, err := v.Instance.SetCrossChainRebalancer(opts, crossChainRebalancerArgs) - if err != nil { - return fmt.Errorf("failed to set cross chain rebalancer: %w", err) - - } - v.logger.Info(). - Str("Liquidity Manager", v.EthAddress.String()). - Interface("Rebalance Argsr", crossChainRebalancerArgs). - Msg("Crosschain Rebalancer set on liquidity manager") - return v.client.ProcessTransaction(tx) -} - -func (v *LiquidityManager) SetOCR3Config( - signers []common.Address, - transmitters []common.Address, - f uint8, - onchainConfig []byte, - offchainConfigVersion uint64, - offchainConfig []byte, -) error { - v.logger.Info(). - Str("Liquidity Manager", v.EthAddress.String()). - Msg("Setting ocr3 config on liquidity manager") - opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) - if err != nil { - return fmt.Errorf("failed to get transaction opts: %w", err) - } - tx, err := v.Instance.SetOCR3Config( - opts, - signers, - transmitters, - f, - onchainConfig, - offchainConfigVersion, - offchainConfig) - if err != nil { - return fmt.Errorf("failed to set cross chain rebalancer: %w", err) - - } - v.logger.Info(). - Str("Liquidity Manager", v.EthAddress.String()). - Msg("Set OCR3Config on LM") - return v.client.ProcessTransaction(tx) -} - -type ArbitrumL1BridgeAdapter struct { - client blockchain.EVMClient - Instance *arbitrum_l1_bridge_adapter.ArbitrumL1BridgeAdapter - EthAddress *common.Address -} - -func (e *CCIPContractsDeployer) DeployArbitrumL1BridgeAdapter( - l1GatewayRouter common.Address, - l1Outbox common.Address, -) (*ArbitrumL1BridgeAdapter, error) { - address, _, instance, err := e.evmClient.DeployContract("ArbitrumL1BridgeAdapter", func( - auth *bind.TransactOpts, - _ bind.ContractBackend, - ) (common.Address, *types.Transaction, interface{}, error) { - return arbitrum_l1_bridge_adapter.DeployArbitrumL1BridgeAdapter( - auth, - wrappers.MustNewWrappedContractBackend(e.evmClient, nil), - l1GatewayRouter, - l1Outbox, - ) - }) - if err != nil { - return nil, err - } - return &ArbitrumL1BridgeAdapter{ - client: e.evmClient, - Instance: instance.(*arbitrum_l1_bridge_adapter.ArbitrumL1BridgeAdapter), - EthAddress: address, - }, err -} - -type ArbitrumL2BridgeAdapter struct { - client blockchain.EVMClient - Instance *arbitrum_l2_bridge_adapter.ArbitrumL2BridgeAdapter - EthAddress *common.Address -} - -func (e *CCIPContractsDeployer) DeployArbitrumL2BridgeAdapter(l2GatewayRouter common.Address) (*ArbitrumL2BridgeAdapter, error) { - address, _, instance, err := e.evmClient.DeployContract("ArbitrumL2BridgeAdapter", func( - auth *bind.TransactOpts, - _ bind.ContractBackend, - ) (common.Address, *types.Transaction, interface{}, error) { - return arbitrum_l2_bridge_adapter.DeployArbitrumL2BridgeAdapter( - auth, - wrappers.MustNewWrappedContractBackend(e.evmClient, nil), - l2GatewayRouter, - ) - }) - if err != nil { - return nil, err - } - return &ArbitrumL2BridgeAdapter{ - client: e.evmClient, - Instance: instance.(*arbitrum_l2_bridge_adapter.ArbitrumL2BridgeAdapter), - EthAddress: address, - }, err -} - -type OptimismL1BridgeAdapter struct { - client blockchain.EVMClient - Instance *optimism_l1_bridge_adapter.OptimismL1BridgeAdapter - EthAddress *common.Address -} - -func (e *CCIPContractsDeployer) DeployOptimismL1BridgeAdapter( - l1Bridge common.Address, - wrappedNative common.Address, - optimismPortal common.Address, -) (*OptimismL1BridgeAdapter, error) { - address, _, instance, err := e.evmClient.DeployContract("OptimismL1BridgeAdapter", func( - auth *bind.TransactOpts, - _ bind.ContractBackend, - ) (common.Address, *types.Transaction, interface{}, error) { - return optimism_l1_bridge_adapter.DeployOptimismL1BridgeAdapter( - auth, - wrappers.MustNewWrappedContractBackend(e.evmClient, nil), - l1Bridge, - wrappedNative, - optimismPortal, - ) - }) - if err != nil { - return nil, err - } - return &OptimismL1BridgeAdapter{ - client: e.evmClient, - Instance: instance.(*optimism_l1_bridge_adapter.OptimismL1BridgeAdapter), - EthAddress: address, - }, err -} - -type OptimismL2BridgeAdapter struct { - client blockchain.EVMClient - Instance *optimism_l2_bridge_adapter.OptimismL2BridgeAdapter - EthAddress *common.Address -} - -func (e *CCIPContractsDeployer) DeployOptimismL2BridgeAdapter(wrappedNative common.Address) (*OptimismL2BridgeAdapter, error) { - address, _, instance, err := e.evmClient.DeployContract("OptimismL2BridgeAdapter", func( - auth *bind.TransactOpts, - _ bind.ContractBackend, - ) (common.Address, *types.Transaction, interface{}, error) { - return optimism_l2_bridge_adapter.DeployOptimismL2BridgeAdapter( - auth, - wrappers.MustNewWrappedContractBackend(e.evmClient, nil), - wrappedNative, - ) - }) - if err != nil { - return nil, err - } - return &OptimismL2BridgeAdapter{ - client: e.evmClient, - Instance: instance.(*optimism_l2_bridge_adapter.OptimismL2BridgeAdapter), - EthAddress: address, - }, err -} - -type MockL1BridgeAdapter struct { - client blockchain.EVMClient - Instance *mock_l1_bridge_adapter.MockL1BridgeAdapter - EthAddress *common.Address -} - -func (e *CCIPContractsDeployer) DeployMockL1BridgeAdapter(tokenAddr common.Address, holdNative bool) (*MockL1BridgeAdapter, error) { - address, _, instance, err := e.evmClient.DeployContract("MockL1BridgeAdapter", func( - auth *bind.TransactOpts, - _ bind.ContractBackend, - ) (common.Address, *types.Transaction, interface{}, error) { - return mock_l1_bridge_adapter.DeployMockL1BridgeAdapter( - auth, - wrappers.MustNewWrappedContractBackend(e.evmClient, nil), - tokenAddr, - holdNative, - ) - }) - if err != nil { - return nil, err - } - return &MockL1BridgeAdapter{ - client: e.evmClient, - Instance: instance.(*mock_l1_bridge_adapter.MockL1BridgeAdapter), - EthAddress: address, - }, err -} - -type MockL2BridgeAdapter struct { - client blockchain.EVMClient - Instance *mock_l2_bridge_adapter.MockL2BridgeAdapter - EthAddress *common.Address -} - -func (e *CCIPContractsDeployer) DeployMockL2BridgeAdapter() (*MockL2BridgeAdapter, error) { - address, _, instance, err := e.evmClient.DeployContract("MockL2BridgeAdapter", func( - auth *bind.TransactOpts, - _ bind.ContractBackend, - ) (common.Address, *types.Transaction, interface{}, error) { - return mock_l2_bridge_adapter.DeployMockL2BridgeAdapter( - auth, - wrappers.MustNewWrappedContractBackend(e.evmClient, nil), - ) - }) - if err != nil { - return nil, err - } - return &MockL2BridgeAdapter{ - client: e.evmClient, - Instance: instance.(*mock_l2_bridge_adapter.MockL2BridgeAdapter), - EthAddress: address, - }, err -} diff --git a/integration-tests/ccip-tests/smoke/lm_test.go b/integration-tests/ccip-tests/smoke/lm_test.go deleted file mode 100644 index 8b2625ac110..00000000000 --- a/integration-tests/ccip-tests/smoke/lm_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package smoke - -import ( - "testing" - "time" - - "github.com/stretchr/testify/require" - - "github.com/smartcontractkit/chainlink-testing-framework/logging" - - "github.com/smartcontractkit/chainlink/integration-tests/ccip-tests/testconfig" - "github.com/smartcontractkit/chainlink/integration-tests/ccip-tests/testsetups" -) - -func TestLmBasic(t *testing.T) { - t.Parallel() - log := logging.GetTestLogger(t) - TestCfg := testsetups.NewCCIPTestConfig(t, log, testconfig.Smoke) - require.NotNil(t, TestCfg.TestGroupInput.MsgDetails.DestGasLimit) - //gasLimit := big.NewInt(*TestCfg.TestGroupInput.MsgDetails.DestGasLimit) - lmTestSetup := testsetups.LMDefaultTestSetup(t, &log, "smoke-lm", TestCfg) - - l1ChainId := lmTestSetup.Cfg.SelectedNetworks[0].ChainID - l2ChainId := lmTestSetup.Cfg.SelectedNetworks[1].ChainID - - l1liquidityStart, err := lmTestSetup.LMModules[l1ChainId].LM.GetLiquidity() - require.NoError(t, err, "Failed to get liquidity from L1") - l2liquidityStart, err := lmTestSetup.LMModules[l2ChainId].LM.GetLiquidity() - require.NoError(t, err, "Failed to get liquidity from L2") - log.Info().Str("L1 Liquidity", l1liquidityStart.String()).Str("L2 Liquidity", l2liquidityStart.String()).Msg("Liquidity at start") - - // TODO: Improve this wait - log.Info().Msg("Waiting 3 minutes for liquidity to change") - time.Sleep(3 * time.Minute) - - l1liquidityEnd, err := lmTestSetup.LMModules[l1ChainId].LM.GetLiquidity() - require.NoError(t, err, "Failed to get liquidity from L1") - l2liquidityEnd, err := lmTestSetup.LMModules[l2ChainId].LM.GetLiquidity() - require.NoError(t, err, "Failed to get liquidity from L2") - log.Info().Str("L1 Liquidity", l1liquidityEnd.String()).Str("L2 Liquidity", l2liquidityEnd.String()).Msg("Liquidity at end") - - // Check if liquidity changed. - // Ideally liquidity should change on both chains, but sometimes I have seen it not change on L2 - // TODO: Investigate why liquidity is not changing on L2 - if (l1liquidityEnd.Cmp(l1liquidityStart) == 0) && (l2liquidityEnd.Cmp(l2liquidityStart) == 0) { - t.Errorf("Liquidity did not change during the test") - } - // TODO: The test should also check for LiquidityTransferred event on both chains -} diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 3fb25bc675c..207773aace4 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -29,7 +29,8 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/blockchain" ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client" - ctfconfig "github.com/smartcontractkit/chainlink-testing-framework/config" + ctf_config "github.com/smartcontractkit/chainlink-testing-framework/config" + ctf_config_types "github.com/smartcontractkit/chainlink-testing-framework/config/types" ctftestenv "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" "github.com/smartcontractkit/chainlink-testing-framework/k8s/config" "github.com/smartcontractkit/chainlink-testing-framework/k8s/environment" @@ -270,16 +271,16 @@ func (c *CCIPTestConfig) SetNetworkPairs(lggr zerolog.Logger) error { c.EnvInput.Network.AnvilConfigs[strings.ToUpper(name)] = existing } - chainConfig := &ctfconfig.EthereumChainConfig{} + chainConfig := &ctf_config.EthereumChainConfig{} err := chainConfig.Default() if err != nil { allError = multierr.Append(allError, fmt.Errorf("failed to get default chain config: %w", err)) } else { chainConfig.ChainID = int(chainID) - eth1 := ctfconfig.EthereumVersion_Eth1 - geth := ctfconfig.ExecutionLayer_Geth + eth1 := ctf_config_types.EthereumVersion_Eth1 + geth := ctf_config_types.ExecutionLayer_Geth - c.EnvInput.PrivateEthereumNetworks[fmt.Sprint(chainID)] = &ctfconfig.EthereumNetworkConfig{ + c.EnvInput.PrivateEthereumNetworks[fmt.Sprint(chainID)] = &ctf_config.EthereumNetworkConfig{ EthereumVersion: ð1, ExecutionLayer: &geth, EthereumChainConfig: chainConfig, diff --git a/integration-tests/ccip-tests/testsetups/lm_setup.go b/integration-tests/ccip-tests/testsetups/lm_setup.go deleted file mode 100644 index dbc2135f1e1..00000000000 --- a/integration-tests/ccip-tests/testsetups/lm_setup.go +++ /dev/null @@ -1,845 +0,0 @@ -package testsetups - -import ( - "context" - "crypto/ed25519" - "encoding/hex" - "fmt" - "math/big" - "os" - "strconv" - "strings" - "testing" - "time" - - "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/core/types" - - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/weth9" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/erc20" - - ocrconfighelper2 "github.com/smartcontractkit/libocr/offchainreporting2/confighelper" - ocrtypes2 "github.com/smartcontractkit/libocr/offchainreporting2/types" - "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper" - "golang.org/x/crypto/curve25519" - - "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm" - - "github.com/ethereum/go-ethereum/common" - "github.com/lib/pq" - - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/liquiditymanager/generated/liquiditymanager" - - "github.com/AlekSi/pointer" - "github.com/pkg/errors" - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" - chainselectors "github.com/smartcontractkit/chain-selectors" - "github.com/stretchr/testify/require" - "go.uber.org/zap/zapcore" - "golang.org/x/sync/errgroup" - - integrationactions "github.com/smartcontractkit/chainlink/integration-tests/actions" - - "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client" - "github.com/smartcontractkit/chainlink-testing-framework/k8s/config" - "github.com/smartcontractkit/chainlink-testing-framework/k8s/environment" - - "github.com/smartcontractkit/chainlink/integration-tests/ccip-tests/actions" - "github.com/smartcontractkit/chainlink/integration-tests/ccip-tests/contracts" - "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" - - integrationtesthelpers "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/liquiditymanager/testhelpers/integration" -) - -type LMTestSetupOutputs struct { - CCIPTestSetUpOutputs - LMModules map[int64]*actions.LMCommon -} - -// TODO - Copied over from ccip tests as such. Refactor and remove unused code -func (o *LMTestSetupOutputs) CreateLMEnvironment( - lggr *zerolog.Logger, - envName string, - reportPath string, -) map[int64]blockchain.EVMClient { - t := o.Cfg.Test - testConfig := o.Cfg - var ( - ccipEnv *actions.CCIPTestEnv - k8Env *environment.Environment - err error - chains []blockchain.EVMClient - local *test_env.CLClusterTestEnv - deployCL func() error - ) - - envConfig := createEnvironmentConfig(t, envName, testConfig, reportPath) - - configureCLNode := !testConfig.useExistingDeployment() || pointer.GetString(testConfig.EnvInput.EnvToConnect) != "" - namespace := "" - if testConfig.TestGroupInput.LoadProfile != nil { - namespace = testConfig.TestGroupInput.LoadProfile.TestRunName - } - require.False(t, testConfig.localCluster() && testConfig.ExistingCLCluster(), - "local cluster and existing cluster cannot be true at the same time") - // if it's a new deployment, deploy the env - // Or if EnvToConnect is given connect to that k8 environment - if configureCLNode { - if !testConfig.ExistingCLCluster() { - // if it's a local cluster, deploy the local cluster in docker - if testConfig.localCluster() { - local, deployCL = DeployLocalCluster(t, testConfig) - ccipEnv = &actions.CCIPTestEnv{ - LocalCluster: local, - } - namespace = "local-docker-deployment" - } else { - // Otherwise, deploy the k8s env - lggr.Info().Msg("Deploying test environment") - // deploy the env if configureCLNode is true - k8Env = DeployEnvironments(t, envConfig, testConfig) - ccipEnv = &actions.CCIPTestEnv{K8Env: k8Env} - namespace = ccipEnv.K8Env.Cfg.Namespace - } - } else { - // if there is already a cluster, use the existing cluster to connect to the nodes - ccipEnv = &actions.CCIPTestEnv{} - mockserverURL := pointer.GetString(testConfig.EnvInput.Mockserver) - require.NotEmpty(t, mockserverURL, "mockserver URL cannot be nil") - ccipEnv.MockServer = ctfClient.NewMockserverClient(&ctfClient.MockserverConfig{ - LocalURL: mockserverURL, - ClusterURL: mockserverURL, - }) - } - ccipEnv.CLNodeWithKeyReady, _ = errgroup.WithContext(o.SetUpContext) - o.Env = ccipEnv - if ccipEnv.K8Env != nil && ccipEnv.K8Env.WillUseRemoteRunner() { - return nil - } - } else { - // if configureCLNode is false it means we don't need to deploy any additional pods, - // use a placeholder env to create just the remote runner in it. - if value, set := os.LookupEnv(config.EnvVarJobImage); set && value != "" { - k8Env = environment.New(envConfig) - err = k8Env.Run() - require.NoErrorf(t, err, "error creating environment remote runner") - o.Env = &actions.CCIPTestEnv{K8Env: k8Env} - if k8Env.WillUseRemoteRunner() { - return nil - } - } - } - chainByChainID := make(map[int64]blockchain.EVMClient) - if pointer.GetBool(testConfig.TestGroupInput.LocalCluster) { - require.NotNil(t, ccipEnv.LocalCluster, "Local cluster shouldn't be nil") - for _, n := range ccipEnv.LocalCluster.EVMNetworks { - if evmClient, err := blockchain.NewEVMClientFromNetwork(*n, *lggr); err == nil { - chainByChainID[evmClient.GetChainID().Int64()] = evmClient - chains = append(chains, evmClient) - } else { - lggr.Error().Err(err).Msgf("EVMClient for chainID %d not found", n.ChainID) - } - } - } else { - for _, n := range testConfig.SelectedNetworks { - if _, ok := chainByChainID[n.ChainID]; ok { - continue - } - var ec blockchain.EVMClient - if k8Env == nil { - ec, err = blockchain.ConnectEVMClient(n, *lggr) - } else { - log.Info().Interface("urls", k8Env.URLs).Msg("URLs") - ec, err = blockchain.NewEVMClient(n, k8Env, *lggr) - } - require.NoError(t, err, "Connecting to blockchain nodes shouldn't fail") - chains = append(chains, ec) - chainByChainID[n.ChainID] = ec - } - } - if configureCLNode { - ccipEnv.CLNodeWithKeyReady.Go(func() error { - var totalNodes int - if !o.Cfg.ExistingCLCluster() { - if ccipEnv.LocalCluster != nil { - err = deployCL() - if err != nil { - return err - } - } - err = ccipEnv.ConnectToDeployedNodes() - if err != nil { - return fmt.Errorf("error connecting to chainlink nodes: %w", err) - } - totalNodes = pointer.GetInt(testConfig.EnvInput.NewCLCluster.NoOfNodes) - } else { - totalNodes = pointer.GetInt(testConfig.EnvInput.ExistingCLCluster.NoOfNodes) - err = ccipEnv.ConnectToExistingNodes(o.Cfg.EnvInput) - if err != nil { - return fmt.Errorf("error deploying and connecting to chainlink nodes: %w", err) - } - } - err = ccipEnv.SetUpNodeKeysAndFund(lggr, big.NewFloat(testConfig.TestGroupInput.NodeFunding), chains) - if err != nil { - return fmt.Errorf("error setting up nodes and keys %w", err) - } - // first node is the bootstrapper - ccipEnv.CommitNodeStartIndex = 1 - ccipEnv.ExecNodeStartIndex = 1 - ccipEnv.NumOfCommitNodes = testConfig.TestGroupInput.NoOfCommitNodes - ccipEnv.NumOfExecNodes = ccipEnv.NumOfCommitNodes - if !pointer.GetBool(testConfig.TestGroupInput.CommitAndExecuteOnSameDON) { - if len(ccipEnv.CLNodesWithKeys) < 11 { - return fmt.Errorf("not enough CL nodes for separate commit and execution nodes") - } - if testConfig.TestGroupInput.NoOfCommitNodes >= totalNodes { - return fmt.Errorf("number of commit nodes can not be greater than total number of nodes in DON") - } - // first two nodes are reserved for bootstrap commit and bootstrap exec - ccipEnv.CommitNodeStartIndex = 2 - ccipEnv.ExecNodeStartIndex = 2 + testConfig.TestGroupInput.NoOfCommitNodes - ccipEnv.NumOfExecNodes = totalNodes - (2 + testConfig.TestGroupInput.NoOfCommitNodes) - if ccipEnv.NumOfExecNodes < 4 { - return fmt.Errorf("insufficient number of exec nodes") - } - } - ccipEnv.NumOfAllowedFaultyExec = (ccipEnv.NumOfExecNodes - 1) / 3 - ccipEnv.NumOfAllowedFaultyCommit = (ccipEnv.NumOfCommitNodes - 1) / 3 - return nil - }) - } - - t.Cleanup(func() { - if configureCLNode { - if ccipEnv.LocalCluster != nil { - err := ccipEnv.LocalCluster.Terminate() - require.NoError(t, err, "Local cluster termination shouldn't fail") - //require.NoError(t, o.Reporter.SendReport(t, namespace, false), "Aggregating and sending report shouldn't fail") - return - } - if pointer.GetBool(testConfig.TestGroupInput.KeepEnvAlive) || testConfig.ExistingCLCluster() { - //require.NoError(t, o.Reporter.SendReport(t, namespace, true), "Aggregating and sending report shouldn't fail") - return - } - lggr.Info().Msg("Tearing down the environment") - err = integrationactions.TeardownSuite(t, nil, ccipEnv.K8Env, ccipEnv.CLNodes, o.Reporter, zapcore.DPanicLevel, o.Cfg.EnvInput) - require.NoError(t, err, "Environment teardown shouldn't fail") - } else { - //just send the report - require.NoError(t, o.Reporter.SendReport(t, namespace, true), "Aggregating and sending report shouldn't fail") - } - }) - return chainByChainID -} - -func (o *LMTestSetupOutputs) DeployLMChainContracts( - lggr *zerolog.Logger, - networkCfg blockchain.EVMNetwork, - lmCommon actions.LMCommon, - l2ChainID int64, -) error { - var k8Env *environment.Environment - ccipEnv := o.Env - chainClient := lmCommon.ChainClient - if ccipEnv != nil { - k8Env = ccipEnv.K8Env - } - if k8Env != nil && chainClient.NetworkSimulated() { - networkCfg.URLs = k8Env.URLs[chainClient.GetNetworkConfig().Name] - } - - chain, err := blockchain.ConcurrentEVMClient(networkCfg, k8Env, chainClient, *lggr) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to create chain client for %s: %w", networkCfg.Name, err)) - } - - chain.ParallelTransactions(true) - //defer chain.Close() - - cd, err := contracts.NewCCIPContractsDeployer(lggr, chain) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to create contract deployer: %w", err)) - } - - // Deploy Wrapped Native contract only on private geth networks - if lmCommon.ChainSelectror == chainselectors.GETH_TESTNET.Selector || - lmCommon.ChainSelectror == chainselectors.GETH_DEVNET_2.Selector { - lggr.Info().Msg("Deploying Wrapped Native contract") - wrapperNative, err := cd.DeployWrappedNative() - if err != nil { - return errors.WithStack(fmt.Errorf("failed to deploy Wrapped Native contract: %w", err)) - } - lggr.Info().Str("Address", wrapperNative.String()).Msg("Deployed Wrapped Native contract") - lmCommon.WrapperNative = wrapperNative - } - - // Deploy Bridge Adapter contracts - switch lmCommon.ChainSelectror { - case chainselectors.GETH_TESTNET.Selector: - lggr.Info().Msg("Deploying Mock L1 Bridge Adapter contract") - bridgeAdapter, err := cd.DeployMockL1BridgeAdapter(*lmCommon.WrapperNative, true) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to deploy Mock L1 Bridge Adapter contract: %w", err)) - } - lggr.Info().Str("Address", bridgeAdapter.EthAddress.String()).Msg("Deployed Mock L1 Bridge Adapter contract") - lmCommon.BridgeAdapterAddr = bridgeAdapter.EthAddress - case chainselectors.GETH_DEVNET_2.Selector: - lggr.Info().Msg("Deploying Mock L2 Bridge Adapter contract") - bridgeAdapter, err := cd.DeployMockL2BridgeAdapter() - if err != nil { - return errors.WithStack(fmt.Errorf("failed to deploy Mock L2 Bridge Adapter contract: %w", err)) - } - lggr.Info().Str("Address", bridgeAdapter.EthAddress.String()).Msg("Deployed Mock L2 Bridge Adapter contract") - lmCommon.BridgeAdapterAddr = bridgeAdapter.EthAddress - case chainselectors.ETHEREUM_TESTNET_SEPOLIA.Selector: - if l2ChainID == int64(chainselectors.ETHEREUM_TESTNET_SEPOLIA_ARBITRUM_1.EvmChainID) { - wethAddress := common.HexToAddress("0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9") - lmCommon.WrapperNative = &wethAddress - lggr.Info().Msg("Deploying Arbitrum L1 Bridge Adapter contract") - bridgeAdapter, err := cd.DeployArbitrumL1BridgeAdapter( - common.HexToAddress("0xcE18836b233C83325Cc8848CA4487e94C6288264"), - common.HexToAddress("0x65f07C7D521164a4d5DaC6eB8Fac8DA067A3B78F"), - ) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to deploy Arbitrum L1 Bridge Adapter contract: %w", err)) - } - lggr.Info().Str("Address", bridgeAdapter.EthAddress.String()).Msg("Deployed Arbitrum L1 Bridge Adapter contract") - lmCommon.BridgeAdapterAddr = bridgeAdapter.EthAddress - } - if l2ChainID == int64(chainselectors.ETHEREUM_TESTNET_SEPOLIA_OPTIMISM_1.EvmChainID) { - wethAddress := common.HexToAddress("0x7b79995e5f793a07bc00c21412e50ecae098e7f9") - lmCommon.WrapperNative = &wethAddress - lggr.Info().Msg("Deploying Optimism L1 Bridge Adapter contract") - bridgeAdapter, err := cd.DeployOptimismL1BridgeAdapter( - common.HexToAddress("0xFBb0621E0B23b5478B630BD55a5f21f67730B0F1"), - *lmCommon.WrapperNative, - common.HexToAddress("0x16Fc5058F25648194471939df75CF27A2fdC48BC"), - ) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to deploy Optimism L1 Bridge Adapter contract: %w", err)) - } - lggr.Info().Str("Address", bridgeAdapter.EthAddress.String()).Msg("Deployed Optimism L1 Bridge Adapter contract") - lmCommon.BridgeAdapterAddr = bridgeAdapter.EthAddress - } - case chainselectors.ETHEREUM_TESTNET_SEPOLIA_ARBITRUM_1.Selector: - wethAddress := common.HexToAddress("0x980B62Da83eFf3D4576C647993b0c1D7faf17c73") - lmCommon.WrapperNative = &wethAddress - lggr.Info().Msg("Deploying Arbitrum L2 Bridge Adapter contract") - bridgeAdapter, err := cd.DeployArbitrumL2BridgeAdapter(common.HexToAddress("0x9fDD1C4E4AA24EEc1d913FABea925594a20d43C7")) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to deploy Arbitrum L2 Bridge Adapter contract: %w", err)) - } - lggr.Info().Str("Address", bridgeAdapter.EthAddress.String()).Msg("Deployed Arbitrum L2 Bridge Adapter contract") - lmCommon.BridgeAdapterAddr = bridgeAdapter.EthAddress - case chainselectors.ETHEREUM_TESTNET_SEPOLIA_OPTIMISM_1.Selector: - wethAddress := common.HexToAddress("0x4200000000000000000000000000000000000006") - lmCommon.WrapperNative = &wethAddress - lggr.Info().Msg("Deploying Optimism L2 Bridge Adapter contract") - bridgeAdapter, err := cd.DeployOptimismL2BridgeAdapter(*lmCommon.WrapperNative) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to deploy Optimism L2 Bridge Adapter contract: %w", err)) - } - lggr.Info().Str("Address", bridgeAdapter.EthAddress.String()).Msg("Deployed Optimism L2 Bridge Adapter contract") - lmCommon.BridgeAdapterAddr = bridgeAdapter.EthAddress - } - - // Deploy Mock ARM contract - lggr.Info().Msg("Deploying Mock ARM contract") - mockARMContract, err := cd.DeployMockARMContract() - if err != nil { - return errors.WithStack(fmt.Errorf("failed to deploy Mock ARM contract: %w", err)) - } - lggr.Info().Str("Address", mockARMContract.String()).Msg("Deployed Mock ARM contract") - lmCommon.MockArm = mockARMContract - - // Deploy ARM Proxy contract - lggr.Info().Msg("Deploying ARM Proxy contract") - armProxyContract, err := cd.DeployArmProxy(*mockARMContract) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to deploy ARM Proxy contract: %w", err)) - } - lggr.Info().Str("Address", armProxyContract.EthAddress.String()).Msg("Deployed ARM Proxy contract") - lmCommon.ArmProxy = armProxyContract - - // Deploy CCIP Router contract - lggr.Info().Msg("Deploying CCIP Router contract") - ccipRouterContract, err := cd.DeployRouter(common.Address{}, *lmCommon.ArmProxy.EthAddress) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to deploy CCIP Router contract: %w", err)) - } - lggr.Info().Str("Address", ccipRouterContract.EthAddress.String()).Msg("Deployed CCIP Router contract") - lmCommon.CcipRouter = ccipRouterContract - - // Deploy Lock Release Token contract - lggr.Info().Msg("Deploying Lock Release Token contract") - lockReleaseTokenPool, err := cd.DeployLockReleaseTokenPoolContract(lmCommon.WrapperNative.String(), *lmCommon.MockArm, lmCommon.CcipRouter.EthAddress) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to deploy Lock Release Token contract: %w", err)) - } - lggr.Info().Str("Address", lockReleaseTokenPool.EthAddress.String()).Msg("Deployed Lock Release Token contract") - lmCommon.TokenPool = lockReleaseTokenPool - - // Deploy Liquidity Manager contract - lggr.Info().Msg("Deploying Liquidity Manager contract") - liquidityManager, err := cd.DeployLiquidityManager(*lmCommon.WrapperNative, lmCommon.ChainSelectror, lmCommon.TokenPool.EthAddress, lmCommon.MinimumLiquidity) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to deploy Liquidity Manager contract: %w", err)) - } - lggr.Info().Str("Address", liquidityManager.EthAddress.String()).Msg("Deployed Liquidity Manager contract") - lmCommon.LM = liquidityManager - - // Set Liquidity Manager on Token Pool - lggr.Info().Msg("Setting Liquidity Manager on Token Pool") - err = lockReleaseTokenPool.SetRebalancer(*liquidityManager.EthAddress) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to set Liquidity Manager on Token Pool: %w", err)) - } - lggr.Info().Msg("Set Liquidity Manager on Token Pool") - - err = chain.WaitForEvents() - if err != nil { - return errors.WithStack(fmt.Errorf("failed to wait for events: %w", err)) - } - - // Verify on chain rebalancer from token pool matches deployed Liquidity Manager - onchainRebalancer, err := lockReleaseTokenPool.GetRebalancer() - if err != nil { - return errors.WithStack(fmt.Errorf("failed to get rebalancer from Token Pool: %w", err)) - } - if onchainRebalancer != *liquidityManager.EthAddress { - return errors.WithStack(fmt.Errorf("onchainRebalancer doesn not match the deployed Liquidity Manager")) - } - - lggr.Debug().Interface("lmCommon", lmCommon).Msg("lmCommon") - o.LMModules[chainClient.GetChainID().Int64()] = &lmCommon - - return nil -} - -func stripKeyPrefix(key string) string { - chunks := strings.Split(key, "_") - if len(chunks) == 3 { - return chunks[2] - } - return key -} - -func (o *LMTestSetupOutputs) SetOCR3Config(chainId int64) error { - clNodesWithKeys := o.Env.CLNodesWithKeys[strconv.FormatInt(chainId, 10)] - donNodes := clNodesWithKeys[1:] - oracleIdentities := make([]ocrconfighelper2.OracleIdentityExtra, 0) - var onChainKeys []ocrtypes2.OnchainPublicKey - var transmitters []common.Address - var schedule []int - - for i, nodeWithKeys := range donNodes { - ocr2Key := nodeWithKeys.KeysBundle.OCR2Key.Data - offChainPubKeyTemp, err := hex.DecodeString(stripKeyPrefix(ocr2Key.Attributes.OffChainPublicKey)) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to decode offchain public key: %w", err)) - } - formattedOnChainPubKey := stripKeyPrefix(ocr2Key.Attributes.OnChainPublicKey) - cfgPubKeyTemp, err := hex.DecodeString(stripKeyPrefix(ocr2Key.Attributes.ConfigPublicKey)) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to decode config public key: %w", err)) - } - cfgPubKeyBytes := [ed25519.PublicKeySize]byte{} - copy(cfgPubKeyBytes[:], cfgPubKeyTemp) - offChainPubKey := [curve25519.PointSize]byte{} - copy(offChainPubKey[:], offChainPubKeyTemp) - ethAddress := nodeWithKeys.KeysBundle.EthAddress - p2pKeys := nodeWithKeys.KeysBundle.P2PKeys - peerID := p2pKeys.Data[0].Attributes.PeerID - oracleIdentities = append(oracleIdentities, ocrconfighelper2.OracleIdentityExtra{ - OracleIdentity: ocrconfighelper2.OracleIdentity{ - OffchainPublicKey: offChainPubKey, - OnchainPublicKey: common.HexToAddress(formattedOnChainPubKey).Bytes(), - PeerID: peerID, - TransmitAccount: ocrtypes2.Account(ethAddress), - }, - ConfigEncryptionPublicKey: cfgPubKeyBytes, - }) - onChainKeys = append(onChainKeys, oracleIdentities[i].OnchainPublicKey) - transmitters = append(transmitters, common.HexToAddress(ethAddress)) - schedule = append(schedule, 1) - - } - signers, err := evm.OnchainPublicKeyToAddress(onChainKeys) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to convert onchain public keys to addresses: %w", err)) - } - - offchainConfig, onchainConfig := []byte{}, []byte{} - f := uint8(1) - _, _, f, onchainConfig, offchainConfigVersion, offchainConfig, err := ocr3confighelper.ContractSetConfigArgsForTests( - 2*time.Minute, - 2*time.Minute, - 20*time.Second, - 2*time.Second, - 20*time.Second, - 10*time.Second, - 40*time.Second, - 3, - schedule, - oracleIdentities, - offchainConfig, - 50*time.Millisecond, - 1*time.Minute, - 1*time.Minute, - 1*time.Second, - int(f), - onchainConfig, - ) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to set OCR3 config args for tests: %w", err)) - } - err = o.LMModules[chainId].LM.SetOCR3Config(signers, transmitters, f, onchainConfig, offchainConfigVersion, offchainConfig) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to set OCR3 config: %w", err)) - } - return nil -} - -func (o *LMTestSetupOutputs) FundPool(chainId int64, lggr *zerolog.Logger, fundingAmount *big.Int) error { - token, err := erc20.NewERC20(*o.LMModules[chainId].WrapperNative, o.LMModules[chainId].ChainClient.Backend()) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to create ERC20 contract instance: %w", err)) - } - balance, err := token.BalanceOf(nil, common.HexToAddress(o.LMModules[chainId].ChainClient.GetDefaultWallet().Address())) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to get token pool balance: %w", err)) - } - lggr.Debug().Str("balance", balance.String()).Msg("weth balance of transactor") - symbol, err := token.Symbol(nil) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to get token symbol: %w", err)) - } - if symbol == "WETH" { - weth, err := weth9.NewWETH9(*o.LMModules[chainId].WrapperNative, o.LMModules[chainId].ChainClient.Backend()) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to create WETH contract instance: %w", err)) - } - nativeBalance, err := o.LMModules[chainId].ChainClient.BalanceAt(context.Background(), common.HexToAddress(o.LMModules[chainId].ChainClient.GetDefaultWallet().Address())) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to get native balance: %w", err)) - } - lggr.Debug().Str("nativeBalance", nativeBalance.String()).Msg("nativeBalance") - if nativeBalance.Cmp(fundingAmount) < 0 { - return errors.WithStack(fmt.Errorf("not enough native balance")) - } - lggr.Info().Msg("Depositing tokenpool funding to WETH contract") - txOpts, err := o.LMModules[chainId].ChainClient.TransactionOpts(o.LMModules[chainId].ChainClient.GetDefaultWallet()) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to get transaction options: %w", err)) - } - txOpts.Value = fundingAmount - tx, err := weth.Deposit(txOpts) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to deposit to WETH contract: %w", err)) - } - receipt, err := bind.WaitMined(context.Background(), o.LMModules[chainId].ChainClient.DeployBackend(), tx) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to wait for transaction receipt: %w", err)) - } - - lggr.Info().Str("tx hash", receipt.TxHash.String()).Msg("Deposited tokenpool funding to WETH contract") - } - lggr.Info().Msg("Funding token pool") - txOpts, err := o.LMModules[chainId].ChainClient.TransactionOpts(o.LMModules[chainId].ChainClient.GetDefaultWallet()) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to get transaction options: %w", err)) - - } - tx, err := token.Transfer(txOpts, o.LMModules[chainId].TokenPool.EthAddress, fundingAmount) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to transfer to token pool: %w", err)) - } - receipt, err := bind.WaitMined(context.Background(), o.LMModules[chainId].ChainClient.DeployBackend(), tx) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to wait for transaction receipt: %w", err)) - } - lggr.Info().Str("tx hash", receipt.TxHash.String()).Msg("Funded token pool") - - balance, err = token.BalanceOf(nil, o.LMModules[chainId].TokenPool.EthAddress) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to get token pool balance: %w", err)) - } - lggr.Debug().Str("balance", balance.String()).Msg("weth balance of token pool") - - return nil -} - -func (o *LMTestSetupOutputs) FundLM(chainId int64, lggr *zerolog.Logger, fundingAmount *big.Int) error { - transactor, err := o.LMModules[chainId].ChainClient.TransactionOpts(o.LMModules[chainId].ChainClient.GetDefaultWallet()) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to get transaction options: %w", err)) - } - cl := o.LMModules[chainId].ChainClient.Backend() - - nonce, err := cl.PendingNonceAt(context.Background(), transactor.From) - if err != nil { - return err - } - - gasPrice, err := cl.SuggestGasPrice(context.Background()) - if err != nil { - return err - } - - gasEstimate, err := cl.EstimateGas(context.Background(), ethereum.CallMsg{ - From: transactor.From, - To: o.LMModules[chainId].LM.EthAddress, - Value: fundingAmount, - }) - if err != nil { - return err - } - - tx := types.NewTx( - &types.LegacyTx{ - Nonce: nonce, - GasPrice: gasPrice, - Gas: gasEstimate, - To: o.LMModules[chainId].LM.EthAddress, - Value: fundingAmount, - }, - ) - signedTx, err := transactor.Signer(transactor.From, tx) - if err != nil { - return err - } - lggr.Info().Msg("Funding Liquidity Manager") - err = cl.SendTransaction(context.Background(), signedTx) - if err != nil { - return err - } - receipt, err := bind.WaitMined(context.Background(), o.LMModules[chainId].ChainClient.DeployBackend(), signedTx) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to wait for transaction receipt: %w", err)) - } - lggr.Info().Str("tx hash", receipt.TxHash.String()).Msg("Funded Liquidity Manager") - return nil -} - -func (o *LMTestSetupOutputs) AddJobs(chainId int64, lggr *zerolog.Logger) error { - // Add bootstrap job - clNodesWithKeys := o.Env.CLNodesWithKeys[strconv.FormatInt(chainId, 10)] - bootstrapNode := clNodesWithKeys[0] - bootstrapSpec, err := integrationtesthelpers.NewBootsrapJobSpec(&integrationtesthelpers.LMJobSpecParams{ - ChainID: uint64(chainId), - ContractID: o.LMModules[chainId].LM.EthAddress.String(), - CfgTrackerInterval: 15 * time.Second, - }) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to create bootstrap job spec: %w", err)) - } - lggr.Info().Msg("Adding bootstrap job") - j, err := bootstrapNode.Node.MustCreateJob(bootstrapSpec) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to create bootstrap job: %w", err)) - } - lggr.Info().Str("jobId", j.Data.ID).Msg("Bootstrap job added") - - P2Pv2Bootstrapper := fmt.Sprintf("%s@%s:%d", bootstrapNode.KeysBundle.P2PKeys.Data[0].Attributes.PeerID, bootstrapNode.Node.InternalIP(), 6690) - - // Add LM jobs - donNodes := clNodesWithKeys[1:] - - for _, node := range donNodes { - lmJobSpec, err := integrationtesthelpers.NewJobSpec(&integrationtesthelpers.LMJobSpecParams{ - ChainID: uint64(chainId), - ContractID: o.LMModules[chainId].LM.EthAddress.String(), - OCRKeyBundleID: node.KeysBundle.OCR2Key.Data.ID, - TransmitterID: node.KeysBundle.EthAddress, - P2PV2Bootstrappers: pq.StringArray{P2Pv2Bootstrapper}, - CfgTrackerInterval: 15 * time.Second, - LiquidityManagerAddress: *o.LMModules[chainId].LM.EthAddress, - NetworkSelector: o.LMModules[chainId].ChainSelectror, - Type: "ping-pong", - }) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to create LM job spec: %w", err)) - } - lggr.Debug().Interface("lmJobSpec", lmJobSpec).Msg("lmJobSpec") - lggr.Info().Str("Node URL", node.Node.URL()).Msg("Adding LM job") - j, err := node.Node.MustCreateJob(lmJobSpec) - if err != nil { - return errors.WithStack(fmt.Errorf("failed to create LM job: %w", err)) - } - lggr.Info().Str("jobId", j.Data.ID).Msg("LM job added") - - } - return nil -} - -func LMDefaultTestSetup( - t *testing.T, - lggr *zerolog.Logger, - envName string, - testConfig *CCIPTestConfig, -) *LMTestSetupOutputs { - var ( - err error - ) - reportPath := "tmp_laneconfig" - parent, cancel := context.WithCancel(context.Background()) - defer cancel() - lmModules := make(map[int64]*actions.LMCommon) - setUpArgs := &LMTestSetupOutputs{ - CCIPTestSetUpOutputs{ - SetUpContext: parent, - Cfg: testConfig, - }, - lmModules, - } - - chainByChainID := setUpArgs.CreateLMEnvironment(lggr, envName, reportPath) - - chainAddGrp, _ := errgroup.WithContext(setUpArgs.SetUpContext) - lggr.Info().Msg("Deploying common contracts") - chainSelectors := make(map[int64]uint64) - - testConfig.SelectedNetworks, _, err = testConfig.EnvInput.EVMNetworks() - require.NoError(t, err) - - testConfig.AllNetworks = make(map[string]blockchain.EVMNetwork) - for _, net := range testConfig.SelectedNetworks { - testConfig.AllNetworks[net.Name] = net - if _, exists := chainSelectors[net.ChainID]; !exists { - chainSelectors[net.ChainID], err = chainselectors.SelectorFromChainId(uint64(net.ChainID)) - require.NoError(t, err) - } - } - - l1ChainId := testConfig.SelectedNetworks[0].ChainID - l2ChainId := testConfig.SelectedNetworks[1].ChainID - - for _, net := range testConfig.AllNetworks { - chain := chainByChainID[net.ChainID] - net := net - net.HTTPURLs = chain.GetNetworkConfig().HTTPURLs - net.URLs = chain.GetNetworkConfig().URLs - var selectors []uint64 - for chainId, selector := range chainSelectors { - if chainId == net.ChainID { - selectors = append(selectors, selector) - } - } - lmCommon, err := actions.DefaultLMModule( - chain, - big.NewInt(0), - selectors[0], - ) - require.NoError(t, err) - chainAddGrp.Go(func() error { - return setUpArgs.DeployLMChainContracts(lggr, net, *lmCommon, l2ChainId) - }) - } - require.NoError(t, chainAddGrp.Wait(), "Deploying common contracts shouldn't fail") - - lggr.Debug().Interface("lmModules", lmModules).Msg("lmModules") - - //Set Cross Chain Rebalancer on L1 Rebalancer - err = lmModules[l1ChainId].LM.SetCrossChainRebalancer( - liquiditymanager.ILiquidityManagerCrossChainRebalancerArgs{ - RemoteRebalancer: *lmModules[l2ChainId].LM.EthAddress, - LocalBridge: *lmModules[l1ChainId].BridgeAdapterAddr, - RemoteToken: *lmModules[l2ChainId].WrapperNative, - RemoteChainSelector: lmModules[l2ChainId].ChainSelectror, - Enabled: true, - }) - require.NoError(t, err, "Setting Cross Chain Rebalancer on L1 Rebalancer shouldn't fail") - - //Set Cross Chain Rebalancer on L2 Rebalancer - err = lmModules[l2ChainId].LM.SetCrossChainRebalancer( - liquiditymanager.ILiquidityManagerCrossChainRebalancerArgs{ - RemoteRebalancer: *lmModules[l1ChainId].LM.EthAddress, - LocalBridge: *lmModules[l2ChainId].BridgeAdapterAddr, - RemoteToken: *lmModules[l1ChainId].WrapperNative, - RemoteChainSelector: lmModules[l1ChainId].ChainSelectror, - Enabled: true, - }) - require.NoError(t, err, "Setting Cross Chain Rebalancer on L1 Rebalancer shouldn't fail") - - // Wait for setting cross chain balancers on both chains to confirm - err = lmModules[l1ChainId].ChainClient.WaitForEvents() - require.NoError(t, err, "Waiting for events to confirm on L1 chain shouldn't fail") - - err = lmModules[l2ChainId].ChainClient.WaitForEvents() - require.NoError(t, err, "Waiting for events to confirm on L2 chain shouldn't fail") - - // Verify that onchain rebalancer matches the deployed Liquidity Manager - onchainRebalancerL1, err := lmModules[l1ChainId].TokenPool.GetRebalancer() - require.NoError(t, err, "Getting rebalancer from Token Pool shouldn't fail") - - onchainRebalancerL2, err := lmModules[l2ChainId].TokenPool.GetRebalancer() - require.NoError(t, err, "Getting rebalancer from Token Pool shouldn't fail") - - if onchainRebalancerL1.String() != lmModules[l1ChainId].LM.EthAddress.String() || - onchainRebalancerL2.String() != lmModules[l2ChainId].LM.EthAddress.String() { - lggr.Debug(). - Str("onchainRebalancerL1", onchainRebalancerL1.String()). - Str("onchainRebalancerL2", onchainRebalancerL2.String()). - Str("L2 LM", lmModules[l2ChainId].LM.EthAddress.String()). - Str("L1 LM", lmModules[l1ChainId].LM.EthAddress.String()). - Msg("Onchain rebalancer mismatch") - t.Fatalf("Onchain rebalancer mismatch") - } - - // Fund L1 Token Pool - err = setUpArgs.FundPool(l1ChainId, lggr, big.NewInt(1000000000)) - require.NoError(t, err, "Funding L1 Token Pool shouldn't fail") - - //Fund L1 LM - err = setUpArgs.FundLM(l1ChainId, lggr, big.NewInt(1000000000)) - require.NoError(t, err, "Funding L1 LM shouldn't fail") - - err = lmModules[l1ChainId].ChainClient.WaitForEvents() - require.NoError(t, err, "Waiting for events to confirm on L1 chain shouldn't fail") - - // Fund L2 Token Pool - err = setUpArgs.FundPool(l2ChainId, lggr, big.NewInt(1000000000)) - require.NoError(t, err, "Funding L2 Token Pool shouldn't fail") - - //Fund L2 LM - err = setUpArgs.FundLM(l2ChainId, lggr, big.NewInt(1000000000)) - require.NoError(t, err, "Funding L2 LM shouldn't fail") - - err = lmModules[l2ChainId].ChainClient.WaitForEvents() - require.NoError(t, err, "Waiting for events to confirm on L2 chain shouldn't fail") - - liquidity, err := setUpArgs.LMModules[l1ChainId].LM.GetLiquidity() - require.NoError(t, err, "Getting liquidity from L1 LM shouldn't fail") - lggr.Debug().Interface("liquidity", liquidity).Msg("Liquidity") - require.Equal(t, big.NewInt(1000000000), liquidity, "Liquidity should match") - - liquidity, err = setUpArgs.LMModules[l2ChainId].LM.GetLiquidity() - require.NoError(t, err, "Getting liquidity from L1 LM shouldn't fail") - lggr.Debug().Interface("liquidity", liquidity).Msg("Liquidity") - require.Equal(t, big.NewInt(1000000000), liquidity, "Liquidity should match") - - err = setUpArgs.Env.CLNodeWithKeyReady.Wait() - require.NoError(t, err, "Waiting for CL nodes to be ready shouldn't fail") - - err = setUpArgs.AddJobs(l1ChainId, lggr) - require.NoError(t, err, "Adding jobs on L1 chain shouldn't fail") - - // Set Config on L2 Chain - err = setUpArgs.SetOCR3Config(l2ChainId) - require.NoError(t, err, "Setting OCR3 config on L2 chain shouldn't fail") - - // TODO: Remove this sleep when it is no longer needed - time.Sleep(30 * time.Second) - - // Set Config on L1 Chain - err = setUpArgs.SetOCR3Config(l1ChainId) - require.NoError(t, err, "Setting OCR3 config on L1 chain shouldn't fail") - - defer lmModules[l1ChainId].ChainClient.Close() - defer lmModules[l2ChainId].ChainClient.Close() - - return setUpArgs -} diff --git a/integration-tests/ccip-tests/testsetups/test_env.go b/integration-tests/ccip-tests/testsetups/test_env.go index e0a9c84482f..63018c9fe44 100644 --- a/integration-tests/ccip-tests/testsetups/test_env.go +++ b/integration-tests/ccip-tests/testsetups/test_env.go @@ -13,7 +13,8 @@ import ( "github.com/rs/zerolog" "github.com/stretchr/testify/require" - ctfconfig "github.com/smartcontractkit/chainlink-testing-framework/config" + ctf_config "github.com/smartcontractkit/chainlink-testing-framework/config" + ctf_config_types "github.com/smartcontractkit/chainlink-testing-framework/config/types" "github.com/smartcontractkit/chainlink-testing-framework/networks" "github.com/smartcontractkit/chainlink-testing-framework/utils/conversions" @@ -256,7 +257,7 @@ func DeployLocalCluster( ) (*test_env.CLClusterTestEnv, func() error) { selectedNetworks := testInputs.SelectedNetworks - privateEthereumNetworks := []*ctfconfig.EthereumNetworkConfig{} + privateEthereumNetworks := []*ctf_config.EthereumNetworkConfig{} for _, network := range testInputs.EnvInput.PrivateEthereumNetworks { privateEthereumNetworks = append(privateEthereumNetworks, network) @@ -286,16 +287,16 @@ func DeployLocalCluster( } for _, network := range missing { - chainConfig := &ctfconfig.EthereumChainConfig{} + chainConfig := &ctf_config.EthereumChainConfig{} err := chainConfig.Default() if err != nil { require.NoError(t, err, "failed to get default chain config: %w", err) } else { chainConfig.ChainID = int(network.ChainID) - eth1 := ctfconfig.EthereumVersion_Eth1 - geth := ctfconfig.ExecutionLayer_Geth + eth1 := ctf_config_types.EthereumVersion_Eth1 + geth := ctf_config_types.ExecutionLayer_Geth - privateEthereumNetworks = append(privateEthereumNetworks, &ctfconfig.EthereumNetworkConfig{ + privateEthereumNetworks = append(privateEthereumNetworks, &ctf_config.EthereumNetworkConfig{ EthereumVersion: ð1, ExecutionLayer: &geth, EthereumChainConfig: chainConfig, diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 7be6ea209f1..c7204cdb18c 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -6,6 +6,9 @@ go 1.22.5 replace github.com/smartcontractkit/chainlink/v2 => ../ require ( + dario.cat/mergo v1.0.0 + github.com/AlekSi/pointer v1.1.0 + github.com/Masterminds/semver/v3 v3.2.1 github.com/avast/retry-go/v4 v4.6.0 github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df github.com/chaos-mesh/chaos-mesh/api v0.0.0-20240709130330-9f4feec7553f @@ -22,11 +25,13 @@ require ( github.com/onsi/gomega v1.33.1 github.com/pelletier/go-toml/v2 v2.2.2 github.com/pkg/errors v0.9.1 + github.com/prometheus/common v0.55.0 github.com/rs/zerolog v1.31.0 github.com/scylladb/go-reflectx v1.0.1 github.com/segmentio/ksuid v1.0.4 github.com/shopspring/decimal v1.4.0 github.com/slack-go/slack v0.12.2 + github.com/smartcontractkit/chain-selectors v1.0.10 github.com/smartcontractkit/chainlink-automation v1.0.4 github.com/smartcontractkit/chainlink-common v0.2.2-0.20240805160614-501c4f40b98c github.com/smartcontractkit/chainlink-testing-framework v1.34.2 @@ -41,7 +46,11 @@ require ( github.com/test-go/testify v1.1.4 github.com/testcontainers/testcontainers-go v0.28.0 github.com/umbracle/ethgo v0.1.3 + go.uber.org/atomic v1.11.0 + go.uber.org/multierr v1.11.0 go.uber.org/zap v1.27.0 + golang.org/x/crypto v0.25.0 + golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 golang.org/x/sync v0.7.0 golang.org/x/text v0.16.0 gopkg.in/guregu/null.v4 v4.0.0 @@ -60,7 +69,6 @@ require ( cosmossdk.io/depinject v1.0.0-alpha.3 // indirect cosmossdk.io/errors v1.0.0 // indirect cosmossdk.io/math v1.0.1 // indirect - dario.cat/mergo v1.0.0 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect @@ -78,7 +86,6 @@ require ( github.com/K-Phoen/sdk v0.12.4 // indirect github.com/MakeNowJust/heredoc v1.0.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.2.1 // indirect github.com/Masterminds/sprig/v3 v3.2.3 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/Microsoft/hcsshim v0.11.4 // indirect @@ -270,6 +277,7 @@ require ( github.com/hashicorp/serf v0.10.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/hdevalence/ed25519consensus v0.1.0 // indirect + github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 // indirect github.com/holiman/bloomfilter/v2 v2.0.3 // indirect github.com/holiman/uint256 v1.2.4 // indirect github.com/huandu/skiplist v1.2.0 // indirect @@ -358,7 +366,6 @@ require ( github.com/prometheus/alertmanager v0.26.0 // indirect github.com/prometheus/client_golang v1.19.1 // indirect github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/common/sigv4 v0.1.0 // indirect github.com/prometheus/exporter-toolkit v0.10.1-0.20230714054209-2f4150c63f97 // indirect github.com/prometheus/procfs v0.15.1 // indirect @@ -376,7 +383,6 @@ require ( github.com/shirou/gopsutil/v3 v3.24.3 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/sirupsen/logrus v1.9.3 // indirect - github.com/smartcontractkit/chain-selectors v1.0.10 // indirect github.com/smartcontractkit/chainlink-ccip v0.0.0-20240806144315-04ac101e9c95 // indirect github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45 // indirect github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240801131703-fd75761c982f // indirect @@ -442,14 +448,10 @@ require ( go.opentelemetry.io/otel/trace v1.28.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect - go.uber.org/atomic v1.11.0 // indirect go.uber.org/goleak v1.3.0 // indirect - go.uber.org/multierr v1.11.0 // indirect go.uber.org/ratelimit v0.3.0 // indirect go4.org/netipx v0.0.0-20230125063823-8449b0a6169f // indirect golang.org/x/arch v0.8.0 // indirect - golang.org/x/crypto v0.25.0 // indirect - golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect golang.org/x/mod v0.19.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect