From 89abd726b6c3f29a84e0fc5d230a1324f622755b Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Fri, 15 Mar 2024 22:06:07 +0100 Subject: [PATCH] add workflow that verifies compatibility with different versions of evm nodes (#12332) * add workflow that verifies compatibility with different versions of evm nodes * fix lints * fix worklow definion * another workflow fix * another fix * send slack notifications only if go-ethereum dep was modified * bump go-ethereum to v1.13.9 to test the workflow * remove hardcoded commit hashes... * fix comparison * bump * use correctly git diff * fetch develop before comparing * remove unnecesary outputs declaration * add outputs debug * remove step id * use explicit outputs * execute workflow also on dispatch if go-ethereum version did not change * fix script output * fix quoting of custom images in TOML, echo test compatibility matrix * don't use pyroscope in compatibility tests * use newer CTF * latest ctf, couple of fixes * bump CTF, run compatibility tests only for geth * all smoke tests will now use TOML config * set ethereum version to empty * adjust TOML created in CI to latest CTF changes * run also ocr2 test * adjust regex capture for Slack message * try to group compatibilty tests results by product * group by product, not full matrix * run even more product tests to check compatibility * fix parameter field name * log details before starting private ethereum network * fix how TOML is build for custom eth client image * fix typo in argument name * fix versions + always notify slack * add a ContractBackend wrapper that is backward-compatible with go-ethereum < 1.11.0 * add comment to contract calelr * try running compatibility fix on broken version * just trigger * try to build image in CI * try to checkout old commit * fix contract caller, and let's see if it fails or not * remove code used for testing, fix slack reporting * fix a situation, when we lose transaction timeout setting for networks that are not overwritten * trigger compatibility tests for PR bumping go-ethereum to 1.13.14 * add gas limit for Fiji, fix a situation when new networks were ignored * fix lints * remove hardcoded github sha * add changeset * separate method for restarting CL cluster * update go.mod * go.mod * lints * do not bump go-eth * use latest CTF v1.27.0 * dump down go-ethereum, fix some comments and descriptions * add helper that exposes legacy methods to use them in test wrapper and rpc client * remove stale comment --- .changeset/moody-ligers-walk.md | 5 + .../notify-slack-jobs-result/action.yml | 9 +- .../setup-create-base64-config/action.yml | 27 ++ .../evm-version-compatibility-tests.yml | 323 ++++++++++++++++++ .../chains/evm/client/compatibility_helper.go | 57 ++++ core/chains/evm/client/rpc_client.go | 53 +-- integration-tests/actions/private_network.go | 2 +- .../contracts/contract_deployer.go | 59 ++-- .../contracts/contract_loader.go | 3 +- .../contracts/ethereum_contracts_seth.go | 5 +- .../contracts/ethereum_vrf_contracts.go | 9 +- .../contracts/ethereum_vrfv2_contracts.go | 13 +- .../contracts/ethereum_vrfv2plus_contracts.go | 9 +- integration-tests/docker/test_env/cl_node.go | 24 +- integration-tests/docker/test_env/test_env.go | 7 + .../docker/test_env/test_env_builder.go | 2 +- integration-tests/go.mod | 2 +- integration-tests/go.sum | 4 +- integration-tests/load/go.mod | 2 +- integration-tests/load/go.sum | 4 +- .../scripts/buildEvmClientTestMatrixList.sh | 64 ++++ integration-tests/smoke/automation_test.go | 8 +- integration-tests/smoke/cron_test.go | 11 +- .../evm_node_compatibility_test_list.json | 214 ++++++++++++ integration-tests/smoke/flux_test.go | 5 +- integration-tests/smoke/forwarder_ocr_test.go | 5 +- .../smoke/forwarders_ocr2_test.go | 4 + integration-tests/smoke/keeper_test.go | 34 +- integration-tests/smoke/ocr2_test.go | 5 +- integration-tests/smoke/runlog_test.go | 6 +- integration-tests/smoke/vrf_test.go | 10 +- integration-tests/smoke/vrfv2_test.go | 9 +- integration-tests/smoke/vrfv2plus_test.go | 8 + integration-tests/testconfig/default.toml | 2 +- .../testconfig/log_poller/log_poller.toml | 8 + .../universal/log_poller/helpers.go | 13 +- integration-tests/wrappers/contract_caller.go | 130 +++++++ 37 files changed, 1007 insertions(+), 148 deletions(-) create mode 100644 .changeset/moody-ligers-walk.md create mode 100644 .github/workflows/evm-version-compatibility-tests.yml create mode 100644 core/chains/evm/client/compatibility_helper.go create mode 100755 integration-tests/scripts/buildEvmClientTestMatrixList.sh create mode 100644 integration-tests/smoke/evm_node_compatibility_test_list.json create mode 100644 integration-tests/wrappers/contract_caller.go diff --git a/.changeset/moody-ligers-walk.md b/.changeset/moody-ligers-walk.md new file mode 100644 index 00000000000..c93bf8517ee --- /dev/null +++ b/.changeset/moody-ligers-walk.md @@ -0,0 +1,5 @@ +--- +"chainlink": patch +--- + +Add new pipeline for testing EVM node compatibility on go-ethereum dependency bump diff --git a/.github/actions/notify-slack-jobs-result/action.yml b/.github/actions/notify-slack-jobs-result/action.yml index 63840cfa393..c61e07d01d1 100644 --- a/.github/actions/notify-slack-jobs-result/action.yml +++ b/.github/actions/notify-slack-jobs-result/action.yml @@ -36,9 +36,10 @@ runs: # I feel like there's some clever, fully jq way to do this, but I ain't got the motivation to figure it out echo "Querying test results at https://api.github.com/repos/${{inputs.github_repository}}/actions/runs/${{ inputs.workflow_run_id }}/jobs" + # we can get a maximum of 100 jobs per page, after that we need to start using pagination PARSED_RESULTS=$(curl \ -H "Authorization: Bearer ${{ inputs.github_token }}" \ - 'https://api.github.com/repos/${{inputs.github_repository}}/actions/runs/${{ inputs.workflow_run_id }}/jobs' \ + 'https://api.github.com/repos/${{inputs.github_repository}}/actions/runs/${{ inputs.workflow_run_id }}/jobs?per_page=100' \ | jq -r --arg pattern "${{ inputs.github_job_name_regex }}" '.jobs[] | select(.name | test($pattern)) as $job | $job.steps[] @@ -59,9 +60,9 @@ runs: echo all_success=$ALL_SUCCESS >> $GITHUB_OUTPUT - FORMATTED_RESULTS=$(echo $PARSED_RESULTS | jq -s '[.[] - | { - conclusion: .conclusion, + FORMATTED_RESULTS=$(echo $PARSED_RESULTS | jq -s '[.[] + | { + conclusion: .conclusion, cap: .cap, html_url: .html_url } diff --git a/.github/actions/setup-create-base64-config/action.yml b/.github/actions/setup-create-base64-config/action.yml index d68d4f7b12f..447f5be42cb 100644 --- a/.github/actions/setup-create-base64-config/action.yml +++ b/.github/actions/setup-create-base64-config/action.yml @@ -35,6 +35,10 @@ inputs: description: Grafana URL grafanaDashboardUrl: description: Grafana dashboard URL + ethExecutionClient: + description: Ethereum execution client to use (geth, besu, nethermind or erigon) + customEthClientDockerImage: + description: custom docker image to use for eth client (e.g. hyperledger/besu:21.10.0) runs: using: composite @@ -58,6 +62,8 @@ runs: LOGSTREAM_LOG_TARGETS: ${{ inputs.logstreamLogTargets }} GRAFANA_URL: ${{ inputs.grafanaUrl }} GRAFANA_DASHBOARD_URL: ${{ inputs.grafanaDashboardUrl }} + ETH_EXECUTION_CLIENT: ${{ inputs.ethExecutionClient }} + CUSTOM_ETH_CLIENT_DOCKER_IMAGE: ${{ inputs.customEthClientDockerImage }} run: | echo ::add-mask::$CHAINLINK_IMAGE function convert_to_toml_array() { @@ -88,6 +94,21 @@ runs: test_log_collect=false fi + custom_images="" + ethereum_version="" + + if [ -n "$CUSTOM_ETH_CLIENT_DOCKER_IMAGE" ]; then + ethereum_version="ethereum_version=\"\"" + custom_images+="[PrivateEthereumNetwork.CustomDockerImages]" + custom_images+=$'\n'"execution_layer=\"$CUSTOM_ETH_CLIENT_DOCKER_IMAGE\"" + fi + + if [ -n "$ETH_EXECUTION_CLIENT" ]; then + execution_layer="$ETH_EXECUTION_CLIENT" + else + execution_layer="geth" + fi + cat << EOF > config.toml [Network] selected_networks=$selected_networks @@ -118,6 +139,12 @@ runs: [Logging.Grafana] base_url="$GRAFANA_URL" dashboard_url="$GRAFANA_DASHBOARD_URL" + + [PrivateEthereumNetwork] + execution_layer="$execution_layer" + $ethereum_version + + $custom_images EOF BASE64_CONFIG_OVERRIDE=$(cat config.toml | base64 -w 0) diff --git a/.github/workflows/evm-version-compatibility-tests.yml b/.github/workflows/evm-version-compatibility-tests.yml new file mode 100644 index 00000000000..5be5f314392 --- /dev/null +++ b/.github/workflows/evm-version-compatibility-tests.yml @@ -0,0 +1,323 @@ +name: EVM Node Version Compatibility Tests +on: + merge_group: + pull_request: + push: + tags: + - "*" + workflow_dispatch: + inputs: + base64_test_list: + description: Base64 encoded test list (same format as ./integration-tests/evm_node_compatibility_test_list.json) + required: false + type: string + +env: + CHAINLINK_IMAGE: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/chainlink + INTERNAL_DOCKER_REPO: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com + MOD_CACHE_VERSION: 2 + +jobs: + + # Check if go.mod has changed + check-dependency-bump: + runs-on: ubuntu-latest + outputs: + dependency_bumped: ${{ steps.changes.outputs.dependency_bumped }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Fetch develop branch + run: git fetch --depth=1 origin develop:develop + - name: Check for go.mod changes + id: changes + run: | + if git diff origin/develop -- go.mod | grep -q 'github.com/ethereum/go-ethereum'; then + echo "Dependency ethereum/go-ethereum was changed" + echo "dependency_bumped=true" >> "$GITHUB_OUTPUT" + else + echo "No relevant dependency bump detected." + echo "dependency_bumped=false" >> "$GITHUB_OUTPUT" + fi + + # Build Test Dependencies + + build-chainlink: + if: needs.check-dependency-bump.outputs.dependency_bumped == 'true' || github.event_name == 'workflow_dispatch' + needs: [check-dependency-bump] + environment: integration + permissions: + id-token: write + contents: read + name: Build Chainlink Image + runs-on: ubuntu-latest + steps: + - name: Collect Metrics + id: collect-gha-metrics + uses: smartcontractkit/push-gha-metrics-action@0281b09807758be1dcc41651e44e62b353808c47 # v2.1.0 + with: + org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }} + basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }} + hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }} + this-job-name: Build Chainlink Image + continue-on-error: true + - name: Checkout the repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }} + - name: Build Chainlink Image + uses: ./.github/actions/build-chainlink-image + with: + tag_suffix: "" + dockerfile: core/chainlink.Dockerfile + git_commit_sha: ${{ github.sha }} + AWS_REGION: ${{ secrets.QA_AWS_REGION }} + AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }} + + build-tests: + if: needs.check-dependency-bump.outputs.dependency_bumped == 'true' || github.event_name == 'workflow_dispatch' + needs: [check-dependency-bump] + environment: integration + permissions: + id-token: write + contents: read + name: Build Tests Binary + runs-on: ubuntu-latest + steps: + - name: Collect Metrics + id: collect-gha-metrics + uses: smartcontractkit/push-gha-metrics-action@0281b09807758be1dcc41651e44e62b353808c47 # v2.1.0 + with: + org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }} + basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }} + hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }} + this-job-name: Build Tests Binary + continue-on-error: true + - name: Checkout the repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }} + - name: Build Tests + uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/build-tests@c67a09566412d153ff7640d99f96b43aa03abc04 # v2.3.6 + with: + test_download_vendor_packages_command: cd ./integration-tests && go mod download + token: ${{ secrets.GITHUB_TOKEN }} + go_mod_path: ./integration-tests/go.mod + go_tags: embed + cache_key_id: core-e2e-${{ env.MOD_CACHE_VERSION }} + cache_restore_only: "true" + binary_name: tests + + build-test-matrix: + if: needs.check-dependency-bump.outputs.dependency_bumped == 'true' || github.event_name == 'workflow_dispatch' + needs: [check-dependency-bump] + runs-on: ubuntu-latest + name: Build Test Matrix + outputs: + matrix: ${{ env.JOB_MATRIX_JSON }} + steps: + - name: Checkout the repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Setup environment variables + run: | + echo "BASE64_TEST_LIST=${{ github.event.inputs.base64_test_list }}" >> $GITHUB_ENV + - name: Decode Base64 Test List Input if Set + id: decode-base64-test-list + if: env.BASE64_TEST_LIST != '' + run: | + echo "Decoding base64 test list..." + DECODED_BASE64_TEST_LIST=$(echo $BASE64_TEST_LIST | base64 -d) + echo $DECODED_BASE64_TEST_LIST + cd ./integration-tests + echo $DECODED_BASE64_TEST_LIST >> ./evm_node_compatibility_test_list.json + - name: Override Test List If Present + if: env.BASE64_TEST_LIST == '' + id: build-test-matrix-list + run: | + cd ./integration-tests + cp ./smoke/evm_node_compatibility_test_list.json . + - name: Create Test Matrix + id: create-test-matrix-list + run: | + cd ./integration-tests + JOB_MATRIX_JSON=$(./scripts/buildEvmClientTestMatrixList.sh ./evm_node_compatibility_test_list.json ubuntu-latest) + echo "JOB_MATRIX_JSON=${JOB_MATRIX_JSON}" >> $GITHUB_ENV + echo $JOB_MATRIX_JSON | jq . + + # End Build Test Dependencies + + evm-node-compatiblity-matrix: + environment: integration + permissions: + checks: write + pull-requests: write + id-token: write + contents: read + needs: + [check-dependency-bump, build-chainlink, build-tests, build-test-matrix] + env: + SELECTED_NETWORKS: SIMULATED + CHAINLINK_COMMIT_SHA: ${{ github.sha }} + CHAINLINK_ENV_USER: ${{ github.actor }} + TEST_LOG_LEVEL: debug + strategy: + fail-fast: false + matrix: + evm_node: ${{fromJson(needs.build-test-matrix.outputs.matrix)}} + runs-on: ${{ matrix.evm_node.os }} + name: EVM node compatibility of ${{ matrix.evm_node.product }} with ${{ matrix.evm_node.docker_image }} + 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@0281b09807758be1dcc41651e44e62b353808c47 # v2.1.0 + with: + basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }} + hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }} + org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }} + this-job-name: EVM node compatibility ${{ matrix.evm_node.name }} ${{ matrix.evm_node.docker_image }} + test-results-file: '{"testType":"go","filePath":"/tmp/gotest.log"}' + continue-on-error: true + - name: Checkout the repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }} + - name: Build Go Test Command + id: build-go-test-command + run: | + # if the matrix.evm_node.run is set, use it for a different command + if [ "${{ matrix.evm_node.run }}" != "" ]; then + echo "run_command=${{ matrix.evm_node.run }} ./smoke/${{ matrix.evm_node.product }}_test.go" >> "$GITHUB_OUTPUT" + else + echo "run_command=./smoke/${{ matrix.evm_node.product }}_test.go" >> "$GITHUB_OUTPUT" + fi + - name: Prepare Base64 TOML override + uses: ./.github/actions/setup-create-base64-config + with: + runId: ${{ github.run_id }} + testLogCollect: ${{ vars.TEST_LOG_COLLECT }} + selectedNetworks: ${{ env.SELECTED_NETWORKS }} + chainlinkImage: ${{ env.CHAINLINK_IMAGE }} + chainlinkVersion: ${{ github.sha }} + lokiEndpoint: ${{ secrets.LOKI_URL }} + lokiTenantId: ${{ vars.LOKI_TENANT_ID }} + lokiBasicAuth: ${{ secrets.LOKI_BASIC_AUTH }} + logstreamLogTargets: ${{ vars.LOGSTREAM_LOG_TARGETS }} + grafanaUrl: ${{ vars.GRAFANA_URL }} + grafanaDashboardUrl: "/d/ddf75041-1e39-42af-aa46-361fe4c36e9e/ci-e2e-tests-logs" + ethExecutionClient: ${{ matrix.evm_node.eth_client }} + customEthClientDockerImage: ${{ matrix.evm_node.docker_image }} + + - name: Run Tests + uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/run-tests@c67a09566412d153ff7640d99f96b43aa03abc04 # v2.3.6 + with: + test_command_to_run: cd ./integration-tests && go test -timeout 45m -count=1 -json -test.parallel=2 ${{ steps.build-go-test-command.outputs.run_command }} 2>&1 | tee /tmp/gotest.log | gotestfmt + test_download_vendor_packages_command: cd ./integration-tests && go mod download + cl_repo: ${{ env.CHAINLINK_IMAGE }} + cl_image_tag: ${{ github.sha }} + aws_registries: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }} + artifacts_location: ./integration-tests/smoke/logs/ + publish_check_name: ${{ matrix.evm_node.product }}-compatibility-${{ matrix.evm_node.eth_client }}-${{ matrix.evm_node.docker_image }} + token: ${{ secrets.GITHUB_TOKEN }} + go_mod_path: ./integration-tests/go.mod + cache_key_id: core-e2e-${{ env.MOD_CACHE_VERSION }} + cache_restore_only: "true" + QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }} + QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }} + QA_KUBECONFIG: "" + should_tidy: "false" + - name: Print failed test summary + if: always() + uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/show-test-summary@c67a09566412d153ff7640d99f96b43aa03abc04 # v2.3.6 + + start-slack-thread: + name: Start Slack Thread + if: ${{ always() && needs.check-dependency-bump.outputs.dependency_bumped == 'true' && needs.*.result != 'skipped' && needs.*.result != 'cancelled' }} + environment: integration + outputs: + thread_ts: ${{ steps.slack.outputs.thread_ts }} + permissions: + checks: write + pull-requests: write + id-token: write + contents: read + runs-on: ubuntu-latest + needs: [ evm-node-compatiblity-matrix] + steps: + - name: Debug Result + run: echo ${{ join(needs.*.result, ',') }} + - name: Main Slack Notification + uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0 + id: slack + with: + channel-id: ${{ secrets.QA_SLACK_CHANNEL }} + payload: | + { + "attachments": [ + { + "color": "${{ contains(join(needs.*.result, ','), 'failure') && '#C62828' || '#2E7D32' }}", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "EVM Node Compatability Test Results ${{ contains(join(needs.*.result, ','), 'failure') && ':x:' || ':white_check_mark:'}}", + "emoji": true + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "${{ contains(join(needs.*.result, ','), 'failure') && 'Some tests failed, notifying <@U060CGGPY8H>' || 'All Good!' }}" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "<${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}|${{ github.ref_name }}> | <${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}> | <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Run>" + } + } + ] + } + ] + } + env: + SLACK_BOT_TOKEN: ${{ secrets.QA_SLACK_API_KEY }} + + post-test-results-to-slack: + name: Post Test Results for ${{matrix.evm_node.eth_client}} to Slack + if: ${{ always() && needs.check-dependency-bump.outputs.dependency_bumped == 'true' && needs.*.result != 'skipped' && needs.*.result != 'cancelled' }} + environment: integration + permissions: + checks: write + pull-requests: write + id-token: write + contents: read + runs-on: ubuntu-latest + needs: [start-slack-thread, build-test-matrix] + strategy: + fail-fast: false + matrix: + # this basically works as group by in SQL; we should update it when we update the test list JSON file + product: [automation,ocr,ocr2,vrf,vrfv2,vrfv2plus] + steps: + - name: Checkout the repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }} + - name: Post Test Results to Slack + uses: ./.github/actions/notify-slack-jobs-result + with: + github_token: ${{ github.token }} + github_repository: ${{ github.repository }} + workflow_run_id: ${{ github.run_id }} + github_job_name_regex: ^EVM node compatibility of ${{ matrix.product }} with (?.*?)$ + message_title: ${{ matrix.product }} + slack_channel_id: ${{ secrets.QA_SLACK_CHANNEL }} + slack_bot_token: ${{ secrets.QA_SLACK_API_KEY }} + slack_thread_ts: ${{ needs.start-slack-thread.outputs.thread_ts }} diff --git a/core/chains/evm/client/compatibility_helper.go b/core/chains/evm/client/compatibility_helper.go new file mode 100644 index 00000000000..c19c66b7442 --- /dev/null +++ b/core/chains/evm/client/compatibility_helper.go @@ -0,0 +1,57 @@ +package client + +import ( + "fmt" + "math/big" + + "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/rpc" +) + +// Needed to support Geth servers < v1.11.0 + +// COPIED FROM go-ethereum/ethclient/gethclient - must be kept up to date! +func ToBackwardCompatibleBlockNumArg(number *big.Int) string { + if number == nil { + return "latest" + } + if number.Sign() >= 0 { + return hexutil.EncodeBig(number) + } + // It's negative. + if number.IsInt64() { + return rpc.BlockNumber(number.Int64()).String() + } + // It's negative and large, which is invalid. + return fmt.Sprintf("", number) +} + +// COPIED FROM go-ethereum/ethclient/gethclient - must be kept up to date! +// Modified to include legacy 'data' as well as 'input' in order to support non-compliant servers. +func ToBackwardCompatibleCallArg(msg ethereum.CallMsg) interface{} { + arg := map[string]interface{}{ + "from": msg.From, + "to": msg.To, + } + if len(msg.Data) > 0 { + arg["input"] = hexutil.Bytes(msg.Data) + arg["data"] = hexutil.Bytes(msg.Data) // duplicate legacy field for compatibility + } + if msg.Value != nil { + arg["value"] = (*hexutil.Big)(msg.Value) + } + if msg.Gas != 0 { + arg["gas"] = hexutil.Uint64(msg.Gas) + } + if msg.GasPrice != nil { + arg["gasPrice"] = (*hexutil.Big)(msg.GasPrice) + } + if msg.GasFeeCap != nil { + arg["maxFeePerGas"] = (*hexutil.Big)(msg.GasFeeCap) + } + if msg.GasTipCap != nil { + arg["maxPriorityFeePerGas"] = (*hexutil.Big)(msg.GasTipCap) + } + return arg +} diff --git a/core/chains/evm/client/rpc_client.go b/core/chains/evm/client/rpc_client.go index f9745cfda11..255b038037a 100644 --- a/core/chains/evm/client/rpc_client.go +++ b/core/chains/evm/client/rpc_client.go @@ -785,10 +785,10 @@ func (r *rpcClient) CallContract(ctx context.Context, msg interface{}, blockNumb start := time.Now() var hex hexutil.Bytes if http != nil { - err = http.rpc.CallContext(ctx, &hex, "eth_call", toCallArg(message), toBlockNumArg(blockNumber)) + err = http.rpc.CallContext(ctx, &hex, "eth_call", ToBackwardCompatibleCallArg(message), ToBackwardCompatibleBlockNumArg(blockNumber)) err = r.wrapHTTP(err) } else { - err = ws.rpc.CallContext(ctx, &hex, "eth_call", toCallArg(message), toBlockNumArg(blockNumber)) + err = ws.rpc.CallContext(ctx, &hex, "eth_call", ToBackwardCompatibleCallArg(message), ToBackwardCompatibleBlockNumArg(blockNumber)) err = r.wrapWS(err) } if err == nil { @@ -816,10 +816,10 @@ func (r *rpcClient) PendingCallContract(ctx context.Context, msg interface{}) (v start := time.Now() var hex hexutil.Bytes if http != nil { - err = http.rpc.CallContext(ctx, &hex, "eth_call", toCallArg(message), "pending") + err = http.rpc.CallContext(ctx, &hex, "eth_call", ToBackwardCompatibleCallArg(message), "pending") err = r.wrapHTTP(err) } else { - err = ws.rpc.CallContext(ctx, &hex, "eth_call", toCallArg(message), "pending") + err = ws.rpc.CallContext(ctx, &hex, "eth_call", ToBackwardCompatibleCallArg(message), "pending") err = r.wrapWS(err) } if err == nil { @@ -834,51 +834,6 @@ func (r *rpcClient) PendingCallContract(ctx context.Context, msg interface{}) (v return } -// COPIED FROM go-ethereum/ethclient/gethclient - must be kept up to date! -func toBlockNumArg(number *big.Int) string { - if number == nil { - return "latest" - } - if number.Sign() >= 0 { - return hexutil.EncodeBig(number) - } - // It's negative. - if number.IsInt64() { - return rpc.BlockNumber(number.Int64()).String() - } - // It's negative and large, which is invalid. - return fmt.Sprintf("", number) -} - -// COPIED FROM go-ethereum/ethclient/gethclient - must be kept up to date! -// Modified to include legacy 'data' as well as 'input' in order to support non-compliant servers. -func toCallArg(msg ethereum.CallMsg) interface{} { - arg := map[string]interface{}{ - "from": msg.From, - "to": msg.To, - } - if len(msg.Data) > 0 { - arg["input"] = hexutil.Bytes(msg.Data) - arg["data"] = hexutil.Bytes(msg.Data) // duplicate legacy field for compatibility - } - if msg.Value != nil { - arg["value"] = (*hexutil.Big)(msg.Value) - } - if msg.Gas != 0 { - arg["gas"] = hexutil.Uint64(msg.Gas) - } - if msg.GasPrice != nil { - arg["gasPrice"] = (*hexutil.Big)(msg.GasPrice) - } - if msg.GasFeeCap != nil { - arg["maxFeePerGas"] = (*hexutil.Big)(msg.GasFeeCap) - } - if msg.GasTipCap != nil { - arg["maxPriorityFeePerGas"] = (*hexutil.Big)(msg.GasTipCap) - } - return arg -} - func (r *rpcClient) LatestBlockHeight(ctx context.Context) (*big.Int, error) { var height big.Int h, err := r.BlockNumber(ctx) diff --git a/integration-tests/actions/private_network.go b/integration-tests/actions/private_network.go index 7f8bfe8bb2c..01a084b66d8 100644 --- a/integration-tests/actions/private_network.go +++ b/integration-tests/actions/private_network.go @@ -12,7 +12,7 @@ func EthereumNetworkConfigFromConfig(l zerolog.Logger, config tc.GlobalTestConfi l.Warn().Msg("No TOML private ethereum network config found, will use old geth") ethBuilder := ctf_test_env.NewEthereumNetworkBuilder() network, err = ethBuilder. - WithConsensusType(ctf_test_env.ConsensusType_PoW). + WithEthereumVersion(ctf_test_env.EthereumVersion_Eth1). WithExecutionLayer(ctf_test_env.ExecutionLayer_Geth). Build() diff --git a/integration-tests/contracts/contract_deployer.go b/integration-tests/contracts/contract_deployer.go index e72b49bb302..c3a70d13cd1 100644 --- a/integration-tests/contracts/contract_deployer.go +++ b/integration-tests/contracts/contract_deployer.go @@ -24,6 +24,7 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/blockchain" eth_contracts "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" + "github.com/smartcontractkit/chainlink/integration-tests/wrappers" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/functions/generated/functions_load_test_client" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/functions/generated/functions_v1_events_mock" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/arbitrum_module" @@ -532,7 +533,7 @@ func (e *EthereumContractDeployer) DeployLinkTokenContract() (LinkToken, error) auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return link_token_interface.DeployLinkToken(auth, backend) + return link_token_interface.DeployLinkToken(auth, wrappers.MustNewWrappedContractBackend(e.client, nil)) }) if err != nil { return nil, err @@ -708,7 +709,7 @@ func (e *EthereumContractDeployer) DeployMockETHLINKFeed(answer *big.Int) (MockE auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return mock_ethlink_aggregator_wrapper.DeployMockETHLINKAggregator(auth, backend, answer) + return mock_ethlink_aggregator_wrapper.DeployMockETHLINKAggregator(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), answer) }) if err != nil { return nil, err @@ -760,7 +761,7 @@ func (e *EthereumContractDeployer) DeployMockGasFeed(answer *big.Int) (MockGasFe auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return mock_gas_aggregator_wrapper.DeployMockGASAggregator(auth, backend, answer) + return mock_gas_aggregator_wrapper.DeployMockGASAggregator(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), answer) }) if err != nil { return nil, err @@ -795,7 +796,7 @@ func (e *EthereumContractDeployer) DeployUpkeepTranscoder() (UpkeepTranscoder, e opts *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return upkeep_transcoder.DeployUpkeepTranscoder(opts, backend) + return upkeep_transcoder.DeployUpkeepTranscoder(opts, wrappers.MustNewWrappedContractBackend(e.client, nil)) }) if err != nil { @@ -837,7 +838,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistrar(registryVersion eth_con opts *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return keeper_registrar_wrapper2_0.DeployKeeperRegistrar(opts, backend, common.HexToAddress(linkAddr), registrarSettings.AutoApproveConfigType, + return keeper_registrar_wrapper2_0.DeployKeeperRegistrar(opts, wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(linkAddr), registrarSettings.AutoApproveConfigType, registrarSettings.AutoApproveMaxAllowed, common.HexToAddress(registrarSettings.RegistryAddr), registrarSettings.MinLinkJuels) }) @@ -866,7 +867,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistrar(registryVersion eth_con return registrar21.DeployAutomationRegistrar( opts, - backend, + wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(linkAddr), common.HexToAddress(registrarSettings.RegistryAddr), registrarSettings.MinLinkJuels, @@ -979,7 +980,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( ) (common.Address, *types.Transaction, interface{}, error) { return keeper_registry_wrapper1_1.DeployKeeperRegistry( auth, - backend, + wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(opts.LinkAddr), common.HexToAddress(opts.ETHFeedAddr), common.HexToAddress(opts.GasFeedAddr), @@ -1011,7 +1012,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( ) (common.Address, *types.Transaction, interface{}, error) { return keeper_registry_wrapper1_2.DeployKeeperRegistry( auth, - backend, + wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(opts.LinkAddr), common.HexToAddress(opts.ETHFeedAddr), common.HexToAddress(opts.GasFeedAddr), @@ -1049,7 +1050,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( ) (common.Address, *types.Transaction, interface{}, error) { return keeper_registry_logic1_3.DeployKeeperRegistryLogic( auth, - backend, + wrappers.MustNewWrappedContractBackend(e.client, nil), mode, // Default payment model registryGasOverhead, // Registry gas overhead common.HexToAddress(opts.LinkAddr), @@ -1071,7 +1072,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( ) (common.Address, *types.Transaction, interface{}, error) { return keeper_registry_wrapper1_3.DeployKeeperRegistry( auth, - backend, + wrappers.MustNewWrappedContractBackend(e.client, nil), *logicAddress, keeper_registry_wrapper1_3.Config{ PaymentPremiumPPB: opts.Settings.PaymentPremiumPPB, @@ -1107,7 +1108,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( ) (common.Address, *types.Transaction, interface{}, error) { return keeper_registry_logic2_0.DeployKeeperRegistryLogic( auth, - backend, + wrappers.MustNewWrappedContractBackend(e.client, nil), mode, // Default payment model common.HexToAddress(opts.LinkAddr), common.HexToAddress(opts.ETHFeedAddr), @@ -1129,7 +1130,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( return keeper_registry_wrapper2_0.DeployKeeperRegistry( auth, - backend, + wrappers.MustNewWrappedContractBackend(e.client, nil), *logicAddress, ) }) @@ -1156,7 +1157,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( return registrylogicb21.DeployKeeperRegistryLogicB( auth, - backend, + wrappers.MustNewWrappedContractBackend(e.client, nil), mode, common.HexToAddress(opts.LinkAddr), common.HexToAddress(opts.ETHFeedAddr), @@ -1179,7 +1180,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( return registrylogica21.DeployKeeperRegistryLogicA( auth, - backend, + wrappers.MustNewWrappedContractBackend(e.client, nil), *registryLogicBAddr, ) }) @@ -1196,7 +1197,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( ) (common.Address, *types.Transaction, interface{}, error) { return registry21.DeployKeeperRegistry( auth, - backend, + wrappers.MustNewWrappedContractBackend(e.client, nil), *registryLogicAAddr, ) }) @@ -1209,7 +1210,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( registryMaster, err := iregistry21.NewIKeeperRegistryMaster( *address, - e.client.Backend(), + wrappers.MustNewWrappedContractBackend(e.client, nil), ) if err != nil { return nil, err @@ -1230,28 +1231,28 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return scroll_module.DeployScrollModule(auth, backend) + return scroll_module.DeployScrollModule(auth, wrappers.MustNewWrappedContractBackend(e.client, nil)) }) } else if chainId == networks.ArbitrumMainnet.ChainID || chainId == networks.ArbitrumSepolia.ChainID { chainModuleAddr, _, _, err = e.client.DeployContract("ArbitrumModule", func( auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return arbitrum_module.DeployArbitrumModule(auth, backend) + return arbitrum_module.DeployArbitrumModule(auth, wrappers.MustNewWrappedContractBackend(e.client, nil)) }) } else if chainId == networks.OptimismMainnet.ChainID || chainId == networks.OptimismSepolia.ChainID { chainModuleAddr, _, _, err = e.client.DeployContract("OptimismModule", func( auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return optimism_module.DeployOptimismModule(auth, backend) + return optimism_module.DeployOptimismModule(auth, wrappers.MustNewWrappedContractBackend(e.client, nil)) }) } else { chainModuleAddr, _, _, err = e.client.DeployContract("ChainModuleBase", func( auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return chain_module_base.DeployChainModuleBase(auth, backend) + return chain_module_base.DeployChainModuleBase(auth, wrappers.MustNewWrappedContractBackend(e.client, nil)) }) } if err != nil { @@ -1279,7 +1280,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( return registrylogicb22.DeployAutomationRegistryLogicB( auth, - backend, + wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(opts.LinkAddr), common.HexToAddress(opts.ETHFeedAddr), common.HexToAddress(opts.GasFeedAddr), @@ -1302,7 +1303,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( return registrylogica22.DeployAutomationRegistryLogicA( auth, - backend, + wrappers.MustNewWrappedContractBackend(e.client, nil), *registryLogicBAddr, ) }) @@ -1319,7 +1320,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( ) (common.Address, *types.Transaction, interface{}, error) { return registry22.DeployAutomationRegistry( auth, - backend, + wrappers.MustNewWrappedContractBackend(e.client, nil), *registryLogicAAddr, ) }) @@ -1332,7 +1333,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( registryMaster, err := iregistry22.NewIAutomationRegistryMaster( *address, - e.client.Backend(), + wrappers.MustNewWrappedContractBackend(e.client, nil), ) if err != nil { return nil, err @@ -1340,7 +1341,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( chainModule, err := i_chain_module.NewIChainModule( *chainModuleAddr, - e.client.Backend(), + wrappers.MustNewWrappedContractBackend(e.client, nil), ) if err != nil { return nil, err @@ -1503,7 +1504,7 @@ func (e *EthereumContractDeployer) DeployAutomationLogTriggerConsumer(testInterv backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { return log_upkeep_counter_wrapper.DeployLogUpkeepCounter( - auth, backend, testInterval, + auth, wrappers.MustNewWrappedContractBackend(e.client, nil), testInterval, ) }) if err != nil { @@ -1541,7 +1542,7 @@ func (e *EthereumContractDeployer) DeployAutomationStreamsLookupUpkeepConsumer(t backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { return streams_lookup_upkeep_wrapper.DeployStreamsLookupUpkeep( - auth, backend, testRange, interval, useArbBlock, staging, verify, + auth, wrappers.MustNewWrappedContractBackend(e.client, nil), testRange, interval, useArbBlock, staging, verify, ) }) if err != nil { @@ -1560,7 +1561,7 @@ func (e *EthereumContractDeployer) DeployAutomationLogTriggeredStreamsLookupUpke backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { return log_triggered_streams_lookup_wrapper.DeployLogTriggeredStreamsLookup( - auth, backend, false, false, false, + auth, wrappers.MustNewWrappedContractBackend(e.client, nil), false, false, false, ) }) if err != nil { @@ -1578,7 +1579,7 @@ func (e *EthereumContractDeployer) DeployUpkeepCounter(testRange *big.Int, inter auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return upkeep_counter_wrapper.DeployUpkeepCounter(auth, backend, testRange, interval) + return upkeep_counter_wrapper.DeployUpkeepCounter(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), testRange, interval) }) if err != nil { return nil, err diff --git a/integration-tests/contracts/contract_loader.go b/integration-tests/contracts/contract_loader.go index a2a4fb60be5..9c26a671194 100644 --- a/integration-tests/contracts/contract_loader.go +++ b/integration-tests/contracts/contract_loader.go @@ -3,6 +3,7 @@ package contracts import ( "errors" + "github.com/smartcontractkit/chainlink/integration-tests/wrappers" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2_5" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2plus_load_test_with_metrics" @@ -409,7 +410,7 @@ func (e *EthereumContractLoader) LoadVRFCoordinatorV2(addr string) (VRFCoordinat address common.Address, backend bind.ContractBackend, ) (interface{}, error) { - return vrf_coordinator_v2.NewVRFCoordinatorV2(address, backend) + return vrf_coordinator_v2.NewVRFCoordinatorV2(address, wrappers.MustNewWrappedContractBackend(e.client, nil)) }) if err != nil { return nil, err diff --git a/integration-tests/contracts/ethereum_contracts_seth.go b/integration-tests/contracts/ethereum_contracts_seth.go index 237d6896234..a2703a0e019 100644 --- a/integration-tests/contracts/ethereum_contracts_seth.go +++ b/integration-tests/contracts/ethereum_contracts_seth.go @@ -18,6 +18,7 @@ import ( ocrConfigHelper "github.com/smartcontractkit/libocr/offchainreporting/confighelper" ocrTypes "github.com/smartcontractkit/libocr/offchainreporting/types" + "github.com/smartcontractkit/chainlink/integration-tests/wrappers" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/authorized_forwarder" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/operator_factory" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/operator_wrapper" @@ -80,7 +81,7 @@ func DeployOffchainAggregator(l zerolog.Logger, seth *seth.Client, linkTokenAddr return EthereumOffchainAggregator{}, fmt.Errorf("OCR instance deployment have failed: %w", err) } - ocr, err := offchainaggregator.NewOffchainAggregator(ocrDeploymentData.Address, seth.Client) + ocr, err := offchainaggregator.NewOffchainAggregator(ocrDeploymentData.Address, wrappers.MustNewWrappedContractBackend(nil, seth)) if err != nil { return EthereumOffchainAggregator{}, fmt.Errorf("failed to instantiate OCR instance: %w", err) } @@ -458,7 +459,7 @@ func DeployOffchainAggregatorV2(l zerolog.Logger, seth *seth.Client, linkTokenAd return EthereumOffchainAggregatorV2{}, fmt.Errorf("OCR instance deployment have failed: %w", err) } - ocr2, err := ocr2aggregator.NewOCR2Aggregator(ocrDeploymentData2.Address, seth.Client) + ocr2, err := ocr2aggregator.NewOCR2Aggregator(ocrDeploymentData2.Address, wrappers.MustNewWrappedContractBackend(nil, seth)) if err != nil { return EthereumOffchainAggregatorV2{}, fmt.Errorf("failed to instantiate OCR instance: %w", err) } diff --git a/integration-tests/contracts/ethereum_vrf_contracts.go b/integration-tests/contracts/ethereum_vrf_contracts.go index ea8a4f94817..a67d30bd201 100644 --- a/integration-tests/contracts/ethereum_vrf_contracts.go +++ b/integration-tests/contracts/ethereum_vrf_contracts.go @@ -13,6 +13,7 @@ import ( "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" + "github.com/smartcontractkit/chainlink/integration-tests/wrappers" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/batch_blockhash_store" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/blockhash_store" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/solidity_vrf_consumer_interface" @@ -64,7 +65,7 @@ func (e *EthereumContractDeployer) DeployVRFContract() (VRF, error) { auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return solidity_vrf_wrapper.DeployVRF(auth, backend) + return solidity_vrf_wrapper.DeployVRF(auth, wrappers.MustNewWrappedContractBackend(e.client, nil)) }) if err != nil { return nil, err @@ -82,7 +83,7 @@ func (e *EthereumContractDeployer) DeployBlockhashStore() (BlockHashStore, error auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return blockhash_store.DeployBlockhashStore(auth, backend) + return blockhash_store.DeployBlockhashStore(auth, wrappers.MustNewWrappedContractBackend(e.client, nil)) }) if err != nil { return nil, err @@ -100,7 +101,7 @@ func (e *EthereumContractDeployer) DeployVRFCoordinator(linkAddr string, bhsAddr auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return solidity_vrf_coordinator_interface.DeployVRFCoordinator(auth, backend, common.HexToAddress(linkAddr), common.HexToAddress(bhsAddr)) + return solidity_vrf_coordinator_interface.DeployVRFCoordinator(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(linkAddr), common.HexToAddress(bhsAddr)) }) if err != nil { return nil, err @@ -118,7 +119,7 @@ func (e *EthereumContractDeployer) DeployVRFConsumer(linkAddr string, coordinato auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return solidity_vrf_consumer_interface.DeployVRFConsumer(auth, backend, common.HexToAddress(coordinatorAddr), common.HexToAddress(linkAddr)) + return solidity_vrf_consumer_interface.DeployVRFConsumer(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(coordinatorAddr), common.HexToAddress(linkAddr)) }) if err != nil { return nil, err diff --git a/integration-tests/contracts/ethereum_vrfv2_contracts.go b/integration-tests/contracts/ethereum_vrfv2_contracts.go index fc7a5a7a138..5ff12e81d57 100644 --- a/integration-tests/contracts/ethereum_vrfv2_contracts.go +++ b/integration-tests/contracts/ethereum_vrfv2_contracts.go @@ -14,6 +14,7 @@ import ( "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" + "github.com/smartcontractkit/chainlink/integration-tests/wrappers" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_test_v2" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_mock_ethlink_aggregator" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_owner" @@ -97,7 +98,7 @@ func (e *EthereumContractDeployer) DeployVRFCoordinatorV2(linkAddr string, bhsAd auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return vrf_coordinator_v2.DeployVRFCoordinatorV2(auth, backend, common.HexToAddress(linkAddr), common.HexToAddress(bhsAddr), common.HexToAddress(linkEthFeedAddr)) + return vrf_coordinator_v2.DeployVRFCoordinatorV2(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(linkAddr), common.HexToAddress(bhsAddr), common.HexToAddress(linkEthFeedAddr)) }) if err != nil { return nil, err @@ -114,7 +115,7 @@ func (e *EthereumContractDeployer) DeployVRFOwner(coordinatorAddr string) (VRFOw auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return vrf_owner.DeployVRFOwner(auth, backend, common.HexToAddress(coordinatorAddr)) + return vrf_owner.DeployVRFOwner(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(coordinatorAddr)) }) if err != nil { return nil, err @@ -131,7 +132,7 @@ func (e *EthereumContractDeployer) DeployVRFCoordinatorTestV2(linkAddr string, b auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return vrf_coordinator_test_v2.DeployVRFCoordinatorTestV2(auth, backend, common.HexToAddress(linkAddr), common.HexToAddress(bhsAddr), common.HexToAddress(linkEthFeedAddr)) + return vrf_coordinator_test_v2.DeployVRFCoordinatorTestV2(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(linkAddr), common.HexToAddress(bhsAddr), common.HexToAddress(linkEthFeedAddr)) }) if err != nil { return nil, err @@ -184,7 +185,7 @@ func (e *EthereumContractDeployer) DeployVRFv2LoadTestConsumer(coordinatorAddr s auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return vrf_load_test_with_metrics.DeployVRFV2LoadTestWithMetrics(auth, backend, common.HexToAddress(coordinatorAddr)) + return vrf_load_test_with_metrics.DeployVRFV2LoadTestWithMetrics(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(coordinatorAddr)) }) if err != nil { return nil, err @@ -201,7 +202,7 @@ func (e *EthereumContractDeployer) DeployVRFV2Wrapper(linkAddr string, linkEthFe auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return vrfv2_wrapper.DeployVRFV2Wrapper(auth, backend, common.HexToAddress(linkAddr), common.HexToAddress(linkEthFeedAddr), common.HexToAddress(coordinatorAddr)) + return vrfv2_wrapper.DeployVRFV2Wrapper(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(linkAddr), common.HexToAddress(linkEthFeedAddr), common.HexToAddress(coordinatorAddr)) }) if err != nil { return nil, err @@ -218,7 +219,7 @@ func (e *EthereumContractDeployer) DeployVRFV2WrapperLoadTestConsumer(linkAddr s auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return vrfv2_wrapper_load_test_consumer.DeployVRFV2WrapperLoadTestConsumer(auth, backend, common.HexToAddress(linkAddr), common.HexToAddress(vrfV2WrapperAddr)) + return vrfv2_wrapper_load_test_consumer.DeployVRFV2WrapperLoadTestConsumer(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(linkAddr), common.HexToAddress(vrfV2WrapperAddr)) }) if err != nil { return nil, err diff --git a/integration-tests/contracts/ethereum_vrfv2plus_contracts.go b/integration-tests/contracts/ethereum_vrfv2plus_contracts.go index 64afb4c466d..d3492b30bf4 100644 --- a/integration-tests/contracts/ethereum_vrfv2plus_contracts.go +++ b/integration-tests/contracts/ethereum_vrfv2plus_contracts.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" + "github.com/smartcontractkit/chainlink/integration-tests/wrappers" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2_5" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2plus_load_test_with_metrics" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2plus_upgraded_version" @@ -119,7 +120,7 @@ func (e *EthereumContractDeployer) DeployVRFCoordinatorV2_5(bhsAddr string) (VRF auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return vrf_coordinator_v2_5.DeployVRFCoordinatorV25(auth, backend, common.HexToAddress(bhsAddr)) + return vrf_coordinator_v2_5.DeployVRFCoordinatorV25(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(bhsAddr)) }) if err != nil { return nil, err @@ -935,7 +936,7 @@ func (e *EthereumContractDeployer) DeployVRFv2PlusLoadTestConsumer(coordinatorAd auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return vrf_v2plus_load_test_with_metrics.DeployVRFV2PlusLoadTestWithMetrics(auth, backend, common.HexToAddress(coordinatorAddr)) + return vrf_v2plus_load_test_with_metrics.DeployVRFV2PlusLoadTestWithMetrics(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(coordinatorAddr)) }) if err != nil { return nil, err @@ -952,7 +953,7 @@ func (e *EthereumContractDeployer) DeployVRFV2PlusWrapper(linkAddr string, linkE auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return vrfv2plus_wrapper.DeployVRFV2PlusWrapper(auth, backend, common.HexToAddress(linkAddr), common.HexToAddress(linkEthFeedAddr), common.HexToAddress(coordinatorAddr)) + return vrfv2plus_wrapper.DeployVRFV2PlusWrapper(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(linkAddr), common.HexToAddress(linkEthFeedAddr), common.HexToAddress(coordinatorAddr)) }) if err != nil { return nil, err @@ -969,7 +970,7 @@ func (e *EthereumContractDeployer) DeployVRFV2PlusWrapperLoadTestConsumer(linkAd auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return vrfv2plus_wrapper_load_test_consumer.DeployVRFV2PlusWrapperLoadTestConsumer(auth, backend, common.HexToAddress(linkAddr), common.HexToAddress(vrfV2PlusWrapperAddr)) + return vrfv2plus_wrapper_load_test_consumer.DeployVRFV2PlusWrapperLoadTestConsumer(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), common.HexToAddress(linkAddr), common.HexToAddress(vrfV2PlusWrapperAddr)) }) if err != nil { return nil, err diff --git a/integration-tests/docker/test_env/cl_node.go b/integration-tests/docker/test_env/cl_node.go index a575768d62f..eae3f894db3 100644 --- a/integration-tests/docker/test_env/cl_node.go +++ b/integration-tests/docker/test_env/cl_node.go @@ -43,6 +43,11 @@ var ( ErrStartCLNodeContainer = "failed to start CL node container" ) +const ( + RestartContainer = true + StartNewContainer = false +) + type ClNode struct { test_env.EnvComponent API *client.ChainlinkClient `json:"-"` @@ -158,7 +163,7 @@ func (n *ClNode) Restart(cfg *chainlink.Config) error { return err } n.NodeConfig = cfg - return n.StartContainer() + return n.RestartContainer() } // UpgradeVersion restarts the cl node with new image and version @@ -285,8 +290,13 @@ func (n *ClNode) Fund(evmClient blockchain.EVMClient, amount *big.Float) error { return evmClient.Fund(toAddress, amount, gasEstimates) } -func (n *ClNode) StartContainer() error { - err := n.PostgresDb.StartContainer() +func (n *ClNode) containerStartOrRestart(restartDb bool) error { + var err error + if restartDb { + err = n.PostgresDb.RestartContainer() + } else { + err = n.PostgresDb.StartContainer() + } if err != nil { return err } @@ -359,6 +369,14 @@ func (n *ClNode) StartContainer() error { return nil } +func (n *ClNode) RestartContainer() error { + return n.containerStartOrRestart(RestartContainer) +} + +func (n *ClNode) StartContainer() error { + return n.containerStartOrRestart(StartNewContainer) +} + func (n *ClNode) ExecGetVersion() (string, error) { cmd := []string{"chainlink", "--version"} _, output, err := n.Container.Exec(context.Background(), cmd) diff --git a/integration-tests/docker/test_env/test_env.go b/integration-tests/docker/test_env/test_env.go index e91a3bba6ad..06417a9268e 100644 --- a/integration-tests/docker/test_env/test_env.go +++ b/integration-tests/docker/test_env/test_env.go @@ -142,6 +142,13 @@ func (te *CLClusterTestEnv) StartEthereumNetwork(cfg *test_env.EthereumNetwork) } cfg = &c } + + te.l.Info(). + Str("Execution Layer", string(*cfg.ExecutionLayer)). + Str("Ethereum Version", string(*cfg.EthereumVersion)). + Str("Custom Docker Images", fmt.Sprintf("%v", cfg.CustomDockerImages)). + Msg("Starting Ethereum network") + n, rpc, err := cfg.Start() if err != nil { diff --git a/integration-tests/docker/test_env/test_env_builder.go b/integration-tests/docker/test_env/test_env_builder.go index 7c50bd1c725..fc2c12da933 100644 --- a/integration-tests/docker/test_env/test_env_builder.go +++ b/integration-tests/docker/test_env/test_env_builder.go @@ -147,7 +147,7 @@ func (b *CLTestEnvBuilder) WithFunding(eth *big.Float) *CLTestEnvBuilder { func (b *CLTestEnvBuilder) WithGeth() *CLTestEnvBuilder { ethBuilder := test_env.NewEthereumNetworkBuilder() cfg, err := ethBuilder. - WithConsensusType(test_env.ConsensusType_PoW). + WithEthereumVersion(test_env.EthereumVersion_Eth1). WithExecutionLayer(test_env.ExecutionLayer_Geth). WithTest(b.t). Build() diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 70b95162e79..098434c09f9 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -24,7 +24,7 @@ require ( github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240311111125-22812a072c35 github.com/smartcontractkit/chainlink-common v0.1.7-0.20240314172156-049609b8e1f9 - github.com/smartcontractkit/chainlink-testing-framework v1.26.0 + github.com/smartcontractkit/chainlink-testing-framework v1.27.0 github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/libocr v0.0.0-20240229181116-bfb2432a7a66 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 9275fabd5a8..47d7ec120cd 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1529,8 +1529,8 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240216142700-c5869534c19 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240216142700-c5869534c19e/go.mod h1:JiykN+8W5TA4UD2ClrzQCVvcH3NcyLEVv7RwY0busrw= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240213121419-1272736c2ac0 h1:7m9PVtccb8/pvKTXMaGuyceFno1icRyC2SFH7KG7+70= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240213121419-1272736c2ac0/go.mod h1:SZ899lZYQ0maUulWbZg+SWqabHQ1wTbyk3jT8wJfyo8= -github.com/smartcontractkit/chainlink-testing-framework v1.26.0 h1:YlEWIqnHzFV5syEaWiL/COjpsjqvCKPZP6Xi0m+Kvhw= -github.com/smartcontractkit/chainlink-testing-framework v1.26.0/go.mod h1:gkmsafC85u6hIqWbxKjynKf4NuFuFJDRcgxIEFsSq6E= +github.com/smartcontractkit/chainlink-testing-framework v1.27.0 h1:fs60anZu4VMPv0E9TtGo9uQ4kJcqChClxgjC9ArvqN4= +github.com/smartcontractkit/chainlink-testing-framework v1.27.0/go.mod h1:jN+HgXbriq6fKRlIqLw9F3I81aYImV6kBJkIfz0mdIA= github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 h1:FFdvEzlYwcuVHkdZ8YnZR/XomeMGbz5E2F2HZI3I3w8= github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868/go.mod h1:Kn1Hape05UzFZ7bOUnm3GVsHzP0TNrVmpfXYNHdqGGs= github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16 h1:TFe+FvzxClblt6qRfqEhUfa4kFQx5UobuoFGO2W4mMo= diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index 3dca77447b0..3b90ec5bb15 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -16,7 +16,7 @@ require ( github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240311111125-22812a072c35 github.com/smartcontractkit/chainlink-common v0.1.7-0.20240314172156-049609b8e1f9 - github.com/smartcontractkit/chainlink-testing-framework v1.26.0 + github.com/smartcontractkit/chainlink-testing-framework v1.27.0 github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240214231432-4ad5eb95178c github.com/smartcontractkit/chainlink/v2 v2.9.0-beta0.0.20240216210048-da02459ddad8 github.com/smartcontractkit/libocr v0.0.0-20240229181116-bfb2432a7a66 diff --git a/integration-tests/load/go.sum b/integration-tests/load/go.sum index 21845553680..6ef7a2bb3ec 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -1512,8 +1512,8 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240216142700-c5869534c19 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240216142700-c5869534c19e/go.mod h1:JiykN+8W5TA4UD2ClrzQCVvcH3NcyLEVv7RwY0busrw= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240213121419-1272736c2ac0 h1:7m9PVtccb8/pvKTXMaGuyceFno1icRyC2SFH7KG7+70= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240213121419-1272736c2ac0/go.mod h1:SZ899lZYQ0maUulWbZg+SWqabHQ1wTbyk3jT8wJfyo8= -github.com/smartcontractkit/chainlink-testing-framework v1.26.0 h1:YlEWIqnHzFV5syEaWiL/COjpsjqvCKPZP6Xi0m+Kvhw= -github.com/smartcontractkit/chainlink-testing-framework v1.26.0/go.mod h1:gkmsafC85u6hIqWbxKjynKf4NuFuFJDRcgxIEFsSq6E= +github.com/smartcontractkit/chainlink-testing-framework v1.27.0 h1:fs60anZu4VMPv0E9TtGo9uQ4kJcqChClxgjC9ArvqN4= +github.com/smartcontractkit/chainlink-testing-framework v1.27.0/go.mod h1:jN+HgXbriq6fKRlIqLw9F3I81aYImV6kBJkIfz0mdIA= github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240227164431-18a7065e23ea h1:ZdLmNAfKRjH8AYUvjiiDGUgiWQfq/7iNpxyTkvjx/ko= github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240227164431-18a7065e23ea/go.mod h1:gCKC9w6XpNk6jm+XIk2psrkkfxhi421N9NSiFceXW88= github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 h1:FFdvEzlYwcuVHkdZ8YnZR/XomeMGbz5E2F2HZI3I3w8= diff --git a/integration-tests/scripts/buildEvmClientTestMatrixList.sh b/integration-tests/scripts/buildEvmClientTestMatrixList.sh new file mode 100755 index 00000000000..2f0e27b7fb8 --- /dev/null +++ b/integration-tests/scripts/buildEvmClientTestMatrixList.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# requires a path to a json file with all the tests it should run +# requires a node label to be passed in, for example "ubuntu-latest" + +set -e + +# get this script's directory +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) + +cd "$SCRIPT_DIR"/../ || exit 1 + +JSONFILE=$1 +NODE_LABEL=$2 + +COUNTER=1 + +# Build a JSON object in the format expected by our evm-version-compatibility-tests workflow matrix +matrix_output() { + local counter=$1 + local job_name=$2 + local test_name=$3 + local node_label=$4 + local eth_client=$5 + local docker_image=$6 + local product=$7 + local counter_out=$(printf "%02d\n" $counter) + echo -n "{\"name\": \"${job_name}-${counter_out}\", \"os\": \"${node_label}\", \"product\": \"${product}\", \"eth_client\": \"${eth_client}\", \"docker_image\": \"${docker_image}\", \"run\": \"-run '^${test_name}$'\"}" +} + +# Read the JSON file and loop through 'tests' and 'run' +jq -c '.tests[]' ${JSONFILE} | while read -r test; do + testName=$(echo ${test} | jq -r '.name') + label=$(echo ${test} | jq -r '.label // empty') + effective_node_label=${label:-$NODE_LABEL} + eth_client=$(echo ${test} | jq -r '.eth_client') + docker_image=$(echo ${test} | jq -r '.docker_image') + product=$(echo ${test} | jq -r '.product') + subTests=$(echo ${test} | jq -r '.run[]?.name // empty') + output="" + + if [ $COUNTER -ne 1 ]; then + echo -n "," + fi + + # Loop through subtests, if any, and print in the desired format + if [ -n "$subTests" ]; then + subTestString="" + subTestCounter=1 + for subTest in $subTests; do + if [ $subTestCounter -ne 1 ]; then + subTestString+="|" + fi + subTestString+="${testName}\/${subTest}" + ((subTestCounter++)) + done + testName="${subTestString}" + fi + matrix_output $COUNTER "emv-node-version-compatibility-test" "${testName}" ${effective_node_label} "${eth_client}" "${docker_image}" "${product}" + ((COUNTER++)) +done > "./tmpout.json" +OUTPUT=$(cat ./tmpout.json) +echo "[${OUTPUT}]" +rm ./tmpout.json \ No newline at end of file diff --git a/integration-tests/smoke/automation_test.go b/integration-tests/smoke/automation_test.go index 8cdd4f25686..14e6ca9ab2c 100644 --- a/integration-tests/smoke/automation_test.go +++ b/integration-tests/smoke/automation_test.go @@ -1151,11 +1151,15 @@ func setupAutomationTestDocker( require.NoError(t, err) l.Debug().Msgf("Funding amount: %f", *automationTestConfig.GetCommonConfig().ChainlinkNodeFunding) clNodesCount := 5 + + privateNetwork, err := actions.EthereumNetworkConfigFromConfig(l, automationTestConfig) + require.NoError(t, err, "Error building ethereum network config") + if isMercuryV02 || isMercuryV03 { env, err = test_env.NewCLTestEnvBuilder(). WithTestInstance(t). WithTestConfig(automationTestConfig). - WithGeth(). + WithPrivateEthereumNetwork(privateNetwork). WithMockAdapter(). WithFunding(big.NewFloat(*automationTestConfig.GetCommonConfig().ChainlinkNodeFunding)). WithStandardCleanup(). @@ -1192,7 +1196,7 @@ func setupAutomationTestDocker( env, err = test_env.NewCLTestEnvBuilder(). WithTestInstance(t). WithTestConfig(automationTestConfig). - WithGeth(). + WithPrivateEthereumNetwork(privateNetwork). WithMockAdapter(). WithCLNodes(clNodesCount). WithCLNodeConfig(clNodeConfig). diff --git a/integration-tests/smoke/cron_test.go b/integration-tests/smoke/cron_test.go index b6e04612aca..15934f48922 100644 --- a/integration-tests/smoke/cron_test.go +++ b/integration-tests/smoke/cron_test.go @@ -11,6 +11,7 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/logging" + "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" tc "github.com/smartcontractkit/chainlink/integration-tests/testconfig" @@ -25,10 +26,13 @@ func TestCronBasic(t *testing.T) { t.Fatal(err) } + privateNetwork, err := actions.EthereumNetworkConfigFromConfig(l, &config) + require.NoError(t, err, "Error building ethereum network config") + env, err := test_env.NewCLTestEnvBuilder(). WithTestInstance(t). WithTestConfig(&config). - WithGeth(). + WithPrivateEthereumNetwork(privateNetwork). WithMockAdapter(). WithCLNodes(1). WithStandardCleanup(). @@ -77,10 +81,13 @@ func TestCronJobReplacement(t *testing.T) { t.Fatal(err) } + privateNetwork, err := actions.EthereumNetworkConfigFromConfig(l, &config) + require.NoError(t, err, "Error building ethereum network config") + env, err := test_env.NewCLTestEnvBuilder(). WithTestInstance(t). WithTestConfig(&config). - WithGeth(). + WithPrivateEthereumNetwork(privateNetwork). WithMockAdapter(). WithCLNodes(1). WithStandardCleanup(). diff --git a/integration-tests/smoke/evm_node_compatibility_test_list.json b/integration-tests/smoke/evm_node_compatibility_test_list.json new file mode 100644 index 00000000000..c14a2b54a3e --- /dev/null +++ b/integration-tests/smoke/evm_node_compatibility_test_list.json @@ -0,0 +1,214 @@ +{ + "tests": [ + { + "product": "ocr", + "name": "TestOCRBasic", + "eth_client": "geth", + "docker_image": "ethereum/client-go:latest_stable", + "label": "ubuntu-latest" + }, + { + "product": "ocr", + "name": "TestOCRBasic", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.13.0", + "label": "ubuntu-latest" + }, + { + "product": "ocr", + "name": "TestOCRBasic", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.12.0", + "label": "ubuntu-latest" + }, + { + "product": "ocr", + "name": "TestOCRBasic", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.11.0", + "label": "ubuntu-latest" + }, + { + "product": "ocr", + "name": "TestOCRBasic", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.10.0", + "label": "ubuntu-latest" + }, + { + "product": "ocr2", + "name": "TestOCRv2Request", + "eth_client": "geth", + "docker_image": "ethereum/client-go:latest_stable", + "label": "ubuntu-latest" + }, + { + "product": "ocr2", + "name": "TestOCRv2Request", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.13.0", + "label": "ubuntu-latest" + }, + { + "product": "ocr2", + "name": "TestOCRv2Request", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.12.0", + "label": "ubuntu-latest" + }, + { + "product": "ocr2", + "name": "TestOCRv2Request", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.11.0", + "label": "ubuntu-latest" + }, + { + "product": "ocr2", + "name": "TestOCRv2Request", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.10.0", + "label": "ubuntu-latest" + }, + { + "product": "vrf", + "name": "TestVRFBasic", + "eth_client": "geth", + "docker_image": "ethereum/client-go:latest_stable", + "label": "ubuntu-latest" + }, + { + "product": "vrf", + "name": "TestVRFBasic", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.13.0", + "label": "ubuntu-latest" + }, + { + "product": "vrf", + "name": "TestVRFBasic", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.12.0", + "label": "ubuntu-latest" + }, + { + "product": "vrf", + "name": "TestVRFBasic", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.11.0", + "label": "ubuntu-latest" + }, + { + "product": "vrf", + "name": "TestVRFBasic", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.10.0", + "label": "ubuntu-latest" + }, + { + "product": "vrfv2", + "name": "TestVRFv2Basic/Request Randomness", + "eth_client": "geth", + "docker_image": "ethereum/client-go:latest_stable", + "label": "ubuntu-latest" + }, + { + "product": "vrfv2", + "name": "TestVRFv2Basic/Request Randomness", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.13.0", + "label": "ubuntu-latest" + }, + { + "product": "vrfv2", + "name": "TestVRFv2Basic/Request Randomness", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.12.0", + "label": "ubuntu-latest" + }, + { + "product": "vrfv2", + "name": "TestVRFv2Basic/Request Randomness", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.11.0", + "label": "ubuntu-latest" + }, + { + "product": "vrfv2", + "name": "TestVRFv2Basic/Request Randomness", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.10.0", + "label": "ubuntu-latest" + }, + { + "product": "vrfv2plus", + "name": "TestVRFv2Plus/Link Billing", + "eth_client": "geth", + "docker_image": "ethereum/client-go:latest_stable", + "label": "ubuntu-latest" + }, + { + "product": "vrfv2plus", + "name": "TestVRFv2Plus/Link Billing", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.13.0", + "label": "ubuntu-latest" + }, + { + "product": "vrfv2plus", + "name": "TestVRFv2Plus/Link Billing", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.12.0", + "label": "ubuntu-latest" + }, + { + "product": "vrfv2plus", + "name": "TestVRFv2Plus/Link Billing", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.11.0", + "label": "ubuntu-latest" + }, + { + "product": "vrfv2plus", + "name": "TestVRFv2Plus/Link Billing", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.10.0", + "label": "ubuntu-latest" + }, + { + "product": "automation", + "name": "TestSetUpkeepTriggerConfig", + "eth_client": "geth", + "docker_image": "ethereum/client-go:latest_stable", + "label": "ubuntu-latest" + }, + { + "product": "automation", + "name": "TestSetUpkeepTriggerConfig", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.13.0", + "label": "ubuntu-latest" + }, + { + "product": "automation", + "name": "TestSetUpkeepTriggerConfig", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.12.0", + "label": "ubuntu-latest" + }, + { + "product": "automation", + "name": "TestSetUpkeepTriggerConfig", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.11.0", + "label": "ubuntu-latest" + }, + { + "product": "automation", + "name": "TestSetUpkeepTriggerConfig", + "eth_client": "geth", + "docker_image": "ethereum/client-go:v1.10.0", + "label": "ubuntu-latest" + } + ] +} \ No newline at end of file diff --git a/integration-tests/smoke/flux_test.go b/integration-tests/smoke/flux_test.go index c8cec4e385b..f7a0c94d0c9 100644 --- a/integration-tests/smoke/flux_test.go +++ b/integration-tests/smoke/flux_test.go @@ -31,10 +31,13 @@ func TestFluxBasic(t *testing.T) { t.Fatal(err) } + privateNetwork, err := actions.EthereumNetworkConfigFromConfig(l, &config) + require.NoError(t, err, "Error building ethereum network config") + env, err := test_env.NewCLTestEnvBuilder(). WithTestInstance(t). WithTestConfig(&config). - WithGeth(). + WithPrivateEthereumNetwork(privateNetwork). WithMockAdapter(). WithCLNodes(3). WithStandardCleanup(). diff --git a/integration-tests/smoke/forwarder_ocr_test.go b/integration-tests/smoke/forwarder_ocr_test.go index 60fe1db3c25..e3709bc8772 100644 --- a/integration-tests/smoke/forwarder_ocr_test.go +++ b/integration-tests/smoke/forwarder_ocr_test.go @@ -24,10 +24,13 @@ func TestForwarderOCRBasic(t *testing.T) { t.Fatal(err) } + privateNetwork, err := actions.EthereumNetworkConfigFromConfig(l, &config) + require.NoError(t, err, "Error building ethereum network config") + env, err := test_env.NewCLTestEnvBuilder(). WithTestInstance(t). WithTestConfig(&config). - WithGeth(). + WithPrivateEthereumNetwork(privateNetwork). WithMockAdapter(). WithForwarders(). WithCLNodes(6). diff --git a/integration-tests/smoke/forwarders_ocr2_test.go b/integration-tests/smoke/forwarders_ocr2_test.go index 7c5b988276b..27b2a4fde94 100644 --- a/integration-tests/smoke/forwarders_ocr2_test.go +++ b/integration-tests/smoke/forwarders_ocr2_test.go @@ -30,9 +30,13 @@ func TestForwarderOCR2Basic(t *testing.T) { t.Fatal(err) } + privateNetwork, err := actions.EthereumNetworkConfigFromConfig(l, &config) + require.NoError(t, err, "Error building ethereum network config") + env, err := test_env.NewCLTestEnvBuilder(). WithTestInstance(t). WithTestConfig(&config). + WithPrivateEthereumNetwork(privateNetwork). WithGeth(). WithMockAdapter(). WithCLNodeConfig(node.NewConfig(node.NewBaseConfig(), diff --git a/integration-tests/smoke/keeper_test.go b/integration-tests/smoke/keeper_test.go index 0ebbc1e083d..18f03dd3514 100644 --- a/integration-tests/smoke/keeper_test.go +++ b/integration-tests/smoke/keeper_test.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/onsi/gomega" + "github.com/rs/zerolog" "github.com/stretchr/testify/require" commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" @@ -93,7 +94,7 @@ func TestKeeperBasicSmoke(t *testing.T) { t.Fatal(err) } - chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t, &config) + chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(l, t, &config) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, registryVersion, @@ -174,7 +175,7 @@ func TestKeeperBlockCountPerTurn(t *testing.T) { t.Fatal(err) } - chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t, &config) + chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(l, t, &config) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, registryVersion, @@ -283,7 +284,7 @@ func TestKeeperSimulation(t *testing.T) { t.Fatal(err) } - chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t, &config) + chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(l, t, &config) registry, _, consumersPerformance, upkeepIDs := actions.DeployPerformanceKeeperContracts( t, registryVersion, @@ -360,7 +361,7 @@ func TestKeeperCheckPerformGasLimit(t *testing.T) { if err != nil { t.Fatal(err) } - chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t, &config) + chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(l, t, &config) registry, _, consumersPerformance, upkeepIDs := actions.DeployPerformanceKeeperContracts( t, registryVersion, @@ -477,7 +478,7 @@ func TestKeeperRegisterUpkeep(t *testing.T) { if err != nil { t.Fatal(err) } - chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t, &config) + chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(l, t, &config) registry, registrar, consumers, upkeepIDs := actions.DeployKeeperContracts( t, registryVersion, @@ -570,7 +571,7 @@ func TestKeeperAddFunds(t *testing.T) { if err != nil { t.Fatal(err) } - chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t, &config) + chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(l, t, &config) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, registryVersion, @@ -637,7 +638,7 @@ func TestKeeperRemove(t *testing.T) { if err != nil { t.Fatal(err) } - chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t, &config) + chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(l, t, &config) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, registryVersion, @@ -719,7 +720,7 @@ func TestKeeperPauseRegistry(t *testing.T) { if err != nil { t.Fatal(err) } - chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t, &config) + chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(l, t, &config) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, registryVersion, @@ -784,7 +785,7 @@ func TestKeeperMigrateRegistry(t *testing.T) { if err != nil { t.Fatal(err) } - chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t, &config) + chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(l, t, &config) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, ethereum.RegistryVersion_1_2, @@ -880,7 +881,7 @@ func TestKeeperNodeDown(t *testing.T) { if err != nil { t.Fatal(err) } - chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t, &config) + chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(l, t, &config) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, registryVersion, @@ -990,7 +991,7 @@ func TestKeeperPauseUnPauseUpkeep(t *testing.T) { if err != nil { t.Fatal(err) } - chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t, &config) + chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(l, t, &config) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, ethereum.RegistryVersion_1_3, @@ -1084,7 +1085,7 @@ func TestKeeperUpdateCheckData(t *testing.T) { if err != nil { t.Fatal(err) } - chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t, &config) + chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(l, t, &config) registry, _, performDataChecker, upkeepIDs := actions.DeployPerformDataCheckerContracts( t, ethereum.RegistryVersion_1_3, @@ -1143,7 +1144,7 @@ func TestKeeperUpdateCheckData(t *testing.T) { }, "3m", "1s").Should(gomega.Succeed()) } -func setupKeeperTest(t *testing.T, config *tc.TestConfig) ( +func setupKeeperTest(l zerolog.Logger, t *testing.T, config *tc.TestConfig) ( blockchain.EVMClient, []*client.ChainlinkClient, contracts.ContractDeployer, @@ -1158,10 +1159,13 @@ func setupKeeperTest(t *testing.T, config *tc.TestConfig) ( clNodeConfig.Keeper.Registry.SyncInterval = &syncInterval clNodeConfig.Keeper.Registry.PerformGasOverhead = &performGasOverhead + privateNetwork, err := actions.EthereumNetworkConfigFromConfig(l, config) + require.NoError(t, err, "Error building ethereum network config") + env, err := test_env.NewCLTestEnvBuilder(). WithTestInstance(t). WithTestConfig(config). - WithGeth(). + WithPrivateEthereumNetwork(privateNetwork). WithCLNodes(5). WithCLNodeConfig(clNodeConfig). WithFunding(big.NewFloat(.5)). @@ -1189,7 +1193,7 @@ func TestKeeperJobReplacement(t *testing.T) { t.Fatal(err) } - chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t, &config) + chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(l, t, &config) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, registryVersion, diff --git a/integration-tests/smoke/ocr2_test.go b/integration-tests/smoke/ocr2_test.go index 33538c1eaa4..b70796c4ab8 100644 --- a/integration-tests/smoke/ocr2_test.go +++ b/integration-tests/smoke/ocr2_test.go @@ -129,10 +129,13 @@ func prepareORCv2SmokeTestEnv(t *testing.T, l zerolog.Logger, firstRoundResult i t.Fatal(err) } + privateNetwork, err := actions.EthereumNetworkConfigFromConfig(l, &config) + require.NoError(t, err, "Error building ethereum network config") + env, err := test_env.NewCLTestEnvBuilder(). WithTestInstance(t). WithTestConfig(&config). - WithGeth(). + WithPrivateEthereumNetwork(privateNetwork). WithMockAdapter(). WithCLNodeConfig(node.NewConfig(node.NewBaseConfig(), node.WithOCR2(), diff --git a/integration-tests/smoke/runlog_test.go b/integration-tests/smoke/runlog_test.go index f7f5c54069e..eb687e439b2 100644 --- a/integration-tests/smoke/runlog_test.go +++ b/integration-tests/smoke/runlog_test.go @@ -14,6 +14,7 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/utils/testcontext" + "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" @@ -29,10 +30,13 @@ func TestRunLogBasic(t *testing.T) { t.Fatal(err) } + privateNetwork, err := actions.EthereumNetworkConfigFromConfig(l, &config) + require.NoError(t, err, "Error building ethereum network config") + env, err := test_env.NewCLTestEnvBuilder(). WithTestInstance(t). WithTestConfig(&config). - WithGeth(). + WithPrivateEthereumNetwork(privateNetwork). WithMockAdapter(). WithCLNodes(1). WithFunding(big.NewFloat(.1)). diff --git a/integration-tests/smoke/vrf_test.go b/integration-tests/smoke/vrf_test.go index b5badf6990b..6c27daffcca 100644 --- a/integration-tests/smoke/vrf_test.go +++ b/integration-tests/smoke/vrf_test.go @@ -30,10 +30,13 @@ func TestVRFBasic(t *testing.T) { t.Fatal(err) } + privateNetwork, err := actions.EthereumNetworkConfigFromConfig(l, &config) + require.NoError(t, err, "Error building ethereum network config") + env, err := test_env.NewCLTestEnvBuilder(). WithTestInstance(t). WithTestConfig(&config). - WithGeth(). + WithPrivateEthereumNetwork(privateNetwork). WithCLNodes(1). WithFunding(big.NewFloat(.1)). WithStandardCleanup(). @@ -124,10 +127,13 @@ func TestVRFJobReplacement(t *testing.T) { t.Fatal(err) } + privateNetwork, err := actions.EthereumNetworkConfigFromConfig(l, &config) + require.NoError(t, err, "Error building ethereum network config") + env, err := test_env.NewCLTestEnvBuilder(). WithTestInstance(t). WithTestConfig(&config). - WithGeth(). + WithPrivateEthereumNetwork(privateNetwork). WithCLNodes(1). WithFunding(big.NewFloat(.1)). WithStandardCleanup(). diff --git a/integration-tests/smoke/vrfv2_test.go b/integration-tests/smoke/vrfv2_test.go index 18a28c6ecbb..57f88346614 100644 --- a/integration-tests/smoke/vrfv2_test.go +++ b/integration-tests/smoke/vrfv2_test.go @@ -296,11 +296,14 @@ func TestVRFv2Basic(t *testing.T) { subscriptionCanceledEvent, err := vrfv2Contracts.CoordinatorV2.WaitForSubscriptionCanceledEvent([]uint64{subIDForCancelling}, time.Second*30) require.NoError(t, err, "error waiting for subscription canceled event") - cancellationTxReceipt, err := env.EVMClient.GetTxReceipt(tx.Hash()) require.NoError(t, err, "error getting tx cancellation Tx Receipt") txGasUsed := new(big.Int).SetUint64(cancellationTxReceipt.GasUsed) + // we don't have that information for older Geth versions + if cancellationTxReceipt.EffectiveGasPrice == nil { + cancellationTxReceipt.EffectiveGasPrice = new(big.Int).SetUint64(0) + } cancellationTxFeeWei := new(big.Int).Mul(txGasUsed, cancellationTxReceipt.EffectiveGasPrice) l.Info(). @@ -408,6 +411,10 @@ func TestVRFv2Basic(t *testing.T) { require.NoError(t, err, "error getting tx cancellation Tx Receipt") txGasUsed := new(big.Int).SetUint64(cancellationTxReceipt.GasUsed) + // we don't have that information for older Geth versions + if cancellationTxReceipt.EffectiveGasPrice == nil { + cancellationTxReceipt.EffectiveGasPrice = new(big.Int).SetUint64(0) + } cancellationTxFeeWei := new(big.Int).Mul(txGasUsed, cancellationTxReceipt.EffectiveGasPrice) l.Info(). diff --git a/integration-tests/smoke/vrfv2plus_test.go b/integration-tests/smoke/vrfv2plus_test.go index 32445995dd9..5cc7b3900fa 100644 --- a/integration-tests/smoke/vrfv2plus_test.go +++ b/integration-tests/smoke/vrfv2plus_test.go @@ -329,6 +329,10 @@ func TestVRFv2Plus(t *testing.T) { require.NoError(t, err, "error getting tx cancellation Tx Receipt") txGasUsed := new(big.Int).SetUint64(cancellationTxReceipt.GasUsed) + // we don't have that information for older Geth versions + if cancellationTxReceipt.EffectiveGasPrice == nil { + cancellationTxReceipt.EffectiveGasPrice = new(big.Int).SetUint64(0) + } cancellationTxFeeWei := new(big.Int).Mul(txGasUsed, cancellationTxReceipt.EffectiveGasPrice) l.Info(). @@ -469,6 +473,10 @@ func TestVRFv2Plus(t *testing.T) { require.NoError(t, err, "error getting tx cancellation Tx Receipt") txGasUsed := new(big.Int).SetUint64(cancellationTxReceipt.GasUsed) + // we don't have that information for older Geth versions + if cancellationTxReceipt.EffectiveGasPrice == nil { + cancellationTxReceipt.EffectiveGasPrice = new(big.Int).SetUint64(0) + } cancellationTxFeeWei := new(big.Int).Mul(txGasUsed, cancellationTxReceipt.EffectiveGasPrice) l.Info(). diff --git a/integration-tests/testconfig/default.toml b/integration-tests/testconfig/default.toml index 1bcb4b3350c..7e518c1fbf2 100644 --- a/integration-tests/testconfig/default.toml +++ b/integration-tests/testconfig/default.toml @@ -13,7 +13,7 @@ postgres_version="15.6" selected_networks=["simulated"] [PrivateEthereumNetwork] -consensus_type="pow" +ethereum_version="eth1" execution_layer="geth" [PrivateEthereumNetwork.EthereumChainConfig] diff --git a/integration-tests/testconfig/log_poller/log_poller.toml b/integration-tests/testconfig/log_poller/log_poller.toml index 89d2f07b4e3..5ead6c91e9c 100644 --- a/integration-tests/testconfig/log_poller/log_poller.toml +++ b/integration-tests/testconfig/log_poller/log_poller.toml @@ -1,3 +1,11 @@ +[PrivateEthereumNetwork] +ethereum_version="eth2" +consensus_layer="prysm" + +[PrivateEthereumNetwork.EthereumChainConfig] +seconds_per_slot=4 +slots_per_epoch=2 + # product defaults [LogPoller] [LogPoller.General] diff --git a/integration-tests/universal/log_poller/helpers.go b/integration-tests/universal/log_poller/helpers.go index 66c63030704..976a9f40fd8 100644 --- a/integration-tests/universal/log_poller/helpers.go +++ b/integration-tests/universal/log_poller/helpers.go @@ -1115,22 +1115,13 @@ func SetupLogPollerTestDocker( return network } - ethBuilder := ctf_test_env.NewEthereumNetworkBuilder() - cfg, err := ethBuilder. - WithConsensusType(ctf_test_env.ConsensusType_PoS). - WithConsensusLayer(ctf_test_env.ConsensusLayer_Prysm). - WithExecutionLayer(ctf_test_env.ExecutionLayer_Geth). - WithEthereumChainConfig(ctf_test_env.EthereumChainConfig{ - SecondsPerSlot: 4, - SlotsPerEpoch: 2, - }). - Build() + privateNetwork, err := actions.EthereumNetworkConfigFromConfig(l, testConfig) require.NoError(t, err, "Error building ethereum network config") env, err = test_env.NewCLTestEnvBuilder(). WithTestConfig(testConfig). WithTestInstance(t). - WithPrivateEthereumNetwork(cfg). + WithPrivateEthereumNetwork(privateNetwork). WithCLNodes(clNodesCount). WithCLNodeConfig(clNodeConfig). WithFunding(big.NewFloat(chainlinkNodeFunding)). diff --git a/integration-tests/wrappers/contract_caller.go b/integration-tests/wrappers/contract_caller.go new file mode 100644 index 00000000000..4be76ee74a1 --- /dev/null +++ b/integration-tests/wrappers/contract_caller.go @@ -0,0 +1,130 @@ +package wrappers + +import ( + "context" + "math/big" + + "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethclient" + "github.com/smartcontractkit/seth" + + evmClient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" + + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" +) + +// WrappedContractBackend is a wrapper around the go-ethereum ContractBackend interface. It's a thin wrapper +// around the go-ethereum/ethclient.Client, which replaces only CallContract and PendingCallContract calls with +// methods that send data both in "input" and "data" field for backwards compatibility with older clients. Other methods +// are passed through to the underlying client. +type WrappedContractBackend struct { + evmClient blockchain.EVMClient + sethClient *seth.Client +} + +// MustNewWrappedContractBackend creates a new WrappedContractBackend with the given clients +func MustNewWrappedContractBackend(evmClient blockchain.EVMClient, sethClient *seth.Client) *WrappedContractBackend { + if evmClient == nil && sethClient == nil { + panic("Must provide at least one client") + } + + return &WrappedContractBackend{ + evmClient: evmClient, + sethClient: sethClient, + } +} + +func (w *WrappedContractBackend) getGethClient() *ethclient.Client { + if w.sethClient != nil { + return w.sethClient.Client + } + + if w.evmClient != nil { + return w.evmClient.GetEthClient() + } + + panic("No client found") +} + +func (w *WrappedContractBackend) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error) { + client := w.getGethClient() + return client.CodeAt(ctx, contract, blockNumber) +} + +func (w *WrappedContractBackend) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error) { + client := w.getGethClient() + return client.PendingCodeAt(ctx, contract) +} + +func (w *WrappedContractBackend) CodeAtHash(ctx context.Context, contract common.Address, blockHash common.Hash) ([]byte, error) { + client := w.getGethClient() + return client.CodeAtHash(ctx, contract, blockHash) +} + +func (w *WrappedContractBackend) CallContractAtHash(ctx context.Context, call ethereum.CallMsg, blockHash common.Hash) ([]byte, error) { + client := w.getGethClient() + return client.CallContractAtHash(ctx, call, blockHash) +} + +func (w *WrappedContractBackend) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) { + client := w.getGethClient() + return client.HeaderByNumber(ctx, number) +} + +func (w *WrappedContractBackend) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) { + client := w.getGethClient() + return client.PendingNonceAt(ctx, account) +} + +func (w *WrappedContractBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) { + client := w.getGethClient() + return client.SuggestGasPrice(ctx) +} + +func (w *WrappedContractBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) { + client := w.getGethClient() + return client.SuggestGasTipCap(ctx) +} + +func (w *WrappedContractBackend) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error) { + client := w.getGethClient() + return client.EstimateGas(ctx, call) +} + +func (w *WrappedContractBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error { + client := w.getGethClient() + return client.SendTransaction(ctx, tx) +} + +func (w *WrappedContractBackend) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error) { + client := w.getGethClient() + return client.FilterLogs(ctx, query) +} + +func (w *WrappedContractBackend) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) { + client := w.getGethClient() + return client.SubscribeFilterLogs(ctx, query, ch) +} + +func (w *WrappedContractBackend) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) { + var hex hexutil.Bytes + client := w.getGethClient() + err := client.Client().CallContext(ctx, &hex, "eth_call", evmClient.ToBackwardCompatibleCallArg(msg), evmClient.ToBackwardCompatibleBlockNumArg(blockNumber)) + if err != nil { + return nil, err + } + return hex, nil +} + +func (w *WrappedContractBackend) PendingCallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error) { + var hex hexutil.Bytes + client := w.getGethClient() + err := client.Client().CallContext(ctx, &hex, "eth_call", evmClient.ToBackwardCompatibleCallArg(msg), "pending") + if err != nil { + return nil, err + } + return hex, nil +}