Skip to content

Commit

Permalink
CCIP-2573 - Handle TokenDeployer client creation when there is more t…
Browse files Browse the repository at this point in the history
…han 1 router per chain (#1027)
  • Loading branch information
AnieeG authored Jun 17, 2024
1 parent c651218 commit 640a6d5
Show file tree
Hide file tree
Showing 16 changed files with 249 additions and 100 deletions.
48 changes: 15 additions & 33 deletions .github/workflows/ccip-offchain-upgrade-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,22 @@ jobs:
AWS_REGION: ${{ secrets.QA_AWS_REGION }}
AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}

build-test-image-current-sha:
build-test-image:
if: needs.changes.outputs.src == 'true' || github.event_name == 'workflow_dispatch'
needs: [ changes ]
environment: integration
permissions:
id-token: write
contents: read
name: Build Test Image with Current Sha
name: Build Test Image
runs-on: ubuntu-latest
steps:
- name: Collect Metrics
if: needs.changes.outputs.src == 'true' || github.event_name == 'workflow_dispatch'
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@dea9b546553cb4ca936607c2267a09c004e4ab3f # v3.0.0
with:
id: ccip-offchain-upgrade-compatibility-tests-build-test-image-current-sha
id: ccip-offchain-upgrade-compatibility-tests-build-test-image
org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }}
basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }}
Expand All @@ -125,19 +125,19 @@ jobs:
uses: ./.github/actions/build-test-image
with:
# we just want to build the load tests
suites: ccip-tests/load
suites: ccip-tests/load ccip-tests/smoke
QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
QA_AWS_ACCOUNT_NUMBER: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}

build-test-image-for-last-release:
last-release-info:
if: needs.changes.outputs.src == 'true' || github.event_name == 'workflow_dispatch'
needs: [ changes ]
environment: integration
permissions:
id-token: write
contents: read
name: Build Test Image for Last Release
name: Fetch Info for Last Release
runs-on: ubuntu-latest
outputs:
release_name: ${{ steps.fetch_last_release.outputs.release_name }}
Expand All @@ -149,7 +149,7 @@ jobs:
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@dea9b546553cb4ca936607c2267a09c004e4ab3f # v3.0.0
with:
id: ccip-offchain-upgrade-compatibility-tests-build-test-image-for-last-release
id: ccip-offchain-upgrade-compatibility-tests-last-release-info
org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }}
basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }}
Expand All @@ -165,20 +165,6 @@ jobs:
echo "release_name=${release_name}" >> $GITHUB_OUTPUT
sha_ref=$(curl -s --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" --request GET https://api.github.com/repos/${{ github.repository }}/git/refs/tags/${release_name} | jq -r '.object.sha' | sort -V | tail -n 1)
echo "sha_ref=${sha_ref}" >> $GITHUB_OUTPUT
- name: Checkout the repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: smartcontractkit/ccip
ref: ${{ steps.fetch_last_release.outputs.sha_ref }}
- name: Build Test Image
if: needs.changes.outputs.src == 'true' || github.event_name == 'workflow_dispatch'
uses: ./.github/actions/build-test-image
with:
QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
QA_AWS_ACCOUNT_NUMBER: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}
tag: ${{ steps.fetch_last_release.outputs.sha_ref }}
other_tags: ${{ steps.fetch_last_release.outputs.release_name }}
# End Build Test Dependencies

# run test with previous image
Expand All @@ -190,7 +176,7 @@ jobs:
pull-requests: write
id-token: write
contents: read
needs: [ changes, build-test-image-for-last-release ]
needs: [ changes, last-release-info, build-test-image ]
outputs:
existing_namespace: ${{ steps.fetch_namespace.outputs.existing_namespace }}
triggered_by: ${{ steps.fetch_namespace.outputs.triggered_by }}
Expand All @@ -203,11 +189,11 @@ jobs:
run: ^TestSmokeCCIPForBidirectionalLane$
config_path: ./integration-tests/ccip-tests/testconfig/tomls/node-pre-upgrade-compatibility.toml
runs-on: ubuntu-latest
name: CCIP Deployment with ${{ needs.build-test-image-for-last-release.outputs.release_tag }} - ${{ matrix.product.name }}
name: CCIP Deployment with ${{ needs.last-release-info.outputs.release_tag }} - ${{ matrix.product.name }}
env:
RELEASE_TAG: ${{ needs.build-test-image-for-last-release.outputs.release_tag }}
RELEASE_SHA: ${{ needs.build-test-image-for-last-release.outputs.release_sha }}
RELEASE_NAME: ${{ needs.build-test-image-for-last-release.outputs.release_name }}
RELEASE_TAG: ${{ needs.last-release-info.outputs.release_tag }}
RELEASE_SHA: ${{ needs.last-release-info.outputs.release_sha }}
RELEASE_NAME: ${{ needs.last-release-info.outputs.release_name }}
TEST_TRIGGERED_BY: ${{ matrix.product.name }}-${{ github.run_id }}
steps:
- name: Collect Metrics
Expand All @@ -219,7 +205,7 @@ jobs:
org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }}
basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }}
this-job-name: CCIP Deployment with ${{ needs.build-test-image-for-last-release.outputs.release_tag }} - ${{ matrix.product.name }}
this-job-name: CCIP Deployment with ${{ needs.last-release-info.outputs.release_tag }} - ${{ matrix.product.name }}
test-results-file: '{"testType":"go","filePath":"/tmp/gotest.log"}'
- name: Checkout the repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down Expand Up @@ -253,11 +239,7 @@ jobs:
env:
BASE64_CCIP_CONFIG_OVERRIDE: ${{ steps.set_override_config.outputs.base_64_override }}
TEST_BASE64_CCIP_CONFIG_OVERRIDE: ${{ steps.set_override_config.outputs.base_64_override }}
# uncomment this later for next release
# ENV_JOB_IMAGE: ${{ env.ENV_JOB_IMAGE_BASE }}:${{ env.RELEASE_SHA }}
# for now we run test with a specific test image pertaining to previous release with some added fixes
# this image use 1.2 ramps instead of incompatible 1.5-dev ramps from offchain v2.10.0-ccip1.4-release
ENV_JOB_IMAGE: ${{ env.ENV_JOB_IMAGE_BASE }}:release-v2.10.0-ccip1.4
ENV_JOB_IMAGE: ${{ env.ENV_JOB_IMAGE_BASE }}:${{ github.sha }}
TEST_SUITE: smoke
TEST_ARGS: -test.timeout 30m
TEST_LOG_LEVEL: info
Expand Down Expand Up @@ -317,7 +299,7 @@ jobs:
pull-requests: write
id-token: write
contents: read
needs: [ build-chainlink, changes, build-test-image-current-sha, run-test-with-last-release ]
needs: [ build-chainlink, changes, build-test-image, run-test-with-last-release ]
strategy:
fail-fast: false
matrix:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ jobs:
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
Expand Down
103 changes: 58 additions & 45 deletions integration-tests/ccip-tests/actions/ccip_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ var (

RootSnoozeTime = 3 * time.Minute
GethLabel = func(name string) string {
name = NetworkName(name)
switch NetworkChart {
case reorg.TXNodesAppLabel:
return fmt.Sprintf("%s-ethereum-geth", name)
case foundry.ChartName:
return fmt.Sprintf("%s-foundry", name)
return name
}
return ""
}
Expand Down Expand Up @@ -1150,11 +1151,10 @@ type StaticPriceConfig struct {
func NewCCIPCommonFromConfig(
logger zerolog.Logger,
testGroupConf *testconfig.CCIPTestGroupConfig,
testEnv *CCIPTestEnv,
chainClient blockchain.EVMClient,
laneConfig *laneconfig.LaneConfig,
) (*CCIPCommon, error) {
newCCIPModule, err := DefaultCCIPModule(logger, testGroupConf, testEnv, chainClient)
newCCIPModule, err := DefaultCCIPModule(logger, testGroupConf, chainClient)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1234,18 +1234,10 @@ func NewCCIPCommonFromConfig(
func DefaultCCIPModule(
logger zerolog.Logger,
testGroupConf *testconfig.CCIPTestGroupConfig,
testEnv *CCIPTestEnv,
chainClient blockchain.EVMClient,
) (*CCIPCommon, error) {
networkCfg := chainClient.GetNetworkConfig()
var k8Env *environment.Environment
if testEnv != nil {
k8Env = testEnv.K8Env
}
if k8Env != nil && chainClient.NetworkSimulated() {
networkCfg.URLs = k8Env.URLs[chainClient.GetNetworkConfig().Name]
}
tokenDeployerChainClient, err := blockchain.ConcurrentEVMClient(*networkCfg, k8Env, chainClient, logger)
tokenDeployerChainClient, err := blockchain.ConcurrentEVMClient(*networkCfg, nil, chainClient, logger)
if err != nil {
return nil, errors.WithStack(fmt.Errorf("failed to create token deployment chain client for %s: %w", networkCfg.Name, err))
}
Expand Down Expand Up @@ -1790,14 +1782,13 @@ func (sourceCCIP *SourceCCIPModule) SendRequest(
func DefaultSourceCCIPModule(
logger zerolog.Logger,
testConf *testconfig.CCIPTestGroupConfig,
testEnv *CCIPTestEnv,
chainClient blockchain.EVMClient,
destChainId uint64,
destChain string,
laneConf *laneconfig.LaneConfig,
) (*SourceCCIPModule, error) {
cmn, err := NewCCIPCommonFromConfig(
logger, testConf, testEnv, chainClient, laneConf,
logger, testConf, chainClient, laneConf,
)
if err != nil {
return nil, err
Expand Down Expand Up @@ -2019,6 +2010,13 @@ func (destCCIP *DestCCIPModule) DeployContracts(
if destCCIP.Common.ExistingDeployment {
return fmt.Errorf("offramp address not provided in lane config")
}
var tokenAdminReg common.Address
if contracts.NeedTokenAdminRegistry() {
if destCCIP.Common.TokenAdminRegistry == nil {
return fmt.Errorf("token admin registry contract address is not provided in lane config")
}
tokenAdminReg = destCCIP.Common.TokenAdminRegistry.EthAddress
}
destCCIP.OffRamp, err = contractDeployer.DeployOffRamp(
destCCIP.SourceChainSelector,
destChainSelector,
Expand All @@ -2028,7 +2026,7 @@ func (destCCIP *DestCCIPModule) DeployContracts(
[]common.Address{},
[]common.Address{},
*destCCIP.Common.ARMContract,
destCCIP.Common.TokenAdminRegistry.EthAddress,
tokenAdminReg,
)
if err != nil {
return fmt.Errorf("deploying offramp shouldn't fail %w", err)
Expand Down Expand Up @@ -2537,14 +2535,13 @@ func (destCCIP *DestCCIPModule) AssertSeqNumberExecuted(
func DefaultDestinationCCIPModule(
logger zerolog.Logger,
testConf *testconfig.CCIPTestGroupConfig,
testEnv *CCIPTestEnv,
chainClient blockchain.EVMClient,
sourceChainId uint64,
sourceChain string,
laneConf *laneconfig.LaneConfig,
) (*DestCCIPModule, error) {
cmn, err := NewCCIPCommonFromConfig(
logger, testConf, testEnv, chainClient, laneConf,
logger, testConf, chainClient, laneConf,
)
if err != nil {
return nil, err
Expand Down Expand Up @@ -3475,7 +3472,6 @@ func (lane *CCIPLane) DeployNewCCIPLane(
lane.Source, err = DefaultSourceCCIPModule(
lane.Logger,
testConf,
env,
sourceChainClient, destChainClient.GetChainID().Uint64(),
destChainClient.GetNetworkName(),
srcConf,
Expand All @@ -3484,7 +3480,7 @@ func (lane *CCIPLane) DeployNewCCIPLane(
return fmt.Errorf("failed to create source module: %w", err)
}
lane.Dest, err = DefaultDestinationCCIPModule(
lane.Logger, testConf, env,
lane.Logger, testConf,
destChainClient, sourceChainClient.GetChainID().Uint64(),
sourceChainClient.GetNetworkName(), destConf,
)
Expand Down Expand Up @@ -3698,17 +3694,26 @@ func SetOCR2Config(
Interface("OCRParmsForCommit", OCR2ParamsForCommit).
Interface("OCRParmsForExec", OCR2ParamsForExec).
Msg("Setting OCR2 config")
commitOffchainCfg, err := contracts.NewCommitOffchainConfig(
*commonconfig.MustNewDuration(5 * time.Second),
1e6,
1e6,
*commonconfig.MustNewDuration(5 * time.Second),
1e6,
*inflightExpiryCommit,
)
if err != nil {
return fmt.Errorf("failed to create commit offchain config: %w", err)
}

commitOnchainCfg, err := contracts.NewCommitOnchainConfig(
destCCIP.Common.PriceRegistry.EthAddress,
)
if err != nil {
return fmt.Errorf("failed to create commit onchain config: %w", err)
}
signers, transmitters, f, onchainConfig, offchainConfigVersion, offchainConfig, err := contracts.NewOffChainAggregatorV2ConfigForCCIPPlugin(
commitNodes, testhelpers.NewCommitOffchainConfig(
*commonconfig.MustNewDuration(5 * time.Second),
1e6,
1e6,
*commonconfig.MustNewDuration(5 * time.Second),
1e6,
*inflightExpiryCommit,
), testhelpers.NewCommitOnchainConfig(
destCCIP.Common.PriceRegistry.EthAddress,
), OCR2ParamsForCommit, 3*time.Minute)
commitNodes, commitOffchainCfg, commitOnchainCfg, OCR2ParamsForCommit, 3*time.Minute)
if err != nil {
return fmt.Errorf("failed to create ocr2 config params for commit: %w", err)
}
Expand All @@ -3724,24 +3729,32 @@ func SetOCR2Config(
nodes = execNodes
}
if destCCIP.OffRamp != nil {
execOffchainCfg, err := contracts.NewExecOffchainConfig(
1,
BatchGasLimit,
0.7,
*inflightExpiryExec,
*commonconfig.MustNewDuration(RootSnoozeTime),
)
if err != nil {
return fmt.Errorf("failed to create exec offchain config: %w", err)
}
execOnchainCfg, err := contracts.NewExecOnchainConfig(
uint32(DefaultPermissionlessExecThreshold.Seconds()),
destCCIP.Common.Router.EthAddress,
destCCIP.Common.PriceRegistry.EthAddress,
DefaultMaxNoOfTokensInMsg,
MaxDataBytes,
200_000,
50_000,
)
if err != nil {
return fmt.Errorf("failed to create exec onchain config: %w", err)
}
signers, transmitters, f, onchainConfig, offchainConfigVersion, offchainConfig, err = contracts.NewOffChainAggregatorV2ConfigForCCIPPlugin(
nodes,
testhelpers.NewExecOffchainConfig(
1,
BatchGasLimit,
0.7,
*inflightExpiryExec,
*commonconfig.MustNewDuration(RootSnoozeTime),
),
testhelpers.NewExecOnchainConfig(
uint32(DefaultPermissionlessExecThreshold.Seconds()),
destCCIP.Common.Router.EthAddress,
destCCIP.Common.PriceRegistry.EthAddress,
DefaultMaxNoOfTokensInMsg,
MaxDataBytes,
200_000,
50_000,
),
execOffchainCfg,
execOnchainCfg,
OCR2ParamsForExec,
3*time.Minute,
)
Expand Down
Loading

0 comments on commit 640a6d5

Please sign in to comment.