diff --git a/.github/actions/build-sign-publish-chainlink/action.yml b/.github/actions/build-sign-publish-chainlink/action.yml index 5db4aef9838..bd633bced74 100644 --- a/.github/actions/build-sign-publish-chainlink/action.yml +++ b/.github/actions/build-sign-publish-chainlink/action.yml @@ -10,6 +10,7 @@ inputs: required: false dockerfile: + description: Path to the Dockerfile (relative to the repo root) default: core/chainlink.Dockerfile required: false ecr-hostname: @@ -23,6 +24,11 @@ inputs: default: chainlink/chainlink required: false ecr-tag-suffix: + description: Docker image tag suffix + required: false + git-commit-sha: + description: Git commit SHA used as metadata when building the application (appears in logs) + default: ${{ github.sha }} required: false aws-role-to-assume: description: The AWS role to assume as the CD user, if any. Used in configuring the docker/login-action @@ -74,7 +80,7 @@ runs: ) SHARED_BUILD_ARGS=$(cat << EOF - COMMIT_SHA=${{ github.sha }} + COMMIT_SHA=${{ inputs.git-commit-sha }} EOF ) diff --git a/.github/workflows/build-publish-develop.yml b/.github/workflows/build-publish-develop.yml index 18c5767d45a..54ccaad5810 100644 --- a/.github/workflows/build-publish-develop.yml +++ b/.github/workflows/build-publish-develop.yml @@ -34,6 +34,13 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: ref: ${{ env.GIT_REF }} + # When this is ran from manual workflow_dispatch, the github.sha may be + # different than the checked out commit sha. The core build uses this + # commit sha as build metadata, so we need to make sure it's correct. + - name: Get checked out git ref + if: github.event.inputs.git_ref + id: git-ref + run: echo "checked-out=$(git rev-parse HEAD)" | tee -a "${GITHUB_OUTPUT}" - name: Build, sign and publish chainlink image uses: ./.github/actions/build-sign-publish-chainlink with: @@ -45,6 +52,7 @@ jobs: ecr-image-name: chainlink ecr-tag-suffix: ${{ matrix.image.tag-suffix }} dockerfile: ${{ matrix.image.dockerfile }} + git-commit-sha: ${{ steps.git-ref.outputs.checked-out || github.sha }} - name: Collect Metrics if: always() id: collect-gha-metrics diff --git a/.github/workflows/ci-core.yml b/.github/workflows/ci-core.yml index 97810236b56..7bc91da3abb 100644 --- a/.github/workflows/ci-core.yml +++ b/.github/workflows/ci-core.yml @@ -156,12 +156,16 @@ jobs: GRAFANA_CLOUD_BASIC_AUTH: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }} GRAFANA_CLOUD_HOST: ${{ secrets.GRAFANA_CLOUD_HOST }} GITHUB_EVENT_PATH: ${{ github.event_path }} + GITHUB_EVENT_NAME: ${{ github.event_name }} + GITHUB_REPO: ${{ github.repository }} run: | ./runner \ -grafana_auth=$GRAFANA_CLOUD_BASIC_AUTH \ -grafana_host=$GRAFANA_CLOUD_HOST \ -gh_sha=$GITHUB_SHA \ -gh_event_path=$GITHUB_EVENT_PATH \ + -gh_event_name=$GITHUB_EVENT_NAME \ + -gh_repo=$GITHUB_REPO \ -command=./tools/bin/go_core_tests \ `ls -R ./artifacts/go_core_tests*/output.txt` - name: Store logs artifacts diff --git a/.github/workflows/on-demand-vrfv2plus-load-test.yml b/.github/workflows/on-demand-vrfv2plus-performance-test.yml similarity index 84% rename from .github/workflows/on-demand-vrfv2plus-load-test.yml rename to .github/workflows/on-demand-vrfv2plus-performance-test.yml index a92ca30fbfc..41b6618ba6b 100644 --- a/.github/workflows/on-demand-vrfv2plus-load-test.yml +++ b/.github/workflows/on-demand-vrfv2plus-performance-test.yml @@ -1,4 +1,4 @@ -name: On Demand VRFV2 Plus Load Test +name: On Demand VRFV2 Plus Performance Test on: workflow_dispatch: inputs: @@ -49,8 +49,8 @@ on: - "Spike" testDuration: description: Duration of the test (time string) - required: false - default: 1m + required: true + default: 5m useExistingEnv: description: Set `true` to use existing environment or `false` to deploy CL node and all contracts required: false @@ -59,8 +59,8 @@ on: description: TOML config in base64 (Needed when overriding config or providing contract addresses for existing env) required: false jobs: - vrfv2plus_load_test: - name: ${{ inputs.network }} VRFV2 Plus Load Test + vrfv2plus_performance_test: + name: ${{ inputs.network }} VRFV2 Plus Performance Test environment: integration runs-on: ubuntu20.04-8cores-32GB permissions: @@ -80,6 +80,8 @@ jobs: REF_NAME: ${{ github.head_ref || github.ref_name }} CHAINLINK_IMAGE: ${{ inputs.chainlinkImage }} CHAINLINK_VERSION: ${{ inputs.chainlinkVersion }} + SLACK_API_KEY: ${{ secrets.QA_SLACK_API_KEY }} + SLACK_CHANNEL: ${{ secrets.QA_VRF_SLACK_CHANNEL }} WASP_LOG_LEVEL: info steps: - name: Collect Metrics @@ -88,8 +90,15 @@ jobs: with: basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }} hostname: ${{ secrets.GRAFANA_CLOUD_HOST }} - this-job-name: ${{ inputs.network }} VRFV2 Plus Load Test + this-job-name: ${{ inputs.network }} VRFV2 Plus Performance Test continue-on-error: true + - name: Setup Push Tag + shell: bash + run: | + echo "### chainlink image used for this test run :link:" >>$GITHUB_STEP_SUMMARY + echo "\`${{ inputs.chainlinkVersion }}\`" >>$GITHUB_STEP_SUMMARY + echo "### chainlink-tests image tag for this test run :ship:" >>$GITHUB_STEP_SUMMARY + echo "\`${GITHUB_SHA}\`" >>$GITHUB_STEP_SUMMARY - name: Get Inputs run: | EVM_URLS=$(jq -r '.inputs.wsURL' $GITHUB_EVENT_PATH) @@ -111,7 +120,7 @@ jobs: - name: Run Tests uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/run-tests@eccde1970eca69f079d3efb3409938a72ade8497 # v2.2.13 with: - test_command_to_run: cd ./integration-tests && go test -v -count=1 -timeout 6h -run TestVRFV2PlusLoad/vrfv2plus_soak_test ./load/vrfv2plus + test_command_to_run: cd ./integration-tests && go test -v -count=1 -timeout 6h -run TestVRFV2PlusPerformance/vrfv2plus_performance_test ./load/vrfv2plus test_download_vendor_packages_command: cd ./integration-tests && go mod download cl_repo: ${{ inputs.chainlinkImage }} cl_image_tag: ${{ inputs.chainlinkVersion }} diff --git a/.github/workflows/solidity-hardhat.yml b/.github/workflows/solidity-hardhat.yml index b3543726f31..6e7de2eba19 100644 --- a/.github/workflows/solidity-hardhat.yml +++ b/.github/workflows/solidity-hardhat.yml @@ -28,6 +28,7 @@ jobs: - 'contracts/src/!(v0.8/(llo-feeds|ccip)/**)/**/*' - 'contracts/test/**/*' - 'contracts/package.json' + - 'contracts/pnpm-lock.yaml' - 'contracts/hardhat.config.ts' - 'contracts/ci.json' - '.github/workflows/solidity-hardhat.yml' diff --git a/VERSION b/VERSION index e70b4523ae7..24ba9a38de6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.6.0 +2.7.0 diff --git a/contracts/.solhintignore b/contracts/.solhintignore index 2eace8a37eb..bc7be4fbfee 100644 --- a/contracts/.solhintignore +++ b/contracts/.solhintignore @@ -1,8 +1,8 @@ -# 351 warnings +# 377 warnings #./src/v0.8/automation -# 91 warnings -#./src/v0.8/functions +# Ignore Functions v1.0.0 code that was frozen after audit +./src/v0.8/functions/v1_0_0 # Ignore tests, this should not be the long term plan but is OK in the short term ./src/v0.8/**/*.t.sol diff --git a/contracts/foundry.toml b/contracts/foundry.toml index 1228ce3ec03..cf27c0f2a8b 100644 --- a/contracts/foundry.toml +++ b/contracts/foundry.toml @@ -18,9 +18,9 @@ block_number = 12345 [profile.functions] solc_version = '0.8.19' -src = 'src/v0.8/functions' -test = 'src/v0.8/functions/tests' -gas_price = 3000000000 +src = 'src/v0.8/functions/dev/v1_X' +test = 'src/v0.8/functions/tests/v1_X' +gas_price = 3_000_000_000 # 3 gwei [profile.vrf] optimizer_runs = 1000 diff --git a/contracts/gas-snapshots/functions.gas-snapshot b/contracts/gas-snapshots/functions.gas-snapshot index b6298350604..d575c8ca196 100644 --- a/contracts/gas-snapshots/functions.gas-snapshot +++ b/contracts/gas-snapshots/functions.gas-snapshot @@ -1,177 +1,195 @@ -FunctionsBilling_EstimateCost:test_EstimateCost_RevertsIfGasPriceAboveCeiling() (gas: 32391) -FunctionsBilling_EstimateCost:test_EstimateCost_Success() (gas: 53182) -FunctionsBilling_EstimateCost:test_EstimateCost_SuccessLowGasPrice() (gas: 53285) +FunctionsBilling_Constructor:test_Constructor_Success() (gas: 14812) +FunctionsBilling_DeleteCommitment:test_DeleteCommitment_RevertIfNotRouter() (gas: 13282) +FunctionsBilling_DeleteCommitment:test_DeleteCommitment_Success() (gas: 15897) +FunctionsBilling_EstimateCost:test_EstimateCost_RevertsIfGasPriceAboveCeiling() (gas: 32458) +FunctionsBilling_EstimateCost:test_EstimateCost_Success() (gas: 53227) +FunctionsBilling_EstimateCost:test_EstimateCost_SuccessLowGasPrice() (gas: 53330) +FunctionsBilling_GetAdminFee:test_GetAdminFee_Success() (gas: 18226) FunctionsBilling_GetConfig:test_GetConfig_Success() (gas: 23671) +FunctionsBilling_GetDONFee:test_GetDONFee_Success() (gas: 15792) +FunctionsBilling_GetWeiPerUnitLink:test_GetWeiPerUnitLink_Success() (gas: 31773) +FunctionsBilling_OracleWithdraw:test_OracleWithdraw_RevertIfInsufficientBalance() (gas: 70138) +FunctionsBilling_OracleWithdraw:test_OracleWithdraw_RevertWithNoBalance() (gas: 106295) +FunctionsBilling_OracleWithdraw:test_OracleWithdraw_SuccessTransmitterWithBalanceNoAmountGiven() (gas: 140174) +FunctionsBilling_OracleWithdraw:test_OracleWithdraw_SuccessTransmitterWithBalanceValidAmountGiven() (gas: 142502) FunctionsBilling_OracleWithdrawAll:test_OracleWithdrawAll_RevertIfNotOwner() (gas: 13296) -FunctionsBilling_OracleWithdrawAll:test_OracleWithdrawAll_SuccessPaysTransmittersWithBalance() (gas: 146657) -FunctionsClient_FulfillRequest:test_FulfillRequest_MaximumGas() (gas: 498113) -FunctionsClient_FulfillRequest:test_FulfillRequest_MinimumGas() (gas: 199261) -FunctionsClient__SendRequest:test__SendRequest_RevertIfInvalidCallbackGasLimit() (gas: 54991) -FunctionsCoordinator_Constructor:test_Constructor_Success() (gas: 11933) -FunctionsOracle_sendRequest:testEmptyRequestDataReverts() (gas: 13452) -FunctionsOracle_setDONPublicKey:testEmptyPublicKeyReverts() (gas: 10974) -FunctionsOracle_setDONPublicKey:testOnlyOwnerReverts() (gas: 11255) -FunctionsOracle_setDONPublicKey:testSetDONPublicKeySuccess() (gas: 126453) -FunctionsOracle_setDONPublicKey:testSetDONPublicKey_gas() (gas: 97580) -FunctionsOracle_setRegistry:testEmptyPublicKeyReverts() (gas: 10635) -FunctionsOracle_setRegistry:testOnlyOwnerReverts() (gas: 10927) -FunctionsOracle_setRegistry:testSetRegistrySuccess() (gas: 35791) -FunctionsOracle_setRegistry:testSetRegistry_gas() (gas: 31987) -FunctionsOracle_typeAndVersion:testTypeAndVersionSuccess() (gas: 6905) +FunctionsBilling_OracleWithdrawAll:test_OracleWithdrawAll_SuccessPaysTransmittersWithBalance() (gas: 147278) +FunctionsBilling_UpdateConfig:test_UpdateConfig_RevertIfNotOwner() (gas: 18974) +FunctionsBilling_UpdateConfig:test_UpdateConfig_Success() (gas: 38251) +FunctionsBilling__DisperseFeePool:test__DisperseFeePool_RevertIfNotSet() (gas: 8801) +FunctionsClient_Constructor:test_Constructor_Success() (gas: 7573) +FunctionsClient_FulfillRequest:test_FulfillRequest_MaximumGas() (gas: 498114) +FunctionsClient_FulfillRequest:test_FulfillRequest_MinimumGas() (gas: 199285) +FunctionsClient_HandleOracleFulfillment:test_HandleOracleFulfillment_RevertIfNotRouter() (gas: 14623) +FunctionsClient_HandleOracleFulfillment:test_HandleOracleFulfillment_Success() (gas: 22923) +FunctionsClient__SendRequest:test__SendRequest_RevertIfInvalidCallbackGasLimit() (gas: 55059) +FunctionsCoordinator_Constructor:test_Constructor_Success() (gas: 11984) +FunctionsCoordinator_GetDONPublicKey:test_GetDONPublicKey_RevertIfEmpty() (gas: 15334) +FunctionsCoordinator_GetDONPublicKey:test_GetDONPublicKey_Success() (gas: 106496) +FunctionsCoordinator_GetThresholdPublicKey:test_GetThresholdPublicKey_RevertIfEmpty() (gas: 15313) +FunctionsCoordinator_GetThresholdPublicKey:test_GetThresholdPublicKey_Success() (gas: 656556) +FunctionsCoordinator_SetDONPublicKey:test_SetDONPublicKey_RevertNotOwner() (gas: 20364) +FunctionsCoordinator_SetDONPublicKey:test_SetDONPublicKey_Success() (gas: 101275) +FunctionsCoordinator_SetThresholdPublicKey:test_SetThresholdPublicKey_RevertNotOwner() (gas: 13892) +FunctionsCoordinator_SetThresholdPublicKey:test_SetThresholdPublicKey_Success() (gas: 651248) +FunctionsCoordinator_StartRequest:test_StartRequest_RevertIfNotRouter() (gas: 22703) +FunctionsCoordinator_StartRequest:test_StartRequest_Success() (gas: 107681) +FunctionsCoordinator__IsTransmitter:test__IsTransmitter_SuccessFound() (gas: 18957) +FunctionsCoordinator__IsTransmitter:test__IsTransmitter_SuccessNotFound() (gas: 19690) FunctionsRequest_DEFAULT_BUFFER_SIZE:test_DEFAULT_BUFFER_SIZE() (gas: 246) FunctionsRequest_EncodeCBOR:test_EncodeCBOR_Success() (gas: 223) FunctionsRequest_REQUEST_DATA_VERSION:test_REQUEST_DATA_VERSION() (gas: 225) -FunctionsRouter_Constructor:test_Constructor_Success() (gas: 12073) -FunctionsRouter_Fulfill:test_Fulfill_RequestNotProcessedCostExceedsCommitment() (gas: 169899) -FunctionsRouter_Fulfill:test_Fulfill_RequestNotProcessedInsufficientGas() (gas: 160226) -FunctionsRouter_Fulfill:test_Fulfill_RequestNotProcessedInvalidCommitment() (gas: 38092) -FunctionsRouter_Fulfill:test_Fulfill_RequestNotProcessedInvalidRequestId() (gas: 35224) -FunctionsRouter_Fulfill:test_Fulfill_RequestNotProcessedSubscriptionBalanceInvariant() (gas: 178394) -FunctionsRouter_Fulfill:test_Fulfill_RevertIfNotCommittedCoordinator() (gas: 28063) -FunctionsRouter_Fulfill:test_Fulfill_RevertIfPaused() (gas: 153900) -FunctionsRouter_Fulfill:test_Fulfill_SuccessClientNoLongerExists() (gas: 296711) -FunctionsRouter_Fulfill:test_Fulfill_SuccessFulfilled() (gas: 310303) -FunctionsRouter_Fulfill:test_Fulfill_SuccessUserCallbackReverts() (gas: 2484943) -FunctionsRouter_Fulfill:test_Fulfill_SuccessUserCallbackRunsOutOfGas() (gas: 515428) -FunctionsRouter_GetAdminFee:test_GetAdminFee_Success() (gas: 18005) -FunctionsRouter_GetAllowListId:test_GetAllowListId_Success() (gas: 12926) -FunctionsRouter_GetConfig:test_GetConfig_Success() (gas: 37136) -FunctionsRouter_GetContractById:test_GetContractById_RevertIfRouteDoesNotExist() (gas: 13871) -FunctionsRouter_GetContractById:test_GetContractById_SuccessIfRouteExists() (gas: 17395) -FunctionsRouter_GetProposedContractById:test_GetProposedContractById_RevertIfRouteDoesNotExist() (gas: 16382) -FunctionsRouter_GetProposedContractById:test_GetProposedContractById_SuccessIfRouteExists() (gas: 23934) -FunctionsRouter_GetProposedContractSet:test_GetProposedContractSet_Success() (gas: 25958) -FunctionsRouter_IsValidCallbackGasLimit:test_IsValidCallbackGasLimit_RevertGasLimitTooBig() (gas: 28034) -FunctionsRouter_IsValidCallbackGasLimit:test_IsValidCallbackGasLimit_RevertInvalidConfig() (gas: 41004) -FunctionsRouter_IsValidCallbackGasLimit:test_IsValidCallbackGasLimit_Success() (gas: 24551) -FunctionsRouter_Pause:test_Pause_RevertIfNotOwner() (gas: 13315) -FunctionsRouter_Pause:test_Pause_Success() (gas: 20298) -FunctionsRouter_ProposeContractsUpdate:test_ProposeContractsUpdate_RevertIfEmptyAddress() (gas: 14768) -FunctionsRouter_ProposeContractsUpdate:test_ProposeContractsUpdate_RevertIfExceedsMaxProposal() (gas: 21670) -FunctionsRouter_ProposeContractsUpdate:test_ProposeContractsUpdate_RevertIfLengthMismatch() (gas: 14647) -FunctionsRouter_ProposeContractsUpdate:test_ProposeContractsUpdate_RevertIfNotNewContract() (gas: 19025) -FunctionsRouter_ProposeContractsUpdate:test_ProposeContractsUpdate_RevertIfNotOwner() (gas: 23369) -FunctionsRouter_ProposeContractsUpdate:test_ProposeContractsUpdate_Success() (gas: 118456) -FunctionsRouter_SendRequest:test_SendRequest_RevertIfConsumerNotAllowed() (gas: 59304) -FunctionsRouter_SendRequest:test_SendRequest_RevertIfDuplicateRequestId() (gas: 192796) -FunctionsRouter_SendRequest:test_SendRequest_RevertIfEmptyData() (gas: 29405) -FunctionsRouter_SendRequest:test_SendRequest_RevertIfIncorrectDonId() (gas: 57926) -FunctionsRouter_SendRequest:test_SendRequest_RevertIfInsufficientSubscriptionBalance() (gas: 186209) -FunctionsRouter_SendRequest:test_SendRequest_RevertIfInvalidCallbackGasLimit() (gas: 50902) -FunctionsRouter_SendRequest:test_SendRequest_RevertIfInvalidDonId() (gas: 25061) -FunctionsRouter_SendRequest:test_SendRequest_RevertIfNoSubscription() (gas: 29111) -FunctionsRouter_SendRequest:test_SendRequest_RevertIfPaused() (gas: 34247) -FunctionsRouter_SendRequest:test_SendRequest_Success() (gas: 284999) -FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_RevertIfConsumerNotAllowed() (gas: 65800) -FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_RevertIfEmptyData() (gas: 35991) -FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_RevertIfIncorrectDonId() (gas: 29897) -FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_RevertIfInvalidCallbackGasLimit() (gas: 57488) -FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_RevertIfInvalidDonId() (gas: 27482) -FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_RevertIfNoSubscription() (gas: 35696) -FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_RevertIfPaused() (gas: 40766) -FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_Success() (gas: 291551) -FunctionsRouter_SendRequestToProposed:test_SendRequest_RevertIfInsufficientSubscriptionBalance() (gas: 192728) -FunctionsRouter_SetAllowListId:test_SetAllowListId_Success() (gas: 30687) -FunctionsRouter_SetAllowListId:test_UpdateConfig_RevertIfNotOwner() (gas: 13380) -FunctionsRouter_Unpause:test_Unpause_RevertIfNotOwner() (gas: 13337) -FunctionsRouter_Unpause:test_Unpause_Success() (gas: 77421) +FunctionsRouter_Constructor:test_Constructor_Success() (gas: 12007) +FunctionsRouter_Fulfill:test_Fulfill_RequestNotProcessedCostExceedsCommitment() (gas: 169900) +FunctionsRouter_Fulfill:test_Fulfill_RequestNotProcessedInsufficientGas() (gas: 160227) +FunctionsRouter_Fulfill:test_Fulfill_RequestNotProcessedInvalidCommitment() (gas: 38115) +FunctionsRouter_Fulfill:test_Fulfill_RequestNotProcessedInvalidRequestId() (gas: 35238) +FunctionsRouter_Fulfill:test_Fulfill_RequestNotProcessedSubscriptionBalanceInvariant() (gas: 178373) +FunctionsRouter_Fulfill:test_Fulfill_RevertIfNotCommittedCoordinator() (gas: 28086) +FunctionsRouter_Fulfill:test_Fulfill_RevertIfPaused() (gas: 153924) +FunctionsRouter_Fulfill:test_Fulfill_SuccessClientNoLongerExists() (gas: 296712) +FunctionsRouter_Fulfill:test_Fulfill_SuccessFulfilled() (gas: 310327) +FunctionsRouter_Fulfill:test_Fulfill_SuccessUserCallbackReverts() (gas: 2484946) +FunctionsRouter_Fulfill:test_Fulfill_SuccessUserCallbackRunsOutOfGas() (gas: 515433) +FunctionsRouter_GetAdminFee:test_GetAdminFee_Success() (gas: 17983) +FunctionsRouter_GetAllowListId:test_GetAllowListId_Success() (gas: 12904) +FunctionsRouter_GetConfig:test_GetConfig_Success() (gas: 37159) +FunctionsRouter_GetContractById:test_GetContractById_RevertIfRouteDoesNotExist() (gas: 13849) +FunctionsRouter_GetContractById:test_GetContractById_SuccessIfRouteExists() (gas: 17373) +FunctionsRouter_GetProposedContractById:test_GetProposedContractById_RevertIfRouteDoesNotExist() (gas: 16383) +FunctionsRouter_GetProposedContractById:test_GetProposedContractById_SuccessIfRouteExists() (gas: 23935) +FunctionsRouter_GetProposedContractSet:test_GetProposedContractSet_Success() (gas: 25936) +FunctionsRouter_IsValidCallbackGasLimit:test_IsValidCallbackGasLimit_RevertGasLimitTooBig() (gas: 28103) +FunctionsRouter_IsValidCallbackGasLimit:test_IsValidCallbackGasLimit_RevertInvalidConfig() (gas: 41093) +FunctionsRouter_IsValidCallbackGasLimit:test_IsValidCallbackGasLimit_Success() (gas: 24626) +FunctionsRouter_Pause:test_Pause_RevertIfNotOwner() (gas: 13338) +FunctionsRouter_Pause:test_Pause_Success() (gas: 20344) +FunctionsRouter_ProposeContractsUpdate:test_ProposeContractsUpdate_RevertIfEmptyAddress() (gas: 14791) +FunctionsRouter_ProposeContractsUpdate:test_ProposeContractsUpdate_RevertIfExceedsMaxProposal() (gas: 21693) +FunctionsRouter_ProposeContractsUpdate:test_ProposeContractsUpdate_RevertIfLengthMismatch() (gas: 14670) +FunctionsRouter_ProposeContractsUpdate:test_ProposeContractsUpdate_RevertIfNotNewContract() (gas: 19048) +FunctionsRouter_ProposeContractsUpdate:test_ProposeContractsUpdate_RevertIfNotOwner() (gas: 23392) +FunctionsRouter_ProposeContractsUpdate:test_ProposeContractsUpdate_Success() (gas: 118479) +FunctionsRouter_SendRequest:test_SendRequest_RevertIfConsumerNotAllowed() (gas: 59347) +FunctionsRouter_SendRequest:test_SendRequest_RevertIfDuplicateRequestId() (gas: 192799) +FunctionsRouter_SendRequest:test_SendRequest_RevertIfEmptyData() (gas: 29426) +FunctionsRouter_SendRequest:test_SendRequest_RevertIfIncorrectDonId() (gas: 57925) +FunctionsRouter_SendRequest:test_SendRequest_RevertIfInsufficientSubscriptionBalance() (gas: 186299) +FunctionsRouter_SendRequest:test_SendRequest_RevertIfInvalidCallbackGasLimit() (gas: 50947) +FunctionsRouter_SendRequest:test_SendRequest_RevertIfInvalidDonId() (gas: 25082) +FunctionsRouter_SendRequest:test_SendRequest_RevertIfNoSubscription() (gas: 29132) +FunctionsRouter_SendRequest:test_SendRequest_RevertIfPaused() (gas: 34291) +FunctionsRouter_SendRequest:test_SendRequest_Success() (gas: 285026) +FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_RevertIfConsumerNotAllowed() (gas: 65843) +FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_RevertIfEmptyData() (gas: 36012) +FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_RevertIfIncorrectDonId() (gas: 29896) +FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_RevertIfInvalidCallbackGasLimit() (gas: 57533) +FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_RevertIfInvalidDonId() (gas: 27503) +FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_RevertIfNoSubscription() (gas: 35717) +FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_RevertIfPaused() (gas: 40810) +FunctionsRouter_SendRequestToProposed:test_SendRequestToProposed_Success() (gas: 291595) +FunctionsRouter_SendRequestToProposed:test_SendRequest_RevertIfInsufficientSubscriptionBalance() (gas: 192791) +FunctionsRouter_SetAllowListId:test_SetAllowListId_Success() (gas: 30688) +FunctionsRouter_SetAllowListId:test_UpdateConfig_RevertIfNotOwner() (gas: 13403) +FunctionsRouter_Unpause:test_Unpause_RevertIfNotOwner() (gas: 13293) +FunctionsRouter_Unpause:test_Unpause_Success() (gas: 77400) FunctionsRouter_UpdateConfig:test_UpdateConfig_RevertIfNotOwner() (gas: 24437) -FunctionsRouter_UpdateConfig:test_UpdateConfig_Success() (gas: 60653) -FunctionsRouter_UpdateContracts:test_UpdateContracts_RevertIfNotOwner() (gas: 13293) -FunctionsRouter_UpdateContracts:test_UpdateContracts_Success() (gas: 38716) -FunctionsSubscriptions_AcceptSubscriptionOwnerTransfer:test_AcceptSubscriptionOwnerTransfer_RevertIfNotAllowedSender() (gas: 60324) -FunctionsSubscriptions_AcceptSubscriptionOwnerTransfer:test_AcceptSubscriptionOwnerTransfer_RevertIfPaused() (gas: 60962) -FunctionsSubscriptions_AcceptSubscriptionOwnerTransfer:test_AcceptSubscriptionOwnerTransfer_RevertIfSenderBecomesBlocked() (gas: 94675) -FunctionsSubscriptions_AcceptSubscriptionOwnerTransfer:test_AcceptSubscriptionOwnerTransfer_RevertIfSenderIsNotNewOwner() (gas: 62691) -FunctionsSubscriptions_AcceptSubscriptionOwnerTransfer:test_AcceptSubscriptionOwnerTransfer_Success() (gas: 214576) -FunctionsSubscriptions_AddConsumer:test_AddConsumer_RevertIfMaximumConsumers() (gas: 137833) -FunctionsSubscriptions_AddConsumer:test_AddConsumer_RevertIfMaximumConsumersAfterConfigUpdate() (gas: 164777) -FunctionsSubscriptions_AddConsumer:test_AddConsumer_RevertIfNoSubscription() (gas: 12926) -FunctionsSubscriptions_AddConsumer:test_AddConsumer_RevertIfNotAllowedSender() (gas: 57789) -FunctionsSubscriptions_AddConsumer:test_AddConsumer_RevertIfNotSubscriptionOwner() (gas: 87142) -FunctionsSubscriptions_AddConsumer:test_AddConsumer_RevertIfPaused() (gas: 18051) -FunctionsSubscriptions_AddConsumer:test_AddConsumer_Success() (gas: 95481) -FunctionsSubscriptions_CancelSubscription:test_CancelSubscription_RevertIfNoSubscription() (gas: 15085) -FunctionsSubscriptions_CancelSubscription:test_CancelSubscription_RevertIfNotAllowedSender() (gas: 57929) -FunctionsSubscriptions_CancelSubscription:test_CancelSubscription_RevertIfNotSubscriptionOwner() (gas: 89316) -FunctionsSubscriptions_CancelSubscription:test_CancelSubscription_RevertIfPaused() (gas: 20191) -FunctionsSubscriptions_CancelSubscription:test_CancelSubscription_RevertIfPendingRequests() (gas: 193763) -FunctionsSubscriptions_CancelSubscription:test_CancelSubscription_SuccessForfeitAllBalanceAsDeposit() (gas: 114636) -FunctionsSubscriptions_CancelSubscription:test_CancelSubscription_SuccessForfeitSomeBalanceAsDeposit() (gas: 125891) -FunctionsSubscriptions_CancelSubscription:test_CancelSubscription_SuccessRecieveDeposit() (gas: 311486) +FunctionsRouter_UpdateConfig:test_UpdateConfig_Success() (gas: 60676) +FunctionsRouter_UpdateContracts:test_UpdateContracts_RevertIfNotOwner() (gas: 13336) +FunctionsRouter_UpdateContracts:test_UpdateContracts_Success() (gas: 38732) +FunctionsSubscriptions_AcceptSubscriptionOwnerTransfer:test_AcceptSubscriptionOwnerTransfer_RevertIfNotAllowedSender() (gas: 60326) +FunctionsSubscriptions_AcceptSubscriptionOwnerTransfer:test_AcceptSubscriptionOwnerTransfer_RevertIfPaused() (gas: 60987) +FunctionsSubscriptions_AcceptSubscriptionOwnerTransfer:test_AcceptSubscriptionOwnerTransfer_RevertIfSenderBecomesBlocked() (gas: 94677) +FunctionsSubscriptions_AcceptSubscriptionOwnerTransfer:test_AcceptSubscriptionOwnerTransfer_RevertIfSenderIsNotNewOwner() (gas: 62693) +FunctionsSubscriptions_AcceptSubscriptionOwnerTransfer:test_AcceptSubscriptionOwnerTransfer_Success() (gas: 214560) +FunctionsSubscriptions_AddConsumer:test_AddConsumer_RevertIfMaximumConsumers() (gas: 137893) +FunctionsSubscriptions_AddConsumer:test_AddConsumer_RevertIfMaximumConsumersAfterConfigUpdate() (gas: 164837) +FunctionsSubscriptions_AddConsumer:test_AddConsumer_RevertIfNoSubscription() (gas: 12946) +FunctionsSubscriptions_AddConsumer:test_AddConsumer_RevertIfNotAllowedSender() (gas: 57809) +FunctionsSubscriptions_AddConsumer:test_AddConsumer_RevertIfNotSubscriptionOwner() (gas: 87162) +FunctionsSubscriptions_AddConsumer:test_AddConsumer_RevertIfPaused() (gas: 18094) +FunctionsSubscriptions_AddConsumer:test_AddConsumer_Success() (gas: 95480) +FunctionsSubscriptions_CancelSubscription:test_CancelSubscription_RevertIfNoSubscription() (gas: 15041) +FunctionsSubscriptions_CancelSubscription:test_CancelSubscription_RevertIfNotAllowedSender() (gas: 57885) +FunctionsSubscriptions_CancelSubscription:test_CancelSubscription_RevertIfNotSubscriptionOwner() (gas: 89272) +FunctionsSubscriptions_CancelSubscription:test_CancelSubscription_RevertIfPaused() (gas: 20148) +FunctionsSubscriptions_CancelSubscription:test_CancelSubscription_RevertIfPendingRequests() (gas: 193688) +FunctionsSubscriptions_CancelSubscription:test_CancelSubscription_SuccessForfeitAllBalanceAsDeposit() (gas: 114506) +FunctionsSubscriptions_CancelSubscription:test_CancelSubscription_SuccessForfeitSomeBalanceAsDeposit() (gas: 125832) +FunctionsSubscriptions_CancelSubscription_ReceiveDeposit:test_CancelSubscription_SuccessRecieveDeposit() (gas: 74973) FunctionsSubscriptions_Constructor:test_Constructor_Success() (gas: 7654) -FunctionsSubscriptions_CreateSubscriptionWithConsumer:test_CreateSubscriptionWithConsumer_RevertIfNotAllowedSender() (gas: 28637) -FunctionsSubscriptions_CreateSubscriptionWithConsumer:test_CreateSubscriptionWithConsumer_RevertIfPaused() (gas: 17948) -FunctionsSubscriptions_CreateSubscriptionWithConsumer:test_CreateSubscriptionWithConsumer_Success() (gas: 351723) -FunctionsSubscriptions_GetConsumer:test_GetConsumer_Success() (gas: 16225) -FunctionsSubscriptions_GetFlags:test_GetFlags_SuccessInvalidSubscription() (gas: 13100) -FunctionsSubscriptions_GetFlags:test_GetFlags_SuccessValidSubscription() (gas: 40858) -FunctionsSubscriptions_GetSubscription:test_GetSubscription_Success() (gas: 30959) -FunctionsSubscriptions_GetSubscriptionCount:test_GetSubscriptionCount_Success() (gas: 12967) -FunctionsSubscriptions_GetSubscriptionsInRange:test_GetSubscriptionsInRange_RevertIfEndIsAfterLastSubscription() (gas: 16523) -FunctionsSubscriptions_GetSubscriptionsInRange:test_GetSubscriptionsInRange_RevertIfStartIsAfterEnd() (gas: 13436) -FunctionsSubscriptions_GetSubscriptionsInRange:test_GetSubscriptionsInRange_Success() (gas: 59568) -FunctionsSubscriptions_GetTotalBalance:test_GetTotalBalance_Success() (gas: 15032) -FunctionsSubscriptions_OnTokenTransfer:test_OnTokenTransfer_RevertIfCallerIsNoCalldata(uint96) (runs: 256, μ: 28401, ~: 28401) -FunctionsSubscriptions_OnTokenTransfer:test_OnTokenTransfer_RevertIfCallerIsNoSubscription(uint96) (runs: 256, μ: 30913, ~: 30913) -FunctionsSubscriptions_OnTokenTransfer:test_OnTokenTransfer_RevertIfCallerIsNotLink(uint96) (runs: 256, μ: 14248, ~: 14248) -FunctionsSubscriptions_OnTokenTransfer:test_OnTokenTransfer_RevertIfPaused(uint96) (runs: 256, μ: 35870, ~: 35870) -FunctionsSubscriptions_OnTokenTransfer:test_OnTokenTransfer_Success(uint96) (runs: 256, μ: 59685, ~: 59685) +FunctionsSubscriptions_CreateSubscriptionWithConsumer:test_CreateSubscriptionWithConsumer_RevertIfNotAllowedSender() (gas: 28660) +FunctionsSubscriptions_CreateSubscriptionWithConsumer:test_CreateSubscriptionWithConsumer_RevertIfPaused() (gas: 17994) +FunctionsSubscriptions_CreateSubscriptionWithConsumer:test_CreateSubscriptionWithConsumer_Success() (gas: 351726) +FunctionsSubscriptions_GetConsumer:test_GetConsumer_Success() (gas: 16226) +FunctionsSubscriptions_GetFlags:test_GetFlags_SuccessInvalidSubscription() (gas: 13101) +FunctionsSubscriptions_GetFlags:test_GetFlags_SuccessValidSubscription() (gas: 40903) +FunctionsSubscriptions_GetSubscription:test_GetSubscription_Success() (gas: 30937) +FunctionsSubscriptions_GetSubscriptionCount:test_GetSubscriptionCount_Success() (gas: 12968) +FunctionsSubscriptions_GetSubscriptionsInRange:test_GetSubscriptionsInRange_RevertIfEndIsAfterLastSubscription() (gas: 16547) +FunctionsSubscriptions_GetSubscriptionsInRange:test_GetSubscriptionsInRange_RevertIfStartIsAfterEnd() (gas: 13459) +FunctionsSubscriptions_GetSubscriptionsInRange:test_GetSubscriptionsInRange_Success() (gas: 59592) +FunctionsSubscriptions_GetTotalBalance:test_GetTotalBalance_Success() (gas: 15010) +FunctionsSubscriptions_OnTokenTransfer:test_OnTokenTransfer_RevertIfCallerIsNoCalldata(uint96) (runs: 256, μ: 28446, ~: 28446) +FunctionsSubscriptions_OnTokenTransfer:test_OnTokenTransfer_RevertIfCallerIsNoSubscription(uint96) (runs: 256, μ: 30958, ~: 30958) +FunctionsSubscriptions_OnTokenTransfer:test_OnTokenTransfer_RevertIfCallerIsNotLink(uint96) (runs: 256, μ: 14293, ~: 14293) +FunctionsSubscriptions_OnTokenTransfer:test_OnTokenTransfer_RevertIfPaused(uint96) (runs: 256, μ: 35938, ~: 35938) +FunctionsSubscriptions_OnTokenTransfer:test_OnTokenTransfer_Success(uint96) (runs: 256, μ: 59686, ~: 59686) FunctionsSubscriptions_OracleWithdraw:test_OracleWithdraw_RevertIfAmountMoreThanBalance() (gas: 20745) FunctionsSubscriptions_OracleWithdraw:test_OracleWithdraw_RevertIfBalanceInvariant() (gas: 189) FunctionsSubscriptions_OracleWithdraw:test_OracleWithdraw_RevertIfNoAmount() (gas: 15638) -FunctionsSubscriptions_OracleWithdraw:test_OracleWithdraw_RevertIfPaused() (gas: 20833) +FunctionsSubscriptions_OracleWithdraw:test_OracleWithdraw_RevertIfPaused() (gas: 20856) FunctionsSubscriptions_OracleWithdraw:test_OracleWithdraw_SuccessPaysRecipient() (gas: 59732) FunctionsSubscriptions_OracleWithdraw:test_OracleWithdraw_SuccessSetsBalanceToZero() (gas: 57701) FunctionsSubscriptions_OwnerCancelSubscription:test_OwnerCancelSubscription_RevertIfNoSubscription() (gas: 12818) FunctionsSubscriptions_OwnerCancelSubscription:test_OwnerCancelSubscription_RevertIfNotOwner() (gas: 15549) FunctionsSubscriptions_OwnerCancelSubscription:test_OwnerCancelSubscription_Success() (gas: 54867) -FunctionsSubscriptions_OwnerCancelSubscription:test_OwnerCancelSubscription_SuccessDeletesSubscription() (gas: 49624) +FunctionsSubscriptions_OwnerCancelSubscription:test_OwnerCancelSubscription_SuccessDeletesSubscription() (gas: 49607) FunctionsSubscriptions_OwnerCancelSubscription:test_OwnerCancelSubscription_SuccessSubOwnerRefunded() (gas: 50896) -FunctionsSubscriptions_OwnerCancelSubscription:test_OwnerCancelSubscription_SuccessWhenRequestInFlight() (gas: 164300) +FunctionsSubscriptions_OwnerCancelSubscription:test_OwnerCancelSubscription_SuccessWhenRequestInFlight() (gas: 164303) FunctionsSubscriptions_OwnerWithdraw:test_OwnerWithdraw_RevertIfAmountMoreThanBalance() (gas: 17924) FunctionsSubscriptions_OwnerWithdraw:test_OwnerWithdraw_RevertIfBalanceInvariant() (gas: 210) -FunctionsSubscriptions_OwnerWithdraw:test_OwnerWithdraw_RevertIfNotOwner() (gas: 15533) +FunctionsSubscriptions_OwnerWithdraw:test_OwnerWithdraw_RevertIfNotOwner() (gas: 15555) FunctionsSubscriptions_OwnerWithdraw:test_OwnerWithdraw_SuccessIfNoAmount() (gas: 37396) FunctionsSubscriptions_OwnerWithdraw:test_OwnerWithdraw_SuccessIfRecipientAddressZero() (gas: 52130) FunctionsSubscriptions_OwnerWithdraw:test_OwnerWithdraw_SuccessPaysRecipient() (gas: 54413) FunctionsSubscriptions_OwnerWithdraw:test_OwnerWithdraw_SuccessSetsBalanceToZero() (gas: 37790) -FunctionsSubscriptions_PendingRequestExists:test_PendingRequestExists_SuccessFalseIfNoPendingRequests() (gas: 15025) -FunctionsSubscriptions_PendingRequestExists:test_PendingRequestExists_SuccessTrueIfPendingRequests() (gas: 175897) -FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_RevertIfEmptyNewOwner() (gas: 27610) -FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_RevertIfInvalidNewOwner() (gas: 57707) -FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_RevertIfNoSubscription() (gas: 15000) -FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_RevertIfNotAllowedSender() (gas: 75130) -FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_RevertIfNotSubscriptionOwner() (gas: 17959) -FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_RevertIfPaused() (gas: 20104) -FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_Success() (gas: 68217) -FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_SuccessChangeProposedOwner() (gas: 82791) -FunctionsSubscriptions_RecoverFunds:test_OwnerCancelSubscription_RevertIfNotOwner() (gas: 15532) -FunctionsSubscriptions_RecoverFunds:test_RecoverFunds_Success(uint64) (runs: 256, μ: 41699, ~: 41704) -FunctionsSubscriptions_RemoveConsumer:test_RemoveConsumer_RevertIfInvalidConsumer() (gas: 30238) -FunctionsSubscriptions_RemoveConsumer:test_RemoveConsumer_RevertIfNoSubscription() (gas: 14997) -FunctionsSubscriptions_RemoveConsumer:test_RemoveConsumer_RevertIfNotAllowedSender() (gas: 57778) -FunctionsSubscriptions_RemoveConsumer:test_RemoveConsumer_RevertIfNotSubscriptionOwner() (gas: 87186) -FunctionsSubscriptions_RemoveConsumer:test_RemoveConsumer_RevertIfPaused() (gas: 18004) -FunctionsSubscriptions_RemoveConsumer:test_RemoveConsumer_RevertIfPendingRequests() (gas: 191195) +FunctionsSubscriptions_PendingRequestExists:test_PendingRequestExists_SuccessFalseIfNoPendingRequests() (gas: 14981) +FunctionsSubscriptions_PendingRequestExists:test_PendingRequestExists_SuccessTrueIfPendingRequests() (gas: 175857) +FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_RevertIfEmptyNewOwner() (gas: 27611) +FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_RevertIfInvalidNewOwner() (gas: 57709) +FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_RevertIfNoSubscription() (gas: 15001) +FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_RevertIfNotAllowedSender() (gas: 75131) +FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_RevertIfNotSubscriptionOwner() (gas: 17960) +FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_RevertIfPaused() (gas: 20128) +FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_Success() (gas: 68196) +FunctionsSubscriptions_ProposeSubscriptionOwnerTransfer:test_ProposeSubscriptionOwnerTransfer_SuccessChangeProposedOwner() (gas: 82749) +FunctionsSubscriptions_RecoverFunds:test_OwnerCancelSubscription_RevertIfNotOwner() (gas: 15554) +FunctionsSubscriptions_RecoverFunds:test_RecoverFunds_Success(uint64) (runs: 256, μ: 41717, ~: 41721) +FunctionsSubscriptions_RemoveConsumer:test_RemoveConsumer_RevertIfInvalidConsumer() (gas: 30260) +FunctionsSubscriptions_RemoveConsumer:test_RemoveConsumer_RevertIfNoSubscription() (gas: 15019) +FunctionsSubscriptions_RemoveConsumer:test_RemoveConsumer_RevertIfNotAllowedSender() (gas: 57800) +FunctionsSubscriptions_RemoveConsumer:test_RemoveConsumer_RevertIfNotSubscriptionOwner() (gas: 87208) +FunctionsSubscriptions_RemoveConsumer:test_RemoveConsumer_RevertIfPaused() (gas: 18049) +FunctionsSubscriptions_RemoveConsumer:test_RemoveConsumer_RevertIfPendingRequests() (gas: 191221) FunctionsSubscriptions_RemoveConsumer:test_RemoveConsumer_Success() (gas: 41979) -FunctionsSubscriptions_SetFlags:test_SetFlags_RevertIfNoSubscription() (gas: 12847) -FunctionsSubscriptions_SetFlags:test_SetFlags_RevertIfNotOwner() (gas: 15640) -FunctionsSubscriptions_SetFlags:test_SetFlags_Success() (gas: 35549) -FunctionsSubscriptions_TimeoutRequests:test_TimeoutRequests_RevertIfPaused() (gas: 25910) -FunctionsSubscriptions_TimeoutRequests:test_TimeoutRequests_RevertIfTimeoutNotExceeded() (gas: 25239) -FunctionsSubscriptions_TimeoutRequests:test_TimeoutRequests_RevertInvalidRequest() (gas: 28220) -FunctionsSubscriptions_TimeoutRequests:test_TimeoutRequests_Success() (gas: 57752) -FunctionsSubscriptions_createSubscription:test_CreateSubscription_RevertIfNotAllowedSender() (gas: 26368) -FunctionsSubscriptions_createSubscription:test_CreateSubscription_RevertIfPaused() (gas: 15714) -FunctionsSubscriptions_createSubscription:test_CreateSubscription_Success() (gas: 152510) +FunctionsSubscriptions_SetFlags:test_SetFlags_RevertIfNoSubscription() (gas: 12891) +FunctionsSubscriptions_SetFlags:test_SetFlags_RevertIfNotOwner() (gas: 15684) +FunctionsSubscriptions_SetFlags:test_SetFlags_Success() (gas: 35594) +FunctionsSubscriptions_TimeoutRequests:test_TimeoutRequests_RevertIfPaused() (gas: 25955) +FunctionsSubscriptions_TimeoutRequests:test_TimeoutRequests_RevertIfTimeoutNotExceeded() (gas: 25261) +FunctionsSubscriptions_TimeoutRequests:test_TimeoutRequests_RevertInvalidRequest() (gas: 28242) +FunctionsSubscriptions_TimeoutRequests:test_TimeoutRequests_Success() (gas: 57754) +FunctionsSubscriptions_createSubscription:test_CreateSubscription_RevertIfNotAllowedSender() (gas: 26390) +FunctionsSubscriptions_createSubscription:test_CreateSubscription_RevertIfPaused() (gas: 15759) +FunctionsSubscriptions_createSubscription:test_CreateSubscription_Success() (gas: 152576) FunctionsTermsOfServiceAllowList_AcceptTermsOfService:testAcceptTermsOfService_InvalidSigner_vuln() (gas: 94815) FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_RevertIfAcceptorIsNotSender() (gas: 25837) FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_RevertIfBlockedSender() (gas: 44348) FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_RevertIfInvalidSigner() (gas: 23597) FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_RevertIfRecipientContractIsNotSender() (gas: 1866530) FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_RevertIfRecipientIsNotSender() (gas: 26003) -FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_SuccessIfAcceptingForContract() (gas: 1946591) +FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_SuccessIfAcceptingForContract() (gas: 1946547) FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_SuccessIfAcceptingForSelf() (gas: 104851) FunctionsTermsOfServiceAllowList_BlockSender:test_BlockSender_RevertIfNotOwner() (gas: 15469) FunctionsTermsOfServiceAllowList_BlockSender:test_BlockSender_Success() (gas: 51794) @@ -188,8 +206,8 @@ FunctionsTermsOfServiceAllowList_UnblockSender:test_UnblockSender_Success() (gas FunctionsTermsOfServiceAllowList_UpdateConfig:test_UpdateConfig_RevertIfNotOwner() (gas: 13727) FunctionsTermsOfServiceAllowList_UpdateConfig:test_UpdateConfig_Success() (gas: 22073) Gas_AcceptTermsOfService:test_AcceptTermsOfService_Gas() (gas: 84675) -Gas_AddConsumer:test_AddConsumer_Gas() (gas: 79067) -Gas_CreateSubscription:test_CreateSubscription_Gas() (gas: 73353) -Gas_FundSubscription:test_FundSubscription_Gas() (gas: 38501) -Gas_SendRequest:test_SendRequest_MaximumGas() (gas: 964209) -Gas_SendRequest:test_SendRequest_MinimumGas() (gas: 156929) \ No newline at end of file +Gas_AddConsumer:test_AddConsumer_Gas() (gas: 79087) +Gas_CreateSubscription:test_CreateSubscription_Gas() (gas: 73375) +Gas_FundSubscription:test_FundSubscription_Gas() (gas: 38546) +Gas_SendRequest:test_SendRequest_MaximumGas() (gas: 964214) +Gas_SendRequest:test_SendRequest_MinimumGas() (gas: 156934) \ No newline at end of file diff --git a/contracts/package.json b/contracts/package.json index 6c902926c2b..46b47440a6e 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -18,7 +18,7 @@ "prepublishOnly": "pnpm compile && ./scripts/prepublish_generate_abi_folder", "publish-beta": "pnpm publish --tag beta", "publish-prod": "npm dist-tag add @chainlink/contracts@0.8.0 latest", - "solhint": "solhint --max-warnings 442 \"./src/v0.8/**/*.sol\"" + "solhint": "solhint --max-warnings 377 \"./src/v0.8/**/*.sol\"" }, "files": [ "src/v0.8", @@ -40,12 +40,12 @@ "@ethersproject/random": "~5.7.0", "@nomicfoundation/hardhat-network-helpers": "^1.0.9", "@nomiclabs/hardhat-ethers": "^2.2.3", - "@nomiclabs/hardhat-etherscan": "^3.1.0", + "@nomiclabs/hardhat-etherscan": "^3.1.7", "@nomiclabs/hardhat-waffle": "2.0.6", "@openzeppelin/hardhat-upgrades": "1.28.0", "@openzeppelin/test-helpers": "^0.5.16", "@typechain/ethers-v5": "^7.2.0", - "@typechain/hardhat": "^5.0.0", + "@typechain/hardhat": "^7.0.0", "@types/cbor": "5.0.1", "@types/chai": "^4.3.9", "@types/debug": "^4.1.10", @@ -55,6 +55,7 @@ "@typescript-eslint/eslint-plugin": "^6.8.0", "@typescript-eslint/parser": "^6.8.0", "abi-to-sol": "^0.6.6", + "cbor": "^5.2.0", "chai": "^4.3.10", "debug": "^4.3.4", "eslint": "^8.51.0", @@ -64,8 +65,8 @@ "ethereum-waffle": "^3.4.4", "ethers": "~5.7.2", "hardhat": "~2.18.1", - "hardhat-abi-exporter": "^2.2.1", - "hardhat-contract-sizer": "^2.5.1", + "hardhat-abi-exporter": "^2.10.1", + "hardhat-contract-sizer": "^2.10.0", "hardhat-gas-reporter": "^1.0.9", "hardhat-ignore-warnings": "^0.2.6", "istanbul": "^0.4.5", diff --git a/contracts/pnpm-lock.yaml b/contracts/pnpm-lock.yaml index 9d54cfa7743..2b6082d656a 100644 --- a/contracts/pnpm-lock.yaml +++ b/contracts/pnpm-lock.yaml @@ -44,14 +44,14 @@ devDependencies: specifier: ^2.2.3 version: 2.2.3(ethers@5.7.2)(hardhat@2.18.1) '@nomiclabs/hardhat-etherscan': - specifier: ^3.1.0 - version: 3.1.0(hardhat@2.18.1) + specifier: ^3.1.7 + version: 3.1.7(hardhat@2.18.1) '@nomiclabs/hardhat-waffle': specifier: 2.0.6 version: 2.0.6(@nomiclabs/hardhat-ethers@2.2.3)(@types/sinon-chai@3.2.8)(ethereum-waffle@3.4.4)(ethers@5.7.2)(hardhat@2.18.1) '@openzeppelin/hardhat-upgrades': specifier: 1.28.0 - version: 1.28.0(@nomiclabs/hardhat-ethers@2.2.3)(@nomiclabs/hardhat-etherscan@3.1.0)(ethers@5.7.2)(hardhat@2.18.1) + version: 1.28.0(@nomiclabs/hardhat-ethers@2.2.3)(@nomiclabs/hardhat-etherscan@3.1.7)(ethers@5.7.2)(hardhat@2.18.1) '@openzeppelin/test-helpers': specifier: ^0.5.16 version: 0.5.16(bn.js@4.12.0) @@ -59,8 +59,8 @@ devDependencies: specifier: ^7.2.0 version: 7.2.0(@ethersproject/abi@5.7.0)(@ethersproject/bytes@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typechain@8.2.0)(typescript@5.2.2) '@typechain/hardhat': - specifier: ^5.0.0 - version: 5.0.0(hardhat@2.18.1)(lodash@4.17.21)(typechain@8.2.0) + specifier: ^7.0.0 + version: 7.0.0(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(@typechain/ethers-v5@7.2.0)(ethers@5.7.2)(hardhat@2.18.1)(typechain@8.2.0) '@types/cbor': specifier: 5.0.1 version: 5.0.1 @@ -88,6 +88,9 @@ devDependencies: abi-to-sol: specifier: ^0.6.6 version: 0.6.6 + cbor: + specifier: ^5.2.0 + version: 5.2.0 chai: specifier: ^4.3.10 version: 4.3.10 @@ -116,14 +119,14 @@ devDependencies: specifier: ~2.18.1 version: 2.18.1(ts-node@10.9.1)(typescript@5.2.2) hardhat-abi-exporter: - specifier: ^2.2.1 - version: 2.2.1(hardhat@2.18.1) + specifier: ^2.10.1 + version: 2.10.1(hardhat@2.18.1) hardhat-contract-sizer: - specifier: ^2.5.1 - version: 2.5.1(hardhat@2.18.1) + specifier: ^2.10.0 + version: 2.10.0(hardhat@2.18.1) hardhat-gas-reporter: specifier: ^1.0.9 - version: 1.0.9(hardhat@2.18.1) + version: 1.0.9(debug@4.3.4)(hardhat@2.18.1) hardhat-ignore-warnings: specifier: ^0.2.6 version: 0.2.9 @@ -1159,22 +1162,22 @@ packages: hardhat: 2.18.1(ts-node@10.9.1)(typescript@5.2.2) dev: true - /@nomiclabs/hardhat-etherscan@3.1.0(hardhat@2.18.1): - resolution: {integrity: sha512-JroYgfN1AlYFkQTQ3nRwFi4o8NtZF7K/qFR2dxDUgHbCtIagkUseca9L4E/D2ScUm4XT40+8PbCdqZi+XmHyQA==} + /@nomiclabs/hardhat-etherscan@3.1.7(hardhat@2.18.1): + resolution: {integrity: sha512-tZ3TvSgpvsQ6B6OGmo1/Au6u8BrAkvs1mIC/eURA3xgIfznUZBhmpne8hv7BXUzw9xNL3fXdpOYgOQlVMTcoHQ==} peerDependencies: hardhat: ^2.0.4 dependencies: '@ethersproject/abi': 5.7.0 '@ethersproject/address': 5.7.0 - cbor: 5.2.0 + cbor: 8.1.0 chalk: 2.4.2 debug: 4.3.4(supports-color@8.1.1) fs-extra: 7.0.1 hardhat: 2.18.1(ts-node@10.9.1)(typescript@5.2.2) lodash: 4.17.21 semver: 6.3.0 - table: 6.8.0 - undici: 5.10.0 + table: 6.8.1 + undici: 5.19.1 transitivePeerDependencies: - supports-color dev: true @@ -1223,7 +1226,7 @@ packages: - encoding dev: true - /@openzeppelin/hardhat-upgrades@1.28.0(@nomiclabs/hardhat-ethers@2.2.3)(@nomiclabs/hardhat-etherscan@3.1.0)(ethers@5.7.2)(hardhat@2.18.1): + /@openzeppelin/hardhat-upgrades@1.28.0(@nomiclabs/hardhat-ethers@2.2.3)(@nomiclabs/hardhat-etherscan@3.1.7)(ethers@5.7.2)(hardhat@2.18.1): resolution: {integrity: sha512-7sb/Jf+X+uIufOBnmHR0FJVWuxEs2lpxjJnLNN6eCJCP8nD0v+Ot5lTOW2Qb/GFnh+fLvJtEkhkowz4ZQ57+zQ==} hasBin: true peerDependencies: @@ -1237,7 +1240,7 @@ packages: optional: true dependencies: '@nomiclabs/hardhat-ethers': 2.2.3(ethers@5.7.2)(hardhat@2.18.1) - '@nomiclabs/hardhat-etherscan': 3.1.0(hardhat@2.18.1) + '@nomiclabs/hardhat-etherscan': 3.1.7(hardhat@2.18.1) '@openzeppelin/defender-base-client': 1.49.0(debug@4.3.4) '@openzeppelin/platform-deploy-client': 0.8.0(debug@4.3.4) '@openzeppelin/upgrades-core': 1.30.1 @@ -1645,16 +1648,22 @@ packages: typescript: 5.2.2 dev: true - /@typechain/hardhat@5.0.0(hardhat@2.18.1)(lodash@4.17.21)(typechain@8.2.0): - resolution: {integrity: sha512-Pqk+KdREbU6Uk3en1Z5caQpWt2bKU+KTOi+6dZwcIXJpF1wKoAwF1cbaYSQEzrG4BSUTM1rHQhW5JHSfeqpsAg==} + /@typechain/hardhat@7.0.0(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(@typechain/ethers-v5@7.2.0)(ethers@5.7.2)(hardhat@2.18.1)(typechain@8.2.0): + resolution: {integrity: sha512-XB79i5ewg9Met7gMVGfgVkmypicbnI25T5clJBEooMoW2161p4zvKFpoS2O+lBppQyMrPIZkdvl2M3LMDayVcA==} peerDependencies: - hardhat: ^2.0.10 - lodash: ^4.17.15 - typechain: ^7.0.0 + '@ethersproject/abi': ^5.4.7 + '@ethersproject/providers': ^5.4.7 + '@typechain/ethers-v5': ^11.0.0 + ethers: ^5.4.7 + hardhat: ^2.9.9 + typechain: ^8.2.0 dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/providers': 5.7.2 + '@typechain/ethers-v5': 7.2.0(@ethersproject/abi@5.7.0)(@ethersproject/bytes@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typechain@8.2.0)(typescript@5.2.2) + ethers: 5.7.2 fs-extra: 9.1.0 hardhat: 2.18.1(ts-node@10.9.1)(typescript@5.2.2) - lodash: 4.17.21 typechain: 8.2.0(typescript@5.2.2) dev: true @@ -2147,11 +2156,6 @@ packages: dev: true optional: true - /ansi-colors@3.2.3: - resolution: {integrity: sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==} - engines: {node: '>=6'} - dev: true - /ansi-colors@3.2.4: resolution: {integrity: sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA==} engines: {node: '>=6'} @@ -2184,11 +2188,6 @@ packages: engines: {node: '>=4'} dev: true - /ansi-regex@4.1.1: - resolution: {integrity: sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==} - engines: {node: '>=6'} - dev: true - /ansi-regex@5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} @@ -2321,17 +2320,6 @@ packages: get-intrinsic: 1.2.1 dev: true - /array.prototype.reduce@1.0.4: - resolution: {integrity: sha512-WnM+AjG/DvLRLo4DDl+r+SvCzYtD2Jd9oeBYMcEaI7t3fFrHY9M53/wdLcTvmZNQ70IU6Htj0emFkZ5TS+lrdw==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.1.4 - es-abstract: 1.20.3 - es-array-method-boxes-properly: 1.0.0 - is-string: 1.0.7 - dev: true - /array.prototype.reduce@1.0.6: resolution: {integrity: sha512-UW+Mz8LG/sPSU8jRDCjVr6J/ZKAGpHfwrZ6kWTG5qCxIEiXdVshqGnu5vEZA8S1y6X4aCSbQZ0/EEsfvEvBiSg==} engines: {node: '>= 0.4'} @@ -3451,11 +3439,6 @@ packages: engines: {node: '>=4'} dev: true - /camelcase@5.3.1: - resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==} - engines: {node: '>=6'} - dev: true - /camelcase@6.3.0: resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} engines: {node: '>=10'} @@ -3487,6 +3470,13 @@ packages: nofilter: 1.0.4 dev: true + /cbor@8.1.0: + resolution: {integrity: sha512-DwGjNW9omn6EwP70aXsn7FQJx5kO12tX0bZkaTjzdVFM6/7nhA4t0EENocKGx6D2Bch9PE2KzCUf5SceBdeijg==} + engines: {node: '>=12.19'} + dependencies: + nofilter: 3.1.0 + dev: true + /cbor@9.0.1: resolution: {integrity: sha512-/TQOWyamDxvVIv+DY9cOLNuABkoyz8K/F3QE56539pGVYohx0+MEA1f4lChFTX79dBTBS7R1PF6ovH7G+VtBfQ==} engines: {node: '>=16'} @@ -3606,21 +3596,6 @@ packages: parse5-htmlparser2-tree-adapter: 7.0.0 dev: true - /chokidar@3.3.0: - resolution: {integrity: sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A==} - engines: {node: '>= 8.10.0'} - dependencies: - anymatch: 3.1.2 - braces: 3.0.2 - glob-parent: 5.1.2 - is-binary-path: 2.1.0 - is-glob: 4.0.3 - normalize-path: 3.0.0 - readdirp: 3.2.0 - optionalDependencies: - fsevents: 2.1.3 - dev: true - /chokidar@3.5.3: resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} engines: {node: '>= 8.10.0'} @@ -3724,14 +3699,6 @@ packages: wrap-ansi: 2.1.0 dev: true - /cliui@5.0.0: - resolution: {integrity: sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==} - dependencies: - string-width: 3.1.0 - strip-ansi: 5.2.0 - wrap-ansi: 5.1.0 - dev: true - /cliui@7.0.4: resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==} dependencies: @@ -4120,7 +4087,7 @@ packages: ms: 2.0.0 dev: true - /debug@3.2.6(supports-color@6.0.0): + /debug@3.2.6: resolution: {integrity: sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==} deprecated: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797) peerDependencies: @@ -4130,7 +4097,6 @@ packages: optional: true dependencies: ms: 2.1.3 - supports-color: 6.0.0 dev: true /debug@3.2.7: @@ -4324,6 +4290,17 @@ packages: engines: {node: '>=0.4.0'} dev: true + /delete-empty@3.0.0: + resolution: {integrity: sha512-ZUyiwo76W+DYnKsL3Kim6M/UOavPdBJgDYWOmuQhYaZvJH0AXAHbUNyEDtRbBra8wqqr686+63/0azfEk1ebUQ==} + engines: {node: '>=10'} + hasBin: true + dependencies: + ansi-colors: 4.1.3 + minimist: 1.2.8 + path-starts-with: 2.0.1 + rimraf: 2.7.1 + dev: true + /depd@1.1.2: resolution: {integrity: sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==} engines: {node: '>= 0.6'} @@ -4371,11 +4348,6 @@ packages: - supports-color dev: true - /diff@3.5.0: - resolution: {integrity: sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==} - engines: {node: '>=0.3.1'} - dev: true - /diff@4.0.2: resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} engines: {node: '>=0.3.1'} @@ -4491,10 +4463,6 @@ packages: minimalistic-assert: 1.0.1 minimalistic-crypto-utils: 1.0.1 - /emoji-regex@7.0.3: - resolution: {integrity: sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==} - dev: true - /emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} dev: true @@ -4558,36 +4526,6 @@ packages: is-arrayish: 0.2.1 dev: true - /es-abstract@1.20.3: - resolution: {integrity: sha512-AyrnaKVpMzljIdwjzrj+LxGmj8ik2LckwXacHqrJJ/jxz6dDDBcZ7I7nlHM0FvEW8MfbWJwOd+yT2XzYW49Frw==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - es-to-primitive: 1.2.1 - function-bind: 1.1.1 - function.prototype.name: 1.1.5 - get-intrinsic: 1.1.3 - get-symbol-description: 1.0.0 - has: 1.0.3 - has-property-descriptors: 1.0.0 - has-symbols: 1.0.3 - internal-slot: 1.0.3 - is-callable: 1.2.7 - is-negative-zero: 2.0.2 - is-regex: 1.1.4 - is-shared-array-buffer: 1.0.2 - is-string: 1.0.7 - is-weakref: 1.0.2 - object-inspect: 1.12.2 - object-keys: 1.1.1 - object.assign: 4.1.4 - regexp.prototype.flags: 1.4.3 - safe-regex-test: 1.0.0 - string.prototype.trimend: 1.0.5 - string.prototype.trimstart: 1.0.5 - unbox-primitive: 1.0.2 - dev: true - /es-abstract@1.22.2: resolution: {integrity: sha512-YoxfFcDmhjOgWPWsV13+2RNjq1F6UQnfs+8TftwNqtzlmFzEXvlUwdrNrYeaizfjQzRMxkZ6ElWMOJIFKdVqwA==} engines: {node: '>= 0.4'} @@ -4889,29 +4827,31 @@ packages: js-sha3: 0.5.7 dev: true - /eth-gas-reporter@0.2.25: - resolution: {integrity: sha512-1fRgyE4xUB8SoqLgN3eDfpDfwEfRxh2Sz1b7wzFbyQA+9TekMmvSjjoRu9SKcSVyK+vLkLIsVbJDsTWjw195OQ==} + /eth-gas-reporter@0.2.27(debug@4.3.4): + resolution: {integrity: sha512-femhvoAM7wL0GcI8ozTdxfuBtBFJ9qsyIAsmKVjlWAHUbdnnXHt+lKzz/kmldM5lA9jLuNHGwuIxorNpLbR1Zw==} peerDependencies: '@codechecks/client': ^0.1.0 peerDependenciesMeta: '@codechecks/client': optional: true dependencies: - '@ethersproject/abi': 5.7.0 '@solidity-parser/parser': 0.14.3 + axios: 1.5.1(debug@4.3.4) cli-table3: 0.5.1 colors: 1.4.0 ethereum-cryptography: 1.1.2 - ethers: 4.0.49 + ethers: 5.7.2 fs-readdir-recursive: 1.1.0 lodash: 4.17.21 markdown-table: 1.1.3 - mocha: 7.2.0 + mocha: 10.2.0 req-cwd: 2.0.0 - request: 2.88.2 - request-promise-native: 1.0.9(request@2.88.2) sha1: 1.1.1 sync-request: 6.1.0 + transitivePeerDependencies: + - bufferutil + - debug + - utf-8-validate dev: true /eth-json-rpc-infura@3.2.1: @@ -5627,13 +5567,6 @@ packages: locate-path: 2.0.0 dev: true - /find-up@3.0.0: - resolution: {integrity: sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==} - engines: {node: '>=6'} - dependencies: - locate-path: 3.0.0 - dev: true - /find-up@4.1.0: resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} engines: {node: '>=8'} @@ -5673,13 +5606,6 @@ packages: rimraf: 3.0.2 dev: true - /flat@4.1.1: - resolution: {integrity: sha512-FmTtBsHskrU6FJ2VxCnsDb84wu9zhmO3cUX2kGFb5tuwhfXxGciiT0oRY+cck35QmG+NmGh5eLz6lLCpWTqwpA==} - hasBin: true - dependencies: - is-buffer: 2.0.5 - dev: true - /flat@5.0.2: resolution: {integrity: sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==} hasBin: true @@ -5835,15 +5761,6 @@ packages: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} dev: true - /fsevents@2.1.3: - resolution: {integrity: sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==} - engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} - os: [darwin] - deprecated: '"Please update to latest v2.3 or v2.2"' - requiresBuild: true - dev: true - optional: true - /fsevents@2.3.2: resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -5856,16 +5773,6 @@ packages: resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} dev: true - /function.prototype.name@1.1.5: - resolution: {integrity: sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.1.4 - es-abstract: 1.20.3 - functions-have-names: 1.2.3 - dev: true - /function.prototype.name@1.1.6: resolution: {integrity: sha512-Z5kx79swU5P27WEayXM1tBi5Ze/lbIyiNgU3qyXUOf9b2rgXYyF9Dy9Cx+IQv/Lc8WCG6L82zwUPpSS9hGehIg==} engines: {node: '>= 0.4'} @@ -5894,7 +5801,7 @@ packages: bip39: 2.5.0 cachedown: 1.0.0 clone: 2.1.2 - debug: 3.2.6(supports-color@6.0.0) + debug: 3.2.6 encoding-down: 5.0.4 eth-sig-util: 3.0.0 ethereumjs-abi: 0.6.8 @@ -5907,7 +5814,7 @@ packages: heap: 0.2.6 level-sublevel: 6.6.4 levelup: 3.1.1 - lodash: 4.17.20 + lodash: 4.17.21 lru-cache: 5.1.1 merkle-patricia-tree: 3.0.0 patch-package: 6.2.2 @@ -6039,17 +5946,6 @@ packages: path-is-absolute: 1.0.1 dev: true - /glob@7.1.3: - resolution: {integrity: sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==} - dependencies: - fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 3.1.2 - once: 1.4.0 - path-is-absolute: 1.0.1 - dev: true - /glob@7.1.7: resolution: {integrity: sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==} dependencies: @@ -6241,11 +6137,6 @@ packages: resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} dev: true - /growl@1.10.5: - resolution: {integrity: sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==} - engines: {node: '>=4.x'} - dev: true - /handlebars@4.7.7: resolution: {integrity: sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==} engines: {node: '>=0.4.7'} @@ -6273,36 +6164,42 @@ packages: har-schema: 2.0.0 dev: true - /hardhat-abi-exporter@2.2.1(hardhat@2.18.1): - resolution: {integrity: sha512-Um7+RPvJEj+OqWjPoPKlTTkO1Akr10pqpgMk8Pw2jz2wrGv5XQBGNW5aQgGVDUosYktUIWDaEhcwwFKbFsir9A==} - engines: {node: '>=12.10.0'} + /hardhat-abi-exporter@2.10.1(hardhat@2.18.1): + resolution: {integrity: sha512-X8GRxUTtebMAd2k4fcPyVnCdPa6dYK4lBsrwzKP5yiSq4i+WadWPIumaLfce53TUf/o2TnLpLOduyO1ylE2NHQ==} + engines: {node: '>=14.14.0'} peerDependencies: hardhat: ^2.0.0 dependencies: + '@ethersproject/abi': 5.7.0 + delete-empty: 3.0.0 hardhat: 2.18.1(ts-node@10.9.1)(typescript@5.2.2) dev: true - /hardhat-contract-sizer@2.5.1(hardhat@2.18.1): - resolution: {integrity: sha512-28yRb73e30aBVaZOOHTlHZFIdIasA/iFunIehrUviIJTubvdQjtSiQUo2wexHFtt71mQeMPP8qjw2sdbgatDnQ==} + /hardhat-contract-sizer@2.10.0(hardhat@2.18.1): + resolution: {integrity: sha512-QiinUgBD5MqJZJh1hl1jc9dNnpJg7eE/w4/4GEnrcmZJJTDbVFNe3+/3Ep24XqISSkYxRz36czcPHKHd/a0dwA==} peerDependencies: hardhat: ^2.0.0 dependencies: chalk: 4.1.2 cli-table3: 0.6.3 hardhat: 2.18.1(ts-node@10.9.1)(typescript@5.2.2) + strip-ansi: 6.0.1 dev: true - /hardhat-gas-reporter@1.0.9(hardhat@2.18.1): + /hardhat-gas-reporter@1.0.9(debug@4.3.4)(hardhat@2.18.1): resolution: {integrity: sha512-INN26G3EW43adGKBNzYWOlI3+rlLnasXTwW79YNnUhXPDa+yHESgt639dJEs37gCjhkbNKcRRJnomXEuMFBXJg==} peerDependencies: hardhat: ^2.0.2 dependencies: array-uniq: 1.0.3 - eth-gas-reporter: 0.2.25 + eth-gas-reporter: 0.2.27(debug@4.3.4) hardhat: 2.18.1(ts-node@10.9.1)(typescript@5.2.2) sha1: 1.1.1 transitivePeerDependencies: - '@codechecks/client' + - bufferutil + - debug + - utf-8-validate dev: true /hardhat-ignore-warnings@0.2.9: @@ -6618,7 +6515,7 @@ packages: engines: {node: '>=0.8', npm: '>=1.3.7'} dependencies: assert-plus: 1.0.0 - jsprim: 1.4.1 + jsprim: 1.4.2 sshpk: 1.16.1 dev: true @@ -6729,15 +6626,6 @@ packages: resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} dev: true - /internal-slot@1.0.3: - resolution: {integrity: sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA==} - engines: {node: '>= 0.4'} - dependencies: - get-intrinsic: 1.1.3 - has: 1.0.3 - side-channel: 1.0.4 - dev: true - /internal-slot@1.0.5: resolution: {integrity: sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ==} engines: {node: '>= 0.4'} @@ -6848,12 +6736,6 @@ packages: ci-info: 2.0.0 dev: true - /is-core-module@2.10.0: - resolution: {integrity: sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg==} - dependencies: - has: 1.0.3 - dev: true - /is-core-module@2.13.0: resolution: {integrity: sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==} dependencies: @@ -7238,14 +7120,6 @@ packages: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} dev: true - /js-yaml@3.13.1: - resolution: {integrity: sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==} - hasBin: true - dependencies: - argparse: 1.0.10 - esprima: 4.0.1 - dev: true - /js-yaml@3.14.1: resolution: {integrity: sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==} hasBin: true @@ -7319,8 +7193,8 @@ packages: resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==} dev: true - /json-schema@0.2.3: - resolution: {integrity: sha512-a3xHnILGMtk+hDOqNwHzF6e2fNbiMrXZvxKQiEv2MlgQP+pjIOzqAmKYD2mDpXYE/44M7g+n9p2bKkYWDUcXCQ==} + /json-schema@0.4.0: + resolution: {integrity: sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==} dev: true /json-stable-stringify-without-jsonify@1.0.1: @@ -7383,13 +7257,13 @@ packages: resolution: {integrity: sha512-/YgW6pRMr6M7C+4o8kS+B/2myEpHCrxO4PEWnqJNBFMjn7EWXqlQ4tGwL6xTHeRplwuZmcAncdvfOad1nT2yMw==} dev: true - /jsprim@1.4.1: - resolution: {integrity: sha512-4Dj8Rf+fQ+/Pn7C5qeEX02op1WfOss3PKTE9Nsop3Dx+6UPxlm1dr/og7o2cRa5hNN07CACr4NFzRLtj/rjWog==} - engines: {'0': node >=0.6.0} + /jsprim@1.4.2: + resolution: {integrity: sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==} + engines: {node: '>=0.6.0'} dependencies: assert-plus: 1.0.0 extsprintf: 1.3.0 - json-schema: 0.2.3 + json-schema: 0.4.0 verror: 1.10.0 dev: true @@ -7650,14 +7524,6 @@ packages: path-exists: 3.0.0 dev: true - /locate-path@3.0.0: - resolution: {integrity: sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==} - engines: {node: '>=6'} - dependencies: - p-locate: 3.0.0 - path-exists: 3.0.0 - dev: true - /locate-path@5.0.0: resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} engines: {node: '>=8'} @@ -7704,13 +7570,6 @@ packages: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} dev: true - /log-symbols@3.0.0: - resolution: {integrity: sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==} - engines: {node: '>=8'} - dependencies: - chalk: 2.4.2 - dev: true - /log-symbols@4.1.0: resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==} engines: {node: '>=10'} @@ -8006,12 +7865,6 @@ packages: /minimalistic-crypto-utils@1.0.1: resolution: {integrity: sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==} - /minimatch@3.0.4: - resolution: {integrity: sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==} - dependencies: - brace-expansion: 1.1.11 - dev: true - /minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} dependencies: @@ -8072,13 +7925,6 @@ packages: mkdirp: 1.0.4 dev: true - /mkdirp@0.5.5: - resolution: {integrity: sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==} - hasBin: true - dependencies: - minimist: 1.2.6 - dev: true - /mkdirp@0.5.6: resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} hasBin: true @@ -8126,37 +7972,6 @@ packages: yargs-unparser: 2.0.0 dev: true - /mocha@7.2.0: - resolution: {integrity: sha512-O9CIypScywTVpNaRrCAgoUnJgozpIofjKUYmJhiCIJMiuYnLI6otcb1/kpW9/n/tJODHGZ7i8aLQoDVsMtOKQQ==} - engines: {node: '>= 8.10.0'} - hasBin: true - dependencies: - ansi-colors: 3.2.3 - browser-stdout: 1.3.1 - chokidar: 3.3.0 - debug: 3.2.6(supports-color@6.0.0) - diff: 3.5.0 - escape-string-regexp: 1.0.5 - find-up: 3.0.0 - glob: 7.1.3 - growl: 1.10.5 - he: 1.2.0 - js-yaml: 3.13.1 - log-symbols: 3.0.0 - minimatch: 3.0.4 - mkdirp: 0.5.5 - ms: 2.1.1 - node-environment-flags: 1.0.6 - object.assign: 4.1.0 - strip-json-comments: 2.0.1 - supports-color: 6.0.0 - which: 1.3.1 - wide-align: 1.1.3 - yargs: 13.3.2 - yargs-parser: 13.1.2 - yargs-unparser: 1.6.0 - dev: true - /mock-fs@4.12.0: resolution: {integrity: sha512-/P/HtrlvBxY4o/PzXY9cCNBrdylDNxg7gnrv2sMNxj+UJ2m8jSpl0/A6fuJeNAWr99ZvGWH8XCbE0vmnM5KupQ==} requiresBuild: true @@ -8325,13 +8140,6 @@ packages: lodash: 4.17.21 dev: true - /node-environment-flags@1.0.6: - resolution: {integrity: sha512-5Evy2epuL+6TM0lCQGpFIj6KwiEsGh1SrHUhTbNX+sLbBtjidPZFAnVK9y5yU1+h//RitLbRHTIMyxQPtxMdHw==} - dependencies: - object.getownpropertydescriptors: 2.1.4 - semver: 5.7.1 - dev: true - /node-fetch@1.7.3: resolution: {integrity: sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==} dependencies: @@ -8384,7 +8192,7 @@ packages: resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} dependencies: hosted-git-info: 2.8.9 - resolve: 1.22.1 + resolve: 1.22.8 semver: 5.7.1 validate-npm-package-license: 3.0.4 dev: true @@ -8492,16 +8300,6 @@ packages: isobject: 3.0.1 dev: true - /object.assign@4.1.0: - resolution: {integrity: sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==} - engines: {node: '>= 0.4'} - dependencies: - define-properties: 1.1.4 - function-bind: 1.1.1 - has-symbols: 1.0.3 - object-keys: 1.1.1 - dev: true - /object.assign@4.1.4: resolution: {integrity: sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==} engines: {node: '>= 0.4'} @@ -8512,16 +8310,6 @@ packages: object-keys: 1.1.1 dev: true - /object.getownpropertydescriptors@2.1.4: - resolution: {integrity: sha512-sccv3L/pMModT6dJAYF3fzGMVcb38ysQ0tEE6ixv2yXJDtEIPph268OlAdJj5/qZMZDq2g/jqvwppt36uS/uQQ==} - engines: {node: '>= 0.8'} - dependencies: - array.prototype.reduce: 1.0.4 - call-bind: 1.0.2 - define-properties: 1.1.4 - es-abstract: 1.20.3 - dev: true - /object.getownpropertydescriptors@2.1.7: resolution: {integrity: sha512-PrJz0C2xJ58FNn11XV2lr4Jt5Gzl94qpy9Lu0JlfEj14z88sqbSBJCBEzdlNUCzY2gburhbrwOZ5BHCmuNUy0g==} engines: {node: '>= 0.8'} @@ -8696,13 +8484,6 @@ packages: p-limit: 1.3.0 dev: true - /p-locate@3.0.0: - resolution: {integrity: sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==} - engines: {node: '>=6'} - dependencies: - p-limit: 2.3.0 - dev: true - /p-locate@4.1.0: resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} engines: {node: '>=8'} @@ -8916,6 +8697,11 @@ packages: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} dev: true + /path-starts-with@2.0.1: + resolution: {integrity: sha512-wZ3AeiRBRlNwkdUxvBANh0+esnt38DLffHDujZyRHkqkaKHTglnY2EP5UX3b8rdeiSutgO4y9NEJwXezNP5vHg==} + engines: {node: '>=8'} + dev: true + /path-to-regexp@0.1.7: resolution: {integrity: sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==} requiresBuild: true @@ -9350,13 +9136,6 @@ packages: util-deprecate: 1.0.2 dev: true - /readdirp@3.2.0: - resolution: {integrity: sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==} - engines: {node: '>= 8'} - dependencies: - picomatch: 2.3.1 - dev: true - /readdirp@3.6.0: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} @@ -9375,7 +9154,7 @@ packages: resolution: {integrity: sha512-nRCcW9Sj7NuZwa2XvH9co8NPeXUBhZP7CRKJtU+cS6PW9FpCIFoI5ib0NT1ZrbNuPoRy0ylyCaUL8Gih4LSyFg==} engines: {node: '>=0.10.0'} dependencies: - minimatch: 3.0.4 + minimatch: 3.1.2 dev: true /reduce-flatten@2.0.0: @@ -9479,29 +9258,6 @@ packages: resolve-from: 3.0.0 dev: true - /request-promise-core@1.1.4(request@2.88.2): - resolution: {integrity: sha512-TTbAfBBRdWD7aNNOoVOBH4pN/KigV6LyapYNNlAPA8JwbovRti1E88m3sYAwsLi5ryhPKsE9APwnjFTgdUjTpw==} - engines: {node: '>=0.10.0'} - peerDependencies: - request: ^2.34 - dependencies: - lodash: 4.17.21 - request: 2.88.2 - dev: true - - /request-promise-native@1.0.9(request@2.88.2): - resolution: {integrity: sha512-wcW+sIUiWnKgNY0dqCpOZkUbF/I+YPi+f09JZIDa39Ec+q82CpSYniDp+ISgTTbKmnpJWASeJBPZmoxH84wt3g==} - engines: {node: '>=0.12.0'} - deprecated: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142 - peerDependencies: - request: ^2.34 - dependencies: - request: 2.88.2 - request-promise-core: 1.1.4(request@2.88.2) - stealthy-require: 1.1.1 - tough-cookie: 2.5.0 - dev: true - /request@2.88.2: resolution: {integrity: sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==} engines: {node: '>= 6'} @@ -9548,10 +9304,6 @@ packages: resolution: {integrity: sha512-IqSUtOVP4ksd1C/ej5zeEh/BIP2ajqpn8c5x+q99gvcIG/Qf0cud5raVnE/Dwd0ua9TXYDoDc0RE5hBSdz22Ug==} dev: true - /require-main-filename@2.0.0: - resolution: {integrity: sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==} - dev: true - /resolve-alpn@1.2.1: resolution: {integrity: sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==} dev: true @@ -9581,15 +9333,6 @@ packages: path-parse: 1.0.7 dev: true - /resolve@1.22.1: - resolution: {integrity: sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==} - hasBin: true - dependencies: - is-core-module: 2.10.0 - path-parse: 1.0.7 - supports-preserve-symlinks-flag: 1.0.0 - dev: true - /resolve@1.22.8: resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==} hasBin: true @@ -9978,8 +9721,8 @@ packages: engines: {node: '>=8'} dev: true - /shelljs@0.8.3: - resolution: {integrity: sha512-fc0BKlAWiLpwZljmOvAOTE/gXawtCoNrP5oaY7KIaQbbyHeQVg01pSEuEGvGh3HEdBU4baCD7wQBwADmM/7f7A==} + /shelljs@0.8.5: + resolution: {integrity: sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==} engines: {node: '>=4'} hasBin: true dependencies: @@ -10297,7 +10040,7 @@ packages: recursive-readdir: 2.2.2 sc-istanbul: 0.4.6 semver: 7.5.4 - shelljs: 0.8.3 + shelljs: 0.8.5 web3-utils: 1.8.0 transitivePeerDependencies: - supports-color @@ -10439,11 +10182,6 @@ packages: engines: {node: '>= 0.8'} dev: true - /stealthy-require@1.1.1: - resolution: {integrity: sha512-ZnWpYnYugiOVEY5GkcuJK1io5V8QmNYChG62gSit9pQVGErXtrKuPC55ITaVSukmMta5qpMU7vqLt2Lnni4f/g==} - engines: {node: '>=0.10.0'} - dev: true - /stream-to-pull-stream@1.7.3: resolution: {integrity: sha512-6sNyqJpr5dIOQdgNy/xcDWwDuzAsAwVzhzrWlAPAQ7Lkjx/rv0wgvxEyKwTq6FmNd5rjTrELt/CLmaSw7crMGg==} dependencies: @@ -10483,15 +10221,6 @@ packages: strip-ansi: 4.0.0 dev: true - /string-width@3.1.0: - resolution: {integrity: sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==} - engines: {node: '>=6'} - dependencies: - emoji-regex: 7.0.3 - is-fullwidth-code-point: 2.0.0 - strip-ansi: 5.2.0 - dev: true - /string-width@4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} @@ -10510,14 +10239,6 @@ packages: es-abstract: 1.22.2 dev: true - /string.prototype.trimend@1.0.5: - resolution: {integrity: sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog==} - dependencies: - call-bind: 1.0.2 - define-properties: 1.1.4 - es-abstract: 1.20.3 - dev: true - /string.prototype.trimend@1.0.7: resolution: {integrity: sha512-Ni79DqeB72ZFq1uH/L6zJ+DKZTkOtPIHovb3YZHQViE+HDouuU4mBrLOLDn5Dde3RF8qw5qVETEjhu9locMLvA==} dependencies: @@ -10526,14 +10247,6 @@ packages: es-abstract: 1.22.2 dev: true - /string.prototype.trimstart@1.0.5: - resolution: {integrity: sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg==} - dependencies: - call-bind: 1.0.2 - define-properties: 1.1.4 - es-abstract: 1.20.3 - dev: true - /string.prototype.trimstart@1.0.7: resolution: {integrity: sha512-NGhtDFu3jCEm7B4Fy0DpLewdJQOZcQ0rGbwQ/+stjnrp2i+rlKeCvos9hOIeCmqwratM47OBxY7uFZzjxHXmrg==} dependencies: @@ -10572,13 +10285,6 @@ packages: ansi-regex: 3.0.1 dev: true - /strip-ansi@5.2.0: - resolution: {integrity: sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==} - engines: {node: '>=6'} - dependencies: - ansi-regex: 4.1.1 - dev: true - /strip-ansi@6.0.1: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} engines: {node: '>=8'} @@ -10615,11 +10321,6 @@ packages: engines: {node: '>=4'} dev: true - /strip-json-comments@2.0.1: - resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==} - engines: {node: '>=0.10.0'} - dev: true - /strip-json-comments@3.1.1: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} engines: {node: '>=8'} @@ -10644,13 +10345,6 @@ packages: has-flag: 3.0.0 dev: true - /supports-color@6.0.0: - resolution: {integrity: sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==} - engines: {node: '>=6'} - dependencies: - has-flag: 3.0.0 - dev: true - /supports-color@7.2.0: resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} engines: {node: '>=8'} @@ -10730,17 +10424,6 @@ packages: wordwrapjs: 4.0.1 dev: true - /table@6.8.0: - resolution: {integrity: sha512-s/fitrbVeEyHKFa7mFdkuQMWlH1Wgw/yEXMt5xACT4ZpzWFluehAxRtUUQKPuWhaLAWhFcVx6w3oC8VKaUfPGA==} - engines: {node: '>=10.0.0'} - dependencies: - ajv: 8.11.0 - lodash.truncate: 4.4.2 - slice-ansi: 4.0.0 - string-width: 4.2.3 - strip-ansi: 6.0.1 - dev: true - /table@6.8.1: resolution: {integrity: sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA==} engines: {node: '>=10.0.0'} @@ -10982,7 +10665,7 @@ packages: glob: 7.2.3 mkdirp: 0.5.6 prettier: 2.8.8 - resolve: 1.22.1 + resolve: 1.22.8 ts-essentials: 1.0.4 dev: true @@ -11244,11 +10927,6 @@ packages: dev: true optional: true - /undici@5.10.0: - resolution: {integrity: sha512-c8HsD3IbwmjjbLvoZuRI26TZic+TSEe8FPMLLOkN1AfYRhdjnKBU6yL+IwcSCbdZiX4e5t0lfMDLDCqj4Sq70g==} - engines: {node: '>=12.18'} - dev: true - /undici@5.19.1: resolution: {integrity: sha512-YiZ61LPIgY73E7syxCDxxa3LV2yl3sN8spnIuTct60boiiRaE1J8mNWHO8Im2Zi/sFrPusjLlmRPrsyraSqX6A==} engines: {node: '>=12.18'} @@ -12389,10 +12067,6 @@ packages: resolution: {integrity: sha512-F6+WgncZi/mJDrammbTuHe1q0R5hOXv/mBaiNA2TCNT/LTHusX0V+CJnj9XT8ki5ln2UZyyddDgHfCzyrOH7MQ==} dev: true - /which-module@2.0.0: - resolution: {integrity: sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==} - dev: true - /which-typed-array@1.1.11: resolution: {integrity: sha512-qe9UWWpkeG5yzZ0tNYxDmd7vo58HDBc39mZ0xWWpolAGADdFOzkfamWLDxkOWcvHQKVmdTyQdLD4NOfjLWTKew==} engines: {node: '>= 0.4'} @@ -12419,12 +12093,6 @@ packages: isexe: 2.0.0 dev: true - /wide-align@1.1.3: - resolution: {integrity: sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==} - dependencies: - string-width: 2.1.1 - dev: true - /window-size@0.2.0: resolution: {integrity: sha512-UD7d8HFA2+PZsbKyaOCEy8gMh1oDtHgJh1LfgjQ4zVXmYjAT/kvz3PueITKuqDiIXQe7yzpPnxX3lNc+AhQMyw==} engines: {node: '>= 0.10.0'} @@ -12460,15 +12128,6 @@ packages: strip-ansi: 3.0.1 dev: true - /wrap-ansi@5.1.0: - resolution: {integrity: sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==} - engines: {node: '>=6'} - dependencies: - ansi-styles: 3.2.1 - string-width: 3.1.0 - strip-ansi: 5.2.0 - dev: true - /wrap-ansi@7.0.0: resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} engines: {node: '>=10'} @@ -12594,10 +12253,6 @@ packages: resolution: {integrity: sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==} dev: true - /y18n@4.0.3: - resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==} - dev: true - /y18n@5.0.8: resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} engines: {node: '>=10'} @@ -12621,13 +12276,6 @@ packages: engines: {node: '>= 6'} dev: true - /yargs-parser@13.1.2: - resolution: {integrity: sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==} - dependencies: - camelcase: 5.3.1 - decamelize: 1.2.0 - dev: true - /yargs-parser@2.4.1: resolution: {integrity: sha512-9pIKIJhnI5tonzG6OnCFlz/yln8xHYcGl+pn3xR0Vzff0vzN1PbNRaelgfgRUwZ3s4i3jvxT9WhmUGL4whnasA==} dependencies: @@ -12640,15 +12288,6 @@ packages: engines: {node: '>=10'} dev: true - /yargs-unparser@1.6.0: - resolution: {integrity: sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw==} - engines: {node: '>=6'} - dependencies: - flat: 4.1.1 - lodash: 4.17.21 - yargs: 13.3.2 - dev: true - /yargs-unparser@2.0.0: resolution: {integrity: sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==} engines: {node: '>=10'} @@ -12659,21 +12298,6 @@ packages: is-plain-obj: 2.1.0 dev: true - /yargs@13.3.2: - resolution: {integrity: sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==} - dependencies: - cliui: 5.0.0 - find-up: 3.0.0 - get-caller-file: 2.0.5 - require-directory: 2.1.1 - require-main-filename: 2.0.0 - set-blocking: 2.0.0 - string-width: 3.1.0 - which-module: 2.0.0 - y18n: 4.0.3 - yargs-parser: 13.1.2 - dev: true - /yargs@16.2.0: resolution: {integrity: sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==} engines: {node: '>=10'} diff --git a/contracts/scripts/native_solc_compile_all_automation b/contracts/scripts/native_solc_compile_all_automation index 7e0b6058aed..414453c8482 100755 --- a/contracts/scripts/native_solc_compile_all_automation +++ b/contracts/scripts/native_solc_compile_all_automation @@ -59,6 +59,15 @@ compileContract automation/v2_1/AutomationUtils2_1.sol compileContract automation/v2_1/AutomationForwarderLogic.sol compileContract automation/testhelpers/LogTriggeredStreamsLookup.sol compileContract automation/testhelpers/DummyProtocol.sol + +compileContract automation/testhelpers/KeeperBase.sol +compileContract automation/testhelpers/KeeperCompatibleInterface.sol +compileContract automation/testhelpers/KeeperConsumer.sol +compileContract automation/testhelpers/KeeperConsumerPerformance.sol +compileContract automation/testhelpers/PerformDataChecker.sol +compileContract automation/testhelpers/UpkeepPerformCounterRestrictive.sol +compileContract automation/testhelpers/UpkeepCounter.sol + compileContract automation/interfaces/StreamsLookupCompatibleInterface.sol compileContract tests/VerifiableLoadUpkeep.sol diff --git a/contracts/scripts/native_solc_compile_all_functions b/contracts/scripts/native_solc_compile_all_functions index 4b353b36901..26e4c0c6e50 100755 --- a/contracts/scripts/native_solc_compile_all_functions +++ b/contracts/scripts/native_solc_compile_all_functions @@ -6,7 +6,6 @@ echo " ┌─────────────────────── echo " │ Compiling Functions contracts... │" echo " └──────────────────────────────────────────────┘" -SOLC_VERSION="0.8.6" OPTIMIZE_RUNS=1000000 @@ -14,11 +13,6 @@ SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; cd ../ && pwd -P )" python3 -m pip install --require-hashes -r $SCRIPTPATH/requirements.txt -solc-select install $SOLC_VERSION -solc-select use $SOLC_VERSION -export SOLC_VERSION=$SOLC_VERSION - - compileContract () { solc @openzeppelin/=$ROOT/node_modules/@openzeppelin/ \ --overwrite --optimize --optimize-runs $OPTIMIZE_RUNS --metadata-hash none \ @@ -28,20 +22,6 @@ compileContract () { $ROOT/src/v0.8/functions/$2 } -########################## -# Version 0 (Testnet Beta) -########################## - -compileContract v0_0_0 dev/v0_0_0/Functions.sol -compileContract v0_0_0 dev/v0_0_0/FunctionsBillingRegistry.sol -compileContract v0_0_0 dev/v0_0_0/FunctionsClient.sol -compileContract v0_0_0 dev/v0_0_0/FunctionsOracle.sol -compileContract v0_0_0 dev/v0_0_0/example/FunctionsClientExample.sol - -# Test helpers -compileContract v0_0_0 tests/v0_0_0/testhelpers/FunctionsBillingRegistryWithInit.sol -compileContract v0_0_0 tests/v0_0_0/testhelpers/FunctionsOracleWithInit.sol - ############################ # Version 1 (Mainnet Preview) ############################ diff --git a/contracts/scripts/native_solc_compile_all_vrf b/contracts/scripts/native_solc_compile_all_vrf index 302dc18d2fe..80adba8e6f7 100755 --- a/contracts/scripts/native_solc_compile_all_vrf +++ b/contracts/scripts/native_solc_compile_all_vrf @@ -83,6 +83,7 @@ compileContract vrf/VRFV2Wrapper.sol compileContract vrf/interfaces/VRFV2WrapperInterface.sol compileContract vrf/VRFV2WrapperConsumerBase.sol compileContract vrf/testhelpers/VRFV2WrapperConsumerExample.sol +compileContract vrf/testhelpers/VRFv2Consumer.sol # VRF Consumers and Mocks compileContract vrf/testhelpers/VRFExternalSubOwnerExample.sol diff --git a/contracts/src/v0.8/automation/testhelpers/KeeperBase.sol b/contracts/src/v0.8/automation/testhelpers/KeeperBase.sol new file mode 100644 index 00000000000..6fe41607f75 --- /dev/null +++ b/contracts/src/v0.8/automation/testhelpers/KeeperBase.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.16; + +contract KeeperBase { + /** + * @notice method that allows it to be simulated via eth_call by checking that + * the sender is the zero address. + */ + function preventExecution() internal view { + require(tx.origin == address(0), "only for simulated backend"); + } + + /** + * @notice modifier that allows it to be simulated via eth_call by checking + * that the sender is the zero address. + */ + modifier cannotExecute() { + preventExecution(); + _; + } +} diff --git a/contracts/src/v0.8/automation/testhelpers/KeeperCompatibleInterface.sol b/contracts/src/v0.8/automation/testhelpers/KeeperCompatibleInterface.sol new file mode 100644 index 00000000000..113f5ef6a55 --- /dev/null +++ b/contracts/src/v0.8/automation/testhelpers/KeeperCompatibleInterface.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: MIT + +pragma solidity 0.8.16; + +interface KeeperCompatibleInterface { + /** + * @notice method that is simulated by the keepers to see if any work actually + * needs to be performed. This method does does not actually need to be + * executable, and since it is only ever simulated it can consume lots of gas. + * @dev To ensure that it is never called, you may want to add the + * cannotExecute modifier from KeeperBase to your implementation of this + * method. + * @param checkData specified in the upkeep registration so it is always the + * same for a registered upkeep. This can easily be broken down into specific + * arguments using `abi.decode`, so multiple upkeeps can be registered on the + * same contract and easily differentiated by the contract. + * @return upkeepNeeded boolean to indicate whether the keeper should call + * performUpkeep or not. + * @return performData bytes that the keeper should call performUpkeep with, if + * upkeep is needed. If you would like to encode data to decode later, try + * `abi.encode`. + */ + function checkUpkeep(bytes calldata checkData) external returns (bool upkeepNeeded, bytes memory performData); + + /** + * @notice method that is actually executed by the keepers, via the registry. + * The data returned by the checkUpkeep simulation will be passed into + * this method to actually be executed. + * @dev The input to this method should not be trusted, and the caller of the + * method should not even be restricted to any single registry. Anyone should + * be able call it, and the input should be validated, there is no guarantee + * that the data passed in is the performData returned from checkUpkeep. This + * could happen due to malicious keepers, racing keepers, or simply a state + * change while the performUpkeep transaction is waiting for confirmation. + * Always validate the data passed in. + * @param performData is the data which was passed back from the checkData + * simulation. If it is encoded, it can easily be decoded into other types by + * calling `abi.decode`. This data should not be trusted, and should be + * validated against the contract's current state. + */ + function performUpkeep(bytes calldata performData) external; +} diff --git a/contracts/src/v0.8/automation/testhelpers/KeeperConsumer.sol b/contracts/src/v0.8/automation/testhelpers/KeeperConsumer.sol new file mode 100644 index 00000000000..ba4694234a9 --- /dev/null +++ b/contracts/src/v0.8/automation/testhelpers/KeeperConsumer.sol @@ -0,0 +1,26 @@ +pragma solidity 0.8.16; + +import "./KeeperCompatibleInterface.sol"; +import "./KeeperBase.sol"; + +contract KeeperConsumer is KeeperCompatibleInterface, KeeperBase { + uint public counter; + uint public immutable interval; + uint public lastTimeStamp; + + constructor(uint updateInterval) public { + interval = updateInterval; + lastTimeStamp = block.timestamp; + counter = 0; + } + + function checkUpkeep( + bytes calldata checkData + ) external view override cannotExecute returns (bool upkeepNeeded, bytes memory performData) { + return (true, checkData); + } + + function performUpkeep(bytes calldata performData) external override { + counter = counter + 1; + } +} diff --git a/integration-tests/contracts/ethereum/src/KeeperConsumerPerformance.sol b/contracts/src/v0.8/automation/testhelpers/KeeperConsumerPerformance.sol similarity index 93% rename from integration-tests/contracts/ethereum/src/KeeperConsumerPerformance.sol rename to contracts/src/v0.8/automation/testhelpers/KeeperConsumerPerformance.sol index 4d763f7276e..5b7f57e116e 100644 --- a/integration-tests/contracts/ethereum/src/KeeperConsumerPerformance.sol +++ b/contracts/src/v0.8/automation/testhelpers/KeeperConsumerPerformance.sol @@ -1,4 +1,4 @@ -pragma solidity 0.7.6; +pragma solidity 0.8.16; contract KeeperConsumerPerformance { event PerformingUpkeep(bool eligible, address from, uint256 initialCall, uint256 nextEligible, uint256 blockNumber); @@ -13,7 +13,12 @@ contract KeeperConsumerPerformance { uint256 public count = 0; - constructor(uint256 _testRange, uint256 _averageEligibilityCadence, uint256 _checkGasToBurn, uint256 _performGasToBurn) { + constructor( + uint256 _testRange, + uint256 _averageEligibilityCadence, + uint256 _checkGasToBurn, + uint256 _performGasToBurn + ) { testRange = _testRange; averageEligibilityCadence = _averageEligibilityCadence; checkGasToBurn = _checkGasToBurn; @@ -80,4 +85,4 @@ contract KeeperConsumerPerformance { function rand() private view returns (uint256) { return uint256(keccak256(abi.encode(blockhash(block.number - 1), address(this)))); } -} \ No newline at end of file +} diff --git a/contracts/src/v0.8/automation/testhelpers/PerformDataChecker.sol b/contracts/src/v0.8/automation/testhelpers/PerformDataChecker.sol new file mode 100644 index 00000000000..03c57ea8e41 --- /dev/null +++ b/contracts/src/v0.8/automation/testhelpers/PerformDataChecker.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.16; + +import "./KeeperCompatibleInterface.sol"; + +contract PerformDataChecker is KeeperCompatibleInterface { + uint256 public counter; + bytes public s_expectedData; + + constructor(bytes memory expectedData) { + s_expectedData = expectedData; + } + + function setExpectedData(bytes calldata expectedData) external { + s_expectedData = expectedData; + } + + function checkUpkeep( + bytes calldata checkData + ) external view override returns (bool upkeepNeeded, bytes memory performData) { + return (keccak256(checkData) == keccak256(s_expectedData), checkData); + } + + function performUpkeep(bytes calldata performData) external override { + if (keccak256(performData) == keccak256(s_expectedData)) { + counter++; + } + } +} diff --git a/integration-tests/contracts/ethereum/src/UpkeepPerformCounterRestrictive.sol b/contracts/src/v0.8/automation/testhelpers/UpkeepPerformCounterRestrictive.sol similarity index 99% rename from integration-tests/contracts/ethereum/src/UpkeepPerformCounterRestrictive.sol rename to contracts/src/v0.8/automation/testhelpers/UpkeepPerformCounterRestrictive.sol index 35e28584a09..3aa345ab458 100644 --- a/integration-tests/contracts/ethereum/src/UpkeepPerformCounterRestrictive.sol +++ b/contracts/src/v0.8/automation/testhelpers/UpkeepPerformCounterRestrictive.sol @@ -1,4 +1,4 @@ -pragma solidity 0.7.6; +pragma solidity 0.8.16; contract UpkeepPerformCounterRestrictive { event PerformingUpkeep(bool eligible, address from, uint256 initialCall, uint256 nextEligible, uint256 blockNumber); diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/Functions.sol b/contracts/src/v0.8/functions/dev/v0_0_0/Functions.sol deleted file mode 100644 index 478149d8dda..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/Functions.sol +++ /dev/null @@ -1,152 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {CBOR, Buffer} from "../../../vendor/solidity-cborutils/v2.0.0/CBOR.sol"; - -/** - * @title Library for Chainlink Functions - */ -library Functions { - uint256 internal constant DEFAULT_BUFFER_SIZE = 256; - - using CBOR for Buffer.buffer; - - enum Location { - Inline, - Remote, - DONHosted - } - - enum CodeLanguage { - JavaScript - // In future version we may add other languages - } - - struct Request { - Location codeLocation; - Location secretsLocation; - CodeLanguage language; - string source; // Source code for Location.Inline, url for Location.Remote or slot decimal number for Location.DONHosted - bytes secrets; // Encrypted urls for Location.Remote or CBOR encoded slotid+version for Location.DONHosted, use addDONHostedSecrets() - string[] args; - } - - error EmptySource(); - error EmptyUrl(); - error EmptySecrets(); - error EmptyArgs(); - error NoInlineSecrets(); - - /** - * @notice Encodes a Request to CBOR encoded bytes - * @param self The request to encode - * @return CBOR encoded bytes - */ - function encodeCBOR(Request memory self) internal pure returns (bytes memory) { - CBOR.CBORBuffer memory buffer; - Buffer.init(buffer.buf, DEFAULT_BUFFER_SIZE); - - CBOR.writeString(buffer, "codeLocation"); - CBOR.writeUInt256(buffer, uint256(self.codeLocation)); - - CBOR.writeString(buffer, "language"); - CBOR.writeUInt256(buffer, uint256(self.language)); - - CBOR.writeString(buffer, "source"); - CBOR.writeString(buffer, self.source); - - if (self.args.length > 0) { - CBOR.writeString(buffer, "args"); - CBOR.startArray(buffer); - for (uint256 i = 0; i < self.args.length; i++) { - CBOR.writeString(buffer, self.args[i]); - } - CBOR.endSequence(buffer); - } - - if (self.secrets.length > 0) { - if (self.secretsLocation == Location.Inline) { - revert NoInlineSecrets(); - } - CBOR.writeString(buffer, "secretsLocation"); - CBOR.writeUInt256(buffer, uint256(self.secretsLocation)); - CBOR.writeString(buffer, "secrets"); - CBOR.writeBytes(buffer, self.secrets); - } - - return buffer.buf.buf; - } - - /** - * @notice Initializes a Chainlink Functions Request - * @dev Sets the codeLocation and code on the request - * @param self The uninitialized request - * @param location The user provided source code location - * @param language The programming language of the user code - * @param source The user provided source code or a url - */ - function initializeRequest( - Request memory self, - Location location, - CodeLanguage language, - string memory source - ) internal pure { - if (bytes(source).length == 0) revert EmptySource(); - - self.codeLocation = location; - self.language = language; - self.source = source; - } - - /** - * @notice Initializes a Chainlink Functions Request - * @dev Simplified version of initializeRequest for PoC - * @param self The uninitialized request - * @param javaScriptSource The user provided JS code (must not be empty) - */ - function initializeRequestForInlineJavaScript(Request memory self, string memory javaScriptSource) internal pure { - initializeRequest(self, Location.Inline, CodeLanguage.JavaScript, javaScriptSource); - } - - /** - * @notice Adds Remote user encrypted secrets to a Request - * @param self The initialized request - * @param encryptedSecretsURLs Encrypted comma-separated string of URLs pointing to off-chain secrets - */ - function addRemoteSecrets(Request memory self, bytes memory encryptedSecretsURLs) internal pure { - if (encryptedSecretsURLs.length == 0) revert EmptySecrets(); - - self.secretsLocation = Location.Remote; - self.secrets = encryptedSecretsURLs; - } - - /** - * @notice Adds DON-hosted secrets reference to a Request - * @param self The initialized request - * @param slotID Slot ID of the user's secrets hosted on DON - * @param version User data version (for the slotID) - */ - function addDONHostedSecrets(Request memory self, uint8 slotID, uint64 version) internal pure { - CBOR.CBORBuffer memory buffer; - Buffer.init(buffer.buf, DEFAULT_BUFFER_SIZE); - - CBOR.writeString(buffer, "slotID"); - CBOR.writeUInt64(buffer, slotID); - CBOR.writeString(buffer, "version"); - CBOR.writeUInt64(buffer, version); - - self.secretsLocation = Location.DONHosted; - self.secrets = buffer.buf.buf; - } - - /** - * @notice Adds args for the user run function - * @param self The initialized request - * @param args The array of args (must not be empty) - */ - function addArgs(Request memory self, string[] memory args) internal pure { - if (args.length == 0) revert EmptyArgs(); - - self.args = args; - } -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/FunctionsBillingRegistry.sol b/contracts/src/v0.8/functions/dev/v0_0_0/FunctionsBillingRegistry.sol deleted file mode 100644 index d241855c983..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/FunctionsBillingRegistry.sol +++ /dev/null @@ -1,841 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {LinkTokenInterface} from "../../../shared/interfaces/LinkTokenInterface.sol"; -import {AggregatorV3Interface} from "../../../interfaces/AggregatorV3Interface.sol"; -import {IFunctionsBillingRegistry} from "./interfaces/IFunctionsBillingRegistry.sol"; -import {IFunctionsOracle} from "./interfaces/IFunctionsOracle.sol"; -import {IFunctionsClient} from "./interfaces/IFunctionsClient.sol"; -import {IERC677Receiver} from "../../../shared/interfaces/IERC677Receiver.sol"; -import {IAuthorizedOriginReceiver} from "./accessControl/interfaces/IAuthorizedOriginReceiver.sol"; -import {ConfirmedOwnerUpgradeable} from "./accessControl/ConfirmedOwnerUpgradeable.sol"; -import {AuthorizedReceiver} from "./accessControl/AuthorizedReceiver.sol"; -import {SafeCast} from "../../../vendor/openzeppelin-solidity/v4.8.0/contracts/utils/math/SafeCast.sol"; -import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; -import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; - -/** - * @title Functions Billing Registry contract - * @notice Contract that coordinates payment from users to the nodes of the Decentralized Oracle Network (DON). - * @dev THIS CONTRACT HAS NOT GONE THROUGH ANY SECURITY REVIEW. DO NOT USE IN PROD. - */ -contract FunctionsBillingRegistry is - Initializable, - ConfirmedOwnerUpgradeable, - PausableUpgradeable, - IFunctionsBillingRegistry, - IERC677Receiver, - AuthorizedReceiver -{ - LinkTokenInterface private LINK; - AggregatorV3Interface private LINK_ETH_FEED; - IAuthorizedOriginReceiver private ORACLE_WITH_ALLOWLIST; - - // We need to maintain a list of consuming addresses. - // This bound ensures we are able to loop over them as needed. - // Should a user require more consumers, they can use multiple subscriptions. - uint16 public constant MAX_CONSUMERS = 100; - - error TooManyConsumers(); - error InsufficientBalance(); - error InvalidConsumer(uint64 subscriptionId, address consumer); - error InvalidSubscription(); - error OnlyCallableFromLink(); - error InvalidCalldata(); - error MustBeSubOwner(address owner); - error PendingRequestExists(); - error MustBeRequestedOwner(address proposedOwner); - error BalanceInvariantViolated(uint256 internalBalance, uint256 externalBalance); // Should never happen - event FundsRecovered(address to, uint256 amount); - - struct Subscription { - // There are only 1e9*1e18 = 1e27 juels in existence, so the balance can fit in uint96 (2^96 ~ 7e28) - uint96 balance; // Common LINK balance that is controlled by the Registry to be used for all consumer requests. - uint96 blockedBalance; // LINK balance that is reserved to pay for pending consumer requests. - } - // We use the config for the mgmt APIs - struct SubscriptionConfig { - address owner; // Owner can fund/withdraw/cancel the sub. - address requestedOwner; // For safely transferring sub ownership. - // Maintains the list of keys in s_consumers. - // We do this for 2 reasons: - // 1. To be able to clean up all keys from s_consumers when canceling a subscription. - // 2. To be able to return the list of all consumers in getSubscription. - // Note that we need the s_consumers map to be able to directly check if a - // consumer is valid without reading all the consumers from storage. - address[] consumers; - } - // Note a nonce of 0 indicates an the consumer is not assigned to that subscription. - mapping(address => mapping(uint64 => uint64)) /* consumer */ /* subscriptionId */ /* nonce */ private s_consumers; - mapping(uint64 => SubscriptionConfig) /* subscriptionId */ /* subscriptionConfig */ private s_subscriptionConfigs; - mapping(uint64 => Subscription) /* subscriptionId */ /* subscription */ private s_subscriptions; - // We make the sub count public so that its possible to - // get all the current subscriptions via getSubscription. - uint64 private s_currentsubscriptionId; - // s_totalBalance tracks the total link sent to/from - // this contract through onTokenTransfer, cancelSubscription and oracleWithdraw. - // A discrepancy with this contract's link balance indicates someone - // sent tokens using transfer and so we may need to use recoverFunds. - uint96 private s_totalBalance; - event SubscriptionCreated(uint64 indexed subscriptionId, address owner); - event SubscriptionFunded(uint64 indexed subscriptionId, uint256 oldBalance, uint256 newBalance); - event SubscriptionConsumerAdded(uint64 indexed subscriptionId, address consumer); - event SubscriptionConsumerRemoved(uint64 indexed subscriptionId, address consumer); - event SubscriptionCanceled(uint64 indexed subscriptionId, address to, uint256 amount); - event SubscriptionOwnerTransferRequested(uint64 indexed subscriptionId, address from, address to); - event SubscriptionOwnerTransferred(uint64 indexed subscriptionId, address from, address to); - - error GasLimitTooBig(uint32 have, uint32 want); - error InvalidLinkWeiPrice(int256 linkWei); - error PaymentTooLarge(); - error Reentrant(); - - mapping(address => uint96) /* oracle node */ /* LINK balance */ private s_withdrawableTokens; - struct Commitment { - uint64 subscriptionId; - address client; - uint32 gasLimit; - uint256 gasPrice; - address don; - uint96 donFee; - uint96 registryFee; - uint96 estimatedCost; - uint256 timestamp; - } - mapping(bytes32 => Commitment) /* requestID */ /* Commitment */ private s_requestCommitments; - event BillingStart(bytes32 indexed requestId, Commitment commitment); - struct ItemizedBill { - uint96 signerPayment; - uint96 transmitterPayment; - uint96 totalCost; - } - event BillingEnd( - bytes32 indexed requestId, - uint64 subscriptionId, - uint96 signerPayment, - uint96 transmitterPayment, - uint96 totalCost, - bool success - ); - event RequestTimedOut(bytes32 indexed requestId); - - struct Config { - // Maxiumum amount of gas that can be given to a request's client callback - uint32 maxGasLimit; - // Reentrancy protection. - bool reentrancyLock; - // stalenessSeconds is how long before we consider the feed price to be stale - // and fallback to fallbackWeiPerUnitLink. - uint32 stalenessSeconds; - // Gas to cover transmitter oracle payment after we calculate the payment. - // We make it configurable in case those operations are repriced. - uint256 gasAfterPaymentCalculation; - // Represents the average gas execution cost. Used in estimating cost beforehand. - uint32 gasOverhead; - // how many seconds it takes before we consider a request to be timed out - uint32 requestTimeoutSeconds; - } - int256 private s_fallbackWeiPerUnitLink; - Config private s_config; - event ConfigSet( - uint32 maxGasLimit, - uint32 stalenessSeconds, - uint256 gasAfterPaymentCalculation, - int256 fallbackWeiPerUnitLink, - uint32 gasOverhead - ); - - /** - * @dev Initializes the contract. - */ - function initialize(address link, address linkEthFeed, address oracle) public initializer { - __Pausable_init(); - __ConfirmedOwner_initialize(msg.sender, address(0)); - LINK = LinkTokenInterface(link); - LINK_ETH_FEED = AggregatorV3Interface(linkEthFeed); - ORACLE_WITH_ALLOWLIST = IAuthorizedOriginReceiver(oracle); - } - - /** - * @notice Sets the configuration of the Chainlink Functions billing registry - * @param maxGasLimit global max for request gas limit - * @param stalenessSeconds if the eth/link feed is more stale then this, use the fallback price - * @param gasAfterPaymentCalculation gas used in doing accounting after completing the gas measurement - * @param fallbackWeiPerUnitLink fallback eth/link price in the case of a stale feed - * @param gasOverhead average gas execution cost used in estimating total cost - * @param requestTimeoutSeconds e2e timeout after which user won't be charged - */ - function setConfig( - uint32 maxGasLimit, - uint32 stalenessSeconds, - uint256 gasAfterPaymentCalculation, - int256 fallbackWeiPerUnitLink, - uint32 gasOverhead, - uint32 requestTimeoutSeconds - ) external onlyOwner { - if (fallbackWeiPerUnitLink <= 0) { - revert InvalidLinkWeiPrice(fallbackWeiPerUnitLink); - } - s_config = Config({ - maxGasLimit: maxGasLimit, - stalenessSeconds: stalenessSeconds, - gasAfterPaymentCalculation: gasAfterPaymentCalculation, - reentrancyLock: false, - gasOverhead: gasOverhead, - requestTimeoutSeconds: requestTimeoutSeconds - }); - s_fallbackWeiPerUnitLink = fallbackWeiPerUnitLink; - emit ConfigSet(maxGasLimit, stalenessSeconds, gasAfterPaymentCalculation, fallbackWeiPerUnitLink, gasOverhead); - } - - /** - * @notice Gets the configuration of the Chainlink Functions billing registry - * @return maxGasLimit global max for request gas limit - * @return stalenessSeconds if the eth/link feed is more stale then this, use the fallback price - * @return gasAfterPaymentCalculation gas used in doing accounting after completing the gas measurement - * @return fallbackWeiPerUnitLink fallback eth/link price in the case of a stale feed - * @return gasOverhead average gas execution cost used in estimating total cost - * @return linkAddress address of contract for the LINK token - * @return linkPriceFeed address of contract for a conversion price between LINK token and native token - */ - function getConfig() - external - view - returns ( - uint32 maxGasLimit, - uint32 stalenessSeconds, - uint256 gasAfterPaymentCalculation, - int256 fallbackWeiPerUnitLink, - uint32 gasOverhead, - address linkAddress, - address linkPriceFeed - ) - { - return ( - s_config.maxGasLimit, - s_config.stalenessSeconds, - s_config.gasAfterPaymentCalculation, - s_fallbackWeiPerUnitLink, - s_config.gasOverhead, - address(LINK), - address(LINK_ETH_FEED) - ); - } - - function pause() external onlyOwner { - _pause(); - } - - function unpause() external onlyOwner { - _unpause(); - } - - function getTotalBalance() external view returns (uint256) { - return s_totalBalance; - } - - /** - * @notice Owner cancel subscription, sends remaining link directly to the subscription owner. - * @param subscriptionId subscription id - * @dev notably can be called even if there are pending requests, outstanding ones may fail onchain - */ - function ownerCancelSubscription(uint64 subscriptionId) external onlyOwner { - address owner = s_subscriptionConfigs[subscriptionId].owner; - if (owner == address(0)) { - revert InvalidSubscription(); - } - cancelSubscriptionHelper(subscriptionId, owner); - } - - /** - * @notice Recover link sent with transfer instead of transferAndCall. - * @param to address to send link to - */ - function recoverFunds(address to) external onlyOwner { - uint256 externalBalance = LINK.balanceOf(address(this)); - uint256 internalBalance = uint256(s_totalBalance); - if (internalBalance > externalBalance) { - revert BalanceInvariantViolated(internalBalance, externalBalance); - } - if (internalBalance < externalBalance) { - uint256 amount = externalBalance - internalBalance; - LINK.transfer(to, amount); - emit FundsRecovered(to, amount); - } - // If the balances are equal, nothing to be done. - } - - /** - * @inheritdoc IFunctionsBillingRegistry - */ - function getRequestConfig() external view override returns (uint32, address[] memory) { - return (s_config.maxGasLimit, getAuthorizedSenders()); - } - - /** - * @inheritdoc IFunctionsBillingRegistry - */ - function getRequiredFee( - bytes calldata /* data */, - IFunctionsBillingRegistry.RequestBilling memory /* billing */ - ) public pure override returns (uint96) { - // NOTE: Optionally, compute additional fee here - return 0; - } - - /** - * @inheritdoc IFunctionsBillingRegistry - */ - function estimateCost( - uint32 gasLimit, - uint256 gasPrice, - uint96 donFee, - uint96 registryFee - ) public view override returns (uint96) { - int256 weiPerUnitLink; - weiPerUnitLink = getFeedData(); - if (weiPerUnitLink <= 0) { - revert InvalidLinkWeiPrice(weiPerUnitLink); - } - uint256 executionGas = s_config.gasOverhead + s_config.gasAfterPaymentCalculation + gasLimit; - // (1e18 juels/link) (wei/gas * gas) / (wei/link) = juels - uint256 paymentNoFee = (1e18 * gasPrice * executionGas) / uint256(weiPerUnitLink); - uint256 fee = uint256(donFee) + uint256(registryFee); - if (paymentNoFee > (1e27 - fee)) { - revert PaymentTooLarge(); // Payment + fee cannot be more than all of the link in existence. - } - return uint96(paymentNoFee + fee); - } - - /** - * @inheritdoc IFunctionsBillingRegistry - */ - function startBilling( - bytes calldata data, - RequestBilling calldata billing - ) external override validateAuthorizedSender nonReentrant whenNotPaused returns (bytes32) { - // Input validation using the subscription storage. - if (s_subscriptionConfigs[billing.subscriptionId].owner == address(0)) { - revert InvalidSubscription(); - } - // It's important to ensure that the consumer is in fact who they say they - // are, otherwise they could use someone else's subscription balance. - // A nonce of 0 indicates consumer is not allocated to the sub. - uint64 currentNonce = s_consumers[billing.client][billing.subscriptionId]; - if (currentNonce == 0) { - revert InvalidConsumer(billing.subscriptionId, billing.client); - } - // No lower bound on the requested gas limit. A user could request 0 - // and they would simply be billed for the gas and computation. - if (billing.gasLimit > s_config.maxGasLimit) { - revert GasLimitTooBig(billing.gasLimit, s_config.maxGasLimit); - } - - // Check that subscription can afford the estimated cost - uint96 oracleFee = IFunctionsOracle(msg.sender).getRequiredFee(data, billing); - uint96 registryFee = getRequiredFee(data, billing); - uint96 estimatedCost = estimateCost(billing.gasLimit, billing.gasPrice, oracleFee, registryFee); - uint96 effectiveBalance = s_subscriptions[billing.subscriptionId].balance - - s_subscriptions[billing.subscriptionId].blockedBalance; - if (effectiveBalance < estimatedCost) { - revert InsufficientBalance(); - } - - uint64 nonce = currentNonce + 1; - bytes32 requestId = computeRequestId(msg.sender, billing.client, billing.subscriptionId, nonce); - - Commitment memory commitment = Commitment( - billing.subscriptionId, - billing.client, - billing.gasLimit, - billing.gasPrice, - msg.sender, - oracleFee, - registryFee, - estimatedCost, - block.timestamp - ); - s_requestCommitments[requestId] = commitment; - s_subscriptions[billing.subscriptionId].blockedBalance += estimatedCost; - - emit BillingStart(requestId, commitment); - s_consumers[billing.client][billing.subscriptionId] = nonce; - return requestId; - } - - function computeRequestId( - address don, - address client, - uint64 subscriptionId, - uint64 nonce - ) private pure returns (bytes32) { - return keccak256(abi.encode(don, client, subscriptionId, nonce)); - } - - /** - * @dev calls target address with exactly gasAmount gas and data as calldata - * or reverts if at least gasAmount gas is not available. - */ - function callWithExactGas(uint256 gasAmount, address target, bytes memory data) private returns (bool success) { - assembly { - let g := gas() - // GAS_FOR_CALL_EXACT_CHECK = 5000 - // Compute g -= GAS_FOR_CALL_EXACT_CHECK and check for underflow - // The gas actually passed to the callee is min(gasAmount, 63//64*gas available). - // We want to ensure that we revert if gasAmount > 63//64*gas available - // as we do not want to provide them with less, however that check itself costs - // gas. GAS_FOR_CALL_EXACT_CHECK ensures we have at least enough gas to be able - // to revert if gasAmount > 63//64*gas available. - if lt(g, 5000) { - revert(0, 0) - } - g := sub(g, 5000) - // if g - g//64 <= gasAmount, revert - // (we subtract g//64 because of EIP-150) - if iszero(gt(sub(g, div(g, 64)), gasAmount)) { - revert(0, 0) - } - // solidity calls check that a contract actually exists at the destination, so we do the same - if iszero(extcodesize(target)) { - revert(0, 0) - } - // call and return whether we succeeded. ignore return data - // call(gas,addr,value,argsOffset,argsLength,retOffset,retLength) - success := call(gasAmount, target, 0, add(data, 0x20), mload(data), 0, 0) - } - return success; - } - - /** - * @inheritdoc IFunctionsBillingRegistry - */ - function fulfillAndBill( - bytes32 requestId, - bytes calldata response, - bytes calldata err, - address transmitter, - address[31] memory signers, - uint8 signerCount, - uint256 reportValidationGas, - uint256 initialGas - ) external override validateAuthorizedSender nonReentrant whenNotPaused returns (FulfillResult) { - Commitment memory commitment = s_requestCommitments[requestId]; - if (commitment.don == address(0)) { - return FulfillResult.INVALID_REQUEST_ID; - } - delete s_requestCommitments[requestId]; - - bytes memory callback = abi.encodeWithSelector( - IFunctionsClient.handleOracleFulfillment.selector, - requestId, - response, - err - ); - // Call with explicitly the amount of callback gas requested - // Important to not let them exhaust the gas budget and avoid payment. - // Do not allow any non-view/non-pure coordinator functions to be called - // during the consumers callback code via reentrancyLock. - // NOTE: that callWithExactGas will revert if we do not have sufficient gas - // to give the callee their requested amount. - s_config.reentrancyLock = true; - bool success = callWithExactGas(commitment.gasLimit, commitment.client, callback); - s_config.reentrancyLock = false; - - // We want to charge users exactly for how much gas they use in their callback. - // The gasAfterPaymentCalculation is meant to cover these additional operations where we - // decrement the subscription balance and increment the oracle's withdrawable balance. - ItemizedBill memory bill = calculatePaymentAmount( - initialGas, - s_config.gasAfterPaymentCalculation, - commitment.donFee, - signerCount, - commitment.registryFee, - reportValidationGas, - tx.gasprice - ); - if (s_subscriptions[commitment.subscriptionId].balance < bill.totalCost) { - revert InsufficientBalance(); - } - s_subscriptions[commitment.subscriptionId].balance -= bill.totalCost; - // Pay out signers their portion of the DON fee - for (uint256 i = 0; i < signerCount; i++) { - s_withdrawableTokens[signers[i]] += bill.signerPayment; - } - // Pay out the registry fee - s_withdrawableTokens[owner()] += commitment.registryFee; - // Reimburse the transmitter for the execution gas cost + pay them their portion of the DON fee - s_withdrawableTokens[transmitter] += bill.transmitterPayment; - // Remove blocked balance - s_subscriptions[commitment.subscriptionId].blockedBalance -= commitment.estimatedCost; - // Include payment in the event for tracking costs. - emit BillingEnd( - requestId, - commitment.subscriptionId, - bill.signerPayment, - bill.transmitterPayment, - bill.totalCost, - success - ); - return success ? FulfillResult.USER_SUCCESS : FulfillResult.USER_ERROR; - } - - // Determine the cost breakdown for payment - function calculatePaymentAmount( - uint256 startGas, - uint256 gasAfterPaymentCalculation, - uint96 donFee, - uint8 signerCount, - uint96 registryFee, - uint256 reportValidationGas, - uint256 weiPerUnitGas - ) private view returns (ItemizedBill memory) { - int256 weiPerUnitLink; - weiPerUnitLink = getFeedData(); - if (weiPerUnitLink <= 0) { - revert InvalidLinkWeiPrice(weiPerUnitLink); - } - // (1e18 juels/link) (wei/gas * gas) / (wei/link) = juels - uint256 paymentNoFee = (1e18 * - weiPerUnitGas * - (reportValidationGas + gasAfterPaymentCalculation + startGas - gasleft())) / uint256(weiPerUnitLink); - uint256 fee = uint256(donFee) + uint256(registryFee); - if (paymentNoFee > (1e27 - fee)) { - revert PaymentTooLarge(); // Payment + fee cannot be more than all of the link in existence. - } - uint96 signerPayment = donFee / uint96(signerCount); - uint96 transmitterPayment = uint96(paymentNoFee); - uint96 totalCost = SafeCast.toUint96(paymentNoFee + fee); - return ItemizedBill(signerPayment, transmitterPayment, totalCost); - } - - function getFeedData() private view returns (int256) { - uint32 stalenessSeconds = s_config.stalenessSeconds; - bool staleFallback = stalenessSeconds > 0; - (, int256 weiPerUnitLink, , uint256 timestamp, ) = LINK_ETH_FEED.latestRoundData(); - // solhint-disable-next-line not-rely-on-time - if (staleFallback && stalenessSeconds < block.timestamp - timestamp) { - weiPerUnitLink = s_fallbackWeiPerUnitLink; - } - return weiPerUnitLink; - } - - /* - * @notice Oracle withdraw LINK earned through fulfilling requests - * @notice If amount is 0 the full balance will be withdrawn - * @notice Both signing and transmitting wallets will have a balance to withdraw - * @param recipient where to send the funds - * @param amount amount to withdraw - */ - function oracleWithdraw(address recipient, uint96 amount) external nonReentrant whenNotPaused { - if (amount == 0) { - amount = s_withdrawableTokens[msg.sender]; - } - if (s_withdrawableTokens[msg.sender] < amount) { - revert InsufficientBalance(); - } - s_withdrawableTokens[msg.sender] -= amount; - s_totalBalance -= amount; - if (!LINK.transfer(recipient, amount)) { - revert InsufficientBalance(); - } - } - - function onTokenTransfer( - address /* sender */, - uint256 amount, - bytes calldata data - ) external override nonReentrant whenNotPaused { - if (msg.sender != address(LINK)) { - revert OnlyCallableFromLink(); - } - if (data.length != 32) { - revert InvalidCalldata(); - } - uint64 subscriptionId = abi.decode(data, (uint64)); - if (s_subscriptionConfigs[subscriptionId].owner == address(0)) { - revert InvalidSubscription(); - } - // We do not check that the msg.sender is the subscription owner, - // anyone can fund a subscription. - uint256 oldBalance = s_subscriptions[subscriptionId].balance; - s_subscriptions[subscriptionId].balance += uint96(amount); - s_totalBalance += uint96(amount); - emit SubscriptionFunded(subscriptionId, oldBalance, oldBalance + amount); - } - - function getCurrentsubscriptionId() external view returns (uint64) { - return s_currentsubscriptionId; - } - - /** - * @notice Get details about a subscription. - * @param subscriptionId - ID of the subscription - * @return balance - LINK balance of the subscription in juels. - * @return owner - owner of the subscription. - * @return consumers - list of consumer address which are able to use this subscription. - */ - function getSubscription( - uint64 subscriptionId - ) external view returns (uint96 balance, address owner, address[] memory consumers) { - if (s_subscriptionConfigs[subscriptionId].owner == address(0)) { - revert InvalidSubscription(); - } - return ( - s_subscriptions[subscriptionId].balance, - s_subscriptionConfigs[subscriptionId].owner, - s_subscriptionConfigs[subscriptionId].consumers - ); - } - - /** - * @notice Create a new subscription. - * @return subscriptionId - A unique subscription id. - * @dev You can manage the consumer set dynamically with addConsumer/removeConsumer. - * @dev Note to fund the subscription, use transferAndCall. For example - * @dev LINKTOKEN.transferAndCall( - * @dev address(REGISTRY), - * @dev amount, - * @dev abi.encode(subscriptionId)); - */ - function createSubscription() external nonReentrant whenNotPaused onlyAuthorizedUsers returns (uint64) { - s_currentsubscriptionId++; - uint64 currentsubscriptionId = s_currentsubscriptionId; - address[] memory consumers = new address[](0); - s_subscriptions[currentsubscriptionId] = Subscription({balance: 0, blockedBalance: 0}); - s_subscriptionConfigs[currentsubscriptionId] = SubscriptionConfig({ - owner: msg.sender, - requestedOwner: address(0), - consumers: consumers - }); - - emit SubscriptionCreated(currentsubscriptionId, msg.sender); - return currentsubscriptionId; - } - - /** - * @notice Gets subscription owner. - * @param subscriptionId - ID of the subscription - * @return owner - owner of the subscription. - */ - function getSubscriptionOwner(uint64 subscriptionId) external view override returns (address owner) { - if (s_subscriptionConfigs[subscriptionId].owner == address(0)) { - revert InvalidSubscription(); - } - return s_subscriptionConfigs[subscriptionId].owner; - } - - /** - * @notice Request subscription owner transfer. - * @param subscriptionId - ID of the subscription - * @param newOwner - proposed new owner of the subscription - */ - function requestSubscriptionOwnerTransfer( - uint64 subscriptionId, - address newOwner - ) external onlySubOwner(subscriptionId) nonReentrant whenNotPaused { - // Proposing to address(0) would never be claimable so don't need to check. - if (s_subscriptionConfigs[subscriptionId].requestedOwner != newOwner) { - s_subscriptionConfigs[subscriptionId].requestedOwner = newOwner; - emit SubscriptionOwnerTransferRequested(subscriptionId, msg.sender, newOwner); - } - } - - /** - * @notice Request subscription owner transfer. - * @param subscriptionId - ID of the subscription - * @dev will revert if original owner of subscriptionId has - * not requested that msg.sender become the new owner. - */ - function acceptSubscriptionOwnerTransfer( - uint64 subscriptionId - ) external nonReentrant whenNotPaused onlyAuthorizedUsers { - if (s_subscriptionConfigs[subscriptionId].owner == address(0)) { - revert InvalidSubscription(); - } - if (s_subscriptionConfigs[subscriptionId].requestedOwner != msg.sender) { - revert MustBeRequestedOwner(s_subscriptionConfigs[subscriptionId].requestedOwner); - } - address oldOwner = s_subscriptionConfigs[subscriptionId].owner; - s_subscriptionConfigs[subscriptionId].owner = msg.sender; - s_subscriptionConfigs[subscriptionId].requestedOwner = address(0); - emit SubscriptionOwnerTransferred(subscriptionId, oldOwner, msg.sender); - } - - /** - * @notice Remove a consumer from a Chainlink Functions subscription. - * @param subscriptionId - ID of the subscription - * @param consumer - Consumer to remove from the subscription - */ - function removeConsumer( - uint64 subscriptionId, - address consumer - ) external onlySubOwner(subscriptionId) nonReentrant whenNotPaused { - if (s_consumers[consumer][subscriptionId] == 0) { - revert InvalidConsumer(subscriptionId, consumer); - } - // Note bounded by MAX_CONSUMERS - address[] memory consumers = s_subscriptionConfigs[subscriptionId].consumers; - uint256 lastConsumerIndex = consumers.length - 1; - for (uint256 i = 0; i < consumers.length; i++) { - if (consumers[i] == consumer) { - address last = consumers[lastConsumerIndex]; - // Storage write to preserve last element - s_subscriptionConfigs[subscriptionId].consumers[i] = last; - // Storage remove last element - s_subscriptionConfigs[subscriptionId].consumers.pop(); - break; - } - } - delete s_consumers[consumer][subscriptionId]; - emit SubscriptionConsumerRemoved(subscriptionId, consumer); - } - - /** - * @notice Add a consumer to a Chainlink Functions subscription. - * @param subscriptionId - ID of the subscription - * @param consumer - New consumer which can use the subscription - */ - function addConsumer( - uint64 subscriptionId, - address consumer - ) external onlySubOwner(subscriptionId) nonReentrant whenNotPaused { - // Already maxed, cannot add any more consumers. - if (s_subscriptionConfigs[subscriptionId].consumers.length == MAX_CONSUMERS) { - revert TooManyConsumers(); - } - if (s_consumers[consumer][subscriptionId] != 0) { - // Idempotence - do nothing if already added. - // Ensures uniqueness in s_subscriptions[subscriptionId].consumers. - return; - } - // Initialize the nonce to 1, indicating the consumer is allocated. - s_consumers[consumer][subscriptionId] = 1; - s_subscriptionConfigs[subscriptionId].consumers.push(consumer); - - emit SubscriptionConsumerAdded(subscriptionId, consumer); - } - - /** - * @notice Cancel a subscription - * @param subscriptionId - ID of the subscription - * @param to - Where to send the remaining LINK to - */ - function cancelSubscription( - uint64 subscriptionId, - address to - ) external onlySubOwner(subscriptionId) nonReentrant whenNotPaused { - if (pendingRequestExists(subscriptionId)) { - revert PendingRequestExists(); - } - cancelSubscriptionHelper(subscriptionId, to); - } - - function cancelSubscriptionHelper(uint64 subscriptionId, address to) private nonReentrant { - SubscriptionConfig memory subConfig = s_subscriptionConfigs[subscriptionId]; - uint96 balance = s_subscriptions[subscriptionId].balance; - // Note bounded by MAX_CONSUMERS; - // If no consumers, does nothing. - for (uint256 i = 0; i < subConfig.consumers.length; i++) { - delete s_consumers[subConfig.consumers[i]][subscriptionId]; - } - delete s_subscriptionConfigs[subscriptionId]; - delete s_subscriptions[subscriptionId]; - s_totalBalance -= balance; - if (!LINK.transfer(to, uint256(balance))) { - revert InsufficientBalance(); - } - emit SubscriptionCanceled(subscriptionId, to, balance); - } - - /** - * @notice Check to see if there exists a request commitment for all consumers for a given sub. - * @param subscriptionId - ID of the subscription - * @return true if there exists at least one unfulfilled request for the subscription, false - * otherwise. - * @dev Looping is bounded to MAX_CONSUMERS*(number of DONs). - * @dev Used to disable subscription canceling while outstanding request are present. - */ - - function pendingRequestExists(uint64 subscriptionId) public view returns (bool) { - address[] memory consumers = s_subscriptionConfigs[subscriptionId].consumers; - address[] memory authorizedSendersList = getAuthorizedSenders(); - for (uint256 i = 0; i < consumers.length; i++) { - for (uint256 j = 0; j < authorizedSendersList.length; j++) { - bytes32 requestId = computeRequestId( - authorizedSendersList[j], - consumers[i], - subscriptionId, - s_consumers[consumers[i]][subscriptionId] - ); - if (s_requestCommitments[requestId].don != address(0)) { - return true; - } - } - } - return false; - } - - /** - * @notice Time out all expired requests: unlocks funds and removes the ability for the request to be fulfilled - * @param requestIdsToTimeout - A list of request IDs to time out - */ - - function timeoutRequests(bytes32[] calldata requestIdsToTimeout) external whenNotPaused { - for (uint256 i = 0; i < requestIdsToTimeout.length; i++) { - bytes32 requestId = requestIdsToTimeout[i]; - Commitment memory commitment = s_requestCommitments[requestId]; - - // Check that the message sender is the subscription owner - if (msg.sender != s_subscriptionConfigs[commitment.subscriptionId].owner) { - revert MustBeSubOwner(s_subscriptionConfigs[commitment.subscriptionId].owner); - } - - if (commitment.timestamp + s_config.requestTimeoutSeconds > block.timestamp) { - // Decrement blocked balance - s_subscriptions[commitment.subscriptionId].blockedBalance -= commitment.estimatedCost; - // Delete commitment - delete s_requestCommitments[requestId]; - emit RequestTimedOut(requestId); - } - } - } - - /** - * @dev The allow list is kept on the Oracle contract. This modifier checks if a user is authorized from there. - */ - modifier onlyAuthorizedUsers() { - if (ORACLE_WITH_ALLOWLIST.authorizedReceiverActive() && !ORACLE_WITH_ALLOWLIST.isAuthorizedSender(msg.sender)) { - revert UnauthorizedSender(); - } - _; - } - - modifier onlySubOwner(uint64 subscriptionId) { - address owner = s_subscriptionConfigs[subscriptionId].owner; - if (owner == address(0)) { - revert InvalidSubscription(); - } - if (msg.sender != owner) { - revert MustBeSubOwner(owner); - } - _; - } - - modifier nonReentrant() { - if (s_config.reentrancyLock) { - revert Reentrant(); - } - _; - } - - function _canSetAuthorizedSenders() internal view override onlyOwner returns (bool) { - return true; - } - - /** - * @dev This empty reserved space is put in place to allow future versions to add new - * variables without shifting down storage in the inheritance chain. - * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps - */ - uint256[49] private __gap; -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/FunctionsClient.sol b/contracts/src/v0.8/functions/dev/v0_0_0/FunctionsClient.sol deleted file mode 100644 index 355d50f8e3c..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/FunctionsClient.sol +++ /dev/null @@ -1,138 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {Functions} from "./Functions.sol"; -import {IFunctionsClient} from "./interfaces/IFunctionsClient.sol"; -import {IFunctionsOracle} from "./interfaces/IFunctionsOracle.sol"; - -/** - * @title The Chainlink Functions client contract - * @notice Contract writers can inherit this contract in order to create Chainlink Functions requests - */ -abstract contract FunctionsClient is IFunctionsClient { - IFunctionsOracle internal s_oracle; - mapping(bytes32 => address) internal s_pendingRequests; - - event RequestSent(bytes32 indexed id); - event RequestFulfilled(bytes32 indexed id); - - error SenderIsNotRegistry(); - error RequestIsAlreadyPending(); - error RequestIsNotPending(); - - constructor(address oracle) { - setOracle(oracle); - } - - /** - * @inheritdoc IFunctionsClient - */ - function getDONPublicKey() external view override returns (bytes memory) { - return s_oracle.getDONPublicKey(); - } - - /** - * @notice Estimate the total cost that will be charged to a subscription to make a request: gas re-imbursement, plus DON fee, plus Registry fee - * @param req The initialized Functions.Request - * @param subscriptionId The subscription ID - * @param gasLimit gas limit for the fulfillment callback - * @return billedCost Cost in Juels (1e18) of LINK - */ - function estimateCost( - Functions.Request memory req, - uint64 subscriptionId, - uint32 gasLimit, - uint256 gasPrice - ) public view returns (uint96) { - return s_oracle.estimateCost(subscriptionId, Functions.encodeCBOR(req), gasLimit, gasPrice); - } - - /** - * @notice Sends a Chainlink Functions request to the stored oracle address - * @param req The initialized Functions.Request - * @param subscriptionId The subscription ID - * @param gasLimit gas limit for the fulfillment callback - * @return requestId The generated request ID - */ - function sendRequest( - Functions.Request memory req, - uint64 subscriptionId, - uint32 gasLimit - ) internal returns (bytes32) { - bytes32 requestId = s_oracle.sendRequest(subscriptionId, Functions.encodeCBOR(req), gasLimit); - s_pendingRequests[requestId] = s_oracle.getRegistry(); - emit RequestSent(requestId); - return requestId; - } - - /** - * @notice User defined function to handle a response - * @param requestId The request ID, returned by sendRequest() - * @param response Aggregated response from the user code - * @param err Aggregated error from the user code or from the execution pipeline - * Either response or error parameter will be set, but never both - */ - function fulfillRequest(bytes32 requestId, bytes memory response, bytes memory err) internal virtual; - - /** - * @inheritdoc IFunctionsClient - */ - function handleOracleFulfillment( - bytes32 requestId, - bytes memory response, - bytes memory err - ) external override recordChainlinkFulfillment(requestId) { - fulfillRequest(requestId, response, err); - } - - /** - * @notice Sets the stored Oracle address - * @param oracle The address of Functions Oracle contract - */ - function setOracle(address oracle) internal { - s_oracle = IFunctionsOracle(oracle); - } - - /** - * @notice Gets the stored address of the oracle contract - * @return The address of the oracle contract - */ - function getChainlinkOracleAddress() internal view returns (address) { - return address(s_oracle); - } - - /** - * @notice Allows for a request which was created on another contract to be fulfilled - * on this contract - * @param oracleAddress The address of the oracle contract that will fulfill the request - * @param requestId The request ID used for the response - */ - function addExternalRequest(address oracleAddress, bytes32 requestId) internal notPendingRequest(requestId) { - s_pendingRequests[requestId] = oracleAddress; - } - - /** - * @dev Reverts if the sender is not the oracle that serviced the request. - * Emits RequestFulfilled event. - * @param requestId The request ID for fulfillment - */ - modifier recordChainlinkFulfillment(bytes32 requestId) { - if (msg.sender != s_pendingRequests[requestId]) { - revert SenderIsNotRegistry(); - } - delete s_pendingRequests[requestId]; - emit RequestFulfilled(requestId); - _; - } - - /** - * @dev Reverts if the request is already pending - * @param requestId The request ID for fulfillment - */ - modifier notPendingRequest(bytes32 requestId) { - if (s_pendingRequests[requestId] != address(0)) { - revert RequestIsAlreadyPending(); - } - _; - } -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/FunctionsOracle.sol b/contracts/src/v0.8/functions/dev/v0_0_0/FunctionsOracle.sol deleted file mode 100644 index 1f284606054..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/FunctionsOracle.sol +++ /dev/null @@ -1,292 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {IFunctionsOracle, IFunctionsBillingRegistry} from "./interfaces/IFunctionsOracle.sol"; -import {OCR2BaseUpgradeable} from "./ocr/OCR2BaseUpgradeable.sol"; -import {AuthorizedOriginReceiverUpgradeable} from "./accessControl/AuthorizedOriginReceiverUpgradeable.sol"; -import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; - -/** - * @title Functions Oracle contract - * @notice Contract that nodes of a Decentralized Oracle Network (DON) interact with - * @dev THIS CONTRACT HAS NOT GONE THROUGH ANY SECURITY REVIEW. DO NOT USE IN PROD. - */ -contract FunctionsOracle is Initializable, IFunctionsOracle, OCR2BaseUpgradeable, AuthorizedOriginReceiverUpgradeable { - event OracleRequest( - bytes32 indexed requestId, - address requestingContract, - address requestInitiator, - uint64 subscriptionId, - address subscriptionOwner, - bytes data - ); - event OracleResponse(bytes32 indexed requestId); - event UserCallbackError(bytes32 indexed requestId, string reason); - event UserCallbackRawError(bytes32 indexed requestId, bytes lowLevelData); - event InvalidRequestID(bytes32 indexed requestId); - event ResponseTransmitted(bytes32 indexed requestId, address transmitter); - - error EmptyRequestData(); - error InconsistentReportData(); - error EmptyPublicKey(); - error EmptyBillingRegistry(); - error UnauthorizedPublicKeyChange(); - - bytes private s_donPublicKey; - IFunctionsBillingRegistry private s_registry; - mapping(address => bytes) private s_nodePublicKeys; - - bytes private s_thresholdPublicKey; - - /** - * @dev Initializes the contract. - */ - function initialize() public initializer { - __OCR2Base_initialize(true); - __AuthorizedOriginReceiver_initialize(true); - } - - /** - * @notice The type and version of this contract - * @return Type and version string - */ - function typeAndVersion() external pure override returns (string memory) { - return "FunctionsOracle 0.0.0"; - } - - /** - * @inheritdoc IFunctionsOracle - */ - function getRegistry() external view override returns (address) { - return address(s_registry); - } - - /** - * @inheritdoc IFunctionsOracle - */ - function setRegistry(address registryAddress) external override onlyOwner { - if (registryAddress == address(0)) { - revert EmptyBillingRegistry(); - } - s_registry = IFunctionsBillingRegistry(registryAddress); - } - - /** - * @inheritdoc IFunctionsOracle - */ - function getThresholdPublicKey() external view override returns (bytes memory) { - return s_thresholdPublicKey; - } - - /** - * @inheritdoc IFunctionsOracle - */ - function setThresholdPublicKey(bytes calldata thresholdPublicKey) external override onlyOwner { - if (thresholdPublicKey.length == 0) { - revert EmptyPublicKey(); - } - s_thresholdPublicKey = thresholdPublicKey; - } - - /** - * @inheritdoc IFunctionsOracle - */ - function getDONPublicKey() external view override returns (bytes memory) { - return s_donPublicKey; - } - - /** - * @inheritdoc IFunctionsOracle - */ - function setDONPublicKey(bytes calldata donPublicKey) external override onlyOwner { - if (donPublicKey.length == 0) { - revert EmptyPublicKey(); - } - s_donPublicKey = donPublicKey; - } - - /** - * @dev check if node is in current transmitter list - */ - function _isTransmitter(address node) internal view returns (bool) { - address[] memory nodes = this.transmitters(); - for (uint256 i = 0; i < nodes.length; i++) { - if (nodes[i] == node) { - return true; - } - } - return false; - } - - /** - * @inheritdoc IFunctionsOracle - */ - function setNodePublicKey(address node, bytes calldata publicKey) external override { - // Owner can set anything. Transmitters can set only their own key. - if (!(msg.sender == owner() || (_isTransmitter(msg.sender) && msg.sender == node))) { - revert UnauthorizedPublicKeyChange(); - } - s_nodePublicKeys[node] = publicKey; - } - - /** - * @inheritdoc IFunctionsOracle - */ - function deleteNodePublicKey(address node) external override { - // Owner can delete anything. Others can delete only their own key. - if (!(msg.sender == owner() || msg.sender == node)) { - revert UnauthorizedPublicKeyChange(); - } - delete s_nodePublicKeys[node]; - } - - /** - * @inheritdoc IFunctionsOracle - */ - function getAllNodePublicKeys() external view override returns (address[] memory, bytes[] memory) { - address[] memory nodes = this.transmitters(); - bytes[] memory keys = new bytes[](nodes.length); - for (uint256 i = 0; i < nodes.length; i++) { - keys[i] = s_nodePublicKeys[nodes[i]]; - } - return (nodes, keys); - } - - /** - * @inheritdoc IFunctionsOracle - */ - function getRequiredFee( - bytes calldata /* data */, - IFunctionsBillingRegistry.RequestBilling memory /* billing */ - ) public pure override returns (uint96) { - // NOTE: Optionally, compute additional fee split between nodes of the DON here - // e.g. 0.1 LINK * s_transmitters.length - return 0; - } - - /** - * @inheritdoc IFunctionsOracle - */ - function estimateCost( - uint64 subscriptionId, - bytes calldata data, - uint32 gasLimit, - uint256 gasPrice - ) external view override registryIsSet returns (uint96) { - IFunctionsBillingRegistry.RequestBilling memory billing = IFunctionsBillingRegistry.RequestBilling( - subscriptionId, - msg.sender, - gasLimit, - gasPrice - ); - uint96 donFee = getRequiredFee(data, billing); - uint96 registryFee = s_registry.getRequiredFee(data, billing); - return s_registry.estimateCost(gasLimit, gasPrice, donFee, registryFee); - } - - /** - * @inheritdoc IFunctionsOracle - */ - function sendRequest( - uint64 subscriptionId, - bytes calldata data, - uint32 gasLimit - ) external override registryIsSet validateAuthorizedSender returns (bytes32) { - if (data.length == 0) { - revert EmptyRequestData(); - } - bytes32 requestId = s_registry.startBilling( - data, - IFunctionsBillingRegistry.RequestBilling(subscriptionId, msg.sender, gasLimit, tx.gasprice) - ); - emit OracleRequest( - requestId, - msg.sender, - tx.origin, - subscriptionId, - s_registry.getSubscriptionOwner(subscriptionId), - data - ); - return requestId; - } - - function _beforeSetConfig(uint8 _f, bytes memory _onchainConfig) internal override {} - - function _afterSetConfig(uint8 _f, bytes memory _onchainConfig) internal override {} - - function _validateReport( - bytes32 /* configDigest */, - uint40 /* epochAndRound */, - bytes memory /* report */ - ) internal pure override returns (bool) { - // validate within _report to save gas - return true; - } - - function _report( - uint256 initialGas, - address transmitter, - uint8 signerCount, - address[maxNumOracles] memory signers, - bytes calldata report - ) internal override registryIsSet { - bytes32[] memory requestIds; - bytes[] memory results; - bytes[] memory errors; - (requestIds, results, errors) = abi.decode(report, (bytes32[], bytes[], bytes[])); - if (requestIds.length == 0 || requestIds.length != results.length || requestIds.length != errors.length) { - revert ReportInvalid(); - } - - uint256 reportValidationGasShare = (initialGas - gasleft()) / requestIds.length; - - for (uint256 i = 0; i < requestIds.length; i++) { - try - s_registry.fulfillAndBill( - requestIds[i], - results[i], - errors[i], - transmitter, - signers, - signerCount, - reportValidationGasShare, - gasleft() - ) - returns (IFunctionsBillingRegistry.FulfillResult result) { - if (result == IFunctionsBillingRegistry.FulfillResult.USER_SUCCESS) { - emit OracleResponse(requestIds[i]); - emit ResponseTransmitted(requestIds[i], transmitter); - } else if (result == IFunctionsBillingRegistry.FulfillResult.USER_ERROR) { - emit UserCallbackError(requestIds[i], "error in callback"); - emit ResponseTransmitted(requestIds[i], transmitter); - } else if (result == IFunctionsBillingRegistry.FulfillResult.INVALID_REQUEST_ID) { - emit InvalidRequestID(requestIds[i]); - } - } catch (bytes memory reason) { - emit UserCallbackRawError(requestIds[i], reason); - emit ResponseTransmitted(requestIds[i], transmitter); - } - } - } - - /** - * @dev Reverts if the the billing registry is not set - */ - modifier registryIsSet() { - if (address(s_registry) == address(0)) { - revert EmptyBillingRegistry(); - } - _; - } - - function _canSetAuthorizedSenders() internal view override returns (bool) { - return msg.sender == owner(); - } - - /** - * @dev This empty reserved space is put in place to allow future versions to add new - * variables without shifting down storage in the inheritance chain. - * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps - */ - uint256[48] private __gap; -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/AuthorizedOriginReceiver.sol b/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/AuthorizedOriginReceiver.sol deleted file mode 100644 index 16918072fba..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/AuthorizedOriginReceiver.sol +++ /dev/null @@ -1,151 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {EnumerableSet} from "../../../../vendor/openzeppelin-solidity/v4.8.0/contracts/utils/structs/EnumerableSet.sol"; -import {IAuthorizedOriginReceiver} from "./interfaces/IAuthorizedOriginReceiver.sol"; - -/** - * @notice Modified AuthorizedReciever abstract for use on the FunctionsOracle contract to limit usage - * @notice Uses tx.origin instead of msg.sender because the client contract sends messages to the Oracle contract - */ - -abstract contract AuthorizedOriginReceiver is IAuthorizedOriginReceiver { - using EnumerableSet for EnumerableSet.AddressSet; - - event AuthorizedSendersChanged(address[] senders, address changedBy); - event AuthorizedSendersActive(address account); - event AuthorizedSendersDeactive(address account); - - error EmptySendersList(); - error UnauthorizedSender(); - error NotAllowedToSetSenders(); - error AlreadySet(); - - bool private s_active; - EnumerableSet.AddressSet private s_authorizedSenders; - - /** - * @dev Initializes the contract in active state. - */ - constructor() { - s_active = true; - } - - /** - * @dev Returns true if the contract is paused, and false otherwise. - */ - function authorizedReceiverActive() public view virtual override returns (bool) { - return s_active; - } - - /** - * @dev Triggers AuthorizedOriginReceiver usage to block unuthorized senders. - * - * Requirements: - * - * - The contract must not be deactive. - */ - function activateAuthorizedReceiver() external override validateAuthorizedSenderSetter { - if (authorizedReceiverActive()) { - revert AlreadySet(); - } - s_active = true; - emit AuthorizedSendersActive(msg.sender); - } - - /** - * @dev Triggers AuthorizedOriginReceiver usage to allow all senders. - * - * Requirements: - * - * - The contract must be active. - */ - function deactivateAuthorizedReceiver() external override validateAuthorizedSenderSetter { - if (!authorizedReceiverActive()) { - revert AlreadySet(); - } - s_active = false; - emit AuthorizedSendersDeactive(msg.sender); - } - - /** - * @notice Sets the permission to request for the given wallet(s). - * @param senders The addresses of the wallet addresses to grant access - */ - function addAuthorizedSenders(address[] calldata senders) external override validateAuthorizedSenderSetter { - if (senders.length == 0) { - revert EmptySendersList(); - } - for (uint256 i = 0; i < senders.length; i++) { - s_authorizedSenders.add(senders[i]); - } - emit AuthorizedSendersChanged(senders, msg.sender); - } - - /** - * @notice Remove the permission to request for the given wallet(s). - * @param senders The addresses of the wallet addresses to revoke access - */ - function removeAuthorizedSenders(address[] calldata senders) external override validateAuthorizedSenderSetter { - if (senders.length == 0) { - revert EmptySendersList(); - } - for (uint256 i = 0; i < senders.length; i++) { - s_authorizedSenders.remove(senders[i]); - } - emit AuthorizedSendersChanged(senders, msg.sender); - } - - /** - * @notice Retrieve a list of authorized senders - * @return array of addresses - */ - function getAuthorizedSenders() public view override returns (address[] memory) { - return EnumerableSet.values(s_authorizedSenders); - } - - /** - * @notice Use this to check if a node is authorized for fulfilling requests - * @param sender The address of the Chainlink node - * @return The authorization status of the node - */ - function isAuthorizedSender(address sender) public view override returns (bool) { - if (!authorizedReceiverActive()) { - return true; - } - return s_authorizedSenders.contains(sender); - } - - /** - * @notice customizable guard of who can update the authorized sender list - * @return bool whether sender can update authorized sender list - */ - function _canSetAuthorizedSenders() internal virtual returns (bool); - - /** - * @notice validates the sender is an authorized sender - */ - function _validateIsAuthorizedSender() internal view { - if (!isAuthorizedSender(tx.origin)) { - revert UnauthorizedSender(); - } - } - - /** - * @notice prevents non-authorized addresses from calling this method - */ - modifier validateAuthorizedSender() { - _validateIsAuthorizedSender(); - _; - } - - /** - * @notice prevents non-authorized addresses from calling this method - */ - modifier validateAuthorizedSenderSetter() { - if (!_canSetAuthorizedSenders()) { - revert NotAllowedToSetSenders(); - } - _; - } -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/AuthorizedOriginReceiverUpgradeable.sol b/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/AuthorizedOriginReceiverUpgradeable.sol deleted file mode 100644 index d59f61526a4..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/AuthorizedOriginReceiverUpgradeable.sol +++ /dev/null @@ -1,153 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {EnumerableSet} from "../../../../vendor/openzeppelin-solidity/v4.8.0/contracts/utils/structs/EnumerableSet.sol"; -import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; -import {IAuthorizedOriginReceiver} from "./interfaces/IAuthorizedOriginReceiver.sol"; - -/** - * @notice Modified AuthorizedReciever abstract for use on the FunctionsOracle contract to limit usage - * @notice Uses tx.origin instead of msg.sender because the client contract sends messages to the Oracle contract - */ - -abstract contract AuthorizedOriginReceiverUpgradeable is Initializable, IAuthorizedOriginReceiver { - using EnumerableSet for EnumerableSet.AddressSet; - - event AuthorizedSendersChanged(address[] senders, address changedBy); - event AuthorizedSendersActive(address account); - event AuthorizedSendersDeactive(address account); - - error EmptySendersList(); - error UnauthorizedSender(); - error NotAllowedToSetSenders(); - error AlreadySet(); - - bool private s_active; - EnumerableSet.AddressSet private s_authorizedSenders; - address[] private s_authorizedSendersList; // DEPRECATED, TODO: remove on proxy re-deploy - - /** - * @dev Initializes the contract in active state. - */ - function __AuthorizedOriginReceiver_initialize(bool active) internal onlyInitializing { - s_active = active; - } - - /** - * @dev Returns true if the contract is paused, and false otherwise. - */ - function authorizedReceiverActive() public view virtual override returns (bool) { - return s_active; - } - - /** - * @dev Triggers AuthorizedOriginReceiver usage to block unuthorized senders. - * - * Requirements: - * - * - The contract must not be deactive. - */ - function activateAuthorizedReceiver() external override validateAuthorizedSenderSetter { - if (authorizedReceiverActive()) { - revert AlreadySet(); - } - s_active = true; - emit AuthorizedSendersActive(msg.sender); - } - - /** - * @dev Triggers AuthorizedOriginReceiver usage to allow all senders. - * - * Requirements: - * - * - The contract must be active. - */ - function deactivateAuthorizedReceiver() external override validateAuthorizedSenderSetter { - if (!authorizedReceiverActive()) { - revert AlreadySet(); - } - s_active = false; - emit AuthorizedSendersDeactive(msg.sender); - } - - /** - * @notice Sets the permission to request for the given wallet(s). - * @param senders The addresses of the wallet addresses to grant access - */ - function addAuthorizedSenders(address[] calldata senders) external override validateAuthorizedSenderSetter { - if (senders.length == 0) { - revert EmptySendersList(); - } - for (uint256 i = 0; i < senders.length; i++) { - s_authorizedSenders.add(senders[i]); - } - emit AuthorizedSendersChanged(senders, msg.sender); - } - - /** - * @notice Remove the permission to request for the given wallet(s). - * @param senders The addresses of the wallet addresses to revoke access - */ - function removeAuthorizedSenders(address[] calldata senders) external override validateAuthorizedSenderSetter { - if (senders.length == 0) { - revert EmptySendersList(); - } - for (uint256 i = 0; i < senders.length; i++) { - s_authorizedSenders.remove(senders[i]); - } - emit AuthorizedSendersChanged(senders, msg.sender); - } - - /** - * @notice Retrieve a list of authorized senders - * @return array of addresses - */ - function getAuthorizedSenders() public view override returns (address[] memory) { - return EnumerableSet.values(s_authorizedSenders); - } - - /** - * @notice Use this to check if a node is authorized for fulfilling requests - * @param sender The address of the Chainlink node - * @return The authorization status of the node - */ - function isAuthorizedSender(address sender) public view override returns (bool) { - if (!authorizedReceiverActive()) { - return true; - } - return s_authorizedSenders.contains(sender); - } - - /** - * @notice customizable guard of who can update the authorized sender list - * @return bool whether sender can update authorized sender list - */ - function _canSetAuthorizedSenders() internal virtual returns (bool); - - /** - * @notice validates the sender is an authorized sender - */ - function _validateIsAuthorizedSender() internal view { - if (!isAuthorizedSender(tx.origin)) { - revert UnauthorizedSender(); - } - } - - /** - * @notice prevents non-authorized addresses from calling this method - */ - modifier validateAuthorizedSender() { - _validateIsAuthorizedSender(); - _; - } - - /** - * @notice prevents non-authorized addresses from calling this method - */ - modifier validateAuthorizedSenderSetter() { - if (!_canSetAuthorizedSenders()) { - revert NotAllowedToSetSenders(); - } - _; - } -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/AuthorizedReceiver.sol b/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/AuthorizedReceiver.sol deleted file mode 100644 index 92d8af6891d..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/AuthorizedReceiver.sol +++ /dev/null @@ -1,86 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {EnumerableSet} from "../../../../vendor/openzeppelin-solidity/v4.8.0/contracts/utils/structs/EnumerableSet.sol"; -import {IAuthorizedReceiver} from "./interfaces/IAuthorizedReceiver.sol"; - -abstract contract AuthorizedReceiver is IAuthorizedReceiver { - using EnumerableSet for EnumerableSet.AddressSet; - - event AuthorizedSendersChanged(address[] senders, address changedBy); - - error EmptySendersList(); - error UnauthorizedSender(); - error NotAllowedToSetSenders(); - - EnumerableSet.AddressSet private s_authorizedSenders; - address[] private s_authorizedSendersList; - - /** - * @notice Sets the fulfillment permission for a given node. Use `true` to allow, `false` to disallow. - * @param senders The addresses of the authorized Chainlink node - */ - function setAuthorizedSenders(address[] calldata senders) external override validateAuthorizedSenderSetter { - if (senders.length == 0) { - revert EmptySendersList(); - } - for (uint256 i = 0; i < s_authorizedSendersList.length; i++) { - s_authorizedSenders.remove(s_authorizedSendersList[i]); - } - for (uint256 i = 0; i < senders.length; i++) { - s_authorizedSenders.add(senders[i]); - } - s_authorizedSendersList = senders; - emit AuthorizedSendersChanged(senders, msg.sender); - } - - /** - * @notice Retrieve a list of authorized senders - * @return array of addresses - */ - function getAuthorizedSenders() public view override returns (address[] memory) { - return s_authorizedSendersList; - } - - /** - * @notice Use this to check if a node is authorized for fulfilling requests - * @param sender The address of the Chainlink node - * @return The authorization status of the node - */ - function isAuthorizedSender(address sender) public view override returns (bool) { - return s_authorizedSenders.contains(sender); - } - - /** - * @notice customizable guard of who can update the authorized sender list - * @return bool whether sender can update authorized sender list - */ - function _canSetAuthorizedSenders() internal virtual returns (bool); - - /** - * @notice validates the sender is an authorized sender - */ - function _validateIsAuthorizedSender() internal view { - if (!isAuthorizedSender(msg.sender)) { - revert UnauthorizedSender(); - } - } - - /** - * @notice prevents non-authorized addresses from calling this method - */ - modifier validateAuthorizedSender() { - _validateIsAuthorizedSender(); - _; - } - - /** - * @notice prevents non-authorized addresses from calling this method - */ - modifier validateAuthorizedSenderSetter() { - if (!_canSetAuthorizedSenders()) { - revert NotAllowedToSetSenders(); - } - _; - } -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/ConfirmedOwnerUpgradeable.sol b/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/ConfirmedOwnerUpgradeable.sol deleted file mode 100644 index c2faec08a63..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/ConfirmedOwnerUpgradeable.sol +++ /dev/null @@ -1,96 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {IOwnable} from "../../../../shared/interfaces/IOwnable.sol"; -import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; - -/** - * @title The ConfirmedOwnerUpgradeable contract - * @notice An upgrade compatible contract with helpers for basic contract ownership. - */ -contract ConfirmedOwnerUpgradeable is Initializable, IOwnable { - address private s_owner; - address private s_pendingOwner; - - event OwnershipTransferRequested(address indexed from, address indexed to); - event OwnershipTransferred(address indexed from, address indexed to); - - error OwnerMustBeSet(); - error NotProposedOwner(); - error CannotSelfTransfer(); - error OnlyCallableByOwner(); - - /** - * @dev Initializes the contract in unpaused state. - */ - function __ConfirmedOwner_initialize(address newOwner, address pendingOwner) internal onlyInitializing { - if (newOwner == address(0)) { - revert OwnerMustBeSet(); - } - - s_owner = newOwner; - if (pendingOwner != address(0)) { - _transferOwnership(pendingOwner); - } - } - - /** - * @notice Allows an owner to begin transferring ownership to a new address, - * pending. - */ - function transferOwnership(address to) public override onlyOwner { - _transferOwnership(to); - } - - /** - * @notice Allows an ownership transfer to be completed by the recipient. - */ - function acceptOwnership() external override { - if (msg.sender != s_pendingOwner) { - revert NotProposedOwner(); - } - - address oldOwner = s_owner; - s_owner = msg.sender; - s_pendingOwner = address(0); - - emit OwnershipTransferred(oldOwner, msg.sender); - } - - /** - * @notice Get the current owner - */ - function owner() public view override returns (address) { - return s_owner; - } - - /** - * @notice validate, transfer ownership, and emit relevant events - */ - function _transferOwnership(address to) private { - if (to == msg.sender) { - revert CannotSelfTransfer(); - } - - s_pendingOwner = to; - - emit OwnershipTransferRequested(s_owner, to); - } - - /** - * @notice validate access - */ - function _validateOwnership() internal view { - if (msg.sender != s_owner) { - revert OnlyCallableByOwner(); - } - } - - /** - * @notice Reverts if called by anyone other than the contract owner. - */ - modifier onlyOwner() { - _validateOwnership(); - _; - } -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/interfaces/IAuthorizedOriginReceiver.sol b/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/interfaces/IAuthorizedOriginReceiver.sol deleted file mode 100644 index dd3dbb71430..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/interfaces/IAuthorizedOriginReceiver.sol +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -/** - * @notice Modified AuthorizedReciever abstract for use on the Functions Oracle contract to limit usage - * @notice Uses tx.origin instead of msg.sender because the client contract sends messages to the Oracle contract - */ - -interface IAuthorizedOriginReceiver { - /** - * @dev Returns true if the contract is paused, and false otherwise. - */ - function authorizedReceiverActive() external view returns (bool); - - /** - * @dev Triggers AuthorizedOriginReceiver usage to block unuthorized senders. - * - * Requirements: - * - * - The contract must not be deactive. - */ - function activateAuthorizedReceiver() external; - - /** - * @dev Triggers AuthorizedOriginReceiver usage to allow all senders. - * - * Requirements: - * - * - The contract must be active. - */ - function deactivateAuthorizedReceiver() external; - - /** - * @notice Sets the permission to request for the given wallet(s). - * @param senders The addresses of the wallet addresses to grant access - */ - function addAuthorizedSenders(address[] calldata senders) external; - - /** - * @notice Remove the permission to request for the given wallet(s). - * @param senders The addresses of the wallet addresses to revoke access - */ - function removeAuthorizedSenders(address[] calldata senders) external; - - /** - * @notice Retrieve a list of authorized senders - * @return array of addresses - */ - function getAuthorizedSenders() external view returns (address[] memory); - - /** - * @notice Use this to check if a node is authorized for fulfilling requests - * @param sender The address of the Chainlink node - * @return The authorization status of the node - */ - function isAuthorizedSender(address sender) external view returns (bool); -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/interfaces/IAuthorizedReceiver.sol b/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/interfaces/IAuthorizedReceiver.sol deleted file mode 100644 index 78140d58682..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/accessControl/interfaces/IAuthorizedReceiver.sol +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -interface IAuthorizedReceiver { - function isAuthorizedSender(address sender) external view returns (bool); - - function getAuthorizedSenders() external returns (address[] memory); - - function setAuthorizedSenders(address[] calldata senders) external; -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/example/FunctionsClientExample.sol b/contracts/src/v0.8/functions/dev/v0_0_0/example/FunctionsClientExample.sol deleted file mode 100644 index 2d118c6961a..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/example/FunctionsClientExample.sol +++ /dev/null @@ -1,75 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {FunctionsClient} from "../FunctionsClient.sol"; -import {Functions} from "../Functions.sol"; -import {ConfirmedOwner} from "../../../../shared/access/ConfirmedOwner.sol"; - -/** - * @title Chainlink Functions example client contract implementation - */ -contract FunctionsClientExample is FunctionsClient, ConfirmedOwner { - using Functions for Functions.Request; - - uint32 public constant MAX_CALLBACK_GAS = 70_000; - - bytes32 public lastRequestId; - bytes32 public lastResponse; - bytes32 public lastError; - uint32 public lastResponseLength; - uint32 public lastErrorLength; - - error UnexpectedRequestID(bytes32 requestId); - - constructor(address oracle) FunctionsClient(oracle) ConfirmedOwner(msg.sender) {} - - /** - * @notice Send a simple request - * @param source JavaScript source code - * @param secrets Encrypted secrets payload - * @param args List of arguments accessible from within the source code - * @param subscriptionId Billing ID - */ - function SendRequest( - string calldata source, - bytes calldata secrets, - string[] calldata args, - uint64 subscriptionId - ) external onlyOwner { - Functions.Request memory req; - req.initializeRequestForInlineJavaScript(source); - if (secrets.length > 0) req.addRemoteSecrets(secrets); - if (args.length > 0) req.addArgs(args); - lastRequestId = sendRequest(req, subscriptionId, MAX_CALLBACK_GAS); - } - - /** - * @notice Store latest result/error - * @param requestId The request ID, returned by sendRequest() - * @param response Aggregated response from the user code - * @param err Aggregated error from the user code or from the execution pipeline - * Either response or error parameter will be set, but never both - */ - function fulfillRequest(bytes32 requestId, bytes memory response, bytes memory err) internal override { - if (lastRequestId != requestId) { - revert UnexpectedRequestID(requestId); - } - // Save only the first 32 bytes of reponse/error to always fit within MAX_CALLBACK_GAS - lastResponse = bytesToBytes32(response); - lastResponseLength = uint32(response.length); - lastError = bytesToBytes32(err); - lastErrorLength = uint32(err.length); - } - - function bytesToBytes32(bytes memory b) private pure returns (bytes32) { - bytes32 out; - uint256 maxLen = 32; - if (b.length < 32) { - maxLen = b.length; - } - for (uint256 i = 0; i < maxLen; i++) { - out |= bytes32(b[i]) >> (i * 8); - } - return out; - } -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/interfaces/IFunctionsBillingRegistry.sol b/contracts/src/v0.8/functions/dev/v0_0_0/interfaces/IFunctionsBillingRegistry.sol deleted file mode 100644 index 01a7f72ecbe..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/interfaces/IFunctionsBillingRegistry.sol +++ /dev/null @@ -1,96 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -/** - * @title Chainlink Functions billing subscription registry interface. - */ -interface IFunctionsBillingRegistry { - struct RequestBilling { - // a unique subscription ID allocated by billing system, - uint64 subscriptionId; - // the client contract that initiated the request to the DON - // to use the subscription it must be added as a consumer on the subscription - address client; - // customer specified gas limit for the fulfillment callback - uint32 gasLimit; - // the expected gas price used to execute the transaction - uint256 gasPrice; - } - - enum FulfillResult { - USER_SUCCESS, - USER_ERROR, - INVALID_REQUEST_ID - } - - /** - * @notice Get configuration relevant for making requests - * @return uint32 global max for request gas limit - * @return address[] list of registered DONs - */ - function getRequestConfig() external view returns (uint32, address[] memory); - - /** - * @notice Determine the charged fee that will be paid to the Registry owner - * @param data Encoded Chainlink Functions request data, use FunctionsClient API to encode a request - * @param billing The request's billing configuration - * @return fee Cost in Juels (1e18) of LINK - */ - function getRequiredFee(bytes calldata data, RequestBilling memory billing) external view returns (uint96); - - /** - * @notice Estimate the total cost to make a request: gas re-imbursement, plus DON fee, plus Registry fee - * @param gasLimit Encoded Chainlink Functions request data, use FunctionsClient API to encode a request - * @param gasPrice The request's billing configuration - * @param donFee Fee charged by the DON that is paid to Oracle Node - * @param registryFee Fee charged by the DON that is paid to Oracle Node - * @return costEstimate Cost in Juels (1e18) of LINK - */ - function estimateCost( - uint32 gasLimit, - uint256 gasPrice, - uint96 donFee, - uint96 registryFee - ) external view returns (uint96); - - /** - * @notice Initiate the billing process for an Functions request - * @param data Encoded Chainlink Functions request data, use FunctionsClient API to encode a request - * @param billing Billing configuration for the request - * @return requestId - A unique identifier of the request. Can be used to match a request to a response in fulfillRequest. - * @dev Only callable by a node that has been approved on the Registry - */ - function startBilling(bytes calldata data, RequestBilling calldata billing) external returns (bytes32); - - /** - * @notice Finalize billing process for an Functions request by sending a callback to the Client contract and then charging the subscription - * @param requestId identifier for the request that was generated by the Registry in the beginBilling commitment - * @param response response data from DON consensus - * @param err error from DON consensus - * @param transmitter the Oracle who sent the report - * @param signers the Oracles who had a part in generating the report - * @param signerCount the number of signers on the report - * @param reportValidationGas the amount of gas used for the report validation. Cost is split by all fulfillments on the report. - * @param initialGas the initial amount of gas that should be used as a baseline to charge the single fulfillment for execution cost - * @return result fulfillment result - * @dev Only callable by a node that has been approved on the Registry - * @dev simulated offchain to determine if sufficient balance is present to fulfill the request - */ - function fulfillAndBill( - bytes32 requestId, - bytes calldata response, - bytes calldata err, - address transmitter, - address[31] memory signers, // 31 comes from OCR2Abstract.sol's maxNumOracles constant - uint8 signerCount, - uint256 reportValidationGas, - uint256 initialGas - ) external returns (FulfillResult); - - /** - * @notice Gets subscription owner. - * @param subscriptionId - ID of the subscription - * @return owner - owner of the subscription. - */ - function getSubscriptionOwner(uint64 subscriptionId) external view returns (address owner); -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/interfaces/IFunctionsClient.sol b/contracts/src/v0.8/functions/dev/v0_0_0/interfaces/IFunctionsClient.sol deleted file mode 100644 index bf7b74c2209..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/interfaces/IFunctionsClient.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -/** - * @title Chainlink Functions client interface. - */ -interface IFunctionsClient { - /** - * @notice Returns the DON's secp256k1 public key used to encrypt secrets - * @dev All Oracles nodes have the corresponding private key - * needed to decrypt the secrets encrypted with the public key - * @return publicKey DON's public key - */ - function getDONPublicKey() external view returns (bytes memory); - - /** - * @notice Chainlink Functions response handler called by the designated transmitter node in an OCR round. - * @param requestId The requestId returned by FunctionsClient.sendRequest(). - * @param response Aggregated response from the user code. - * @param err Aggregated error either from the user code or from the execution pipeline. - * Either response or error parameter will be set, but never both. - */ - function handleOracleFulfillment(bytes32 requestId, bytes memory response, bytes memory err) external; -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/interfaces/IFunctionsOracle.sol b/contracts/src/v0.8/functions/dev/v0_0_0/interfaces/IFunctionsOracle.sol deleted file mode 100644 index 52f8023b7b9..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/interfaces/IFunctionsOracle.sol +++ /dev/null @@ -1,108 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {IFunctionsBillingRegistry} from "./IFunctionsBillingRegistry.sol"; - -/** - * @title Chainlink Functions oracle interface. - */ -interface IFunctionsOracle { - /** - * @notice Gets the stored billing registry address - * @return registryAddress The address of Chainlink Functions billing registry contract - */ - function getRegistry() external view returns (address); - - /** - * @notice Sets the stored billing registry address - * @param registryAddress The new address of Chainlink Functions billing registry contract - */ - function setRegistry(address registryAddress) external; - - /** - * @notice Returns the DON's threshold encryption public key used to encrypt secrets - * @dev All nodes on the DON have separate key shares of the threshold decryption key - * and nodes must participate in a threshold decryption OCR round to decrypt secrets - * @return thresholdPublicKey the DON's threshold encryption public key - */ - function getThresholdPublicKey() external view returns (bytes memory); - - /** - * @notice Sets the DON's threshold encryption public key used to encrypt secrets - * @dev Used to rotate the key - * @param thresholdPublicKey The new public key - */ - function setThresholdPublicKey(bytes calldata thresholdPublicKey) external; - - /** - * @notice Returns the DON's secp256k1 public key that is used to encrypt secrets - * @dev All nodes on the DON have the corresponding private key - * needed to decrypt the secrets encrypted with the public key - * @return publicKey the DON's public key - */ - function getDONPublicKey() external view returns (bytes memory); - - /** - * @notice Sets DON's secp256k1 public key used to encrypt secrets - * @dev Used to rotate the key - * @param donPublicKey The new public key - */ - function setDONPublicKey(bytes calldata donPublicKey) external; - - /** - * @notice Sets a per-node secp256k1 public key used to encrypt secrets for that node - * @dev Callable only by contract owner and DON members - * @param node node's address - * @param publicKey node's public key - */ - function setNodePublicKey(address node, bytes calldata publicKey) external; - - /** - * @notice Deletes node's public key - * @dev Callable only by contract owner or the node itself - * @param node node's address - */ - function deleteNodePublicKey(address node) external; - - /** - * @notice Return two arrays of equal size containing DON members' addresses and their corresponding - * public keys (or empty byte arrays if per-node key is not defined) - */ - function getAllNodePublicKeys() external view returns (address[] memory, bytes[] memory); - - /** - * @notice Determine the fee charged by the DON that will be split between signing Node Operators for servicing the request - * @param data Encoded Chainlink Functions request data, use FunctionsClient API to encode a request - * @param billing The request's billing configuration - * @return fee Cost in Juels (1e18) of LINK - */ - function getRequiredFee( - bytes calldata data, - IFunctionsBillingRegistry.RequestBilling calldata billing - ) external view returns (uint96); - - /** - * @notice Estimate the total cost that will be charged to a subscription to make a request: gas re-imbursement, plus DON fee, plus Registry fee - * @param subscriptionId A unique subscription ID allocated by billing system, - * a client can make requests from different contracts referencing the same subscription - * @param data Encoded Chainlink Functions request data, use FunctionsClient API to encode a request - * @param gasLimit Gas limit for the fulfillment callback - * @return billedCost Cost in Juels (1e18) of LINK - */ - function estimateCost( - uint64 subscriptionId, - bytes calldata data, - uint32 gasLimit, - uint256 gasPrice - ) external view returns (uint96); - - /** - * @notice Sends a request (encoded as data) using the provided subscriptionId - * @param subscriptionId A unique subscription ID allocated by billing system, - * a client can make requests from different contracts referencing the same subscription - * @param data Encoded Chainlink Functions request data, use FunctionsClient API to encode a request - * @param gasLimit Gas limit for the fulfillment callback - * @return requestId A unique request identifier (unique per DON) - */ - function sendRequest(uint64 subscriptionId, bytes calldata data, uint32 gasLimit) external returns (bytes32); -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/ocr/OCR2Abstract.sol b/contracts/src/v0.8/functions/dev/v0_0_0/ocr/OCR2Abstract.sol deleted file mode 100644 index 08dcae6d48e..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/ocr/OCR2Abstract.sol +++ /dev/null @@ -1,134 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {ITypeAndVersion} from "../../../../shared/interfaces/ITypeAndVersion.sol"; - -abstract contract OCR2Abstract is ITypeAndVersion { - // Maximum number of oracles the offchain reporting protocol is designed for - uint256 internal constant maxNumOracles = 31; - - /** - * @notice triggers a new run of the offchain reporting protocol - * @param previousConfigBlockNumber block in which the previous config was set, to simplify historic analysis - * @param configDigest configDigest of this configuration - * @param configCount ordinal number of this config setting among all config settings over the life of this contract - * @param signers ith element is address ith oracle uses to sign a report - * @param transmitters ith element is address ith oracle uses to transmit a report via the transmit method - * @param f maximum number of faulty/dishonest oracles the protocol can tolerate while still working correctly - * @param onchainConfig serialized configuration used by the contract (and possibly oracles) - * @param offchainConfigVersion version of the serialization format used for "offchainConfig" parameter - * @param offchainConfig serialized configuration used by the oracles exclusively and only passed through the contract - */ - event ConfigSet( - uint32 previousConfigBlockNumber, - bytes32 configDigest, - uint64 configCount, - address[] signers, - address[] transmitters, - uint8 f, - bytes onchainConfig, - uint64 offchainConfigVersion, - bytes offchainConfig - ); - - /** - * @notice sets offchain reporting protocol configuration incl. participating oracles - * @param signers addresses with which oracles sign the reports - * @param transmitters addresses oracles use to transmit the reports - * @param f number of faulty oracles the system can tolerate - * @param onchainConfig serialized configuration used by the contract (and possibly oracles) - * @param offchainConfigVersion version number for offchainEncoding schema - * @param offchainConfig serialized configuration used by the oracles exclusively and only passed through the contract - */ - function setConfig( - address[] memory signers, - address[] memory transmitters, - uint8 f, - bytes memory onchainConfig, - uint64 offchainConfigVersion, - bytes memory offchainConfig - ) external virtual; - - /** - * @notice information about current offchain reporting protocol configuration - * @return configCount ordinal number of current config, out of all configs applied to this contract so far - * @return blockNumber block at which this config was set - * @return configDigest domain-separation tag for current config (see _configDigestFromConfigData) - */ - function latestConfigDetails() - external - view - virtual - returns (uint32 configCount, uint32 blockNumber, bytes32 configDigest); - - function _configDigestFromConfigData( - uint256 chainId, - address contractAddress, - uint64 configCount, - address[] memory signers, - address[] memory transmitters, - uint8 f, - bytes memory onchainConfig, - uint64 offchainConfigVersion, - bytes memory offchainConfig - ) internal pure returns (bytes32) { - uint256 h = uint256( - keccak256( - abi.encode( - chainId, - contractAddress, - configCount, - signers, - transmitters, - f, - onchainConfig, - offchainConfigVersion, - offchainConfig - ) - ) - ); - uint256 prefixMask = type(uint256).max << (256 - 16); // 0xFFFF00..00 - uint256 prefix = 0x0001 << (256 - 16); // 0x000100..00 - return bytes32((prefix & prefixMask) | (h & ~prefixMask)); - } - - /** - * @notice optionally emited to indicate the latest configDigest and epoch for - which a report was successfully transmited. Alternatively, the contract may - use latestConfigDigestAndEpoch with scanLogs set to false. - */ - event Transmitted(bytes32 configDigest, uint32 epoch); - - /** - * @notice optionally returns the latest configDigest and epoch for which a - report was successfully transmitted. Alternatively, the contract may return - scanLogs set to true and use Transmitted events to provide this information - to offchain watchers. - * @return scanLogs indicates whether to rely on the configDigest and epoch - returned or whether to scan logs for the Transmitted event instead. - * @return configDigest - * @return epoch - */ - function latestConfigDigestAndEpoch() - external - view - virtual - returns (bool scanLogs, bytes32 configDigest, uint32 epoch); - - /** - * @notice transmit is called to post a new report to the contract - * @param report serialized report, which the signatures are signing. - * @param rs ith element is the R components of the ith signature on report. Must have at most maxNumOracles entries - * @param ss ith element is the S components of the ith signature on report. Must have at most maxNumOracles entries - * @param rawVs ith element is the the V component of the ith signature - */ - function transmit( - // NOTE: If these parameters are changed, expectedMsgDataLength and/or - // TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT need to be changed accordingly - bytes32[3] calldata reportContext, - bytes calldata report, - bytes32[] calldata rs, - bytes32[] calldata ss, - bytes32 rawVs // signatures - ) external virtual; -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/ocr/OCR2Base.sol b/contracts/src/v0.8/functions/dev/v0_0_0/ocr/OCR2Base.sol deleted file mode 100644 index 0814311248c..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/ocr/OCR2Base.sol +++ /dev/null @@ -1,383 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {ConfirmedOwner} from "../../../../shared/access/ConfirmedOwner.sol"; -import {OCR2Abstract} from "./OCR2Abstract.sol"; - -/** - * @notice Onchain verification of reports from the offchain reporting protocol - * @dev THIS CONTRACT HAS NOT GONE THROUGH ANY SECURITY REVIEW. DO NOT USE IN PROD. - * @dev For details on its operation, see the offchain reporting protocol design - * doc, which refers to this contract as simply the "contract". - * @dev This contract is meant to aid rapid development of new applications based on OCR2. - * However, for actual production contracts, it is expected that most of the logic of this contract - * will be folded directly into the application contract. Inheritance prevents us from doing lots - * of juicy storage layout optimizations, leading to a substantial increase in gas cost. - */ -abstract contract OCR2Base is ConfirmedOwner, OCR2Abstract { - error ReportInvalid(); - - bool internal immutable i_uniqueReports; - - constructor(bool uniqueReports) ConfirmedOwner(msg.sender) { - i_uniqueReports = uniqueReports; - } - - uint256 private constant maxUint32 = (1 << 32) - 1; - - // Storing these fields used on the hot path in a ConfigInfo variable reduces the - // retrieval of all of them to a single SLOAD. If any further fields are - // added, make sure that storage of the struct still takes at most 32 bytes. - struct ConfigInfo { - bytes32 latestConfigDigest; - uint8 f; // TODO: could be optimized by squeezing into one slot - uint8 n; - } - ConfigInfo internal s_configInfo; - - // incremented each time a new config is posted. This count is incorporated - // into the config digest, to prevent replay attacks. - uint32 internal s_configCount; - uint32 internal s_latestConfigBlockNumber; // makes it easier for offchain systems - // to extract config from logs. - - // Used for s_oracles[a].role, where a is an address, to track the purpose - // of the address, or to indicate that the address is unset. - enum Role { - // No oracle role has been set for address a - Unset, - // Signing address for the s_oracles[a].index'th oracle. I.e., report - // signatures from this oracle should ecrecover back to address a. - Signer, - // Transmission address for the s_oracles[a].index'th oracle. I.e., if a - // report is received by OCR2Aggregator.transmit in which msg.sender is - // a, it is attributed to the s_oracles[a].index'th oracle. - Transmitter - } - - struct Oracle { - uint8 index; // Index of oracle in s_signers/s_transmitters - Role role; // Role of the address which mapped to this struct - } - - mapping(address => Oracle) /* signer OR transmitter address */ internal s_oracles; - - // s_signers contains the signing address of each oracle - address[] internal s_signers; - - // s_transmitters contains the transmission address of each oracle, - // i.e. the address the oracle actually sends transactions to the contract from - address[] internal s_transmitters; - - /* - * Config logic - */ - - // Reverts transaction if config args are invalid - modifier checkConfigValid( - uint256 _numSigners, - uint256 _numTransmitters, - uint256 _f - ) { - require(_numSigners <= maxNumOracles, "too many signers"); - require(_f > 0, "f must be positive"); - require(_numSigners == _numTransmitters, "oracle addresses out of registration"); - require(_numSigners > 3 * _f, "faulty-oracle f too high"); - _; - } - - struct SetConfigArgs { - address[] signers; - address[] transmitters; - uint8 f; - bytes onchainConfig; - uint64 offchainConfigVersion; - bytes offchainConfig; - } - - /// @inheritdoc OCR2Abstract - function latestConfigDigestAndEpoch() - external - view - virtual - override - returns (bool scanLogs, bytes32 configDigest, uint32 epoch) - { - return (true, bytes32(0), uint32(0)); - } - - /** - * @notice sets offchain reporting protocol configuration incl. participating oracles - * @param _signers addresses with which oracles sign the reports - * @param _transmitters addresses oracles use to transmit the reports - * @param _f number of faulty oracles the system can tolerate - * @param _onchainConfig encoded on-chain contract configuration - * @param _offchainConfigVersion version number for offchainEncoding schema - * @param _offchainConfig encoded off-chain oracle configuration - */ - function setConfig( - address[] memory _signers, - address[] memory _transmitters, - uint8 _f, - bytes memory _onchainConfig, - uint64 _offchainConfigVersion, - bytes memory _offchainConfig - ) external override checkConfigValid(_signers.length, _transmitters.length, _f) onlyOwner { - SetConfigArgs memory args = SetConfigArgs({ - signers: _signers, - transmitters: _transmitters, - f: _f, - onchainConfig: _onchainConfig, - offchainConfigVersion: _offchainConfigVersion, - offchainConfig: _offchainConfig - }); - - _beforeSetConfig(args.f, args.onchainConfig); - - while (s_signers.length != 0) { - // remove any old signer/transmitter addresses - uint256 lastIdx = s_signers.length - 1; - address signer = s_signers[lastIdx]; - address transmitter = s_transmitters[lastIdx]; - delete s_oracles[signer]; - delete s_oracles[transmitter]; - s_signers.pop(); - s_transmitters.pop(); - } - - for (uint256 i = 0; i < args.signers.length; ++i) { - // add new signer/transmitter addresses - require(s_oracles[args.signers[i]].role == Role.Unset, "repeated signer address"); - s_oracles[args.signers[i]] = Oracle(uint8(i), Role.Signer); - require(s_oracles[args.transmitters[i]].role == Role.Unset, "repeated transmitter address"); - s_oracles[args.transmitters[i]] = Oracle(uint8(i), Role.Transmitter); - s_signers.push(args.signers[i]); - s_transmitters.push(args.transmitters[i]); - } - s_configInfo.f = args.f; - uint32 previousConfigBlockNumber = s_latestConfigBlockNumber; - s_latestConfigBlockNumber = uint32(block.number); - s_configCount += 1; - { - s_configInfo.latestConfigDigest = configDigestFromConfigData( - block.chainid, - address(this), - s_configCount, - args.signers, - args.transmitters, - args.f, - args.onchainConfig, - args.offchainConfigVersion, - args.offchainConfig - ); - } - s_configInfo.n = uint8(args.signers.length); - - emit ConfigSet( - previousConfigBlockNumber, - s_configInfo.latestConfigDigest, - s_configCount, - args.signers, - args.transmitters, - args.f, - args.onchainConfig, - args.offchainConfigVersion, - args.offchainConfig - ); - - _afterSetConfig(args.f, args.onchainConfig); - } - - function configDigestFromConfigData( - uint256 _chainId, - address _contractAddress, - uint64 _configCount, - address[] memory _signers, - address[] memory _transmitters, - uint8 _f, - bytes memory _onchainConfig, - uint64 _encodedConfigVersion, - bytes memory _encodedConfig - ) internal pure returns (bytes32) { - uint256 h = uint256( - keccak256( - abi.encode( - _chainId, - _contractAddress, - _configCount, - _signers, - _transmitters, - _f, - _onchainConfig, - _encodedConfigVersion, - _encodedConfig - ) - ) - ); - uint256 prefixMask = type(uint256).max << (256 - 16); // 0xFFFF00..00 - uint256 prefix = 0x0001 << (256 - 16); // 0x000100..00 - return bytes32((prefix & prefixMask) | (h & ~prefixMask)); - } - - /** - * @notice information about current offchain reporting protocol configuration - * @return configCount ordinal number of current config, out of all configs applied to this contract so far - * @return blockNumber block at which this config was set - * @return configDigest domain-separation tag for current config (see configDigestFromConfigData) - */ - function latestConfigDetails() - external - view - override - returns (uint32 configCount, uint32 blockNumber, bytes32 configDigest) - { - return (s_configCount, s_latestConfigBlockNumber, s_configInfo.latestConfigDigest); - } - - /** - * @return list of addresses permitted to transmit reports to this contract - * @dev The list will match the order used to specify the transmitter during setConfig - */ - function transmitters() external view returns (address[] memory) { - return s_transmitters; - } - - function _beforeSetConfig(uint8 _f, bytes memory _onchainConfig) internal virtual; - - function _afterSetConfig(uint8 _f, bytes memory _onchainConfig) internal virtual; - - /** - * @dev hook to allow additional validation of the report by the extending contract - * @param configDigest separation tag for current config (see configDigestFromConfigData) - * @param epochAndRound 27 byte padding, 4-byte epoch and 1-byte round - * @param report serialized report - */ - function _validateReport( - bytes32 configDigest, - uint40 epochAndRound, - bytes memory report - ) internal virtual returns (bool); - - /** - * @dev hook called after the report has been fully validated - * for the extending contract to handle additional logic, such as oracle payment - * @param initialGas the amount of gas before validation - * @param transmitter the address of the account that submitted the report - * @param signers the addresses of all signing accounts - * @param report serialized report - */ - function _report( - uint256 initialGas, - address transmitter, - uint8 signerCount, - address[maxNumOracles] memory signers, - bytes calldata report - ) internal virtual; - - // The constant-length components of the msg.data sent to transmit. - // See the "If we wanted to call sam" example on for example reasoning - // https://solidity.readthedocs.io/en/v0.7.2/abi-spec.html - uint16 private constant TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT = - 4 + // function selector - 32 * - 3 + // 3 words containing reportContext - 32 + // word containing start location of abiencoded report value - 32 + // word containing location start of abiencoded rs value - 32 + // word containing start location of abiencoded ss value - 32 + // rawVs value - 32 + // word containing length of report - 32 + // word containing length rs - 32 + // word containing length of ss - 0; // placeholder - - function requireExpectedMsgDataLength( - bytes calldata report, - bytes32[] calldata rs, - bytes32[] calldata ss - ) private pure { - // calldata will never be big enough to make this overflow - uint256 expected = uint256(TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT) + - report.length + // one byte pure entry in _report - rs.length * - 32 + // 32 bytes per entry in _rs - ss.length * - 32 + // 32 bytes per entry in _ss - 0; // placeholder - require(msg.data.length == expected, "calldata length mismatch"); - } - - /** - * @notice transmit is called to post a new report to the contract - * @param report serialized report, which the signatures are signing. - * @param rs ith element is the R components of the ith signature on report. Must have at most maxNumOracles entries - * @param ss ith element is the S components of the ith signature on report. Must have at most maxNumOracles entries - * @param rawVs ith element is the the V component of the ith signature - */ - function transmit( - // NOTE: If these parameters are changed, expectedMsgDataLength and/or - // TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT need to be changed accordingly - bytes32[3] calldata reportContext, - bytes calldata report, - bytes32[] calldata rs, - bytes32[] calldata ss, - bytes32 rawVs // signatures - ) external override { - uint256 initialGas = gasleft(); // This line must come first - - { - // reportContext consists of: - // reportContext[0]: ConfigDigest - // reportContext[1]: 27 byte padding, 4-byte epoch and 1-byte round - // reportContext[2]: ExtraHash - bytes32 configDigest = reportContext[0]; - uint32 epochAndRound = uint32(uint256(reportContext[1])); - - if (!_validateReport(configDigest, epochAndRound, report)) { - revert ReportInvalid(); - } - - emit Transmitted(configDigest, uint32(epochAndRound >> 8)); - - ConfigInfo memory configInfo = s_configInfo; - require(configInfo.latestConfigDigest == configDigest, "configDigest mismatch"); - - requireExpectedMsgDataLength(report, rs, ss); - - uint256 expectedNumSignatures; - if (i_uniqueReports) { - expectedNumSignatures = (configInfo.n + configInfo.f) / 2 + 1; - } else { - expectedNumSignatures = configInfo.f + 1; - } - - require(rs.length == expectedNumSignatures, "wrong number of signatures"); - require(rs.length == ss.length, "signatures out of registration"); - - Oracle memory transmitter = s_oracles[msg.sender]; - require( // Check that sender is authorized to report - transmitter.role == Role.Transmitter && msg.sender == s_transmitters[transmitter.index], - "unauthorized transmitter" - ); - } - - address[maxNumOracles] memory signed; - uint8 signerCount = 0; - - { - // Verify signatures attached to report - bytes32 h = keccak256(abi.encodePacked(keccak256(report), reportContext)); - - Oracle memory o; - for (uint256 i = 0; i < rs.length; ++i) { - address signer = ecrecover(h, uint8(rawVs[i]) + 27, rs[i], ss[i]); - o = s_oracles[signer]; - require(o.role == Role.Signer, "address not authorized to sign"); - require(signed[o.index] == address(0), "non-unique signature"); - signed[o.index] = signer; - signerCount += 1; - } - } - - _report(initialGas, msg.sender, signerCount, signed, report); - } -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/ocr/OCR2BaseUpgradeable.sol b/contracts/src/v0.8/functions/dev/v0_0_0/ocr/OCR2BaseUpgradeable.sol deleted file mode 100644 index 94397ac4231..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/ocr/OCR2BaseUpgradeable.sol +++ /dev/null @@ -1,388 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {ConfirmedOwnerUpgradeable} from "../accessControl/ConfirmedOwnerUpgradeable.sol"; -import {OCR2Abstract} from "./OCR2Abstract.sol"; -import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; - -/** - * @notice Onchain verification of reports from the offchain reporting protocol - * @dev THIS CONTRACT HAS NOT GONE THROUGH ANY SECURITY REVIEW. DO NOT USE IN PROD. - * @dev For details on its operation, see the offchain reporting protocol design - * doc, which refers to this contract as simply the "contract". - * @dev This contract is meant to aid rapid development of new applications based on OCR2. - * However, for actual production contracts, it is expected that most of the logic of this contract - * will be folded directly into the application contract. Inheritance prevents us from doing lots - * of juicy storage layout optimizations, leading to a substantial increase in gas cost. - */ -abstract contract OCR2BaseUpgradeable is Initializable, ConfirmedOwnerUpgradeable, OCR2Abstract { - error ReportInvalid(); - - bool internal i_uniqueReports; - - /** - * @dev Initializes the contract. - */ - function __OCR2Base_initialize(bool uniqueReports) internal onlyInitializing { - __ConfirmedOwner_initialize(msg.sender, address(0)); - i_uniqueReports = uniqueReports; - } - - uint256 private constant maxUint32 = (1 << 32) - 1; - - // Storing these fields used on the hot path in a ConfigInfo variable reduces the - // retrieval of all of them to a single SLOAD. If any further fields are - // added, make sure that storage of the struct still takes at most 32 bytes. - struct ConfigInfo { - bytes32 latestConfigDigest; - uint8 f; // TODO: could be optimized by squeezing into one slot - uint8 n; - } - ConfigInfo internal s_configInfo; - - // incremented each time a new config is posted. This count is incorporated - // into the config digest, to prevent replay attacks. - uint32 internal s_configCount; - uint32 internal s_latestConfigBlockNumber; // makes it easier for offchain systems - // to extract config from logs. - - // Used for s_oracles[a].role, where a is an address, to track the purpose - // of the address, or to indicate that the address is unset. - enum Role { - // No oracle role has been set for address a - Unset, - // Signing address for the s_oracles[a].index'th oracle. I.e., report - // signatures from this oracle should ecrecover back to address a. - Signer, - // Transmission address for the s_oracles[a].index'th oracle. I.e., if a - // report is received by OCR2Aggregator.transmit in which msg.sender is - // a, it is attributed to the s_oracles[a].index'th oracle. - Transmitter - } - - struct Oracle { - uint8 index; // Index of oracle in s_signers/s_transmitters - Role role; // Role of the address which mapped to this struct - } - - mapping(address => Oracle) /* signer OR transmitter address */ internal s_oracles; - - // s_signers contains the signing address of each oracle - address[] internal s_signers; - - // s_transmitters contains the transmission address of each oracle, - // i.e. the address the oracle actually sends transactions to the contract from - address[] internal s_transmitters; - - /* - * Config logic - */ - - // Reverts transaction if config args are invalid - modifier checkConfigValid( - uint256 _numSigners, - uint256 _numTransmitters, - uint256 _f - ) { - require(_numSigners <= maxNumOracles, "too many signers"); - require(_f > 0, "f must be positive"); - require(_numSigners == _numTransmitters, "oracle addresses out of registration"); - require(_numSigners > 3 * _f, "faulty-oracle f too high"); - _; - } - - struct SetConfigArgs { - address[] signers; - address[] transmitters; - uint8 f; - bytes onchainConfig; - uint64 offchainConfigVersion; - bytes offchainConfig; - } - - /// @inheritdoc OCR2Abstract - function latestConfigDigestAndEpoch() - external - view - virtual - override - returns (bool scanLogs, bytes32 configDigest, uint32 epoch) - { - return (true, bytes32(0), uint32(0)); - } - - /** - * @notice sets offchain reporting protocol configuration incl. participating oracles - * @param _signers addresses with which oracles sign the reports - * @param _transmitters addresses oracles use to transmit the reports - * @param _f number of faulty oracles the system can tolerate - * @param _onchainConfig encoded on-chain contract configuration - * @param _offchainConfigVersion version number for offchainEncoding schema - * @param _offchainConfig encoded off-chain oracle configuration - */ - function setConfig( - address[] memory _signers, - address[] memory _transmitters, - uint8 _f, - bytes memory _onchainConfig, - uint64 _offchainConfigVersion, - bytes memory _offchainConfig - ) external override checkConfigValid(_signers.length, _transmitters.length, _f) onlyOwner { - SetConfigArgs memory args = SetConfigArgs({ - signers: _signers, - transmitters: _transmitters, - f: _f, - onchainConfig: _onchainConfig, - offchainConfigVersion: _offchainConfigVersion, - offchainConfig: _offchainConfig - }); - - _beforeSetConfig(args.f, args.onchainConfig); - - while (s_signers.length != 0) { - // remove any old signer/transmitter addresses - uint256 lastIdx = s_signers.length - 1; - address signer = s_signers[lastIdx]; - address transmitter = s_transmitters[lastIdx]; - delete s_oracles[signer]; - delete s_oracles[transmitter]; - s_signers.pop(); - s_transmitters.pop(); - } - - for (uint256 i = 0; i < args.signers.length; ++i) { - // add new signer/transmitter addresses - require(s_oracles[args.signers[i]].role == Role.Unset, "repeated signer address"); - s_oracles[args.signers[i]] = Oracle(uint8(i), Role.Signer); - require(s_oracles[args.transmitters[i]].role == Role.Unset, "repeated transmitter address"); - s_oracles[args.transmitters[i]] = Oracle(uint8(i), Role.Transmitter); - s_signers.push(args.signers[i]); - s_transmitters.push(args.transmitters[i]); - } - s_configInfo.f = args.f; - uint32 previousConfigBlockNumber = s_latestConfigBlockNumber; - s_latestConfigBlockNumber = uint32(block.number); - s_configCount += 1; - { - s_configInfo.latestConfigDigest = configDigestFromConfigData( - block.chainid, - address(this), - s_configCount, - args.signers, - args.transmitters, - args.f, - args.onchainConfig, - args.offchainConfigVersion, - args.offchainConfig - ); - } - s_configInfo.n = uint8(args.signers.length); - - emit ConfigSet( - previousConfigBlockNumber, - s_configInfo.latestConfigDigest, - s_configCount, - args.signers, - args.transmitters, - args.f, - args.onchainConfig, - args.offchainConfigVersion, - args.offchainConfig - ); - - _afterSetConfig(args.f, args.onchainConfig); - } - - function configDigestFromConfigData( - uint256 _chainId, - address _contractAddress, - uint64 _configCount, - address[] memory _signers, - address[] memory _transmitters, - uint8 _f, - bytes memory _onchainConfig, - uint64 _encodedConfigVersion, - bytes memory _encodedConfig - ) internal pure returns (bytes32) { - uint256 h = uint256( - keccak256( - abi.encode( - _chainId, - _contractAddress, - _configCount, - _signers, - _transmitters, - _f, - _onchainConfig, - _encodedConfigVersion, - _encodedConfig - ) - ) - ); - uint256 prefixMask = type(uint256).max << (256 - 16); // 0xFFFF00..00 - uint256 prefix = 0x0001 << (256 - 16); // 0x000100..00 - return bytes32((prefix & prefixMask) | (h & ~prefixMask)); - } - - /** - * @notice information about current offchain reporting protocol configuration - * @return configCount ordinal number of current config, out of all configs applied to this contract so far - * @return blockNumber block at which this config was set - * @return configDigest domain-separation tag for current config (see configDigestFromConfigData) - */ - function latestConfigDetails() - external - view - override - returns (uint32 configCount, uint32 blockNumber, bytes32 configDigest) - { - return (s_configCount, s_latestConfigBlockNumber, s_configInfo.latestConfigDigest); - } - - /** - * @return list of addresses permitted to transmit reports to this contract - * @dev The list will match the order used to specify the transmitter during setConfig - */ - function transmitters() external view returns (address[] memory) { - return s_transmitters; - } - - function _beforeSetConfig(uint8 _f, bytes memory _onchainConfig) internal virtual; - - function _afterSetConfig(uint8 _f, bytes memory _onchainConfig) internal virtual; - - /** - * @dev hook to allow additional validation of the report by the extending contract - * @param configDigest separation tag for current config (see configDigestFromConfigData) - * @param epochAndRound 27 byte padding, 4-byte epoch and 1-byte round - * @param report serialized report - */ - function _validateReport( - bytes32 configDigest, - uint40 epochAndRound, - bytes memory report - ) internal virtual returns (bool); - - /** - * @dev hook called after the report has been fully validated - * for the extending contract to handle additional logic, such as oracle payment - * @param initialGas the amount of gas before validation - * @param transmitter the address of the account that submitted the report - * @param signers the addresses of all signing accounts - * @param report serialized report - */ - function _report( - uint256 initialGas, - address transmitter, - uint8 signerCount, - address[maxNumOracles] memory signers, - bytes calldata report - ) internal virtual; - - // The constant-length components of the msg.data sent to transmit. - // See the "If we wanted to call sam" example on for example reasoning - // https://solidity.readthedocs.io/en/v0.7.2/abi-spec.html - uint16 private constant TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT = - 4 + // function selector - 32 * - 3 + // 3 words containing reportContext - 32 + // word containing start location of abiencoded report value - 32 + // word containing location start of abiencoded rs value - 32 + // word containing start location of abiencoded ss value - 32 + // rawVs value - 32 + // word containing length of report - 32 + // word containing length rs - 32 + // word containing length of ss - 0; // placeholder - - function requireExpectedMsgDataLength( - bytes calldata report, - bytes32[] calldata rs, - bytes32[] calldata ss - ) private pure { - // calldata will never be big enough to make this overflow - uint256 expected = uint256(TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT) + - report.length + // one byte pure entry in _report - rs.length * - 32 + // 32 bytes per entry in _rs - ss.length * - 32 + // 32 bytes per entry in _ss - 0; // placeholder - require(msg.data.length == expected, "calldata length mismatch"); - } - - /** - * @notice transmit is called to post a new report to the contract - * @param report serialized report, which the signatures are signing. - * @param rs ith element is the R components of the ith signature on report. Must have at most maxNumOracles entries - * @param ss ith element is the S components of the ith signature on report. Must have at most maxNumOracles entries - * @param rawVs ith element is the the V component of the ith signature - */ - function transmit( - // NOTE: If these parameters are changed, expectedMsgDataLength and/or - // TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT need to be changed accordingly - bytes32[3] calldata reportContext, - bytes calldata report, - bytes32[] calldata rs, - bytes32[] calldata ss, - bytes32 rawVs // signatures - ) external override { - uint256 initialGas = gasleft(); // This line must come first - - { - // reportContext consists of: - // reportContext[0]: ConfigDigest - // reportContext[1]: 27 byte padding, 4-byte epoch and 1-byte round - // reportContext[2]: ExtraHash - bytes32 configDigest = reportContext[0]; - uint32 epochAndRound = uint32(uint256(reportContext[1])); - - if (!_validateReport(configDigest, epochAndRound, report)) { - revert ReportInvalid(); - } - - emit Transmitted(configDigest, uint32(epochAndRound >> 8)); - - ConfigInfo memory configInfo = s_configInfo; - require(configInfo.latestConfigDigest == configDigest, "configDigest mismatch"); - - requireExpectedMsgDataLength(report, rs, ss); - - uint256 expectedNumSignatures; - if (i_uniqueReports) { - expectedNumSignatures = (configInfo.n + configInfo.f) / 2 + 1; - } else { - expectedNumSignatures = configInfo.f + 1; - } - - require(rs.length == expectedNumSignatures, "wrong number of signatures"); - require(rs.length == ss.length, "signatures out of registration"); - - Oracle memory transmitter = s_oracles[msg.sender]; - require( // Check that sender is authorized to report - transmitter.role == Role.Transmitter && msg.sender == s_transmitters[transmitter.index], - "unauthorized transmitter" - ); - } - - address[maxNumOracles] memory signed; - uint8 signerCount = 0; - - { - // Verify signatures attached to report - bytes32 h = keccak256(abi.encodePacked(keccak256(report), reportContext)); - - Oracle memory o; - for (uint256 i = 0; i < rs.length; ++i) { - address signer = ecrecover(h, uint8(rawVs[i]) + 27, rs[i], ss[i]); - o = s_oracles[signer]; - require(o.role == Role.Signer, "address not authorized to sign"); - require(signed[o.index] == address(0), "non-unique signature"); - signed[o.index] = signer; - signerCount += 1; - } - } - - _report(initialGas, msg.sender, signerCount, signed, report); - } -} diff --git a/contracts/src/v0.8/functions/dev/v0_0_0/ocr/README.md b/contracts/src/v0.8/functions/dev/v0_0_0/ocr/README.md deleted file mode 100644 index e7ccc5120b2..00000000000 --- a/contracts/src/v0.8/functions/dev/v0_0_0/ocr/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# OCR2 Rapid Prototype Contracts - -The contracts in this directory are to aid rapid prototyping of OCR2 based products. They abstract OCR2 config and boilerplate code so that specific logic can be implemented and tested quickly. They are not optimized or audited. - -Do not use these contracts in production. For actual production contracts, it is expected that most of the logic of these contracts will be folded directly into the application contract. \ No newline at end of file diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/BaseTest.t.sol b/contracts/src/v0.8/functions/tests/v0_0_0/BaseTest.t.sol deleted file mode 100644 index 6463b2b94b6..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/BaseTest.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -pragma solidity ^0.8.6; - -import {Test} from "forge-std/Test.sol"; - -contract BaseTest is Test { - bool private s_baseTestInitialized; - address internal constant OWNER = 0x00007e64E1fB0C487F25dd6D3601ff6aF8d32e4e; - - function setUp() public virtual { - // BaseTest.setUp is often called multiple times from tests' setUp due to inheritance. - if (s_baseTestInitialized) return; - s_baseTestInitialized = true; - - // Set msg.sender to OWNER until changePrank or stopPrank is called - vm.startPrank(OWNER); - } -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/FunctionsOracle.t.sol b/contracts/src/v0.8/functions/tests/v0_0_0/FunctionsOracle.t.sol deleted file mode 100644 index ab175c3c45d..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/FunctionsOracle.t.sol +++ /dev/null @@ -1,144 +0,0 @@ -pragma solidity ^0.8.6; - -import {BaseTest} from "./BaseTest.t.sol"; -import {FunctionsOracle, FunctionsOracleWithInit} from "./testhelpers/FunctionsOracleWithInit.sol"; -import {FunctionsBillingRegistryWithInit} from "./testhelpers/FunctionsBillingRegistryWithInit.sol"; -import {ConfirmedOwnerUpgradeable} from "../../dev/v0_0_0/accessControl/ConfirmedOwnerUpgradeable.sol"; - -// import {LinkToken} from "../../../../src/v0.4/LinkToken.sol"; -// import {MockV3Aggregator} from "../../../../src/v0.7/tests/MockV3Aggregator.sol"; - -contract FunctionsOracleSetup is BaseTest { - bytes constant DATA = abi.encode("bytes"); - address registryAddress = makeAddr("Registry"); - - FunctionsOracleWithInit s_oracle; - - function setUp() public virtual override { - BaseTest.setUp(); - - s_oracle = new FunctionsOracleWithInit(); - } -} - -contract FunctionsOracle_typeAndVersion is FunctionsOracleSetup { - function testTypeAndVersionSuccess() public { - assertEq(s_oracle.typeAndVersion(), "FunctionsOracle 0.0.0"); - } -} - -contract FunctionsOracle_setDONPublicKey is FunctionsOracleSetup { - function testSetDONPublicKey_gas() public { - s_oracle.setDONPublicKey(DATA); - } - - function testSetDONPublicKeySuccess() public { - bytes memory donPublicKey = abi.encode("newKey"); - - // Verify the existing key is different from the new key - bytes memory existingDonPublicKey = s_oracle.getDONPublicKey(); - bytes memory expectedExistingDonPublicKey; - assertEq(existingDonPublicKey, expectedExistingDonPublicKey); - // If they have different lengths they are not the same - assertFalse(donPublicKey.length == expectedExistingDonPublicKey.length); - - s_oracle.setDONPublicKey(donPublicKey); - bytes memory newDonPublicKey = s_oracle.getDONPublicKey(); - assertEq(newDonPublicKey, donPublicKey); - } - - // Reverts - - function testEmptyPublicKeyReverts() public { - bytes memory donPublicKey; - - vm.expectRevert(FunctionsOracle.EmptyPublicKey.selector); - s_oracle.setDONPublicKey(donPublicKey); - } - - function testOnlyOwnerReverts() public { - vm.stopPrank(); - vm.expectRevert(ConfirmedOwnerUpgradeable.OnlyCallableByOwner.selector); - - bytes memory donPublicKey; - s_oracle.setDONPublicKey(donPublicKey); - } -} - -contract FunctionsOracle_setRegistry is FunctionsOracleSetup { - function testSetRegistry_gas() public { - s_oracle.setRegistry(registryAddress); - } - - function testSetRegistrySuccess() public { - address registryAddress = makeAddr("newRegistry"); - - // Verify the existing key is different from the new key - address existingRegistryAddress = s_oracle.getRegistry(); - address expectedRegistryAddress; - assertEq(existingRegistryAddress, expectedRegistryAddress); - - s_oracle.setRegistry(registryAddress); - address newRegistryAddress = s_oracle.getRegistry(); - assertEq(registryAddress, newRegistryAddress); - } - - // Reverts - - function testEmptyPublicKeyReverts() public { - address registryAddress; - - vm.expectRevert(FunctionsOracle.EmptyBillingRegistry.selector); - s_oracle.setRegistry(registryAddress); - } - - function testOnlyOwnerReverts() public { - vm.stopPrank(); - vm.expectRevert(ConfirmedOwnerUpgradeable.OnlyCallableByOwner.selector); - - address registryAddress; - s_oracle.setRegistry(registryAddress); - } -} - -contract FunctionsOracle_sendRequest is FunctionsOracleSetup { - FunctionsBillingRegistryWithInit s_registry; - - // LinkToken s_link; - // MockV3Aggregator s_linketh; - - function setUp() public virtual override { - FunctionsOracleSetup.setUp(); - - // s_link = new LinkToken(); - // s_linketh = new MockV3Aggregator(0, 5021530000000000); - s_registry = new FunctionsBillingRegistryWithInit(makeAddr("Link Token"), makeAddr("Link Eth"), address(s_oracle)); - s_oracle.setRegistry(address(s_registry)); - s_oracle.deactivateAuthorizedReceiver(); - } - - event OracleRequest(bytes32 requestId, bytes data); - - // TODO: write new ^0.8.0 mocks for LinkToken & MockV3Aggregator - // function testSendRequest_gas() public { - // s_oracle.sendRequest(0, DATA, 0); - // } - - // function testSendRequestFuzzSuccess(uint64 subscriptionId, bytes calldata data) public { - // vm.assume(data.length != 0); - - // vm.expectEmit(false, false, false, false); - // emit OracleRequest(0, data); - - // s_oracle.sendRequest(subscriptionId, data, 0); - // } - - // Reverts - - function testEmptyRequestDataReverts() public { - bytes memory emptyData; - - vm.expectRevert(FunctionsOracle.EmptyRequestData.selector); - s_oracle.sendRequest(0, emptyData, 0); - } -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/AuthorizedOriginReceiverTestHelper.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/AuthorizedOriginReceiverTestHelper.sol deleted file mode 100644 index 0c592ae81c6..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/AuthorizedOriginReceiverTestHelper.sol +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import "../../../dev/v0_0_0/accessControl/AuthorizedOriginReceiver.sol"; - -contract AuthorizedOriginReceiverTestHelper is AuthorizedOriginReceiver { - bool private s_canSetAuthorizedSenders = true; - - function changeSetAuthorizedSender(bool on) external { - s_canSetAuthorizedSenders = on; - } - - function verifyValidateAuthorizedSender() external view validateAuthorizedSender returns (bool) { - return true; - } - - function _canSetAuthorizedSenders() internal view override returns (bool) { - return s_canSetAuthorizedSenders; - } -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/AuthorizedReceiverTestHelper.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/AuthorizedReceiverTestHelper.sol deleted file mode 100644 index ee541013f45..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/AuthorizedReceiverTestHelper.sol +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import "../../../dev/v0_0_0/accessControl/AuthorizedReceiver.sol"; - -contract AuthorizedReceiverTestHelper is AuthorizedReceiver { - bool private s_canSetAuthorizedSenders = true; - - function changeSetAuthorizedSender(bool on) external { - s_canSetAuthorizedSenders = on; - } - - function verifyValidateAuthorizedSender() external view validateAuthorizedSender returns (bool) { - return true; - } - - function _canSetAuthorizedSenders() internal view override returns (bool) { - return s_canSetAuthorizedSenders; - } -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsBillingRegistryWithInit.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsBillingRegistryWithInit.sol deleted file mode 100644 index 0ace817fa52..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsBillingRegistryWithInit.sol +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {FunctionsBillingRegistry} from "../../../dev/v0_0_0/FunctionsBillingRegistry.sol"; - -contract FunctionsBillingRegistryWithInit is FunctionsBillingRegistry { - constructor(address link, address linkEthFeed, address oracle) { - initialize(link, linkEthFeed, oracle); - } -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsClientTestHelper.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsClientTestHelper.sol deleted file mode 100644 index 89366510da7..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsClientTestHelper.sol +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {FunctionsClient, Functions} from "../../../dev/v0_0_0/FunctionsClient.sol"; - -contract FunctionsClientTestHelper is FunctionsClient { - using Functions for Functions.Request; - - event SendRequestInvoked(bytes32 requestId, string sourceCode, uint64 subscriptionId); - event FulfillRequestInvoked(bytes32 requestId, bytes response, bytes err); - - bool private s_revertFulfillRequest; - bool private s_doInvalidOperation; - - constructor(address oracle) FunctionsClient(oracle) {} - - function sendSimpleRequestWithJavaScript( - string memory sourceCode, - uint64 subscriptionId - ) public returns (bytes32 requestId) { - Functions.Request memory request; - request.initializeRequestForInlineJavaScript(sourceCode); - requestId = sendRequest(request, subscriptionId, 20_000); - emit SendRequestInvoked(requestId, sourceCode, subscriptionId); - } - - function estimateJuelCost( - string memory sourceCode, - uint64 subscriptionId, - uint256 gasCost - ) public view returns (uint96) { - Functions.Request memory request; - request.initializeRequestForInlineJavaScript(sourceCode); - return estimateCost(request, subscriptionId, 20_000, gasCost); - } - - function fulfillRequest(bytes32 requestId, bytes memory response, bytes memory err) internal override { - if (s_revertFulfillRequest) { - revert("asked to revert"); - } - if (s_doInvalidOperation) { - uint256 x = 1; - uint256 y = 0; - x = x / y; - } - emit FulfillRequestInvoked(requestId, response, err); - } - - function setRevertFulfillRequest(bool on) external { - s_revertFulfillRequest = on; - } - - function setDoInvalidOperation(bool on) external { - s_doInvalidOperation = on; - } -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleHelper.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleHelper.sol deleted file mode 100644 index 4ecc15b48c9..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleHelper.sol +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {FunctionsOracleWithInit} from "./FunctionsOracleWithInit.sol"; - -contract FunctionsOracleHelper is FunctionsOracleWithInit { - function callValidateReport(bytes calldata report) external pure returns (bool isValid) { - bytes32 configDigest; - uint40 epochAndRound; - isValid = _validateReport(configDigest, epochAndRound, report); - } - - function callReport(bytes calldata report) external { - address[maxNumOracles] memory signers; - signers[0] = msg.sender; - _report(gasleft(), msg.sender, 1, signers, report); - } - - function callReportMultipleSigners(bytes calldata report, address secondSigner) external { - address[maxNumOracles] memory signers; - signers[0] = msg.sender; - signers[1] = secondSigner; - _report(gasleft(), msg.sender, 2, signers, report); - } -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleMigrationHelper.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleMigrationHelper.sol deleted file mode 100644 index e70fed0b7a1..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleMigrationHelper.sol +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {FunctionsOracleMigration} from "./mocks/FunctionsOracleMigration.sol"; - -contract FunctionsOracleMigrationHelper is FunctionsOracleMigration { - function callValidateReport(bytes calldata report) external pure returns (bool isValid) { - bytes32 configDigest; - uint40 epochAndRound; - isValid = _validateReport(configDigest, epochAndRound, report); - } - - function callReport(bytes calldata report) external { - address[maxNumOracles] memory signers; - signers[0] = msg.sender; - _report(gasleft(), msg.sender, 1, signers, report); - } - - function callReportMultipleSigners(bytes calldata report, address secondSigner) external { - address[maxNumOracles] memory signers; - signers[0] = msg.sender; - signers[1] = secondSigner; - _report(gasleft(), msg.sender, 2, signers, report); - } -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleOriginalHelper.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleOriginalHelper.sol deleted file mode 100644 index 4d7102a71c3..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleOriginalHelper.sol +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {FunctionsOracleOriginal} from "./mocks/FunctionsOracleOriginal.sol"; - -contract FunctionsOracleOriginalHelper is FunctionsOracleOriginal { - function callValidateReport(bytes calldata report) external pure returns (bool isValid) { - bytes32 configDigest; - uint40 epochAndRound; - isValid = _validateReport(configDigest, epochAndRound, report); - } - - function callReport(bytes calldata report) external { - address[maxNumOracles] memory signers; - signers[0] = msg.sender; - _report(gasleft(), msg.sender, 1, signers, report); - } - - function callReportMultipleSigners(bytes calldata report, address secondSigner) external { - address[maxNumOracles] memory signers; - signers[0] = msg.sender; - signers[1] = secondSigner; - _report(gasleft(), msg.sender, 2, signers, report); - } -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleUpgradeableHelper.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleUpgradeableHelper.sol deleted file mode 100644 index d11d22372db..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleUpgradeableHelper.sol +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {FunctionsOracle} from "../../../dev/v0_0_0/FunctionsOracle.sol"; - -contract FunctionsOracleUpgradeableHelper is FunctionsOracle { - function callValidateReport(bytes calldata report) external pure returns (bool isValid) { - bytes32 configDigest; - uint40 epochAndRound; - isValid = _validateReport(configDigest, epochAndRound, report); - } - - function callReport(bytes calldata report) external { - address[maxNumOracles] memory signers; - signers[0] = msg.sender; - _report(gasleft(), msg.sender, 1, signers, report); - } - - function callReportMultipleSigners(bytes calldata report, address secondSigner) external { - address[maxNumOracles] memory signers; - signers[0] = msg.sender; - signers[1] = secondSigner; - _report(gasleft(), msg.sender, 2, signers, report); - } -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleWithInit.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleWithInit.sol deleted file mode 100644 index c5b913e9e97..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleWithInit.sol +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {FunctionsOracle} from "../../../dev/v0_0_0/FunctionsOracle.sol"; - -contract FunctionsOracleWithInit is FunctionsOracle { - constructor() { - initialize(); - } -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsTestHelper.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsTestHelper.sol deleted file mode 100644 index 5c942936d4a..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsTestHelper.sol +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {Functions} from "../../../dev/v0_0_0/Functions.sol"; - -contract FunctionsTestHelper { - using Functions for Functions.Request; - - error EmptySource(); - error EmptyUrl(); - error EmptySecrets(); - error EmptyArgs(); - - Functions.Request private s_req; - - event RequestData(bytes data); - - function closeEvent() public { - emit RequestData(s_req.encodeCBOR()); - } - - function initializeRequestForInlineJavaScript(string memory sourceCode) public { - Functions.Request memory r; - r.initializeRequestForInlineJavaScript(sourceCode); - storeRequest(r); - } - - function addSecrets(bytes memory secrets) public { - Functions.Request memory r = s_req; - r.addRemoteSecrets(secrets); - storeRequest(r); - } - - function addEmptyArgs() public pure { - Functions.Request memory r; - string[] memory args; - r.addArgs(args); - } - - function addTwoArgs(string memory arg1, string memory arg2) public { - string[] memory args = new string[](2); - args[0] = arg1; - args[1] = arg2; - Functions.Request memory r = s_req; - r.addArgs(args); - storeRequest(r); - } - - function storeRequest(Functions.Request memory r) private { - s_req.codeLocation = r.codeLocation; - s_req.language = r.language; - s_req.source = r.source; - s_req.args = r.args; - s_req.secretsLocation = r.secretsLocation; - s_req.secrets = r.secrets; - } -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/AuthorizedOriginReceiverInterface.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/AuthorizedOriginReceiverInterface.sol deleted file mode 100644 index 5f3567613dd..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/AuthorizedOriginReceiverInterface.sol +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -/** - * @notice Modified AuthorizedReciever abstract for use on the Functions Oracle contract to limit usage - * @notice Uses tx.origin instead of msg.sender because the client contract sends messages to the Oracle contract - */ - -interface AuthorizedOriginReceiverInterface { - /** - * @dev Returns true if the contract is paused, and false otherwise. - */ - function authorizedReceiverActive() external view returns (bool); - - /** - * @dev Triggers AuthorizedOriginReceiver usage to block unuthorized senders. - * - * Requirements: - * - * - The contract must not be deactive. - */ - function activateAuthorizedReceiver() external; - - /** - * @dev Triggers AuthorizedOriginReceiver usage to allow all senders. - * - * Requirements: - * - * - The contract must be active. - */ - function deactivateAuthorizedReceiver() external; - - /** - * @notice Sets the permission to request for the given wallet(s). - * @param senders The addresses of the wallet addresses to grant access - */ - function addAuthorizedSenders(address[] calldata senders) external; - - /** - * @notice Remove the permission to request for the given wallet(s). - * @param senders The addresses of the wallet addresses to revoke access - */ - function removeAuthorizedSenders(address[] calldata senders) external; - - /** - * @notice Retrieve a list of authorized senders - * @return array of addresses - */ - function getAuthorizedSenders() external view returns (address[] memory); - - /** - * @notice Use this to check if a node is authorized for fulfilling requests - * @param sender The address of the Chainlink node - * @return The authorization status of the node - */ - function isAuthorizedSender(address sender) external view returns (bool); -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/AuthorizedOriginReceiverUpgradeable.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/AuthorizedOriginReceiverUpgradeable.sol deleted file mode 100644 index a2d0a789b2a..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/AuthorizedOriginReceiverUpgradeable.sol +++ /dev/null @@ -1,153 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {EnumerableSet} from "../../../../../vendor/openzeppelin-solidity/v4.8.0/contracts/utils/structs/EnumerableSet.sol"; -import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; -import {AuthorizedOriginReceiverInterface} from "./AuthorizedOriginReceiverInterface.sol"; - -/** - * @notice Modified AuthorizedReciever abstract for use on the FunctionsOracle contract to limit usage - * @notice Uses tx.origin instead of msg.sender because the client contract sends messages to the Oracle contract - */ - -abstract contract AuthorizedOriginReceiverUpgradeable is Initializable, AuthorizedOriginReceiverInterface { - using EnumerableSet for EnumerableSet.AddressSet; - - event AuthorizedSendersChanged(address[] senders, address changedBy); - event AuthorizedSendersActive(address account); - event AuthorizedSendersDeactive(address account); - - error EmptySendersList(); - error UnauthorizedSender(); - error NotAllowedToSetSenders(); - error AlreadySet(); - - bool private s_active; - EnumerableSet.AddressSet private s_authorizedSenders; - address[] private s_authorizedSendersList; // DEPRECATED, TODO: remove on proxy re-deploy - - /** - * @dev Initializes the contract in active state. - */ - function __AuthorizedOriginReceiver_initialize(bool active) internal onlyInitializing { - s_active = active; - } - - /** - * @dev Returns true if the contract is paused, and false otherwise. - */ - function authorizedReceiverActive() public view virtual override returns (bool) { - return s_active; - } - - /** - * @dev Triggers AuthorizedOriginReceiver usage to block unuthorized senders. - * - * Requirements: - * - * - The contract must not be deactive. - */ - function activateAuthorizedReceiver() external validateAuthorizedSenderSetter { - if (authorizedReceiverActive()) { - revert AlreadySet(); - } - s_active = true; - emit AuthorizedSendersActive(msg.sender); - } - - /** - * @dev Triggers AuthorizedOriginReceiver usage to allow all senders. - * - * Requirements: - * - * - The contract must be active. - */ - function deactivateAuthorizedReceiver() external validateAuthorizedSenderSetter { - if (!authorizedReceiverActive()) { - revert AlreadySet(); - } - s_active = false; - emit AuthorizedSendersDeactive(msg.sender); - } - - /** - * @notice Sets the permission to request for the given wallet(s). - * @param senders The addresses of the wallet addresses to grant access - */ - function addAuthorizedSenders(address[] calldata senders) external validateAuthorizedSenderSetter { - if (senders.length == 0) { - revert EmptySendersList(); - } - for (uint256 i = 0; i < senders.length; i++) { - s_authorizedSenders.add(senders[i]); - } - emit AuthorizedSendersChanged(senders, msg.sender); - } - - /** - * @notice Remove the permission to request for the given wallet(s). - * @param senders The addresses of the wallet addresses to revoke access - */ - function removeAuthorizedSenders(address[] calldata senders) external validateAuthorizedSenderSetter { - if (senders.length == 0) { - revert EmptySendersList(); - } - for (uint256 i = 0; i < senders.length; i++) { - s_authorizedSenders.remove(senders[i]); - } - emit AuthorizedSendersChanged(senders, msg.sender); - } - - /** - * @notice Retrieve a list of authorized senders - * @return array of addresses - */ - function getAuthorizedSenders() public view returns (address[] memory) { - return EnumerableSet.values(s_authorizedSenders); - } - - /** - * @notice Use this to check if a node is authorized for fulfilling requests - * @param sender The address of the Chainlink node - * @return The authorization status of the node - */ - function isAuthorizedSender(address sender) public view returns (bool) { - if (!authorizedReceiverActive()) { - return true; - } - return s_authorizedSenders.contains(sender); - } - - /** - * @notice customizable guard of who can update the authorized sender list - * @return bool whether sender can update authorized sender list - */ - function _canSetAuthorizedSenders() internal virtual returns (bool); - - /** - * @notice validates the sender is an authorized sender - */ - function _validateIsAuthorizedSender() internal view { - if (!isAuthorizedSender(tx.origin)) { - revert UnauthorizedSender(); - } - } - - /** - * @notice prevents non-authorized addresses from calling this method - */ - modifier validateAuthorizedSender() { - _validateIsAuthorizedSender(); - _; - } - - /** - * @notice prevents non-authorized addresses from calling this method - */ - modifier validateAuthorizedSenderSetter() { - if (!_canSetAuthorizedSenders()) { - revert NotAllowedToSetSenders(); - } - _; - } -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/AuthorizedReceiver.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/AuthorizedReceiver.sol deleted file mode 100644 index 52078ff6447..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/AuthorizedReceiver.sol +++ /dev/null @@ -1,86 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {EnumerableSet} from "../../../../../vendor/openzeppelin-solidity/v4.8.0/contracts/utils/structs/EnumerableSet.sol"; -import {AuthorizedReceiverInterface} from "./AuthorizedReceiverInterface.sol"; - -abstract contract AuthorizedReceiver is AuthorizedReceiverInterface { - using EnumerableSet for EnumerableSet.AddressSet; - - event AuthorizedSendersChanged(address[] senders, address changedBy); - - error EmptySendersList(); - error UnauthorizedSender(); - error NotAllowedToSetSenders(); - - EnumerableSet.AddressSet private s_authorizedSenders; - address[] private s_authorizedSendersList; - - /** - * @notice Sets the fulfillment permission for a given node. Use `true` to allow, `false` to disallow. - * @param senders The addresses of the authorized Chainlink node - */ - function setAuthorizedSenders(address[] calldata senders) external override validateAuthorizedSenderSetter { - if (senders.length == 0) { - revert EmptySendersList(); - } - for (uint256 i = 0; i < s_authorizedSendersList.length; i++) { - s_authorizedSenders.remove(s_authorizedSendersList[i]); - } - for (uint256 i = 0; i < senders.length; i++) { - s_authorizedSenders.add(senders[i]); - } - s_authorizedSendersList = senders; - emit AuthorizedSendersChanged(senders, msg.sender); - } - - /** - * @notice Retrieve a list of authorized senders - * @return array of addresses - */ - function getAuthorizedSenders() public view override returns (address[] memory) { - return s_authorizedSendersList; - } - - /** - * @notice Use this to check if a node is authorized for fulfilling requests - * @param sender The address of the Chainlink node - * @return The authorization status of the node - */ - function isAuthorizedSender(address sender) public view override returns (bool) { - return s_authorizedSenders.contains(sender); - } - - /** - * @notice customizable guard of who can update the authorized sender list - * @return bool whether sender can update authorized sender list - */ - function _canSetAuthorizedSenders() internal virtual returns (bool); - - /** - * @notice validates the sender is an authorized sender - */ - function _validateIsAuthorizedSender() internal view { - if (!isAuthorizedSender(msg.sender)) { - revert UnauthorizedSender(); - } - } - - /** - * @notice prevents non-authorized addresses from calling this method - */ - modifier validateAuthorizedSender() { - _validateIsAuthorizedSender(); - _; - } - - /** - * @notice prevents non-authorized addresses from calling this method - */ - modifier validateAuthorizedSenderSetter() { - if (!_canSetAuthorizedSenders()) { - revert NotAllowedToSetSenders(); - } - _; - } -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/AuthorizedReceiverInterface.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/AuthorizedReceiverInterface.sol deleted file mode 100644 index 28b20b14f33..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/AuthorizedReceiverInterface.sol +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -interface AuthorizedReceiverInterface { - function isAuthorizedSender(address sender) external view returns (bool); - - function getAuthorizedSenders() external returns (address[] memory); - - function setAuthorizedSenders(address[] calldata senders) external; -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/ConfirmedOwnerUpgradeable.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/ConfirmedOwnerUpgradeable.sol deleted file mode 100644 index a6cf69d0913..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/ConfirmedOwnerUpgradeable.sol +++ /dev/null @@ -1,96 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {IOwnable} from "../../../../../shared/interfaces/IOwnable.sol"; -import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; - -/** - * @title The ConfirmedOwnerUpgradeable contract - * @notice An upgrade compatible contract with helpers for basic contract ownership. - */ -contract ConfirmedOwnerUpgradeable is Initializable, IOwnable { - address private s_owner; - address private s_pendingOwner; - - event OwnershipTransferRequested(address indexed from, address indexed to); - event OwnershipTransferred(address indexed from, address indexed to); - - error OwnerMustBeSet(); - error NotProposedOwner(); - error CannotSelfTransfer(); - error OnlyCallableByOwner(); - - /** - * @dev Initializes the contract in unpaused state. - */ - function __ConfirmedOwner_initialize(address newOwner, address pendingOwner) internal onlyInitializing { - if (newOwner == address(0)) { - revert OwnerMustBeSet(); - } - - s_owner = newOwner; - if (pendingOwner != address(0)) { - _transferOwnership(pendingOwner); - } - } - - /** - * @notice Allows an owner to begin transferring ownership to a new address, - * pending. - */ - function transferOwnership(address to) public override onlyOwner { - _transferOwnership(to); - } - - /** - * @notice Allows an ownership transfer to be completed by the recipient. - */ - function acceptOwnership() external override { - if (msg.sender != s_pendingOwner) { - revert NotProposedOwner(); - } - - address oldOwner = s_owner; - s_owner = msg.sender; - s_pendingOwner = address(0); - - emit OwnershipTransferred(oldOwner, msg.sender); - } - - /** - * @notice Get the current owner - */ - function owner() public view override returns (address) { - return s_owner; - } - - /** - * @notice validate, transfer ownership, and emit relevant events - */ - function _transferOwnership(address to) private { - if (to == msg.sender) { - revert CannotSelfTransfer(); - } - - s_pendingOwner = to; - - emit OwnershipTransferRequested(s_owner, to); - } - - /** - * @notice validate access - */ - function _validateOwnership() internal view { - if (msg.sender != s_owner) { - revert OnlyCallableByOwner(); - } - } - - /** - * @notice Reverts if called by anyone other than the contract owner. - */ - modifier onlyOwner() { - _validateOwnership(); - _; - } -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsBillingRegistryInterface.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsBillingRegistryInterface.sol deleted file mode 100644 index 63044267645..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsBillingRegistryInterface.sol +++ /dev/null @@ -1,93 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -/** - * @title Chainlink Functions billing subscription registry interface. - */ -interface FunctionsBillingRegistryInterface { - struct RequestBilling { - // a unique subscription ID allocated by billing system, - uint64 subscriptionId; - // the client contract that initiated the request to the DON - // to use the subscription it must be added as a consumer on the subscription - address client; - // customer specified gas limit for the fulfillment callback - uint32 gasLimit; - // the expected gas price used to execute the transaction - uint256 gasPrice; - } - - /** - * @notice Get configuration relevant for making requests - * @return uint32 global max for request gas limit - * @return address[] list of registered DONs - */ - function getRequestConfig() external view returns (uint32, address[] memory); - - /** - * @notice Determine the charged fee that will be paid to the Registry owner - * @param data Encoded Chainlink Functions request data, use FunctionsClient API to encode a request - * @param billing The request's billing configuration - * @return fee Cost in Juels (1e18) of LINK - */ - function getRequiredFee( - bytes calldata data, - FunctionsBillingRegistryInterface.RequestBilling memory billing - ) external view returns (uint96); - - /** - * @notice Estimate the total cost to make a request: gas re-imbursement, plus DON fee, plus Registry fee - * @param gasLimit Encoded Chainlink Functions request data, use FunctionsClient API to encode a request - * @param gasPrice The request's billing configuration - * @param donFee Fee charged by the DON that is paid to Oracle Node - * @param registryFee Fee charged by the DON that is paid to Oracle Node - * @return costEstimate Cost in Juels (1e18) of LINK - */ - function estimateCost( - uint32 gasLimit, - uint256 gasPrice, - uint96 donFee, - uint96 registryFee - ) external view returns (uint96); - - /** - * @notice Initiate the billing process for an Functions request - * @param data Encoded Chainlink Functions request data, use FunctionsClient API to encode a request - * @param billing Billing configuration for the request - * @return requestId - A unique identifier of the request. Can be used to match a request to a response in fulfillRequest. - * @dev Only callable by a node that has been approved on the Registry - */ - function startBilling(bytes calldata data, RequestBilling calldata billing) external returns (bytes32); - - /** - * @notice Finalize billing process for an Functions request by sending a callback to the Client contract and then charging the subscription - * @param requestId identifier for the request that was generated by the Registry in the beginBilling commitment - * @param response response data from DON consensus - * @param err error from DON consensus - * @param transmitter the Oracle who sent the report - * @param signers the Oracles who had a part in generating the report - * @param signerCount the number of signers on the report - * @param reportValidationGas the amount of gas used for the report validation. Cost is split by all fulfillments on the report. - * @param initialGas the initial amount of gas that should be used as a baseline to charge the single fulfillment for execution cost - * @return success - * @dev Only callable by a node that has been approved on the Registry - * @dev simulated offchain to determine if sufficient balance is present to fulfill the request - */ - function fulfillAndBill( - bytes32 requestId, - bytes calldata response, - bytes calldata err, - address transmitter, - address[31] memory signers, // 31 comes from OCR2Abstract.sol's maxNumOracles constant - uint8 signerCount, - uint256 reportValidationGas, - uint256 initialGas - ) external returns (bool success); - - /** - * @notice Gets subscription owner. - * @param subscriptionId - ID of the subscription - * @return owner - owner of the subscription. - */ - function getSubscriptionOwner(uint64 subscriptionId) external view returns (address owner); -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsBillingRegistryMigration.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsBillingRegistryMigration.sol deleted file mode 100644 index ef63f4c71ae..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsBillingRegistryMigration.sol +++ /dev/null @@ -1,835 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {LinkTokenInterface} from "../../../../../shared/interfaces/LinkTokenInterface.sol"; -import {AggregatorV3Interface} from "../../../../../interfaces/AggregatorV3Interface.sol"; -import {FunctionsBillingRegistryInterface} from "./FunctionsBillingRegistryInterface.sol"; -import {FunctionsOracleInterface} from "./FunctionsOracleInterface.sol"; -import {FunctionsClientInterface} from "./FunctionsClientInterface.sol"; -import {IERC677Receiver} from "../../../../../shared/interfaces/IERC677Receiver.sol"; -import {AuthorizedOriginReceiverInterface} from "./AuthorizedOriginReceiverInterface.sol"; -import {ConfirmedOwnerUpgradeable} from "./ConfirmedOwnerUpgradeable.sol"; -import {AuthorizedReceiver} from "./AuthorizedReceiver.sol"; -import {SafeCast} from "../../../../../vendor/openzeppelin-solidity/v4.8.0/contracts/utils/math/SafeCast.sol"; -import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; -import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; - -/** - * @title Functions Billing Registry contract - * @notice Contract that coordinates payment from users to the nodes of the Decentralized Oracle Network (DON). - * @dev THIS CONTRACT HAS NOT GONE THROUGH ANY SECURITY REVIEW. DO NOT USE IN PROD. - */ -contract FunctionsBillingRegistryMigration is - Initializable, - ConfirmedOwnerUpgradeable, - PausableUpgradeable, - FunctionsBillingRegistryInterface, - IERC677Receiver, - AuthorizedReceiver -{ - LinkTokenInterface public LINK; - AggregatorV3Interface public LINK_ETH_FEED; - AuthorizedOriginReceiverInterface private ORACLE_WITH_ALLOWLIST; - - // We need to maintain a list of consuming addresses. - // This bound ensures we are able to loop over them as needed. - // Should a user require more consumers, they can use multiple subscriptions. - uint16 public constant MAX_CONSUMERS = 100; - - error TooManyConsumers(); - error InsufficientBalance(); - error InvalidConsumer(uint64 subscriptionId, address consumer); - error InvalidSubscription(); - error OnlyCallableFromLink(); - error InvalidCalldata(); - error MustBeSubOwner(address owner); - error PendingRequestExists(); - error MustBeRequestedOwner(address proposedOwner); - error BalanceInvariantViolated(uint256 internalBalance, uint256 externalBalance); // Should never happen - event FundsRecovered(address to, uint256 amount); - - struct Subscription { - // There are only 1e9*1e18 = 1e27 juels in existence, so the balance can fit in uint96 (2^96 ~ 7e28) - uint96 balance; // Common LINK balance that is controlled by the Registry to be used for all consumer requests. - uint96 blockedBalance; // LINK balance that is reserved to pay for pending consumer requests. - } - // We use the config for the mgmt APIs - struct SubscriptionConfig { - address owner; // Owner can fund/withdraw/cancel the sub. - address requestedOwner; // For safely transferring sub ownership. - // Maintains the list of keys in s_consumers. - // We do this for 2 reasons: - // 1. To be able to clean up all keys from s_consumers when canceling a subscription. - // 2. To be able to return the list of all consumers in getSubscription. - // Note that we need the s_consumers map to be able to directly check if a - // consumer is valid without reading all the consumers from storage. - address[] consumers; - } - // Note a nonce of 0 indicates an the consumer is not assigned to that subscription. - mapping(address => mapping(uint64 => uint64)) /* consumer */ /* subscriptionId */ /* nonce */ private s_consumers; - mapping(uint64 => SubscriptionConfig) /* subscriptionId */ /* subscriptionConfig */ private s_subscriptionConfigs; - mapping(uint64 => Subscription) /* subscriptionId */ /* subscription */ private s_subscriptions; - // We make the sub count public so that its possible to - // get all the current subscriptions via getSubscription. - uint64 private s_currentsubscriptionId; - // s_totalBalance tracks the total link sent to/from - // this contract through onTokenTransfer, cancelSubscription and oracleWithdraw. - // A discrepancy with this contract's link balance indicates someone - // sent tokens using transfer and so we may need to use recoverFunds. - uint96 private s_totalBalance; - event SubscriptionCreated(uint64 indexed subscriptionId, address owner); - event SubscriptionFunded(uint64 indexed subscriptionId, uint256 oldBalance, uint256 newBalance); - event SubscriptionConsumerAdded(uint64 indexed subscriptionId, address consumer); - event SubscriptionConsumerRemoved(uint64 indexed subscriptionId, address consumer); - event SubscriptionCanceled(uint64 indexed subscriptionId, address to, uint256 amount); - event SubscriptionOwnerTransferRequested(uint64 indexed subscriptionId, address from, address to); - event SubscriptionOwnerTransferred(uint64 indexed subscriptionId, address from, address to); - - error GasLimitTooBig(uint32 have, uint32 want); - error InvalidLinkWeiPrice(int256 linkWei); - error IncorrectRequestID(); - error PaymentTooLarge(); - error Reentrant(); - - mapping(address => uint96) /* oracle node */ /* LINK balance */ private s_withdrawableTokens; - struct Commitment { - uint64 subscriptionId; - address client; - uint32 gasLimit; - uint256 gasPrice; - address don; - uint96 donFee; - uint96 registryFee; - uint96 estimatedCost; - uint256 timestamp; - } - mapping(bytes32 => Commitment) /* requestID */ /* Commitment */ private s_requestCommitments; - event BillingStart(bytes32 indexed requestId, Commitment commitment); - struct ItemizedBill { - uint96 signerPayment; - uint96 transmitterPayment; - uint96 totalCost; - } - event BillingEnd( - bytes32 indexed requestId, - uint64 subscriptionId, - uint96 signerPayment, - uint96 transmitterPayment, - uint96 totalCost, - bool success - ); - event RequestTimedOut(bytes32 indexed requestId); - - struct Config { - // Maxiumum amount of gas that can be given to a request's client callback - uint32 maxGasLimit; - // Reentrancy protection. - bool reentrancyLock; - // stalenessSeconds is how long before we consider the feed price to be stale - // and fallback to fallbackWeiPerUnitLink. - uint32 stalenessSeconds; - // Gas to cover transmitter oracle payment after we calculate the payment. - // We make it configurable in case those operations are repriced. - uint256 gasAfterPaymentCalculation; - // Represents the average gas execution cost. Used in estimating cost beforehand. - uint32 gasOverhead; - // how many seconds it takes before we consider a request to be timed out - uint32 requestTimeoutSeconds; - } - int256 private s_fallbackWeiPerUnitLink; - Config private s_config; - event ConfigSet( - uint32 maxGasLimit, - uint32 stalenessSeconds, - uint256 gasAfterPaymentCalculation, - int256 fallbackWeiPerUnitLink, - uint32 gasOverhead - ); - - /** - * @dev Initializes the contract. - */ - function initialize(address link, address linkEthFeed, address oracle) public initializer { - __Pausable_init(); - __ConfirmedOwner_initialize(msg.sender, address(0)); - LINK = LinkTokenInterface(link); - LINK_ETH_FEED = AggregatorV3Interface(linkEthFeed); - ORACLE_WITH_ALLOWLIST = AuthorizedOriginReceiverInterface(oracle); - } - - /** - * @notice Sets the configuration of the Chainlink Functions billing registry - * @param maxGasLimit global max for request gas limit - * @param stalenessSeconds if the eth/link feed is more stale then this, use the fallback price - * @param gasAfterPaymentCalculation gas used in doing accounting after completing the gas measurement - * @param fallbackWeiPerUnitLink fallback eth/link price in the case of a stale feed - * @param gasOverhead average gas execution cost used in estimating total cost - * @param requestTimeoutSeconds e2e timeout after which user won't be charged - */ - function setConfig( - uint32 maxGasLimit, - uint32 stalenessSeconds, - uint256 gasAfterPaymentCalculation, - int256 fallbackWeiPerUnitLink, - uint32 gasOverhead, - uint32 requestTimeoutSeconds - ) external onlyOwner { - if (fallbackWeiPerUnitLink <= 0) { - revert InvalidLinkWeiPrice(fallbackWeiPerUnitLink); - } - s_config = Config({ - maxGasLimit: maxGasLimit, - stalenessSeconds: stalenessSeconds, - gasAfterPaymentCalculation: gasAfterPaymentCalculation, - reentrancyLock: false, - gasOverhead: gasOverhead, - requestTimeoutSeconds: requestTimeoutSeconds - }); - s_fallbackWeiPerUnitLink = fallbackWeiPerUnitLink; - emit ConfigSet(maxGasLimit, stalenessSeconds, gasAfterPaymentCalculation, fallbackWeiPerUnitLink, gasOverhead); - } - - /** - * @notice Gets the configuration of the Chainlink Functions billing registry - * @return maxGasLimit global max for request gas limit - * @return stalenessSeconds if the eth/link feed is more stale then this, use the fallback price - * @return gasAfterPaymentCalculation gas used in doing accounting after completing the gas measurement - * @return fallbackWeiPerUnitLink fallback eth/link price in the case of a stale feed - * @return gasOverhead average gas execution cost used in estimating total cost - */ - function getConfig() - external - view - returns ( - uint32 maxGasLimit, - uint32 stalenessSeconds, - uint256 gasAfterPaymentCalculation, - int256 fallbackWeiPerUnitLink, - uint32 gasOverhead - ) - { - return ( - s_config.maxGasLimit, - s_config.stalenessSeconds, - s_config.gasAfterPaymentCalculation, - s_fallbackWeiPerUnitLink, - s_config.gasOverhead - ); - } - - function pause() external onlyOwner { - _pause(); - } - - function unpause() external onlyOwner { - _unpause(); - } - - function getTotalBalance() external view returns (uint256) { - return s_totalBalance; - } - - /** - * @notice Owner cancel subscription, sends remaining link directly to the subscription owner. - * @param subscriptionId subscription id - * @dev notably can be called even if there are pending requests, outstanding ones may fail onchain - */ - function ownerCancelSubscription(uint64 subscriptionId) external onlyOwner { - address owner = s_subscriptionConfigs[subscriptionId].owner; - if (owner == address(0)) { - revert InvalidSubscription(); - } - cancelSubscriptionHelper(subscriptionId, owner); - } - - /** - * @notice Recover link sent with transfer instead of transferAndCall. - * @param to address to send link to - */ - function recoverFunds(address to) external onlyOwner { - uint256 externalBalance = LINK.balanceOf(address(this)); - uint256 internalBalance = uint256(s_totalBalance); - if (internalBalance > externalBalance) { - revert BalanceInvariantViolated(internalBalance, externalBalance); - } - if (internalBalance < externalBalance) { - uint256 amount = externalBalance - internalBalance; - LINK.transfer(to, amount); - emit FundsRecovered(to, amount); - } - // If the balances are equal, nothing to be done. - } - - /** - * @inheritdoc FunctionsBillingRegistryInterface - */ - function getRequestConfig() external view override returns (uint32, address[] memory) { - return (s_config.maxGasLimit, getAuthorizedSenders()); - } - - /** - * @inheritdoc FunctionsBillingRegistryInterface - */ - function getRequiredFee( - bytes calldata /* data */, - FunctionsBillingRegistryInterface.RequestBilling memory /* billing */ - ) public pure override returns (uint96) { - return 1; - } - - /** - * @inheritdoc FunctionsBillingRegistryInterface - */ - function estimateCost( - uint32 gasLimit, - uint256 gasPrice, - uint96 donFee, - uint96 registryFee - ) public view override returns (uint96) { - int256 weiPerUnitLink; - weiPerUnitLink = getFeedData(); - if (weiPerUnitLink <= 0) { - revert InvalidLinkWeiPrice(weiPerUnitLink); - } - uint256 executionGas = s_config.gasOverhead + s_config.gasAfterPaymentCalculation + gasLimit; - // (1e18 juels/link) (wei/gas * gas) / (wei/link) = juels - uint256 paymentNoFee = (1e18 * gasPrice * executionGas) / uint256(weiPerUnitLink); - uint256 fee = uint256(donFee) + uint256(registryFee); - if (paymentNoFee > (1e27 - fee)) { - revert PaymentTooLarge(); // Payment + fee cannot be more than all of the link in existence. - } - return uint96(paymentNoFee + fee); - } - - /** - * @inheritdoc FunctionsBillingRegistryInterface - */ - function startBilling( - bytes calldata data, - RequestBilling calldata billing - ) external override validateAuthorizedSender nonReentrant whenNotPaused returns (bytes32) { - // Input validation using the subscription storage. - if (s_subscriptionConfigs[billing.subscriptionId].owner == address(0)) { - revert InvalidSubscription(); - } - // It's important to ensure that the consumer is in fact who they say they - // are, otherwise they could use someone else's subscription balance. - // A nonce of 0 indicates consumer is not allocated to the sub. - uint64 currentNonce = s_consumers[billing.client][billing.subscriptionId]; - if (currentNonce == 0) { - revert InvalidConsumer(billing.subscriptionId, billing.client); - } - // No lower bound on the requested gas limit. A user could request 0 - // and they would simply be billed for the gas and computation. - if (billing.gasLimit > s_config.maxGasLimit) { - revert GasLimitTooBig(billing.gasLimit, s_config.maxGasLimit); - } - - // Check that subscription can afford the estimated cost - uint96 oracleFee = FunctionsOracleInterface(msg.sender).getRequiredFee(data, billing); - uint96 registryFee = getRequiredFee(data, billing); - uint96 estimatedCost = estimateCost(billing.gasLimit, billing.gasPrice, oracleFee, registryFee); - uint96 effectiveBalance = s_subscriptions[billing.subscriptionId].balance - - s_subscriptions[billing.subscriptionId].blockedBalance; - if (effectiveBalance < estimatedCost) { - revert InsufficientBalance(); - } - - uint64 nonce = currentNonce + 1; - bytes32 requestId = computeRequestId(msg.sender, billing.client, billing.subscriptionId, nonce); - - Commitment memory commitment = Commitment( - billing.subscriptionId, - billing.client, - billing.gasLimit, - billing.gasPrice, - msg.sender, - oracleFee, - registryFee, - estimatedCost, - block.timestamp - ); - s_requestCommitments[requestId] = commitment; - s_subscriptions[billing.subscriptionId].blockedBalance += estimatedCost; - - emit BillingStart(requestId, commitment); - s_consumers[billing.client][billing.subscriptionId] = nonce; - return requestId; - } - - function computeRequestId( - address don, - address client, - uint64 subscriptionId, - uint64 nonce - ) private pure returns (bytes32) { - return keccak256(abi.encode(don, client, subscriptionId, nonce)); - } - - /** - * @dev calls target address with exactly gasAmount gas and data as calldata - * or reverts if at least gasAmount gas is not available. - */ - function callWithExactGas(uint256 gasAmount, address target, bytes memory data) private returns (bool success) { - assembly { - let g := gas() - // GAS_FOR_CALL_EXACT_CHECK = 5000 - // Compute g -= GAS_FOR_CALL_EXACT_CHECK and check for underflow - // The gas actually passed to the callee is min(gasAmount, 63//64*gas available). - // We want to ensure that we revert if gasAmount > 63//64*gas available - // as we do not want to provide them with less, however that check itself costs - // gas. GAS_FOR_CALL_EXACT_CHECK ensures we have at least enough gas to be able - // to revert if gasAmount > 63//64*gas available. - if lt(g, 5000) { - revert(0, 0) - } - g := sub(g, 5000) - // if g - g//64 <= gasAmount, revert - // (we subtract g//64 because of EIP-150) - if iszero(gt(sub(g, div(g, 64)), gasAmount)) { - revert(0, 0) - } - // solidity calls check that a contract actually exists at the destination, so we do the same - if iszero(extcodesize(target)) { - revert(0, 0) - } - // call and return whether we succeeded. ignore return data - // call(gas,addr,value,argsOffset,argsLength,retOffset,retLength) - success := call(gasAmount, target, 0, add(data, 0x20), mload(data), 0, 0) - } - return success; - } - - /** - * @inheritdoc FunctionsBillingRegistryInterface - */ - function fulfillAndBill( - bytes32 requestId, - bytes calldata response, - bytes calldata err, - address transmitter, - address[31] memory signers, - uint8 signerCount, - uint256 reportValidationGas, - uint256 initialGas - ) external override validateAuthorizedSender nonReentrant whenNotPaused returns (bool success) { - Commitment memory commitment = s_requestCommitments[requestId]; - if (commitment.don == address(0)) { - revert IncorrectRequestID(); - } - delete s_requestCommitments[requestId]; - - bytes memory callback = abi.encodeWithSelector( - FunctionsClientInterface.handleOracleFulfillment.selector, - requestId, - response, - err - ); - // Call with explicitly the amount of callback gas requested - // Important to not let them exhaust the gas budget and avoid payment. - // Do not allow any non-view/non-pure coordinator functions to be called - // during the consumers callback code via reentrancyLock. - // NOTE: that callWithExactGas will revert if we do not have sufficient gas - // to give the callee their requested amount. - s_config.reentrancyLock = true; - success = callWithExactGas(commitment.gasLimit, commitment.client, callback); - s_config.reentrancyLock = false; - - // We want to charge users exactly for how much gas they use in their callback. - // The gasAfterPaymentCalculation is meant to cover these additional operations where we - // decrement the subscription balance and increment the oracle's withdrawable balance. - ItemizedBill memory bill = calculatePaymentAmount( - initialGas, - s_config.gasAfterPaymentCalculation, - commitment.donFee, - signerCount, - commitment.registryFee, - reportValidationGas, - tx.gasprice - ); - if (s_subscriptions[commitment.subscriptionId].balance < bill.totalCost) { - revert InsufficientBalance(); - } - s_subscriptions[commitment.subscriptionId].balance -= bill.totalCost; - // Pay out signers their portion of the DON fee - for (uint256 i = 0; i < signerCount; i++) { - if (signers[i] != transmitter) { - s_withdrawableTokens[signers[i]] += bill.signerPayment; - } - } - // Pay out the registry fee - s_withdrawableTokens[owner()] += commitment.registryFee; - // Reimburse the transmitter for the execution gas cost + pay them their portion of the DON fee - s_withdrawableTokens[transmitter] += bill.transmitterPayment; - // Remove blocked balance - s_subscriptions[commitment.subscriptionId].blockedBalance -= commitment.estimatedCost; - // Include payment in the event for tracking costs. - emit BillingEnd( - requestId, - commitment.subscriptionId, - bill.signerPayment, - bill.transmitterPayment, - bill.totalCost, - success - ); - } - - // Determine the cost breakdown for payment - function calculatePaymentAmount( - uint256 startGas, - uint256 gasAfterPaymentCalculation, - uint96 donFee, - uint8 signerCount, - uint96 registryFee, - uint256 reportValidationGas, - uint256 weiPerUnitGas - ) private view returns (ItemizedBill memory) { - int256 weiPerUnitLink; - weiPerUnitLink = getFeedData(); - if (weiPerUnitLink <= 0) { - revert InvalidLinkWeiPrice(weiPerUnitLink); - } - // (1e18 juels/link) (wei/gas * gas) / (wei/link) = juels - uint256 paymentNoFee = (1e18 * - weiPerUnitGas * - (reportValidationGas + gasAfterPaymentCalculation + startGas - gasleft())) / uint256(weiPerUnitLink); - uint256 fee = uint256(donFee) + uint256(registryFee); - if (paymentNoFee > (1e27 - fee)) { - revert PaymentTooLarge(); // Payment + fee cannot be more than all of the link in existence. - } - uint96 signerPayment = donFee / uint96(signerCount); - uint96 transmitterPayment = uint96(paymentNoFee) + signerPayment; - uint96 totalCost = SafeCast.toUint96(paymentNoFee + fee); - return ItemizedBill(signerPayment, transmitterPayment, totalCost); - } - - function getFeedData() private view returns (int256) { - uint32 stalenessSeconds = s_config.stalenessSeconds; - bool staleFallback = stalenessSeconds > 0; - (, int256 weiPerUnitLink, , uint256 timestamp, ) = LINK_ETH_FEED.latestRoundData(); - // solhint-disable-next-line not-rely-on-time - if (staleFallback && stalenessSeconds < block.timestamp - timestamp) { - weiPerUnitLink = s_fallbackWeiPerUnitLink; - } - return weiPerUnitLink; - } - - /* - * @notice Oracle withdraw LINK earned through fulfilling requests - * @notice If amount is 0 the full balance will be withdrawn - * @param recipient where to send the funds - * @param amount amount to withdraw - */ - function oracleWithdraw(address recipient, uint96 amount) external nonReentrant whenNotPaused { - if (amount == 0) { - amount = s_withdrawableTokens[msg.sender]; - } - if (s_withdrawableTokens[msg.sender] < amount) { - revert InsufficientBalance(); - } - s_withdrawableTokens[msg.sender] -= amount; - s_totalBalance -= amount; - if (!LINK.transfer(recipient, amount)) { - revert InsufficientBalance(); - } - } - - function onTokenTransfer( - address /* sender */, - uint256 amount, - bytes calldata data - ) external override nonReentrant whenNotPaused { - if (msg.sender != address(LINK)) { - revert OnlyCallableFromLink(); - } - if (data.length != 32) { - revert InvalidCalldata(); - } - uint64 subscriptionId = abi.decode(data, (uint64)); - if (s_subscriptionConfigs[subscriptionId].owner == address(0)) { - revert InvalidSubscription(); - } - // We do not check that the msg.sender is the subscription owner, - // anyone can fund a subscription. - uint256 oldBalance = s_subscriptions[subscriptionId].balance; - s_subscriptions[subscriptionId].balance += uint96(amount); - s_totalBalance += uint96(amount); - emit SubscriptionFunded(subscriptionId, oldBalance, oldBalance + amount); - } - - function getCurrentsubscriptionId() external view returns (uint64) { - return s_currentsubscriptionId; - } - - /** - * @notice Get details about a subscription. - * @param subscriptionId - ID of the subscription - * @return balance - LINK balance of the subscription in juels. - * @return owner - owner of the subscription. - * @return consumers - list of consumer address which are able to use this subscription. - */ - function getSubscription( - uint64 subscriptionId - ) external view returns (uint96 balance, address owner, address[] memory consumers) { - if (s_subscriptionConfigs[subscriptionId].owner == address(0)) { - revert InvalidSubscription(); - } - return ( - s_subscriptions[subscriptionId].balance, - s_subscriptionConfigs[subscriptionId].owner, - s_subscriptionConfigs[subscriptionId].consumers - ); - } - - /** - * @notice Create a new subscription. - * @return subscriptionId - A unique subscription id. - * @dev You can manage the consumer set dynamically with addConsumer/removeConsumer. - * @dev Note to fund the subscription, use transferAndCall. For example - * @dev LINKTOKEN.transferAndCall( - * @dev address(REGISTRY), - * @dev amount, - * @dev abi.encode(subscriptionId)); - */ - function createSubscription() external nonReentrant whenNotPaused onlyAuthorizedUsers returns (uint64) { - s_currentsubscriptionId++; - uint64 currentsubscriptionId = s_currentsubscriptionId; - address[] memory consumers = new address[](0); - s_subscriptions[currentsubscriptionId] = Subscription({balance: 0, blockedBalance: 0}); - s_subscriptionConfigs[currentsubscriptionId] = SubscriptionConfig({ - owner: msg.sender, - requestedOwner: address(0), - consumers: consumers - }); - - emit SubscriptionCreated(currentsubscriptionId, msg.sender); - return currentsubscriptionId; - } - - /** - * @notice Gets subscription owner. - * @param subscriptionId - ID of the subscription - * @return owner - owner of the subscription. - */ - function getSubscriptionOwner(uint64 subscriptionId) external view override returns (address owner) { - if (s_subscriptionConfigs[subscriptionId].owner == address(0)) { - revert InvalidSubscription(); - } - return s_subscriptionConfigs[subscriptionId].owner; - } - - /** - * @notice Request subscription owner transfer. - * @param subscriptionId - ID of the subscription - * @param newOwner - proposed new owner of the subscription - */ - function requestSubscriptionOwnerTransfer( - uint64 subscriptionId, - address newOwner - ) external onlySubOwner(subscriptionId) nonReentrant whenNotPaused { - // Proposing to address(0) would never be claimable so don't need to check. - if (s_subscriptionConfigs[subscriptionId].requestedOwner != newOwner) { - s_subscriptionConfigs[subscriptionId].requestedOwner = newOwner; - emit SubscriptionOwnerTransferRequested(subscriptionId, msg.sender, newOwner); - } - } - - /** - * @notice Request subscription owner transfer. - * @param subscriptionId - ID of the subscription - * @dev will revert if original owner of subscriptionId has - * not requested that msg.sender become the new owner. - */ - function acceptSubscriptionOwnerTransfer( - uint64 subscriptionId - ) external nonReentrant whenNotPaused onlyAuthorizedUsers { - if (s_subscriptionConfigs[subscriptionId].owner == address(0)) { - revert InvalidSubscription(); - } - if (s_subscriptionConfigs[subscriptionId].requestedOwner != msg.sender) { - revert MustBeRequestedOwner(s_subscriptionConfigs[subscriptionId].requestedOwner); - } - address oldOwner = s_subscriptionConfigs[subscriptionId].owner; - s_subscriptionConfigs[subscriptionId].owner = msg.sender; - s_subscriptionConfigs[subscriptionId].requestedOwner = address(0); - emit SubscriptionOwnerTransferred(subscriptionId, oldOwner, msg.sender); - } - - /** - * @notice Remove a consumer from a Chainlink Functions subscription. - * @param subscriptionId - ID of the subscription - * @param consumer - Consumer to remove from the subscription - */ - function removeConsumer( - uint64 subscriptionId, - address consumer - ) external onlySubOwner(subscriptionId) nonReentrant whenNotPaused { - if (s_consumers[consumer][subscriptionId] == 0) { - revert InvalidConsumer(subscriptionId, consumer); - } - // Note bounded by MAX_CONSUMERS - address[] memory consumers = s_subscriptionConfigs[subscriptionId].consumers; - uint256 lastConsumerIndex = consumers.length - 1; - for (uint256 i = 0; i < consumers.length; i++) { - if (consumers[i] == consumer) { - address last = consumers[lastConsumerIndex]; - // Storage write to preserve last element - s_subscriptionConfigs[subscriptionId].consumers[i] = last; - // Storage remove last element - s_subscriptionConfigs[subscriptionId].consumers.pop(); - break; - } - } - delete s_consumers[consumer][subscriptionId]; - emit SubscriptionConsumerRemoved(subscriptionId, consumer); - } - - /** - * @notice Add a consumer to a Chainlink Functions subscription. - * @param subscriptionId - ID of the subscription - * @param consumer - New consumer which can use the subscription - */ - function addConsumer( - uint64 subscriptionId, - address consumer - ) external onlySubOwner(subscriptionId) nonReentrant whenNotPaused { - // Already maxed, cannot add any more consumers. - if (s_subscriptionConfigs[subscriptionId].consumers.length == MAX_CONSUMERS) { - revert TooManyConsumers(); - } - if (s_consumers[consumer][subscriptionId] != 0) { - // Idempotence - do nothing if already added. - // Ensures uniqueness in s_subscriptions[subscriptionId].consumers. - return; - } - // Initialize the nonce to 1, indicating the consumer is allocated. - s_consumers[consumer][subscriptionId] = 1; - s_subscriptionConfigs[subscriptionId].consumers.push(consumer); - - emit SubscriptionConsumerAdded(subscriptionId, consumer); - } - - /** - * @notice Cancel a subscription - * @param subscriptionId - ID of the subscription - * @param to - Where to send the remaining LINK to - */ - function cancelSubscription( - uint64 subscriptionId, - address to - ) external onlySubOwner(subscriptionId) nonReentrant whenNotPaused { - if (pendingRequestExists(subscriptionId)) { - revert PendingRequestExists(); - } - cancelSubscriptionHelper(subscriptionId, to); - } - - function cancelSubscriptionHelper(uint64 subscriptionId, address to) private nonReentrant { - SubscriptionConfig memory subConfig = s_subscriptionConfigs[subscriptionId]; - uint96 balance = s_subscriptions[subscriptionId].balance; - // Note bounded by MAX_CONSUMERS; - // If no consumers, does nothing. - for (uint256 i = 0; i < subConfig.consumers.length; i++) { - delete s_consumers[subConfig.consumers[i]][subscriptionId]; - } - delete s_subscriptionConfigs[subscriptionId]; - delete s_subscriptions[subscriptionId]; - s_totalBalance -= balance; - if (!LINK.transfer(to, uint256(balance))) { - revert InsufficientBalance(); - } - emit SubscriptionCanceled(subscriptionId, to, balance); - } - - /** - * @notice Check to see if there exists a request commitment for all consumers for a given sub. - * @param subscriptionId - ID of the subscription - * @return true if there exists at least one unfulfilled request for the subscription, false - * otherwise. - * @dev Looping is bounded to MAX_CONSUMERS*(number of DONs). - * @dev Used to disable subscription canceling while outstanding request are present. - */ - - function pendingRequestExists(uint64 subscriptionId) public view returns (bool) { - address[] memory consumers = s_subscriptionConfigs[subscriptionId].consumers; - address[] memory authorizedSendersList = getAuthorizedSenders(); - for (uint256 i = 0; i < consumers.length; i++) { - for (uint256 j = 0; j < authorizedSendersList.length; j++) { - bytes32 requestId = computeRequestId( - authorizedSendersList[j], - consumers[i], - subscriptionId, - s_consumers[consumers[i]][subscriptionId] - ); - if (s_requestCommitments[requestId].don != address(0)) { - return true; - } - } - } - return false; - } - - /** - * @notice Time out all expired requests: unlocks funds and removes the ability for the request to be fulfilled - * @param requestIdsToTimeout - A list of request IDs to time out - */ - - function timeoutRequests(bytes32[] calldata requestIdsToTimeout) external whenNotPaused { - for (uint256 i = 0; i < requestIdsToTimeout.length; i++) { - bytes32 requestId = requestIdsToTimeout[i]; - Commitment memory commitment = s_requestCommitments[requestId]; - - // Check that the message sender is the subscription owner - if (msg.sender != s_subscriptionConfigs[commitment.subscriptionId].owner) { - revert MustBeSubOwner(s_subscriptionConfigs[commitment.subscriptionId].owner); - } - - if (commitment.timestamp + s_config.requestTimeoutSeconds > block.timestamp) { - // Decrement blocked balance - s_subscriptions[commitment.subscriptionId].blockedBalance -= commitment.estimatedCost; - // Delete commitment - delete s_requestCommitments[requestId]; - emit RequestTimedOut(requestId); - } - } - } - - /** - * @dev The allow list is kept on the Oracle contract. This modifier checks if a user is authorized from there. - */ - modifier onlyAuthorizedUsers() { - if (ORACLE_WITH_ALLOWLIST.authorizedReceiverActive() && !ORACLE_WITH_ALLOWLIST.isAuthorizedSender(msg.sender)) { - revert UnauthorizedSender(); - } - _; - } - - modifier onlySubOwner(uint64 subscriptionId) { - address owner = s_subscriptionConfigs[subscriptionId].owner; - if (owner == address(0)) { - revert InvalidSubscription(); - } - if (msg.sender != owner) { - revert MustBeSubOwner(owner); - } - _; - } - - modifier nonReentrant() { - if (s_config.reentrancyLock) { - revert Reentrant(); - } - _; - } - - function _canSetAuthorizedSenders() internal view override onlyOwner returns (bool) { - return true; - } - - /** - * @dev This empty reserved space is put in place to allow future versions to add new - * variables without shifting down storage in the inheritance chain. - * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps - */ - uint256[49] private __gap; -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsBillingRegistryOriginal.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsBillingRegistryOriginal.sol deleted file mode 100644 index 3eeb1387ead..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsBillingRegistryOriginal.sol +++ /dev/null @@ -1,835 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {LinkTokenInterface} from "../../../../../shared/interfaces/LinkTokenInterface.sol"; -import {AggregatorV3Interface} from "../../../../../interfaces/AggregatorV3Interface.sol"; -import {FunctionsOracleInterface} from "./FunctionsOracleInterface.sol"; -import {FunctionsBillingRegistryInterface} from "./FunctionsBillingRegistryInterface.sol"; -import {FunctionsClientInterface} from "./FunctionsClientInterface.sol"; -import {IERC677Receiver} from "../../../../../shared/interfaces/IERC677Receiver.sol"; -import {AuthorizedOriginReceiverInterface} from "./AuthorizedOriginReceiverInterface.sol"; -import {ConfirmedOwnerUpgradeable} from "./ConfirmedOwnerUpgradeable.sol"; -import {AuthorizedReceiver} from "./AuthorizedReceiver.sol"; -import {SafeCast} from "../../../../../vendor/openzeppelin-solidity/v4.8.0/contracts/utils/math/SafeCast.sol"; -import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; -import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; - -/** - * @title Functions Billing Registry contract - * @notice Contract that coordinates payment from users to the nodes of the Decentralized Oracle Network (DON). - * @dev THIS CONTRACT HAS NOT GONE THROUGH ANY SECURITY REVIEW. DO NOT USE IN PROD. - */ -contract FunctionsBillingRegistryOriginal is - Initializable, - ConfirmedOwnerUpgradeable, - PausableUpgradeable, - FunctionsBillingRegistryInterface, - IERC677Receiver, - AuthorizedReceiver -{ - LinkTokenInterface public LINK; - AggregatorV3Interface public LINK_ETH_FEED; - AuthorizedOriginReceiverInterface private ORACLE_WITH_ALLOWLIST; - - // We need to maintain a list of consuming addresses. - // This bound ensures we are able to loop over them as needed. - // Should a user require more consumers, they can use multiple subscriptions. - uint16 public constant MAX_CONSUMERS = 100; - - error TooManyConsumers(); - error InsufficientBalance(); - error InvalidConsumer(uint64 subscriptionId, address consumer); - error InvalidSubscription(); - error OnlyCallableFromLink(); - error InvalidCalldata(); - error MustBeSubOwner(address owner); - error PendingRequestExists(); - error MustBeRequestedOwner(address proposedOwner); - error BalanceInvariantViolated(uint256 internalBalance, uint256 externalBalance); // Should never happen - event FundsRecovered(address to, uint256 amount); - - struct Subscription { - // There are only 1e9*1e18 = 1e27 juels in existence, so the balance can fit in uint96 (2^96 ~ 7e28) - uint96 balance; // Common LINK balance that is controlled by the Registry to be used for all consumer requests. - uint96 blockedBalance; // LINK balance that is reserved to pay for pending consumer requests. - } - // We use the config for the mgmt APIs - struct SubscriptionConfig { - address owner; // Owner can fund/withdraw/cancel the sub. - address requestedOwner; // For safely transferring sub ownership. - // Maintains the list of keys in s_consumers. - // We do this for 2 reasons: - // 1. To be able to clean up all keys from s_consumers when canceling a subscription. - // 2. To be able to return the list of all consumers in getSubscription. - // Note that we need the s_consumers map to be able to directly check if a - // consumer is valid without reading all the consumers from storage. - address[] consumers; - } - // Note a nonce of 0 indicates an the consumer is not assigned to that subscription. - mapping(address => mapping(uint64 => uint64)) /* consumer */ /* subscriptionId */ /* nonce */ private s_consumers; - mapping(uint64 => SubscriptionConfig) /* subscriptionId */ /* subscriptionConfig */ private s_subscriptionConfigs; - mapping(uint64 => Subscription) /* subscriptionId */ /* subscription */ private s_subscriptions; - // We make the sub count public so that its possible to - // get all the current subscriptions via getSubscription. - uint64 private s_currentsubscriptionId; - // s_totalBalance tracks the total link sent to/from - // this contract through onTokenTransfer, cancelSubscription and oracleWithdraw. - // A discrepancy with this contract's link balance indicates someone - // sent tokens using transfer and so we may need to use recoverFunds. - uint96 private s_totalBalance; - event SubscriptionCreated(uint64 indexed subscriptionId, address owner); - event SubscriptionFunded(uint64 indexed subscriptionId, uint256 oldBalance, uint256 newBalance); - event SubscriptionConsumerAdded(uint64 indexed subscriptionId, address consumer); - event SubscriptionConsumerRemoved(uint64 indexed subscriptionId, address consumer); - event SubscriptionCanceled(uint64 indexed subscriptionId, address to, uint256 amount); - event SubscriptionOwnerTransferRequested(uint64 indexed subscriptionId, address from, address to); - event SubscriptionOwnerTransferred(uint64 indexed subscriptionId, address from, address to); - - error GasLimitTooBig(uint32 have, uint32 want); - error InvalidLinkWeiPrice(int256 linkWei); - error IncorrectRequestID(); - error PaymentTooLarge(); - error Reentrant(); - - mapping(address => uint96) /* oracle node */ /* LINK balance */ private s_withdrawableTokens; - struct Commitment { - uint64 subscriptionId; - address client; - uint32 gasLimit; - uint256 gasPrice; - address don; - uint96 donFee; - uint96 registryFee; - uint96 estimatedCost; - uint256 timestamp; - } - mapping(bytes32 => Commitment) /* requestID */ /* Commitment */ private s_requestCommitments; - event BillingStart(bytes32 indexed requestId, Commitment commitment); - struct ItemizedBill { - uint96 signerPayment; - uint96 transmitterPayment; - uint96 totalCost; - } - event BillingEnd( - bytes32 indexed requestId, - uint64 subscriptionId, - uint96 signerPayment, - uint96 transmitterPayment, - uint96 totalCost, - bool success - ); - event RequestTimedOut(bytes32 indexed requestId); - - struct Config { - // Maxiumum amount of gas that can be given to a request's client callback - uint32 maxGasLimit; - // Reentrancy protection. - bool reentrancyLock; - // stalenessSeconds is how long before we consider the feed price to be stale - // and fallback to fallbackWeiPerUnitLink. - uint32 stalenessSeconds; - // Gas to cover transmitter oracle payment after we calculate the payment. - // We make it configurable in case those operations are repriced. - uint256 gasAfterPaymentCalculation; - // Represents the average gas execution cost. Used in estimating cost beforehand. - uint32 gasOverhead; - // how many seconds it takes before we consider a request to be timed out - uint32 requestTimeoutSeconds; - } - int256 private s_fallbackWeiPerUnitLink; - Config private s_config; - event ConfigSet( - uint32 maxGasLimit, - uint32 stalenessSeconds, - uint256 gasAfterPaymentCalculation, - int256 fallbackWeiPerUnitLink, - uint32 gasOverhead - ); - - /** - * @dev Initializes the contract. - */ - function initialize(address link, address linkEthFeed, address oracle) public initializer { - __Pausable_init(); - __ConfirmedOwner_initialize(msg.sender, address(0)); - LINK = LinkTokenInterface(link); - LINK_ETH_FEED = AggregatorV3Interface(linkEthFeed); - ORACLE_WITH_ALLOWLIST = AuthorizedOriginReceiverInterface(oracle); - } - - /** - * @notice Sets the configuration of the Chainlink Functions billing registry - * @param maxGasLimit global max for request gas limit - * @param stalenessSeconds if the eth/link feed is more stale then this, use the fallback price - * @param gasAfterPaymentCalculation gas used in doing accounting after completing the gas measurement - * @param fallbackWeiPerUnitLink fallback eth/link price in the case of a stale feed - * @param gasOverhead average gas execution cost used in estimating total cost - * @param requestTimeoutSeconds e2e timeout after which user won't be charged - */ - function setConfig( - uint32 maxGasLimit, - uint32 stalenessSeconds, - uint256 gasAfterPaymentCalculation, - int256 fallbackWeiPerUnitLink, - uint32 gasOverhead, - uint32 requestTimeoutSeconds - ) external onlyOwner { - if (fallbackWeiPerUnitLink <= 0) { - revert InvalidLinkWeiPrice(fallbackWeiPerUnitLink); - } - s_config = Config({ - maxGasLimit: maxGasLimit, - stalenessSeconds: stalenessSeconds, - gasAfterPaymentCalculation: gasAfterPaymentCalculation, - reentrancyLock: false, - gasOverhead: gasOverhead, - requestTimeoutSeconds: requestTimeoutSeconds - }); - s_fallbackWeiPerUnitLink = fallbackWeiPerUnitLink; - emit ConfigSet(maxGasLimit, stalenessSeconds, gasAfterPaymentCalculation, fallbackWeiPerUnitLink, gasOverhead); - } - - /** - * @notice Gets the configuration of the Chainlink Functions billing registry - * @return maxGasLimit global max for request gas limit - * @return stalenessSeconds if the eth/link feed is more stale then this, use the fallback price - * @return gasAfterPaymentCalculation gas used in doing accounting after completing the gas measurement - * @return fallbackWeiPerUnitLink fallback eth/link price in the case of a stale feed - * @return gasOverhead average gas execution cost used in estimating total cost - */ - function getConfig() - external - view - returns ( - uint32 maxGasLimit, - uint32 stalenessSeconds, - uint256 gasAfterPaymentCalculation, - int256 fallbackWeiPerUnitLink, - uint32 gasOverhead - ) - { - return ( - s_config.maxGasLimit, - s_config.stalenessSeconds, - s_config.gasAfterPaymentCalculation, - s_fallbackWeiPerUnitLink, - s_config.gasOverhead - ); - } - - function pause() external onlyOwner { - _pause(); - } - - function unpause() external onlyOwner { - _unpause(); - } - - function getTotalBalance() external view returns (uint256) { - return s_totalBalance; - } - - /** - * @notice Owner cancel subscription, sends remaining link directly to the subscription owner. - * @param subscriptionId subscription id - * @dev notably can be called even if there are pending requests, outstanding ones may fail onchain - */ - function ownerCancelSubscription(uint64 subscriptionId) external onlyOwner { - address owner = s_subscriptionConfigs[subscriptionId].owner; - if (owner == address(0)) { - revert InvalidSubscription(); - } - cancelSubscriptionHelper(subscriptionId, owner); - } - - /** - * @notice Recover link sent with transfer instead of transferAndCall. - * @param to address to send link to - */ - function recoverFunds(address to) external onlyOwner { - uint256 externalBalance = LINK.balanceOf(address(this)); - uint256 internalBalance = uint256(s_totalBalance); - if (internalBalance > externalBalance) { - revert BalanceInvariantViolated(internalBalance, externalBalance); - } - if (internalBalance < externalBalance) { - uint256 amount = externalBalance - internalBalance; - LINK.transfer(to, amount); - emit FundsRecovered(to, amount); - } - // If the balances are equal, nothing to be done. - } - - /** - * @inheritdoc FunctionsBillingRegistryInterface - */ - function getRequestConfig() external view override returns (uint32, address[] memory) { - return (s_config.maxGasLimit, getAuthorizedSenders()); - } - - /** - * @inheritdoc FunctionsBillingRegistryInterface - */ - function getRequiredFee( - bytes calldata /* data */, - FunctionsBillingRegistryInterface.RequestBilling memory /* billing */ - ) public pure override returns (uint96) { - return 0; - } - - /** - * @inheritdoc FunctionsBillingRegistryInterface - */ - function estimateCost( - uint32 gasLimit, - uint256 gasPrice, - uint96 donFee, - uint96 registryFee - ) public view override returns (uint96) { - int256 weiPerUnitLink; - weiPerUnitLink = getFeedData(); - if (weiPerUnitLink <= 0) { - revert InvalidLinkWeiPrice(weiPerUnitLink); - } - uint256 executionGas = s_config.gasOverhead + s_config.gasAfterPaymentCalculation + gasLimit; - // (1e18 juels/link) (wei/gas * gas) / (wei/link) = juels - uint256 paymentNoFee = (1e18 * gasPrice * executionGas) / uint256(weiPerUnitLink); - uint256 fee = uint256(donFee) + uint256(registryFee); - if (paymentNoFee > (1e27 - fee)) { - revert PaymentTooLarge(); // Payment + fee cannot be more than all of the link in existence. - } - return uint96(paymentNoFee + fee); - } - - /** - * @inheritdoc FunctionsBillingRegistryInterface - */ - function startBilling( - bytes calldata data, - RequestBilling calldata billing - ) external override validateAuthorizedSender nonReentrant whenNotPaused returns (bytes32) { - // Input validation using the subscription storage. - if (s_subscriptionConfigs[billing.subscriptionId].owner == address(0)) { - revert InvalidSubscription(); - } - // It's important to ensure that the consumer is in fact who they say they - // are, otherwise they could use someone else's subscription balance. - // A nonce of 0 indicates consumer is not allocated to the sub. - uint64 currentNonce = s_consumers[billing.client][billing.subscriptionId]; - if (currentNonce == 0) { - revert InvalidConsumer(billing.subscriptionId, billing.client); - } - // No lower bound on the requested gas limit. A user could request 0 - // and they would simply be billed for the gas and computation. - if (billing.gasLimit > s_config.maxGasLimit) { - revert GasLimitTooBig(billing.gasLimit, s_config.maxGasLimit); - } - - // Check that subscription can afford the estimated cost - uint96 oracleFee = FunctionsOracleInterface(msg.sender).getRequiredFee(data, billing); - uint96 registryFee = getRequiredFee(data, billing); - uint96 estimatedCost = estimateCost(billing.gasLimit, billing.gasPrice, oracleFee, registryFee); - uint96 effectiveBalance = s_subscriptions[billing.subscriptionId].balance - - s_subscriptions[billing.subscriptionId].blockedBalance; - if (effectiveBalance < estimatedCost) { - revert InsufficientBalance(); - } - - uint64 nonce = currentNonce + 1; - bytes32 requestId = computeRequestId(msg.sender, billing.client, billing.subscriptionId, nonce); - - Commitment memory commitment = Commitment( - billing.subscriptionId, - billing.client, - billing.gasLimit, - billing.gasPrice, - msg.sender, - oracleFee, - registryFee, - estimatedCost, - block.timestamp - ); - s_requestCommitments[requestId] = commitment; - s_subscriptions[billing.subscriptionId].blockedBalance += estimatedCost; - - emit BillingStart(requestId, commitment); - s_consumers[billing.client][billing.subscriptionId] = nonce; - return requestId; - } - - function computeRequestId( - address don, - address client, - uint64 subscriptionId, - uint64 nonce - ) private pure returns (bytes32) { - return keccak256(abi.encode(don, client, subscriptionId, nonce)); - } - - /** - * @dev calls target address with exactly gasAmount gas and data as calldata - * or reverts if at least gasAmount gas is not available. - */ - function callWithExactGas(uint256 gasAmount, address target, bytes memory data) private returns (bool success) { - assembly { - let g := gas() - // GAS_FOR_CALL_EXACT_CHECK = 5000 - // Compute g -= GAS_FOR_CALL_EXACT_CHECK and check for underflow - // The gas actually passed to the callee is min(gasAmount, 63//64*gas available). - // We want to ensure that we revert if gasAmount > 63//64*gas available - // as we do not want to provide them with less, however that check itself costs - // gas. GAS_FOR_CALL_EXACT_CHECK ensures we have at least enough gas to be able - // to revert if gasAmount > 63//64*gas available. - if lt(g, 5000) { - revert(0, 0) - } - g := sub(g, 5000) - // if g - g//64 <= gasAmount, revert - // (we subtract g//64 because of EIP-150) - if iszero(gt(sub(g, div(g, 64)), gasAmount)) { - revert(0, 0) - } - // solidity calls check that a contract actually exists at the destination, so we do the same - if iszero(extcodesize(target)) { - revert(0, 0) - } - // call and return whether we succeeded. ignore return data - // call(gas,addr,value,argsOffset,argsLength,retOffset,retLength) - success := call(gasAmount, target, 0, add(data, 0x20), mload(data), 0, 0) - } - return success; - } - - /** - * @inheritdoc FunctionsBillingRegistryInterface - */ - function fulfillAndBill( - bytes32 requestId, - bytes calldata response, - bytes calldata err, - address transmitter, - address[31] memory signers, - uint8 signerCount, - uint256 reportValidationGas, - uint256 initialGas - ) external override validateAuthorizedSender nonReentrant whenNotPaused returns (bool success) { - Commitment memory commitment = s_requestCommitments[requestId]; - if (commitment.don == address(0)) { - revert IncorrectRequestID(); - } - delete s_requestCommitments[requestId]; - - bytes memory callback = abi.encodeWithSelector( - FunctionsClientInterface.handleOracleFulfillment.selector, - requestId, - response, - err - ); - // Call with explicitly the amount of callback gas requested - // Important to not let them exhaust the gas budget and avoid payment. - // Do not allow any non-view/non-pure coordinator functions to be called - // during the consumers callback code via reentrancyLock. - // NOTE: that callWithExactGas will revert if we do not have sufficient gas - // to give the callee their requested amount. - s_config.reentrancyLock = true; - success = callWithExactGas(commitment.gasLimit, commitment.client, callback); - s_config.reentrancyLock = false; - - // We want to charge users exactly for how much gas they use in their callback. - // The gasAfterPaymentCalculation is meant to cover these additional operations where we - // decrement the subscription balance and increment the oracle's withdrawable balance. - ItemizedBill memory bill = calculatePaymentAmount( - initialGas, - s_config.gasAfterPaymentCalculation, - commitment.donFee, - signerCount, - commitment.registryFee, - reportValidationGas, - tx.gasprice - ); - if (s_subscriptions[commitment.subscriptionId].balance < bill.totalCost) { - revert InsufficientBalance(); - } - s_subscriptions[commitment.subscriptionId].balance -= bill.totalCost; - // Pay out signers their portion of the DON fee - for (uint256 i = 0; i < signerCount; i++) { - if (signers[i] != transmitter) { - s_withdrawableTokens[signers[i]] += bill.signerPayment; - } - } - // Pay out the registry fee - s_withdrawableTokens[owner()] += commitment.registryFee; - // Reimburse the transmitter for the execution gas cost + pay them their portion of the DON fee - s_withdrawableTokens[transmitter] += bill.transmitterPayment; - // Remove blocked balance - s_subscriptions[commitment.subscriptionId].blockedBalance -= commitment.estimatedCost; - // Include payment in the event for tracking costs. - emit BillingEnd( - requestId, - commitment.subscriptionId, - bill.signerPayment, - bill.transmitterPayment, - bill.totalCost, - success - ); - } - - // Determine the cost breakdown for payment - function calculatePaymentAmount( - uint256 startGas, - uint256 gasAfterPaymentCalculation, - uint96 donFee, - uint8 signerCount, - uint96 registryFee, - uint256 reportValidationGas, - uint256 weiPerUnitGas - ) private view returns (ItemizedBill memory) { - int256 weiPerUnitLink; - weiPerUnitLink = getFeedData(); - if (weiPerUnitLink <= 0) { - revert InvalidLinkWeiPrice(weiPerUnitLink); - } - // (1e18 juels/link) (wei/gas * gas) / (wei/link) = juels - uint256 paymentNoFee = (1e18 * - weiPerUnitGas * - (reportValidationGas + gasAfterPaymentCalculation + startGas - gasleft())) / uint256(weiPerUnitLink); - uint256 fee = uint256(donFee) + uint256(registryFee); - if (paymentNoFee > (1e27 - fee)) { - revert PaymentTooLarge(); // Payment + fee cannot be more than all of the link in existence. - } - uint96 signerPayment = donFee / uint96(signerCount); - uint96 transmitterPayment = uint96(paymentNoFee) + signerPayment; - uint96 totalCost = SafeCast.toUint96(paymentNoFee + fee); - return ItemizedBill(signerPayment, transmitterPayment, totalCost); - } - - function getFeedData() private view returns (int256) { - uint32 stalenessSeconds = s_config.stalenessSeconds; - bool staleFallback = stalenessSeconds > 0; - (, int256 weiPerUnitLink, , uint256 timestamp, ) = LINK_ETH_FEED.latestRoundData(); - // solhint-disable-next-line not-rely-on-time - if (staleFallback && stalenessSeconds < block.timestamp - timestamp) { - weiPerUnitLink = s_fallbackWeiPerUnitLink; - } - return weiPerUnitLink; - } - - /* - * @notice Oracle withdraw LINK earned through fulfilling requests - * @notice If amount is 0 the full balance will be withdrawn - * @param recipient where to send the funds - * @param amount amount to withdraw - */ - function oracleWithdraw(address recipient, uint96 amount) external nonReentrant whenNotPaused { - if (amount == 0) { - amount = s_withdrawableTokens[msg.sender]; - } - if (s_withdrawableTokens[msg.sender] < amount) { - revert InsufficientBalance(); - } - s_withdrawableTokens[msg.sender] -= amount; - s_totalBalance -= amount; - if (!LINK.transfer(recipient, amount)) { - revert InsufficientBalance(); - } - } - - function onTokenTransfer( - address /* sender */, - uint256 amount, - bytes calldata data - ) external override nonReentrant whenNotPaused { - if (msg.sender != address(LINK)) { - revert OnlyCallableFromLink(); - } - if (data.length != 32) { - revert InvalidCalldata(); - } - uint64 subscriptionId = abi.decode(data, (uint64)); - if (s_subscriptionConfigs[subscriptionId].owner == address(0)) { - revert InvalidSubscription(); - } - // We do not check that the msg.sender is the subscription owner, - // anyone can fund a subscription. - uint256 oldBalance = s_subscriptions[subscriptionId].balance; - s_subscriptions[subscriptionId].balance += uint96(amount); - s_totalBalance += uint96(amount); - emit SubscriptionFunded(subscriptionId, oldBalance, oldBalance + amount); - } - - function getCurrentsubscriptionId() external view returns (uint64) { - return s_currentsubscriptionId; - } - - /** - * @notice Get details about a subscription. - * @param subscriptionId - ID of the subscription - * @return balance - LINK balance of the subscription in juels. - * @return owner - owner of the subscription. - * @return consumers - list of consumer address which are able to use this subscription. - */ - function getSubscription( - uint64 subscriptionId - ) external view returns (uint96 balance, address owner, address[] memory consumers) { - if (s_subscriptionConfigs[subscriptionId].owner == address(0)) { - revert InvalidSubscription(); - } - return ( - s_subscriptions[subscriptionId].balance, - s_subscriptionConfigs[subscriptionId].owner, - s_subscriptionConfigs[subscriptionId].consumers - ); - } - - /** - * @notice Create a new subscription. - * @return subscriptionId - A unique subscription id. - * @dev You can manage the consumer set dynamically with addConsumer/removeConsumer. - * @dev Note to fund the subscription, use transferAndCall. For example - * @dev LINKTOKEN.transferAndCall( - * @dev address(REGISTRY), - * @dev amount, - * @dev abi.encode(subscriptionId)); - */ - function createSubscription() external nonReentrant whenNotPaused onlyAuthorizedUsers returns (uint64) { - s_currentsubscriptionId++; - uint64 currentsubscriptionId = s_currentsubscriptionId; - address[] memory consumers = new address[](0); - s_subscriptions[currentsubscriptionId] = Subscription({balance: 0, blockedBalance: 0}); - s_subscriptionConfigs[currentsubscriptionId] = SubscriptionConfig({ - owner: msg.sender, - requestedOwner: address(0), - consumers: consumers - }); - - emit SubscriptionCreated(currentsubscriptionId, msg.sender); - return currentsubscriptionId; - } - - /** - * @notice Gets subscription owner. - * @param subscriptionId - ID of the subscription - * @return owner - owner of the subscription. - */ - function getSubscriptionOwner(uint64 subscriptionId) external view override returns (address owner) { - if (s_subscriptionConfigs[subscriptionId].owner == address(0)) { - revert InvalidSubscription(); - } - return s_subscriptionConfigs[subscriptionId].owner; - } - - /** - * @notice Request subscription owner transfer. - * @param subscriptionId - ID of the subscription - * @param newOwner - proposed new owner of the subscription - */ - function requestSubscriptionOwnerTransfer( - uint64 subscriptionId, - address newOwner - ) external onlySubOwner(subscriptionId) nonReentrant whenNotPaused { - // Proposing to address(0) would never be claimable so don't need to check. - if (s_subscriptionConfigs[subscriptionId].requestedOwner != newOwner) { - s_subscriptionConfigs[subscriptionId].requestedOwner = newOwner; - emit SubscriptionOwnerTransferRequested(subscriptionId, msg.sender, newOwner); - } - } - - /** - * @notice Request subscription owner transfer. - * @param subscriptionId - ID of the subscription - * @dev will revert if original owner of subscriptionId has - * not requested that msg.sender become the new owner. - */ - function acceptSubscriptionOwnerTransfer( - uint64 subscriptionId - ) external nonReentrant whenNotPaused onlyAuthorizedUsers { - if (s_subscriptionConfigs[subscriptionId].owner == address(0)) { - revert InvalidSubscription(); - } - if (s_subscriptionConfigs[subscriptionId].requestedOwner != msg.sender) { - revert MustBeRequestedOwner(s_subscriptionConfigs[subscriptionId].requestedOwner); - } - address oldOwner = s_subscriptionConfigs[subscriptionId].owner; - s_subscriptionConfigs[subscriptionId].owner = msg.sender; - s_subscriptionConfigs[subscriptionId].requestedOwner = address(0); - emit SubscriptionOwnerTransferred(subscriptionId, oldOwner, msg.sender); - } - - /** - * @notice Remove a consumer from a Chainlink Functions subscription. - * @param subscriptionId - ID of the subscription - * @param consumer - Consumer to remove from the subscription - */ - function removeConsumer( - uint64 subscriptionId, - address consumer - ) external onlySubOwner(subscriptionId) nonReentrant whenNotPaused { - if (s_consumers[consumer][subscriptionId] == 0) { - revert InvalidConsumer(subscriptionId, consumer); - } - // Note bounded by MAX_CONSUMERS - address[] memory consumers = s_subscriptionConfigs[subscriptionId].consumers; - uint256 lastConsumerIndex = consumers.length - 1; - for (uint256 i = 0; i < consumers.length; i++) { - if (consumers[i] == consumer) { - address last = consumers[lastConsumerIndex]; - // Storage write to preserve last element - s_subscriptionConfigs[subscriptionId].consumers[i] = last; - // Storage remove last element - s_subscriptionConfigs[subscriptionId].consumers.pop(); - break; - } - } - delete s_consumers[consumer][subscriptionId]; - emit SubscriptionConsumerRemoved(subscriptionId, consumer); - } - - /** - * @notice Add a consumer to a Chainlink Functions subscription. - * @param subscriptionId - ID of the subscription - * @param consumer - New consumer which can use the subscription - */ - function addConsumer( - uint64 subscriptionId, - address consumer - ) external onlySubOwner(subscriptionId) nonReentrant whenNotPaused { - // Already maxed, cannot add any more consumers. - if (s_subscriptionConfigs[subscriptionId].consumers.length == MAX_CONSUMERS) { - revert TooManyConsumers(); - } - if (s_consumers[consumer][subscriptionId] != 0) { - // Idempotence - do nothing if already added. - // Ensures uniqueness in s_subscriptions[subscriptionId].consumers. - return; - } - // Initialize the nonce to 1, indicating the consumer is allocated. - s_consumers[consumer][subscriptionId] = 1; - s_subscriptionConfigs[subscriptionId].consumers.push(consumer); - - emit SubscriptionConsumerAdded(subscriptionId, consumer); - } - - /** - * @notice Cancel a subscription - * @param subscriptionId - ID of the subscription - * @param to - Where to send the remaining LINK to - */ - function cancelSubscription( - uint64 subscriptionId, - address to - ) external onlySubOwner(subscriptionId) nonReentrant whenNotPaused { - if (pendingRequestExists(subscriptionId)) { - revert PendingRequestExists(); - } - cancelSubscriptionHelper(subscriptionId, to); - } - - function cancelSubscriptionHelper(uint64 subscriptionId, address to) private nonReentrant { - SubscriptionConfig memory subConfig = s_subscriptionConfigs[subscriptionId]; - uint96 balance = s_subscriptions[subscriptionId].balance; - // Note bounded by MAX_CONSUMERS; - // If no consumers, does nothing. - for (uint256 i = 0; i < subConfig.consumers.length; i++) { - delete s_consumers[subConfig.consumers[i]][subscriptionId]; - } - delete s_subscriptionConfigs[subscriptionId]; - delete s_subscriptions[subscriptionId]; - s_totalBalance -= balance; - if (!LINK.transfer(to, uint256(balance))) { - revert InsufficientBalance(); - } - emit SubscriptionCanceled(subscriptionId, to, balance); - } - - /** - * @notice Check to see if there exists a request commitment for all consumers for a given sub. - * @param subscriptionId - ID of the subscription - * @return true if there exists at least one unfulfilled request for the subscription, false - * otherwise. - * @dev Looping is bounded to MAX_CONSUMERS*(number of DONs). - * @dev Used to disable subscription canceling while outstanding request are present. - */ - - function pendingRequestExists(uint64 subscriptionId) public view returns (bool) { - address[] memory consumers = s_subscriptionConfigs[subscriptionId].consumers; - address[] memory authorizedSendersList = getAuthorizedSenders(); - for (uint256 i = 0; i < consumers.length; i++) { - for (uint256 j = 0; j < authorizedSendersList.length; j++) { - bytes32 requestId = computeRequestId( - authorizedSendersList[j], - consumers[i], - subscriptionId, - s_consumers[consumers[i]][subscriptionId] - ); - if (s_requestCommitments[requestId].don != address(0)) { - return true; - } - } - } - return false; - } - - /** - * @notice Time out all expired requests: unlocks funds and removes the ability for the request to be fulfilled - * @param requestIdsToTimeout - A list of request IDs to time out - */ - - function timeoutRequests(bytes32[] calldata requestIdsToTimeout) external whenNotPaused { - for (uint256 i = 0; i < requestIdsToTimeout.length; i++) { - bytes32 requestId = requestIdsToTimeout[i]; - Commitment memory commitment = s_requestCommitments[requestId]; - - // Check that the message sender is the subscription owner - if (msg.sender != s_subscriptionConfigs[commitment.subscriptionId].owner) { - revert MustBeSubOwner(s_subscriptionConfigs[commitment.subscriptionId].owner); - } - - if (commitment.timestamp + s_config.requestTimeoutSeconds > block.timestamp) { - // Decrement blocked balance - s_subscriptions[commitment.subscriptionId].blockedBalance -= commitment.estimatedCost; - // Delete commitment - delete s_requestCommitments[requestId]; - emit RequestTimedOut(requestId); - } - } - } - - /** - * @dev The allow list is kept on the Oracle contract. This modifier checks if a user is authorized from there. - */ - modifier onlyAuthorizedUsers() { - if (ORACLE_WITH_ALLOWLIST.authorizedReceiverActive() && !ORACLE_WITH_ALLOWLIST.isAuthorizedSender(msg.sender)) { - revert UnauthorizedSender(); - } - _; - } - - modifier onlySubOwner(uint64 subscriptionId) { - address owner = s_subscriptionConfigs[subscriptionId].owner; - if (owner == address(0)) { - revert InvalidSubscription(); - } - if (msg.sender != owner) { - revert MustBeSubOwner(owner); - } - _; - } - - modifier nonReentrant() { - if (s_config.reentrancyLock) { - revert Reentrant(); - } - _; - } - - function _canSetAuthorizedSenders() internal view override onlyOwner returns (bool) { - return true; - } - - /** - * @dev This empty reserved space is put in place to allow future versions to add new - * variables without shifting down storage in the inheritance chain. - * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps - */ - uint256[49] private __gap; -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsClientInterface.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsClientInterface.sol deleted file mode 100644 index b047a673135..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsClientInterface.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -/** - * @title Chainlink Functions client interface. - */ -interface FunctionsClientInterface { - /** - * @notice Returns the DON's secp256k1 public key used to encrypt secrets - * @dev All Oracles nodes have the corresponding private key - * needed to decrypt the secrets encrypted with the public key - * @return publicKey DON's public key - */ - function getDONPublicKey() external view returns (bytes memory); - - /** - * @notice Chainlink Functions response handler called by the designated transmitter node in an OCR round. - * @param requestId The requestId returned by FunctionsClient.sendRequest(). - * @param response Aggregated response from the user code. - * @param err Aggregated error either from the user code or from the execution pipeline. - * Either response or error parameter will be set, but never both. - */ - function handleOracleFulfillment(bytes32 requestId, bytes memory response, bytes memory err) external; -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsOracleInterface.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsOracleInterface.sol deleted file mode 100644 index 2076dcc0c37..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsOracleInterface.sol +++ /dev/null @@ -1,93 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import "./FunctionsBillingRegistryInterface.sol"; - -/** - * @title Chainlink Functions oracle interface. - */ -interface FunctionsOracleInterface { - /** - * @notice Gets the stored billing registry address - * @return registryAddress The address of Chainlink Functions billing registry contract - */ - function getRegistry() external view returns (address); - - /** - * @notice Sets the stored billing registry address - * @param registryAddress The new address of Chainlink Functions billing registry contract - */ - function setRegistry(address registryAddress) external; - - /** - * @notice Returns the DON's secp256k1 public key that is used to encrypt secrets - * @dev All nodes on the DON have the corresponding private key - * needed to decrypt the secrets encrypted with the public key - * @return publicKey the DON's public key - */ - function getDONPublicKey() external view returns (bytes memory); - - /** - * @notice Sets DON's secp256k1 public key used to encrypt secrets - * @dev Used to rotate the key - * @param donPublicKey The new public key - */ - function setDONPublicKey(bytes calldata donPublicKey) external; - - /** - * @notice Sets a per-node secp256k1 public key used to encrypt secrets for that node - * @dev Callable only by contract owner and DON members - * @param node node's address - * @param publicKey node's public key - */ - function setNodePublicKey(address node, bytes calldata publicKey) external; - - /** - * @notice Deletes node's public key - * @dev Callable only by contract owner or the node itself - * @param node node's address - */ - function deleteNodePublicKey(address node) external; - - /** - * @notice Return two arrays of equal size containing DON members' addresses and their corresponding - * public keys (or empty byte arrays if per-node key is not defined) - */ - function getAllNodePublicKeys() external view returns (address[] memory, bytes[] memory); - - /** - * @notice Determine the fee charged by the DON that will be split between signing Node Operators for servicing the request - * @param data Encoded Chainlink Functions request data, use FunctionsClient API to encode a request - * @param billing The request's billing configuration - * @return fee Cost in Juels (1e18) of LINK - */ - function getRequiredFee( - bytes calldata data, - FunctionsBillingRegistryInterface.RequestBilling calldata billing - ) external view returns (uint96); - - /** - * @notice Estimate the total cost that will be charged to a subscription to make a request: gas re-imbursement, plus DON fee, plus Registry fee - * @param subscriptionId A unique subscription ID allocated by billing system, - * a client can make requests from different contracts referencing the same subscription - * @param data Encoded Chainlink Functions request data, use FunctionsClient API to encode a request - * @param gasLimit Gas limit for the fulfillment callback - * @return billedCost Cost in Juels (1e18) of LINK - */ - function estimateCost( - uint64 subscriptionId, - bytes calldata data, - uint32 gasLimit, - uint256 gasPrice - ) external view returns (uint96); - - /** - * @notice Sends a request (encoded as data) using the provided subscriptionId - * @param subscriptionId A unique subscription ID allocated by billing system, - * a client can make requests from different contracts referencing the same subscription - * @param data Encoded Chainlink Functions request data, use FunctionsClient API to encode a request - * @param gasLimit Gas limit for the fulfillment callback - * @return requestId A unique request identifier (unique per DON) - */ - function sendRequest(uint64 subscriptionId, bytes calldata data, uint32 gasLimit) external returns (bytes32); -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsOracleMigration.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsOracleMigration.sol deleted file mode 100644 index f22c25cc1a3..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsOracleMigration.sol +++ /dev/null @@ -1,273 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {FunctionsOracleInterface} from "./FunctionsOracleInterface.sol"; -import {FunctionsBillingRegistryInterface} from "./FunctionsBillingRegistryInterface.sol"; -import {OCR2BaseUpgradeable} from "./OCR2BaseUpgradeable.sol"; -import {AuthorizedOriginReceiverUpgradeable} from "./AuthorizedOriginReceiverUpgradeable.sol"; -import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; - -/** - * @title Functions Oracle contract - * @notice Contract that nodes of a Decentralized Oracle Network (DON) interact with - * @dev THIS CONTRACT HAS NOT GONE THROUGH ANY SECURITY REVIEW. DO NOT USE IN PROD. - */ -contract FunctionsOracleMigration is - Initializable, - FunctionsOracleInterface, - OCR2BaseUpgradeable, - AuthorizedOriginReceiverUpgradeable -{ - event OracleRequest( - bytes32 indexed requestId, - address requestingContract, - address requestInitiator, - uint64 subscriptionId, - address subscriptionOwner, - bytes data - ); - event OracleResponse(bytes32 indexed requestId); - event UserCallbackError(bytes32 indexed requestId, string reason); - event UserCallbackRawError(bytes32 indexed requestId, bytes lowLevelData); - - error EmptyRequestData(); - error InconsistentReportData(); - error EmptyPublicKey(); - error EmptyBillingRegistry(); - error InvalidRequestID(); - error UnauthorizedPublicKeyChange(); - - bytes private s_donPublicKey; - FunctionsBillingRegistryInterface private s_registry; - mapping(address => bytes) private s_nodePublicKeys; - - /** - * @dev Initializes the contract. - */ - function initialize() public initializer { - __OCR2Base_initialize(true); - __AuthorizedOriginReceiver_initialize(true); - } - - /** - * @notice The type and version of this contract - * @return Type and version string - */ - function typeAndVersion() external pure override returns (string memory) { - return "FunctionsOracle ?.?.?"; - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function getRegistry() external view override returns (address) { - return address(s_registry); - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function setRegistry(address registryAddress) external override onlyOwner { - if (registryAddress == address(0)) { - revert EmptyBillingRegistry(); - } - s_registry = FunctionsBillingRegistryInterface(registryAddress); - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function getDONPublicKey() external view override returns (bytes memory) { - return s_donPublicKey; - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function setDONPublicKey(bytes calldata donPublicKey) external override onlyOwner { - if (donPublicKey.length == 0) { - revert EmptyPublicKey(); - } - s_donPublicKey = donPublicKey; - } - - /** - * @dev check if node is in current transmitter list - */ - function _isTransmitter(address node) internal view returns (bool) { - address[] memory nodes = this.transmitters(); - for (uint256 i = 0; i < nodes.length; i++) { - if (nodes[i] == node) { - return true; - } - } - return false; - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function setNodePublicKey(address node, bytes calldata publicKey) external override { - // Owner can set anything. Transmitters can set only their own key. - if (!(msg.sender == owner() || (_isTransmitter(msg.sender) && msg.sender == node))) { - revert UnauthorizedPublicKeyChange(); - } - s_nodePublicKeys[node] = publicKey; - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function deleteNodePublicKey(address node) external override { - // Owner can delete anything. Others can delete only their own key. - if (!(msg.sender == owner() || msg.sender == node)) { - revert UnauthorizedPublicKeyChange(); - } - delete s_nodePublicKeys[node]; - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function getAllNodePublicKeys() external view override returns (address[] memory, bytes[] memory) { - address[] memory nodes = this.transmitters(); - bytes[] memory keys = new bytes[](nodes.length); - for (uint256 i = 0; i < nodes.length; i++) { - keys[i] = s_nodePublicKeys[nodes[i]]; - } - return (nodes, keys); - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function getRequiredFee( - bytes calldata /* data */, - FunctionsBillingRegistryInterface.RequestBilling memory /* billing */ - ) public pure override returns (uint96) { - // NOTE: Optionally, compute additional fee split between nodes of the DON here - // e.g. 0.1 LINK * s_transmitters.length - return 1; - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function estimateCost( - uint64 subscriptionId, - bytes calldata data, - uint32 gasLimit, - uint256 gasPrice - ) external view override registryIsSet returns (uint96) { - FunctionsBillingRegistryInterface.RequestBilling memory billing = FunctionsBillingRegistryInterface.RequestBilling( - subscriptionId, - msg.sender, - gasLimit, - gasPrice - ); - uint96 requiredFee = getRequiredFee(data, billing); - uint96 registryFee = getRequiredFee(data, billing); - return s_registry.estimateCost(gasLimit, gasPrice, requiredFee, registryFee); - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function sendRequest( - uint64 subscriptionId, - bytes calldata data, - uint32 gasLimit - ) external override registryIsSet validateAuthorizedSender returns (bytes32) { - if (data.length == 0) { - revert EmptyRequestData(); - } - bytes32 requestId = s_registry.startBilling( - data, - FunctionsBillingRegistryInterface.RequestBilling(subscriptionId, msg.sender, gasLimit, tx.gasprice) - ); - emit OracleRequest( - requestId, - msg.sender, - tx.origin, - subscriptionId, - s_registry.getSubscriptionOwner(subscriptionId), - data - ); - return requestId; - } - - function _beforeSetConfig(uint8 _f, bytes memory _onchainConfig) internal override {} - - function _afterSetConfig(uint8 _f, bytes memory _onchainConfig) internal override {} - - function _validateReport( - bytes32 /* configDigest */, - uint40 /* epochAndRound */, - bytes memory /* report */ - ) internal pure override returns (bool) { - // validate within _report to save gas - return true; - } - - function _report( - uint256 initialGas, - address transmitter, - uint8 signerCount, - address[maxNumOracles] memory signers, - bytes calldata report - ) internal override registryIsSet { - bytes32[] memory requestIds; - bytes[] memory results; - bytes[] memory errors; - (requestIds, results, errors) = abi.decode(report, (bytes32[], bytes[], bytes[])); - if (requestIds.length == 0 || requestIds.length != results.length || requestIds.length != errors.length) { - revert ReportInvalid(); - } - - uint256 reportValidationGasShare = (initialGas - gasleft()) / requestIds.length; - - for (uint256 i = 0; i < requestIds.length; i++) { - try - s_registry.fulfillAndBill( - requestIds[i], - results[i], - errors[i], - transmitter, - signers, - signerCount, - reportValidationGasShare, - gasleft() - ) - returns (bool success) { - if (success) { - emit OracleResponse(requestIds[i]); - } else { - emit UserCallbackError(requestIds[i], "error in callback"); - } - } catch (bytes memory reason) { - emit UserCallbackRawError(requestIds[i], reason); - } - } - } - - /** - * @dev Reverts if the the billing registry is not set - */ - modifier registryIsSet() { - if (address(s_registry) == address(0)) { - revert EmptyBillingRegistry(); - } - _; - } - - function _canSetAuthorizedSenders() internal view override returns (bool) { - return msg.sender == owner(); - } - - /** - * @dev This empty reserved space is put in place to allow future versions to add new - * variables without shifting down storage in the inheritance chain. - * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps - */ - uint256[49] private __gap; -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsOracleOriginal.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsOracleOriginal.sol deleted file mode 100644 index f6264a7d629..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsOracleOriginal.sol +++ /dev/null @@ -1,273 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; - -import {FunctionsOracleInterface} from "./FunctionsOracleInterface.sol"; -import {FunctionsBillingRegistryInterface} from "./FunctionsBillingRegistryInterface.sol"; -import {OCR2BaseUpgradeable} from "./OCR2BaseUpgradeable.sol"; -import {AuthorizedOriginReceiverUpgradeable} from "./AuthorizedOriginReceiverUpgradeable.sol"; -import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; - -/** - * @title Functions Oracle contract - * @notice Contract that nodes of a Decentralized Oracle Network (DON) interact with - * @dev THIS CONTRACT HAS NOT GONE THROUGH ANY SECURITY REVIEW. DO NOT USE IN PROD. - */ -contract FunctionsOracleOriginal is - Initializable, - FunctionsOracleInterface, - OCR2BaseUpgradeable, - AuthorizedOriginReceiverUpgradeable -{ - event OracleRequest( - bytes32 indexed requestId, - address requestingContract, - address requestInitiator, - uint64 subscriptionId, - address subscriptionOwner, - bytes data - ); - event OracleResponse(bytes32 indexed requestId); - event UserCallbackError(bytes32 indexed requestId, string reason); - event UserCallbackRawError(bytes32 indexed requestId, bytes lowLevelData); - - error EmptyRequestData(); - error InconsistentReportData(); - error EmptyPublicKey(); - error EmptyBillingRegistry(); - error InvalidRequestID(); - error UnauthorizedPublicKeyChange(); - - bytes private s_donPublicKey; - FunctionsBillingRegistryInterface private s_registry; - mapping(address => bytes) private s_nodePublicKeys; - - /** - * @dev Initializes the contract. - */ - function initialize() public initializer { - __OCR2Base_initialize(true); - __AuthorizedOriginReceiver_initialize(true); - } - - /** - * @notice The type and version of this contract - * @return Type and version string - */ - function typeAndVersion() external pure override returns (string memory) { - return "FunctionsOracle ?.?.?"; - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function getRegistry() external view override returns (address) { - return address(s_registry); - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function setRegistry(address registryAddress) external override onlyOwner { - if (registryAddress == address(0)) { - revert EmptyBillingRegistry(); - } - s_registry = FunctionsBillingRegistryInterface(registryAddress); - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function getDONPublicKey() external view override returns (bytes memory) { - return s_donPublicKey; - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function setDONPublicKey(bytes calldata donPublicKey) external override onlyOwner { - if (donPublicKey.length == 0) { - revert EmptyPublicKey(); - } - s_donPublicKey = donPublicKey; - } - - /** - * @dev check if node is in current transmitter list - */ - function _isTransmitter(address node) internal view returns (bool) { - address[] memory nodes = this.transmitters(); - for (uint256 i = 0; i < nodes.length; i++) { - if (nodes[i] == node) { - return true; - } - } - return false; - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function setNodePublicKey(address node, bytes calldata publicKey) external override { - // Owner can set anything. Transmitters can set only their own key. - if (!(msg.sender == owner() || (_isTransmitter(msg.sender) && msg.sender == node))) { - revert UnauthorizedPublicKeyChange(); - } - s_nodePublicKeys[node] = publicKey; - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function deleteNodePublicKey(address node) external override { - // Owner can delete anything. Others can delete only their own key. - if (!(msg.sender == owner() || msg.sender == node)) { - revert UnauthorizedPublicKeyChange(); - } - delete s_nodePublicKeys[node]; - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function getAllNodePublicKeys() external view override returns (address[] memory, bytes[] memory) { - address[] memory nodes = this.transmitters(); - bytes[] memory keys = new bytes[](nodes.length); - for (uint256 i = 0; i < nodes.length; i++) { - keys[i] = s_nodePublicKeys[nodes[i]]; - } - return (nodes, keys); - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function getRequiredFee( - bytes calldata /* data */, - FunctionsBillingRegistryInterface.RequestBilling memory /* billing */ - ) public pure override returns (uint96) { - // NOTE: Optionally, compute additional fee split between nodes of the DON here - // e.g. 0.1 LINK * s_transmitters.length - return 0; - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function estimateCost( - uint64 subscriptionId, - bytes calldata data, - uint32 gasLimit, - uint256 gasPrice - ) external view override registryIsSet returns (uint96) { - FunctionsBillingRegistryInterface.RequestBilling memory billing = FunctionsBillingRegistryInterface.RequestBilling( - subscriptionId, - msg.sender, - gasLimit, - gasPrice - ); - uint96 requiredFee = getRequiredFee(data, billing); - uint96 registryFee = getRequiredFee(data, billing); - return s_registry.estimateCost(gasLimit, gasPrice, requiredFee, registryFee); - } - - /** - * @inheritdoc FunctionsOracleInterface - */ - function sendRequest( - uint64 subscriptionId, - bytes calldata data, - uint32 gasLimit - ) external override registryIsSet validateAuthorizedSender returns (bytes32) { - if (data.length == 0) { - revert EmptyRequestData(); - } - bytes32 requestId = s_registry.startBilling( - data, - FunctionsBillingRegistryInterface.RequestBilling(subscriptionId, msg.sender, gasLimit, tx.gasprice) - ); - emit OracleRequest( - requestId, - msg.sender, - tx.origin, - subscriptionId, - s_registry.getSubscriptionOwner(subscriptionId), - data - ); - return requestId; - } - - function _beforeSetConfig(uint8 _f, bytes memory _onchainConfig) internal override {} - - function _afterSetConfig(uint8 _f, bytes memory _onchainConfig) internal override {} - - function _validateReport( - bytes32 /* configDigest */, - uint40 /* epochAndRound */, - bytes memory /* report */ - ) internal pure override returns (bool) { - // validate within _report to save gas - return true; - } - - function _report( - uint256 initialGas, - address transmitter, - uint8 signerCount, - address[maxNumOracles] memory signers, - bytes calldata report - ) internal override registryIsSet { - bytes32[] memory requestIds; - bytes[] memory results; - bytes[] memory errors; - (requestIds, results, errors) = abi.decode(report, (bytes32[], bytes[], bytes[])); - if (requestIds.length == 0 || requestIds.length != results.length || requestIds.length != errors.length) { - revert ReportInvalid(); - } - - uint256 reportValidationGasShare = (initialGas - gasleft()) / requestIds.length; - - for (uint256 i = 0; i < requestIds.length; i++) { - try - s_registry.fulfillAndBill( - requestIds[i], - results[i], - errors[i], - transmitter, - signers, - signerCount, - reportValidationGasShare, - gasleft() - ) - returns (bool success) { - if (success) { - emit OracleResponse(requestIds[i]); - } else { - emit UserCallbackError(requestIds[i], "error in callback"); - } - } catch (bytes memory reason) { - emit UserCallbackRawError(requestIds[i], reason); - } - } - } - - /** - * @dev Reverts if the the billing registry is not set - */ - modifier registryIsSet() { - if (address(s_registry) == address(0)) { - revert EmptyBillingRegistry(); - } - _; - } - - function _canSetAuthorizedSenders() internal view override returns (bool) { - return msg.sender == owner(); - } - - /** - * @dev This empty reserved space is put in place to allow future versions to add new - * variables without shifting down storage in the inheritance chain. - * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps - */ - uint256[49] private __gap; -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/OCR2Abstract.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/OCR2Abstract.sol deleted file mode 100644 index 02e204585ac..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/OCR2Abstract.sol +++ /dev/null @@ -1,134 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {TypeAndVersionInterface} from "../../../../../interfaces/TypeAndVersionInterface.sol"; - -abstract contract OCR2Abstract is TypeAndVersionInterface { - // Maximum number of oracles the offchain reporting protocol is designed for - uint256 internal constant maxNumOracles = 31; - - /** - * @notice triggers a new run of the offchain reporting protocol - * @param previousConfigBlockNumber block in which the previous config was set, to simplify historic analysis - * @param configDigest configDigest of this configuration - * @param configCount ordinal number of this config setting among all config settings over the life of this contract - * @param signers ith element is address ith oracle uses to sign a report - * @param transmitters ith element is address ith oracle uses to transmit a report via the transmit method - * @param f maximum number of faulty/dishonest oracles the protocol can tolerate while still working correctly - * @param onchainConfig serialized configuration used by the contract (and possibly oracles) - * @param offchainConfigVersion version of the serialization format used for "offchainConfig" parameter - * @param offchainConfig serialized configuration used by the oracles exclusively and only passed through the contract - */ - event ConfigSet( - uint32 previousConfigBlockNumber, - bytes32 configDigest, - uint64 configCount, - address[] signers, - address[] transmitters, - uint8 f, - bytes onchainConfig, - uint64 offchainConfigVersion, - bytes offchainConfig - ); - - /** - * @notice sets offchain reporting protocol configuration incl. participating oracles - * @param signers addresses with which oracles sign the reports - * @param transmitters addresses oracles use to transmit the reports - * @param f number of faulty oracles the system can tolerate - * @param onchainConfig serialized configuration used by the contract (and possibly oracles) - * @param offchainConfigVersion version number for offchainEncoding schema - * @param offchainConfig serialized configuration used by the oracles exclusively and only passed through the contract - */ - function setConfig( - address[] memory signers, - address[] memory transmitters, - uint8 f, - bytes memory onchainConfig, - uint64 offchainConfigVersion, - bytes memory offchainConfig - ) external virtual; - - /** - * @notice information about current offchain reporting protocol configuration - * @return configCount ordinal number of current config, out of all configs applied to this contract so far - * @return blockNumber block at which this config was set - * @return configDigest domain-separation tag for current config (see _configDigestFromConfigData) - */ - function latestConfigDetails() - external - view - virtual - returns (uint32 configCount, uint32 blockNumber, bytes32 configDigest); - - function _configDigestFromConfigData( - uint256 chainId, - address contractAddress, - uint64 configCount, - address[] memory signers, - address[] memory transmitters, - uint8 f, - bytes memory onchainConfig, - uint64 offchainConfigVersion, - bytes memory offchainConfig - ) internal pure returns (bytes32) { - uint256 h = uint256( - keccak256( - abi.encode( - chainId, - contractAddress, - configCount, - signers, - transmitters, - f, - onchainConfig, - offchainConfigVersion, - offchainConfig - ) - ) - ); - uint256 prefixMask = type(uint256).max << (256 - 16); // 0xFFFF00..00 - uint256 prefix = 0x0001 << (256 - 16); // 0x000100..00 - return bytes32((prefix & prefixMask) | (h & ~prefixMask)); - } - - /** - * @notice optionally emited to indicate the latest configDigest and epoch for - which a report was successfully transmited. Alternatively, the contract may - use latestConfigDigestAndEpoch with scanLogs set to false. - */ - event Transmitted(bytes32 configDigest, uint32 epoch); - - /** - * @notice optionally returns the latest configDigest and epoch for which a - report was successfully transmitted. Alternatively, the contract may return - scanLogs set to true and use Transmitted events to provide this information - to offchain watchers. - * @return scanLogs indicates whether to rely on the configDigest and epoch - returned or whether to scan logs for the Transmitted event instead. - * @return configDigest - * @return epoch - */ - function latestConfigDigestAndEpoch() - external - view - virtual - returns (bool scanLogs, bytes32 configDigest, uint32 epoch); - - /** - * @notice transmit is called to post a new report to the contract - * @param report serialized report, which the signatures are signing. - * @param rs ith element is the R components of the ith signature on report. Must have at most maxNumOracles entries - * @param ss ith element is the S components of the ith signature on report. Must have at most maxNumOracles entries - * @param rawVs ith element is the the V component of the ith signature - */ - function transmit( - // NOTE: If these parameters are changed, expectedMsgDataLength and/or - // TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT need to be changed accordingly - bytes32[3] calldata reportContext, - bytes calldata report, - bytes32[] calldata rs, - bytes32[] calldata ss, - bytes32 rawVs // signatures - ) external virtual; -} diff --git a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/OCR2BaseUpgradeable.sol b/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/OCR2BaseUpgradeable.sol deleted file mode 100644 index f67220dd5d4..00000000000 --- a/contracts/src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/OCR2BaseUpgradeable.sol +++ /dev/null @@ -1,388 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {ConfirmedOwnerUpgradeable} from "./ConfirmedOwnerUpgradeable.sol"; -import {OCR2Abstract} from "./OCR2Abstract.sol"; -import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; - -/** - * @notice Onchain verification of reports from the offchain reporting protocol - * @dev THIS CONTRACT HAS NOT GONE THROUGH ANY SECURITY REVIEW. DO NOT USE IN PROD. - * @dev For details on its operation, see the offchain reporting protocol design - * doc, which refers to this contract as simply the "contract". - * @dev This contract is meant to aid rapid development of new applications based on OCR2. - * However, for actual production contracts, it is expected that most of the logic of this contract - * will be folded directly into the application contract. Inheritance prevents us from doing lots - * of juicy storage layout optimizations, leading to a substantial increase in gas cost. - */ -abstract contract OCR2BaseUpgradeable is Initializable, ConfirmedOwnerUpgradeable, OCR2Abstract { - error ReportInvalid(); - - bool internal i_uniqueReports; - - /** - * @dev Initializes the contract. - */ - function __OCR2Base_initialize(bool uniqueReports) internal onlyInitializing { - __ConfirmedOwner_initialize(msg.sender, address(0)); - i_uniqueReports = uniqueReports; - } - - uint256 private constant maxUint32 = (1 << 32) - 1; - - // Storing these fields used on the hot path in a ConfigInfo variable reduces the - // retrieval of all of them to a single SLOAD. If any further fields are - // added, make sure that storage of the struct still takes at most 32 bytes. - struct ConfigInfo { - bytes32 latestConfigDigest; - uint8 f; // TODO: could be optimized by squeezing into one slot - uint8 n; - } - ConfigInfo internal s_configInfo; - - // incremented each time a new config is posted. This count is incorporated - // into the config digest, to prevent replay attacks. - uint32 internal s_configCount; - uint32 internal s_latestConfigBlockNumber; // makes it easier for offchain systems - // to extract config from logs. - - // Used for s_oracles[a].role, where a is an address, to track the purpose - // of the address, or to indicate that the address is unset. - enum Role { - // No oracle role has been set for address a - Unset, - // Signing address for the s_oracles[a].index'th oracle. I.e., report - // signatures from this oracle should ecrecover back to address a. - Signer, - // Transmission address for the s_oracles[a].index'th oracle. I.e., if a - // report is received by OCR2Aggregator.transmit in which msg.sender is - // a, it is attributed to the s_oracles[a].index'th oracle. - Transmitter - } - - struct Oracle { - uint8 index; // Index of oracle in s_signers/s_transmitters - Role role; // Role of the address which mapped to this struct - } - - mapping(address => Oracle) /* signer OR transmitter address */ internal s_oracles; - - // s_signers contains the signing address of each oracle - address[] internal s_signers; - - // s_transmitters contains the transmission address of each oracle, - // i.e. the address the oracle actually sends transactions to the contract from - address[] internal s_transmitters; - - /* - * Config logic - */ - - // Reverts transaction if config args are invalid - modifier checkConfigValid( - uint256 _numSigners, - uint256 _numTransmitters, - uint256 _f - ) { - require(_numSigners <= maxNumOracles, "too many signers"); - require(_f > 0, "f must be positive"); - require(_numSigners == _numTransmitters, "oracle addresses out of registration"); - require(_numSigners > 3 * _f, "faulty-oracle f too high"); - _; - } - - struct SetConfigArgs { - address[] signers; - address[] transmitters; - uint8 f; - bytes onchainConfig; - uint64 offchainConfigVersion; - bytes offchainConfig; - } - - /// @inheritdoc OCR2Abstract - function latestConfigDigestAndEpoch() - external - view - virtual - override - returns (bool scanLogs, bytes32 configDigest, uint32 epoch) - { - return (true, bytes32(0), uint32(0)); - } - - /** - * @notice sets offchain reporting protocol configuration incl. participating oracles - * @param _signers addresses with which oracles sign the reports - * @param _transmitters addresses oracles use to transmit the reports - * @param _f number of faulty oracles the system can tolerate - * @param _onchainConfig encoded on-chain contract configuration - * @param _offchainConfigVersion version number for offchainEncoding schema - * @param _offchainConfig encoded off-chain oracle configuration - */ - function setConfig( - address[] memory _signers, - address[] memory _transmitters, - uint8 _f, - bytes memory _onchainConfig, - uint64 _offchainConfigVersion, - bytes memory _offchainConfig - ) external override checkConfigValid(_signers.length, _transmitters.length, _f) onlyOwner { - SetConfigArgs memory args = SetConfigArgs({ - signers: _signers, - transmitters: _transmitters, - f: _f, - onchainConfig: _onchainConfig, - offchainConfigVersion: _offchainConfigVersion, - offchainConfig: _offchainConfig - }); - - _beforeSetConfig(args.f, args.onchainConfig); - - while (s_signers.length != 0) { - // remove any old signer/transmitter addresses - uint256 lastIdx = s_signers.length - 1; - address signer = s_signers[lastIdx]; - address transmitter = s_transmitters[lastIdx]; - delete s_oracles[signer]; - delete s_oracles[transmitter]; - s_signers.pop(); - s_transmitters.pop(); - } - - for (uint256 i = 0; i < args.signers.length; ++i) { - // add new signer/transmitter addresses - require(s_oracles[args.signers[i]].role == Role.Unset, "repeated signer address"); - s_oracles[args.signers[i]] = Oracle(uint8(i), Role.Signer); - require(s_oracles[args.transmitters[i]].role == Role.Unset, "repeated transmitter address"); - s_oracles[args.transmitters[i]] = Oracle(uint8(i), Role.Transmitter); - s_signers.push(args.signers[i]); - s_transmitters.push(args.transmitters[i]); - } - s_configInfo.f = args.f; - uint32 previousConfigBlockNumber = s_latestConfigBlockNumber; - s_latestConfigBlockNumber = uint32(block.number); - s_configCount += 1; - { - s_configInfo.latestConfigDigest = configDigestFromConfigData( - block.chainid, - address(this), - s_configCount, - args.signers, - args.transmitters, - args.f, - args.onchainConfig, - args.offchainConfigVersion, - args.offchainConfig - ); - } - s_configInfo.n = uint8(args.signers.length); - - emit ConfigSet( - previousConfigBlockNumber, - s_configInfo.latestConfigDigest, - s_configCount, - args.signers, - args.transmitters, - args.f, - args.onchainConfig, - args.offchainConfigVersion, - args.offchainConfig - ); - - _afterSetConfig(args.f, args.onchainConfig); - } - - function configDigestFromConfigData( - uint256 _chainId, - address _contractAddress, - uint64 _configCount, - address[] memory _signers, - address[] memory _transmitters, - uint8 _f, - bytes memory _onchainConfig, - uint64 _encodedConfigVersion, - bytes memory _encodedConfig - ) internal pure returns (bytes32) { - uint256 h = uint256( - keccak256( - abi.encode( - _chainId, - _contractAddress, - _configCount, - _signers, - _transmitters, - _f, - _onchainConfig, - _encodedConfigVersion, - _encodedConfig - ) - ) - ); - uint256 prefixMask = type(uint256).max << (256 - 16); // 0xFFFF00..00 - uint256 prefix = 0x0001 << (256 - 16); // 0x000100..00 - return bytes32((prefix & prefixMask) | (h & ~prefixMask)); - } - - /** - * @notice information about current offchain reporting protocol configuration - * @return configCount ordinal number of current config, out of all configs applied to this contract so far - * @return blockNumber block at which this config was set - * @return configDigest domain-separation tag for current config (see configDigestFromConfigData) - */ - function latestConfigDetails() - external - view - override - returns (uint32 configCount, uint32 blockNumber, bytes32 configDigest) - { - return (s_configCount, s_latestConfigBlockNumber, s_configInfo.latestConfigDigest); - } - - /** - * @return list of addresses permitted to transmit reports to this contract - * @dev The list will match the order used to specify the transmitter during setConfig - */ - function transmitters() external view returns (address[] memory) { - return s_transmitters; - } - - function _beforeSetConfig(uint8 _f, bytes memory _onchainConfig) internal virtual; - - function _afterSetConfig(uint8 _f, bytes memory _onchainConfig) internal virtual; - - /** - * @dev hook to allow additional validation of the report by the extending contract - * @param configDigest separation tag for current config (see configDigestFromConfigData) - * @param epochAndRound 27 byte padding, 4-byte epoch and 1-byte round - * @param report serialized report - */ - function _validateReport( - bytes32 configDigest, - uint40 epochAndRound, - bytes memory report - ) internal virtual returns (bool); - - /** - * @dev hook called after the report has been fully validated - * for the extending contract to handle additional logic, such as oracle payment - * @param initialGas the amount of gas before validation - * @param transmitter the address of the account that submitted the report - * @param signers the addresses of all signing accounts - * @param report serialized report - */ - function _report( - uint256 initialGas, - address transmitter, - uint8 signerCount, - address[maxNumOracles] memory signers, - bytes calldata report - ) internal virtual; - - // The constant-length components of the msg.data sent to transmit. - // See the "If we wanted to call sam" example on for example reasoning - // https://solidity.readthedocs.io/en/v0.7.2/abi-spec.html - uint16 private constant TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT = - 4 + // function selector - 32 * - 3 + // 3 words containing reportContext - 32 + // word containing start location of abiencoded report value - 32 + // word containing location start of abiencoded rs value - 32 + // word containing start location of abiencoded ss value - 32 + // rawVs value - 32 + // word containing length of report - 32 + // word containing length rs - 32 + // word containing length of ss - 0; // placeholder - - function requireExpectedMsgDataLength( - bytes calldata report, - bytes32[] calldata rs, - bytes32[] calldata ss - ) private pure { - // calldata will never be big enough to make this overflow - uint256 expected = uint256(TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT) + - report.length + // one byte pure entry in _report - rs.length * - 32 + // 32 bytes per entry in _rs - ss.length * - 32 + // 32 bytes per entry in _ss - 0; // placeholder - require(msg.data.length == expected, "calldata length mismatch"); - } - - /** - * @notice transmit is called to post a new report to the contract - * @param report serialized report, which the signatures are signing. - * @param rs ith element is the R components of the ith signature on report. Must have at most maxNumOracles entries - * @param ss ith element is the S components of the ith signature on report. Must have at most maxNumOracles entries - * @param rawVs ith element is the the V component of the ith signature - */ - function transmit( - // NOTE: If these parameters are changed, expectedMsgDataLength and/or - // TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT need to be changed accordingly - bytes32[3] calldata reportContext, - bytes calldata report, - bytes32[] calldata rs, - bytes32[] calldata ss, - bytes32 rawVs // signatures - ) external override { - uint256 initialGas = gasleft(); // This line must come first - - { - // reportContext consists of: - // reportContext[0]: ConfigDigest - // reportContext[1]: 27 byte padding, 4-byte epoch and 1-byte round - // reportContext[2]: ExtraHash - bytes32 configDigest = reportContext[0]; - uint32 epochAndRound = uint32(uint256(reportContext[1])); - - if (!_validateReport(configDigest, epochAndRound, report)) { - revert ReportInvalid(); - } - - emit Transmitted(configDigest, uint32(epochAndRound >> 8)); - - ConfigInfo memory configInfo = s_configInfo; - require(configInfo.latestConfigDigest == configDigest, "configDigest mismatch"); - - requireExpectedMsgDataLength(report, rs, ss); - - uint256 expectedNumSignatures; - if (i_uniqueReports) { - expectedNumSignatures = (configInfo.n + configInfo.f) / 2 + 1; - } else { - expectedNumSignatures = configInfo.f + 1; - } - - require(rs.length == expectedNumSignatures, "wrong number of signatures"); - require(rs.length == ss.length, "signatures out of registration"); - - Oracle memory transmitter = s_oracles[msg.sender]; - require( // Check that sender is authorized to report - transmitter.role == Role.Transmitter && msg.sender == s_transmitters[transmitter.index], - "unauthorized transmitter" - ); - } - - address[maxNumOracles] memory signed; - uint8 signerCount = 0; - - { - // Verify signatures attached to report - bytes32 h = keccak256(abi.encodePacked(keccak256(report), reportContext)); - - Oracle memory o; - for (uint256 i = 0; i < rs.length; ++i) { - address signer = ecrecover(h, uint8(rawVs[i]) + 27, rs[i], ss[i]); - o = s_oracles[signer]; - require(o.role == Role.Signer, "address not authorized to sign"); - require(signed[o.index] == address(0), "non-unique signature"); - signed[o.index] = signer; - signerCount += 1; - } - } - - _report(initialGas, msg.sender, signerCount, signed, report); - } -} diff --git a/contracts/src/v0.8/functions/tests/v1_X/FunctionsBilling.t.sol b/contracts/src/v0.8/functions/tests/v1_X/FunctionsBilling.t.sol index 14188fdc04a..82dea8672c8 100644 --- a/contracts/src/v0.8/functions/tests/v1_X/FunctionsBilling.t.sol +++ b/contracts/src/v0.8/functions/tests/v1_X/FunctionsBilling.t.sol @@ -4,12 +4,17 @@ pragma solidity ^0.8.19; import {FunctionsCoordinator} from "../../dev/v1_X/FunctionsCoordinator.sol"; import {FunctionsBilling} from "../../dev/v1_X/FunctionsBilling.sol"; import {FunctionsRequest} from "../../dev/v1_X/libraries/FunctionsRequest.sol"; +import {FunctionsSubscriptions} from "../../dev/v1_X/FunctionsSubscriptions.sol"; +import {Routable} from "../../dev/v1_X/Routable.sol"; -import {FunctionsRouterSetup, FunctionsSubscriptionSetup, FunctionsMultipleFulfillmentsSetup} from "./Setup.t.sol"; +import {FunctionsRouterSetup, FunctionsSubscriptionSetup, FunctionsClientRequestSetup, FunctionsMultipleFulfillmentsSetup} from "./Setup.t.sol"; /// @notice #constructor -contract FunctionsBilling_Constructor { - +contract FunctionsBilling_Constructor is FunctionsSubscriptionSetup { + function test_Constructor_Success() public { + assertEq(address(s_functionsRouter), s_functionsCoordinator.getRouter_HARNESS()); + assertEq(address(s_linkEthFeed), s_functionsCoordinator.getLinkToNativeFeed_HARNESS()); + } } /// @notice #getConfig @@ -32,28 +37,94 @@ contract FunctionsBilling_GetConfig is FunctionsRouterSetup { } /// @notice #updateConfig -contract FunctionsBilling_UpdateConfig { +contract FunctionsBilling_UpdateConfig is FunctionsRouterSetup { + FunctionsBilling.Config internal configToSet; + + function setUp() public virtual override { + FunctionsRouterSetup.setUp(); + + configToSet = FunctionsBilling.Config({ + feedStalenessSeconds: getCoordinatorConfig().feedStalenessSeconds * 2, + gasOverheadAfterCallback: getCoordinatorConfig().gasOverheadAfterCallback * 2, + gasOverheadBeforeCallback: getCoordinatorConfig().gasOverheadBeforeCallback * 2, + requestTimeoutSeconds: getCoordinatorConfig().requestTimeoutSeconds * 2, + donFee: getCoordinatorConfig().donFee * 2, + maxSupportedRequestDataVersion: getCoordinatorConfig().maxSupportedRequestDataVersion * 2, + fulfillmentGasPriceOverEstimationBP: getCoordinatorConfig().fulfillmentGasPriceOverEstimationBP * 2, + fallbackNativePerUnitLink: getCoordinatorConfig().fallbackNativePerUnitLink * 2, + minimumEstimateGasPriceWei: getCoordinatorConfig().minimumEstimateGasPriceWei * 2 + }); + } + function test_UpdateConfig_RevertIfNotOwner() public { + // Send as stranger + vm.stopPrank(); + vm.startPrank(STRANGER_ADDRESS); + + vm.expectRevert("Only callable by owner"); + s_functionsCoordinator.updateConfig(configToSet); + } + + event ConfigUpdated(FunctionsBilling.Config config); + + function test_UpdateConfig_Success() public { + // topic0 (function signature, always checked), NOT topic1 (false), NOT topic2 (false), NOT topic3 (false), and data (true). + bool checkTopic1 = false; + bool checkTopic2 = false; + bool checkTopic3 = false; + bool checkData = true; + vm.expectEmit(checkTopic1, checkTopic2, checkTopic3, checkData); + emit ConfigUpdated(configToSet); + + s_functionsCoordinator.updateConfig(configToSet); + + FunctionsBilling.Config memory config = s_functionsCoordinator.getConfig(); + assertEq(config.feedStalenessSeconds, configToSet.feedStalenessSeconds); + assertEq(config.gasOverheadAfterCallback, configToSet.gasOverheadAfterCallback); + assertEq(config.gasOverheadBeforeCallback, configToSet.gasOverheadBeforeCallback); + assertEq(config.requestTimeoutSeconds, configToSet.requestTimeoutSeconds); + assertEq(config.donFee, configToSet.donFee); + assertEq(config.maxSupportedRequestDataVersion, configToSet.maxSupportedRequestDataVersion); + assertEq(config.fulfillmentGasPriceOverEstimationBP, configToSet.fulfillmentGasPriceOverEstimationBP); + assertEq(config.fallbackNativePerUnitLink, configToSet.fallbackNativePerUnitLink); + assertEq(config.minimumEstimateGasPriceWei, configToSet.minimumEstimateGasPriceWei); + } } /// @notice #getDONFee -contract FunctionsBilling_GetDONFee { +contract FunctionsBilling_GetDONFee is FunctionsRouterSetup { + function test_GetDONFee_Success() public { + // Send as stranger + vm.stopPrank(); + vm.startPrank(STRANGER_ADDRESS); + uint72 donFee = s_functionsCoordinator.getDONFee(new bytes(0)); + assertEq(donFee, s_donFee); + } } /// @notice #getAdminFee -contract FunctionsBilling_GetAdminFee { +contract FunctionsBilling_GetAdminFee is FunctionsRouterSetup { + function test_GetAdminFee_Success() public { + // Send as stranger + vm.stopPrank(); + vm.startPrank(STRANGER_ADDRESS); + uint72 adminFee = s_functionsCoordinator.getAdminFee(); + assertEq(adminFee, s_adminFee); + } } /// @notice #getWeiPerUnitLink -contract FunctionsBilling_GetWeiPerUnitLink { - -} +contract FunctionsBilling_GetWeiPerUnitLink is FunctionsRouterSetup { + function test_GetWeiPerUnitLink_Success() public { + // Send as stranger + vm.stopPrank(); + vm.startPrank(STRANGER_ADDRESS); -/// @notice #_getJuelsPerGas -contract FunctionsBilling__GetJuelsPerGas { - // TODO: make contract internal function helper + uint256 weiPerUnitLink = s_functionsCoordinator.getWeiPerUnitLink(); + assertEq(weiPerUnitLink, uint256(LINK_ETH_RATE)); + } } /// @notice #estimateCost @@ -109,7 +180,7 @@ contract FunctionsBilling_EstimateCost is FunctionsSubscriptionSetup { callbackGasLimit, gasPriceWei ); - uint96 expectedCostEstimate = 16375000000000200; + uint96 expectedCostEstimate = 51110500000000200; assertEq(costEstimate, expectedCostEstimate); } @@ -134,7 +205,7 @@ contract FunctionsBilling_EstimateCost is FunctionsSubscriptionSetup { callbackGasLimit, gasPriceWei ); - uint96 expectedCostEstimate = 81875000000000200; + uint96 expectedCostEstimate = 255552500000000200; assertEq(costEstimate, expectedCostEstimate); } } @@ -149,24 +220,115 @@ contract FunctionsBilling__StartBilling { // TODO: make contract internal function helper } -/// @notice #_computeRequestId -contract FunctionsBilling__ComputeRequestId { - // TODO: make contract internal function helper -} - /// @notice #_fulfillAndBill contract FunctionsBilling__FulfillAndBill { // TODO: make contract internal function helper } /// @notice #deleteCommitment -contract FunctionsBilling_DeleteCommitment { +contract FunctionsBilling_DeleteCommitment is FunctionsClientRequestSetup { + function test_DeleteCommitment_RevertIfNotRouter() public { + // Send as stranger + vm.stopPrank(); + vm.startPrank(STRANGER_ADDRESS); + + vm.expectRevert(Routable.OnlyCallableByRouter.selector); + s_functionsCoordinator.deleteCommitment(s_requests[1].requestId); + } + + event CommitmentDeleted(bytes32 requestId); + + function test_DeleteCommitment_Success() public { + // Send as Router + vm.stopPrank(); + vm.startPrank(address(s_functionsRouter)); + + // topic0 (function signature, always checked), NOT topic1 (false), NOT topic2 (false), NOT topic3 (false), and data (true). + bool checkTopic1 = false; + bool checkTopic2 = false; + bool checkTopic3 = false; + bool checkData = true; + vm.expectEmit(checkTopic1, checkTopic2, checkTopic3, checkData); + emit CommitmentDeleted(s_requests[1].requestId); + s_functionsCoordinator.deleteCommitment(s_requests[1].requestId); + } } /// @notice #oracleWithdraw -contract FunctionsBilling_OracleWithdraw { +contract FunctionsBilling_OracleWithdraw is FunctionsMultipleFulfillmentsSetup { + function test_OracleWithdraw_RevertWithNoBalance() public { + uint256[4] memory transmitterBalancesBefore = _getTransmitterBalances(); + _assertTransmittersAllHaveBalance(transmitterBalancesBefore, 0); + // Send as stranger, which has no balance + vm.stopPrank(); + vm.startPrank(STRANGER_ADDRESS); + + vm.expectRevert(FunctionsSubscriptions.InvalidCalldata.selector); + + // Attempt to withdraw with no amount, which would withdraw the full balance + s_functionsCoordinator.oracleWithdraw(STRANGER_ADDRESS, 0); + + uint256[4] memory transmitterBalancesAfter = _getTransmitterBalances(); + _assertTransmittersAllHaveBalance(transmitterBalancesAfter, 0); + } + + function test_OracleWithdraw_RevertIfInsufficientBalance() public { + // Send as transmitter 1, which has transmitted 1 report + vm.stopPrank(); + vm.startPrank(NOP_TRANSMITTER_ADDRESS_1); + + vm.expectRevert(FunctionsBilling.InsufficientBalance.selector); + + // Attempt to withdraw more than the Coordinator has assigned + s_functionsCoordinator.oracleWithdraw(NOP_TRANSMITTER_ADDRESS_1, s_fulfillmentCoordinatorBalance + 1); + } + + function test_OracleWithdraw_SuccessTransmitterWithBalanceValidAmountGiven() public { + uint256[4] memory transmitterBalancesBefore = _getTransmitterBalances(); + _assertTransmittersAllHaveBalance(transmitterBalancesBefore, 0); + + // Send as transmitter 1, which has transmitted 1 report + vm.stopPrank(); + vm.startPrank(NOP_TRANSMITTER_ADDRESS_1); + + uint96 expectedTransmitterBalance = s_fulfillmentCoordinatorBalance / 3; + + // Attempt to withdraw half of balance + uint96 halfBalance = expectedTransmitterBalance / 2; + s_functionsCoordinator.oracleWithdraw(NOP_TRANSMITTER_ADDRESS_1, halfBalance); + + uint256[4] memory transmitterBalancesAfter = _getTransmitterBalances(); + assertEq(transmitterBalancesAfter[0], halfBalance); + assertEq(transmitterBalancesAfter[1], 0); + assertEq(transmitterBalancesAfter[2], 0); + assertEq(transmitterBalancesAfter[3], 0); + } + + function test_OracleWithdraw_SuccessTransmitterWithBalanceNoAmountGiven() public { + uint256[4] memory transmitterBalancesBefore = _getTransmitterBalances(); + _assertTransmittersAllHaveBalance(transmitterBalancesBefore, 0); + + // Send as transmitter 1, which has transmitted 1 report + vm.stopPrank(); + vm.startPrank(NOP_TRANSMITTER_ADDRESS_1); + + // Attempt to withdraw with no amount, which will withdraw the full balance + s_functionsCoordinator.oracleWithdraw(NOP_TRANSMITTER_ADDRESS_1, 0); + + // 3 report transmissions have been made + uint96 totalDonFees = s_donFee * 3; + // 4 transmitters will share the DON fees + uint96 donFeeShare = totalDonFees / 4; + uint96 expectedTransmitterBalance = ((s_fulfillmentCoordinatorBalance - totalDonFees) / 3) + donFeeShare; + + uint256[4] memory transmitterBalancesAfter = _getTransmitterBalances(); + assertEq(transmitterBalancesAfter[0], expectedTransmitterBalance); + assertEq(transmitterBalancesAfter[1], 0); + assertEq(transmitterBalancesAfter[2], 0); + assertEq(transmitterBalancesAfter[3], 0); + } } /// @notice #oracleWithdrawAll @@ -188,37 +350,29 @@ contract FunctionsBilling_OracleWithdrawAll is FunctionsMultipleFulfillmentsSetu } function test_OracleWithdrawAll_SuccessPaysTransmittersWithBalance() public { - uint256 transmitter1BalanceBefore = s_linkToken.balanceOf(NOP_TRANSMITTER_ADDRESS_1); - assertEq(transmitter1BalanceBefore, 0); - uint256 transmitter2BalanceBefore = s_linkToken.balanceOf(NOP_TRANSMITTER_ADDRESS_2); - assertEq(transmitter2BalanceBefore, 0); - uint256 transmitter3BalanceBefore = s_linkToken.balanceOf(NOP_TRANSMITTER_ADDRESS_3); - assertEq(transmitter3BalanceBefore, 0); - uint256 transmitter4BalanceBefore = s_linkToken.balanceOf(NOP_TRANSMITTER_ADDRESS_4); - assertEq(transmitter4BalanceBefore, 0); + uint256[4] memory transmitterBalancesBefore = _getTransmitterBalances(); + _assertTransmittersAllHaveBalance(transmitterBalancesBefore, 0); s_functionsCoordinator.oracleWithdrawAll(); uint96 expectedTransmitterBalance = s_fulfillmentCoordinatorBalance / 3; - uint256 transmitter1BalanceAfter = s_linkToken.balanceOf(NOP_TRANSMITTER_ADDRESS_1); - assertEq(transmitter1BalanceAfter, expectedTransmitterBalance); - uint256 transmitter2BalanceAfter = s_linkToken.balanceOf(NOP_TRANSMITTER_ADDRESS_2); - assertEq(transmitter2BalanceAfter, expectedTransmitterBalance); - uint256 transmitter3BalanceAfter = s_linkToken.balanceOf(NOP_TRANSMITTER_ADDRESS_3); - assertEq(transmitter3BalanceAfter, expectedTransmitterBalance); + uint256[4] memory transmitterBalancesAfter = _getTransmitterBalances(); + assertEq(transmitterBalancesAfter[0], expectedTransmitterBalance); + assertEq(transmitterBalancesAfter[1], expectedTransmitterBalance); + assertEq(transmitterBalancesAfter[2], expectedTransmitterBalance); // Transmitter 4 has no balance - uint256 transmitter4BalanceAfter = s_linkToken.balanceOf(NOP_TRANSMITTER_ADDRESS_4); - assertEq(transmitter4BalanceAfter, 0); + assertEq(transmitterBalancesAfter[3], 0); } } -/// @notice #_getTransmitters -contract FunctionsBilling__GetTransmitters { - // TODO: make contract internal function helper -} - /// @notice #_disperseFeePool -contract FunctionsBilling__DisperseFeePool { - // TODO: make contract internal function helper +contract FunctionsBilling__DisperseFeePool is FunctionsRouterSetup { + function test__DisperseFeePool_RevertIfNotSet() public { + // Manually set s_feePool (at slot 11) to 1 to get past first check in _disperseFeePool + vm.store(address(s_functionsCoordinator), bytes32(uint256(11)), bytes32(uint256(1))); + + vm.expectRevert(FunctionsBilling.NoTransmittersSet.selector); + s_functionsCoordinator.disperseFeePool_HARNESS(); + } } diff --git a/contracts/src/v0.8/functions/tests/v1_X/FunctionsClient.t.sol b/contracts/src/v0.8/functions/tests/v1_X/FunctionsClient.t.sol index d6a3be16847..363827645c0 100644 --- a/contracts/src/v0.8/functions/tests/v1_X/FunctionsClient.t.sol +++ b/contracts/src/v0.8/functions/tests/v1_X/FunctionsClient.t.sol @@ -2,22 +2,23 @@ pragma solidity ^0.8.19; import {BaseTest} from "./BaseTest.t.sol"; +import {FunctionsClient} from "../../dev/v1_X/FunctionsClient.sol"; import {FunctionsRouter} from "../../dev/v1_X/FunctionsRouter.sol"; import {FunctionsSubscriptions} from "../../dev/v1_X/FunctionsSubscriptions.sol"; import {FunctionsRequest} from "../../dev/v1_X/libraries/FunctionsRequest.sol"; import {FunctionsResponse} from "../../dev/v1_X/libraries/FunctionsResponse.sol"; -import {FunctionsSubscriptionSetup} from "./Setup.t.sol"; +import {FunctionsClientSetup, FunctionsSubscriptionSetup, FunctionsClientRequestSetup} from "./Setup.t.sol"; /// @notice #constructor -contract FunctionsClient_Constructor { - +contract FunctionsClient_Constructor is FunctionsClientSetup { + function test_Constructor_Success() public { + assertEq(address(s_functionsRouter), s_functionsClient.getRouter_HARNESS()); + } } /// @notice #_sendRequest contract FunctionsClient__SendRequest is FunctionsSubscriptionSetup { - // TODO: make contract internal function helper - function test__SendRequest_RevertIfInvalidCallbackGasLimit() public { // Build minimal valid request data string memory sourceCode = "return 'hello world';"; @@ -43,12 +44,35 @@ contract FunctionsClient__SendRequest is FunctionsSubscriptionSetup { } } -/// @notice #fulfillRequest -contract FunctionsClient_FulfillRequest { +/// @notice #handleOracleFulfillment +contract FunctionsClient_HandleOracleFulfillment is FunctionsClientRequestSetup { + function test_HandleOracleFulfillment_RevertIfNotRouter() public { + // Send as stranger + vm.stopPrank(); + vm.startPrank(STRANGER_ADDRESS); -} + vm.expectRevert(FunctionsClient.OnlyRouterCanFulfill.selector); + s_functionsClient.handleOracleFulfillment(s_requests[1].requestId, new bytes(0), new bytes(0)); + } -/// @notice #handleOracleFulfillment -contract FunctionsClient_HandleOracleFulfillment { + event RequestFulfilled(bytes32 indexed id); + event ResponseReceived(bytes32 indexed requestId, bytes result, bytes err); + + function test_HandleOracleFulfillment_Success() public { + // Send as Router + vm.stopPrank(); + vm.startPrank(address(s_functionsRouter)); + // topic0 (function signature, always checked), NOT topic1 (false), NOT topic2 (false), NOT topic3 (false), and data (true). + bool checkTopic1 = false; + bool checkTopic2 = false; + bool checkTopic3 = false; + bool checkData = true; + vm.expectEmit(checkTopic1, checkTopic2, checkTopic3, checkData); + emit ResponseReceived(s_requests[1].requestId, new bytes(0), new bytes(0)); + vm.expectEmit(checkTopic1, checkTopic2, checkTopic3, checkData); + emit RequestFulfilled(s_requests[1].requestId); + + s_functionsClient.handleOracleFulfillment(s_requests[1].requestId, new bytes(0), new bytes(0)); + } } diff --git a/contracts/src/v0.8/functions/tests/v1_X/FunctionsCoordinator.t.sol b/contracts/src/v0.8/functions/tests/v1_X/FunctionsCoordinator.t.sol index 893aa6408b6..7166add19fe 100644 --- a/contracts/src/v0.8/functions/tests/v1_X/FunctionsCoordinator.t.sol +++ b/contracts/src/v0.8/functions/tests/v1_X/FunctionsCoordinator.t.sol @@ -4,9 +4,13 @@ pragma solidity ^0.8.19; import {FunctionsCoordinator} from "../../dev/v1_X/FunctionsCoordinator.sol"; import {FunctionsBilling} from "../../dev/v1_X/FunctionsBilling.sol"; import {FunctionsRequest} from "../../dev/v1_X/libraries/FunctionsRequest.sol"; +import {FunctionsResponse} from "../../dev/v1_X/libraries/FunctionsResponse.sol"; import {FunctionsRouter} from "../../dev/v1_X/FunctionsRouter.sol"; +import {Routable} from "../../dev/v1_X/Routable.sol"; -import {FunctionsRouterSetup} from "./Setup.t.sol"; +import {BaseTest} from "./BaseTest.t.sol"; +import {FunctionsRouterSetup, FunctionsDONSetup, FunctionsSubscriptionSetup} from "./Setup.t.sol"; +import "forge-std/console.sol"; /// @notice #constructor contract FunctionsCoordinator_Constructor is FunctionsRouterSetup { @@ -17,48 +21,220 @@ contract FunctionsCoordinator_Constructor is FunctionsRouterSetup { } /// @notice #getThresholdPublicKey -contract FunctionsCoordinator_GetThresholdPublicKey { +contract FunctionsCoordinator_GetThresholdPublicKey is FunctionsDONSetup { + function test_GetThresholdPublicKey_RevertIfEmpty() public { + // Send as stranger + vm.stopPrank(); + vm.startPrank(STRANGER_ADDRESS); + // Reverts when empty + vm.expectRevert(FunctionsCoordinator.EmptyPublicKey.selector); + s_functionsCoordinator.getThresholdPublicKey(); + } + + function test_GetThresholdPublicKey_Success() public { + s_functionsCoordinator.setThresholdPublicKey(s_thresholdKey); + + // Send as stranger + vm.stopPrank(); + vm.startPrank(STRANGER_ADDRESS); + + bytes memory thresholdKey = s_functionsCoordinator.getThresholdPublicKey(); + assertEq(thresholdKey, s_thresholdKey); + } } /// @notice #setThresholdPublicKey -contract FunctionsCoordinator_SetThresholdPublicKey { +contract FunctionsCoordinator_SetThresholdPublicKey is FunctionsDONSetup { + function test_SetThresholdPublicKey_RevertNotOwner() public { + // Send as stranger + vm.stopPrank(); + vm.startPrank(STRANGER_ADDRESS); + + vm.expectRevert("Only callable by owner"); + bytes memory newThresholdKey = new bytes(0); + s_functionsCoordinator.setThresholdPublicKey(newThresholdKey); + } + + function test_SetThresholdPublicKey_Success() public { + s_functionsCoordinator.setThresholdPublicKey(s_thresholdKey); + + bytes memory thresholdKey = s_functionsCoordinator.getThresholdPublicKey(); + assertEq(thresholdKey, s_thresholdKey); + } } /// @notice #getDONPublicKey -contract FunctionsCoordinator_GetDONPublicKey { +contract FunctionsCoordinator_GetDONPublicKey is FunctionsDONSetup { + function test_GetDONPublicKey_RevertIfEmpty() public { + // Send as stranger + vm.stopPrank(); + vm.startPrank(STRANGER_ADDRESS); + + // Reverts when empty + vm.expectRevert(FunctionsCoordinator.EmptyPublicKey.selector); + s_functionsCoordinator.getDONPublicKey(); + } + + function test_GetDONPublicKey_Success() public { + s_functionsCoordinator.setDONPublicKey(s_donKey); + + // Send as stranger + vm.stopPrank(); + vm.startPrank(STRANGER_ADDRESS); + bytes memory donKey = s_functionsCoordinator.getDONPublicKey(); + assertEq(donKey, s_donKey); + } } /// @notice #setDONPublicKey -contract FunctionsCoordinator__SetDONPublicKey { +contract FunctionsCoordinator_SetDONPublicKey is FunctionsDONSetup { + function test_SetDONPublicKey_RevertNotOwner() public { + // Send as stranger + vm.stopPrank(); + vm.startPrank(STRANGER_ADDRESS); + + vm.expectRevert("Only callable by owner"); + s_functionsCoordinator.setDONPublicKey(s_donKey); + } + + function test_SetDONPublicKey_Success() public { + s_functionsCoordinator.setDONPublicKey(s_donKey); + bytes memory donKey = s_functionsCoordinator.getDONPublicKey(); + assertEq(donKey, s_donKey); + } } /// @notice #_isTransmitter -contract FunctionsCoordinator_IsTransmitter { - // TODO: make contract internal function helper +contract FunctionsCoordinator__IsTransmitter is FunctionsDONSetup { + function test__IsTransmitter_SuccessFound() public { + bool isTransmitter = s_functionsCoordinator.isTransmitter_HARNESS(NOP_TRANSMITTER_ADDRESS_1); + assertEq(isTransmitter, true); + } + + function test__IsTransmitter_SuccessNotFound() public { + bool isTransmitter = s_functionsCoordinator.isTransmitter_HARNESS(STRANGER_ADDRESS); + assertEq(isTransmitter, false); + } } -/// @notice #setNodePublicKey -contract FunctionsCoordinator_SetNodePublicKey { +/// @notice #startRequest +contract FunctionsCoordinator_StartRequest is FunctionsSubscriptionSetup { + function test_StartRequest_RevertIfNotRouter() public { + // Send as stranger + vm.stopPrank(); + vm.startPrank(STRANGER_ADDRESS); -} + vm.expectRevert(Routable.OnlyCallableByRouter.selector); -/// @notice #deleteNodePublicKey -contract FunctionsCoordinator_DeleteNodePublicKey { + s_functionsCoordinator.startRequest( + FunctionsResponse.RequestMeta({ + requestingContract: address(s_functionsClient), + data: new bytes(0), + subscriptionId: s_subscriptionId, + dataVersion: FunctionsRequest.REQUEST_DATA_VERSION, + flags: bytes32(0), + callbackGasLimit: 5_500, + adminFee: s_adminFee, + initiatedRequests: 0, + completedRequests: 0, + availableBalance: s_subscriptionInitialFunding, + subscriptionOwner: OWNER_ADDRESS + }) + ); + } -} + event OracleRequest( + bytes32 indexed requestId, + address indexed requestingContract, + address requestInitiator, + uint64 subscriptionId, + address subscriptionOwner, + bytes data, + uint16 dataVersion, + bytes32 flags, + uint64 callbackGasLimit, + FunctionsResponse.Commitment commitment + ); -/// @notice #getAllNodePublicKeys -contract FunctionsCoordinator_GetAllNodePublicKeys { + function test_StartRequest_Success() public { + // Send as Router + vm.stopPrank(); + vm.startPrank(address(s_functionsRouter)); + (, , address txOrigin) = vm.readCallers(); -} + bytes memory _requestData = new bytes(0); + uint32 _callbackGasLimit = 5_500; + uint96 costEstimate = s_functionsCoordinator.estimateCost( + s_subscriptionId, + _requestData, + _callbackGasLimit, + tx.gasprice + ); + uint32 timeoutTimestamp = uint32(block.timestamp + getCoordinatorConfig().requestTimeoutSeconds); + bytes32 expectedRequestId = keccak256( + abi.encode( + address(s_functionsCoordinator), + address(s_functionsClient), + s_subscriptionId, + 1, + keccak256(_requestData), + FunctionsRequest.REQUEST_DATA_VERSION, + _callbackGasLimit, + costEstimate, + timeoutTimestamp, + txOrigin + ) + ); -/// @notice #startRequest -contract FunctionsCoordinator_StartRequest { + FunctionsResponse.Commitment memory expectedComittment = FunctionsResponse.Commitment({ + adminFee: s_adminFee, + coordinator: address(s_functionsCoordinator), + client: address(s_functionsClient), + subscriptionId: s_subscriptionId, + callbackGasLimit: _callbackGasLimit, + estimatedTotalCostJuels: costEstimate, + timeoutTimestamp: timeoutTimestamp, + requestId: expectedRequestId, + donFee: s_donFee, + gasOverheadBeforeCallback: getCoordinatorConfig().gasOverheadBeforeCallback, + gasOverheadAfterCallback: getCoordinatorConfig().gasOverheadAfterCallback + }); + // topic0 (function signature, always checked), topic1 (true), topic2 (true), NOT topic3 (false), and data (true). + vm.expectEmit(true, true, false, true); + emit OracleRequest({ + requestId: expectedRequestId, + requestingContract: address(s_functionsClient), + requestInitiator: txOrigin, + subscriptionId: s_subscriptionId, + subscriptionOwner: OWNER_ADDRESS, + data: _requestData, + dataVersion: FunctionsRequest.REQUEST_DATA_VERSION, + flags: bytes32(0), + callbackGasLimit: _callbackGasLimit, + commitment: expectedComittment + }); + + s_functionsCoordinator.startRequest( + FunctionsResponse.RequestMeta({ + requestingContract: address(s_functionsClient), + data: _requestData, + subscriptionId: s_subscriptionId, + dataVersion: FunctionsRequest.REQUEST_DATA_VERSION, + flags: bytes32(0), + callbackGasLimit: 5_500, + adminFee: s_adminFee, + initiatedRequests: 0, + completedRequests: 0, + availableBalance: s_subscriptionInitialFunding, + subscriptionOwner: OWNER_ADDRESS + }) + ); + } } /// @notice #_beforeSetConfig @@ -73,10 +249,10 @@ contract FunctionsCoordinator__GetTransmitters { /// @notice #_report contract FunctionsCoordinator__Report { - + // TODO: make contract internal function helper } /// @notice #_onlyOwner contract FunctionsCoordinator__OnlyOwner { - + // TODO: make contract internal function helper } diff --git a/contracts/src/v0.8/functions/tests/v1_X/FunctionsRouter.t.sol b/contracts/src/v0.8/functions/tests/v1_X/FunctionsRouter.t.sol index b9b6e1d5746..081fe2f6649 100644 --- a/contracts/src/v0.8/functions/tests/v1_X/FunctionsRouter.t.sol +++ b/contracts/src/v0.8/functions/tests/v1_X/FunctionsRouter.t.sol @@ -938,7 +938,7 @@ contract FunctionsRouter_Fulfill is FunctionsClientRequestSetup { uint32 callbackGasLimit = s_requests[requestToFulfill].requestData.callbackGasLimit; // Coordinator sends enough gas that would get through callback and payment, but fail after - uint256 gasToUse = getCoordinatorConfig().gasOverheadBeforeCallback + callbackGasLimit + 100000; + uint256 gasToUse = getCoordinatorConfig().gasOverheadBeforeCallback + callbackGasLimit + 10_000; // topic0 (function signature, always checked), topic1 (true), NOT topic2 (false), NOT topic3 (false), and data (true). bool checkTopic1RequestId = true; @@ -1221,7 +1221,7 @@ contract FunctionsRouter_Fulfill is FunctionsClientRequestSetup { emit RequestProcessed({ requestId: s_requests[requestToFulfill].requestId, subscriptionId: s_subscriptionId, - totalCostJuels: _getExpectedCost(5393), // gasUsed is manually taken + totalCostJuels: _getExpectedCost(5416), // gasUsed is manually taken transmitter: NOP_TRANSMITTER_ADDRESS_1, resultCode: FunctionsResponse.FulfillResult.FULFILLED, response: bytes(response), diff --git a/contracts/src/v0.8/functions/tests/v1_X/FunctionsSubscriptions.t.sol b/contracts/src/v0.8/functions/tests/v1_X/FunctionsSubscriptions.t.sol index 8046bf7d939..df905fb8bee 100644 --- a/contracts/src/v0.8/functions/tests/v1_X/FunctionsSubscriptions.t.sol +++ b/contracts/src/v0.8/functions/tests/v1_X/FunctionsSubscriptions.t.sol @@ -1122,62 +1122,14 @@ contract FunctionsSubscriptions_CancelSubscription is FunctionsSubscriptionSetup uint256 balanceAfterWithdraw = s_linkToken.balanceOf(STRANGER_ADDRESS); assertEq(balanceBeforeWithdraw + expectedDepositWithheld, balanceAfterWithdraw); } +} - function test_CancelSubscription_SuccessRecieveDeposit() public { - // Complete 1 request = subscriptionDepositMinimumRequests - vm.recordLogs(); - bytes32 requestId = s_functionsClient.sendRequest( - s_donId, - "return 'hello world';", - new bytes(0), - new string[](0), - new bytes[](0), - s_subscriptionId, - 5500 - ); - - // Get commitment data from OracleRequest event log - Vm.Log[] memory entries = vm.getRecordedLogs(); - (, , , , , , , FunctionsResponse.Commitment memory commitment) = abi.decode( - entries[0].data, - (address, uint64, address, bytes, uint16, bytes32, uint64, FunctionsResponse.Commitment) - ); - - // Send as transmitter 1 - vm.stopPrank(); - vm.startPrank(NOP_TRANSMITTER_ADDRESS_1); - - // Build report - bytes32[] memory requestIds = new bytes32[](1); - requestIds[0] = requestId; - bytes[] memory results = new bytes[](1); - results[0] = bytes("hello world!"); - bytes[] memory errors = new bytes[](1); - // No error - bytes[] memory onchainMetadata = new bytes[](1); - onchainMetadata[0] = abi.encode(commitment); - bytes[] memory offchainMetadata = new bytes[](1); - // No offchain metadata - bytes memory report = abi.encode(requestIds, results, errors, onchainMetadata, offchainMetadata); - - // Build signers - address[31] memory signers; - signers[0] = NOP_SIGNER_ADDRESS_1; - - // Send report - vm.recordLogs(); - s_functionsCoordinator.callReportWithSigners(report, signers); - - // Get actual cost from RequestProcessed event log - Vm.Log[] memory entries2 = vm.getRecordedLogs(); - (uint96 totalCostJuels, , , , , ) = abi.decode( - entries2[2].data, - (uint96, address, FunctionsResponse.FulfillResult, bytes, bytes, bytes) - ); +/// @notice #cancelSubscription +contract FunctionsSubscriptions_CancelSubscription_ReceiveDeposit is FunctionsFulfillmentSetup { + event SubscriptionCanceled(uint64 indexed subscriptionId, address fundsRecipient, uint256 fundsAmount); - // Return to sending as owner - vm.stopPrank(); - vm.startPrank(OWNER_ADDRESS); + function test_CancelSubscription_SuccessRecieveDeposit() public { + uint96 totalCostJuels = s_fulfillmentRouterOwnerBalance + s_fulfillmentCoordinatorBalance; uint256 subscriptionOwnerBalanceBefore = s_linkToken.balanceOf(OWNER_ADDRESS); diff --git a/contracts/src/v0.8/functions/tests/v1_X/README.md b/contracts/src/v0.8/functions/tests/v1_X/README.md index 6400a28dc79..5f96532fb43 100644 --- a/contracts/src/v0.8/functions/tests/v1_X/README.md +++ b/contracts/src/v0.8/functions/tests/v1_X/README.md @@ -5,18 +5,21 @@ First set the foundry profile to Functions: export FOUNDRY_PROFILE=functions ``` -To run all test files use: +**To run tests use**: + +All Functions test files: ``` -forge test -vv +forge test -vvv ``` To run a specific file use: ``` -forge test -vv --mp src/v0.8/functions/tests/v1_X/[File Name].t.sol +forge test -vvv --mp src/v0.8/functions/tests/v1_X/[File Name].t.sol ``` -To see coverage: -First ensure that the correct files are being evaluated. For example, if only v1 contracts are, then temporarily change the Functions profile in `./foundry.toml`. +**To see coverage**: +First ensure that the correct files are being evaluated. For example, if only v0 contracts are, then temporarily change the Functions profile in `./foundry.toml`. + ``` -forge coverage +forge coverage --ir-minimum ``` \ No newline at end of file diff --git a/contracts/src/v0.8/functions/tests/v1_X/Setup.t.sol b/contracts/src/v0.8/functions/tests/v1_X/Setup.t.sol index f603e83281c..0c08fd20cd3 100644 --- a/contracts/src/v0.8/functions/tests/v1_X/Setup.t.sol +++ b/contracts/src/v0.8/functions/tests/v1_X/Setup.t.sol @@ -2,21 +2,21 @@ pragma solidity ^0.8.19; import {BaseTest} from "./BaseTest.t.sol"; -import {FunctionsRouter} from "../../dev/v1_X/FunctionsRouter.sol"; -import {FunctionsCoordinatorTestHelper} from "./testhelpers/FunctionsCoordinatorTestHelper.sol"; +import {FunctionsClientHarness} from "./testhelpers/FunctionsClientHarness.sol"; +import {FunctionsRouterHarness, FunctionsRouter} from "./testhelpers/FunctionsRouterHarness.sol"; +import {FunctionsCoordinatorHarness} from "./testhelpers/FunctionsCoordinatorHarness.sol"; import {FunctionsBilling} from "../../dev/v1_X/FunctionsBilling.sol"; import {FunctionsResponse} from "../../dev/v1_X/libraries/FunctionsResponse.sol"; import {MockV3Aggregator} from "../../../tests/MockV3Aggregator.sol"; import {TermsOfServiceAllowList} from "../../dev/v1_X/accessControl/TermsOfServiceAllowList.sol"; -import {FunctionsClientUpgradeHelper} from "./testhelpers/FunctionsClientUpgradeHelper.sol"; import {MockLinkToken} from "../../../mocks/MockLinkToken.sol"; import "forge-std/Vm.sol"; /// @notice Set up to deploy the following contracts: FunctionsRouter, FunctionsCoordinator, LINK/ETH Feed, ToS Allow List, and LINK token contract FunctionsRouterSetup is BaseTest { - FunctionsRouter internal s_functionsRouter; - FunctionsCoordinatorTestHelper internal s_functionsCoordinator; // TODO: use actual FunctionsCoordinator instead of helper + FunctionsRouterHarness internal s_functionsRouter; + FunctionsCoordinatorHarness internal s_functionsCoordinator; MockV3Aggregator internal s_linkEthFeed; TermsOfServiceAllowList internal s_termsOfServiceAllowList; MockLinkToken internal s_linkToken; @@ -36,9 +36,9 @@ contract FunctionsRouterSetup is BaseTest { function setUp() public virtual override { BaseTest.setUp(); s_linkToken = new MockLinkToken(); - s_functionsRouter = new FunctionsRouter(address(s_linkToken), getRouterConfig()); + s_functionsRouter = new FunctionsRouterHarness(address(s_linkToken), getRouterConfig()); s_linkEthFeed = new MockV3Aggregator(0, LINK_ETH_RATE); - s_functionsCoordinator = new FunctionsCoordinatorTestHelper( + s_functionsCoordinator = new FunctionsCoordinatorHarness( address(s_functionsRouter), getCoordinatorConfig(), address(s_linkEthFeed) @@ -68,8 +68,8 @@ contract FunctionsRouterSetup is BaseTest { return FunctionsBilling.Config({ feedStalenessSeconds: 24 * 60 * 60, // 1 day - gasOverheadAfterCallback: 50_000, // TODO: update - gasOverheadBeforeCallback: 100_00, // TODO: update + gasOverheadAfterCallback: 93_942, + gasOverheadBeforeCallback: 105_000, requestTimeoutSeconds: 60 * 5, // 5 minutes donFee: s_donFee, maxSupportedRequestDataVersion: 1, @@ -111,6 +111,15 @@ contract FunctionsDONSetup is FunctionsRouterSetup { uint64 internal s_offchainConfigVersion = 1; bytes internal s_offchainConfig = new bytes(0); + bytes s_thresholdKey = + vm.parseBytes( + "0x7b2247726f7570223a2250323536222c22475f626172223a22424f2f344358424575792f64547a436a612b614e774d666c2b645a77346d325036533246536b4966472f6633527547327337392b494e79642b4639326a346f586e67433657427561556a752b4a637a32377834484251343d222c2248223a224250532f72485065377941467232416c447a79395549466258776d46384666756632596d514177666e3342373844336f474845643247474536466e616f34552b4c6a4d4d5756792b464f7075686e77554f6a75427a64773d222c22484172726179223a5b22424d75546862414473337768316e67764e56792f6e3841316d42674b5a4b4c475259385937796a39695769337242502f316a32347571695869534531437554384c6f51446a386248466d384345477667517158494e62383d222c224248687974716d6e34314373322f4658416f43737548687151486236382f597930524b2b41354c6647654f645a78466f4e386c442b45656e4b587a544943784f6d3231636d535447364864484a6e336342645663714c673d222c22424d794e7a4534616e596258474d72694f52664c52634e7239766c347878654279316432452f4464335a744630546372386267567435582b2b42355967552b4b7875726e512f4d656b6857335845782b79506e4e4f584d3d222c22424d6a753272375a657a4a45545539413938746a6b6d547966796a79493735345742555835505174724a6578346d6766366130787373426d50325a7472412b55576d504e592b6d4664526b46674f7944694c53614e59453d225d7d" + ); + bytes s_donKey = + vm.parseBytes( + "0xf2f9c47363202d89aa9fa70baf783d70006fe493471ac8cfa82f1426fd09f16a5f6b32b7c4b5d5165cd147a6e513ba4c0efd39d969d6b20a8a21126f0411b9c6" + ); + function setUp() public virtual override { FunctionsRouterSetup.setUp(); @@ -136,6 +145,22 @@ contract FunctionsDONSetup is FunctionsRouterSetup { s_offchainConfig ); } + + function _getTransmitterBalances() internal view returns (uint256[4] memory balances) { + return [ + s_linkToken.balanceOf(NOP_TRANSMITTER_ADDRESS_1), + s_linkToken.balanceOf(NOP_TRANSMITTER_ADDRESS_2), + s_linkToken.balanceOf(NOP_TRANSMITTER_ADDRESS_3), + s_linkToken.balanceOf(NOP_TRANSMITTER_ADDRESS_4) + ]; + } + + function _assertTransmittersAllHaveBalance(uint256[4] memory balances, uint256 expectedBalance) internal { + assertEq(balances[0], expectedBalance); + assertEq(balances[1], expectedBalance); + assertEq(balances[2], expectedBalance); + assertEq(balances[3], expectedBalance); + } } /// @notice Set up to add the Coordinator and ToS Allow Contract as routes on the Router contract @@ -172,12 +197,12 @@ contract FunctionsOwnerAcceptTermsOfServiceSetup is FunctionsRoutesSetup { /// @notice Set up to deploy a consumer contract contract FunctionsClientSetup is FunctionsOwnerAcceptTermsOfServiceSetup { - FunctionsClientUpgradeHelper internal s_functionsClient; + FunctionsClientHarness internal s_functionsClient; function setUp() public virtual override { FunctionsOwnerAcceptTermsOfServiceSetup.setUp(); - s_functionsClient = new FunctionsClientUpgradeHelper(address(s_functionsRouter)); + s_functionsClient = new FunctionsClientHarness(address(s_functionsRouter)); } } @@ -261,7 +286,7 @@ contract FunctionsClientRequestSetup is FunctionsSubscriptionSetup { vm.recordLogs(); - bytes32 requestId = FunctionsClientUpgradeHelper(client).sendRequest( + bytes32 requestId = FunctionsClientHarness(client).sendRequest( s_donId, sourceCode, secrets, diff --git a/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsClientHarness.sol b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsClientHarness.sol new file mode 100644 index 00000000000..ec3b5a65fea --- /dev/null +++ b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsClientHarness.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; + +import {FunctionsClientUpgradeHelper} from "./FunctionsClientUpgradeHelper.sol"; +import {FunctionsResponse} from "../../../dev/v1_X/libraries/FunctionsResponse.sol"; + +/// @title Functions Client Test Harness +/// @notice Contract to expose internal functions for testing purposes +contract FunctionsClientHarness is FunctionsClientUpgradeHelper { + constructor(address router) FunctionsClientUpgradeHelper(router) {} + + function getRouter_HARNESS() external view returns (address) { + return address(i_router); + } + + function sendRequest_HARNESS( + bytes memory data, + uint64 subscriptionId, + uint32 callbackGasLimit, + bytes32 donId + ) external returns (bytes32) { + return super._sendRequest(data, subscriptionId, callbackGasLimit, donId); + } +} diff --git a/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsClientTestHelper.sol b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsClientTestHelper.sol index bca0f0a3fa2..bc73544205e 100644 --- a/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsClientTestHelper.sol +++ b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsClientTestHelper.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; +pragma solidity ^0.8.19; import {ITermsOfServiceAllowList} from "../../../dev/v1_X/accessControl/interfaces/ITermsOfServiceAllowList.sol"; import {IFunctionsSubscriptions} from "../../../dev/v1_X/interfaces/IFunctionsSubscriptions.sol"; diff --git a/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsClientWithEmptyCallback.sol b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsClientWithEmptyCallback.sol index 362b21d89ba..e5674717730 100644 --- a/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsClientWithEmptyCallback.sol +++ b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsClientWithEmptyCallback.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; +pragma solidity ^0.8.19; import {FunctionsRequest} from "../../../dev/v1_X/libraries/FunctionsRequest.sol"; import {FunctionsClient} from "../../../dev/v1_X/FunctionsClient.sol"; diff --git a/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsCoordinatorHarness.sol b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsCoordinatorHarness.sol new file mode 100644 index 00000000000..bc103fc3561 --- /dev/null +++ b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsCoordinatorHarness.sol @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; + +import {FunctionsCoordinator} from "../../../dev/v1_X/FunctionsCoordinator.sol"; +import {FunctionsBilling} from "../../../dev/v1_X/FunctionsBilling.sol"; +import {FunctionsResponse} from "../../../dev/v1_X/libraries/FunctionsResponse.sol"; + +/// @title Functions Coordinator Test Harness +/// @notice Contract to expose internal functions for testing purposes +contract FunctionsCoordinatorHarness is FunctionsCoordinator { + address s_linkToNativeFeed_HARNESS; + address s_router_HARNESS; + + constructor( + address router, + FunctionsBilling.Config memory config, + address linkToNativeFeed + ) FunctionsCoordinator(router, config, linkToNativeFeed) { + s_linkToNativeFeed_HARNESS = linkToNativeFeed; + s_router_HARNESS = router; + } + + function isTransmitter_HARNESS(address node) external view returns (bool) { + return super._isTransmitter(node); + } + + function beforeSetConfig_HARNESS(uint8 _f, bytes memory _onchainConfig) external { + return super._beforeSetConfig(_f, _onchainConfig); + } + + /// @dev Used by FunctionsBilling.sol + function getTransmitters_HARNESS() external view returns (address[] memory) { + return super._getTransmitters(); + } + + function report_HARNESS( + uint256 initialGas, + address transmitter, + uint8 signerCount, + address[MAX_NUM_ORACLES] memory signers, + bytes calldata report + ) external { + return super._report(initialGas, transmitter, signerCount, signers, report); + } + + function onlyOwner_HARNESS() external view { + return super._onlyOwner(); + } + + // ================================================================ + // | Functions Billing | + // ================================================================ + + function getLinkToNativeFeed_HARNESS() external view returns (address) { + return s_linkToNativeFeed_HARNESS; + } + + function getRouter_HARNESS() external view returns (address) { + return s_router_HARNESS; + } + + function calculateCostEstimate_HARNESS( + uint32 callbackGasLimit, + uint256 gasPriceWei, + uint72 donFee, + uint72 adminFee + ) external view returns (uint96) { + return super._calculateCostEstimate(callbackGasLimit, gasPriceWei, donFee, adminFee); + } + + function startBilling_HARNESS( + FunctionsResponse.RequestMeta memory request + ) external returns (FunctionsResponse.Commitment memory commitment) { + return super._startBilling(request); + } + + function fulfillAndBill_HARNESS( + bytes32 requestId, + bytes memory response, + bytes memory err, + bytes memory onchainMetadata, + bytes memory offchainMetadata + ) external returns (FunctionsResponse.FulfillResult) { + return super._fulfillAndBill(requestId, response, err, onchainMetadata, offchainMetadata); + } + + function disperseFeePool_HARNESS() external { + return super._disperseFeePool(); + } + + // ================================================================ + // | OCR2 | + // ================================================================ + + function configDigestFromConfigData_HARNESS( + uint256 _chainId, + address _contractAddress, + uint64 _configCount, + address[] memory _signers, + address[] memory _transmitters, + uint8 _f, + bytes memory _onchainConfig, + uint64 _encodedConfigVersion, + bytes memory _encodedConfig + ) internal pure returns (bytes32) { + return + super._configDigestFromConfigData( + _chainId, + _contractAddress, + _configCount, + _signers, + _transmitters, + _f, + _onchainConfig, + _encodedConfigVersion, + _encodedConfig + ); + } +} diff --git a/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsCoordinatorTestHelper.sol b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsCoordinatorTestHelper.sol index 1d883b3b29a..5e57e62e599 100644 --- a/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsCoordinatorTestHelper.sol +++ b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsCoordinatorTestHelper.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; +pragma solidity ^0.8.19; import {FunctionsCoordinator} from "../../../dev/v1_X/FunctionsCoordinator.sol"; import {FunctionsBilling} from "../../../dev/v1_X/FunctionsBilling.sol"; diff --git a/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsRouterHarness.sol b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsRouterHarness.sol new file mode 100644 index 00000000000..7caeff498a3 --- /dev/null +++ b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsRouterHarness.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; + +import {FunctionsRouter} from "../../../dev/v1_X/FunctionsRouter.sol"; + +/// @title Functions Router Test Harness +/// @notice Contract to expose internal functions for testing purposes +contract FunctionsRouterHarness is FunctionsRouter { + constructor(address linkToken, Config memory config) FunctionsRouter(linkToken, config) {} + + function getMaxConsumers_HARNESS() external view returns (uint16) { + return super._getMaxConsumers(); + } + + function getSubscriptionDepositDetails_HARNESS() external view returns (uint16, uint72) { + return super._getSubscriptionDepositDetails(); + } + + function whenNotPaused_HARNESS() external view { + return super._whenNotPaused(); + } + + function onlyRouterOwner_HARNESS() external view { + return super._onlyRouterOwner(); + } + + function onlySenderThatAcceptedToS_HARNESS() external view { + return super._onlySenderThatAcceptedToS(); + } +} diff --git a/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsSubscriptionsHarness.sol b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsSubscriptionsHarness.sol new file mode 100644 index 00000000000..2e2427f6e13 --- /dev/null +++ b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsSubscriptionsHarness.sol @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; + +import {FunctionsSubscriptions} from "../../../dev/v1_X/FunctionsSubscriptions.sol"; + +/// @title Functions Subscriptions Test Harness +/// @notice Contract to expose internal functions for testing purposes +contract FunctionsSubscriptionsHarness is FunctionsSubscriptions { + constructor(address link) FunctionsSubscriptions(link) {} + + function markRequestInFlight_HARNESS(address client, uint64 subscriptionId, uint96 estimatedTotalCostJuels) external { + return super._markRequestInFlight(client, subscriptionId, estimatedTotalCostJuels); + } + + function pay_HARNESS( + uint64 subscriptionId, + uint96 estimatedTotalCostJuels, + address client, + uint96 adminFee, + uint96 juelsPerGas, + uint96 gasUsed, + uint96 costWithoutCallbackJuels + ) external returns (Receipt memory) { + return + super._pay( + subscriptionId, + estimatedTotalCostJuels, + client, + adminFee, + juelsPerGas, + gasUsed, + costWithoutCallbackJuels + ); + } + + function isExistingSubscription_HARNESS(uint64 subscriptionId) external view { + return super._isExistingSubscription(subscriptionId); + } + + function isAllowedConsumer_HARNESS(address client, uint64 subscriptionId) external view { + return super._isAllowedConsumer(client, subscriptionId); + } + + // Overrides + function _getMaxConsumers() internal view override returns (uint16) {} + + function _getSubscriptionDepositDetails() internal override returns (uint16, uint72) {} + + function _onlySenderThatAcceptedToS() internal override {} + + function _onlyRouterOwner() internal override {} + + function _whenNotPaused() internal override {} +} diff --git a/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsTestHelper.sol b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsTestHelper.sol index e8e74e3ed74..50e90c44953 100644 --- a/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsTestHelper.sol +++ b/contracts/src/v0.8/functions/tests/v1_X/testhelpers/FunctionsTestHelper.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.6; +pragma solidity ^0.8.19; import {FunctionsRequest} from "../../../dev/v1_X/libraries/FunctionsRequest.sol"; diff --git a/contracts/src/v0.8/vrf/testhelpers/VRFv2Consumer.sol b/contracts/src/v0.8/vrf/testhelpers/VRFv2Consumer.sol new file mode 100644 index 00000000000..4ec7ad081b1 --- /dev/null +++ b/contracts/src/v0.8/vrf/testhelpers/VRFv2Consumer.sol @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: MIT +// An example of a consumer contract that relies on a subscription for funding. +pragma solidity 0.8.6; + +import "../interfaces/VRFCoordinatorV2Interface.sol"; +import "../VRFConsumerBaseV2.sol"; +import "../../shared/access/ConfirmedOwner.sol"; + +/** + * THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED VALUES FOR CLARITY. + * THIS IS AN EXAMPLE CONTRACT THAT USES UN-AUDITED CODE. + * DO NOT USE THIS CODE IN PRODUCTION. + */ + +contract VRFv2Consumer is VRFConsumerBaseV2, ConfirmedOwner { + event RequestSent(uint256 requestId, uint32 numWords); + event RequestFulfilled(uint256 requestId, uint256[] randomWords); + + struct RequestStatus { + bool fulfilled; // whether the request has been successfully fulfilled + bool exists; // whether a requestId exists + uint256[] randomWords; + } + mapping(uint256 => RequestStatus) public s_requests; /* requestId --> requestStatus */ + VRFCoordinatorV2Interface COORDINATOR; + + // past requests Id. + uint256[] public requestIds; + uint256 public lastRequestId; + + constructor(address vrfCoordinator) VRFConsumerBaseV2(vrfCoordinator) ConfirmedOwner(msg.sender) { + COORDINATOR = VRFCoordinatorV2Interface(vrfCoordinator); + } + + // Assumes the subscription is funded sufficiently. + function requestRandomWords( + uint64 subId, + uint32 callbackGasLimit, + uint16 requestConfirmations, + uint32 numWords, + bytes32 keyHash + ) external onlyOwner returns (uint256 requestId) { + // Will revert if subscription is not set and funded. + requestId = COORDINATOR.requestRandomWords(keyHash, subId, requestConfirmations, callbackGasLimit, numWords); + s_requests[requestId] = RequestStatus({randomWords: new uint256[](0), exists: true, fulfilled: false}); + requestIds.push(requestId); + lastRequestId = requestId; + emit RequestSent(requestId, numWords); + return requestId; + } + + function fulfillRandomWords(uint256 _requestId, uint256[] memory _randomWords) internal override { + require(s_requests[_requestId].exists, "request not found"); + s_requests[_requestId].fulfilled = true; + s_requests[_requestId].randomWords = _randomWords; + emit RequestFulfilled(_requestId, _randomWords); + } + + function getRequestStatus(uint256 _requestId) external view returns (bool fulfilled, uint256[] memory randomWords) { + require(s_requests[_requestId].exists, "request not found"); + RequestStatus memory request = s_requests[_requestId]; + return (request.fulfilled, request.randomWords); + } +} diff --git a/contracts/test/v0.8/dev/AuthorizedOriginReceiver.test.ts b/contracts/test/v0.8/dev/AuthorizedOriginReceiver.test.ts deleted file mode 100644 index dc6406422de..00000000000 --- a/contracts/test/v0.8/dev/AuthorizedOriginReceiver.test.ts +++ /dev/null @@ -1,181 +0,0 @@ -import { ethers } from 'hardhat' -import { expect } from 'chai' -import { Contract, ContractFactory } from 'ethers' -import { Roles, getUsers } from '../../test-helpers/setup' - -let authorizedOriginReceiverFactory: ContractFactory -let roles: Roles - -before(async () => { - roles = (await getUsers()).roles - - authorizedOriginReceiverFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/AuthorizedOriginReceiverTestHelper.sol:AuthorizedOriginReceiverTestHelper', - roles.defaultAccount, - ) -}) - -describe('AuthorizedOriginReceiverTestHelper', () => { - let receiver: Contract - - beforeEach(async () => { - receiver = await authorizedOriginReceiverFactory - .connect(roles.defaultAccount) - .deploy() - }) - - describe('AuthorizedOriginReceiver', () => { - it('#addAuthorizedSenders', async () => { - const { personas } = await getUsers() - const addr1 = await personas.Carol.getAddress() - const addr2 = await personas.Nancy.getAddress() - - await expect(receiver.addAuthorizedSenders([addr1, addr2])).not.to.be - .reverted - - const senders = await receiver.callStatic.getAuthorizedSenders() - expect(senders).to.be.deep.equal([addr1, addr2]) - }) - - it('#addAuthorizedSenders emits AuthorizedSendersChanged', async () => { - const { personas } = await getUsers() - const owner = await personas.Default.getAddress() - const addr1 = await personas.Carol.getAddress() - const addr2 = await personas.Nancy.getAddress() - - await expect(receiver.addAuthorizedSenders([addr1, addr2])) - .to.emit(receiver, 'AuthorizedSendersChanged') - .withArgs([addr1, addr2], owner) - }) - - it('#addAuthorizedSenders empty list', async () => { - await expect(receiver.addAuthorizedSenders([])).to.be.revertedWith( - 'EmptySendersList', - ) - }) - - it('#addAuthorizedSenders new senders', async () => { - const { personas } = await getUsers() - const addr1 = await personas.Carol.getAddress() - const addr2 = await personas.Nancy.getAddress() - const addr3 = await personas.Neil.getAddress() - const addr4 = await personas.Ned.getAddress() - - await expect(receiver.addAuthorizedSenders([addr1, addr2])).not.to.be - .reverted - - await expect(receiver.addAuthorizedSenders([addr3, addr4])).not.to.be - .reverted - - const senders = await receiver.callStatic.getAuthorizedSenders() - expect(senders).to.be.deep.equal([addr1, addr2, addr3, addr4]) - }) - - it('#addAuthorizedSenders removes duplicate new senders', async () => { - const { personas } = await getUsers() - const addr1 = await personas.Carol.getAddress() - const addr2 = await personas.Nancy.getAddress() - const addr3 = await personas.Neil.getAddress() - - await expect(receiver.addAuthorizedSenders([addr1, addr2])).not.to.be - .reverted - - await expect(receiver.addAuthorizedSenders([addr2, addr3])).not.to.be - .reverted - - const senders = await receiver.callStatic.getAuthorizedSenders() - expect(senders).to.be.deep.equal([addr1, addr2, addr3]) - }) - - it('#remove AuthorizedSenders', async () => { - const { personas } = await getUsers() - const addr1 = await personas.Carol.getAddress() - const addr2 = await personas.Nancy.getAddress() - - await expect(receiver.addAuthorizedSenders([addr1, addr2])).not.to.be - .reverted - - const senders = await receiver.callStatic.getAuthorizedSenders() - expect(senders).to.be.deep.equal([addr1, addr2]) - - await expect(receiver.removeAuthorizedSenders([addr1, addr2])).not.to.be - .reverted - const sendersAfterRemove = - await receiver.callStatic.getAuthorizedSenders() - expect(sendersAfterRemove).to.be.deep.equal([]) - }) - - it('#addAuthorizedSenders', async () => { - const { personas } = await getUsers() - const addr1 = await personas.Carol.getAddress() - const addr2 = await personas.Nancy.getAddress() - - await expect(receiver.addAuthorizedSenders([addr1, addr2])).not.to.be - .reverted - - const senders = await receiver.callStatic.getAuthorizedSenders() - expect(senders).to.be.deep.equal([addr1, addr2]) - }) - - it('#isAuthorizedSender', async () => { - const { personas } = await getUsers() - const addr1 = await personas.Carol.getAddress() - const addr2 = await personas.Nancy.getAddress() - - await expect(receiver.addAuthorizedSenders([addr1])).not.to.be.reverted - - expect(await receiver.callStatic.isAuthorizedSender(addr1)).to.be.equal( - true, - ) - expect(await receiver.callStatic.isAuthorizedSender(addr2)).to.be.equal( - false, - ) - }) - }) - - describe('#verifyValidateAuthorizedSender', () => { - it('Should revert for empty state', async () => { - await expect( - receiver.verifyValidateAuthorizedSender(), - ).to.be.revertedWith('UnauthorizedSender') - }) - - it('#validateAuthorizedSender modifier', async () => { - const { personas } = await getUsers() - - await expect( - receiver.addAuthorizedSenders([ - await personas.Carol.getAddress(), - await personas.Nancy.getAddress(), - ]), - ).not.to.be.reverted - - expect( - await receiver - .connect(personas.Carol) - .callStatic.verifyValidateAuthorizedSender(), - ).to.be.equal(true) - expect( - await receiver - .connect(personas.Nancy) - .callStatic.verifyValidateAuthorizedSender(), - ).to.be.equal(true) - await expect( - receiver.connect(personas.Neil).verifyValidateAuthorizedSender(), - ).to.be.revertedWith('UnauthorizedSender') - }) - - it('Should revert addAuthorizedSenders if cannot set', async () => { - const { personas } = await getUsers() - - await expect(receiver.changeSetAuthorizedSender(false)).not.to.be.reverted - - await expect( - receiver.addAuthorizedSenders([ - await personas.Carol.getAddress(), - await personas.Nancy.getAddress(), - ]), - ).to.be.revertedWith('NotAllowedToSetSenders') - }) - }) -}) diff --git a/contracts/test/v0.8/dev/AuthorizedReceiver.test.ts b/contracts/test/v0.8/dev/AuthorizedReceiver.test.ts deleted file mode 100644 index ca9951e6889..00000000000 --- a/contracts/test/v0.8/dev/AuthorizedReceiver.test.ts +++ /dev/null @@ -1,135 +0,0 @@ -import { ethers } from 'hardhat' -import { expect } from 'chai' -import { Contract, ContractFactory } from 'ethers' -import { Roles, getUsers } from '../../test-helpers/setup' - -let authorizedReceiverFactory: ContractFactory -let roles: Roles - -before(async () => { - roles = (await getUsers()).roles - - authorizedReceiverFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/AuthorizedReceiverTestHelper.sol:AuthorizedReceiverTestHelper', - roles.defaultAccount, - ) -}) - -describe('AuthorizedReceiverTestHelper', () => { - let receiver: Contract - - beforeEach(async () => { - receiver = await authorizedReceiverFactory - .connect(roles.defaultAccount) - .deploy() - }) - - describe('AuthorizedReceiver', () => { - it('#setAuthorizedSenders', async () => { - const { personas } = await getUsers() - const addr1 = await personas.Carol.getAddress() - const addr2 = await personas.Nancy.getAddress() - - await expect(receiver.setAuthorizedSenders([addr1, addr2])).not.to.be - .reverted - - const senders = await receiver.callStatic.getAuthorizedSenders() - expect(senders).to.be.deep.equal([addr1, addr2]) - }) - - it('#setAuthorizedSenders emits AuthorizedSendersChanged', async () => { - const { personas } = await getUsers() - const owner = await personas.Default.getAddress() - const addr1 = await personas.Carol.getAddress() - const addr2 = await personas.Nancy.getAddress() - - await expect(receiver.setAuthorizedSenders([addr1, addr2])) - .to.emit(receiver, 'AuthorizedSendersChanged') - .withArgs([addr1, addr2], owner) - }) - - it('#setAuthorizedSenders empty list', async () => { - await expect(receiver.setAuthorizedSenders([])).to.be.revertedWith( - 'EmptySendersList', - ) - }) - - it('#setAuthorizedSenders new senders', async () => { - const { personas } = await getUsers() - const addr1 = await personas.Carol.getAddress() - const addr2 = await personas.Nancy.getAddress() - const addr3 = await personas.Neil.getAddress() - const addr4 = await personas.Ned.getAddress() - - await expect(receiver.setAuthorizedSenders([addr1, addr2])).not.to.be - .reverted - - await expect(receiver.setAuthorizedSenders([addr3, addr4])).not.to.be - .reverted - - const senders = await receiver.callStatic.getAuthorizedSenders() - expect(senders).to.be.deep.equal([addr3, addr4]) - }) - - it('#isAuthorizedSender', async () => { - const { personas } = await getUsers() - const addr1 = await personas.Carol.getAddress() - const addr2 = await personas.Nancy.getAddress() - - await expect(receiver.setAuthorizedSenders([addr1])).not.to.be.reverted - - expect(await receiver.callStatic.isAuthorizedSender(addr1)).to.be.equal( - true, - ) - expect(await receiver.callStatic.isAuthorizedSender(addr2)).to.be.equal( - false, - ) - }) - }) - - describe('#verifyValidateAuthorizedSender', () => { - it('Should revert for empty state', async () => { - await expect( - receiver.verifyValidateAuthorizedSender(), - ).to.be.revertedWith('UnauthorizedSender') - }) - - it('#validateAuthorizedSender modifier', async () => { - const { personas } = await getUsers() - - await expect( - receiver.setAuthorizedSenders([ - await personas.Carol.getAddress(), - await personas.Nancy.getAddress(), - ]), - ).not.to.be.reverted - - expect( - await receiver - .connect(personas.Carol) - .callStatic.verifyValidateAuthorizedSender(), - ).to.be.equal(true) - expect( - await receiver - .connect(personas.Nancy) - .callStatic.verifyValidateAuthorizedSender(), - ).to.be.equal(true) - await expect( - receiver.connect(personas.Neil).verifyValidateAuthorizedSender(), - ).to.be.revertedWith('UnauthorizedSender') - }) - - it('Should revert setAuthorizedSenders if cannot set', async () => { - const { personas } = await getUsers() - - await expect(receiver.changeSetAuthorizedSender(false)).not.to.be.reverted - - await expect( - receiver.setAuthorizedSenders([ - await personas.Carol.getAddress(), - await personas.Nancy.getAddress(), - ]), - ).to.be.revertedWith('NotAllowedToSetSenders') - }) - }) -}) diff --git a/contracts/test/v0.8/functions/v0/Functions.test.ts b/contracts/test/v0.8/functions/v0/Functions.test.ts deleted file mode 100644 index 242e5d57aad..00000000000 --- a/contracts/test/v0.8/functions/v0/Functions.test.ts +++ /dev/null @@ -1,168 +0,0 @@ -import { ethers } from 'hardhat' -import { - publicAbi, - decodeDietCBOR, - hexToBuf, -} from '../../../test-helpers/helpers' -import { assert, expect } from 'chai' -import { Contract, ContractFactory, providers, Signer } from 'ethers' -import { Roles, getUsers } from '../../../test-helpers/setup' -import { makeDebug } from '../../../test-helpers/debug' - -const debug = makeDebug('FunctionsTestHelper') -let concreteFunctionsTestHelperFactory: ContractFactory - -let roles: Roles - -before(async () => { - roles = (await getUsers()).roles - concreteFunctionsTestHelperFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsTestHelper.sol:FunctionsTestHelper', - roles.defaultAccount, - ) -}) - -describe('FunctionsTestHelper', () => { - let ctr: Contract - let defaultAccount: Signer - - beforeEach(async () => { - defaultAccount = roles.defaultAccount - ctr = await concreteFunctionsTestHelperFactory - .connect(defaultAccount) - .deploy() - }) - - it('has a limited public interface [ @skip-coverage ]', () => { - publicAbi(ctr, [ - 'closeEvent', - 'initializeRequestForInlineJavaScript', - 'addSecrets', - 'addTwoArgs', - 'addEmptyArgs', - ]) - }) - - async function parseRequestDataEvent(tx: providers.TransactionResponse) { - const receipt = await tx.wait() - const data = receipt.logs?.[0].data - const d = debug.extend('parseRequestDataEvent') - d('data %s', data) - return ethers.utils.defaultAbiCoder.decode(['bytes'], data ?? '') - } - - describe('#closeEvent', () => { - it('handles empty request', async () => { - const tx = await ctr.closeEvent() - const [payload] = await parseRequestDataEvent(tx) - const decoded = await decodeDietCBOR(payload) - assert.deepEqual( - { - ...decoded, - language: decoded.language.toNumber(), - codeLocation: decoded.codeLocation.toNumber(), - }, - { - language: 0, - codeLocation: 0, - source: '', - }, - ) - }) - }) - - describe('#initializeRequestForInlineJavaScript', () => { - it('emits simple CBOR encoded request for js', async () => { - const js = 'function run(args, responses) {}' - await ctr.initializeRequestForInlineJavaScript(js) - const tx = await ctr.closeEvent() - const [payload] = await parseRequestDataEvent(tx) - const decoded = await decodeDietCBOR(payload) - assert.deepEqual( - { - ...decoded, - language: decoded.language.toNumber(), - codeLocation: decoded.codeLocation.toNumber(), - }, - { - language: 0, - codeLocation: 0, - source: js, - }, - ) - }) - }) - - describe('#initializeRequestForInlineJavaScript to revert', () => { - it('reverts with EmptySource() if source param is empty', async () => { - await expect( - ctr.initializeRequestForInlineJavaScript(''), - ).to.be.revertedWith('EmptySource()') - }) - }) - - describe('#addSecrets', () => { - it('emits CBOR encoded request with js and secrets', async () => { - const js = 'function run(args, responses) {}' - const secrets = '0xA161616162' - await ctr.initializeRequestForInlineJavaScript(js) - await ctr.addSecrets(secrets) - const tx = await ctr.closeEvent() - const [payload] = await parseRequestDataEvent(tx) - const decoded = await decodeDietCBOR(payload) - assert.deepEqual( - { - ...decoded, - language: decoded.language.toNumber(), - codeLocation: decoded.codeLocation.toNumber(), - secretsLocation: decoded.secretsLocation.toNumber(), - }, - { - language: 0, - codeLocation: 0, - source: js, - secretsLocation: 1, - secrets: hexToBuf(secrets), - }, - ) - }) - }) - - describe('#addSecrets to revert', () => { - it('reverts with EmptySecrets() if secrets param is empty', async () => { - const js = 'function run(args, responses) {}' - await ctr.initializeRequestForInlineJavaScript(js) - await expect(ctr.addSecrets('0x')).to.be.revertedWith('EmptySecrets()') - }) - }) - - describe('#addArgs', () => { - it('emits CBOR encoded request with js and args', async () => { - const js = 'function run(args, responses) {}' - await ctr.initializeRequestForInlineJavaScript(js) - await ctr.addTwoArgs('arg1', 'arg2') - const tx = await ctr.closeEvent() - const [payload] = await parseRequestDataEvent(tx) - const decoded = await decodeDietCBOR(payload) - assert.deepEqual( - { - ...decoded, - language: decoded.language.toNumber(), - codeLocation: decoded.codeLocation.toNumber(), - }, - { - language: 0, - codeLocation: 0, - source: js, - args: ['arg1', 'arg2'], - }, - ) - }) - }) - - describe('#addEmptyArgs to revert', () => { - it('reverts with EmptyArgs() if args param is empty', async () => { - await expect(ctr.addEmptyArgs()).to.be.revertedWith('EmptyArgs()') - }) - }) -}) diff --git a/contracts/test/v0.8/functions/v0/FunctionsBillingRegistry.test.ts b/contracts/test/v0.8/functions/v0/FunctionsBillingRegistry.test.ts deleted file mode 100644 index 95160689d28..00000000000 --- a/contracts/test/v0.8/functions/v0/FunctionsBillingRegistry.test.ts +++ /dev/null @@ -1,834 +0,0 @@ -import { ethers } from 'hardhat' -import { expect } from 'chai' -import { BigNumber, Contract, ContractFactory, Signer } from 'ethers' -import { Roles, getUsers } from '../../../test-helpers/setup' -import { randomAddressString } from 'hardhat/internal/hardhat-network/provider/utils/random' -import { stringToBytes } from '../../../test-helpers/helpers' - -let functionsOracleFactory: ContractFactory -let clientTestHelperFactory: ContractFactory -let functionsBillingRegistryFactory: ContractFactory -let linkTokenFactory: ContractFactory -let mockAggregatorV3Factory: ContractFactory -let roles: Roles -let subOwner: Signer -let subOwnerAddress: string -let consumer: Signer -let consumerAddress: string -let stranger: Signer -let strangerAddress: string - -const stringToHex = (s: string) => { - return ethers.utils.hexlify(ethers.utils.toUtf8Bytes(s)) -} - -const encodeReport = (requestId: string, result: string, err: string) => { - const abi = ethers.utils.defaultAbiCoder - return abi.encode( - ['bytes32[]', 'bytes[]', 'bytes[]'], - [[requestId], [result], [err]], - ) -} - -const linkEth = BigNumber.from(5021530000000000) - -type RegistryConfig = { - maxGasLimit: number - stalenessSeconds: number - gasAfterPaymentCalculation: number - weiPerUnitLink: BigNumber - gasOverhead: number - requestTimeoutSeconds: number -} -const config: RegistryConfig = { - maxGasLimit: 1_000_000, - stalenessSeconds: 86_400, - gasAfterPaymentCalculation: - 21_000 + 5_000 + 2_100 + 20_000 + 2 * 2_100 - 15_000 + 7_315, - weiPerUnitLink: BigNumber.from('5000000000000000'), - gasOverhead: 100_000, - requestTimeoutSeconds: 300, -} - -before(async () => { - roles = (await getUsers()).roles - - functionsOracleFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleHelper.sol:FunctionsOracleHelper', - roles.defaultAccount, - ) - - clientTestHelperFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsClientTestHelper.sol:FunctionsClientTestHelper', - roles.consumer, - ) - - functionsBillingRegistryFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsBillingRegistryWithInit.sol:FunctionsBillingRegistryWithInit', - roles.consumer, - ) - - linkTokenFactory = await ethers.getContractFactory( - 'src/v0.8/mocks/MockLinkToken.sol:MockLinkToken', - roles.consumer, - ) - - mockAggregatorV3Factory = await ethers.getContractFactory( - 'src/v0.8/tests/MockV3Aggregator.sol:MockV3Aggregator', - roles.consumer, - ) -}) - -describe('FunctionsRegistry', () => { - let registry: Contract - let oracle: Contract - let client: Contract - let linkToken: Contract - let mockLinkEth: Contract - - beforeEach(async () => { - const { roles } = await getUsers() - subOwner = roles.consumer - subOwnerAddress = await subOwner.getAddress() - consumer = roles.consumer2 - consumerAddress = await consumer.getAddress() - stranger = roles.stranger - strangerAddress = await stranger.getAddress() - - // Deploy - linkToken = await linkTokenFactory.connect(roles.defaultAccount).deploy() - mockLinkEth = await mockAggregatorV3Factory.deploy(0, linkEth) - oracle = await functionsOracleFactory.connect(roles.defaultAccount).deploy() - registry = await functionsBillingRegistryFactory - .connect(roles.defaultAccount) - .deploy(linkToken.address, mockLinkEth.address, oracle.address) - client = await clientTestHelperFactory - .connect(roles.consumer) - .deploy(oracle.address) - - // Setup contracts - await oracle.setRegistry(registry.address) - await oracle.deactivateAuthorizedReceiver() - - // Setup accounts - await linkToken.transfer( - subOwnerAddress, - BigNumber.from('1000000000000000000'), // 1 LINK - ) - await linkToken.transfer( - strangerAddress, - BigNumber.from('1000000000000000000'), // 1 LINK - ) - }) - - // NOTE: Temporarily disabled until contract size can be reduced in another way - // describe('General', () => { - // it('#typeAndVersion', async () => { - // expect(await registry.callStatic.typeAndVersion()).to.be.equal( - // 'FunctionsBillingRegistry 0.0.0', - // ) - // }) - // }) - - describe('Config', () => { - it('non-owner is unable set config', async () => { - await expect( - registry - .connect(roles.stranger) - .setConfig( - config.maxGasLimit, - config.stalenessSeconds, - config.gasAfterPaymentCalculation, - config.weiPerUnitLink, - config.gasOverhead, - config.requestTimeoutSeconds, - ), - ).to.be.revertedWith('OnlyCallableByOwner()') - }) - - it('owner can set config', async () => { - await expect( - registry - .connect(roles.defaultAccount) - .setConfig( - config.maxGasLimit, - config.stalenessSeconds, - config.gasAfterPaymentCalculation, - config.weiPerUnitLink, - config.gasOverhead, - config.requestTimeoutSeconds, - ), - ).not.to.be.reverted - }) - - it('returns the config set on the registry', async () => { - await registry - .connect(roles.defaultAccount) - .setConfig( - config.maxGasLimit, - config.stalenessSeconds, - config.gasAfterPaymentCalculation, - config.weiPerUnitLink, - config.gasOverhead, - config.requestTimeoutSeconds, - ) - - const [ - maxGasLimit, - stalenessSeconds, - gasAfterPaymentCalculation, - weiPerUnitLink, - gasOverhead, - ] = await registry.connect(roles.stranger).getConfig() - - await expect(config.maxGasLimit).to.equal(maxGasLimit) - await expect(config.stalenessSeconds).to.equal(stalenessSeconds) - await expect(config.gasAfterPaymentCalculation).to.equal( - gasAfterPaymentCalculation, - ) - await expect(config.weiPerUnitLink).to.equal(weiPerUnitLink) - await expect(config.gasOverhead).to.equal(gasOverhead) - }) - }) - - describe('DON registration', () => { - it('non-owner is unable to register a DON', async () => { - await expect( - registry.connect(roles.stranger).setAuthorizedSenders([oracle.address]), - ).to.be.revertedWith('OnlyCallableByOwner()') - }) - - it('owner can register a DON', async () => { - await expect( - registry - .connect(roles.defaultAccount) - .setAuthorizedSenders([oracle.address]), - ).not.to.be.reverted - }) - }) - - async function createSubscription( - owner: Signer, - consumers: string[], - ): Promise { - const tx = await registry.connect(owner).createSubscription() - const receipt = await tx.wait() - const subId = receipt.events[0].args['subscriptionId'].toNumber() - for (let i = 0; i < consumers.length; i++) { - await registry.connect(owner).addConsumer(subId, consumers[i]) - } - return subId - } - - describe('Subscription management', () => { - describe('#createSubscription', async function () { - it('can create a subscription', async function () { - await expect(registry.connect(subOwner).createSubscription()) - .to.emit(registry, 'SubscriptionCreated') - .withArgs(1, subOwnerAddress) - const s = await registry.getSubscription(1) - expect(s.balance.toString() == '0', 'invalid balance') - expect(s.owner == subOwnerAddress, 'invalid address') - }) - it('subscription id increments', async function () { - await expect(registry.connect(subOwner).createSubscription()) - .to.emit(registry, 'SubscriptionCreated') - .withArgs(1, subOwnerAddress) - await expect(registry.connect(subOwner).createSubscription()) - .to.emit(registry, 'SubscriptionCreated') - .withArgs(2, subOwnerAddress) - }) - it('cannot create more than the max', async function () { - const subId = createSubscription(subOwner, []) - for (let i = 0; i < 100; i++) { - await registry - .connect(subOwner) - .addConsumer(subId, randomAddressString()) - } - await expect( - registry.connect(subOwner).addConsumer(subId, randomAddressString()), - ).to.be.revertedWith(`TooManyConsumers()`) - }) - }) - - describe('#requestSubscriptionOwnerTransfer', async function () { - let subId: number - beforeEach(async () => { - subId = await createSubscription(subOwner, [consumerAddress]) - }) - it('rejects non-owner', async function () { - await expect( - registry - .connect(roles.stranger) - .requestSubscriptionOwnerTransfer(subId, strangerAddress), - ).to.be.revertedWith(`MustBeSubOwner("${subOwnerAddress}")`) - }) - it('owner can request transfer', async function () { - await expect( - registry - .connect(subOwner) - .requestSubscriptionOwnerTransfer(subId, strangerAddress), - ) - .to.emit(registry, 'SubscriptionOwnerTransferRequested') - .withArgs(subId, subOwnerAddress, strangerAddress) - // Same request is a noop - await expect( - registry - .connect(subOwner) - .requestSubscriptionOwnerTransfer(subId, strangerAddress), - ).to.not.emit(registry, 'SubscriptionOwnerTransferRequested') - }) - }) - - describe('#acceptSubscriptionOwnerTransfer', async function () { - let subId: number - beforeEach(async () => { - subId = await createSubscription(subOwner, [consumerAddress]) - }) - it('subscription must exist', async function () { - await expect( - registry - .connect(subOwner) - .acceptSubscriptionOwnerTransfer(1203123123), - ).to.be.revertedWith(`InvalidSubscription`) - }) - it('must be requested owner to accept', async function () { - await expect( - registry - .connect(subOwner) - .requestSubscriptionOwnerTransfer(subId, strangerAddress), - ) - await expect( - registry.connect(subOwner).acceptSubscriptionOwnerTransfer(subId), - ).to.be.revertedWith(`MustBeRequestedOwner("${strangerAddress}")`) - }) - it('requested owner can accept', async function () { - await expect( - registry - .connect(subOwner) - .requestSubscriptionOwnerTransfer(subId, strangerAddress), - ) - .to.emit(registry, 'SubscriptionOwnerTransferRequested') - .withArgs(subId, subOwnerAddress, strangerAddress) - await expect( - registry.connect(stranger).acceptSubscriptionOwnerTransfer(subId), - ) - .to.emit(registry, 'SubscriptionOwnerTransferred') - .withArgs(subId, subOwnerAddress, strangerAddress) - }) - }) - - describe('#addConsumer', async function () { - let subId: number - beforeEach(async () => { - subId = await createSubscription(subOwner, [consumerAddress]) - }) - it('subscription must exist', async function () { - await expect( - registry.connect(subOwner).addConsumer(1203123123, strangerAddress), - ).to.be.revertedWith(`InvalidSubscription`) - }) - it('must be owner', async function () { - await expect( - registry.connect(stranger).addConsumer(subId, strangerAddress), - ).to.be.revertedWith(`MustBeSubOwner("${subOwnerAddress}")`) - }) - it('add is idempotent', async function () { - await registry.connect(subOwner).addConsumer(subId, strangerAddress) - await registry.connect(subOwner).addConsumer(subId, strangerAddress) - }) - it('cannot add more than maximum', async function () { - // There is one consumer, add another 99 to hit the max - for (let i = 0; i < 99; i++) { - await registry - .connect(subOwner) - .addConsumer(subId, randomAddressString()) - } - // Adding one more should fail - // await registry.connect(subOwner).addConsumer(subId, strangerAddress); - await expect( - registry.connect(subOwner).addConsumer(subId, strangerAddress), - ).to.be.revertedWith(`TooManyConsumers()`) - // Same is true if we first create with the maximum - const consumers: string[] = [] - for (let i = 0; i < 100; i++) { - consumers.push(randomAddressString()) - } - subId = await createSubscription(subOwner, consumers) - await expect( - registry.connect(subOwner).addConsumer(subId, strangerAddress), - ).to.be.revertedWith(`TooManyConsumers()`) - }) - it('owner can update', async function () { - await expect( - registry.connect(subOwner).addConsumer(subId, strangerAddress), - ) - .to.emit(registry, 'SubscriptionConsumerAdded') - .withArgs(subId, strangerAddress) - }) - }) - - describe('#removeConsumer', async function () { - let subId: number - beforeEach(async () => { - subId = await createSubscription(subOwner, [consumerAddress]) - }) - it('subscription must exist', async function () { - await expect( - registry - .connect(subOwner) - .removeConsumer(1203123123, strangerAddress), - ).to.be.revertedWith(`InvalidSubscription`) - }) - it('must be owner', async function () { - await expect( - registry.connect(stranger).removeConsumer(subId, strangerAddress), - ).to.be.revertedWith(`MustBeSubOwner("${subOwnerAddress}")`) - }) - it('owner can update', async function () { - const subBefore = await registry.getSubscription(subId) - await registry.connect(subOwner).addConsumer(subId, strangerAddress) - await expect( - registry.connect(subOwner).removeConsumer(subId, strangerAddress), - ) - .to.emit(registry, 'SubscriptionConsumerRemoved') - .withArgs(subId, strangerAddress) - const subAfter = await registry.getSubscription(subId) - // Subscription should NOT contain the removed consumer - expect(subBefore.consumers).to.deep.equal(subAfter.consumers) - }) - it('can remove all consumers', async function () { - // Testing the handling of zero. - await registry.connect(subOwner).addConsumer(subId, strangerAddress) - await registry.connect(subOwner).removeConsumer(subId, strangerAddress) - await registry.connect(subOwner).removeConsumer(subId, consumerAddress) - // Should be empty - const subAfter = await registry.getSubscription(subId) - expect(subAfter.consumers).to.deep.equal([]) - }) - }) - - describe('#pendingRequestExists', async function () { - let subId: number - beforeEach(async () => { - subId = await createSubscription(subOwner, [consumerAddress]) - await registry.setConfig( - config.maxGasLimit, - config.stalenessSeconds, - config.gasAfterPaymentCalculation, - config.weiPerUnitLink, - config.gasOverhead, - config.requestTimeoutSeconds, - ) - - await linkToken - .connect(subOwner) - .transferAndCall( - registry.address, - BigNumber.from('130790416713017745'), - ethers.utils.defaultAbiCoder.encode(['uint64'], [subId]), - ) - await registry.connect(subOwner).addConsumer(subId, client.address) - await registry.connect(roles.defaultAccount).reg - await registry.setAuthorizedSenders([oracle.address]) - }) - it('returns false when there is no latest pending request', async function () { - expect(await registry.connect(subOwner).pendingRequestExists(subId)).to - .be.false - }) - it('returns true when the latest request is pending', async function () { - await client - .connect(consumer) - .sendSimpleRequestWithJavaScript(`return 'hello world'`, subId) - expect(await registry.connect(subOwner).pendingRequestExists(subId)).to - .be.true - }) - }) - - describe('#cancelSubscription', async function () { - let subId: number - beforeEach(async () => { - subId = await createSubscription(subOwner, [consumerAddress]) - }) - it('subscription must exist', async function () { - await expect( - registry - .connect(subOwner) - .cancelSubscription(1203123123, subOwnerAddress), - ).to.be.revertedWith(`InvalidSubscription`) - }) - it('must be owner', async function () { - await expect( - registry.connect(stranger).cancelSubscription(subId, subOwnerAddress), - ).to.be.revertedWith(`MustBeSubOwner("${subOwnerAddress}")`) - }) - it('can cancel', async function () { - await linkToken - .connect(subOwner) - .transferAndCall( - registry.address, - BigNumber.from('1000'), - ethers.utils.defaultAbiCoder.encode(['uint64'], [subId]), - ) - await expect( - registry.connect(subOwner).cancelSubscription(subId, strangerAddress), - ) - .to.emit(registry, 'SubscriptionCanceled') - .withArgs(subId, strangerAddress, BigNumber.from('1000')) - const strangerBalance = await linkToken.balanceOf(strangerAddress) - expect(strangerBalance.toString()).to.equal('1000000000000001000') - await expect( - registry.connect(subOwner).getSubscription(subId), - ).to.be.revertedWith('InvalidSubscription') - }) - it('can add same consumer after canceling', async function () { - await linkToken - .connect(subOwner) - .transferAndCall( - registry.address, - BigNumber.from('1000'), - ethers.utils.defaultAbiCoder.encode(['uint64'], [subId]), - ) - await registry.connect(subOwner).addConsumer(subId, strangerAddress) - await registry - .connect(subOwner) - .cancelSubscription(subId, strangerAddress) - subId = await createSubscription(subOwner, [consumerAddress]) - // The cancel should have removed this consumer, so we can add it again. - await registry.connect(subOwner).addConsumer(subId, strangerAddress) - }) - it('cannot cancel with pending request', async function () { - await registry.setConfig( - config.maxGasLimit, - config.stalenessSeconds, - config.gasAfterPaymentCalculation, - config.weiPerUnitLink, - config.gasOverhead, - config.requestTimeoutSeconds, - ) - - await linkToken - .connect(subOwner) - .transferAndCall( - registry.address, - BigNumber.from('130790416713017745'), - ethers.utils.defaultAbiCoder.encode(['uint64'], [subId]), - ) - await registry.connect(subOwner).addConsumer(subId, client.address) - await registry.connect(roles.defaultAccount).reg - await registry.setAuthorizedSenders([oracle.address]) - await client - .connect(consumer) - .sendSimpleRequestWithJavaScript(`return 'hello world'`, subId) - // Should revert with outstanding requests - await expect( - registry.connect(subOwner).cancelSubscription(subId, strangerAddress), - ).to.be.revertedWith('PendingRequestExists()') - // However the owner is able to cancel - // funds go to the sub owner. - await expect( - registry.connect(roles.defaultAccount).ownerCancelSubscription(subId), - ) - .to.emit(registry, 'SubscriptionCanceled') - .withArgs( - subId, - subOwnerAddress, - BigNumber.from('130790416713017745'), - ) - }) - }) - - describe('#recoverFunds', async function () { - let subId: number - beforeEach(async () => { - subId = await createSubscription(subOwner, [consumerAddress]) - }) - - it('function that should change internal balance do', async function () { - type bf = [() => Promise, BigNumber] - const balanceChangingFns: Array = [ - [ - async function () { - const s = ethers.utils.defaultAbiCoder.encode(['uint64'], [subId]) - await linkToken - .connect(subOwner) - .transferAndCall(registry.address, BigNumber.from('1000'), s) - }, - BigNumber.from('1000'), - ], - [ - async function () { - await registry - .connect(subOwner) - .cancelSubscription(subId, strangerAddress) - }, - BigNumber.from('-1000'), - ], - ] - for (const [fn, expectedBalanceChange] of balanceChangingFns) { - const startingBalance = await registry.getTotalBalance() - await fn() - const endingBalance = await registry.getTotalBalance() - expect( - endingBalance.sub(startingBalance).toString() == - expectedBalanceChange.toString(), - ) - } - }) - it('only owner can recover', async function () { - await expect( - registry.connect(subOwner).recoverFunds(strangerAddress), - ).to.be.revertedWith('OnlyCallableByOwner()') - }) - - it('owner can recover link transferred', async function () { - // Set the internal balance - expect(BigNumber.from('0'), linkToken.balanceOf(strangerAddress)) - const s = ethers.utils.defaultAbiCoder.encode(['uint64'], [subId]) - await linkToken - .connect(subOwner) - .transferAndCall(registry.address, BigNumber.from('1000'), s) - // Circumvent internal balance - await linkToken - .connect(subOwner) - .transfer(registry.address, BigNumber.from('1000')) - // Should recover this 1000 - await expect( - registry.connect(roles.defaultAccount).recoverFunds(strangerAddress), - ) - .to.emit(registry, 'FundsRecovered') - .withArgs(strangerAddress, BigNumber.from('1000')) - expect(BigNumber.from('1000'), linkToken.balanceOf(strangerAddress)) - }) - }) - }) - - describe('#startBilling', () => { - let subId: number - - beforeEach(async () => { - await registry.setAuthorizedSenders([oracle.address]) - - await registry.setConfig( - config.maxGasLimit, - config.stalenessSeconds, - config.gasAfterPaymentCalculation, - config.weiPerUnitLink, - config.gasOverhead, - config.requestTimeoutSeconds, - ) - - subId = await createSubscription(subOwner, [consumerAddress]) - - await linkToken - .connect(subOwner) - .transferAndCall( - registry.address, - BigNumber.from('54666805176129187'), - ethers.utils.defaultAbiCoder.encode(['uint64'], [subId]), - ) - await registry.connect(subOwner).addConsumer(subId, client.address) - await registry.connect(roles.defaultAccount).reg - }) - - it('only callable by registered DONs', async () => { - await expect( - registry.connect(consumer).startBilling(stringToHex('some data'), { - requester: consumerAddress, - client: consumerAddress, - subscriptionId: subId, - gasPrice: 20_000, - gasLimit: 20_000, - confirmations: 50, - }), - ).to.be.revertedWith(`reverted with custom error 'UnauthorizedSender()'`) - }) - - it('a subscription can only be used by a subscription consumer', async () => { - await expect( - oracle - .connect(stranger) - .sendRequest(subId, stringToBytes('some data'), 0), - ).to.be.revertedWith( - `reverted with custom error 'InvalidConsumer(${subId}, "${strangerAddress}")`, - ) - await expect( - client - .connect(consumer) - .sendSimpleRequestWithJavaScript(`return 'hello world'`, subId), - ).to.not.be.reverted - }) - - it('fails if the subscription does not have the funds for the estimated cost', async () => { - const subId = await createSubscription(subOwner, [subOwnerAddress]) - await registry.connect(subOwner).addConsumer(subId, client.address) - - await expect( - client - .connect(subOwner) - .sendSimpleRequestWithJavaScript(`return 'hello world'`, subId), - ).to.be.revertedWith(`InsufficientBalance()`) - }) - - it('when successful, emits an event', async () => { - await expect( - client - .connect(consumer) - .sendSimpleRequestWithJavaScript(`return 'hello world'`, subId), - ).to.emit(registry, 'BillingStart') - }) - - it('fails multiple requests if the subscription does not have the funds for the estimated cost', async () => { - client - .connect(consumer) - .sendSimpleRequestWithJavaScript(`return 'hello world'`, subId, { - gasPrice: 1000000008, - }) - - await expect( - client - .connect(subOwner) - .sendSimpleRequestWithJavaScript(`return 'hello world'`, subId, { - gasPrice: 1000000008, - }), - ).to.be.revertedWith(`InsufficientBalance()`) - }) - }) - - describe('#fulfillAndBill', () => { - let subId: number - let requestId: string - - beforeEach(async () => { - subId = await createSubscription(subOwner, [consumerAddress]) - - await registry.setConfig( - config.maxGasLimit, - config.stalenessSeconds, - config.gasAfterPaymentCalculation, - config.weiPerUnitLink, - config.gasOverhead, - config.requestTimeoutSeconds, - ) - - await linkToken - .connect(subOwner) - .transferAndCall( - registry.address, - BigNumber.from('1000000000000000000'), - ethers.utils.defaultAbiCoder.encode(['uint64'], [subId]), - ) - await registry.connect(subOwner).addConsumer(subId, client.address) - await registry.connect(roles.defaultAccount).reg - await registry.setAuthorizedSenders([oracle.address]) - - const request = await client - .connect(consumer) - .sendSimpleRequestWithJavaScript(`return 'hello world'`, subId) - requestId = (await request.wait()).events[3].args[0] - }) - - it('only callable by registered DONs', async () => { - const someAddress = randomAddressString() - const someSigners = Array(31).fill(ethers.constants.AddressZero) - someSigners[0] = someAddress - await expect( - registry - .connect(consumer) - .fulfillAndBill( - ethers.utils.hexZeroPad(requestId, 32), - stringToHex('some data'), - stringToHex('some data'), - someAddress, - someSigners, - 1, - 10, - 0, - ), - ).to.be.revertedWith('UnauthorizedSender()') - }) - - it('when successful, emits an event', async () => { - const report = encodeReport( - ethers.utils.hexZeroPad(requestId, 32), - stringToHex('hello world'), - stringToHex(''), - ) - await expect( - oracle - .connect(roles.oracleNode) - .callReport(report, { gasLimit: 500_000 }), - ).to.emit(registry, 'BillingEnd') - }) - - it('validates request ID', async () => { - const unknown = - '0x67c6a2e151d4352a55021b5d0028c18121cfc24c7d73b179d22b17eeeeeeeeee' - const report = encodeReport( - ethers.utils.hexZeroPad(unknown, 32), - stringToHex('hello world'), - stringToHex(''), - ) - await expect( - oracle - .connect(roles.oracleNode) - .callReport(report, { gasLimit: 500_000 }), - ).to.emit(oracle, 'InvalidRequestID') - }) - - it('pays the transmitter the expected amount', async () => { - const oracleBalanceBefore = await linkToken.balanceOf( - await roles.oracleNode.getAddress(), - ) - const [subscriptionBalanceBefore] = await registry.getSubscription(subId) - - const report = encodeReport( - ethers.utils.hexZeroPad(requestId, 32), - stringToHex('hello world'), - stringToHex(''), - ) - - const transmitter = await roles.oracleNode.getAddress() - - await expect( - oracle - .connect(roles.oracleNode) - .callReport(report, { gasLimit: 500_000 }), - ) - .to.emit(oracle, 'OracleResponse') - .withArgs(requestId) - .to.emit(oracle, 'ResponseTransmitted') - .withArgs(requestId, transmitter) - .to.emit(registry, 'BillingEnd') - .to.emit(client, 'FulfillRequestInvoked') - - await registry - .connect(roles.oracleNode) - .oracleWithdraw( - await roles.oracleNode.getAddress(), - BigNumber.from('0'), - ) - - const oracleBalanceAfter = await linkToken.balanceOf( - await roles.oracleNode.getAddress(), - ) - const [subscriptionBalanceAfter] = await registry.getSubscription(subId) - - expect(subscriptionBalanceBefore.gt(subscriptionBalanceAfter)).to.be.true - expect(oracleBalanceAfter.gt(oracleBalanceBefore)).to.be.true - expect(subscriptionBalanceBefore.sub(subscriptionBalanceAfter)).to.equal( - oracleBalanceAfter.sub(oracleBalanceBefore), - ) - }) - }) - - describe('#oracleWithdraw', async function () { - it('cannot withdraw with no balance', async function () { - await expect( - registry - .connect(roles.oracleNode) - .oracleWithdraw(randomAddressString(), BigNumber.from('100')), - ).to.be.revertedWith(`InsufficientBalance`) - }) - }) -}) diff --git a/contracts/test/v0.8/functions/v0/FunctionsBillingRegistryUpgradeable.test.ts b/contracts/test/v0.8/functions/v0/FunctionsBillingRegistryUpgradeable.test.ts deleted file mode 100644 index 5de99864525..00000000000 --- a/contracts/test/v0.8/functions/v0/FunctionsBillingRegistryUpgradeable.test.ts +++ /dev/null @@ -1,249 +0,0 @@ -import { ethers, upgrades } from 'hardhat' -import { expect } from 'chai' -import { BigNumber, Contract, ContractFactory, Signer } from 'ethers' -import { Roles, getUsers } from '../../../test-helpers/setup' - -let functionsOracleFactory: ContractFactory -let clientTestHelperFactory: ContractFactory -let functionsBillingRegistryFactory: ContractFactory -let linkTokenFactory: ContractFactory -let mockAggregatorV3Factory: ContractFactory -let roles: Roles -let subOwner: Signer -let subOwnerAddress: string -let consumer: Signer -let consumerAddress: string -let stranger: Signer -let strangerAddress: string - -const stringToHex = (s: string) => { - return ethers.utils.hexlify(ethers.utils.toUtf8Bytes(s)) -} - -const encodeReport = (requestId: string, result: string, err: string) => { - const abi = ethers.utils.defaultAbiCoder - return abi.encode( - ['bytes32[]', 'bytes[]', 'bytes[]'], - [[requestId], [result], [err]], - ) -} - -const fundedLink = '1000000000000000000' -const linkEth = BigNumber.from(5021530000000000) - -type RegistryConfig = { - maxGasLimit: number - stalenessSeconds: number - gasAfterPaymentCalculation: number - weiPerUnitLink: BigNumber - gasOverhead: number - requestTimeoutSeconds: number -} -const config: RegistryConfig = { - maxGasLimit: 1_000_000, - stalenessSeconds: 86_400, - gasAfterPaymentCalculation: - 21_000 + 5_000 + 2_100 + 20_000 + 2 * 2_100 - 15_000 + 7_315, - weiPerUnitLink: BigNumber.from('5000000000000000'), - gasOverhead: 100_000, - requestTimeoutSeconds: 300, -} - -before(async () => { - roles = (await getUsers()).roles - - functionsOracleFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleHelper.sol:FunctionsOracleHelper', - roles.defaultAccount, - ) - - clientTestHelperFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsClientTestHelper.sol:FunctionsClientTestHelper', - roles.consumer, - ) - - functionsBillingRegistryFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsBillingRegistryOriginal.sol:FunctionsBillingRegistryOriginal', - roles.consumer, - ) - - linkTokenFactory = await ethers.getContractFactory( - 'src/v0.8/mocks/MockLinkToken.sol:MockLinkToken', - roles.consumer, - ) - - mockAggregatorV3Factory = await ethers.getContractFactory( - 'src/v0.8/tests/MockV3Aggregator.sol:MockV3Aggregator', - roles.consumer, - ) -}) - -describe('FunctionsRegistryUpgradeable', () => { - let registry: Contract - let oracle: Contract - let client: Contract - let linkToken: Contract - let mockLinkEth: Contract - - beforeEach(async () => { - const { roles } = await getUsers() - subOwner = roles.consumer - subOwnerAddress = await subOwner.getAddress() - consumer = roles.consumer2 - consumerAddress = await consumer.getAddress() - stranger = roles.stranger - strangerAddress = await stranger.getAddress() - - // Deploy - linkToken = await linkTokenFactory.connect(roles.defaultAccount).deploy() - mockLinkEth = await mockAggregatorV3Factory.deploy(0, linkEth) - oracle = await functionsOracleFactory.connect(roles.defaultAccount).deploy() - registry = await upgrades.deployProxy( - functionsBillingRegistryFactory.connect(roles.defaultAccount), - [linkToken.address, mockLinkEth.address, oracle.address], - ) - client = await clientTestHelperFactory - .connect(roles.consumer) - .deploy(oracle.address) - - // Setup contracts - await oracle.setRegistry(registry.address) - await oracle.deactivateAuthorizedReceiver() - - // Setup accounts - await linkToken.transfer( - subOwnerAddress, - BigNumber.from(fundedLink), // 1 LINK - ) - await linkToken.transfer( - strangerAddress, - BigNumber.from(fundedLink), // 1 LINK - ) - }) - - async function createSubscription( - owner: Signer, - consumers: string[], - ): Promise { - const tx = await registry.connect(owner).createSubscription() - const receipt = await tx.wait() - const subId = receipt.events[0].args['subscriptionId'].toNumber() - for (let i = 0; i < consumers.length; i++) { - await registry.connect(owner).addConsumer(subId, consumers[i]) - } - return subId - } - - describe('Upgrades', () => { - let subId: number - let requestId: string - - async function migrateAndCheck(factoryPath: string): Promise { - // Upgrade the implementation contract a new version - const functionsBillingRegistryMigrationFactory = - await ethers.getContractFactory(factoryPath, roles.consumer) - - const upgradedRegistry = await upgrades.upgradeProxy( - registry.address, - functionsBillingRegistryMigrationFactory.connect(roles.defaultAccount), - ) - - // Check config is the same - const currentConfig = await upgradedRegistry.getConfig() - expect(currentConfig.maxGasLimit).to.equal(config.maxGasLimit) - expect(currentConfig.stalenessSeconds).to.equal(config.stalenessSeconds) - expect(currentConfig.gasAfterPaymentCalculation).to.equal( - config.gasAfterPaymentCalculation, - ) - expect(currentConfig.fallbackWeiPerUnitLink).to.equal( - config.weiPerUnitLink, - ) - expect(currentConfig.gasOverhead).to.equal(config.gasOverhead) - - // Check funds are the same - const subscription = await upgradedRegistry.getSubscription(subId) - expect(subscription.balance).to.equal(fundedLink) - - // Check request fulfillment still works - const report = encodeReport( - ethers.utils.hexZeroPad(requestId, 32), - stringToHex('hello world'), - stringToHex(''), - ) - await expect( - oracle - .connect(roles.oracleNode) - .callReport(report, { gasLimit: 500_000 }), - ).to.emit(registry, 'BillingEnd') - - return upgradedRegistry - } - - beforeEach(async () => { - subId = await createSubscription(subOwner, [consumerAddress]) - - await registry.setConfig( - config.maxGasLimit, - config.stalenessSeconds, - config.gasAfterPaymentCalculation, - config.weiPerUnitLink, - config.gasOverhead, - config.requestTimeoutSeconds, - ) - - await linkToken - .connect(subOwner) - .transferAndCall( - registry.address, - BigNumber.from('1000000000000000000'), - ethers.utils.defaultAbiCoder.encode(['uint64'], [subId]), - ) - await registry.connect(subOwner).addConsumer(subId, client.address) - await registry.connect(roles.defaultAccount).reg - await registry.setAuthorizedSenders([oracle.address]) - - const request = await client - .connect(consumer) - .sendSimpleRequestWithJavaScript(`return 'hello world'`, subId) - requestId = (await request.wait()).events[3].args[0] - }) - - it('is successful when deployed behind a proxy', async () => { - const report = encodeReport( - ethers.utils.hexZeroPad(requestId, 32), - stringToHex('hello world'), - stringToHex(''), - ) - await expect( - oracle - .connect(roles.oracleNode) - .callReport(report, { gasLimit: 500_000 }), - ).to.emit(registry, 'BillingEnd') - }) - - it('can be upgraded to a new implementation', async () => { - const upgradedRegistry = await migrateAndCheck( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/mocks/FunctionsBillingRegistryMigration.sol:FunctionsBillingRegistryMigration', - ) - - // Check that upgrade was successful - const dummyRequest = [ - '0x', - { - subscriptionId: subId, - client: client.address, - gasLimit: 0, - gasPrice: 0, - }, - ] - const registryFee = await upgradedRegistry.getRequiredFee(...dummyRequest) - expect(registryFee).to.equal(1) - }) - - it('can be upgraded to the latest implementation', async () => { - await migrateAndCheck( - 'src/v0.8/functions/dev/v0_0_0/FunctionsBillingRegistry.sol:FunctionsBillingRegistry', - ) - }) - }) -}) diff --git a/contracts/test/v0.8/functions/v0/FunctionsClient.test.ts b/contracts/test/v0.8/functions/v0/FunctionsClient.test.ts deleted file mode 100644 index 94b06d8b37e..00000000000 --- a/contracts/test/v0.8/functions/v0/FunctionsClient.test.ts +++ /dev/null @@ -1,205 +0,0 @@ -import { ethers } from 'hardhat' -import { assert, expect } from 'chai' -import { Contract, ContractFactory, providers } from 'ethers' -import { Roles, getUsers } from '../../../test-helpers/setup' -import { decodeDietCBOR, stringToBytes } from '../../../test-helpers/helpers' - -let concreteFunctionsClientFactory: ContractFactory -let functionsOracleFactory: ContractFactory -let functionsBillingRegistryFactory: ContractFactory -let linkTokenFactory: ContractFactory -let mockAggregatorV3Factory: ContractFactory -let roles: Roles - -function getEventArg(events: any, eventName: string, argIndex: number) { - if (Array.isArray(events)) { - const event = events.find((e: any) => e.event == eventName) - if (event && Array.isArray(event.args) && event.args.length > 0) { - return event.args[argIndex] - } - } - return undefined -} - -async function parseOracleRequestEventArgs(tx: providers.TransactionResponse) { - const receipt = await tx.wait() - const data = receipt.logs?.[1].data - return ethers.utils.defaultAbiCoder.decode( - ['address', 'address', 'uint64', 'address', 'bytes'], - data ?? '', - ) -} - -before(async () => { - roles = (await getUsers()).roles - - concreteFunctionsClientFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsClientTestHelper.sol:FunctionsClientTestHelper', - roles.defaultAccount, - ) - functionsOracleFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleHelper.sol:FunctionsOracleHelper', - roles.defaultAccount, - ) - - functionsBillingRegistryFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsBillingRegistryWithInit.sol:FunctionsBillingRegistryWithInit', - roles.defaultAccount, - ) - - linkTokenFactory = await ethers.getContractFactory( - 'src/v0.8/mocks/MockLinkToken.sol:MockLinkToken', - roles.consumer, - ) - - mockAggregatorV3Factory = await ethers.getContractFactory( - 'src/v0.8/tests/MockV3Aggregator.sol:MockV3Aggregator', - roles.consumer, - ) -}) - -describe('FunctionsClientTestHelper', () => { - const donPublicKey = - '0x3804a19f2437f7bba4fcfbc194379e43e514aa98073db3528ccdbdb642e24011' - let subscriptionId: number - const anyValue = () => true - - let client: Contract - let oracle: Contract - let registry: Contract - let linkToken: Contract - let mockLinkEth: Contract - - beforeEach(async () => { - // Deploy - linkToken = await linkTokenFactory.connect(roles.defaultAccount).deploy() - mockLinkEth = await mockAggregatorV3Factory.deploy( - 0, - ethers.BigNumber.from(5021530000000000), - ) - oracle = await functionsOracleFactory.connect(roles.defaultAccount).deploy() - registry = await functionsBillingRegistryFactory - .connect(roles.defaultAccount) - .deploy(linkToken.address, mockLinkEth.address, oracle.address) - - // Setup contracts - await oracle.setRegistry(registry.address) - await oracle.deactivateAuthorizedReceiver() - client = await concreteFunctionsClientFactory - .connect(roles.defaultAccount) - .deploy(oracle.address) - await registry.setAuthorizedSenders([oracle.address]) - - await registry.setConfig( - 1_000_000, - 86_400, - 21_000 + 5_000 + 2_100 + 20_000 + 2 * 2_100 - 15_000 + 7_315, - ethers.BigNumber.from('5000000000000000'), - 100_000, - 300, - ) - - // Setup accounts - const createSubTx = await registry - .connect(roles.defaultAccount) - .createSubscription() - const receipt = await createSubTx.wait() - subscriptionId = receipt.events[0].args['subscriptionId'].toNumber() - - await registry - .connect(roles.defaultAccount) - .addConsumer(subscriptionId, client.address) - - await linkToken - .connect(roles.defaultAccount) - .transferAndCall( - registry.address, - ethers.BigNumber.from('115957983815660167'), - ethers.utils.defaultAbiCoder.encode(['uint64'], [subscriptionId]), - ) - }) - - describe('#getDONPublicKey', () => { - it('returns DON public key set on Oracle', async () => { - await expect(oracle.setDONPublicKey(donPublicKey)).not.to.be.reverted - expect(await client.callStatic.getDONPublicKey()).to.be.equal( - donPublicKey, - ) - }) - }) - - describe('#sendSimpleRequestWithJavaScript', () => { - it('emits events from the client and the oracle contracts', async () => { - await expect( - client - .connect(roles.defaultAccount) - .sendSimpleRequestWithJavaScript('function run() {}', subscriptionId), - ) - .to.emit(client, 'RequestSent') - .withArgs(anyValue) - .to.emit(oracle, 'OracleRequest') - .withArgs( - anyValue, - client.address, - await roles.defaultAccount.getAddress(), - subscriptionId, - await roles.defaultAccount.getAddress(), - anyValue, - ) - }) - - it('encodes user request to CBOR', async () => { - const js = 'function run() {}' - const tx = await client.sendSimpleRequestWithJavaScript( - js, - subscriptionId, - ) - const args = await parseOracleRequestEventArgs(tx) - assert.equal(5, args.length) - const decoded = await decodeDietCBOR(args[4]) - assert.deepEqual( - { - ...decoded, - language: decoded.language.toNumber(), - codeLocation: decoded.codeLocation.toNumber(), - }, - { - language: 0, - codeLocation: 0, - source: js, - }, - ) - }) - }) - - describe('#fulfillRequest', () => { - it('emits fulfillment events', async () => { - const tx = await client.sendSimpleRequestWithJavaScript( - 'function run(){return response}', - subscriptionId, - ) - - const { events } = await tx.wait() - const requestId = getEventArg(events, 'RequestSent', 0) - await expect(tx).to.emit(client, 'RequestSent').withArgs(requestId) - - const response = stringToBytes('response') - const error = stringToBytes('') - const abi = ethers.utils.defaultAbiCoder - - const report = abi.encode( - ['bytes32[]', 'bytes[]', 'bytes[]'], - [[ethers.utils.hexZeroPad(requestId, 32)], [response], [error]], - ) - - await expect(oracle.callReport(report, { gasLimit: 300_000 })) - .to.emit(oracle, 'OracleResponse') - .withArgs(requestId) - .to.emit(oracle, 'ResponseTransmitted') - .withArgs(requestId, anyValue) - .to.emit(registry, 'BillingEnd') - .to.emit(client, 'FulfillRequestInvoked') - .withArgs(requestId, response, error) - }) - }) -}) diff --git a/contracts/test/v0.8/functions/v0/FunctionsOracle.test.ts b/contracts/test/v0.8/functions/v0/FunctionsOracle.test.ts deleted file mode 100644 index 397cc3b397f..00000000000 --- a/contracts/test/v0.8/functions/v0/FunctionsOracle.test.ts +++ /dev/null @@ -1,537 +0,0 @@ -import { ethers } from 'hardhat' -import { expect } from 'chai' -import { BigNumber, Contract, ContractFactory } from 'ethers' -import { Roles, getUsers } from '../../../test-helpers/setup' - -let functionsOracleFactory: ContractFactory -let clientTestHelperFactory: ContractFactory -let functionsBillingRegistryFactory: ContractFactory -let linkTokenFactory: ContractFactory -let mockAggregatorV3Factory: ContractFactory -let roles: Roles - -const stringToHex = (s: string) => { - return ethers.utils.hexlify(ethers.utils.toUtf8Bytes(s)) -} - -const anyValue = () => true - -const encodeReport = (requestId: string, result: string, err: string) => { - const abi = ethers.utils.defaultAbiCoder - return abi.encode( - ['bytes32[]', 'bytes[]', 'bytes[]'], - [[requestId], [result], [err]], - ) -} - -before(async () => { - roles = (await getUsers()).roles - - functionsOracleFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleHelper.sol:FunctionsOracleHelper', - roles.defaultAccount, - ) - - clientTestHelperFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsClientTestHelper.sol:FunctionsClientTestHelper', - roles.consumer, - ) - - functionsBillingRegistryFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsBillingRegistryWithInit.sol:FunctionsBillingRegistryWithInit', - roles.defaultAccount, - ) - - linkTokenFactory = await ethers.getContractFactory( - 'src/v0.8/mocks/MockLinkToken.sol:MockLinkToken', - roles.consumer, - ) - - mockAggregatorV3Factory = await ethers.getContractFactory( - 'src/v0.8/tests/MockV3Aggregator.sol:MockV3Aggregator', - roles.consumer, - ) -}) - -describe('FunctionsOracle', () => { - let subscriptionId: number - const donPublicKey = - '0x3804a19f2437f7bba4fcfbc194379e43e514aa98073db3528ccdbdb642e24011' - let client: Contract - let oracle: Contract - let registry: Contract - let linkToken: Contract - let mockLinkEth: Contract - let transmitters: string[] - - beforeEach(async () => { - // Deploy contracts - linkToken = await linkTokenFactory.connect(roles.defaultAccount).deploy() - mockLinkEth = await mockAggregatorV3Factory.deploy( - 0, - ethers.BigNumber.from(5021530000000000), - ) - oracle = await functionsOracleFactory.connect(roles.defaultAccount).deploy() - registry = await functionsBillingRegistryFactory - .connect(roles.defaultAccount) - .deploy(linkToken.address, mockLinkEth.address, oracle.address) - - // Setup contracts - await oracle.setRegistry(registry.address) - await oracle.deactivateAuthorizedReceiver() - client = await clientTestHelperFactory - .connect(roles.defaultAccount) - .deploy(oracle.address) - await registry.setAuthorizedSenders([oracle.address]) - - await registry.setConfig( - 1_000_000, // maxGasLimit - 86_400, // stalenessSeconds - 39_173 /* gasAfterPaymentCalculation - gathered by taking the difference from gasleft() directly after payment calculation, and then again after the BillingEnd event, using a hardhat console log - */, - ethers.BigNumber.from('5000000000000000'), // fallbackWeiPerUnitLink - 519_719 /* gasOverhead - gathered by taking the difference from initialGas and gasleft() directly after payment calculation, adding back the user's callback gas usage, using a hardhat console log - NOTE: this number can vary slightly by number of nodes on the DON - */, - 300, // requestTimeoutSeconds - ) - - // Setup accounts - const createSubTx = await registry - .connect(roles.defaultAccount) - .createSubscription() - const receipt = await createSubTx.wait() - subscriptionId = receipt.events[0].args['subscriptionId'].toNumber() - - await registry - .connect(roles.defaultAccount) - .addConsumer(subscriptionId, await roles.defaultAccount.getAddress()) - - await registry - .connect(roles.defaultAccount) - .addConsumer(subscriptionId, client.address) - - await linkToken - .connect(roles.defaultAccount) - .transferAndCall( - registry.address, - ethers.BigNumber.from('300938394174049741'), - ethers.utils.defaultAbiCoder.encode(['uint64'], [subscriptionId]), - ) - - const signers = Array.from( - [0, 0, 0, 0], - (_) => ethers.Wallet.createRandom().address, - ) - transmitters = [ - await roles.oracleNode1.getAddress(), - await roles.oracleNode2.getAddress(), - await roles.oracleNode3.getAddress(), - await roles.oracleNode4.getAddress(), - ] - await oracle.setConfig(signers, transmitters, 1, [], 1, []) - }) - - describe('General', () => { - it('#typeAndVersion', async () => { - expect(await oracle.callStatic.typeAndVersion()).to.be.equal( - 'FunctionsOracle 0.0.0', - ) - }) - - it('returns DON public key set on this Oracle', async () => { - await expect(oracle.setDONPublicKey(donPublicKey)).not.to.be.reverted - expect(await oracle.callStatic.getDONPublicKey()).to.be.equal( - donPublicKey, - ) - }) - - it('reverts setDONPublicKey for empty data', async () => { - const emptyPublicKey = stringToHex('') - await expect(oracle.setDONPublicKey(emptyPublicKey)).to.be.revertedWith( - 'EmptyPublicKey', - ) - }) - - async function validatePubKeys( - expectedNodes: string[], - expectedKeys: string[], - ) { - const allNodesAndKeys = await oracle.getAllNodePublicKeys() - for (let i = 0; i < expectedNodes.length; i++) { - expect(allNodesAndKeys[0][i]).to.be.equal(expectedNodes[i]) - expect(allNodesAndKeys[1][i]).to.be.equal(expectedKeys[i]) - } - } - - it('set/delete/get node public keys', async () => { - const emptyKey = stringToHex('') - const publicKey2 = stringToHex('key420') - const publicKey3 = stringToHex('key666') - - await oracle.setNodePublicKey(roles.oracleNode2.getAddress(), publicKey2) - await oracle.setNodePublicKey(roles.oracleNode3.getAddress(), publicKey3) - validatePubKeys(transmitters, [ - emptyKey, - publicKey2, - publicKey3, - emptyKey, - ]) - - await oracle.deleteNodePublicKey(roles.oracleNode1.getAddress()) - await oracle.deleteNodePublicKey(roles.oracleNode2.getAddress()) - validatePubKeys(transmitters, [emptyKey, emptyKey, publicKey3, emptyKey]) - }) - - it('reverts setNodePublicKey for unauthorized callers', async () => { - const pubKey = stringToHex('abcd') - - await expect( - oracle - .connect(roles.defaultAccount) - .setNodePublicKey(roles.oracleNode2.getAddress(), pubKey), - ).not.to.be.reverted - - await expect( - oracle - .connect(roles.consumer) - .setNodePublicKey(roles.oracleNode2.getAddress(), pubKey), - ).to.be.revertedWith('UnauthorizedPublicKeyChange') - - await expect( - oracle - .connect(roles.consumer) - .setNodePublicKey(roles.consumer.getAddress(), pubKey), - ).to.be.revertedWith('UnauthorizedPublicKeyChange') - - await expect( - oracle - .connect(roles.oracleNode2) - .setNodePublicKey(roles.oracleNode3.getAddress(), pubKey), - ).to.be.revertedWith('UnauthorizedPublicKeyChange') - - await expect( - oracle - .connect(roles.oracleNode2) - .setNodePublicKey(roles.oracleNode2.getAddress(), pubKey), - ).not.to.be.reverted - }) - - it('reverts deleteNodePublicKey for unauthorized callers', async () => { - await expect( - oracle - .connect(roles.defaultAccount) - .deleteNodePublicKey(roles.oracleNode2.getAddress()), - ).not.to.be.reverted - - await expect( - oracle - .connect(roles.consumer) - .deleteNodePublicKey(roles.oracleNode2.getAddress()), - ).to.be.revertedWith('UnauthorizedPublicKeyChange') - - await expect( - oracle - .connect(roles.consumer) - .deleteNodePublicKey(roles.consumer.getAddress()), - ).not.to.be.reverted - }) - }) - - describe('Sending requests', () => { - it('#sendRequest emits OracleRequest event', async () => { - const data = stringToHex('some data') - await expect(oracle.sendRequest(subscriptionId, data, 0)) - .to.emit(oracle, 'OracleRequest') - .withArgs( - anyValue, - await roles.defaultAccount.getAddress(), - await roles.defaultAccount.getAddress(), - subscriptionId, - await roles.defaultAccount.getAddress(), - data, - ) - }) - - it('#sendRequest reverts for empty data', async () => { - const data = stringToHex('') - await expect( - oracle.sendRequest(subscriptionId, data, 0), - ).to.be.revertedWith('EmptyRequestData') - }) - - it('#sendRequest returns non-empty requestId', async () => { - const data = stringToHex('test data') - const requestId = await oracle.callStatic.sendRequest( - subscriptionId, - data, - 0, - ) - expect(requestId).not.to.be.empty - }) - - it('#sendRequest returns different requestIds', async () => { - const data = stringToHex('test data') - const requestId1 = await oracle.callStatic.sendRequest( - subscriptionId, - data, - 0, - ) - await expect(oracle.sendRequest(subscriptionId, data, 0)) - .to.emit(oracle, 'OracleRequest') - .withArgs( - anyValue, - await roles.defaultAccount.getAddress(), - await roles.defaultAccount.getAddress(), - subscriptionId, - await roles.defaultAccount.getAddress(), - data, - ) - const requestId2 = await oracle.callStatic.sendRequest( - subscriptionId, - data, - 0, - ) - expect(requestId1).not.to.be.equal(requestId2) - }) - }) - - describe('Fulfilling requests', () => { - const placeTestRequest = async () => { - const requestId = await client - .connect(roles.oracleNode) - .callStatic.sendSimpleRequestWithJavaScript( - 'function(){}', - subscriptionId, - ) - await expect( - client - .connect(roles.oracleNode) - .sendSimpleRequestWithJavaScript('function(){}', subscriptionId), - ) - .to.emit(client, 'RequestSent') - .withArgs(requestId) - return requestId - } - - it('#fulfillRequest emits an error for unknown requestId', async () => { - const requestId = - '0x67c6a2e151d4352a55021b5d0028c18121cfc24c7d73b179d22b17daff069c6e' - - const report = encodeReport( - ethers.utils.hexZeroPad(requestId, 32), - stringToHex('response'), - stringToHex(''), - ) - - await expect(oracle.callReport(report)).to.emit( - oracle, - 'InvalidRequestID', - ) - }) - - it('#fulfillRequest emits OracleResponse and ResponseTransmitted', async () => { - const requestId = await placeTestRequest() - - const report = encodeReport( - ethers.utils.hexZeroPad(requestId, 32), - stringToHex('response'), - stringToHex(''), - ) - - const transmitter = await roles.oracleNode.getAddress() - - await expect(oracle.connect(roles.oracleNode).callReport(report)) - .to.emit(oracle, 'OracleResponse') - .withArgs(requestId) - .to.emit(oracle, 'ResponseTransmitted') - .withArgs(requestId, transmitter) - }) - - it('#estimateCost correctly estimates cost [ @skip-coverage ]', async () => { - const [subscriptionBalanceBefore] = - await registry.getSubscription(subscriptionId) - - const request = await client - .connect(roles.oracleNode) - .sendSimpleRequestWithJavaScript('function(){}', subscriptionId) - const receipt = await request.wait() - const requestId = receipt.events[3].args[0] - - const report = encodeReport( - ethers.utils.hexZeroPad(requestId, 32), - stringToHex('response'), - stringToHex(''), - ) - - const transmitter = await roles.oracleNode.getAddress() - - await expect(oracle.connect(roles.oracleNode).callReport(report)) - .to.emit(oracle, 'OracleResponse') - .withArgs(requestId) - .to.emit(oracle, 'ResponseTransmitted') - .withArgs(requestId, transmitter) - .to.emit(registry, 'BillingEnd') - - const [subscriptionBalanceAfter] = - await registry.getSubscription(subscriptionId) - - const feeData = await ethers.provider.getFeeData() - const estimatedCost = await client.estimateJuelCost( - 'function(){}', - subscriptionId, - feeData.gasPrice ?? BigNumber.from(0), - ) - // Expect charged amount to be +-0.01% - expect( - subscriptionBalanceBefore.sub(subscriptionBalanceAfter), - ).to.be.below(estimatedCost.add(estimatedCost.div(100))) - expect( - subscriptionBalanceBefore.sub(subscriptionBalanceAfter), - ).to.be.above(estimatedCost.sub(estimatedCost.div(100))) - }) - - it('#fulfillRequest emits UserCallbackError if callback reverts', async () => { - const requestId = await placeTestRequest() - - const report = encodeReport( - ethers.utils.hexZeroPad(requestId, 32), - stringToHex('response'), - stringToHex(''), - ) - - const transmitter = await roles.oracleNode.getAddress() - - await client.setRevertFulfillRequest(true) - - await expect(oracle.connect(roles.oracleNode).callReport(report)) - .to.emit(oracle, 'UserCallbackError') - .withArgs(requestId, anyValue) - .to.emit(oracle, 'ResponseTransmitted') - .withArgs(requestId, transmitter) - }) - - it('#fulfillRequest emits UserCallbackError if callback does invalid op', async () => { - const requestId = await placeTestRequest() - - const report = encodeReport( - ethers.utils.hexZeroPad(requestId, 32), - stringToHex('response'), - stringToHex(''), - ) - - const transmitter = await roles.oracleNode.getAddress() - - await client.setDoInvalidOperation(true) - - await expect(oracle.connect(roles.oracleNode).callReport(report)) - .to.emit(oracle, 'UserCallbackError') - .withArgs(requestId, anyValue) - .to.emit(oracle, 'ResponseTransmitted') - .withArgs(requestId, transmitter) - }) - - it('#fulfillRequest invokes client fulfillRequest', async () => { - const requestId = await placeTestRequest() - - const report = encodeReport( - ethers.utils.hexZeroPad(requestId, 32), - stringToHex('response'), - stringToHex('err'), - ) - - await expect(oracle.connect(roles.oracleNode).callReport(report)) - .to.emit(client, 'FulfillRequestInvoked') - .withArgs(requestId, stringToHex('response'), stringToHex('err')) - }) - - it('#fulfillRequest invalidates requestId', async () => { - const requestId = await placeTestRequest() - - const report = encodeReport( - ethers.utils.hexZeroPad(requestId, 32), - stringToHex('response'), - stringToHex('err'), - ) - - await expect(oracle.connect(roles.oracleNode).callReport(report)) - .to.emit(client, 'FulfillRequestInvoked') - .withArgs(requestId, stringToHex('response'), stringToHex('err')) - - // for second fulfill the requestId becomes invalid - await expect(oracle.connect(roles.oracleNode).callReport(report)) - .to.emit(oracle, 'InvalidRequestID') - .withArgs(requestId) - }) - - it('#_report reverts for inconsistent encoding', async () => { - const requestId = await placeTestRequest() - - const abi = ethers.utils.defaultAbiCoder - const report = abi.encode( - ['bytes32[]', 'bytes[]', 'bytes[]'], - [[requestId], [], []], - ) - - await expect( - oracle.connect(roles.oracleNode).callReport(report), - ).to.be.revertedWith('ReportInvalid()') - }) - - it('#_report handles multiple reports', async () => { - const requestId1 = await placeTestRequest() - const requestId2 = await placeTestRequest() - const result1 = stringToHex('result1') - const result2 = stringToHex('result2') - const err = stringToHex('') - - const abi = ethers.utils.defaultAbiCoder - const report = abi.encode( - ['bytes32[]', 'bytes[]', 'bytes[]'], - [ - [requestId1, requestId2], - [result1, result2], - [err, err], - ], - ) - - await expect( - oracle - .connect(roles.oracleNode) - .callReport(report, { gasLimit: 300_000 }), - ) - .to.emit(client, 'FulfillRequestInvoked') - .withArgs(requestId1, result1, err) - .to.emit(client, 'FulfillRequestInvoked') - .withArgs(requestId2, result2, err) - }) - - it('#_report handles multiple failures', async () => { - const requestId1 = await placeTestRequest() - const requestId2 = await placeTestRequest() - const result1 = stringToHex('result1') - const result2 = stringToHex('result2') - const err = stringToHex('') - - const abi = ethers.utils.defaultAbiCoder - const report = abi.encode( - ['bytes32[]', 'bytes[]', 'bytes[]'], - [ - [requestId1, requestId2], - [result1, result2], - [err, err], - ], - ) - - await client.setRevertFulfillRequest(true) - - await expect(oracle.connect(roles.oracleNode).callReport(report)) - .to.emit(oracle, 'UserCallbackError') - .withArgs(requestId1, anyValue) - .to.emit(oracle, 'UserCallbackError') - .withArgs(requestId2, anyValue) - }) - }) -}) diff --git a/contracts/test/v0.8/functions/v0/FunctionsOracleUpgradeable.test.ts b/contracts/test/v0.8/functions/v0/FunctionsOracleUpgradeable.test.ts deleted file mode 100644 index fe2dfdc9c3e..00000000000 --- a/contracts/test/v0.8/functions/v0/FunctionsOracleUpgradeable.test.ts +++ /dev/null @@ -1,247 +0,0 @@ -import { ethers, upgrades } from 'hardhat' -import { expect } from 'chai' -import { BigNumber, Contract, ContractFactory } from 'ethers' -import { Roles, getUsers } from '../../../test-helpers/setup' - -let functionsOracleOriginalFactory: ContractFactory -let clientTestHelperFactory: ContractFactory -let functionsBillingRegistryFactory: ContractFactory -let linkTokenFactory: ContractFactory -let mockAggregatorV3Factory: ContractFactory -let roles: Roles - -const stringToHex = (s: string) => { - return ethers.utils.hexlify(ethers.utils.toUtf8Bytes(s)) -} - -const encodeReport = (requestId: string, result: string, err: string) => { - const abi = ethers.utils.defaultAbiCoder - return abi.encode( - ['bytes32[]', 'bytes[]', 'bytes[]'], - [[requestId], [result], [err]], - ) -} - -type RegistryConfig = { - maxGasLimit: number - stalenessSeconds: number - gasAfterPaymentCalculation: number - weiPerUnitLink: BigNumber - gasOverhead: number - requestTimeoutSeconds: number -} -const config: RegistryConfig = { - maxGasLimit: 1_000_000, - stalenessSeconds: 86_400, - gasAfterPaymentCalculation: - 21_000 + 5_000 + 2_100 + 20_000 + 2 * 2_100 - 15_000 + 7_315, - weiPerUnitLink: BigNumber.from('5000000000000000'), - gasOverhead: 100_000, - requestTimeoutSeconds: 300, -} - -before(async () => { - roles = (await getUsers()).roles - - functionsOracleOriginalFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleOriginalHelper.sol:FunctionsOracleOriginalHelper', - roles.defaultAccount, - ) - - clientTestHelperFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsClientTestHelper.sol:FunctionsClientTestHelper', - roles.consumer, - ) - - functionsBillingRegistryFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsBillingRegistryWithInit.sol:FunctionsBillingRegistryWithInit', - roles.defaultAccount, - ) - - linkTokenFactory = await ethers.getContractFactory( - 'src/v0.8/mocks/MockLinkToken.sol:MockLinkToken', - roles.consumer, - ) - - mockAggregatorV3Factory = await ethers.getContractFactory( - 'src/v0.8/tests/MockV3Aggregator.sol:MockV3Aggregator', - roles.consumer, - ) -}) - -describe('FunctionsOracleUpgradeable', () => { - let subscriptionId: number - let client: Contract - let oracle: Contract - let registry: Contract - let linkToken: Contract - let mockLinkEth: Contract - let transmitters: string[] - - beforeEach(async () => { - // Deploy contracts - linkToken = await linkTokenFactory.connect(roles.defaultAccount).deploy() - mockLinkEth = await mockAggregatorV3Factory.deploy( - 0, - ethers.BigNumber.from(5021530000000000), - ) - oracle = await upgrades.deployProxy( - functionsOracleOriginalFactory.connect(roles.defaultAccount), - ) - registry = await functionsBillingRegistryFactory - .connect(roles.defaultAccount) - .deploy(linkToken.address, mockLinkEth.address, oracle.address) - - // Setup contracts - await oracle.setRegistry(registry.address) - await oracle.deactivateAuthorizedReceiver() - client = await clientTestHelperFactory - .connect(roles.defaultAccount) - .deploy(oracle.address) - await registry.setAuthorizedSenders([oracle.address]) - - await registry.setConfig( - config.maxGasLimit, - config.stalenessSeconds, - config.gasAfterPaymentCalculation, - config.weiPerUnitLink, - config.gasOverhead, - config.requestTimeoutSeconds, - ) - - // Setup accounts - const createSubTx = await registry - .connect(roles.defaultAccount) - .createSubscription() - const receipt = await createSubTx.wait() - subscriptionId = receipt.events[0].args['subscriptionId'].toNumber() - - await registry - .connect(roles.defaultAccount) - .addConsumer(subscriptionId, await roles.defaultAccount.getAddress()) - - await registry - .connect(roles.defaultAccount) - .addConsumer(subscriptionId, client.address) - - await linkToken - .connect(roles.defaultAccount) - .transferAndCall( - registry.address, - ethers.BigNumber.from('300938394174049741'), - ethers.utils.defaultAbiCoder.encode(['uint64'], [subscriptionId]), - ) - - const signers = Array.from( - [0, 0, 0, 0], - (_) => ethers.Wallet.createRandom().address, - ) - transmitters = [ - await roles.oracleNode1.getAddress(), - await roles.oracleNode2.getAddress(), - await roles.oracleNode3.getAddress(), - await roles.oracleNode4.getAddress(), - ] - await oracle.setConfig(signers, transmitters, 1, [], 1, []) - }) - - describe('Upgrades', () => { - const placeTestRequest = async () => { - const requestId = await client - .connect(roles.oracleNode) - .callStatic.sendSimpleRequestWithJavaScript( - 'function(){}', - subscriptionId, - ) - await expect( - client - .connect(roles.oracleNode) - .sendSimpleRequestWithJavaScript('function(){}', subscriptionId), - ) - .to.emit(client, 'RequestSent') - .withArgs(requestId) - return requestId - } - - async function migrateAndCheck(factoryPath: string): Promise { - const functionsOracleMigrationFactory = await ethers.getContractFactory( - factoryPath, - roles.consumer, - ) - - // Upgrade the implementation contract - const upgradedOracle = await upgrades.upgradeProxy( - oracle.address, - functionsOracleMigrationFactory.connect(roles.defaultAccount), - ) - - // Check request fulfillment still works - const requestId = await placeTestRequest() - const report = encodeReport( - ethers.utils.hexZeroPad(requestId, 32), - stringToHex('hello world'), - stringToHex(''), - ) - await expect( - upgradedOracle - .connect(roles.oracleNode) - .callReport(report, { gasLimit: 500_000 }), - ).to.emit(registry, 'BillingEnd') - - return upgradedOracle - } - - it('is successful when deployed behind a proxy', async () => { - const requestId1 = await placeTestRequest() - const requestId2 = await placeTestRequest() - const result1 = stringToHex('result1') - const result2 = stringToHex('result2') - const err = stringToHex('') - - const abi = ethers.utils.defaultAbiCoder - const report = abi.encode( - ['bytes32[]', 'bytes[]', 'bytes[]'], - [ - [requestId1, requestId2], - [result1, result2], - [err, err], - ], - ) - - await expect( - oracle - .connect(roles.oracleNode) - .callReport(report, { gasLimit: 300_000 }), - ) - .to.emit(client, 'FulfillRequestInvoked') - .withArgs(requestId1, result1, err) - .to.emit(client, 'FulfillRequestInvoked') - .withArgs(requestId2, result2, err) - }) - - it('can be upgraded to a new implementation', async () => { - const upgradedOracle = await migrateAndCheck( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleMigrationHelper.sol:FunctionsOracleMigrationHelper', - ) - - // Check that upgrade was successful - const dummyRequest = [ - '0x', - { - subscriptionId, - client: client.address, - gasLimit: 0, - gasPrice: 0, - }, - ] - const registryFee = await upgradedOracle.getRequiredFee(...dummyRequest) - expect(registryFee).to.equal(1) - }) - - it('can be upgraded to the latest implementation', async () => { - await migrateAndCheck( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleUpgradeableHelper.sol:FunctionsOracleUpgradeableHelper', - ) - }) - }) -}) diff --git a/contracts/test/v0.8/functions/v0/Gas.test.ts b/contracts/test/v0.8/functions/v0/Gas.test.ts deleted file mode 100644 index affa8052b9f..00000000000 --- a/contracts/test/v0.8/functions/v0/Gas.test.ts +++ /dev/null @@ -1,158 +0,0 @@ -import { ethers } from 'hardhat' -import { expect } from 'chai' -import { Contract, ContractFactory } from 'ethers' -import { Roles, getUsers } from '../../../test-helpers/setup' -import { stringToBytes } from '../../../test-helpers/helpers' - -let concreteFunctionsClientFactory: ContractFactory -let functionsOracleFactory: ContractFactory -let functionsBillingRegistryFactory: ContractFactory -let linkTokenFactory: ContractFactory -let mockAggregatorV3Factory: ContractFactory -let roles: Roles - -function getEventArg(events: any, eventName: string, argIndex: number) { - if (Array.isArray(events)) { - const event = events.find((e: any) => e.event == eventName) - if (event && Array.isArray(event.args) && event.args.length > 0) { - return event.args[argIndex] - } - } - return undefined -} - -const baselineGasUsed = 641560 -let currentGasUsed = 0 - -before(async () => { - roles = (await getUsers()).roles - - concreteFunctionsClientFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsClientTestHelper.sol:FunctionsClientTestHelper', - roles.defaultAccount, - ) - functionsOracleFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsOracleHelper.sol:FunctionsOracleHelper', - roles.defaultAccount, - ) - - functionsBillingRegistryFactory = await ethers.getContractFactory( - 'src/v0.8/functions/tests/v0_0_0/testhelpers/FunctionsBillingRegistryWithInit.sol:FunctionsBillingRegistryWithInit', - roles.defaultAccount, - ) - - linkTokenFactory = await ethers.getContractFactory( - 'src/v0.8/mocks/MockLinkToken.sol:MockLinkToken', - roles.consumer, - ) - - mockAggregatorV3Factory = await ethers.getContractFactory( - 'src/v0.8/tests/MockV3Aggregator.sol:MockV3Aggregator', - roles.consumer, - ) -}) - -after(() => { - const score = currentGasUsed - baselineGasUsed - console.log( - `\n ⛳ Baseline gas used : ${baselineGasUsed} gas`, - ) - console.log(`\n Current gas used : ${currentGasUsed} gas`) - console.log(`\n 🚩 Delta : ${score} gas`) -}) - -let subscriptionId: number - -let client: Contract -let oracle: Contract -let registry: Contract -let linkToken: Contract -let mockLinkEth: Contract - -beforeEach(async () => { - // Deploy - linkToken = await linkTokenFactory.connect(roles.defaultAccount).deploy() - mockLinkEth = await mockAggregatorV3Factory.deploy( - 0, - ethers.BigNumber.from(5021530000000000), - ) - oracle = await functionsOracleFactory.connect(roles.defaultAccount).deploy() - registry = await functionsBillingRegistryFactory - .connect(roles.defaultAccount) - .deploy(linkToken.address, mockLinkEth.address, oracle.address) - - // Setup contracts - await oracle.setRegistry(registry.address) - await oracle.deactivateAuthorizedReceiver() - client = await concreteFunctionsClientFactory - .connect(roles.defaultAccount) - .deploy(oracle.address) - await registry.setAuthorizedSenders([oracle.address]) - - await registry.setConfig( - 1_000_000, - 86_400, - 21_000 + 5_000 + 2_100 + 20_000 + 2 * 2_100 - 15_000 + 7_315, - ethers.BigNumber.from('5000000000000000'), - 100_000, - 300, - ) -}) - -describe('Gas', () => { - it('uses the expected amount of gas', async () => { - // Setup accounts - const createSubTx = await registry - .connect(roles.defaultAccount) - .createSubscription() - const createSubscriptionTxReceipt = await createSubTx.wait() - subscriptionId = - createSubscriptionTxReceipt.events[0].args['subscriptionId'].toNumber() - const createSubscriptionGasUsed = createSubscriptionTxReceipt.gasUsed - - const addConsumerTx = await registry - .connect(roles.defaultAccount) - .addConsumer(subscriptionId, client.address) - const { gasUsed: addConsumerTxGasUsed } = await addConsumerTx.wait() - - const transferAndCallTx = await linkToken - .connect(roles.defaultAccount) - .transferAndCall( - registry.address, - ethers.BigNumber.from('115957983815660167'), - ethers.utils.defaultAbiCoder.encode(['uint64'], [subscriptionId]), - ) - const { gasUsed: transferAndCallTxGasUsed } = await transferAndCallTx.wait() - - const requestTx = await client.sendSimpleRequestWithJavaScript( - 'function run(){return response}', - subscriptionId, - ) - - const { events, gasUsed: requestTxGasUsed } = await requestTx.wait() - const requestId = getEventArg(events, 'RequestSent', 0) - await expect(requestTx).to.emit(client, 'RequestSent').withArgs(requestId) - - const response = stringToBytes('response') - const error = stringToBytes('') - const abi = ethers.utils.defaultAbiCoder - - const report = abi.encode( - ['bytes32[]', 'bytes[]', 'bytes[]'], - [[ethers.utils.hexZeroPad(requestId, 32)], [response], [error]], - ) - - const fulfillmentTx = await oracle.callReport(report, { - gasLimit: 300_000, - }) - - const { gasUsed: fulfillmentTxGasUsed } = await fulfillmentTx.wait() - - currentGasUsed = createSubscriptionGasUsed - .add(addConsumerTxGasUsed) - .add(transferAndCallTxGasUsed) - .add(requestTxGasUsed) - .add(fulfillmentTxGasUsed) - .toNumber() - }) -}) diff --git a/core/bridges/orm_test.go b/core/bridges/orm_test.go index db043393350..b110b4f519d 100644 --- a/core/bridges/orm_test.go +++ b/core/bridges/orm_test.go @@ -5,15 +5,16 @@ import ( "time" "github.com/google/uuid" - "github.com/smartcontractkit/sqlx" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/sqlx" + "github.com/smartcontractkit/chainlink/v2/core/auth" "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/pg" diff --git a/core/chains/evm/chain_test.go b/core/chains/evm/chain_test.go index 09395ff4c97..ba24598ef73 100644 --- a/core/chains/evm/chain_test.go +++ b/core/chains/evm/chain_test.go @@ -4,12 +4,13 @@ import ( "math/big" "testing" - "github.com/smartcontractkit/sqlx" "github.com/stretchr/testify/assert" + "github.com/smartcontractkit/sqlx" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/pg" "github.com/smartcontractkit/chainlink/v2/core/utils" diff --git a/core/chains/evm/config/config_test.go b/core/chains/evm/config/config_test.go index 10984d45d1e..d0f9e846e37 100644 --- a/core/chains/evm/config/config_test.go +++ b/core/chains/evm/config/config_test.go @@ -15,7 +15,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" diff --git a/core/chains/evm/forwarders/forwarder_manager_test.go b/core/chains/evm/forwarders/forwarder_manager_test.go index 0117c2f2c07..082d329e385 100644 --- a/core/chains/evm/forwarders/forwarder_manager_test.go +++ b/core/chains/evm/forwarders/forwarder_manager_test.go @@ -19,7 +19,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/authorized_receiver" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/operator_wrapper" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/chains/evm/headtracker/head_broadcaster_test.go b/core/chains/evm/headtracker/head_broadcaster_test.go index c478920e00e..5c2423f328a 100644 --- a/core/chains/evm/headtracker/head_broadcaster_test.go +++ b/core/chains/evm/headtracker/head_broadcaster_test.go @@ -17,7 +17,7 @@ import ( evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/chains/evm/headtracker/head_listener_test.go b/core/chains/evm/headtracker/head_listener_test.go index 63d22233836..dff97f58436 100644 --- a/core/chains/evm/headtracker/head_listener_test.go +++ b/core/chains/evm/headtracker/head_listener_test.go @@ -17,7 +17,7 @@ import ( evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" diff --git a/core/chains/evm/headtracker/head_saver_test.go b/core/chains/evm/headtracker/head_saver_test.go index 5ab43679f4b..5ed85adc598 100644 --- a/core/chains/evm/headtracker/head_saver_test.go +++ b/core/chains/evm/headtracker/head_saver_test.go @@ -10,7 +10,7 @@ import ( httypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker/types" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" ) diff --git a/core/chains/evm/headtracker/head_tracker_test.go b/core/chains/evm/headtracker/head_tracker_test.go index d30571f331d..502aa4ae6db 100644 --- a/core/chains/evm/headtracker/head_tracker_test.go +++ b/core/chains/evm/headtracker/head_tracker_test.go @@ -29,7 +29,7 @@ import ( evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/chains/evm/headtracker/orm_test.go b/core/chains/evm/headtracker/orm_test.go index 5b106ac1018..123478ff902 100644 --- a/core/chains/evm/headtracker/orm_test.go +++ b/core/chains/evm/headtracker/orm_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/ethereum/go-ethereum/common" diff --git a/core/chains/evm/log/helpers_test.go b/core/chains/evm/log/helpers_test.go index 58e81132b0f..688757a3e96 100644 --- a/core/chains/evm/log/helpers_test.go +++ b/core/chains/evm/log/helpers_test.go @@ -31,7 +31,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/flux_aggregator_wrapper" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/chains/evm/log/orm_test.go b/core/chains/evm/log/orm_test.go index 365bb354338..48524896cf4 100644 --- a/core/chains/evm/log/orm_test.go +++ b/core/chains/evm/log/orm_test.go @@ -12,7 +12,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/pg" diff --git a/core/chains/evm/monitor/balance_test.go b/core/chains/evm/monitor/balance_test.go index dbb2003b695..c80d64e7ef7 100644 --- a/core/chains/evm/monitor/balance_test.go +++ b/core/chains/evm/monitor/balance_test.go @@ -18,7 +18,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/monitor" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" ) diff --git a/core/chains/evm/txmgr/attempts_test.go b/core/chains/evm/txmgr/attempts_test.go index 099143f0ce4..863eae47236 100644 --- a/core/chains/evm/txmgr/attempts_test.go +++ b/core/chains/evm/txmgr/attempts_test.go @@ -19,7 +19,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" diff --git a/core/chains/evm/txmgr/broadcaster_test.go b/core/chains/evm/txmgr/broadcaster_test.go index 6f9308548b3..3901da59eeb 100644 --- a/core/chains/evm/txmgr/broadcaster_test.go +++ b/core/chains/evm/txmgr/broadcaster_test.go @@ -37,7 +37,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest/heavyweight" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/chains/evm/txmgr/confirmer_test.go b/core/chains/evm/txmgr/confirmer_test.go index 32246b06cea..8fbdb7696d9 100644 --- a/core/chains/evm/txmgr/confirmer_test.go +++ b/core/chains/evm/txmgr/confirmer_test.go @@ -33,7 +33,7 @@ import ( evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/chains/evm/txmgr/evm_tx_store.go b/core/chains/evm/txmgr/evm_tx_store.go index 7b1ef8948c1..96963e78d75 100644 --- a/core/chains/evm/txmgr/evm_tx_store.go +++ b/core/chains/evm/txmgr/evm_tx_store.go @@ -1486,14 +1486,20 @@ func (o *evmTxStore) UpdateTxUnstartedToInProgress(ctx context.Context, etx *Tx, // Note: the record of the original abandoned transaction will remain in evm.txes, only the attempt is replaced. (Any receipt // associated with the abandoned attempt would also be lost, although this shouldn't happen since only unconfirmed transactions // can be abandoned.) - _, err := tx.Exec(`DELETE FROM evm.tx_attempts a USING evm.txes t + result, err := tx.Exec(`DELETE FROM evm.tx_attempts a USING evm.txes t WHERE t.id = a.eth_tx_id AND a.hash = $1 AND t.state = $2 AND t.error = 'abandoned'`, attempt.Hash, txmgr.TxFatalError, ) if err == nil { - o.logger.Debugf("Replacing abandoned tx with tx hash %s with tx_id=%d with identical tx hash", attempt.Hash, attempt.TxID) - } else if errors.Is(err, sql.ErrNoRows) { - return err + count, err := result.RowsAffected() + if err != nil { + return pkgerrors.Wrap(err, "UpdateTxUnstartedToInProgress failed to get rows affected") + } + if count > 0 { + o.logger.Debugf("Replacing abandoned tx with tx hash %s with tx_id=%d with identical tx hash", attempt.Hash, attempt.TxID) + } + } else { + return pkgerrors.Wrap(err, "UpdateTxUnstartedToInProgress failed to delete abandoned transactions") } var dbAttempt DbEthTxAttempt diff --git a/core/chains/evm/txmgr/evm_tx_store_test.go b/core/chains/evm/txmgr/evm_tx_store_test.go index e5b47c457b4..ba02f118cf5 100644 --- a/core/chains/evm/txmgr/evm_tx_store_test.go +++ b/core/chains/evm/txmgr/evm_tx_store_test.go @@ -15,7 +15,7 @@ import ( evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/chains/evm/txmgr/nonce_syncer_test.go b/core/chains/evm/txmgr/nonce_syncer_test.go index 13e5fd02e8c..f6480b4c305 100644 --- a/core/chains/evm/txmgr/nonce_syncer_test.go +++ b/core/chains/evm/txmgr/nonce_syncer_test.go @@ -7,7 +7,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/chains/evm/txmgr/reaper_test.go b/core/chains/evm/txmgr/reaper_test.go index 830ed1ac17f..20cc27a675f 100644 --- a/core/chains/evm/txmgr/reaper_test.go +++ b/core/chains/evm/txmgr/reaper_test.go @@ -12,7 +12,7 @@ import ( txmgrmocks "github.com/smartcontractkit/chainlink/v2/common/txmgr/types/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/utils" diff --git a/core/chains/evm/txmgr/resender_test.go b/core/chains/evm/txmgr/resender_test.go index d17156f4525..cc94511e3b0 100644 --- a/core/chains/evm/txmgr/resender_test.go +++ b/core/chains/evm/txmgr/resender_test.go @@ -17,7 +17,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/chains/evm/txmgr/strategies_test.go b/core/chains/evm/txmgr/strategies_test.go index 9c5a1be37f1..765b43e78f2 100644 --- a/core/chains/evm/txmgr/strategies_test.go +++ b/core/chains/evm/txmgr/strategies_test.go @@ -11,7 +11,7 @@ import ( txmgrcommon "github.com/smartcontractkit/chainlink/v2/common/txmgr" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" ) func Test_SendEveryStrategy(t *testing.T) { diff --git a/core/chains/evm/txmgr/txmgr_test.go b/core/chains/evm/txmgr/txmgr_test.go index de8c6ff4ef8..6cb43b27716 100644 --- a/core/chains/evm/txmgr/txmgr_test.go +++ b/core/chains/evm/txmgr/txmgr_test.go @@ -30,7 +30,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/chains/evm/types/models_test.go b/core/chains/evm/types/models_test.go index 683a49692b6..2f9dc7dd7c3 100644 --- a/core/chains/evm/types/models_test.go +++ b/core/chains/evm/types/models_test.go @@ -22,7 +22,7 @@ import ( evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/null" "github.com/smartcontractkit/chainlink/v2/core/utils" diff --git a/core/cmd/app_test.go b/core/cmd/app_test.go index 78331bf7063..bbb00bff3ec 100644 --- a/core/cmd/app_test.go +++ b/core/cmd/app_test.go @@ -9,7 +9,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/config/env" "github.com/smartcontractkit/chainlink/v2/core/config/toml" - testtomlutils "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2/toml" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/store/models" ) @@ -88,7 +88,7 @@ func Test_initServerConfig(t *testing.T) { name: "files only", args: args{ opts: new(chainlink.GeneralConfigOpts), - fileNames: []string{testtomlutils.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, + fileNames: []string{configtest.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, }, wantCfg: withDefaults(t, testConfigFileContents, chainlink.Secrets{}), }, @@ -104,7 +104,7 @@ func Test_initServerConfig(t *testing.T) { name: "env overlay of file", args: args{ opts: new(chainlink.GeneralConfigOpts), - fileNames: []string{testtomlutils.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, + fileNames: []string{configtest.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, envVar: testEnvContents, }, wantCfg: withDefaults(t, chainlink.Config{ @@ -124,7 +124,7 @@ func Test_initServerConfig(t *testing.T) { name: "failed to read secrets", args: args{ opts: new(chainlink.GeneralConfigOpts), - fileNames: []string{testtomlutils.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, + fileNames: []string{configtest.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, secretsFiles: []string{"/doesnt-exist"}, }, wantErr: true, @@ -133,8 +133,8 @@ func Test_initServerConfig(t *testing.T) { name: "reading secrets", args: args{ opts: new(chainlink.GeneralConfigOpts), - fileNames: []string{testtomlutils.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, - secretsFiles: []string{testtomlutils.WriteTOMLFile(t, testSecretsFileContents, "test_secrets.toml")}, + fileNames: []string{configtest.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, + secretsFiles: []string{configtest.WriteTOMLFile(t, testSecretsFileContents, "test_secrets.toml")}, }, wantCfg: withDefaults(t, testConfigFileContents, testSecretsRedactedContents), }, @@ -142,7 +142,7 @@ func Test_initServerConfig(t *testing.T) { name: "reading multiple secrets", args: args{ opts: new(chainlink.GeneralConfigOpts), - fileNames: []string{testtomlutils.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, + fileNames: []string{configtest.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, secretsFiles: []string{ "../services/chainlink/testdata/mergingsecretsdata/secrets-database.toml", "../services/chainlink/testdata/mergingsecretsdata/secrets-password.toml", @@ -159,7 +159,7 @@ func Test_initServerConfig(t *testing.T) { name: "reading multiple secrets with overrides: Database", args: args{ opts: new(chainlink.GeneralConfigOpts), - fileNames: []string{testtomlutils.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, + fileNames: []string{configtest.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, secretsFiles: []string{ "../testdata/mergingsecretsdata/secrets-database.toml", "../testdata/mergingsecretsdata/secrets-database.toml", @@ -171,7 +171,7 @@ func Test_initServerConfig(t *testing.T) { name: "reading multiple secrets with overrides: Password", args: args{ opts: new(chainlink.GeneralConfigOpts), - fileNames: []string{testtomlutils.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, + fileNames: []string{configtest.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, secretsFiles: []string{ "../testdata/mergingsecretsdata/secrets-password.toml", "../testdata/mergingsecretsdata/secrets-password.toml", @@ -183,7 +183,7 @@ func Test_initServerConfig(t *testing.T) { name: "reading multiple secrets with overrides: Pyroscope", args: args{ opts: new(chainlink.GeneralConfigOpts), - fileNames: []string{testtomlutils.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, + fileNames: []string{configtest.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, secretsFiles: []string{ "../testdata/mergingsecretsdata/secrets-pyroscope.toml", "../testdata/mergingsecretsdata/secrets-pyroscope.toml", @@ -195,7 +195,7 @@ func Test_initServerConfig(t *testing.T) { name: "reading multiple secrets with overrides: Prometheus", args: args{ opts: new(chainlink.GeneralConfigOpts), - fileNames: []string{testtomlutils.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, + fileNames: []string{configtest.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, secretsFiles: []string{ "../testdata/mergingsecretsdata/secrets-prometheus.toml", "../testdata/mergingsecretsdata/secrets-prometheus.toml", @@ -207,7 +207,7 @@ func Test_initServerConfig(t *testing.T) { name: "reading multiple secrets with overrides: Mercury", args: args{ opts: new(chainlink.GeneralConfigOpts), - fileNames: []string{testtomlutils.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, + fileNames: []string{configtest.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, secretsFiles: []string{ "../testdata/mergingsecretsdata/secrets-mercury-split-one.toml", "../testdata/mergingsecretsdata/secrets-mercury-split-one.toml", @@ -219,7 +219,7 @@ func Test_initServerConfig(t *testing.T) { name: "reading multiple secrets with overrides: Threshold", args: args{ opts: new(chainlink.GeneralConfigOpts), - fileNames: []string{testtomlutils.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, + fileNames: []string{configtest.WriteTOMLFile(t, testConfigFileContents, "test.toml")}, secretsFiles: []string{ "../testdata/mergingsecretsdata/secrets-threshold.toml", "../testdata/mergingsecretsdata/secrets-threshold.toml", diff --git a/core/cmd/p2p_keys_commands_test.go b/core/cmd/p2p_keys_commands_test.go index cf107ba5071..0407c924575 100644 --- a/core/cmd/p2p_keys_commands_test.go +++ b/core/cmd/p2p_keys_commands_test.go @@ -13,6 +13,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/cmd" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" "github.com/smartcontractkit/chainlink/v2/core/utils" @@ -24,7 +25,7 @@ func TestP2PKeyPresenter_RenderTable(t *testing.T) { var ( id = "1" - peerID = "12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X" + peerID = configtest.DefaultPeerID pubKey = "somepubkey" buffer = bytes.NewBufferString("") r = cmd.RendererTable{Writer: buffer} diff --git a/core/cmd/shell_local_test.go b/core/cmd/shell_local_test.go index be8d5c94056..d70b06f5a98 100644 --- a/core/cmd/shell_local_test.go +++ b/core/cmd/shell_local_test.go @@ -16,7 +16,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest/heavyweight" "github.com/smartcontractkit/chainlink/v2/core/internal/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/cmd/shell_remote_test.go b/core/cmd/shell_remote_test.go index c1d15df9ec8..7f998225f63 100644 --- a/core/cmd/shell_remote_test.go +++ b/core/cmd/shell_remote_test.go @@ -25,7 +25,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/cmd" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest2 "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" @@ -58,7 +58,7 @@ func startNewApplicationV2(t *testing.T, overrideFn func(c *chainlink.Config, s fn(sopts) } - config := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + config := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.JobPipeline.HTTPRequest.DefaultTimeout = models.MustNewDuration(30 * time.Millisecond) f := false c.EVM[0].Enabled = &f diff --git a/core/cmd/shell_test.go b/core/cmd/shell_test.go index 74768a21928..9b87e8fb1da 100644 --- a/core/cmd/shell_test.go +++ b/core/cmd/shell_test.go @@ -19,7 +19,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/cmd" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/logger/audit" diff --git a/core/gethwrappers/functions/go_generate.go b/core/gethwrappers/functions/go_generate.go index 9c389a699e4..0538518da2d 100644 --- a/core/gethwrappers/functions/go_generate.go +++ b/core/gethwrappers/functions/go_generate.go @@ -4,13 +4,6 @@ package gethwrappers // Chainlink Functions (OCR2DR) -// Version 0 (Testnet Beta) -//go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.6/functions/v0_0_0/Functions.abi ../../../contracts/solc/v0.8.6/functions/v0_0_0/Functions.bin OCR2DR ocr2dr -//go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.6/functions/v0_0_0/FunctionsClient.abi ../../../contracts/solc/v0.8.6/functions/v0_0_0/FunctionsClient.bin OCR2DRClient ocr2dr_client -//go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.6/functions/v0_0_0/FunctionsClientExample.abi ../../../contracts/solc/v0.8.6/functions/v0_0_0/FunctionsClientExample.bin OCR2DRClientExample ocr2dr_client_example -//go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.6/functions/v0_0_0/FunctionsOracleWithInit.abi ../../../contracts/solc/v0.8.6/functions/v0_0_0/FunctionsOracleWithInit.bin OCR2DROracle ocr2dr_oracle -//go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.6/functions/v0_0_0/FunctionsBillingRegistryWithInit.abi ../../../contracts/solc/v0.8.6/functions/v0_0_0/FunctionsBillingRegistryWithInit.bin OCR2DRRegistry ocr2dr_registry - // Version 1 (Mainnet Preview) //go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.19/functions/v1_X/FunctionsRequest.abi ../../../contracts/solc/v0.8.19/functions/v1_X/FunctionsRequest.bin Functions functions //go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.19/functions/v1_X/FunctionsClient.abi ../../../contracts/solc/v0.8.19/functions/v1_X/FunctionsClient.bin FunctionsClient functions_client diff --git a/integration-tests/contracts/ethereum/KeeperConsumerPerformance.go b/core/gethwrappers/generated/keeper_consumer_performance_wrapper/keeper_consumer_performance_wrapper.go similarity index 57% rename from integration-tests/contracts/ethereum/KeeperConsumerPerformance.go rename to core/gethwrappers/generated/keeper_consumer_performance_wrapper/keeper_consumer_performance_wrapper.go index 23cbef7c2a3..0e1876ce0a2 100644 --- a/integration-tests/contracts/ethereum/KeeperConsumerPerformance.go +++ b/core/gethwrappers/generated/keeper_consumer_performance_wrapper/keeper_consumer_performance_wrapper.go @@ -1,10 +1,11 @@ // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package ethereum +package keeper_consumer_performance_wrapper import ( "errors" + "fmt" "math/big" "strings" @@ -14,9 +15,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated" ) -// Reference imports to suppress errors if they are not otherwise used. var ( _ = errors.New _ = big.NewInt @@ -26,23 +27,18 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription + _ = abi.ConvertType ) -// KeeperConsumerPerformanceMetaData contains all meta data concerning the KeeperConsumerPerformance contract. var KeeperConsumerPerformanceMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_testRange\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_averageEligibilityCadence\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_checkGasToBurn\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_performGasToBurn\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"eligible\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"initialCall\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"nextEligible\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"PerformingUpkeep\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"averageEligibilityCadence\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"checkEligible\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"checkGasToBurn\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"checkUpkeep\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"dummyMap\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCountPerforms\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialCall\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nextEligible\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"performGasToBurn\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"performUpkeep\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"reset\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"setCheckGasToBurn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"setPerformGasToBurn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_newTestRange\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_newAverageEligibilityCadence\",\"type\":\"uint256\"}],\"name\":\"setSpread\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"testRange\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", - Bin: "0x6080604052600080556000600155600060075534801561001e57600080fd5b506040516105f03803806105f08339818101604052608081101561004157600080fd5b5080516020820151604083015160609093015160029290925560035560049190915560055561057b806100756000396000f3fe608060405234801561001057600080fd5b50600436106100e05760003560e01c80637145f11b116100875780637145f11b146102b05780637f407edf146102e1578063926f086e14610304578063a9a4c57c1461030c578063b30566b414610314578063c228a98e1461031c578063d826f88f14610324578063e303666f1461032c576100e0565b806306661abd146100e557806313bda75b146100ff5780632555d2cf1461011e5780632ff3617d1461013b5780634585e33b14610143578063523d9b8a146101b15780636250a13a146101b95780636e04ff0d146101c1575b600080fd5b6100ed610334565b60408051918252519081900360200190f35b61011c6004803603602081101561011557600080fd5b503561033a565b005b61011c6004803603602081101561013457600080fd5b503561033f565b6100ed610344565b61011c6004803603602081101561015957600080fd5b810190602081018135600160201b81111561017357600080fd5b82018360208201111561018557600080fd5b803590602001918460018302840111600160201b831117156101a657600080fd5b50909250905061034a565b6100ed610425565b6100ed61042b565b61022f600480360360208110156101d757600080fd5b810190602081018135600160201b8111156101f157600080fd5b82018360208201111561020357600080fd5b803590602001918460018302840111600160201b8311171561022457600080fd5b509092509050610431565b60405180831515815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561027457818101518382015260200161025c565b50505050905090810190601f1680156102a15780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b6102cd600480360360208110156102c657600080fd5b503561049f565b604080519115158252519081900360200190f35b61011c600480360360408110156102f757600080fd5b50803590602001356104b4565b6100ed6104bf565b6100ed6104c5565b6100ed6104cb565b6102cd6104d1565b61011c6104e0565b6100ed6104ea565b60075481565b600455565b600555565b60045481565b60005a905060006103596104f0565b60005460015460408051841515815232602082015280820193909352606083019190915243608083018190529051929350917fbd6b6608a51477954e8b498c633bda87e5cd555e06ead50486398d9e3b9cebc09181900360a00190a1816103bf57600080fd5b6000546103cc5760008190555b6003546002026103da610514565b816103e157fe5b068101600190810181556007805490910190555b6005545a8403101561041e5743406000908152600660205260409020805460ff191690556103f5565b5050505050565b60015481565b60025481565b6000606060005a905060005b6004545a8303101561046d578080156104665750434060009081526006602052604090205460ff165b905061043d565b6104756104f0565b60408051921515602080850191909152815180850390910181529281019052969095509350505050565b60066020526000908152604090205460ff1681565b600291909155600355565b60005481565b60035481565b60055481565b60006104db6104f0565b905090565b6000808055600755565b60075490565b6000805415806104db575060025460005443031080156104db575050600154431190565b604080516000194301406020808301919091523082840152825180830384018152606090920190925280519101209056fea2646970667358221220e233009b46ad9b01fb692930a06d8a04abee3578625455b4761ede5e8ae7489e64736f6c63430007060033", + Bin: "0x6080604052600080556000600155600060075534801561001e57600080fd5b5060405161070438038061070483398101604081905261003d91610054565b60029390935560039190915560045560055561008a565b6000806000806080858703121561006a57600080fd5b505082516020840151604085015160609095015191969095509092509050565b61066b806100996000396000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c80637145f11b11610097578063b30566b411610066578063b30566b4146101f6578063c228a98e146101ff578063d826f88f14610207578063e303666f1461021457600080fd5b80637145f11b146101985780637f407edf146101cb578063926f086e146101e4578063a9a4c57c146101ed57600080fd5b80634585e33b116100d35780634585e33b14610152578063523d9b8a146101655780636250a13a1461016e5780636e04ff0d1461017757600080fd5b806306661abd1461010557806313bda75b146101215780632555d2cf146101365780632ff3617d14610149575b600080fd5b61010e60075481565b6040519081526020015b60405180910390f35b61013461012f366004610430565b600455565b005b610134610144366004610430565b600555565b61010e60045481565b610134610160366004610449565b61021c565b61010e60015481565b61010e60025481565b61018a610185366004610449565b610342565b6040516101189291906104bb565b6101bb6101a6366004610430565b60066020526000908152604090205460ff1681565b6040519015158152602001610118565b6101346101d9366004610531565b600291909155600355565b61010e60005481565b61010e60035481565b61010e60055481565b6101bb6103b7565b6101346000808055600755565b60075461010e565b60005a9050600061022b6103c6565b60005460015460408051841515815232602082015290810192909252606082015243608082018190529192507fbd6b6608a51477954e8b498c633bda87e5cd555e06ead50486398d9e3b9cebc09060a00160405180910390a18161028e57600080fd5b60005460000361029e5760008190555b6003546102ac906002610582565b6102b46103f2565b6102be91906105bf565b6102c890826105fa565b6102d39060016105fa565b600155600780549060006102e683610613565b91905055505b6005545a6102fa908561064b565b101561033b574340600090815260066020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556102ec565b5050505050565b6000606060005a905060005b6004545a61035c908461064b565b10156103865780801561037f5750434060009081526006602052604090205460ff165b905061034e565b61038e6103c6565b604080518315156020820152016040516020818303038152906040529350935050509250929050565b60006103c16103c6565b905090565b6000805415806103c157506002546000546103e1904361064b565b1080156103c1575050600154431190565b60006103ff60014361064b565b604080519140602083015230908201526060016040516020818303038152906040528051906020012060001c905090565b60006020828403121561044257600080fd5b5035919050565b6000806020838503121561045c57600080fd5b823567ffffffffffffffff8082111561047457600080fd5b818501915085601f83011261048857600080fd5b81358181111561049757600080fd5b8660208285010111156104a957600080fd5b60209290920196919550909350505050565b821515815260006020604081840152835180604085015260005b818110156104f1578581018301518582016060015282016104d5565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116850101925050509392505050565b6000806040838503121561054457600080fd5b50508035926020909101359150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156105ba576105ba610553565b500290565b6000826105f5577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500690565b8082018082111561060d5761060d610553565b92915050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361064457610644610553565b5060010190565b8181038181111561060d5761060d61055356fea164736f6c6343000810000a", } -// KeeperConsumerPerformanceABI is the input ABI used to generate the binding from. -// Deprecated: Use KeeperConsumerPerformanceMetaData.ABI instead. var KeeperConsumerPerformanceABI = KeeperConsumerPerformanceMetaData.ABI -// KeeperConsumerPerformanceBin is the compiled bytecode used for deploying new contracts. -// Deprecated: Use KeeperConsumerPerformanceMetaData.Bin instead. var KeeperConsumerPerformanceBin = KeeperConsumerPerformanceMetaData.Bin -// DeployKeeperConsumerPerformance deploys a new Ethereum contract, binding an instance of KeeperConsumerPerformance to it. func DeployKeeperConsumerPerformance(auth *bind.TransactOpts, backend bind.ContractBackend, _testRange *big.Int, _averageEligibilityCadence *big.Int, _checkGasToBurn *big.Int, _performGasToBurn *big.Int) (common.Address, *types.Transaction, *KeeperConsumerPerformance, error) { parsed, err := KeeperConsumerPerformanceMetaData.GetAbi() if err != nil { @@ -59,75 +55,66 @@ func DeployKeeperConsumerPerformance(auth *bind.TransactOpts, backend bind.Contr return address, tx, &KeeperConsumerPerformance{KeeperConsumerPerformanceCaller: KeeperConsumerPerformanceCaller{contract: contract}, KeeperConsumerPerformanceTransactor: KeeperConsumerPerformanceTransactor{contract: contract}, KeeperConsumerPerformanceFilterer: KeeperConsumerPerformanceFilterer{contract: contract}}, nil } -// KeeperConsumerPerformance is an auto generated Go binding around an Ethereum contract. type KeeperConsumerPerformance struct { - KeeperConsumerPerformanceCaller // Read-only binding to the contract - KeeperConsumerPerformanceTransactor // Write-only binding to the contract - KeeperConsumerPerformanceFilterer // Log filterer for contract events + address common.Address + abi abi.ABI + KeeperConsumerPerformanceCaller + KeeperConsumerPerformanceTransactor + KeeperConsumerPerformanceFilterer } -// KeeperConsumerPerformanceCaller is an auto generated read-only Go binding around an Ethereum contract. type KeeperConsumerPerformanceCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls + contract *bind.BoundContract } -// KeeperConsumerPerformanceTransactor is an auto generated write-only Go binding around an Ethereum contract. type KeeperConsumerPerformanceTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls + contract *bind.BoundContract } -// KeeperConsumerPerformanceFilterer is an auto generated log filtering Go binding around an Ethereum contract events. type KeeperConsumerPerformanceFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls + contract *bind.BoundContract } -// KeeperConsumerPerformanceSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. type KeeperConsumerPerformanceSession struct { - Contract *KeeperConsumerPerformance // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session + Contract *KeeperConsumerPerformance + CallOpts bind.CallOpts + TransactOpts bind.TransactOpts } -// KeeperConsumerPerformanceCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. type KeeperConsumerPerformanceCallerSession struct { - Contract *KeeperConsumerPerformanceCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session + Contract *KeeperConsumerPerformanceCaller + CallOpts bind.CallOpts } -// KeeperConsumerPerformanceTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. type KeeperConsumerPerformanceTransactorSession struct { - Contract *KeeperConsumerPerformanceTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session + Contract *KeeperConsumerPerformanceTransactor + TransactOpts bind.TransactOpts } -// KeeperConsumerPerformanceRaw is an auto generated low-level Go binding around an Ethereum contract. type KeeperConsumerPerformanceRaw struct { - Contract *KeeperConsumerPerformance // Generic contract binding to access the raw methods on + Contract *KeeperConsumerPerformance } -// KeeperConsumerPerformanceCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. type KeeperConsumerPerformanceCallerRaw struct { - Contract *KeeperConsumerPerformanceCaller // Generic read-only contract binding to access the raw methods on + Contract *KeeperConsumerPerformanceCaller } -// KeeperConsumerPerformanceTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. type KeeperConsumerPerformanceTransactorRaw struct { - Contract *KeeperConsumerPerformanceTransactor // Generic write-only contract binding to access the raw methods on + Contract *KeeperConsumerPerformanceTransactor } -// NewKeeperConsumerPerformance creates a new instance of KeeperConsumerPerformance, bound to a specific deployed contract. func NewKeeperConsumerPerformance(address common.Address, backend bind.ContractBackend) (*KeeperConsumerPerformance, error) { + abi, err := abi.JSON(strings.NewReader(KeeperConsumerPerformanceABI)) + if err != nil { + return nil, err + } contract, err := bindKeeperConsumerPerformance(address, backend, backend, backend) if err != nil { return nil, err } - return &KeeperConsumerPerformance{KeeperConsumerPerformanceCaller: KeeperConsumerPerformanceCaller{contract: contract}, KeeperConsumerPerformanceTransactor: KeeperConsumerPerformanceTransactor{contract: contract}, KeeperConsumerPerformanceFilterer: KeeperConsumerPerformanceFilterer{contract: contract}}, nil + return &KeeperConsumerPerformance{address: address, abi: abi, KeeperConsumerPerformanceCaller: KeeperConsumerPerformanceCaller{contract: contract}, KeeperConsumerPerformanceTransactor: KeeperConsumerPerformanceTransactor{contract: contract}, KeeperConsumerPerformanceFilterer: KeeperConsumerPerformanceFilterer{contract: contract}}, nil } -// NewKeeperConsumerPerformanceCaller creates a new read-only instance of KeeperConsumerPerformance, bound to a specific deployed contract. func NewKeeperConsumerPerformanceCaller(address common.Address, caller bind.ContractCaller) (*KeeperConsumerPerformanceCaller, error) { contract, err := bindKeeperConsumerPerformance(address, caller, nil, nil) if err != nil { @@ -136,7 +123,6 @@ func NewKeeperConsumerPerformanceCaller(address common.Address, caller bind.Cont return &KeeperConsumerPerformanceCaller{contract: contract}, nil } -// NewKeeperConsumerPerformanceTransactor creates a new write-only instance of KeeperConsumerPerformance, bound to a specific deployed contract. func NewKeeperConsumerPerformanceTransactor(address common.Address, transactor bind.ContractTransactor) (*KeeperConsumerPerformanceTransactor, error) { contract, err := bindKeeperConsumerPerformance(address, nil, transactor, nil) if err != nil { @@ -145,7 +131,6 @@ func NewKeeperConsumerPerformanceTransactor(address common.Address, transactor b return &KeeperConsumerPerformanceTransactor{contract: contract}, nil } -// NewKeeperConsumerPerformanceFilterer creates a new log filterer instance of KeeperConsumerPerformance, bound to a specific deployed contract. func NewKeeperConsumerPerformanceFilterer(address common.Address, filterer bind.ContractFilterer) (*KeeperConsumerPerformanceFilterer, error) { contract, err := bindKeeperConsumerPerformance(address, nil, nil, filterer) if err != nil { @@ -154,56 +139,38 @@ func NewKeeperConsumerPerformanceFilterer(address common.Address, filterer bind. return &KeeperConsumerPerformanceFilterer{contract: contract}, nil } -// bindKeeperConsumerPerformance binds a generic wrapper to an already deployed contract. func bindKeeperConsumerPerformance(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(KeeperConsumerPerformanceABI)) + parsed, err := KeeperConsumerPerformanceMetaData.GetAbi() if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil } -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. func (_KeeperConsumerPerformance *KeeperConsumerPerformanceRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { return _KeeperConsumerPerformance.Contract.KeeperConsumerPerformanceCaller.contract.Call(opts, result, method, params...) } -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. func (_KeeperConsumerPerformance *KeeperConsumerPerformanceRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { return _KeeperConsumerPerformance.Contract.KeeperConsumerPerformanceTransactor.contract.Transfer(opts) } -// Transact invokes the (paid) contract method with params as input values. func (_KeeperConsumerPerformance *KeeperConsumerPerformanceRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { return _KeeperConsumerPerformance.Contract.KeeperConsumerPerformanceTransactor.contract.Transact(opts, method, params...) } -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { return _KeeperConsumerPerformance.Contract.contract.Call(opts, result, method, params...) } -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. func (_KeeperConsumerPerformance *KeeperConsumerPerformanceTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { return _KeeperConsumerPerformance.Contract.contract.Transfer(opts) } -// Transact invokes the (paid) contract method with params as input values. func (_KeeperConsumerPerformance *KeeperConsumerPerformanceTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { return _KeeperConsumerPerformance.Contract.contract.Transact(opts, method, params...) } -// AverageEligibilityCadence is a free data retrieval call binding the contract method 0xa9a4c57c. -// -// Solidity: function averageEligibilityCadence() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) AverageEligibilityCadence(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} err := _KeeperConsumerPerformance.contract.Call(opts, &out, "averageEligibilityCadence") @@ -218,23 +185,14 @@ func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) AverageEligib } -// AverageEligibilityCadence is a free data retrieval call binding the contract method 0xa9a4c57c. -// -// Solidity: function averageEligibilityCadence() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) AverageEligibilityCadence() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.AverageEligibilityCadence(&_KeeperConsumerPerformance.CallOpts) } -// AverageEligibilityCadence is a free data retrieval call binding the contract method 0xa9a4c57c. -// -// Solidity: function averageEligibilityCadence() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCallerSession) AverageEligibilityCadence() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.AverageEligibilityCadence(&_KeeperConsumerPerformance.CallOpts) } -// CheckEligible is a free data retrieval call binding the contract method 0xc228a98e. -// -// Solidity: function checkEligible() view returns(bool) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) CheckEligible(opts *bind.CallOpts) (bool, error) { var out []interface{} err := _KeeperConsumerPerformance.contract.Call(opts, &out, "checkEligible") @@ -249,23 +207,14 @@ func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) CheckEligible } -// CheckEligible is a free data retrieval call binding the contract method 0xc228a98e. -// -// Solidity: function checkEligible() view returns(bool) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) CheckEligible() (bool, error) { return _KeeperConsumerPerformance.Contract.CheckEligible(&_KeeperConsumerPerformance.CallOpts) } -// CheckEligible is a free data retrieval call binding the contract method 0xc228a98e. -// -// Solidity: function checkEligible() view returns(bool) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCallerSession) CheckEligible() (bool, error) { return _KeeperConsumerPerformance.Contract.CheckEligible(&_KeeperConsumerPerformance.CallOpts) } -// CheckGasToBurn is a free data retrieval call binding the contract method 0x2ff3617d. -// -// Solidity: function checkGasToBurn() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) CheckGasToBurn(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} err := _KeeperConsumerPerformance.contract.Call(opts, &out, "checkGasToBurn") @@ -280,23 +229,14 @@ func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) CheckGasToBur } -// CheckGasToBurn is a free data retrieval call binding the contract method 0x2ff3617d. -// -// Solidity: function checkGasToBurn() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) CheckGasToBurn() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.CheckGasToBurn(&_KeeperConsumerPerformance.CallOpts) } -// CheckGasToBurn is a free data retrieval call binding the contract method 0x2ff3617d. -// -// Solidity: function checkGasToBurn() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCallerSession) CheckGasToBurn() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.CheckGasToBurn(&_KeeperConsumerPerformance.CallOpts) } -// CheckUpkeep is a free data retrieval call binding the contract method 0x6e04ff0d. -// -// Solidity: function checkUpkeep(bytes data) view returns(bool, bytes) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) CheckUpkeep(opts *bind.CallOpts, data []byte) (bool, []byte, error) { var out []interface{} err := _KeeperConsumerPerformance.contract.Call(opts, &out, "checkUpkeep", data) @@ -312,23 +252,14 @@ func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) CheckUpkeep(o } -// CheckUpkeep is a free data retrieval call binding the contract method 0x6e04ff0d. -// -// Solidity: function checkUpkeep(bytes data) view returns(bool, bytes) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) CheckUpkeep(data []byte) (bool, []byte, error) { return _KeeperConsumerPerformance.Contract.CheckUpkeep(&_KeeperConsumerPerformance.CallOpts, data) } -// CheckUpkeep is a free data retrieval call binding the contract method 0x6e04ff0d. -// -// Solidity: function checkUpkeep(bytes data) view returns(bool, bytes) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCallerSession) CheckUpkeep(data []byte) (bool, []byte, error) { return _KeeperConsumerPerformance.Contract.CheckUpkeep(&_KeeperConsumerPerformance.CallOpts, data) } -// Count is a free data retrieval call binding the contract method 0x06661abd. -// -// Solidity: function count() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) Count(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} err := _KeeperConsumerPerformance.contract.Call(opts, &out, "count") @@ -343,23 +274,14 @@ func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) Count(opts *b } -// Count is a free data retrieval call binding the contract method 0x06661abd. -// -// Solidity: function count() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) Count() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.Count(&_KeeperConsumerPerformance.CallOpts) } -// Count is a free data retrieval call binding the contract method 0x06661abd. -// -// Solidity: function count() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCallerSession) Count() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.Count(&_KeeperConsumerPerformance.CallOpts) } -// DummyMap is a free data retrieval call binding the contract method 0x7145f11b. -// -// Solidity: function dummyMap(bytes32 ) view returns(bool) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) DummyMap(opts *bind.CallOpts, arg0 [32]byte) (bool, error) { var out []interface{} err := _KeeperConsumerPerformance.contract.Call(opts, &out, "dummyMap", arg0) @@ -374,23 +296,14 @@ func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) DummyMap(opts } -// DummyMap is a free data retrieval call binding the contract method 0x7145f11b. -// -// Solidity: function dummyMap(bytes32 ) view returns(bool) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) DummyMap(arg0 [32]byte) (bool, error) { return _KeeperConsumerPerformance.Contract.DummyMap(&_KeeperConsumerPerformance.CallOpts, arg0) } -// DummyMap is a free data retrieval call binding the contract method 0x7145f11b. -// -// Solidity: function dummyMap(bytes32 ) view returns(bool) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCallerSession) DummyMap(arg0 [32]byte) (bool, error) { return _KeeperConsumerPerformance.Contract.DummyMap(&_KeeperConsumerPerformance.CallOpts, arg0) } -// GetCountPerforms is a free data retrieval call binding the contract method 0xe303666f. -// -// Solidity: function getCountPerforms() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) GetCountPerforms(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} err := _KeeperConsumerPerformance.contract.Call(opts, &out, "getCountPerforms") @@ -405,23 +318,14 @@ func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) GetCountPerfo } -// GetCountPerforms is a free data retrieval call binding the contract method 0xe303666f. -// -// Solidity: function getCountPerforms() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) GetCountPerforms() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.GetCountPerforms(&_KeeperConsumerPerformance.CallOpts) } -// GetCountPerforms is a free data retrieval call binding the contract method 0xe303666f. -// -// Solidity: function getCountPerforms() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCallerSession) GetCountPerforms() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.GetCountPerforms(&_KeeperConsumerPerformance.CallOpts) } -// InitialCall is a free data retrieval call binding the contract method 0x926f086e. -// -// Solidity: function initialCall() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) InitialCall(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} err := _KeeperConsumerPerformance.contract.Call(opts, &out, "initialCall") @@ -436,23 +340,14 @@ func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) InitialCall(o } -// InitialCall is a free data retrieval call binding the contract method 0x926f086e. -// -// Solidity: function initialCall() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) InitialCall() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.InitialCall(&_KeeperConsumerPerformance.CallOpts) } -// InitialCall is a free data retrieval call binding the contract method 0x926f086e. -// -// Solidity: function initialCall() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCallerSession) InitialCall() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.InitialCall(&_KeeperConsumerPerformance.CallOpts) } -// NextEligible is a free data retrieval call binding the contract method 0x523d9b8a. -// -// Solidity: function nextEligible() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) NextEligible(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} err := _KeeperConsumerPerformance.contract.Call(opts, &out, "nextEligible") @@ -467,23 +362,14 @@ func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) NextEligible( } -// NextEligible is a free data retrieval call binding the contract method 0x523d9b8a. -// -// Solidity: function nextEligible() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) NextEligible() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.NextEligible(&_KeeperConsumerPerformance.CallOpts) } -// NextEligible is a free data retrieval call binding the contract method 0x523d9b8a. -// -// Solidity: function nextEligible() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCallerSession) NextEligible() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.NextEligible(&_KeeperConsumerPerformance.CallOpts) } -// PerformGasToBurn is a free data retrieval call binding the contract method 0xb30566b4. -// -// Solidity: function performGasToBurn() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) PerformGasToBurn(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} err := _KeeperConsumerPerformance.contract.Call(opts, &out, "performGasToBurn") @@ -498,23 +384,14 @@ func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) PerformGasToB } -// PerformGasToBurn is a free data retrieval call binding the contract method 0xb30566b4. -// -// Solidity: function performGasToBurn() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) PerformGasToBurn() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.PerformGasToBurn(&_KeeperConsumerPerformance.CallOpts) } -// PerformGasToBurn is a free data retrieval call binding the contract method 0xb30566b4. -// -// Solidity: function performGasToBurn() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCallerSession) PerformGasToBurn() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.PerformGasToBurn(&_KeeperConsumerPerformance.CallOpts) } -// TestRange is a free data retrieval call binding the contract method 0x6250a13a. -// -// Solidity: function testRange() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) TestRange(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} err := _KeeperConsumerPerformance.contract.Call(opts, &out, "testRange") @@ -529,147 +406,92 @@ func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCaller) TestRange(opt } -// TestRange is a free data retrieval call binding the contract method 0x6250a13a. -// -// Solidity: function testRange() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) TestRange() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.TestRange(&_KeeperConsumerPerformance.CallOpts) } -// TestRange is a free data retrieval call binding the contract method 0x6250a13a. -// -// Solidity: function testRange() view returns(uint256) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceCallerSession) TestRange() (*big.Int, error) { return _KeeperConsumerPerformance.Contract.TestRange(&_KeeperConsumerPerformance.CallOpts) } -// PerformUpkeep is a paid mutator transaction binding the contract method 0x4585e33b. -// -// Solidity: function performUpkeep(bytes data) returns() func (_KeeperConsumerPerformance *KeeperConsumerPerformanceTransactor) PerformUpkeep(opts *bind.TransactOpts, data []byte) (*types.Transaction, error) { return _KeeperConsumerPerformance.contract.Transact(opts, "performUpkeep", data) } -// PerformUpkeep is a paid mutator transaction binding the contract method 0x4585e33b. -// -// Solidity: function performUpkeep(bytes data) returns() func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) PerformUpkeep(data []byte) (*types.Transaction, error) { return _KeeperConsumerPerformance.Contract.PerformUpkeep(&_KeeperConsumerPerformance.TransactOpts, data) } -// PerformUpkeep is a paid mutator transaction binding the contract method 0x4585e33b. -// -// Solidity: function performUpkeep(bytes data) returns() func (_KeeperConsumerPerformance *KeeperConsumerPerformanceTransactorSession) PerformUpkeep(data []byte) (*types.Transaction, error) { return _KeeperConsumerPerformance.Contract.PerformUpkeep(&_KeeperConsumerPerformance.TransactOpts, data) } -// Reset is a paid mutator transaction binding the contract method 0xd826f88f. -// -// Solidity: function reset() returns() func (_KeeperConsumerPerformance *KeeperConsumerPerformanceTransactor) Reset(opts *bind.TransactOpts) (*types.Transaction, error) { return _KeeperConsumerPerformance.contract.Transact(opts, "reset") } -// Reset is a paid mutator transaction binding the contract method 0xd826f88f. -// -// Solidity: function reset() returns() func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) Reset() (*types.Transaction, error) { return _KeeperConsumerPerformance.Contract.Reset(&_KeeperConsumerPerformance.TransactOpts) } -// Reset is a paid mutator transaction binding the contract method 0xd826f88f. -// -// Solidity: function reset() returns() func (_KeeperConsumerPerformance *KeeperConsumerPerformanceTransactorSession) Reset() (*types.Transaction, error) { return _KeeperConsumerPerformance.Contract.Reset(&_KeeperConsumerPerformance.TransactOpts) } -// SetCheckGasToBurn is a paid mutator transaction binding the contract method 0x13bda75b. -// -// Solidity: function setCheckGasToBurn(uint256 value) returns() func (_KeeperConsumerPerformance *KeeperConsumerPerformanceTransactor) SetCheckGasToBurn(opts *bind.TransactOpts, value *big.Int) (*types.Transaction, error) { return _KeeperConsumerPerformance.contract.Transact(opts, "setCheckGasToBurn", value) } -// SetCheckGasToBurn is a paid mutator transaction binding the contract method 0x13bda75b. -// -// Solidity: function setCheckGasToBurn(uint256 value) returns() func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) SetCheckGasToBurn(value *big.Int) (*types.Transaction, error) { return _KeeperConsumerPerformance.Contract.SetCheckGasToBurn(&_KeeperConsumerPerformance.TransactOpts, value) } -// SetCheckGasToBurn is a paid mutator transaction binding the contract method 0x13bda75b. -// -// Solidity: function setCheckGasToBurn(uint256 value) returns() func (_KeeperConsumerPerformance *KeeperConsumerPerformanceTransactorSession) SetCheckGasToBurn(value *big.Int) (*types.Transaction, error) { return _KeeperConsumerPerformance.Contract.SetCheckGasToBurn(&_KeeperConsumerPerformance.TransactOpts, value) } -// SetPerformGasToBurn is a paid mutator transaction binding the contract method 0x2555d2cf. -// -// Solidity: function setPerformGasToBurn(uint256 value) returns() func (_KeeperConsumerPerformance *KeeperConsumerPerformanceTransactor) SetPerformGasToBurn(opts *bind.TransactOpts, value *big.Int) (*types.Transaction, error) { return _KeeperConsumerPerformance.contract.Transact(opts, "setPerformGasToBurn", value) } -// SetPerformGasToBurn is a paid mutator transaction binding the contract method 0x2555d2cf. -// -// Solidity: function setPerformGasToBurn(uint256 value) returns() func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) SetPerformGasToBurn(value *big.Int) (*types.Transaction, error) { return _KeeperConsumerPerformance.Contract.SetPerformGasToBurn(&_KeeperConsumerPerformance.TransactOpts, value) } -// SetPerformGasToBurn is a paid mutator transaction binding the contract method 0x2555d2cf. -// -// Solidity: function setPerformGasToBurn(uint256 value) returns() func (_KeeperConsumerPerformance *KeeperConsumerPerformanceTransactorSession) SetPerformGasToBurn(value *big.Int) (*types.Transaction, error) { return _KeeperConsumerPerformance.Contract.SetPerformGasToBurn(&_KeeperConsumerPerformance.TransactOpts, value) } -// SetSpread is a paid mutator transaction binding the contract method 0x7f407edf. -// -// Solidity: function setSpread(uint256 _newTestRange, uint256 _newAverageEligibilityCadence) returns() func (_KeeperConsumerPerformance *KeeperConsumerPerformanceTransactor) SetSpread(opts *bind.TransactOpts, _newTestRange *big.Int, _newAverageEligibilityCadence *big.Int) (*types.Transaction, error) { return _KeeperConsumerPerformance.contract.Transact(opts, "setSpread", _newTestRange, _newAverageEligibilityCadence) } -// SetSpread is a paid mutator transaction binding the contract method 0x7f407edf. -// -// Solidity: function setSpread(uint256 _newTestRange, uint256 _newAverageEligibilityCadence) returns() func (_KeeperConsumerPerformance *KeeperConsumerPerformanceSession) SetSpread(_newTestRange *big.Int, _newAverageEligibilityCadence *big.Int) (*types.Transaction, error) { return _KeeperConsumerPerformance.Contract.SetSpread(&_KeeperConsumerPerformance.TransactOpts, _newTestRange, _newAverageEligibilityCadence) } -// SetSpread is a paid mutator transaction binding the contract method 0x7f407edf. -// -// Solidity: function setSpread(uint256 _newTestRange, uint256 _newAverageEligibilityCadence) returns() func (_KeeperConsumerPerformance *KeeperConsumerPerformanceTransactorSession) SetSpread(_newTestRange *big.Int, _newAverageEligibilityCadence *big.Int) (*types.Transaction, error) { return _KeeperConsumerPerformance.Contract.SetSpread(&_KeeperConsumerPerformance.TransactOpts, _newTestRange, _newAverageEligibilityCadence) } -// KeeperConsumerPerformancePerformingUpkeepIterator is returned from FilterPerformingUpkeep and is used to iterate over the raw logs and unpacked data for PerformingUpkeep events raised by the KeeperConsumerPerformance contract. type KeeperConsumerPerformancePerformingUpkeepIterator struct { - Event *KeeperConsumerPerformancePerformingUpkeep // Event containing the contract specifics and raw log + Event *KeeperConsumerPerformancePerformingUpkeep - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data + contract *bind.BoundContract + event string - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration + logs chan types.Log + sub ethereum.Subscription + done bool + fail error } -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. func (it *KeeperConsumerPerformancePerformingUpkeepIterator) Next() bool { - // If the iterator failed, stop iterating + if it.fail != nil { return false } - // If the iterator completed, deliver directly whatever's available + if it.done { select { case log := <-it.logs: @@ -685,7 +507,7 @@ func (it *KeeperConsumerPerformancePerformingUpkeepIterator) Next() bool { return false } } - // Iterator still in progress, wait for either a data or an error event + select { case log := <-it.logs: it.Event = new(KeeperConsumerPerformancePerformingUpkeep) @@ -703,31 +525,24 @@ func (it *KeeperConsumerPerformancePerformingUpkeepIterator) Next() bool { } } -// Error returns any retrieval or parsing error occurred during filtering. func (it *KeeperConsumerPerformancePerformingUpkeepIterator) Error() error { return it.fail } -// Close terminates the iteration process, releasing any pending underlying -// resources. func (it *KeeperConsumerPerformancePerformingUpkeepIterator) Close() error { it.sub.Unsubscribe() return nil } -// KeeperConsumerPerformancePerformingUpkeep represents a PerformingUpkeep event raised by the KeeperConsumerPerformance contract. type KeeperConsumerPerformancePerformingUpkeep struct { Eligible bool From common.Address InitialCall *big.Int NextEligible *big.Int BlockNumber *big.Int - Raw types.Log // Blockchain specific contextual infos + Raw types.Log } -// FilterPerformingUpkeep is a free log retrieval operation binding the contract event 0xbd6b6608a51477954e8b498c633bda87e5cd555e06ead50486398d9e3b9cebc0. -// -// Solidity: event PerformingUpkeep(bool eligible, address from, uint256 initialCall, uint256 nextEligible, uint256 blockNumber) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceFilterer) FilterPerformingUpkeep(opts *bind.FilterOpts) (*KeeperConsumerPerformancePerformingUpkeepIterator, error) { logs, sub, err := _KeeperConsumerPerformance.contract.FilterLogs(opts, "PerformingUpkeep") @@ -737,9 +552,6 @@ func (_KeeperConsumerPerformance *KeeperConsumerPerformanceFilterer) FilterPerfo return &KeeperConsumerPerformancePerformingUpkeepIterator{contract: _KeeperConsumerPerformance.contract, event: "PerformingUpkeep", logs: logs, sub: sub}, nil } -// WatchPerformingUpkeep is a free log subscription operation binding the contract event 0xbd6b6608a51477954e8b498c633bda87e5cd555e06ead50486398d9e3b9cebc0. -// -// Solidity: event PerformingUpkeep(bool eligible, address from, uint256 initialCall, uint256 nextEligible, uint256 blockNumber) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceFilterer) WatchPerformingUpkeep(opts *bind.WatchOpts, sink chan<- *KeeperConsumerPerformancePerformingUpkeep) (event.Subscription, error) { logs, sub, err := _KeeperConsumerPerformance.contract.WatchLogs(opts, "PerformingUpkeep") @@ -751,7 +563,7 @@ func (_KeeperConsumerPerformance *KeeperConsumerPerformanceFilterer) WatchPerfor for { select { case log := <-logs: - // New log arrived, parse the event and forward to the user + event := new(KeeperConsumerPerformancePerformingUpkeep) if err := _KeeperConsumerPerformance.contract.UnpackLog(event, "PerformingUpkeep", log); err != nil { return err @@ -774,9 +586,6 @@ func (_KeeperConsumerPerformance *KeeperConsumerPerformanceFilterer) WatchPerfor }), nil } -// ParsePerformingUpkeep is a log parse operation binding the contract event 0xbd6b6608a51477954e8b498c633bda87e5cd555e06ead50486398d9e3b9cebc0. -// -// Solidity: event PerformingUpkeep(bool eligible, address from, uint256 initialCall, uint256 nextEligible, uint256 blockNumber) func (_KeeperConsumerPerformance *KeeperConsumerPerformanceFilterer) ParsePerformingUpkeep(log types.Log) (*KeeperConsumerPerformancePerformingUpkeep, error) { event := new(KeeperConsumerPerformancePerformingUpkeep) if err := _KeeperConsumerPerformance.contract.UnpackLog(event, "PerformingUpkeep", log); err != nil { @@ -785,3 +594,65 @@ func (_KeeperConsumerPerformance *KeeperConsumerPerformanceFilterer) ParsePerfor event.Raw = log return event, nil } + +func (_KeeperConsumerPerformance *KeeperConsumerPerformance) ParseLog(log types.Log) (generated.AbigenLog, error) { + switch log.Topics[0] { + case _KeeperConsumerPerformance.abi.Events["PerformingUpkeep"].ID: + return _KeeperConsumerPerformance.ParsePerformingUpkeep(log) + + default: + return nil, fmt.Errorf("abigen wrapper received unknown log topic: %v", log.Topics[0]) + } +} + +func (KeeperConsumerPerformancePerformingUpkeep) Topic() common.Hash { + return common.HexToHash("0xbd6b6608a51477954e8b498c633bda87e5cd555e06ead50486398d9e3b9cebc0") +} + +func (_KeeperConsumerPerformance *KeeperConsumerPerformance) Address() common.Address { + return _KeeperConsumerPerformance.address +} + +type KeeperConsumerPerformanceInterface interface { + AverageEligibilityCadence(opts *bind.CallOpts) (*big.Int, error) + + CheckEligible(opts *bind.CallOpts) (bool, error) + + CheckGasToBurn(opts *bind.CallOpts) (*big.Int, error) + + CheckUpkeep(opts *bind.CallOpts, data []byte) (bool, []byte, error) + + Count(opts *bind.CallOpts) (*big.Int, error) + + DummyMap(opts *bind.CallOpts, arg0 [32]byte) (bool, error) + + GetCountPerforms(opts *bind.CallOpts) (*big.Int, error) + + InitialCall(opts *bind.CallOpts) (*big.Int, error) + + NextEligible(opts *bind.CallOpts) (*big.Int, error) + + PerformGasToBurn(opts *bind.CallOpts) (*big.Int, error) + + TestRange(opts *bind.CallOpts) (*big.Int, error) + + PerformUpkeep(opts *bind.TransactOpts, data []byte) (*types.Transaction, error) + + Reset(opts *bind.TransactOpts) (*types.Transaction, error) + + SetCheckGasToBurn(opts *bind.TransactOpts, value *big.Int) (*types.Transaction, error) + + SetPerformGasToBurn(opts *bind.TransactOpts, value *big.Int) (*types.Transaction, error) + + SetSpread(opts *bind.TransactOpts, _newTestRange *big.Int, _newAverageEligibilityCadence *big.Int) (*types.Transaction, error) + + FilterPerformingUpkeep(opts *bind.FilterOpts) (*KeeperConsumerPerformancePerformingUpkeepIterator, error) + + WatchPerformingUpkeep(opts *bind.WatchOpts, sink chan<- *KeeperConsumerPerformancePerformingUpkeep) (event.Subscription, error) + + ParsePerformingUpkeep(log types.Log) (*KeeperConsumerPerformancePerformingUpkeep, error) + + ParseLog(log types.Log) (generated.AbigenLog, error) + + Address() common.Address +} diff --git a/core/gethwrappers/generated/keeper_consumer_wrapper/keeper_consumer_wrapper.go b/core/gethwrappers/generated/keeper_consumer_wrapper/keeper_consumer_wrapper.go new file mode 100644 index 00000000000..896927f9e6d --- /dev/null +++ b/core/gethwrappers/generated/keeper_consumer_wrapper/keeper_consumer_wrapper.go @@ -0,0 +1,303 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package keeper_consumer_wrapper + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +var KeeperConsumerMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"updateInterval\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"checkData\",\"type\":\"bytes\"}],\"name\":\"checkUpkeep\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"upkeepNeeded\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"performData\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"counter\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"interval\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastTimeStamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"performData\",\"type\":\"bytes\"}],\"name\":\"performUpkeep\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x60a060405234801561001057600080fd5b5060405161036c38038061036c83398101604081905261002f9161003f565b6080524260015560008055610058565b60006020828403121561005157600080fd5b5051919050565b6080516102fa610072600039600060cc01526102fa6000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c806361bc221a1161005057806361bc221a1461009d5780636e04ff0d146100a6578063947a36fb146100c757600080fd5b80633f3b3b271461006c5780634585e33b14610088575b600080fd5b61007560015481565b6040519081526020015b60405180910390f35b61009b6100963660046101c5565b6100ee565b005b61007560005481565b6100b96100b43660046101c5565b610103565b60405161007f929190610237565b6100757f000000000000000000000000000000000000000000000000000000000000000081565b6000546100fc9060016102ad565b6000555050565b6000606061010f610157565b6001848481818080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250959a92995091975050505050505050565b32156101c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f6f6e6c7920666f722073696d756c61746564206261636b656e64000000000000604482015260640160405180910390fd5b565b600080602083850312156101d857600080fd5b823567ffffffffffffffff808211156101f057600080fd5b818501915085601f83011261020457600080fd5b81358181111561021357600080fd5b86602082850101111561022557600080fd5b60209290920196919550909350505050565b821515815260006020604081840152835180604085015260005b8181101561026d57858101830151858201606001528201610251565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116850101925050509392505050565b808201808211156102e7577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b9291505056fea164736f6c6343000810000a", +} + +var KeeperConsumerABI = KeeperConsumerMetaData.ABI + +var KeeperConsumerBin = KeeperConsumerMetaData.Bin + +func DeployKeeperConsumer(auth *bind.TransactOpts, backend bind.ContractBackend, updateInterval *big.Int) (common.Address, *types.Transaction, *KeeperConsumer, error) { + parsed, err := KeeperConsumerMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(KeeperConsumerBin), backend, updateInterval) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &KeeperConsumer{KeeperConsumerCaller: KeeperConsumerCaller{contract: contract}, KeeperConsumerTransactor: KeeperConsumerTransactor{contract: contract}, KeeperConsumerFilterer: KeeperConsumerFilterer{contract: contract}}, nil +} + +type KeeperConsumer struct { + address common.Address + abi abi.ABI + KeeperConsumerCaller + KeeperConsumerTransactor + KeeperConsumerFilterer +} + +type KeeperConsumerCaller struct { + contract *bind.BoundContract +} + +type KeeperConsumerTransactor struct { + contract *bind.BoundContract +} + +type KeeperConsumerFilterer struct { + contract *bind.BoundContract +} + +type KeeperConsumerSession struct { + Contract *KeeperConsumer + CallOpts bind.CallOpts + TransactOpts bind.TransactOpts +} + +type KeeperConsumerCallerSession struct { + Contract *KeeperConsumerCaller + CallOpts bind.CallOpts +} + +type KeeperConsumerTransactorSession struct { + Contract *KeeperConsumerTransactor + TransactOpts bind.TransactOpts +} + +type KeeperConsumerRaw struct { + Contract *KeeperConsumer +} + +type KeeperConsumerCallerRaw struct { + Contract *KeeperConsumerCaller +} + +type KeeperConsumerTransactorRaw struct { + Contract *KeeperConsumerTransactor +} + +func NewKeeperConsumer(address common.Address, backend bind.ContractBackend) (*KeeperConsumer, error) { + abi, err := abi.JSON(strings.NewReader(KeeperConsumerABI)) + if err != nil { + return nil, err + } + contract, err := bindKeeperConsumer(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &KeeperConsumer{address: address, abi: abi, KeeperConsumerCaller: KeeperConsumerCaller{contract: contract}, KeeperConsumerTransactor: KeeperConsumerTransactor{contract: contract}, KeeperConsumerFilterer: KeeperConsumerFilterer{contract: contract}}, nil +} + +func NewKeeperConsumerCaller(address common.Address, caller bind.ContractCaller) (*KeeperConsumerCaller, error) { + contract, err := bindKeeperConsumer(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &KeeperConsumerCaller{contract: contract}, nil +} + +func NewKeeperConsumerTransactor(address common.Address, transactor bind.ContractTransactor) (*KeeperConsumerTransactor, error) { + contract, err := bindKeeperConsumer(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &KeeperConsumerTransactor{contract: contract}, nil +} + +func NewKeeperConsumerFilterer(address common.Address, filterer bind.ContractFilterer) (*KeeperConsumerFilterer, error) { + contract, err := bindKeeperConsumer(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &KeeperConsumerFilterer{contract: contract}, nil +} + +func bindKeeperConsumer(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := KeeperConsumerMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +func (_KeeperConsumer *KeeperConsumerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _KeeperConsumer.Contract.KeeperConsumerCaller.contract.Call(opts, result, method, params...) +} + +func (_KeeperConsumer *KeeperConsumerRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _KeeperConsumer.Contract.KeeperConsumerTransactor.contract.Transfer(opts) +} + +func (_KeeperConsumer *KeeperConsumerRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _KeeperConsumer.Contract.KeeperConsumerTransactor.contract.Transact(opts, method, params...) +} + +func (_KeeperConsumer *KeeperConsumerCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _KeeperConsumer.Contract.contract.Call(opts, result, method, params...) +} + +func (_KeeperConsumer *KeeperConsumerTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _KeeperConsumer.Contract.contract.Transfer(opts) +} + +func (_KeeperConsumer *KeeperConsumerTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _KeeperConsumer.Contract.contract.Transact(opts, method, params...) +} + +func (_KeeperConsumer *KeeperConsumerCaller) CheckUpkeep(opts *bind.CallOpts, checkData []byte) (CheckUpkeep, + + error) { + var out []interface{} + err := _KeeperConsumer.contract.Call(opts, &out, "checkUpkeep", checkData) + + outstruct := new(CheckUpkeep) + if err != nil { + return *outstruct, err + } + + outstruct.UpkeepNeeded = *abi.ConvertType(out[0], new(bool)).(*bool) + outstruct.PerformData = *abi.ConvertType(out[1], new([]byte)).(*[]byte) + + return *outstruct, err + +} + +func (_KeeperConsumer *KeeperConsumerSession) CheckUpkeep(checkData []byte) (CheckUpkeep, + + error) { + return _KeeperConsumer.Contract.CheckUpkeep(&_KeeperConsumer.CallOpts, checkData) +} + +func (_KeeperConsumer *KeeperConsumerCallerSession) CheckUpkeep(checkData []byte) (CheckUpkeep, + + error) { + return _KeeperConsumer.Contract.CheckUpkeep(&_KeeperConsumer.CallOpts, checkData) +} + +func (_KeeperConsumer *KeeperConsumerCaller) Counter(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _KeeperConsumer.contract.Call(opts, &out, "counter") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_KeeperConsumer *KeeperConsumerSession) Counter() (*big.Int, error) { + return _KeeperConsumer.Contract.Counter(&_KeeperConsumer.CallOpts) +} + +func (_KeeperConsumer *KeeperConsumerCallerSession) Counter() (*big.Int, error) { + return _KeeperConsumer.Contract.Counter(&_KeeperConsumer.CallOpts) +} + +func (_KeeperConsumer *KeeperConsumerCaller) Interval(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _KeeperConsumer.contract.Call(opts, &out, "interval") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_KeeperConsumer *KeeperConsumerSession) Interval() (*big.Int, error) { + return _KeeperConsumer.Contract.Interval(&_KeeperConsumer.CallOpts) +} + +func (_KeeperConsumer *KeeperConsumerCallerSession) Interval() (*big.Int, error) { + return _KeeperConsumer.Contract.Interval(&_KeeperConsumer.CallOpts) +} + +func (_KeeperConsumer *KeeperConsumerCaller) LastTimeStamp(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _KeeperConsumer.contract.Call(opts, &out, "lastTimeStamp") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_KeeperConsumer *KeeperConsumerSession) LastTimeStamp() (*big.Int, error) { + return _KeeperConsumer.Contract.LastTimeStamp(&_KeeperConsumer.CallOpts) +} + +func (_KeeperConsumer *KeeperConsumerCallerSession) LastTimeStamp() (*big.Int, error) { + return _KeeperConsumer.Contract.LastTimeStamp(&_KeeperConsumer.CallOpts) +} + +func (_KeeperConsumer *KeeperConsumerTransactor) PerformUpkeep(opts *bind.TransactOpts, performData []byte) (*types.Transaction, error) { + return _KeeperConsumer.contract.Transact(opts, "performUpkeep", performData) +} + +func (_KeeperConsumer *KeeperConsumerSession) PerformUpkeep(performData []byte) (*types.Transaction, error) { + return _KeeperConsumer.Contract.PerformUpkeep(&_KeeperConsumer.TransactOpts, performData) +} + +func (_KeeperConsumer *KeeperConsumerTransactorSession) PerformUpkeep(performData []byte) (*types.Transaction, error) { + return _KeeperConsumer.Contract.PerformUpkeep(&_KeeperConsumer.TransactOpts, performData) +} + +type CheckUpkeep struct { + UpkeepNeeded bool + PerformData []byte +} + +func (_KeeperConsumer *KeeperConsumer) Address() common.Address { + return _KeeperConsumer.address +} + +type KeeperConsumerInterface interface { + CheckUpkeep(opts *bind.CallOpts, checkData []byte) (CheckUpkeep, + + error) + + Counter(opts *bind.CallOpts) (*big.Int, error) + + Interval(opts *bind.CallOpts) (*big.Int, error) + + LastTimeStamp(opts *bind.CallOpts) (*big.Int, error) + + PerformUpkeep(opts *bind.TransactOpts, performData []byte) (*types.Transaction, error) + + Address() common.Address +} diff --git a/integration-tests/contracts/ethereum/PerformDataChecker.go b/core/gethwrappers/generated/perform_data_checker_wrapper/perform_data_checker_wrapper.go similarity index 70% rename from integration-tests/contracts/ethereum/PerformDataChecker.go rename to core/gethwrappers/generated/perform_data_checker_wrapper/perform_data_checker_wrapper.go index 99c8d1380cd..aa639deb9c0 100644 --- a/integration-tests/contracts/ethereum/PerformDataChecker.go +++ b/core/gethwrappers/generated/perform_data_checker_wrapper/perform_data_checker_wrapper.go @@ -1,14 +1,14 @@ -package ethereum - // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. +package perform_data_checker_wrapper + import ( "errors" "math/big" "strings" - "github.com/ethereum/go-ethereum" + ethereum "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -25,11 +25,12 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription + _ = abi.ConvertType ) var PerformDataCheckerMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"expectedData\",\"type\":\"bytes\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"checkData\",\"type\":\"bytes\"}],\"name\":\"checkUpkeep\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"upkeepNeeded\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"performData\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"counter\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"performData\",\"type\":\"bytes\"}],\"name\":\"performUpkeep\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"s_expectedData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"expectedData\",\"type\":\"bytes\"}],\"name\":\"setExpectedData\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b506040516107d33803806107d383398101604081905261002f916100e2565b8051610042906001906020840190610049565b5050610202565b828054610055906101b1565b90600052602060002090601f01602090048101928261007757600085556100bd565b82601f1061009057805160ff19168380011785556100bd565b828001600101855582156100bd579182015b828111156100bd5782518255916020019190600101906100a2565b506100c99291506100cd565b5090565b5b808211156100c957600081556001016100ce565b600060208083850312156100f557600080fd5b82516001600160401b038082111561010c57600080fd5b818501915085601f83011261012057600080fd5b815181811115610132576101326101ec565b604051601f8201601f19908116603f0116810190838211818310171561015a5761015a6101ec565b81604052828152888684870101111561017257600080fd5b600093505b828410156101945784840186015181850187015292850192610177565b828411156101a55760008684830101525b98975050505050505050565b600181811c908216806101c557607f821691505b602082108114156101e657634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b6105c2806102116000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c806361bc221a1161005057806361bc221a146100945780636e04ff0d146100b05780638d1a93c2146100d157600080fd5b80632aa0f7951461006c5780634585e33b14610081575b600080fd5b61007f61007a366004610304565b6100e6565b005b61007f61008f366004610304565b6100f7565b61009d60005481565b6040519081526020015b60405180910390f35b6100c36100be366004610304565b610145565b6040516100a79291906104c4565b6100d96101bf565b6040516100a791906104e7565b6100f26001838361024d565b505050565b600160405161010691906103f1565b6040518091039020828260405161011e9291906103e1565b604051809103902014156101415760008054908061013b83610555565b91905055505b5050565b60006060600160405161015891906103f1565b604051809103902084846040516101709291906103e1565b604051809103902014848481818080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250959a92995091975050505050505050565b600180546101cc90610501565b80601f01602080910402602001604051908101604052809291908181526020018280546101f890610501565b80156102455780601f1061021a57610100808354040283529160200191610245565b820191906000526020600020905b81548152906001019060200180831161022857829003601f168201915b505050505081565b82805461025990610501565b90600052602060002090601f01602090048101928261027b57600085556102df565b82601f106102b2578280017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008235161785556102df565b828001600101855582156102df579182015b828111156102df5782358255916020019190600101906102c4565b506102eb9291506102ef565b5090565b5b808211156102eb57600081556001016102f0565b6000806020838503121561031757600080fd5b823567ffffffffffffffff8082111561032f57600080fd5b818501915085601f83011261034357600080fd5b81358181111561035257600080fd5b86602082850101111561036457600080fd5b60209290920196919550909350505050565b6000815180845260005b8181101561039c57602081850181015186830182015201610380565b818111156103ae576000602083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b8183823760009101908152919050565b600080835481600182811c91508083168061040d57607f831692505b6020808410821415610446577f4e487b710000000000000000000000000000000000000000000000000000000086526022600452602486fd5b81801561045a5760018114610489576104b6565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008616895284890196506104b6565b60008a81526020902060005b868110156104ae5781548b820152908501908301610495565b505084890196505b509498975050505050505050565b82151581526040602082015260006104df6040830184610376565b949350505050565b6020815260006104fa6020830184610376565b9392505050565b600181811c9082168061051557607f821691505b6020821081141561054f577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156105ae577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b506001019056fea164736f6c6343000806000a", + Bin: "0x608060405234801561001057600080fd5b506040516108d33803806108d383398101604081905261002f91610058565b600161003b82826101aa565b5050610269565b634e487b7160e01b600052604160045260246000fd5b6000602080838503121561006b57600080fd5b82516001600160401b038082111561008257600080fd5b818501915085601f83011261009657600080fd5b8151818111156100a8576100a8610042565b604051601f8201601f19908116603f011681019083821181831017156100d0576100d0610042565b8160405282815288868487010111156100e857600080fd5b600093505b8284101561010a57848401860151818501870152928501926100ed565b600086848301015280965050505050505092915050565b600181811c9082168061013557607f821691505b60208210810361015557634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156101a557600081815260208120601f850160051c810160208610156101825750805b601f850160051c820191505b818110156101a15782815560010161018e565b5050505b505050565b81516001600160401b038111156101c3576101c3610042565b6101d7816101d18454610121565b8461015b565b602080601f83116001811461020c57600084156101f45750858301515b600019600386901b1c1916600185901b1785556101a1565b600085815260208120601f198616915b8281101561023b5788860151825594840194600190910190840161021c565b50858210156102595787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b61065b806102786000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c806361bc221a1161005057806361bc221a146100945780636e04ff0d146100b05780638d1a93c2146100d157600080fd5b80632aa0f7951461006c5780634585e33b14610081575b600080fd5b61007f61007a36600461024d565b6100e6565b005b61007f61008f36600461024d565b6100f8565b61009d60005481565b6040519081526020015b60405180910390f35b6100c36100be36600461024d565b610145565b6040516100a7929190610323565b6100d96101bf565b6040516100a79190610346565b60016100f3828483610430565b505050565b6001604051610107919061054b565b6040518091039020828260405161011f9291906105df565b6040518091039020036101415760008054908061013b836105ef565b91905055505b5050565b600060606001604051610158919061054b565b604051809103902084846040516101709291906105df565b604051809103902014848481818080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250959a92995091975050505050505050565b600180546101cc9061038f565b80601f01602080910402602001604051908101604052809291908181526020018280546101f89061038f565b80156102455780601f1061021a57610100808354040283529160200191610245565b820191906000526020600020905b81548152906001019060200180831161022857829003601f168201915b505050505081565b6000806020838503121561026057600080fd5b823567ffffffffffffffff8082111561027857600080fd5b818501915085601f83011261028c57600080fd5b81358181111561029b57600080fd5b8660208285010111156102ad57600080fd5b60209290920196919550909350505050565b6000815180845260005b818110156102e5576020818501810151868301820152016102c9565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b821515815260406020820152600061033e60408301846102bf565b949350505050565b60208152600061035960208301846102bf565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600181811c908216806103a357607f821691505b6020821081036103dc577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b601f8211156100f357600081815260208120601f850160051c810160208610156104095750805b601f850160051c820191505b8181101561042857828155600101610415565b505050505050565b67ffffffffffffffff83111561044857610448610360565b61045c83610456835461038f565b836103e2565b6000601f8411600181146104ae57600085156104785750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b178355610544565b6000838152602090207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0861690835b828110156104fd57868501358255602094850194600190920191016104dd565b5086821015610538577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b60008083546105598161038f565b6001828116801561057157600181146105a4576105d3565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00841687528215158302870194506105d3565b8760005260208060002060005b858110156105ca5781548a8201529084019082016105b1565b50505082870194505b50929695505050505050565b8183823760009101908152919050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610647577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b506001019056fea164736f6c6343000810000a", } var PerformDataCheckerABI = PerformDataCheckerMetaData.ABI @@ -137,11 +138,11 @@ func NewPerformDataCheckerFilterer(address common.Address, filterer bind.Contrac } func bindPerformDataChecker(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(PerformDataCheckerABI)) + parsed, err := PerformDataCheckerMetaData.GetAbi() if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil } func (_PerformDataChecker *PerformDataCheckerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { diff --git a/core/gethwrappers/generated/upkeep_counter_wrapper/upkeep_counter_wrapper.go b/core/gethwrappers/generated/upkeep_counter_wrapper/upkeep_counter_wrapper.go index 4276610f731..4f9fe79d77c 100644 --- a/core/gethwrappers/generated/upkeep_counter_wrapper/upkeep_counter_wrapper.go +++ b/core/gethwrappers/generated/upkeep_counter_wrapper/upkeep_counter_wrapper.go @@ -32,7 +32,7 @@ var ( var UpkeepCounterMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_testRange\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_interval\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"initialBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lastBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"counter\",\"type\":\"uint256\"}],\"name\":\"PerformingUpkeep\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"checkUpkeep\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"counter\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"eligible\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"interval\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"performData\",\"type\":\"bytes\"}],\"name\":\"performUpkeep\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"previousPerformBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_testRange\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_interval\",\"type\":\"uint256\"}],\"name\":\"setSpread\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"testRange\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b5060405161044d38038061044d8339818101604052604081101561003357600080fd5b508051602090910151600091825560015560038190554360025560048190556005556103e9806100646000396000f3fe608060405234801561001057600080fd5b50600436106100be5760003560e01c80637f407edf11610076578063917d895f1161005b578063917d895f1461027b578063947a36fb14610283578063d832d92f1461028b576100be565b80637f407edf14610250578063806b984f14610273576100be565b806361bc221a116100a757806361bc221a1461014f5780636250a13a146101575780636e04ff0d1461015f576100be565b80632cb15864146100c35780634585e33b146100dd575b600080fd5b6100cb6102a7565b60408051918252519081900360200190f35b61014d600480360360208110156100f357600080fd5b81019060208101813564010000000081111561010e57600080fd5b82018360208201111561012057600080fd5b8035906020019184600183028401116401000000008311171561014257600080fd5b5090925090506102ad565b005b6100cb610324565b6100cb61032a565b6101cf6004803603602081101561017557600080fd5b81019060208101813564010000000081111561019057600080fd5b8201836020820111156101a257600080fd5b803590602001918460018302840111640100000000831117156101c457600080fd5b509092509050610330565b60405180831515815260200180602001828103825283818151815260200191508051906020019080838360005b838110156102145781810151838201526020016101fc565b50505050905090810190601f1680156102415780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b61014d6004803603604081101561026657600080fd5b5080359060200135610382565b6100cb610394565b6100cb61039a565b6100cb6103a0565b6102936103a6565b604080519115158252519081900360200190f35b60045481565b6004546102b957436004555b4360028190556005805460010190819055600454600354604080519283526020830194909452818401526060810191909152905132917f8e8112f20a2134e18e591d2cdd68cd86a95d06e6328ede501fc6314f4a5075fa919081900360800190a25050600254600355565b60055481565b60005481565b6000606061033c6103a6565b848481818080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250959a92995091975050505050505050565b60009182556001556004819055600555565b60025481565b60035481565b60015481565b6000600454600014156103bb575060016103d9565b60005460045443031080156103d65750600154600254430310155b90505b9056fea164736f6c6343000706000a", + Bin: "0x608060405234801561001057600080fd5b5060405161048338038061048383398101604081905261002f9161004d565b60009182556001556003819055436002556004819055600555610071565b6000806040838503121561006057600080fd5b505080516020909101519092909150565b610403806100806000396000f3fe608060405234801561001057600080fd5b50600436106100be5760003560e01c80637f407edf11610076578063917d895f1161005b578063917d895f14610150578063947a36fb14610159578063d832d92f1461016257600080fd5b80637f407edf14610127578063806b984f1461014757600080fd5b806361bc221a116100a757806361bc221a146100f45780636250a13a146100fd5780636e04ff0d1461010657600080fd5b80632cb15864146100c35780634585e33b146100df575b600080fd5b6100cc60045481565b6040519081526020015b60405180910390f35b6100f26100ed366004610291565b61017a565b005b6100cc60055481565b6100cc60005481565b610119610114366004610291565b6101fd565b6040516100d6929190610303565b6100f2610135366004610379565b60009182556001556004819055600555565b6100cc60025481565b6100cc60035481565b6100cc60015481565b61016a61024f565b60405190151581526020016100d6565b60045460000361018957436004555b4360025560055461019b9060016103ca565b600581905560045460025460035460408051938452602084019290925290820152606081019190915232907f8e8112f20a2134e18e591d2cdd68cd86a95d06e6328ede501fc6314f4a5075fa9060800160405180910390a25050600254600355565b6000606061020961024f565b848481818080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250959a92995091975050505050505050565b60006004546000036102615750600190565b60005460045461027190436103e3565b10801561028c575060015460025461028990436103e3565b10155b905090565b600080602083850312156102a457600080fd5b823567ffffffffffffffff808211156102bc57600080fd5b818501915085601f8301126102d057600080fd5b8135818111156102df57600080fd5b8660208285010111156102f157600080fd5b60209290920196919550909350505050565b821515815260006020604081840152835180604085015260005b818110156103395785810183015185820160600152820161031d565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116850101925050509392505050565b6000806040838503121561038c57600080fd5b50508035926020909101359150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156103dd576103dd61039b565b92915050565b818103818111156103dd576103dd61039b56fea164736f6c6343000810000a", } var UpkeepCounterABI = UpkeepCounterMetaData.ABI diff --git a/core/gethwrappers/generated/upkeep_perform_counter_restrictive_wrapper/upkeep_perform_counter_restrictive_wrapper.go b/core/gethwrappers/generated/upkeep_perform_counter_restrictive_wrapper/upkeep_perform_counter_restrictive_wrapper.go index 6212853de68..e6770fd074f 100644 --- a/core/gethwrappers/generated/upkeep_perform_counter_restrictive_wrapper/upkeep_perform_counter_restrictive_wrapper.go +++ b/core/gethwrappers/generated/upkeep_perform_counter_restrictive_wrapper/upkeep_perform_counter_restrictive_wrapper.go @@ -32,7 +32,7 @@ var ( var UpkeepPerformCounterRestrictiveMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_testRange\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_averageEligibilityCadence\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"eligible\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"initialCall\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"nextEligible\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"PerformingUpkeep\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"averageEligibilityCadence\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"checkEligible\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"checkGasToBurn\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"checkUpkeep\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"dummyMap\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCountPerforms\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialCall\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nextEligible\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"performGasToBurn\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"performUpkeep\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"reset\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"setCheckGasToBurn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"setPerformGasToBurn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_newTestRange\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_newAverageEligibilityCadence\",\"type\":\"uint256\"}],\"name\":\"setSpread\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"testRange\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", - Bin: "0x6080604052600080556000600155600060075534801561001e57600080fd5b506040516106883803806106888339818101604052604081101561004157600080fd5b508051602090910151600291909155600355610626806100626000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c80637145f11b11610097578063b30566b411610066578063b30566b414610325578063c228a98e1461032d578063d826f88f14610335578063e303666f1461033d576100f5565b80637145f11b146102c15780637f407edf146102f2578063926f086e14610315578063a9a4c57c1461031d576100f5565b80634585e33b116100d35780634585e33b14610150578063523d9b8a146101c05780636250a13a146101c85780636e04ff0d146101d0576100f5565b806313bda75b146100fa5780632555d2cf146101195780632ff3617d14610136575b600080fd5b6101176004803603602081101561011057600080fd5b5035610345565b005b6101176004803603602081101561012f57600080fd5b503561034a565b61013e61034f565b60408051918252519081900360200190f35b6101176004803603602081101561016657600080fd5b81019060208101813564010000000081111561018157600080fd5b82018360208201111561019357600080fd5b803590602001918460018302840111640100000000831117156101b557600080fd5b509092509050610355565b61013e610492565b61013e610498565b610240600480360360208110156101e657600080fd5b81019060208101813564010000000081111561020157600080fd5b82018360208201111561021357600080fd5b8035906020019184600183028401116401000000008311171561023557600080fd5b50909250905061049e565b60405180831515815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561028557818101518382015260200161026d565b50505050905090810190601f1680156102b25780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b6102de600480360360208110156102d757600080fd5b5035610555565b604080519115158252519081900360200190f35b6101176004803603604081101561030857600080fd5b508035906020013561056a565b61013e610575565b61013e61057b565b61013e610581565b6102de610587565b610117610596565b61013e6105a0565b600455565b600555565b60045481565b60005a905060006103646105a6565b60005460015460408051841515815232602082015280820193909352606083019190915243608083018190529051929350917fbd6b6608a51477954e8b498c633bda87e5cd555e06ead50486398d9e3b9cebc09181900360a00190a1816103ca57600080fd5b6000546103d75760008190555b6003546002026103e56105ca565b816103ec57fe5b068101600190810181556007805490910190557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff015b6005545a8403101561048b578040600090815260066020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01610422565b5050505050565b60015481565b60025481565b6000606060005a90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff430160005b6004545a84031015610522578080156104f65750814060009081526006602052604090205460ff165b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092019190506104cd565b61052a6105a6565b6040805192151560208085019190915281518085039091018152928101905297909650945050505050565b60066020526000908152604090205460ff1681565b600291909155600355565b60005481565b60035481565b60055481565b60006105916105a6565b905090565b6000808055600755565b60075490565b60008054158061059157506002546000544303108015610591575050600154431190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4301406020808301919091523082840152825180830384018152606090920190925280519101209056fea164736f6c6343000706000a", + Bin: "0x6080604052600080556000600155600060075534801561001e57600080fd5b5060405161074238038061074283398101604081905261003d9161004b565b60029190915560035561006f565b6000806040838503121561005e57600080fd5b505080516020909101519092909150565b6106c48061007e6000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c80637145f11b11610097578063b30566b411610066578063b30566b4146101e2578063c228a98e146101eb578063d826f88f146101f3578063e303666f1461020057600080fd5b80637145f11b146101845780637f407edf146101b7578063926f086e146101d0578063a9a4c57c146101d957600080fd5b80634585e33b116100d35780634585e33b1461013e578063523d9b8a146101515780636250a13a1461015a5780636e04ff0d1461016357600080fd5b806313bda75b146100fa5780632555d2cf1461010f5780632ff3617d14610122575b600080fd5b61010d610108366004610454565b600455565b005b61010d61011d366004610454565b600555565b61012b60045481565b6040519081526020015b60405180910390f35b61010d61014c36600461046d565b610208565b61012b60015481565b61012b60025481565b61017661017136600461046d565b610349565b6040516101359291906104df565b6101a7610192366004610454565b60066020526000908152604090205460ff1681565b6040519015158152602001610135565b61010d6101c5366004610555565b600291909155600355565b61012b60005481565b61012b60035481565b61012b60055481565b6101a76103db565b61010d6000808055600755565b60075461012b565b60005a905060006102176103ea565b60005460015460408051841515815232602082015290810192909252606082015243608082018190529192507fbd6b6608a51477954e8b498c633bda87e5cd555e06ead50486398d9e3b9cebc09060a00160405180910390a18161027a57600080fd5b60005460000361028a5760008190555b6003546102989060026105a6565b6102a0610416565b6102aa91906105e3565b6102b4908261061e565b6102bf90600161061e565b600155600780549060006102d283610637565b919050555080806102e29061066f565b9150505b6005545a6102f490856106a4565b1015610342578040600090815260066020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690558061033a8161066f565b9150506102e6565b5050505050565b6000606060005a9050600061035f6001436106a4565b905060005b6004545a61037290856106a4565b10156103a9578080156103955750814060009081526006602052604090205460ff165b9050816103a18161066f565b925050610364565b6103b16103ea565b60408051831515602082015201604051602081830303815290604052945094505050509250929050565b60006103e56103ea565b905090565b6000805415806103e5575060025460005461040590436106a4565b1080156103e5575050600154431190565b60006104236001436106a4565b604080519140602083015230908201526060016040516020818303038152906040528051906020012060001c905090565b60006020828403121561046657600080fd5b5035919050565b6000806020838503121561048057600080fd5b823567ffffffffffffffff8082111561049857600080fd5b818501915085601f8301126104ac57600080fd5b8135818111156104bb57600080fd5b8660208285010111156104cd57600080fd5b60209290920196919550909350505050565b821515815260006020604081840152835180604085015260005b81811015610515578581018301518582016060015282016104f9565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116850101925050509392505050565b6000806040838503121561056857600080fd5b50508035926020909101359150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156105de576105de610577565b500290565b600082610619577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500690565b8082018082111561063157610631610577565b92915050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361066857610668610577565b5060010190565b60008161067e5761067e610577565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b818103818111156106315761063161057756fea164736f6c6343000810000a", } var UpkeepPerformCounterRestrictiveABI = UpkeepPerformCounterRestrictiveMetaData.ABI diff --git a/core/gethwrappers/generated/vrf_v2_consumer_wrapper/vrf_v2_consumer_wrapper.go b/core/gethwrappers/generated/vrf_v2_consumer_wrapper/vrf_v2_consumer_wrapper.go new file mode 100644 index 00000000000..a5d57945802 --- /dev/null +++ b/core/gethwrappers/generated/vrf_v2_consumer_wrapper/vrf_v2_consumer_wrapper.go @@ -0,0 +1,951 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package vrf_v2_consumer_wrapper + +import ( + "errors" + "fmt" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated" +) + +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +var VRFv2ConsumerMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vrfCoordinator\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"have\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"want\",\"type\":\"address\"}],\"name\":\"OnlyCoordinatorCanFulfill\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"OwnershipTransferRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"randomWords\",\"type\":\"uint256[]\"}],\"name\":\"RequestFulfilled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"numWords\",\"type\":\"uint32\"}],\"name\":\"RequestSent\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_requestId\",\"type\":\"uint256\"}],\"name\":\"getRequestStatus\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"fulfilled\",\"type\":\"bool\"},{\"internalType\":\"uint256[]\",\"name\":\"randomWords\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastRequestId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"requestId\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"randomWords\",\"type\":\"uint256[]\"}],\"name\":\"rawFulfillRandomWords\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"requestIds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"subId\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"callbackGasLimit\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"requestConfirmations\",\"type\":\"uint16\"},{\"internalType\":\"uint32\",\"name\":\"numWords\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"keyHash\",\"type\":\"bytes32\"}],\"name\":\"requestRandomWords\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"requestId\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"s_requests\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"fulfilled\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"exists\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x60a060405234801561001057600080fd5b50604051610e31380380610e3183398101604081905261002f9161019a565b6001600160601b0319606082901b1660805233806000816100975760405162461bcd60e51b815260206004820152601860248201527f43616e6e6f7420736574206f776e657220746f207a65726f000000000000000060448201526064015b60405180910390fd5b600080546001600160a01b0319166001600160a01b03848116919091179091558116156100c7576100c7816100f0565b5050600380546001600160a01b0319166001600160a01b039390931692909217909155506101ca565b6001600160a01b0381163314156101495760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c66000000000000000000604482015260640161008e565b600180546001600160a01b0319166001600160a01b0383811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b6000602082840312156101ac57600080fd5b81516001600160a01b03811681146101c357600080fd5b9392505050565b60805160601c610c426101ef600039600081816101be01526102260152610c426000f3fe608060405234801561001057600080fd5b50600436106100a35760003560e01c80639561f02311610076578063d8a4676f1161005b578063d8a4676f14610169578063f2fde38b1461018a578063fc2a88c31461019d57600080fd5b80639561f02314610113578063a168fa891461012657600080fd5b80631fe543e3146100a857806379ba5097146100bd5780638796ba8c146100c55780638da5cb5b146100eb575b600080fd5b6100bb6100b6366004610a2c565b6101a6565b005b6100bb610266565b6100d86100d33660046109fa565b610363565b6040519081526020015b60405180910390f35b60005460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100e2565b6100d8610121366004610b1b565b610384565b6101526101343660046109fa565b60026020526000908152604090205460ff8082169161010090041682565b6040805192151583529015156020830152016100e2565b61017c6101773660046109fa565b610593565b6040516100e2929190610bca565b6100bb6101983660046109bd565b6106ad565b6100d860055481565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610258576040517f1cf993f400000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001660248201526044015b60405180910390fd5b61026282826106c1565b5050565b60015473ffffffffffffffffffffffffffffffffffffffff1633146102e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4d7573742062652070726f706f736564206f776e657200000000000000000000604482015260640161024f565b60008054337fffffffffffffffffffffffff00000000000000000000000000000000000000008083168217845560018054909116905560405173ffffffffffffffffffffffffffffffffffffffff90921692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a350565b6004818154811061037357600080fd5b600091825260209091200154905081565b600061038e6107cb565b6003546040517f5d3b1d300000000000000000000000000000000000000000000000000000000081526004810184905267ffffffffffffffff8816602482015261ffff8616604482015263ffffffff80881660648301528516608482015273ffffffffffffffffffffffffffffffffffffffff90911690635d3b1d309060a401602060405180830381600087803b15801561042857600080fd5b505af115801561043c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104609190610a13565b604080516060810182526000808252600160208084018281528551848152808301875285870190815287855260028352959093208451815494517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00009095169015157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff161761010094151594909402939093178355935180519596509294919361050f9391850192910190610944565b5050600480546001810182556000919091527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b018290555060058190556040805182815263ffffffff851660208201527fcc58b13ad3eab50626c6a6300b1d139cd6ebb1688a7cced9461c2f7e762665ee910160405180910390a195945050505050565b600081815260026020526040812054606090610100900460ff16610613576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f72657175657374206e6f7420666f756e64000000000000000000000000000000604482015260640161024f565b60008381526002602090815260408083208151606081018352815460ff808216151583526101009091041615158185015260018201805484518187028101870186528181529295939486019383018282801561068e57602002820191906000526020600020905b81548152602001906001019080831161067a575b5050505050815250509050806000015181604001519250925050915091565b6106b56107cb565b6106be8161084e565b50565b600082815260026020526040902054610100900460ff1661073e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f72657175657374206e6f7420666f756e64000000000000000000000000000000604482015260640161024f565b600082815260026020908152604090912080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660019081178255835161078d939290910191840190610944565b507ffe2e2d779dba245964d4e3ef9b994be63856fd568bf7d3ca9e224755cb1bd54d82826040516107bf929190610bed565b60405180910390a15050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461084c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015260640161024f565b565b73ffffffffffffffffffffffffffffffffffffffff81163314156108ce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c66000000000000000000604482015260640161024f565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b82805482825590600052602060002090810192821561097f579160200282015b8281111561097f578251825591602001919060010190610964565b5061098b92915061098f565b5090565b5b8082111561098b5760008155600101610990565b803563ffffffff811681146109b857600080fd5b919050565b6000602082840312156109cf57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff811681146109f357600080fd5b9392505050565b600060208284031215610a0c57600080fd5b5035919050565b600060208284031215610a2557600080fd5b5051919050565b60008060408385031215610a3f57600080fd5b8235915060208084013567ffffffffffffffff80821115610a5f57600080fd5b818601915086601f830112610a7357600080fd5b813581811115610a8557610a85610c06565b8060051b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f83011681018181108582111715610ac857610ac8610c06565b604052828152858101935084860182860187018b1015610ae757600080fd5b600095505b83861015610b0a578035855260019590950194938601938601610aec565b508096505050505050509250929050565b600080600080600060a08688031215610b3357600080fd5b853567ffffffffffffffff81168114610b4b57600080fd5b9450610b59602087016109a4565b9350604086013561ffff81168114610b7057600080fd5b9250610b7e606087016109a4565b949793965091946080013592915050565b600081518084526020808501945080840160005b83811015610bbf57815187529582019590820190600101610ba3565b509495945050505050565b8215158152604060208201526000610be56040830184610b8f565b949350505050565b828152604060208201526000610be56040830184610b8f565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fdfea164736f6c6343000806000a", +} + +var VRFv2ConsumerABI = VRFv2ConsumerMetaData.ABI + +var VRFv2ConsumerBin = VRFv2ConsumerMetaData.Bin + +func DeployVRFv2Consumer(auth *bind.TransactOpts, backend bind.ContractBackend, vrfCoordinator common.Address) (common.Address, *types.Transaction, *VRFv2Consumer, error) { + parsed, err := VRFv2ConsumerMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(VRFv2ConsumerBin), backend, vrfCoordinator) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &VRFv2Consumer{VRFv2ConsumerCaller: VRFv2ConsumerCaller{contract: contract}, VRFv2ConsumerTransactor: VRFv2ConsumerTransactor{contract: contract}, VRFv2ConsumerFilterer: VRFv2ConsumerFilterer{contract: contract}}, nil +} + +type VRFv2Consumer struct { + address common.Address + abi abi.ABI + VRFv2ConsumerCaller + VRFv2ConsumerTransactor + VRFv2ConsumerFilterer +} + +type VRFv2ConsumerCaller struct { + contract *bind.BoundContract +} + +type VRFv2ConsumerTransactor struct { + contract *bind.BoundContract +} + +type VRFv2ConsumerFilterer struct { + contract *bind.BoundContract +} + +type VRFv2ConsumerSession struct { + Contract *VRFv2Consumer + CallOpts bind.CallOpts + TransactOpts bind.TransactOpts +} + +type VRFv2ConsumerCallerSession struct { + Contract *VRFv2ConsumerCaller + CallOpts bind.CallOpts +} + +type VRFv2ConsumerTransactorSession struct { + Contract *VRFv2ConsumerTransactor + TransactOpts bind.TransactOpts +} + +type VRFv2ConsumerRaw struct { + Contract *VRFv2Consumer +} + +type VRFv2ConsumerCallerRaw struct { + Contract *VRFv2ConsumerCaller +} + +type VRFv2ConsumerTransactorRaw struct { + Contract *VRFv2ConsumerTransactor +} + +func NewVRFv2Consumer(address common.Address, backend bind.ContractBackend) (*VRFv2Consumer, error) { + abi, err := abi.JSON(strings.NewReader(VRFv2ConsumerABI)) + if err != nil { + return nil, err + } + contract, err := bindVRFv2Consumer(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &VRFv2Consumer{address: address, abi: abi, VRFv2ConsumerCaller: VRFv2ConsumerCaller{contract: contract}, VRFv2ConsumerTransactor: VRFv2ConsumerTransactor{contract: contract}, VRFv2ConsumerFilterer: VRFv2ConsumerFilterer{contract: contract}}, nil +} + +func NewVRFv2ConsumerCaller(address common.Address, caller bind.ContractCaller) (*VRFv2ConsumerCaller, error) { + contract, err := bindVRFv2Consumer(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &VRFv2ConsumerCaller{contract: contract}, nil +} + +func NewVRFv2ConsumerTransactor(address common.Address, transactor bind.ContractTransactor) (*VRFv2ConsumerTransactor, error) { + contract, err := bindVRFv2Consumer(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &VRFv2ConsumerTransactor{contract: contract}, nil +} + +func NewVRFv2ConsumerFilterer(address common.Address, filterer bind.ContractFilterer) (*VRFv2ConsumerFilterer, error) { + contract, err := bindVRFv2Consumer(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &VRFv2ConsumerFilterer{contract: contract}, nil +} + +func bindVRFv2Consumer(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := VRFv2ConsumerMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +func (_VRFv2Consumer *VRFv2ConsumerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _VRFv2Consumer.Contract.VRFv2ConsumerCaller.contract.Call(opts, result, method, params...) +} + +func (_VRFv2Consumer *VRFv2ConsumerRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _VRFv2Consumer.Contract.VRFv2ConsumerTransactor.contract.Transfer(opts) +} + +func (_VRFv2Consumer *VRFv2ConsumerRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _VRFv2Consumer.Contract.VRFv2ConsumerTransactor.contract.Transact(opts, method, params...) +} + +func (_VRFv2Consumer *VRFv2ConsumerCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _VRFv2Consumer.Contract.contract.Call(opts, result, method, params...) +} + +func (_VRFv2Consumer *VRFv2ConsumerTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _VRFv2Consumer.Contract.contract.Transfer(opts) +} + +func (_VRFv2Consumer *VRFv2ConsumerTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _VRFv2Consumer.Contract.contract.Transact(opts, method, params...) +} + +func (_VRFv2Consumer *VRFv2ConsumerCaller) GetRequestStatus(opts *bind.CallOpts, _requestId *big.Int) (GetRequestStatus, + + error) { + var out []interface{} + err := _VRFv2Consumer.contract.Call(opts, &out, "getRequestStatus", _requestId) + + outstruct := new(GetRequestStatus) + if err != nil { + return *outstruct, err + } + + outstruct.Fulfilled = *abi.ConvertType(out[0], new(bool)).(*bool) + outstruct.RandomWords = *abi.ConvertType(out[1], new([]*big.Int)).(*[]*big.Int) + + return *outstruct, err + +} + +func (_VRFv2Consumer *VRFv2ConsumerSession) GetRequestStatus(_requestId *big.Int) (GetRequestStatus, + + error) { + return _VRFv2Consumer.Contract.GetRequestStatus(&_VRFv2Consumer.CallOpts, _requestId) +} + +func (_VRFv2Consumer *VRFv2ConsumerCallerSession) GetRequestStatus(_requestId *big.Int) (GetRequestStatus, + + error) { + return _VRFv2Consumer.Contract.GetRequestStatus(&_VRFv2Consumer.CallOpts, _requestId) +} + +func (_VRFv2Consumer *VRFv2ConsumerCaller) LastRequestId(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _VRFv2Consumer.contract.Call(opts, &out, "lastRequestId") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_VRFv2Consumer *VRFv2ConsumerSession) LastRequestId() (*big.Int, error) { + return _VRFv2Consumer.Contract.LastRequestId(&_VRFv2Consumer.CallOpts) +} + +func (_VRFv2Consumer *VRFv2ConsumerCallerSession) LastRequestId() (*big.Int, error) { + return _VRFv2Consumer.Contract.LastRequestId(&_VRFv2Consumer.CallOpts) +} + +func (_VRFv2Consumer *VRFv2ConsumerCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _VRFv2Consumer.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +func (_VRFv2Consumer *VRFv2ConsumerSession) Owner() (common.Address, error) { + return _VRFv2Consumer.Contract.Owner(&_VRFv2Consumer.CallOpts) +} + +func (_VRFv2Consumer *VRFv2ConsumerCallerSession) Owner() (common.Address, error) { + return _VRFv2Consumer.Contract.Owner(&_VRFv2Consumer.CallOpts) +} + +func (_VRFv2Consumer *VRFv2ConsumerCaller) RequestIds(opts *bind.CallOpts, arg0 *big.Int) (*big.Int, error) { + var out []interface{} + err := _VRFv2Consumer.contract.Call(opts, &out, "requestIds", arg0) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_VRFv2Consumer *VRFv2ConsumerSession) RequestIds(arg0 *big.Int) (*big.Int, error) { + return _VRFv2Consumer.Contract.RequestIds(&_VRFv2Consumer.CallOpts, arg0) +} + +func (_VRFv2Consumer *VRFv2ConsumerCallerSession) RequestIds(arg0 *big.Int) (*big.Int, error) { + return _VRFv2Consumer.Contract.RequestIds(&_VRFv2Consumer.CallOpts, arg0) +} + +func (_VRFv2Consumer *VRFv2ConsumerCaller) SRequests(opts *bind.CallOpts, arg0 *big.Int) (SRequests, + + error) { + var out []interface{} + err := _VRFv2Consumer.contract.Call(opts, &out, "s_requests", arg0) + + outstruct := new(SRequests) + if err != nil { + return *outstruct, err + } + + outstruct.Fulfilled = *abi.ConvertType(out[0], new(bool)).(*bool) + outstruct.Exists = *abi.ConvertType(out[1], new(bool)).(*bool) + + return *outstruct, err + +} + +func (_VRFv2Consumer *VRFv2ConsumerSession) SRequests(arg0 *big.Int) (SRequests, + + error) { + return _VRFv2Consumer.Contract.SRequests(&_VRFv2Consumer.CallOpts, arg0) +} + +func (_VRFv2Consumer *VRFv2ConsumerCallerSession) SRequests(arg0 *big.Int) (SRequests, + + error) { + return _VRFv2Consumer.Contract.SRequests(&_VRFv2Consumer.CallOpts, arg0) +} + +func (_VRFv2Consumer *VRFv2ConsumerTransactor) AcceptOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _VRFv2Consumer.contract.Transact(opts, "acceptOwnership") +} + +func (_VRFv2Consumer *VRFv2ConsumerSession) AcceptOwnership() (*types.Transaction, error) { + return _VRFv2Consumer.Contract.AcceptOwnership(&_VRFv2Consumer.TransactOpts) +} + +func (_VRFv2Consumer *VRFv2ConsumerTransactorSession) AcceptOwnership() (*types.Transaction, error) { + return _VRFv2Consumer.Contract.AcceptOwnership(&_VRFv2Consumer.TransactOpts) +} + +func (_VRFv2Consumer *VRFv2ConsumerTransactor) RawFulfillRandomWords(opts *bind.TransactOpts, requestId *big.Int, randomWords []*big.Int) (*types.Transaction, error) { + return _VRFv2Consumer.contract.Transact(opts, "rawFulfillRandomWords", requestId, randomWords) +} + +func (_VRFv2Consumer *VRFv2ConsumerSession) RawFulfillRandomWords(requestId *big.Int, randomWords []*big.Int) (*types.Transaction, error) { + return _VRFv2Consumer.Contract.RawFulfillRandomWords(&_VRFv2Consumer.TransactOpts, requestId, randomWords) +} + +func (_VRFv2Consumer *VRFv2ConsumerTransactorSession) RawFulfillRandomWords(requestId *big.Int, randomWords []*big.Int) (*types.Transaction, error) { + return _VRFv2Consumer.Contract.RawFulfillRandomWords(&_VRFv2Consumer.TransactOpts, requestId, randomWords) +} + +func (_VRFv2Consumer *VRFv2ConsumerTransactor) RequestRandomWords(opts *bind.TransactOpts, subId uint64, callbackGasLimit uint32, requestConfirmations uint16, numWords uint32, keyHash [32]byte) (*types.Transaction, error) { + return _VRFv2Consumer.contract.Transact(opts, "requestRandomWords", subId, callbackGasLimit, requestConfirmations, numWords, keyHash) +} + +func (_VRFv2Consumer *VRFv2ConsumerSession) RequestRandomWords(subId uint64, callbackGasLimit uint32, requestConfirmations uint16, numWords uint32, keyHash [32]byte) (*types.Transaction, error) { + return _VRFv2Consumer.Contract.RequestRandomWords(&_VRFv2Consumer.TransactOpts, subId, callbackGasLimit, requestConfirmations, numWords, keyHash) +} + +func (_VRFv2Consumer *VRFv2ConsumerTransactorSession) RequestRandomWords(subId uint64, callbackGasLimit uint32, requestConfirmations uint16, numWords uint32, keyHash [32]byte) (*types.Transaction, error) { + return _VRFv2Consumer.Contract.RequestRandomWords(&_VRFv2Consumer.TransactOpts, subId, callbackGasLimit, requestConfirmations, numWords, keyHash) +} + +func (_VRFv2Consumer *VRFv2ConsumerTransactor) TransferOwnership(opts *bind.TransactOpts, to common.Address) (*types.Transaction, error) { + return _VRFv2Consumer.contract.Transact(opts, "transferOwnership", to) +} + +func (_VRFv2Consumer *VRFv2ConsumerSession) TransferOwnership(to common.Address) (*types.Transaction, error) { + return _VRFv2Consumer.Contract.TransferOwnership(&_VRFv2Consumer.TransactOpts, to) +} + +func (_VRFv2Consumer *VRFv2ConsumerTransactorSession) TransferOwnership(to common.Address) (*types.Transaction, error) { + return _VRFv2Consumer.Contract.TransferOwnership(&_VRFv2Consumer.TransactOpts, to) +} + +type VRFv2ConsumerOwnershipTransferRequestedIterator struct { + Event *VRFv2ConsumerOwnershipTransferRequested + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *VRFv2ConsumerOwnershipTransferRequestedIterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(VRFv2ConsumerOwnershipTransferRequested) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(VRFv2ConsumerOwnershipTransferRequested) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *VRFv2ConsumerOwnershipTransferRequestedIterator) Error() error { + return it.fail +} + +func (it *VRFv2ConsumerOwnershipTransferRequestedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type VRFv2ConsumerOwnershipTransferRequested struct { + From common.Address + To common.Address + Raw types.Log +} + +func (_VRFv2Consumer *VRFv2ConsumerFilterer) FilterOwnershipTransferRequested(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*VRFv2ConsumerOwnershipTransferRequestedIterator, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _VRFv2Consumer.contract.FilterLogs(opts, "OwnershipTransferRequested", fromRule, toRule) + if err != nil { + return nil, err + } + return &VRFv2ConsumerOwnershipTransferRequestedIterator{contract: _VRFv2Consumer.contract, event: "OwnershipTransferRequested", logs: logs, sub: sub}, nil +} + +func (_VRFv2Consumer *VRFv2ConsumerFilterer) WatchOwnershipTransferRequested(opts *bind.WatchOpts, sink chan<- *VRFv2ConsumerOwnershipTransferRequested, from []common.Address, to []common.Address) (event.Subscription, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _VRFv2Consumer.contract.WatchLogs(opts, "OwnershipTransferRequested", fromRule, toRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(VRFv2ConsumerOwnershipTransferRequested) + if err := _VRFv2Consumer.contract.UnpackLog(event, "OwnershipTransferRequested", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_VRFv2Consumer *VRFv2ConsumerFilterer) ParseOwnershipTransferRequested(log types.Log) (*VRFv2ConsumerOwnershipTransferRequested, error) { + event := new(VRFv2ConsumerOwnershipTransferRequested) + if err := _VRFv2Consumer.contract.UnpackLog(event, "OwnershipTransferRequested", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type VRFv2ConsumerOwnershipTransferredIterator struct { + Event *VRFv2ConsumerOwnershipTransferred + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *VRFv2ConsumerOwnershipTransferredIterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(VRFv2ConsumerOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(VRFv2ConsumerOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *VRFv2ConsumerOwnershipTransferredIterator) Error() error { + return it.fail +} + +func (it *VRFv2ConsumerOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type VRFv2ConsumerOwnershipTransferred struct { + From common.Address + To common.Address + Raw types.Log +} + +func (_VRFv2Consumer *VRFv2ConsumerFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*VRFv2ConsumerOwnershipTransferredIterator, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _VRFv2Consumer.contract.FilterLogs(opts, "OwnershipTransferred", fromRule, toRule) + if err != nil { + return nil, err + } + return &VRFv2ConsumerOwnershipTransferredIterator{contract: _VRFv2Consumer.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +func (_VRFv2Consumer *VRFv2ConsumerFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *VRFv2ConsumerOwnershipTransferred, from []common.Address, to []common.Address) (event.Subscription, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _VRFv2Consumer.contract.WatchLogs(opts, "OwnershipTransferred", fromRule, toRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(VRFv2ConsumerOwnershipTransferred) + if err := _VRFv2Consumer.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_VRFv2Consumer *VRFv2ConsumerFilterer) ParseOwnershipTransferred(log types.Log) (*VRFv2ConsumerOwnershipTransferred, error) { + event := new(VRFv2ConsumerOwnershipTransferred) + if err := _VRFv2Consumer.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type VRFv2ConsumerRequestFulfilledIterator struct { + Event *VRFv2ConsumerRequestFulfilled + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *VRFv2ConsumerRequestFulfilledIterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(VRFv2ConsumerRequestFulfilled) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(VRFv2ConsumerRequestFulfilled) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *VRFv2ConsumerRequestFulfilledIterator) Error() error { + return it.fail +} + +func (it *VRFv2ConsumerRequestFulfilledIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type VRFv2ConsumerRequestFulfilled struct { + RequestId *big.Int + RandomWords []*big.Int + Raw types.Log +} + +func (_VRFv2Consumer *VRFv2ConsumerFilterer) FilterRequestFulfilled(opts *bind.FilterOpts) (*VRFv2ConsumerRequestFulfilledIterator, error) { + + logs, sub, err := _VRFv2Consumer.contract.FilterLogs(opts, "RequestFulfilled") + if err != nil { + return nil, err + } + return &VRFv2ConsumerRequestFulfilledIterator{contract: _VRFv2Consumer.contract, event: "RequestFulfilled", logs: logs, sub: sub}, nil +} + +func (_VRFv2Consumer *VRFv2ConsumerFilterer) WatchRequestFulfilled(opts *bind.WatchOpts, sink chan<- *VRFv2ConsumerRequestFulfilled) (event.Subscription, error) { + + logs, sub, err := _VRFv2Consumer.contract.WatchLogs(opts, "RequestFulfilled") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(VRFv2ConsumerRequestFulfilled) + if err := _VRFv2Consumer.contract.UnpackLog(event, "RequestFulfilled", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_VRFv2Consumer *VRFv2ConsumerFilterer) ParseRequestFulfilled(log types.Log) (*VRFv2ConsumerRequestFulfilled, error) { + event := new(VRFv2ConsumerRequestFulfilled) + if err := _VRFv2Consumer.contract.UnpackLog(event, "RequestFulfilled", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type VRFv2ConsumerRequestSentIterator struct { + Event *VRFv2ConsumerRequestSent + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *VRFv2ConsumerRequestSentIterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(VRFv2ConsumerRequestSent) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(VRFv2ConsumerRequestSent) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *VRFv2ConsumerRequestSentIterator) Error() error { + return it.fail +} + +func (it *VRFv2ConsumerRequestSentIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type VRFv2ConsumerRequestSent struct { + RequestId *big.Int + NumWords uint32 + Raw types.Log +} + +func (_VRFv2Consumer *VRFv2ConsumerFilterer) FilterRequestSent(opts *bind.FilterOpts) (*VRFv2ConsumerRequestSentIterator, error) { + + logs, sub, err := _VRFv2Consumer.contract.FilterLogs(opts, "RequestSent") + if err != nil { + return nil, err + } + return &VRFv2ConsumerRequestSentIterator{contract: _VRFv2Consumer.contract, event: "RequestSent", logs: logs, sub: sub}, nil +} + +func (_VRFv2Consumer *VRFv2ConsumerFilterer) WatchRequestSent(opts *bind.WatchOpts, sink chan<- *VRFv2ConsumerRequestSent) (event.Subscription, error) { + + logs, sub, err := _VRFv2Consumer.contract.WatchLogs(opts, "RequestSent") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(VRFv2ConsumerRequestSent) + if err := _VRFv2Consumer.contract.UnpackLog(event, "RequestSent", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_VRFv2Consumer *VRFv2ConsumerFilterer) ParseRequestSent(log types.Log) (*VRFv2ConsumerRequestSent, error) { + event := new(VRFv2ConsumerRequestSent) + if err := _VRFv2Consumer.contract.UnpackLog(event, "RequestSent", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type GetRequestStatus struct { + Fulfilled bool + RandomWords []*big.Int +} +type SRequests struct { + Fulfilled bool + Exists bool +} + +func (_VRFv2Consumer *VRFv2Consumer) ParseLog(log types.Log) (generated.AbigenLog, error) { + switch log.Topics[0] { + case _VRFv2Consumer.abi.Events["OwnershipTransferRequested"].ID: + return _VRFv2Consumer.ParseOwnershipTransferRequested(log) + case _VRFv2Consumer.abi.Events["OwnershipTransferred"].ID: + return _VRFv2Consumer.ParseOwnershipTransferred(log) + case _VRFv2Consumer.abi.Events["RequestFulfilled"].ID: + return _VRFv2Consumer.ParseRequestFulfilled(log) + case _VRFv2Consumer.abi.Events["RequestSent"].ID: + return _VRFv2Consumer.ParseRequestSent(log) + + default: + return nil, fmt.Errorf("abigen wrapper received unknown log topic: %v", log.Topics[0]) + } +} + +func (VRFv2ConsumerOwnershipTransferRequested) Topic() common.Hash { + return common.HexToHash("0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278") +} + +func (VRFv2ConsumerOwnershipTransferred) Topic() common.Hash { + return common.HexToHash("0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0") +} + +func (VRFv2ConsumerRequestFulfilled) Topic() common.Hash { + return common.HexToHash("0xfe2e2d779dba245964d4e3ef9b994be63856fd568bf7d3ca9e224755cb1bd54d") +} + +func (VRFv2ConsumerRequestSent) Topic() common.Hash { + return common.HexToHash("0xcc58b13ad3eab50626c6a6300b1d139cd6ebb1688a7cced9461c2f7e762665ee") +} + +func (_VRFv2Consumer *VRFv2Consumer) Address() common.Address { + return _VRFv2Consumer.address +} + +type VRFv2ConsumerInterface interface { + GetRequestStatus(opts *bind.CallOpts, _requestId *big.Int) (GetRequestStatus, + + error) + + LastRequestId(opts *bind.CallOpts) (*big.Int, error) + + Owner(opts *bind.CallOpts) (common.Address, error) + + RequestIds(opts *bind.CallOpts, arg0 *big.Int) (*big.Int, error) + + SRequests(opts *bind.CallOpts, arg0 *big.Int) (SRequests, + + error) + + AcceptOwnership(opts *bind.TransactOpts) (*types.Transaction, error) + + RawFulfillRandomWords(opts *bind.TransactOpts, requestId *big.Int, randomWords []*big.Int) (*types.Transaction, error) + + RequestRandomWords(opts *bind.TransactOpts, subId uint64, callbackGasLimit uint32, requestConfirmations uint16, numWords uint32, keyHash [32]byte) (*types.Transaction, error) + + TransferOwnership(opts *bind.TransactOpts, to common.Address) (*types.Transaction, error) + + FilterOwnershipTransferRequested(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*VRFv2ConsumerOwnershipTransferRequestedIterator, error) + + WatchOwnershipTransferRequested(opts *bind.WatchOpts, sink chan<- *VRFv2ConsumerOwnershipTransferRequested, from []common.Address, to []common.Address) (event.Subscription, error) + + ParseOwnershipTransferRequested(log types.Log) (*VRFv2ConsumerOwnershipTransferRequested, error) + + FilterOwnershipTransferred(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*VRFv2ConsumerOwnershipTransferredIterator, error) + + WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *VRFv2ConsumerOwnershipTransferred, from []common.Address, to []common.Address) (event.Subscription, error) + + ParseOwnershipTransferred(log types.Log) (*VRFv2ConsumerOwnershipTransferred, error) + + FilterRequestFulfilled(opts *bind.FilterOpts) (*VRFv2ConsumerRequestFulfilledIterator, error) + + WatchRequestFulfilled(opts *bind.WatchOpts, sink chan<- *VRFv2ConsumerRequestFulfilled) (event.Subscription, error) + + ParseRequestFulfilled(log types.Log) (*VRFv2ConsumerRequestFulfilled, error) + + FilterRequestSent(opts *bind.FilterOpts) (*VRFv2ConsumerRequestSentIterator, error) + + WatchRequestSent(opts *bind.WatchOpts, sink chan<- *VRFv2ConsumerRequestSent) (event.Subscription, error) + + ParseRequestSent(log types.Log) (*VRFv2ConsumerRequestSent, error) + + ParseLog(log types.Log) (generated.AbigenLog, error) + + Address() common.Address +} diff --git a/core/gethwrappers/generation/generated-wrapper-dependency-versions-do-not-edit.txt b/core/gethwrappers/generation/generated-wrapper-dependency-versions-do-not-edit.txt index 0f8c642f027..0d0bb388f2f 100644 --- a/core/gethwrappers/generation/generated-wrapper-dependency-versions-do-not-edit.txt +++ b/core/gethwrappers/generation/generated-wrapper-dependency-versions-do-not-edit.txt @@ -1,4 +1,10 @@ GETH_VERSION: 1.12.0 +KeeperConsumer: ../../contracts/solc/v0.8.16/KeeperConsumer.abi ../../contracts/solc/v0.8.16/KeeperConsumer.bin 53d7902867ce421641ffa9de63204b89ab9dc157b93f0beb9ac08c6450365a70 +KeeperConsumerPerformance: ../../contracts/solc/v0.8.16/KeeperConsumerPerformance.abi ../../contracts/solc/v0.8.16/KeeperConsumerPerformance.bin eeda39f5d3e1c8ffa0fb6cd1803731b98a4bc262d41833458e3fe8b40933ae90 +PerformDataChecker: ../../contracts/solc/v0.8.16/PerformDataChecker.abi ../../contracts/solc/v0.8.16/PerformDataChecker.bin 48d8309c2117c29a24e1155917ab0b780956b2cd6a8a39ef06ae66a7f6d94f73 +UpkeepCounter: ../../contracts/solc/v0.8.16/UpkeepCounter.abi ../../contracts/solc/v0.8.16/UpkeepCounter.bin 77f000229a501f638dd2dc439859257f632894c728b31e68aea4f6d6c52f1b71 +UpkeepPerformCounterRestrictive: ../../contracts/solc/v0.8.16/UpkeepPerformCounterRestrictive.abi ../../contracts/solc/v0.8.16/UpkeepPerformCounterRestrictive.bin 20955b21acceb58355fa287b29194a73edf5937067ba7140667301017cb2b24c +VRFv2Consumer: ../../contracts/solc/v0.8.6/VRFv2Consumer.abi ../../contracts/solc/v0.8.6/VRFv2Consumer.bin 12368b3b5e06392440143a13b94c0ea2f79c4c897becc3b060982559e10ace40 aggregator_v2v3_interface: ../../contracts/solc/v0.8.6/AggregatorV2V3Interface.abi ../../contracts/solc/v0.8.6/AggregatorV2V3Interface.bin 95e8814b408bb05bf21742ef580d98698b7db6a9bac6a35c3de12b23aec4ee28 aggregator_v3_interface: ../../contracts/solc/v0.8.6/AggregatorV3Interface.abi ../../contracts/solc/v0.8.6/AggregatorV3Interface.bin 351b55d3b0f04af67db6dfb5c92f1c64479400ca1fec77afc20bc0ce65cb49ab authorized_forwarder: ../../contracts/solc/v0.8.19/AuthorizedForwarder.abi ../../contracts/solc/v0.8.19/AuthorizedForwarder.bin 8ea76c883d460f8353a45a493f2aebeb5a2d9a7b4619d1bc4fff5fb590bb3e10 @@ -24,6 +30,8 @@ gas_wrapper: ../../contracts/solc/v0.8.6/KeeperRegistryCheckUpkeepGasUsageWrappe gas_wrapper_mock: ../../contracts/solc/v0.8.6/KeeperRegistryCheckUpkeepGasUsageWrapper1_2Mock.abi ../../contracts/solc/v0.8.6/KeeperRegistryCheckUpkeepGasUsageWrapper1_2Mock.bin a9b08f18da59125c6fc305855710241f3d35161b8b9f3e3f635a7b1d5c6da9c8 i_keeper_registry_master_wrapper_2_1: ../../contracts/solc/v0.8.16/IKeeperRegistryMaster.abi ../../contracts/solc/v0.8.16/IKeeperRegistryMaster.bin 6501bb9bcf5048bab2737b00685c6984a24867e234ddf5b60a65904eee9a4ebc i_log_automation: ../../contracts/solc/v0.8.16/ILogAutomation.abi ../../contracts/solc/v0.8.16/ILogAutomation.bin 296beccb6af655d6fc3a6e676b244831cce2da6688d3afc4f21f8738ae59e03e +keeper_consumer_performance_wrapper: ../../contracts/solc/v0.8.16/KeeperConsumerPerformance.abi ../../contracts/solc/v0.8.16/KeeperConsumerPerformance.bin eeda39f5d3e1c8ffa0fb6cd1803731b98a4bc262d41833458e3fe8b40933ae90 +keeper_consumer_wrapper: ../../contracts/solc/v0.8.16/KeeperConsumer.abi ../../contracts/solc/v0.8.16/KeeperConsumer.bin 53d7902867ce421641ffa9de63204b89ab9dc157b93f0beb9ac08c6450365a70 keeper_registrar_wrapper1_2: ../../contracts/solc/v0.8.6/KeeperRegistrar.abi ../../contracts/solc/v0.8.6/KeeperRegistrar.bin e49b2f8b23da17af1ed2209b8ae0968cc04350554d636711e6c24a3ad3118692 keeper_registrar_wrapper1_2_mock: ../../contracts/solc/v0.8.6/KeeperRegistrar1_2Mock.abi ../../contracts/solc/v0.8.6/KeeperRegistrar1_2Mock.bin 5b155a7cb3def309fd7525de1d7cd364ebf8491bdc3060eac08ea0ff55ab29bc keeper_registrar_wrapper2_0: ../../contracts/solc/v0.8.6/KeeperRegistrar2_0.abi ../../contracts/solc/v0.8.6/KeeperRegistrar2_0.bin 647f125c2f0dafabcdc545cb77b15dc2ec3ea9429357806813179b1fd555c2d2 @@ -49,6 +57,7 @@ offchain_aggregator_wrapper: OffchainAggregator/OffchainAggregator.abi - 5c8d656 operator_factory: ../../contracts/solc/v0.8.19/OperatorFactory.abi ../../contracts/solc/v0.8.19/OperatorFactory.bin 0fdfacf8879537b854875608dfca41c6221c342174417112acaa67dfcadafddc operator_wrapper: ../../contracts/solc/v0.8.19/Operator.abi ../../contracts/solc/v0.8.19/Operator.bin d7abd0e67f30a3a4c9c04c896124391306fa364fcf579fa6df04dbf912b48568 oracle_wrapper: ../../contracts/solc/v0.6/Oracle.abi ../../contracts/solc/v0.6/Oracle.bin 7af2fbac22a6e8c2847e8e685a5400cac5101d72ddf5365213beb79e4dede43a +perform_data_checker_wrapper: ../../contracts/solc/v0.8.16/PerformDataChecker.abi ../../contracts/solc/v0.8.16/PerformDataChecker.bin 48d8309c2117c29a24e1155917ab0b780956b2cd6a8a39ef06ae66a7f6d94f73 solidity_vrf_consumer_interface: ../../contracts/solc/v0.6/VRFConsumer.abi ../../contracts/solc/v0.6/VRFConsumer.bin ecc99378aa798014de9db42b2eb81320778b0663dbe208008dad75ccdc1d4366 solidity_vrf_consumer_interface_v08: ../../contracts/solc/v0.8.6/VRFConsumer.abi ../../contracts/solc/v0.8.6/VRFConsumer.bin b14f9136b15e3dc9d6154d5700f3ed4cf88ddc4f70f20c3bb57fc46050904c8f solidity_vrf_coordinator_interface: ../../contracts/solc/v0.6/VRFCoordinator.abi ../../contracts/solc/v0.6/VRFCoordinator.bin a23d3c395156804788c7f6fbda2994e8f7184304c0f0c9f2c4ddeaf073d346d2 @@ -62,8 +71,8 @@ streams_lookup_upkeep_wrapper: ../../contracts/solc/v0.8.16/StreamsLookupUpkeep. test_api_consumer_wrapper: ../../contracts/solc/v0.6/TestAPIConsumer.abi ../../contracts/solc/v0.6/TestAPIConsumer.bin ed10893cb18894c18e275302329c955f14ea2de37ee044f84aa1e067ac5ea71e trusted_blockhash_store: ../../contracts/solc/v0.8.6/TrustedBlockhashStore.abi ../../contracts/solc/v0.8.6/TrustedBlockhashStore.bin 98cb0dc06c15af5dcd3b53bdfc98e7ed2489edc96a42203294ac2fc0efdda02b type_and_version_interface_wrapper: ../../contracts/solc/v0.8.6/TypeAndVersionInterface.abi ../../contracts/solc/v0.8.6/TypeAndVersionInterface.bin bc9c3a6e73e3ebd5b58754df0deeb3b33f4bb404d5709bb904aed51d32f4b45e -upkeep_counter_wrapper: ../../contracts/solc/v0.7/UpkeepCounter.abi ../../contracts/solc/v0.7/UpkeepCounter.bin 901961ebf18906febc1c350f02da85c7ea1c2a68da70cfd94efa27c837a48663 -upkeep_perform_counter_restrictive_wrapper: ../../contracts/solc/v0.7/UpkeepPerformCounterRestrictive.abi ../../contracts/solc/v0.7/UpkeepPerformCounterRestrictive.bin 8975a058fba528e16d8414dc6f13946d17a145fcbc66cf25a32449b6fe1ce878 +upkeep_counter_wrapper: ../../contracts/solc/v0.8.16/UpkeepCounter.abi ../../contracts/solc/v0.8.16/UpkeepCounter.bin 77f000229a501f638dd2dc439859257f632894c728b31e68aea4f6d6c52f1b71 +upkeep_perform_counter_restrictive_wrapper: ../../contracts/solc/v0.8.16/UpkeepPerformCounterRestrictive.abi ../../contracts/solc/v0.8.16/UpkeepPerformCounterRestrictive.bin 20955b21acceb58355fa287b29194a73edf5937067ba7140667301017cb2b24c upkeep_transcoder: ../../contracts/solc/v0.8.6/UpkeepTranscoder.abi ../../contracts/solc/v0.8.6/UpkeepTranscoder.bin 336c92a981597be26508455f81a908a0784a817b129a59686c5b2c4afcba730a verifiable_load_log_trigger_upkeep_wrapper: ../../contracts/solc/v0.8.16/VerifiableLoadLogTriggerUpkeep.abi ../../contracts/solc/v0.8.16/VerifiableLoadLogTriggerUpkeep.bin fb674ba44c0e8f3b385cd10b2f7dea5cd07b5f38df08066747e8b1542e152557 verifiable_load_streams_lookup_upkeep_wrapper: ../../contracts/solc/v0.8.16/VerifiableLoadStreamsLookupUpkeep.abi ../../contracts/solc/v0.8.16/VerifiableLoadStreamsLookupUpkeep.bin 785f68c44bfff070505eaa65e38a1af94046e5f9afc1189bcf2c8cfcd1102d66 @@ -87,6 +96,7 @@ vrf_owner: ../../contracts/solc/v0.8.6/VRFOwner.abi ../../contracts/solc/v0.8.6/ vrf_owner_test_consumer: ../../contracts/solc/v0.8.6/VRFV2OwnerTestConsumer.abi ../../contracts/solc/v0.8.6/VRFV2OwnerTestConsumer.bin 0537bbe96c5a8bbd44d0a65fbb7e51f6a9f9e75f4673225845ac1ba33f4e7974 vrf_ownerless_consumer_example: ../../contracts/solc/v0.8.6/VRFOwnerlessConsumerExample.abi ../../contracts/solc/v0.8.6/VRFOwnerlessConsumerExample.bin 9893b3805863273917fb282eed32274e32aa3d5c2a67a911510133e1218132be vrf_single_consumer_example: ../../contracts/solc/v0.8.6/VRFSingleConsumerExample.abi ../../contracts/solc/v0.8.6/VRFSingleConsumerExample.bin 892a5ed35da2e933f7fd7835cd6f7f70ef3aa63a9c03a22c5b1fd026711b0ece +vrf_v2_consumer_wrapper: ../../contracts/solc/v0.8.6/VRFv2Consumer.abi ../../contracts/solc/v0.8.6/VRFv2Consumer.bin 12368b3b5e06392440143a13b94c0ea2f79c4c897becc3b060982559e10ace40 vrf_v2plus_load_test_with_metrics: ../../contracts/solc/v0.8.6/VRFV2PlusLoadTestWithMetrics.abi ../../contracts/solc/v0.8.6/VRFV2PlusLoadTestWithMetrics.bin 0a89cb7ed9dfb42f91e559b03dc351ccdbe14d281a7ab71c63bd3f47eeed7711 vrf_v2plus_single_consumer: ../../contracts/solc/v0.8.6/VRFV2PlusSingleConsumerExample.abi ../../contracts/solc/v0.8.6/VRFV2PlusSingleConsumerExample.bin 6226d05afa1664033b182bfbdde11d5dfb1d4c8e3eb0bd0448c8bfb76f5b96e4 vrf_v2plus_sub_owner: ../../contracts/solc/v0.8.6/VRFV2PlusExternalSubOwnerExample.abi ../../contracts/solc/v0.8.6/VRFV2PlusExternalSubOwnerExample.bin 7541f986571b8a5671a256edc27ae9b8df9bcdff45ac3b96e5609bbfcc320e4e diff --git a/core/gethwrappers/go_generate.go b/core/gethwrappers/go_generate.go index e2b9f619c74..ce553dc8186 100644 --- a/core/gethwrappers/go_generate.go +++ b/core/gethwrappers/go_generate.go @@ -62,6 +62,12 @@ package gethwrappers //go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.16/LogTriggeredStreamsLookup.abi ../../contracts/solc/v0.8.16/LogTriggeredStreamsLookup.bin LogTriggeredStreamsLookup log_triggered_streams_lookup_wrapper //go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.16/DummyProtocol.abi ../../contracts/solc/v0.8.16/DummyProtocol.bin DummyProtocol dummy_protocol_wrapper +//go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.16/KeeperConsumer.abi ../../contracts/solc/v0.8.16/KeeperConsumer.bin KeeperConsumer keeper_consumer_wrapper +//go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.16/KeeperConsumerPerformance.abi ../../contracts/solc/v0.8.16/KeeperConsumerPerformance.bin KeeperConsumerPerformance keeper_consumer_performance_wrapper +//go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.16/PerformDataChecker.abi ../../contracts/solc/v0.8.16/PerformDataChecker.bin PerformDataChecker perform_data_checker_wrapper +//go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.16/UpkeepCounter.abi ../../contracts/solc/v0.8.16/UpkeepCounter.bin UpkeepCounter upkeep_counter_wrapper +//go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.16/UpkeepPerformCounterRestrictive.abi ../../contracts/solc/v0.8.16/UpkeepPerformCounterRestrictive.bin UpkeepPerformCounterRestrictive upkeep_perform_counter_restrictive_wrapper + // v0.8.6 VRFConsumer //go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.6/VRFCoordinatorMock.abi ../../contracts/solc/v0.8.6/VRFCoordinatorMock.bin VRFCoordinatorMock vrf_coordinator_mock //go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.6/VRFConsumer.abi ../../contracts/solc/v0.8.6/VRFConsumer.bin VRFConsumer solidity_vrf_consumer_interface_v08 @@ -71,6 +77,7 @@ package gethwrappers //go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.6/VRFLoadTestExternalSubOwner.abi ../../contracts/solc/v0.8.6/VRFLoadTestExternalSubOwner.bin VRFLoadTestExternalSubOwner vrf_load_test_external_sub_owner //go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.6/VRFV2LoadTestWithMetrics.abi ../../contracts/solc/v0.8.6/VRFV2LoadTestWithMetrics.bin VRFV2LoadTestWithMetrics vrf_load_test_with_metrics //go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.6/VRFV2OwnerTestConsumer.abi ../../contracts/solc/v0.8.6/VRFV2OwnerTestConsumer.bin VRFV2OwnerTestConsumer vrf_owner_test_consumer +//go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.6/VRFv2Consumer.abi ../../contracts/solc/v0.8.6/VRFv2Consumer.bin VRFv2Consumer vrf_v2_consumer_wrapper //go:generate go run ./generation/generate_link/wrap_link.go @@ -148,11 +155,7 @@ package gethwrappers // 2. Generate events mock .sol files based on ABI of compiled contracts. // 3. Compile events mock contracts. ./generation/compile_event_mock_contract.sh calls contracts/scripts/native_solc_compile_all_events_mock to compile events mock contracts. // 4. Generate wrappers for events mock contracts. -//go:generate go run ./generation/generate_events_mock/create_events_mock_contract.go ../../contracts/solc/v0.8.6/functions/v0_0_0/FunctionsOracle.abi ../../contracts/src/v0.8/mocks/FunctionsOracleEventsMock.sol FunctionsOracleEventsMock -//go:generate go run ./generation/generate_events_mock/create_events_mock_contract.go ../../contracts/solc/v0.8.6/functions/v0_0_0/FunctionsBillingRegistry.abi ../../contracts/src/v0.8/mocks/FunctionsBillingRegistryEventsMock.sol FunctionsBillingRegistryEventsMock //go:generate ./generation/compile_event_mock_contract.sh -//go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.6/FunctionsOracleEventsMock.abi ../../contracts/solc/v0.8.6/FunctionsOracleEventsMock.bin FunctionsOracleEventsMock functions_oracle_events_mock -//go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.6/FunctionsBillingRegistryEventsMock.abi ../../contracts/solc/v0.8.6/FunctionsBillingRegistryEventsMock.bin FunctionsBillingRegistryEventsMock functions_billing_registry_events_mock // Transmission //go:generate go generate ./transmission diff --git a/core/internal/cltest/cltest.go b/core/internal/cltest/cltest.go index a9ff8144b3c..3fa00901779 100644 --- a/core/internal/cltest/cltest.go +++ b/core/internal/cltest/cltest.go @@ -61,7 +61,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/cmd" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" - configtest2 "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" clhttptest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/httptest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/keystest" @@ -108,7 +107,7 @@ const ( // SessionSecret is the hardcoded secret solely used for test SessionSecret = "clsession_test_secret" // DefaultPeerID is the peer ID of the default p2p key - DefaultPeerID = "12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X" + DefaultPeerID = configtest.DefaultPeerID // DefaultOCRKeyBundleID is the ID of the default ocr key bundle DefaultOCRKeyBundleID = "f5bf259689b26f1374efb3c9a9868796953a0f814bb2d39b968d0e61b58620a5" // DefaultOCR2KeyBundleID is the ID of the fixture ocr2 key bundle @@ -240,7 +239,7 @@ func NewWSServer(t *testing.T, chainID *big.Int, callback testutils.JSONRPCHandl func NewApplicationEVMDisabled(t *testing.T) *TestApplication { t.Helper() - c := configtest2.NewGeneralConfig(t, nil) + c := configtest.NewGeneralConfig(t, nil) return NewApplicationWithConfig(t, c) } @@ -250,7 +249,7 @@ func NewApplicationEVMDisabled(t *testing.T) *TestApplication { func NewApplication(t testing.TB, flagsAndDeps ...interface{}) *TestApplication { t.Helper() - c := configtest2.NewGeneralConfig(t, nil) + c := configtest.NewGeneralConfig(t, nil) return NewApplicationWithConfig(t, c, flagsAndDeps...) } @@ -260,7 +259,7 @@ func NewApplication(t testing.TB, flagsAndDeps ...interface{}) *TestApplication func NewApplicationWithKey(t *testing.T, flagsAndDeps ...interface{}) *TestApplication { t.Helper() - config := configtest2.NewGeneralConfig(t, nil) + config := configtest.NewGeneralConfig(t, nil) return NewApplicationWithConfigAndKey(t, config, flagsAndDeps...) } @@ -1617,7 +1616,7 @@ func AssertPipelineTaskRunsErrored(t testing.TB, runs []pipeline.TaskRun) { } func NewTestChainScopedConfig(t testing.TB) evmconfig.ChainScopedConfig { - cfg := configtest2.NewGeneralConfig(t, nil) + cfg := configtest.NewGeneralConfig(t, nil) return evmtest.NewChainScopedConfig(t, cfg) } diff --git a/core/internal/cltest/factories.go b/core/internal/cltest/factories.go index a1a5d9db6be..85ffc6b02bd 100644 --- a/core/internal/cltest/factories.go +++ b/core/internal/cltest/factories.go @@ -34,7 +34,7 @@ import ( evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/flux_aggregator_wrapper" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/keeper" diff --git a/core/internal/cltest/heavyweight/orm.go b/core/internal/cltest/heavyweight/orm.go index 841901c25aa..2f9370f35a6 100644 --- a/core/internal/cltest/heavyweight/orm.go +++ b/core/internal/cltest/heavyweight/orm.go @@ -14,13 +14,14 @@ import ( "runtime" "testing" - "github.com/smartcontractkit/sqlx" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/sqlx" + "github.com/smartcontractkit/chainlink/v2/core/cmd" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest2 "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/pg" "github.com/smartcontractkit/chainlink/v2/core/store/dialects" @@ -50,7 +51,7 @@ func prepareFullTestDBV2(t testing.TB, name string, empty bool, loadFixtures boo t.Fatal("could not load fixtures into an empty DB") } - gcfg := configtest2.NewGeneralConfigSimulated(t, func(c *chainlink.Config, s *chainlink.Secrets) { + gcfg := configtest.NewGeneralConfigSimulated(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.Database.Dialect = dialects.Postgres if overrideFn != nil { overrideFn(c, s) @@ -68,7 +69,7 @@ func prepareFullTestDBV2(t testing.TB, name string, empty bool, loadFixtures boo os.RemoveAll(gcfg.RootDir()) }) - gcfg = configtest2.NewGeneralConfigSimulated(t, func(c *chainlink.Config, s *chainlink.Secrets) { + gcfg = configtest.NewGeneralConfigSimulated(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.Database.Dialect = dialects.Postgres s.Database.URL = models.MustSecretURL(migrationTestDBURL) if overrideFn != nil { diff --git a/core/internal/cltest/job_factories.go b/core/internal/cltest/job_factories.go index 910ffe79e38..77fee125e21 100644 --- a/core/internal/cltest/job_factories.go +++ b/core/internal/cltest/job_factories.go @@ -5,11 +5,12 @@ import ( "testing" "github.com/google/uuid" - "github.com/smartcontractkit/sqlx" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/sqlx" + "github.com/smartcontractkit/chainlink/v2/core/bridges" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/job" diff --git a/core/internal/features/features_test.go b/core/internal/features/features_test.go index c5d16590d52..058c8325b9a 100644 --- a/core/internal/features/features_test.go +++ b/core/internal/features/features_test.go @@ -56,7 +56,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest/heavyweight" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest2 "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" @@ -83,7 +83,7 @@ func TestIntegration_ExternalInitiatorV2(t *testing.T) { ethClient := cltest.NewEthMocksWithStartupAssertions(t) - cfg := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.JobPipeline.ExternalInitiatorsEnabled = ptr(true) c.Database.Listener.FallbackPollInterval = models.MustNewDuration(10 * time.Millisecond) }) @@ -362,7 +362,7 @@ func TestIntegration_DirectRequest(t *testing.T) { t.Run(test.name, func(t *testing.T) { // Simulate a consumer contract calling to obtain ETH quotes in 3 different currencies // in a single callback. - config := configtest2.NewGeneralConfigSimulated(t, func(c *chainlink.Config, s *chainlink.Secrets) { + config := configtest.NewGeneralConfigSimulated(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.Database.Listener.FallbackPollInterval = models.MustNewDuration(100 * time.Millisecond) c.EVM[0].GasEstimator.EIP1559DynamicFees = ptr(true) }) @@ -467,7 +467,7 @@ func setupAppForEthTx(t *testing.T, operatorContracts OperatorContracts) (app *c b := operatorContracts.sim lggr, o := logger.TestLoggerObserved(t, zapcore.DebugLevel) - cfg := configtest2.NewGeneralConfigSimulated(t, func(c *chainlink.Config, s *chainlink.Secrets) { + cfg := configtest.NewGeneralConfigSimulated(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.Database.Listener.FallbackPollInterval = models.MustNewDuration(100 * time.Millisecond) }) app = cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, cfg, b, lggr) @@ -1320,7 +1320,7 @@ func TestIntegration_BlockHistoryEstimator(t *testing.T) { var initialDefaultGasPrice int64 = 5_000_000_000 maxGasPrice := assets.NewWeiI(10 * initialDefaultGasPrice) - cfg := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.EVM[0].BalanceMonitor.Enabled = ptr(false) c.EVM[0].GasEstimator.BlockHistory.CheckInclusionBlocks = ptr[uint16](0) c.EVM[0].GasEstimator.PriceDefault = assets.NewWeiI(initialDefaultGasPrice) diff --git a/core/internal/testutils/configtest/general_config.go b/core/internal/testutils/configtest/general_config.go index 1b652eeecdd..93d388b2d30 100644 --- a/core/internal/testutils/configtest/general_config.go +++ b/core/internal/testutils/configtest/general_config.go @@ -1,6 +1,122 @@ package configtest -// TODO move? -const ( - DefaultPeerID = "12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X" +import ( + "net" + "testing" + "time" + + "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" + evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" + evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" + "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" + "github.com/smartcontractkit/chainlink/v2/core/store/dialects" + "github.com/smartcontractkit/chainlink/v2/core/store/models" + "github.com/smartcontractkit/chainlink/v2/core/utils" ) + +const DefaultPeerID = "12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X" + +// NewTestGeneralConfig returns a new chainlink.GeneralConfig with default test overrides and one chain with evmclient.NullClientChainID. +func NewTestGeneralConfig(t testing.TB) chainlink.GeneralConfig { return NewGeneralConfig(t, nil) } + +// NewGeneralConfig returns a new chainlink.GeneralConfig with overrides. +// The default test overrides are applied before overrideFn, and include one chain with evmclient.NullClientChainID. +func NewGeneralConfig(t testing.TB, overrideFn func(*chainlink.Config, *chainlink.Secrets)) chainlink.GeneralConfig { + tempDir := t.TempDir() + g, err := chainlink.GeneralConfigOpts{ + OverrideFn: func(c *chainlink.Config, s *chainlink.Secrets) { + overrides(c, s) + c.RootDir = &tempDir + if fn := overrideFn; fn != nil { + fn(c, s) + } + }, + }.New() + require.NoError(t, err) + return g +} + +// overrides applies some test config settings and adds a default chain with evmclient.NullClientChainID. +func overrides(c *chainlink.Config, s *chainlink.Secrets) { + s.Password.Keystore = models.NewSecret("dummy-to-pass-validation") + + c.Insecure.OCRDevelopmentMode = ptr(true) + c.InsecureFastScrypt = ptr(true) + c.ShutdownGracePeriod = models.MustNewDuration(testutils.DefaultWaitTimeout) + + c.Database.Dialect = dialects.TransactionWrappedPostgres + c.Database.Lock.Enabled = ptr(false) + c.Database.MaxIdleConns = ptr[int64](20) + c.Database.MaxOpenConns = ptr[int64](20) + c.Database.MigrateOnStartup = ptr(false) + c.Database.DefaultLockTimeout = models.MustNewDuration(1 * time.Minute) + + c.JobPipeline.ReaperInterval = models.MustNewDuration(0) + + c.P2P.V1.Enabled = ptr(false) + c.P2P.V2.Enabled = ptr(false) + + c.WebServer.SessionTimeout = models.MustNewDuration(2 * time.Minute) + c.WebServer.BridgeResponseURL = models.MustParseURL("http://localhost:6688") + testIP := net.ParseIP("127.0.0.1") + c.WebServer.ListenIP = &testIP + c.WebServer.TLS.ListenIP = &testIP + + chainID := utils.NewBigI(evmclient.NullClientChainID) + c.EVM = append(c.EVM, &evmcfg.EVMConfig{ + ChainID: chainID, + Chain: evmcfg.Defaults(chainID), + Nodes: evmcfg.EVMNodes{ + &evmcfg.Node{ + Name: ptr("test"), + WSURL: &models.URL{}, + HTTPURL: &models.URL{}, + SendOnly: new(bool), + Order: ptr[int32](100), + }, + }, + }) +} + +// NewGeneralConfigSimulated returns a new chainlink.GeneralConfig with overrides, including the simulated EVM chain. +// The default test overrides are applied before overrideFn. +// The simulated chain (testutils.SimulatedChainID) replaces the null chain (evmclient.NullClientChainID). +func NewGeneralConfigSimulated(t testing.TB, overrideFn func(*chainlink.Config, *chainlink.Secrets)) chainlink.GeneralConfig { + return NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + simulated(c, s) + if fn := overrideFn; fn != nil { + fn(c, s) + } + }) +} + +// simulated is a config override func that appends the simulated EVM chain (testutils.SimulatedChainID), +// or replaces the null chain (client.NullClientChainID) if that is the only entry. +func simulated(c *chainlink.Config, s *chainlink.Secrets) { + chainID := utils.NewBig(testutils.SimulatedChainID) + enabled := true + cfg := evmcfg.EVMConfig{ + ChainID: chainID, + Chain: evmcfg.Defaults(chainID), + Enabled: &enabled, + Nodes: evmcfg.EVMNodes{&validTestNode}, + } + if len(c.EVM) == 1 && c.EVM[0].ChainID.Cmp(utils.NewBigI(client.NullClientChainID)) == 0 { + c.EVM[0] = &cfg // replace null, if only entry + } else { + c.EVM = append(c.EVM, &cfg) + } +} + +var validTestNode = evmcfg.Node{ + Name: ptr("simulated-node"), + WSURL: models.MustParseURL("WSS://simulated-wss.com/ws"), + HTTPURL: models.MustParseURL("http://simulated.com"), + SendOnly: nil, + Order: ptr(int32(1)), +} + +func ptr[T any](v T) *T { return &v } diff --git a/core/internal/testutils/configtest/v2/toml/toml.go b/core/internal/testutils/configtest/toml.go similarity index 95% rename from core/internal/testutils/configtest/v2/toml/toml.go rename to core/internal/testutils/configtest/toml.go index 0cb89010f25..78db05f9c3c 100644 --- a/core/internal/testutils/configtest/v2/toml/toml.go +++ b/core/internal/testutils/configtest/toml.go @@ -1,4 +1,4 @@ -package testtomlutils +package configtest import ( "os" diff --git a/core/internal/testutils/configtest/v2/general_config.go b/core/internal/testutils/configtest/v2/general_config.go deleted file mode 100644 index febbb367bd5..00000000000 --- a/core/internal/testutils/configtest/v2/general_config.go +++ /dev/null @@ -1,120 +0,0 @@ -package v2 - -import ( - "net" - "testing" - "time" - - "github.com/stretchr/testify/require" - - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" - evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" - evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" - "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/store/dialects" - "github.com/smartcontractkit/chainlink/v2/core/store/models" - "github.com/smartcontractkit/chainlink/v2/core/utils" -) - -// NewTestGeneralConfig returns a new chainlink.GeneralConfig with default test overrides and one chain with evmclient.NullClientChainID. -func NewTestGeneralConfig(t testing.TB) chainlink.GeneralConfig { return NewGeneralConfig(t, nil) } - -// NewGeneralConfig returns a new chainlink.GeneralConfig with overrides. -// The default test overrides are applied before overrideFn, and include one chain with evmclient.NullClientChainID. -func NewGeneralConfig(t testing.TB, overrideFn func(*chainlink.Config, *chainlink.Secrets)) chainlink.GeneralConfig { - tempDir := t.TempDir() - g, err := chainlink.GeneralConfigOpts{ - OverrideFn: func(c *chainlink.Config, s *chainlink.Secrets) { - overrides(c, s) - c.RootDir = &tempDir - if fn := overrideFn; fn != nil { - fn(c, s) - } - }, - }.New() - require.NoError(t, err) - return g -} - -// overrides applies some test config settings and adds a default chain with evmclient.NullClientChainID. -func overrides(c *chainlink.Config, s *chainlink.Secrets) { - s.Password.Keystore = models.NewSecret("dummy-to-pass-validation") - - c.Insecure.OCRDevelopmentMode = ptr(true) - c.InsecureFastScrypt = ptr(true) - c.ShutdownGracePeriod = models.MustNewDuration(testutils.DefaultWaitTimeout) - - c.Database.Dialect = dialects.TransactionWrappedPostgres - c.Database.Lock.Enabled = ptr(false) - c.Database.MaxIdleConns = ptr[int64](20) - c.Database.MaxOpenConns = ptr[int64](20) - c.Database.MigrateOnStartup = ptr(false) - c.Database.DefaultLockTimeout = models.MustNewDuration(1 * time.Minute) - - c.JobPipeline.ReaperInterval = models.MustNewDuration(0) - - c.P2P.V1.Enabled = ptr(false) - c.P2P.V2.Enabled = ptr(false) - - c.WebServer.SessionTimeout = models.MustNewDuration(2 * time.Minute) - c.WebServer.BridgeResponseURL = models.MustParseURL("http://localhost:6688") - testIP := net.ParseIP("127.0.0.1") - c.WebServer.ListenIP = &testIP - c.WebServer.TLS.ListenIP = &testIP - - chainID := utils.NewBigI(evmclient.NullClientChainID) - c.EVM = append(c.EVM, &evmcfg.EVMConfig{ - ChainID: chainID, - Chain: evmcfg.Defaults(chainID), - Nodes: evmcfg.EVMNodes{ - &evmcfg.Node{ - Name: ptr("test"), - WSURL: &models.URL{}, - HTTPURL: &models.URL{}, - SendOnly: new(bool), - Order: ptr[int32](100), - }, - }, - }) -} - -// NewGeneralConfigSimulated returns a new chainlink.GeneralConfig with overrides, including the simulated EVM chain. -// The default test overrides are applied before overrideFn. -// The simulated chain (testutils.SimulatedChainID) replaces the null chain (evmclient.NullClientChainID). -func NewGeneralConfigSimulated(t testing.TB, overrideFn func(*chainlink.Config, *chainlink.Secrets)) chainlink.GeneralConfig { - return NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { - simulated(c, s) - if fn := overrideFn; fn != nil { - fn(c, s) - } - }) -} - -// simulated is a config override func that appends the simulated EVM chain (testutils.SimulatedChainID), -// or replaces the null chain (client.NullClientChainID) if that is the only entry. -func simulated(c *chainlink.Config, s *chainlink.Secrets) { - chainID := utils.NewBig(testutils.SimulatedChainID) - enabled := true - cfg := evmcfg.EVMConfig{ - ChainID: chainID, - Chain: evmcfg.Defaults(chainID), - Enabled: &enabled, - Nodes: evmcfg.EVMNodes{&validTestNode}, - } - if len(c.EVM) == 1 && c.EVM[0].ChainID.Cmp(utils.NewBigI(client.NullClientChainID)) == 0 { - c.EVM[0] = &cfg // replace null, if only entry - } else { - c.EVM = append(c.EVM, &cfg) - } -} - -var validTestNode = evmcfg.Node{ - Name: ptr("simulated-node"), - WSURL: models.MustParseURL("WSS://simulated-wss.com/ws"), - HTTPURL: models.MustParseURL("http://simulated.com"), - SendOnly: nil, - Order: ptr(int32(1)), -} - -func ptr[T any](v T) *T { return &v } diff --git a/core/internal/testutils/evmtest/v2/evmtest.go b/core/internal/testutils/evmtest/v2/evmtest.go index 400690480d7..fa22588c8fb 100644 --- a/core/internal/testutils/evmtest/v2/evmtest.go +++ b/core/internal/testutils/evmtest/v2/evmtest.go @@ -5,7 +5,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/utils" ) diff --git a/core/services/blockhashstore/bhs_test.go b/core/services/blockhashstore/bhs_test.go index ed32b3ab49f..5c501a62ac9 100644 --- a/core/services/blockhashstore/bhs_test.go +++ b/core/services/blockhashstore/bhs_test.go @@ -12,7 +12,7 @@ import ( txmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr/mocks" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/blockhash_store" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/blockhashstore/delegate_test.go b/core/services/blockhashstore/delegate_test.go index 582492105e0..089e9544af5 100644 --- a/core/services/blockhashstore/delegate_test.go +++ b/core/services/blockhashstore/delegate_test.go @@ -15,7 +15,7 @@ import ( mocklp "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/chainlink/relayer_chain_interoperators_test.go b/core/services/chainlink/relayer_chain_interoperators_test.go index 5b17e2e4232..b7291e7dc74 100644 --- a/core/services/chainlink/relayer_chain_interoperators_test.go +++ b/core/services/chainlink/relayer_chain_interoperators_test.go @@ -29,7 +29,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/plugins" evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/utils" ) diff --git a/core/services/cron/cron_test.go b/core/services/cron/cron_test.go index 174f80586ae..19a51a30650 100644 --- a/core/services/cron/cron_test.go +++ b/core/services/cron/cron_test.go @@ -11,7 +11,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/directrequest/delegate_test.go b/core/services/directrequest/delegate_test.go index ffd78443cc2..e58dbaeb50c 100644 --- a/core/services/directrequest/delegate_test.go +++ b/core/services/directrequest/delegate_test.go @@ -20,7 +20,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/operator_wrapper" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/feeds/orm_test.go b/core/services/feeds/orm_test.go index fab9d39a265..746956bbfcd 100644 --- a/core/services/feeds/orm_test.go +++ b/core/services/feeds/orm_test.go @@ -14,7 +14,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/feeds/service_test.go b/core/services/feeds/service_test.go index 744c5d14702..c94a75b3dd5 100644 --- a/core/services/feeds/service_test.go +++ b/core/services/feeds/service_test.go @@ -15,7 +15,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/fluxmonitorv2/flux_monitor_test.go b/core/services/fluxmonitorv2/flux_monitor_test.go index 83ffee8ac57..0d1eb085a84 100644 --- a/core/services/fluxmonitorv2/flux_monitor_test.go +++ b/core/services/fluxmonitorv2/flux_monitor_test.go @@ -32,7 +32,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest/heavyweight" "github.com/smartcontractkit/chainlink/v2/core/internal/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" corenull "github.com/smartcontractkit/chainlink/v2/core/null" diff --git a/core/services/fluxmonitorv2/orm_test.go b/core/services/fluxmonitorv2/orm_test.go index 3bebc150c82..0bb08032617 100644 --- a/core/services/fluxmonitorv2/orm_test.go +++ b/core/services/fluxmonitorv2/orm_test.go @@ -16,7 +16,7 @@ import ( txmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/functions/listener_test.go b/core/services/functions/listener_test.go index 6f0badd6e11..007a2a91688 100644 --- a/core/services/functions/listener_test.go +++ b/core/services/functions/listener_test.go @@ -21,7 +21,7 @@ import ( log_mocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/job/job_orm_test.go b/core/services/job/job_orm_test.go index 20f569a893a..74416e68dce 100644 --- a/core/services/job/job_orm_test.go +++ b/core/services/job/job_orm_test.go @@ -23,7 +23,7 @@ import ( evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/job/job_pipeline_orm_integration_test.go b/core/services/job/job_pipeline_orm_integration_test.go index a5d3ee984da..1158fc46260 100644 --- a/core/services/job/job_pipeline_orm_integration_test.go +++ b/core/services/job/job_pipeline_orm_integration_test.go @@ -4,14 +4,15 @@ import ( "testing" "time" - "github.com/smartcontractkit/sqlx" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/sqlx" + "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest2 "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" @@ -44,7 +45,7 @@ func TestPipelineORM_Integration(t *testing.T) { answer2 [type=bridge name=election_winner index=1]; ` - config := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + config := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.JobPipeline.HTTPRequest.DefaultTimeout = models.MustNewDuration(30 * time.Millisecond) }) db := pgtest.NewSqlxDB(t) @@ -147,7 +148,7 @@ func TestPipelineORM_Integration(t *testing.T) { t.Run("creates runs", func(t *testing.T) { lggr := logger.TestLogger(t) - cfg := configtest2.NewTestGeneralConfig(t) + cfg := configtest.NewTestGeneralConfig(t) clearJobsDb(t, db) orm := pipeline.NewORM(db, logger.TestLogger(t), cfg.Database(), cfg.JobPipeline().MaxSuccessfulRuns()) btORM := bridges.NewORM(db, logger.TestLogger(t), cfg.Database()) diff --git a/core/services/job/orm_test.go b/core/services/job/orm_test.go index 15a2432f9e9..a6986d7fb32 100644 --- a/core/services/job/orm_test.go +++ b/core/services/job/orm_test.go @@ -3,13 +3,14 @@ package job_test import ( "testing" - "github.com/smartcontractkit/sqlx" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/sqlx" + "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/chains/evm" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/logger" clnull "github.com/smartcontractkit/chainlink/v2/core/null" diff --git a/core/services/job/runner_integration_test.go b/core/services/job/runner_integration_test.go index 05782f95ce8..c0fff1e560a 100644 --- a/core/services/job/runner_integration_test.go +++ b/core/services/job/runner_integration_test.go @@ -13,39 +13,38 @@ import ( "testing" "time" - configtest2 "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" - "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/validate" - evmrelay "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm" - "github.com/smartcontractkit/chainlink/v2/core/services/srvctest" - "github.com/smartcontractkit/chainlink/v2/core/utils" + "github.com/google/uuid" + "github.com/pelletier/go-toml" + "github.com/pkg/errors" + "github.com/shopspring/decimal" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + "gopkg.in/guregu/null.v4" "github.com/smartcontractkit/chainlink/v2/core/auth" "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" clhttptest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/httptest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" + "github.com/smartcontractkit/chainlink/v2/core/logger" + "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/job" + "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/ocr" + "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/validate" "github.com/smartcontractkit/chainlink/v2/core/services/ocrcommon" "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" + evmrelay "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm" + "github.com/smartcontractkit/chainlink/v2/core/services/srvctest" "github.com/smartcontractkit/chainlink/v2/core/services/telemetry" "github.com/smartcontractkit/chainlink/v2/core/services/webhook" "github.com/smartcontractkit/chainlink/v2/core/store/models" + "github.com/smartcontractkit/chainlink/v2/core/utils" "github.com/smartcontractkit/chainlink/v2/core/web" - - "github.com/google/uuid" - "github.com/pelletier/go-toml" - "github.com/pkg/errors" - "github.com/shopspring/decimal" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/require" - "gopkg.in/guregu/null.v4" ) var monitoringEndpoint = telemetry.MonitoringEndpointGenerator(&telemetry.NoopAgent{}) @@ -58,7 +57,7 @@ func TestRunner(t *testing.T) { _, transmitterAddress := cltest.MustInsertRandomKey(t, ethKeyStore) require.NoError(t, keyStore.OCR().Add(cltest.DefaultOCRKey)) - config := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + config := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.P2P.V1.Enabled = ptr(true) c.P2P.V1.DefaultBootstrapPeers = &[]string{ "/dns4/chain.link/tcp/1234/p2p/16Uiu2HAm58SP7UL8zsnpeuwHfytLocaqgnyaYKP8wu7qRdrixLju", @@ -759,7 +758,7 @@ func TestRunner_Success_Callback_AsyncJob(t *testing.T) { ethClient := cltest.NewEthMocksWithStartupAssertions(t) - cfg := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { t := true c.JobPipeline.ExternalInitiatorsEnabled = &t c.Database.Listener.FallbackPollInterval = models.MustNewDuration(10 * time.Millisecond) @@ -941,7 +940,7 @@ func TestRunner_Error_Callback_AsyncJob(t *testing.T) { ethClient := cltest.NewEthMocksWithStartupAssertions(t) - cfg := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { t := true c.JobPipeline.ExternalInitiatorsEnabled = &t c.Database.Listener.FallbackPollInterval = models.MustNewDuration(10 * time.Millisecond) diff --git a/core/services/job/spawner_test.go b/core/services/job/spawner_test.go index 4e28dcdf062..be4a480a6c9 100644 --- a/core/services/job/spawner_test.go +++ b/core/services/job/spawner_test.go @@ -18,7 +18,7 @@ import ( evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest2 "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" @@ -73,7 +73,7 @@ func (g *relayGetter) Get(id relay.ID) (loop.Relayer, error) { func TestSpawner_CreateJobDeleteJob(t *testing.T) { t.Parallel() - config := configtest2.NewTestGeneralConfig(t) + config := configtest.NewTestGeneralConfig(t) db := pgtest.NewSqlxDB(t) keyStore := cltest.NewKeyStore(t, db, config.Database()) ethKeyStore := keyStore.Eth() @@ -264,7 +264,7 @@ func TestSpawner_CreateJobDeleteJob(t *testing.T) { }) t.Run("Unregisters filters on 'DeleteJob()'", func(t *testing.T) { - config = configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + config = configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.Feature.LogPoller = func(b bool) *bool { return &b }(true) }) lp := &mocklp.LogPoller{} diff --git a/core/services/keeper/orm_test.go b/core/services/keeper/orm_test.go index 972437eda1d..d990effa103 100644 --- a/core/services/keeper/orm_test.go +++ b/core/services/keeper/orm_test.go @@ -9,13 +9,14 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/onsi/gomega" - "github.com/smartcontractkit/sqlx" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/sqlx" + evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/keeper/registry1_1_synchronizer_test.go b/core/services/keeper/registry1_1_synchronizer_test.go index 8444aa50dd4..031b7a59074 100644 --- a/core/services/keeper/registry1_1_synchronizer_test.go +++ b/core/services/keeper/registry1_1_synchronizer_test.go @@ -18,7 +18,7 @@ import ( registry1_1 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_1" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/keeper/registry1_2_synchronizer_test.go b/core/services/keeper/registry1_2_synchronizer_test.go index f593a638f99..e7d8d6a48a2 100644 --- a/core/services/keeper/registry1_2_synchronizer_test.go +++ b/core/services/keeper/registry1_2_synchronizer_test.go @@ -18,7 +18,7 @@ import ( registry1_2 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_2" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/keeper/registry1_3_synchronizer_test.go b/core/services/keeper/registry1_3_synchronizer_test.go index 53b5cbf983f..a0522fd717e 100644 --- a/core/services/keeper/registry1_3_synchronizer_test.go +++ b/core/services/keeper/registry1_3_synchronizer_test.go @@ -14,7 +14,7 @@ import ( evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" registry1_3 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_3" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/utils" logmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log/mocks" diff --git a/core/services/keeper/registry_synchronizer_helper_test.go b/core/services/keeper/registry_synchronizer_helper_test.go index 99fb54eba4d..63dc6343535 100644 --- a/core/services/keeper/registry_synchronizer_helper_test.go +++ b/core/services/keeper/registry_synchronizer_helper_test.go @@ -14,7 +14,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log" logmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/keeper/upkeep_executer_test.go b/core/services/keeper/upkeep_executer_test.go index 39f85aedcd9..7f9698435f8 100644 --- a/core/services/keeper/upkeep_executer_test.go +++ b/core/services/keeper/upkeep_executer_test.go @@ -9,11 +9,12 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/onsi/gomega" - "github.com/smartcontractkit/sqlx" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/sqlx" + "github.com/smartcontractkit/chainlink/v2/core/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm" evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" @@ -24,7 +25,7 @@ import ( evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/keystore/cosmos_test.go b/core/services/keystore/cosmos_test.go index ada7c25a2c4..3c33f16282d 100644 --- a/core/services/keystore/cosmos_test.go +++ b/core/services/keystore/cosmos_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/cosmoskey" diff --git a/core/services/keystore/csa_test.go b/core/services/keystore/csa_test.go index ef2dd1f6893..b6dfb009593 100644 --- a/core/services/keystore/csa_test.go +++ b/core/services/keystore/csa_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/csakey" diff --git a/core/services/keystore/dkgencrypt_test.go b/core/services/keystore/dkgencrypt_test.go index 1edbc2120fa..36f48f9c2b4 100644 --- a/core/services/keystore/dkgencrypt_test.go +++ b/core/services/keystore/dkgencrypt_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/dkgencryptkey" diff --git a/core/services/keystore/dkgsign_test.go b/core/services/keystore/dkgsign_test.go index d699800b509..5ea23a516be 100644 --- a/core/services/keystore/dkgsign_test.go +++ b/core/services/keystore/dkgsign_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/dkgsignkey" diff --git a/core/services/keystore/eth_test.go b/core/services/keystore/eth_test.go index 0fec509a325..4165350300f 100644 --- a/core/services/keystore/eth_test.go +++ b/core/services/keystore/eth_test.go @@ -16,7 +16,7 @@ import ( evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" diff --git a/core/services/keystore/master_test.go b/core/services/keystore/master_test.go index 7a280cc6756..73f636c6625 100644 --- a/core/services/keystore/master_test.go +++ b/core/services/keystore/master_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" ) diff --git a/core/services/keystore/ocr2_test.go b/core/services/keystore/ocr2_test.go index b4feb33b5f5..9223538a766 100644 --- a/core/services/keystore/ocr2_test.go +++ b/core/services/keystore/ocr2_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype" diff --git a/core/services/keystore/ocr_test.go b/core/services/keystore/ocr_test.go index 5698352ec30..200d62415eb 100644 --- a/core/services/keystore/ocr_test.go +++ b/core/services/keystore/ocr_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocrkey" diff --git a/core/services/keystore/p2p_test.go b/core/services/keystore/p2p_test.go index 63654786fd1..89cab3e1621 100644 --- a/core/services/keystore/p2p_test.go +++ b/core/services/keystore/p2p_test.go @@ -9,7 +9,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" diff --git a/core/services/keystore/solana_test.go b/core/services/keystore/solana_test.go index 8d7d90a9da8..6e895a56117 100644 --- a/core/services/keystore/solana_test.go +++ b/core/services/keystore/solana_test.go @@ -8,7 +8,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/solkey" diff --git a/core/services/keystore/starknet_test.go b/core/services/keystore/starknet_test.go index 571a809a55a..df9516f8710 100644 --- a/core/services/keystore/starknet_test.go +++ b/core/services/keystore/starknet_test.go @@ -13,7 +13,7 @@ import ( "github.com/smartcontractkit/caigo" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/starkkey" diff --git a/core/services/keystore/vrf_test.go b/core/services/keystore/vrf_test.go index f0c6949bbea..7a2e91ffec3 100644 --- a/core/services/keystore/vrf_test.go +++ b/core/services/keystore/vrf_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/vrfkey" diff --git a/core/services/ocr/contract_tracker_test.go b/core/services/ocr/contract_tracker_test.go index d8fe45e8b33..5684219cf16 100644 --- a/core/services/ocr/contract_tracker_test.go +++ b/core/services/ocr/contract_tracker_test.go @@ -23,7 +23,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/offchain_aggregator_wrapper" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/ocr/database_test.go b/core/services/ocr/database_test.go index 8b345df8597..6a72c27aa65 100644 --- a/core/services/ocr/database_test.go +++ b/core/services/ocr/database_test.go @@ -7,14 +7,15 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/smartcontractkit/libocr/gethwrappers/offchainaggregator" - ocrtypes "github.com/smartcontractkit/libocr/offchainreporting/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/libocr/gethwrappers/offchainaggregator" + ocrtypes "github.com/smartcontractkit/libocr/offchainreporting/types" + "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/ocr" "github.com/smartcontractkit/chainlink/v2/core/utils" diff --git a/core/services/ocr/validate_test.go b/core/services/ocr/validate_test.go index 3efd2d8381e..0164fd82c54 100644 --- a/core/services/ocr/validate_test.go +++ b/core/services/ocr/validate_test.go @@ -12,7 +12,7 @@ import ( "gopkg.in/guregu/null.v4" evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" - configtest2 "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/job" @@ -399,7 +399,7 @@ answer1 [type=median index=0]; for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { - c := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + c := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.Insecure.OCRDevelopmentMode = null.BoolFrom(false).Ptr() if tc.overrides != nil { tc.overrides(c, s) diff --git a/core/services/ocr2/database_test.go b/core/services/ocr2/database_test.go index 18c0ec85194..aabb2b33a79 100644 --- a/core/services/ocr2/database_test.go +++ b/core/services/ocr2/database_test.go @@ -7,14 +7,15 @@ import ( medianconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/median/config" - ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" - "github.com/smartcontractkit/sqlx" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + "github.com/smartcontractkit/sqlx" + "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/job" diff --git a/core/services/ocr2/delegate_test.go b/core/services/ocr2/delegate_test.go index 3973774c56a..daffac3f96b 100644 --- a/core/services/ocr2/delegate_test.go +++ b/core/services/ocr2/delegate_test.go @@ -13,7 +13,7 @@ import ( txmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/ocr2/plugins/dkg/config/config_test.go b/core/services/ocr2/plugins/dkg/config/config_test.go index b49a5277d9c..fe796a9ad6c 100644 --- a/core/services/ocr2/plugins/dkg/config/config_test.go +++ b/core/services/ocr2/plugins/dkg/config/config_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/dkg/config" ) diff --git a/core/services/ocr2/validate/validate_test.go b/core/services/ocr2/validate/validate_test.go index 98a13ebf8a7..4685ed745dd 100644 --- a/core/services/ocr2/validate/validate_test.go +++ b/core/services/ocr2/validate/validate_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest2 "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/job" medianconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/median/config" @@ -584,7 +584,7 @@ KeyID = "6f3b82406688b8ddb944c6f2e6d808f014c8fa8d568d639c25019568c for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { - c := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + c := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.Insecure.OCRDevelopmentMode = testutils.Ptr(false) // tests run with OCRDevelopmentMode by default. if tc.overrides != nil { tc.overrides(c, s) diff --git a/core/services/ocrcommon/peer_wrapper_test.go b/core/services/ocrcommon/peer_wrapper_test.go index 45edc64e9db..209bc6b969b 100644 --- a/core/services/ocrcommon/peer_wrapper_test.go +++ b/core/services/ocrcommon/peer_wrapper_test.go @@ -10,7 +10,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" @@ -25,7 +25,7 @@ func Test_SingletonPeerWrapper_Start(t *testing.T) { db := pgtest.NewSqlxDB(t) - peerID, err := p2ppeer.Decode("12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X") + peerID, err := p2ppeer.Decode(configtest.DefaultPeerID) require.NoError(t, err) t.Run("with no p2p keys returns error", func(t *testing.T) { diff --git a/core/services/ocrcommon/peerstore_test.go b/core/services/ocrcommon/peerstore_test.go index ba55e0767ab..6e692153564 100644 --- a/core/services/ocrcommon/peerstore_test.go +++ b/core/services/ocrcommon/peerstore_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/require" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" @@ -21,7 +21,7 @@ import ( func Test_Peerstore_Start(t *testing.T) { db := pgtest.NewSqlxDB(t) - peerID, err := p2ppeer.Decode("12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X") + peerID, err := p2ppeer.Decode(configtest.DefaultPeerID) require.NoError(t, err) nonExistentP2PPeerID, err := p2ppeer.Decode("12D3KooWAdCzaesXyezatDzgGvCngqsBqoUqnV9PnVc46jsVt2i9") @@ -72,7 +72,7 @@ func Test_Peerstore_Start(t *testing.T) { func Test_Peerstore_WriteToDB(t *testing.T) { db := pgtest.NewSqlxDB(t) - peerID, err := p2ppeer.Decode("12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X") + peerID, err := p2ppeer.Decode(configtest.DefaultPeerID) require.NoError(t, err) cfg := configtest.NewTestGeneralConfig(t) diff --git a/core/services/ocrcommon/transmitter_pipeline_test.go b/core/services/ocrcommon/transmitter_pipeline_test.go index 8a1f2f2a922..e0114d0aa0d 100644 --- a/core/services/ocrcommon/transmitter_pipeline_test.go +++ b/core/services/ocrcommon/transmitter_pipeline_test.go @@ -9,7 +9,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/job" diff --git a/core/services/ocrcommon/transmitter_test.go b/core/services/ocrcommon/transmitter_test.go index ac5d120eb0d..d954da869bc 100644 --- a/core/services/ocrcommon/transmitter_test.go +++ b/core/services/ocrcommon/transmitter_test.go @@ -13,7 +13,7 @@ import ( txmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/ocrcommon" ) diff --git a/core/services/pg/locked_db_test.go b/core/services/pg/locked_db_test.go index aaf7ebf32c4..a2aebcd57f4 100644 --- a/core/services/pg/locked_db_test.go +++ b/core/services/pg/locked_db_test.go @@ -6,7 +6,7 @@ import ( "time" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/pg" diff --git a/core/services/pipeline/common_test.go b/core/services/pipeline/common_test.go index 37cc60f27e9..7da80d3af47 100644 --- a/core/services/pipeline/common_test.go +++ b/core/services/pipeline/common_test.go @@ -14,7 +14,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest2 "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" @@ -323,7 +323,7 @@ func TestTaskRunResult_IsPending(t *testing.T) { func TestSelectGasLimit(t *testing.T) { t.Parallel() - gcfg := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + gcfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.EVM[0].GasEstimator.LimitDefault = ptr(uint32(999)) c.EVM[0].GasEstimator.LimitJobType = toml.GasLimitJobType{ DR: ptr(uint32(100)), diff --git a/core/services/pipeline/orm_test.go b/core/services/pipeline/orm_test.go index 4c03ce16ef8..a487c231fb8 100644 --- a/core/services/pipeline/orm_test.go +++ b/core/services/pipeline/orm_test.go @@ -5,17 +5,18 @@ import ( "time" "github.com/google/uuid" - "github.com/smartcontractkit/sqlx" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/zap/zapcore" "gopkg.in/guregu/null.v4" + "github.com/smartcontractkit/sqlx" + "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest/heavyweight" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest2 "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" @@ -514,7 +515,7 @@ func Test_GetUnfinishedRuns_Keepers(t *testing.T) { // The test configures single Keeper job with two running tasks. // GetUnfinishedRuns() expects to catch both running tasks. - config := configtest2.NewTestGeneralConfig(t) + config := configtest.NewTestGeneralConfig(t) lggr := logger.TestLogger(t) db := pgtest.NewSqlxDB(t) keyStore := cltest.NewKeyStore(t, db, config.Database()) @@ -616,7 +617,7 @@ func Test_GetUnfinishedRuns_DirectRequest(t *testing.T) { // The test configures single DR job with two task runs: one is running and one is suspended. // GetUnfinishedRuns() expects to catch the one that is running. - config := configtest2.NewTestGeneralConfig(t) + config := configtest.NewTestGeneralConfig(t) lggr := logger.TestLogger(t) db := pgtest.NewSqlxDB(t) keyStore := cltest.NewKeyStore(t, db, config.Database()) @@ -709,7 +710,7 @@ func Test_Prune(t *testing.T) { n := uint64(2) - cfg := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.JobPipeline.MaxSuccessfulRuns = &n }) lggr, observed := logger.TestLoggerObserved(t, zapcore.DebugLevel) diff --git a/core/services/pipeline/runner_test.go b/core/services/pipeline/runner_test.go index 22b70829ba5..3abcdbe0abe 100644 --- a/core/services/pipeline/runner_test.go +++ b/core/services/pipeline/runner_test.go @@ -26,7 +26,7 @@ import ( bridgesMocks "github.com/smartcontractkit/chainlink/v2/core/bridges/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" clhttptest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/httptest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" diff --git a/core/services/pipeline/task.bridge_test.go b/core/services/pipeline/task.bridge_test.go index 6f542d485e0..03a804c9c12 100644 --- a/core/services/pipeline/task.bridge_test.go +++ b/core/services/pipeline/task.bridge_test.go @@ -24,8 +24,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" - configtest2 "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" clhttptest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/httptest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" @@ -208,7 +207,7 @@ func TestBridgeTask_HandlesIntermittentFailure(t *testing.T) { t.Parallel() db := pgtest.NewSqlxDB(t) - cfg := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) {}) + cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) {}) s1 := httptest.NewServer(fakeIntermittentlyFailingPriceResponder(t, utils.MustUnmarshalToMap(btcUSDPairing), decimal.NewFromInt(9700), "", nil)) defer s1.Close() @@ -270,7 +269,7 @@ func TestBridgeTask_DoesNotReturnStaleResults(t *testing.T) { db := pgtest.NewSqlxDB(t) - cfg := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.WebServer.BridgeCacheTTL = models.MustNewDuration(30 * time.Second) }) queryer := pg.NewQ(db, logger.TestLogger(t), cfg.Database()) @@ -336,7 +335,7 @@ func TestBridgeTask_DoesNotReturnStaleResults(t *testing.T) { require.NoError(t, result2.Error) require.Equal(t, string(big.NewInt(9700).Bytes()), result2.Value) - cfg2 := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + cfg2 := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.WebServer.BridgeCacheTTL = models.MustNewDuration(0 * time.Second) }) task.HelperSetDependencies(cfg2.JobPipeline(), cfg2.WebServer(), orm, specID, uuid.UUID{}, c) diff --git a/core/services/pipeline/task.eth_call_test.go b/core/services/pipeline/task.eth_call_test.go index 77a10681fb4..8fe8bec16c0 100644 --- a/core/services/pipeline/task.eth_call_test.go +++ b/core/services/pipeline/task.eth_call_test.go @@ -17,7 +17,7 @@ import ( txmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/pipeline/task.eth_tx_test.go b/core/services/pipeline/task.eth_tx_test.go index af09d793852..e5f50bc29e5 100644 --- a/core/services/pipeline/task.eth_tx_test.go +++ b/core/services/pipeline/task.eth_tx_test.go @@ -15,7 +15,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" txmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/pipeline/task.http_test.go b/core/services/pipeline/task.http_test.go index eee3a9aa783..c0dd93df430 100644 --- a/core/services/pipeline/task.http_test.go +++ b/core/services/pipeline/task.http_test.go @@ -20,7 +20,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" clhttptest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/httptest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/promreporter/prom_reporter_test.go b/core/services/promreporter/prom_reporter_test.go index f57cf8f45a8..1f15d94418d 100644 --- a/core/services/promreporter/prom_reporter_test.go +++ b/core/services/promreporter/prom_reporter_test.go @@ -14,7 +14,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/promreporter" diff --git a/core/services/relay/evm/evm_test.go b/core/services/relay/evm/evm_test.go index df7cd8eb818..4e9c44a7b93 100644 --- a/core/services/relay/evm/evm_test.go +++ b/core/services/relay/evm/evm_test.go @@ -3,10 +3,11 @@ package evm_test import ( "testing" - "github.com/smartcontractkit/sqlx" "github.com/stretchr/testify/assert" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/sqlx" + + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/pg" "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm" ) diff --git a/core/services/relay/evm/relayer_extender_test.go b/core/services/relay/evm/relayer_extender_test.go index 361a7468f30..3f4a3749ac8 100644 --- a/core/services/relay/evm/relayer_extender_test.go +++ b/core/services/relay/evm/relayer_extender_test.go @@ -12,7 +12,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" diff --git a/core/services/relay/evm/request_round_tracker_test.go b/core/services/relay/evm/request_round_tracker_test.go index b9f38d54ba3..cb2ee2a8d72 100644 --- a/core/services/relay/evm/request_round_tracker_test.go +++ b/core/services/relay/evm/request_round_tracker_test.go @@ -7,12 +7,13 @@ import ( gethCommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/pkg/errors" - "github.com/smartcontractkit/libocr/gethwrappers2/ocr2aggregator" - ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/libocr/gethwrappers2/ocr2aggregator" + ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + commonmocks "github.com/smartcontractkit/chainlink/v2/common/mocks" evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" @@ -21,7 +22,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" offchain_aggregator_wrapper "github.com/smartcontractkit/chainlink/v2/core/internal/gethwrappers2/generated/offchainaggregator" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/vrf/delegate_test.go b/core/services/vrf/delegate_test.go index 8c522520faf..38b361716b6 100644 --- a/core/services/vrf/delegate_test.go +++ b/core/services/vrf/delegate_test.go @@ -21,7 +21,7 @@ import ( evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/solidity_vrf_coordinator_interface" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/vrf/proof/proof_response_test.go b/core/services/vrf/proof/proof_response_test.go index 191c18b60d3..24df77d4b32 100644 --- a/core/services/vrf/proof/proof_response_test.go +++ b/core/services/vrf/proof/proof_response_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/solidity_vrf_verifier_wrapper" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" proof2 "github.com/smartcontractkit/chainlink/v2/core/services/vrf/proof" "github.com/ethereum/go-ethereum/accounts/abi/bind" diff --git a/core/services/vrf/v2/integration_v2_plus_test.go b/core/services/vrf/v2/integration_v2_plus_test.go index 33eb9f74839..9adf47f256b 100644 --- a/core/services/vrf/v2/integration_v2_plus_test.go +++ b/core/services/vrf/v2/integration_v2_plus_test.go @@ -40,7 +40,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest/heavyweight" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/vrfkey" diff --git a/core/services/vrf/v2/integration_v2_test.go b/core/services/vrf/v2/integration_v2_test.go index 6dad3173072..093adc8eaaf 100644 --- a/core/services/vrf/v2/integration_v2_test.go +++ b/core/services/vrf/v2/integration_v2_test.go @@ -57,7 +57,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest/heavyweight" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/job" diff --git a/core/store/migrate/migrate_test.go b/core/store/migrate/migrate_test.go index 7a1e38fb030..fe218589d2d 100644 --- a/core/store/migrate/migrate_test.go +++ b/core/store/migrate/migrate_test.go @@ -19,7 +19,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/config/env" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest/heavyweight" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" diff --git a/core/web/cors_test.go b/core/web/cors_test.go index cfd82dd8b71..fcd5d9b3874 100644 --- a/core/web/cors_test.go +++ b/core/web/cors_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" ) diff --git a/core/web/cosmos_chains_controller_test.go b/core/web/cosmos_chains_controller_test.go index f3f5909940f..475ef413528 100644 --- a/core/web/cosmos_chains_controller_test.go +++ b/core/web/cosmos_chains_controller_test.go @@ -16,7 +16,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/cosmos" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/cosmostest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/web" diff --git a/core/web/eth_keys_controller_test.go b/core/web/eth_keys_controller_test.go index 98641721737..e3a39d541a4 100644 --- a/core/web/eth_keys_controller_test.go +++ b/core/web/eth_keys_controller_test.go @@ -14,7 +14,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" diff --git a/core/web/evm_chains_controller_test.go b/core/web/evm_chains_controller_test.go index 4ebf06f2b6d..3d5a4e3eedd 100644 --- a/core/web/evm_chains_controller_test.go +++ b/core/web/evm_chains_controller_test.go @@ -14,7 +14,7 @@ import ( evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/utils" diff --git a/core/web/evm_forwarders_controller_test.go b/core/web/evm_forwarders_controller_test.go index 46820b42337..31e49f20ecc 100644 --- a/core/web/evm_forwarders_controller_test.go +++ b/core/web/evm_forwarders_controller_test.go @@ -13,7 +13,7 @@ import ( evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/utils" "github.com/smartcontractkit/chainlink/v2/core/web" diff --git a/core/web/evm_transfer_controller_test.go b/core/web/evm_transfer_controller_test.go index 0f3cdc8bb69..14259637b4f 100644 --- a/core/web/evm_transfer_controller_test.go +++ b/core/web/evm_transfer_controller_test.go @@ -15,7 +15,7 @@ import ( evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest2 "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/store/models" @@ -125,7 +125,7 @@ func TestTransfersController_CreateSuccess_From_BalanceMonitorDisabled(t *testin ethClient.On("PendingNonceAt", mock.Anything, key.Address).Return(uint64(1), nil) ethClient.On("BalanceAt", mock.Anything, key.Address, (*big.Int)(nil)).Return(balance.ToInt(), nil) - config := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + config := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.EVM[0].BalanceMonitor.Enabled = ptr(false) }) @@ -285,7 +285,7 @@ func TestTransfersController_CreateSuccess_eip1559(t *testing.T) { ethClient.On("BalanceAt", mock.Anything, key.Address, (*big.Int)(nil)).Return(balance.ToInt(), nil) ethClient.On("SequenceAt", mock.Anything, mock.Anything, mock.Anything).Return(evmtypes.Nonce(0), nil).Maybe() - config := configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + config := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.EVM[0].GasEstimator.EIP1559DynamicFees = ptr(true) c.EVM[0].GasEstimator.Mode = ptr("FixedPrice") c.EVM[0].ChainID = (*utils.Big)(testutils.FixtureChainID) diff --git a/core/web/external_initiators_controller_test.go b/core/web/external_initiators_controller_test.go index 2229b40b7ef..6a1b715b728 100644 --- a/core/web/external_initiators_controller_test.go +++ b/core/web/external_initiators_controller_test.go @@ -10,7 +10,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest2 "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" @@ -69,7 +69,7 @@ func TestExternalInitiatorsController_Index(t *testing.T) { t.Parallel() app := cltest.NewApplicationWithConfig(t, - configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.JobPipeline.ExternalInitiatorsEnabled = ptr(true) })) require.NoError(t, app.Start(testutils.Context(t))) @@ -135,7 +135,7 @@ func TestExternalInitiatorsController_Create_success(t *testing.T) { t.Parallel() app := cltest.NewApplicationWithConfig(t, - configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.JobPipeline.ExternalInitiatorsEnabled = ptr(true) })) require.NoError(t, app.Start(testutils.Context(t))) @@ -163,7 +163,7 @@ func TestExternalInitiatorsController_Create_without_URL(t *testing.T) { t.Parallel() app := cltest.NewApplicationWithConfig(t, - configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.JobPipeline.ExternalInitiatorsEnabled = ptr(true) })) require.NoError(t, app.Start(testutils.Context(t))) @@ -191,7 +191,7 @@ func TestExternalInitiatorsController_Create_invalid(t *testing.T) { t.Parallel() app := cltest.NewApplicationWithConfig(t, - configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.JobPipeline.ExternalInitiatorsEnabled = ptr(true) })) require.NoError(t, app.Start(testutils.Context(t))) @@ -209,7 +209,7 @@ func TestExternalInitiatorsController_Delete(t *testing.T) { t.Parallel() app := cltest.NewApplicationWithConfig(t, - configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.JobPipeline.ExternalInitiatorsEnabled = ptr(true) })) require.NoError(t, app.Start(testutils.Context(t))) @@ -231,7 +231,7 @@ func TestExternalInitiatorsController_DeleteNotFound(t *testing.T) { t.Parallel() app := cltest.NewApplicationWithConfig(t, - configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.JobPipeline.ExternalInitiatorsEnabled = ptr(true) })) require.NoError(t, app.Start(testutils.Context(t))) diff --git a/core/web/features_controller_test.go b/core/web/features_controller_test.go index 8ef2e08d394..727d7db5476 100644 --- a/core/web/features_controller_test.go +++ b/core/web/features_controller_test.go @@ -6,7 +6,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/web" "github.com/smartcontractkit/chainlink/v2/core/web/presenters" diff --git a/core/web/gui_assets_test.go b/core/web/gui_assets_test.go index 784b0958f59..137b1231984 100644 --- a/core/web/gui_assets_test.go +++ b/core/web/gui_assets_test.go @@ -8,7 +8,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" clhttptest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/httptest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/web" diff --git a/core/web/jobs_controller_test.go b/core/web/jobs_controller_test.go index 345662909a4..fc2e8d7a30e 100644 --- a/core/web/jobs_controller_test.go +++ b/core/web/jobs_controller_test.go @@ -25,7 +25,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/directrequest" "github.com/smartcontractkit/chainlink/v2/core/services/job" @@ -44,7 +44,7 @@ func TestJobsController_Create_ValidationFailure_OffchainReportingSpec(t *testin contractAddress = cltest.NewEIP55Address() ) - peerID, err := p2ppeer.Decode("12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X") + peerID, err := p2ppeer.Decode(configtest.DefaultPeerID) require.NoError(t, err) randomBytes := testutils.Random32Byte() diff --git a/core/web/log_controller_test.go b/core/web/log_controller_test.go index e4cd1768cef..dbb95361b98 100644 --- a/core/web/log_controller_test.go +++ b/core/web/log_controller_test.go @@ -14,7 +14,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/config/toml" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/web" "github.com/smartcontractkit/chainlink/v2/core/web/presenters" diff --git a/core/web/loop_registry_test.go b/core/web/loop_registry_test.go index 59a4d0df686..ea766725641 100644 --- a/core/web/loop_registry_test.go +++ b/core/web/loop_registry_test.go @@ -17,7 +17,7 @@ import ( "github.com/smartcontractkit/chainlink-relay/pkg/loop" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" ) diff --git a/core/web/pipeline_runs_controller_test.go b/core/web/pipeline_runs_controller_test.go index 5b17fcb007e..c44ee9ae8da 100644 --- a/core/web/pipeline_runs_controller_test.go +++ b/core/web/pipeline_runs_controller_test.go @@ -19,7 +19,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/webhook" diff --git a/core/web/resolver/eth_key_test.go b/core/web/resolver/eth_key_test.go index 26e061b164f..6cac2f4ac4f 100644 --- a/core/web/resolver/eth_key_test.go +++ b/core/web/resolver/eth_key_test.go @@ -14,7 +14,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" mocks2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" evmrelay "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm" diff --git a/core/web/resolver/features_test.go b/core/web/resolver/features_test.go index 1d3f5b8ddaf..f14f71abc90 100644 --- a/core/web/resolver/features_test.go +++ b/core/web/resolver/features_test.go @@ -3,7 +3,7 @@ package resolver import ( "testing" - configtest2 "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" ) @@ -24,7 +24,7 @@ func Test_ToFeatures(t *testing.T) { name: "success", authenticated: true, before: func(f *gqlTestFramework) { - f.App.On("GetConfig").Return(configtest2.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + f.App.On("GetConfig").Return(configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { t, f := true, false c.Feature.UICSAKeys = &f c.Feature.FeedsManager = &t diff --git a/core/web/solana_chains_controller_test.go b/core/web/solana_chains_controller_test.go index 5d6dc7424a2..724d5cd2c3d 100644 --- a/core/web/solana_chains_controller_test.go +++ b/core/web/solana_chains_controller_test.go @@ -18,7 +18,7 @@ import ( "github.com/smartcontractkit/chainlink-solana/pkg/solana" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/web" "github.com/smartcontractkit/chainlink/v2/core/web/presenters" diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 469cd0d1686..44d018769ec 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [dev] +... + +## 2.7.0 - UNRELEASED + ### Added - Added new configuration field named `LeaseDuration` for `EVM.NodePool` that will periodically check if internal subscriptions are connected to the "best" (as defined by the `SelectionMode`) node and switch to it if necessary. Setting this value to `0s` will disable this feature. diff --git a/integration-tests/actions/vrfv2plus/vrfv2plus_config/config.go b/integration-tests/actions/vrfv2plus/vrfv2plus_config/config.go index 7a1221eaf8b..caee353294f 100644 --- a/integration-tests/actions/vrfv2plus/vrfv2plus_config/config.go +++ b/integration-tests/actions/vrfv2plus/vrfv2plus_config/config.go @@ -18,6 +18,8 @@ type VRFV2PlusConfig struct { FulfillmentFlatFeeLinkPPM uint32 `envconfig:"FULFILLMENT_FLAT_FEE_LINK_PPM" default:"500"` // Flat fee in ppm for LINK for the VRF Coordinator config FulfillmentFlatFeeNativePPM uint32 `envconfig:"FULFILLMENT_FLAT_FEE_NATIVE_PPM" default:"500"` // Flat fee in ppm for native currency for the VRF Coordinator config + NumberOfSubToCreate int `envconfig:"NUMBER_OF_SUB_TO_CREATE" default:"1"` // Number of subscriptions to create + RandomnessRequestCountPerRequest uint16 `envconfig:"RANDOMNESS_REQUEST_COUNT_PER_REQUEST" default:"1"` // How many randomness requests to send per request RandomnessRequestCountPerRequestDeviation uint16 `envconfig:"RANDOMNESS_REQUEST_COUNT_PER_REQUEST_DEVIATION" default:"0"` // How many randomness requests to send per request diff --git a/integration-tests/contracts/contract_deployer.go b/integration-tests/contracts/contract_deployer.go index 9210a60c013..bdf63d19195 100644 --- a/integration-tests/contracts/contract_deployer.go +++ b/integration-tests/contracts/contract_deployer.go @@ -29,6 +29,8 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/gas_wrapper" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/gas_wrapper_mock" iregistry21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_keeper_registry_master_wrapper_2_1" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_consumer_performance_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_consumer_wrapper" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registrar_wrapper1_2" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registrar_wrapper1_2_mock" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registrar_wrapper2_0" @@ -50,8 +52,11 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/mock_gas_aggregator_wrapper" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/operator_factory" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/oracle_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/perform_data_checker_wrapper" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/streams_lookup_upkeep_wrapper" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/test_api_consumer_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/upkeep_counter_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/upkeep_perform_counter_restrictive_wrapper" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/upkeep_transcoder" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/llo-feeds/generated/fee_manager" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/llo-feeds/generated/reward_manager" @@ -1228,14 +1233,14 @@ func (e *EthereumContractDeployer) DeployKeeperConsumer(updateInterval *big.Int) auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return eth_contracts.DeployKeeperConsumer(auth, backend, updateInterval) + return keeper_consumer_wrapper.DeployKeeperConsumer(auth, backend, updateInterval) }) if err != nil { return nil, err } return &EthereumKeeperConsumer{ client: e.client, - consumer: instance.(*eth_contracts.KeeperConsumer), + consumer: instance.(*keeper_consumer_wrapper.KeeperConsumer), address: address, }, err } @@ -1302,14 +1307,14 @@ func (e *EthereumContractDeployer) DeployUpkeepCounter(testRange *big.Int, inter auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return eth_contracts.DeployUpkeepCounter(auth, backend, testRange, interval) + return upkeep_counter_wrapper.DeployUpkeepCounter(auth, backend, testRange, interval) }) if err != nil { return nil, err } return &EthereumUpkeepCounter{ client: e.client, - consumer: instance.(*eth_contracts.UpkeepCounter), + consumer: instance.(*upkeep_counter_wrapper.UpkeepCounter), address: address, }, err } @@ -1319,14 +1324,14 @@ func (e *EthereumContractDeployer) DeployUpkeepPerformCounterRestrictive(testRan auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return eth_contracts.DeployUpkeepPerformCounterRestrictive(auth, backend, testRange, averageEligibilityCadence) + return upkeep_perform_counter_restrictive_wrapper.DeployUpkeepPerformCounterRestrictive(auth, backend, testRange, averageEligibilityCadence) }) if err != nil { return nil, err } return &EthereumUpkeepPerformCounterRestrictive{ client: e.client, - consumer: instance.(*eth_contracts.UpkeepPerformCounterRestrictive), + consumer: instance.(*upkeep_perform_counter_restrictive_wrapper.UpkeepPerformCounterRestrictive), address: address, }, err } @@ -1341,7 +1346,7 @@ func (e *EthereumContractDeployer) DeployKeeperConsumerPerformance( auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return eth_contracts.DeployKeeperConsumerPerformance( + return keeper_consumer_performance_wrapper.DeployKeeperConsumerPerformance( auth, backend, testBlockRange, @@ -1355,7 +1360,7 @@ func (e *EthereumContractDeployer) DeployKeeperConsumerPerformance( } return &EthereumKeeperConsumerPerformance{ client: e.client, - consumer: instance.(*eth_contracts.KeeperConsumerPerformance), + consumer: instance.(*keeper_consumer_performance_wrapper.KeeperConsumerPerformance), address: address, }, err } @@ -1403,7 +1408,7 @@ func (e *EthereumContractDeployer) DeployKeeperPerformDataChecker(expectedData [ auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return eth_contracts.DeployPerformDataChecker( + return perform_data_checker_wrapper.DeployPerformDataChecker( auth, backend, expectedData, @@ -1414,7 +1419,7 @@ func (e *EthereumContractDeployer) DeployKeeperPerformDataChecker(expectedData [ } return &EthereumKeeperPerformDataCheckerConsumer{ client: e.client, - performDataChecker: instance.(*eth_contracts.PerformDataChecker), + performDataChecker: instance.(*perform_data_checker_wrapper.PerformDataChecker), address: address, }, err } diff --git a/integration-tests/contracts/contract_vrf_models.go b/integration-tests/contracts/contract_vrf_models.go index ea8b6ae3cac..656cabb92e9 100644 --- a/integration-tests/contracts/contract_vrf_models.go +++ b/integration-tests/contracts/contract_vrf_models.go @@ -11,6 +11,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2_5" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_load_test_with_metrics" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2_consumer_wrapper" "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" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrfv2plus_wrapper_load_test_consumer" @@ -152,7 +153,7 @@ type VRFConsumerV2 interface { type VRFv2Consumer interface { Address() string RequestRandomness(hash [32]byte, subID uint64, confs uint16, gasLimit uint32, numWords uint32) error - GetRequestStatus(ctx context.Context, requestID *big.Int) (RequestStatus, error) + GetRequestStatus(ctx context.Context, requestID *big.Int) (vrf_v2_consumer_wrapper.GetRequestStatus, error) GetLastRequestId(ctx context.Context) (*big.Int, error) } diff --git a/integration-tests/contracts/ethereum/KeeperConsumer.go b/integration-tests/contracts/ethereum/KeeperConsumer.go deleted file mode 100644 index c0691729d21..00000000000 --- a/integration-tests/contracts/ethereum/KeeperConsumer.go +++ /dev/null @@ -1,361 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package ethereum - -import ( - "errors" - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = errors.New - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription -) - -// KeeperConsumerMetaData contains all meta data concerning the KeeperConsumer contract. -var KeeperConsumerMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"updateInterval\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"checkData\",\"type\":\"bytes\"}],\"name\":\"checkUpkeep\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"upkeepNeeded\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"performData\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"counter\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"interval\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastTimeStamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"performData\",\"type\":\"bytes\"}],\"name\":\"performUpkeep\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x60a060405234801561001057600080fd5b506040516103583803806103588339818101604052602081101561003357600080fd5b505160805242600155600080556080516102fe61005a6000398061025452506102fe6000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80633f3b3b271461005c5780634585e33b1461007657806361bc221a146100e65780636e04ff0d146100ee578063947a36fb146101dd575b600080fd5b6100646101e5565b60408051918252519081900360200190f35b6100e46004803603602081101561008c57600080fd5b810190602081018135600160201b8111156100a657600080fd5b8201836020820111156100b857600080fd5b803590602001918460018302840111600160201b831117156100d957600080fd5b5090925090506101eb565b005b6100646101f8565b61015c6004803603602081101561010457600080fd5b810190602081018135600160201b81111561011e57600080fd5b82018360208201111561013057600080fd5b803590602001918460018302840111600160201b8311171561015157600080fd5b5090925090506101fe565b60405180831515815260200180602001828103825283818151815260200191508051906020019080838360005b838110156101a1578181015183820152602001610189565b50505050905090810190601f1680156101ce5780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b610064610252565b60015481565b5050600080546001019055565b60005481565b6000606061020a610276565b6001848481818080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250959a92995091975050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b32156102c6576040805162461bcd60e51b815260206004820152601a6024820152791bdb9b1e48199bdc881cda5b5d5b185d195908189858dad95b9960321b604482015290519081900360640190fd5b56fea2646970667358221220c0e089efa59b00d8b131c6b0456904c0ef8f5646c27f81de540a4cc400cff70c64736f6c63430007060033", -} - -// KeeperConsumerABI is the input ABI used to generate the binding from. -// Deprecated: Use KeeperConsumerMetaData.ABI instead. -var KeeperConsumerABI = KeeperConsumerMetaData.ABI - -// KeeperConsumerBin is the compiled bytecode used for deploying new contracts. -// Deprecated: Use KeeperConsumerMetaData.Bin instead. -var KeeperConsumerBin = KeeperConsumerMetaData.Bin - -// DeployKeeperConsumer deploys a new Ethereum contract, binding an instance of KeeperConsumer to it. -func DeployKeeperConsumer(auth *bind.TransactOpts, backend bind.ContractBackend, updateInterval *big.Int) (common.Address, *types.Transaction, *KeeperConsumer, error) { - parsed, err := KeeperConsumerMetaData.GetAbi() - if err != nil { - return common.Address{}, nil, nil, err - } - if parsed == nil { - return common.Address{}, nil, nil, errors.New("GetABI returned nil") - } - - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(KeeperConsumerBin), backend, updateInterval) - if err != nil { - return common.Address{}, nil, nil, err - } - return address, tx, &KeeperConsumer{KeeperConsumerCaller: KeeperConsumerCaller{contract: contract}, KeeperConsumerTransactor: KeeperConsumerTransactor{contract: contract}, KeeperConsumerFilterer: KeeperConsumerFilterer{contract: contract}}, nil -} - -// KeeperConsumer is an auto generated Go binding around an Ethereum contract. -type KeeperConsumer struct { - KeeperConsumerCaller // Read-only binding to the contract - KeeperConsumerTransactor // Write-only binding to the contract - KeeperConsumerFilterer // Log filterer for contract events -} - -// KeeperConsumerCaller is an auto generated read-only Go binding around an Ethereum contract. -type KeeperConsumerCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// KeeperConsumerTransactor is an auto generated write-only Go binding around an Ethereum contract. -type KeeperConsumerTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// KeeperConsumerFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type KeeperConsumerFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// KeeperConsumerSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type KeeperConsumerSession struct { - Contract *KeeperConsumer // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// KeeperConsumerCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type KeeperConsumerCallerSession struct { - Contract *KeeperConsumerCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// KeeperConsumerTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type KeeperConsumerTransactorSession struct { - Contract *KeeperConsumerTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// KeeperConsumerRaw is an auto generated low-level Go binding around an Ethereum contract. -type KeeperConsumerRaw struct { - Contract *KeeperConsumer // Generic contract binding to access the raw methods on -} - -// KeeperConsumerCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type KeeperConsumerCallerRaw struct { - Contract *KeeperConsumerCaller // Generic read-only contract binding to access the raw methods on -} - -// KeeperConsumerTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type KeeperConsumerTransactorRaw struct { - Contract *KeeperConsumerTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewKeeperConsumer creates a new instance of KeeperConsumer, bound to a specific deployed contract. -func NewKeeperConsumer(address common.Address, backend bind.ContractBackend) (*KeeperConsumer, error) { - contract, err := bindKeeperConsumer(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &KeeperConsumer{KeeperConsumerCaller: KeeperConsumerCaller{contract: contract}, KeeperConsumerTransactor: KeeperConsumerTransactor{contract: contract}, KeeperConsumerFilterer: KeeperConsumerFilterer{contract: contract}}, nil -} - -// NewKeeperConsumerCaller creates a new read-only instance of KeeperConsumer, bound to a specific deployed contract. -func NewKeeperConsumerCaller(address common.Address, caller bind.ContractCaller) (*KeeperConsumerCaller, error) { - contract, err := bindKeeperConsumer(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &KeeperConsumerCaller{contract: contract}, nil -} - -// NewKeeperConsumerTransactor creates a new write-only instance of KeeperConsumer, bound to a specific deployed contract. -func NewKeeperConsumerTransactor(address common.Address, transactor bind.ContractTransactor) (*KeeperConsumerTransactor, error) { - contract, err := bindKeeperConsumer(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &KeeperConsumerTransactor{contract: contract}, nil -} - -// NewKeeperConsumerFilterer creates a new log filterer instance of KeeperConsumer, bound to a specific deployed contract. -func NewKeeperConsumerFilterer(address common.Address, filterer bind.ContractFilterer) (*KeeperConsumerFilterer, error) { - contract, err := bindKeeperConsumer(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &KeeperConsumerFilterer{contract: contract}, nil -} - -// bindKeeperConsumer binds a generic wrapper to an already deployed contract. -func bindKeeperConsumer(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(KeeperConsumerABI)) - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_KeeperConsumer *KeeperConsumerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _KeeperConsumer.Contract.KeeperConsumerCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_KeeperConsumer *KeeperConsumerRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _KeeperConsumer.Contract.KeeperConsumerTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_KeeperConsumer *KeeperConsumerRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _KeeperConsumer.Contract.KeeperConsumerTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_KeeperConsumer *KeeperConsumerCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _KeeperConsumer.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_KeeperConsumer *KeeperConsumerTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _KeeperConsumer.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_KeeperConsumer *KeeperConsumerTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _KeeperConsumer.Contract.contract.Transact(opts, method, params...) -} - -// CheckUpkeep is a free data retrieval call binding the contract method 0x6e04ff0d. -// -// Solidity: function checkUpkeep(bytes checkData) view returns(bool upkeepNeeded, bytes performData) -func (_KeeperConsumer *KeeperConsumerCaller) CheckUpkeep(opts *bind.CallOpts, checkData []byte) (struct { - UpkeepNeeded bool - PerformData []byte -}, error) { - var out []interface{} - err := _KeeperConsumer.contract.Call(opts, &out, "checkUpkeep", checkData) - - outstruct := new(struct { - UpkeepNeeded bool - PerformData []byte - }) - if err != nil { - return *outstruct, err - } - - outstruct.UpkeepNeeded = *abi.ConvertType(out[0], new(bool)).(*bool) - outstruct.PerformData = *abi.ConvertType(out[1], new([]byte)).(*[]byte) - - return *outstruct, err - -} - -// CheckUpkeep is a free data retrieval call binding the contract method 0x6e04ff0d. -// -// Solidity: function checkUpkeep(bytes checkData) view returns(bool upkeepNeeded, bytes performData) -func (_KeeperConsumer *KeeperConsumerSession) CheckUpkeep(checkData []byte) (struct { - UpkeepNeeded bool - PerformData []byte -}, error) { - return _KeeperConsumer.Contract.CheckUpkeep(&_KeeperConsumer.CallOpts, checkData) -} - -// CheckUpkeep is a free data retrieval call binding the contract method 0x6e04ff0d. -// -// Solidity: function checkUpkeep(bytes checkData) view returns(bool upkeepNeeded, bytes performData) -func (_KeeperConsumer *KeeperConsumerCallerSession) CheckUpkeep(checkData []byte) (struct { - UpkeepNeeded bool - PerformData []byte -}, error) { - return _KeeperConsumer.Contract.CheckUpkeep(&_KeeperConsumer.CallOpts, checkData) -} - -// Counter is a free data retrieval call binding the contract method 0x61bc221a. -// -// Solidity: function counter() view returns(uint256) -func (_KeeperConsumer *KeeperConsumerCaller) Counter(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _KeeperConsumer.contract.Call(opts, &out, "counter") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// Counter is a free data retrieval call binding the contract method 0x61bc221a. -// -// Solidity: function counter() view returns(uint256) -func (_KeeperConsumer *KeeperConsumerSession) Counter() (*big.Int, error) { - return _KeeperConsumer.Contract.Counter(&_KeeperConsumer.CallOpts) -} - -// Counter is a free data retrieval call binding the contract method 0x61bc221a. -// -// Solidity: function counter() view returns(uint256) -func (_KeeperConsumer *KeeperConsumerCallerSession) Counter() (*big.Int, error) { - return _KeeperConsumer.Contract.Counter(&_KeeperConsumer.CallOpts) -} - -// Interval is a free data retrieval call binding the contract method 0x947a36fb. -// -// Solidity: function interval() view returns(uint256) -func (_KeeperConsumer *KeeperConsumerCaller) Interval(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _KeeperConsumer.contract.Call(opts, &out, "interval") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// Interval is a free data retrieval call binding the contract method 0x947a36fb. -// -// Solidity: function interval() view returns(uint256) -func (_KeeperConsumer *KeeperConsumerSession) Interval() (*big.Int, error) { - return _KeeperConsumer.Contract.Interval(&_KeeperConsumer.CallOpts) -} - -// Interval is a free data retrieval call binding the contract method 0x947a36fb. -// -// Solidity: function interval() view returns(uint256) -func (_KeeperConsumer *KeeperConsumerCallerSession) Interval() (*big.Int, error) { - return _KeeperConsumer.Contract.Interval(&_KeeperConsumer.CallOpts) -} - -// LastTimeStamp is a free data retrieval call binding the contract method 0x3f3b3b27. -// -// Solidity: function lastTimeStamp() view returns(uint256) -func (_KeeperConsumer *KeeperConsumerCaller) LastTimeStamp(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _KeeperConsumer.contract.Call(opts, &out, "lastTimeStamp") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// LastTimeStamp is a free data retrieval call binding the contract method 0x3f3b3b27. -// -// Solidity: function lastTimeStamp() view returns(uint256) -func (_KeeperConsumer *KeeperConsumerSession) LastTimeStamp() (*big.Int, error) { - return _KeeperConsumer.Contract.LastTimeStamp(&_KeeperConsumer.CallOpts) -} - -// LastTimeStamp is a free data retrieval call binding the contract method 0x3f3b3b27. -// -// Solidity: function lastTimeStamp() view returns(uint256) -func (_KeeperConsumer *KeeperConsumerCallerSession) LastTimeStamp() (*big.Int, error) { - return _KeeperConsumer.Contract.LastTimeStamp(&_KeeperConsumer.CallOpts) -} - -// PerformUpkeep is a paid mutator transaction binding the contract method 0x4585e33b. -// -// Solidity: function performUpkeep(bytes performData) returns() -func (_KeeperConsumer *KeeperConsumerTransactor) PerformUpkeep(opts *bind.TransactOpts, performData []byte) (*types.Transaction, error) { - return _KeeperConsumer.contract.Transact(opts, "performUpkeep", performData) -} - -// PerformUpkeep is a paid mutator transaction binding the contract method 0x4585e33b. -// -// Solidity: function performUpkeep(bytes performData) returns() -func (_KeeperConsumer *KeeperConsumerSession) PerformUpkeep(performData []byte) (*types.Transaction, error) { - return _KeeperConsumer.Contract.PerformUpkeep(&_KeeperConsumer.TransactOpts, performData) -} - -// PerformUpkeep is a paid mutator transaction binding the contract method 0x4585e33b. -// -// Solidity: function performUpkeep(bytes performData) returns() -func (_KeeperConsumer *KeeperConsumerTransactorSession) PerformUpkeep(performData []byte) (*types.Transaction, error) { - return _KeeperConsumer.Contract.PerformUpkeep(&_KeeperConsumer.TransactOpts, performData) -} diff --git a/integration-tests/contracts/ethereum/UpkeepCounter.go b/integration-tests/contracts/ethereum/UpkeepCounter.go deleted file mode 100644 index f0097bfb7b0..00000000000 --- a/integration-tests/contracts/ethereum/UpkeepCounter.go +++ /dev/null @@ -1,641 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package ethereum - -import ( - "errors" - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = errors.New - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription -) - -// UpkeepCounterMetaData contains all meta data concerning the UpkeepCounter contract. -var UpkeepCounterMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_testRange\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_interval\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"initialBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lastBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"counter\",\"type\":\"uint256\"}],\"name\":\"PerformingUpkeep\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"checkUpkeep\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"counter\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"eligible\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"interval\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"performData\",\"type\":\"bytes\"}],\"name\":\"performUpkeep\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"previousPerformBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_testRange\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_interval\",\"type\":\"uint256\"}],\"name\":\"setSpread\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"testRange\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b506040516104423803806104428339818101604052604081101561003357600080fd5b508051602090910151600091825560015560038190554360025560048190556005556103de806100646000396000f3fe608060405234801561001057600080fd5b506004361061008e5760003560e01c80632cb15864146100935780634585e33b146100ad57806361bc221a1461011d5780636250a13a146101255780636e04ff0d1461012d5780637f407edf1461021c578063806b984f1461023f578063917d895f14610247578063947a36fb1461024f578063d832d92f14610257575b600080fd5b61009b610273565b60408051918252519081900360200190f35b61011b600480360360208110156100c357600080fd5b810190602081018135600160201b8111156100dd57600080fd5b8201836020820111156100ef57600080fd5b803590602001918460018302840111600160201b8311171561011057600080fd5b509092509050610279565b005b61009b6102f0565b61009b6102f6565b61019b6004803603602081101561014357600080fd5b810190602081018135600160201b81111561015d57600080fd5b82018360208201111561016f57600080fd5b803590602001918460018302840111600160201b8311171561019057600080fd5b5090925090506102fc565b60405180831515815260200180602001828103825283818151815260200191508051906020019080838360005b838110156101e05781810151838201526020016101c8565b50505050905090810190601f16801561020d5780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b61011b6004803603604081101561023257600080fd5b508035906020013561034e565b61009b610360565b61009b610366565b61009b61036c565b61025f610372565b604080519115158252519081900360200190f35b60045481565b60045461028557436004555b4360028190556005805460010190819055600454600354604080519283526020830194909452818401526060810191909152905132917f8e8112f20a2134e18e591d2cdd68cd86a95d06e6328ede501fc6314f4a5075fa919081900360800190a25050600254600355565b60055481565b60005481565b60006060610308610372565b848481818080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250959a92995091975050505050505050565b60009182556001556004819055600555565b60025481565b60035481565b60015481565b600060045460001415610387575060016103a5565b60005460045443031080156103a25750600154600254430310155b90505b9056fea264697066735822122040ec1d65fcf245bb817ffdc5ef880653b8cc880e41da1037b27143dcb90127c864736f6c63430007060033", -} - -// UpkeepCounterABI is the input ABI used to generate the binding from. -// Deprecated: Use UpkeepCounterMetaData.ABI instead. -var UpkeepCounterABI = UpkeepCounterMetaData.ABI - -// UpkeepCounterBin is the compiled bytecode used for deploying new contracts. -// Deprecated: Use UpkeepCounterMetaData.Bin instead. -var UpkeepCounterBin = UpkeepCounterMetaData.Bin - -// DeployUpkeepCounter deploys a new Ethereum contract, binding an instance of UpkeepCounter to it. -func DeployUpkeepCounter(auth *bind.TransactOpts, backend bind.ContractBackend, _testRange *big.Int, _interval *big.Int) (common.Address, *types.Transaction, *UpkeepCounter, error) { - parsed, err := UpkeepCounterMetaData.GetAbi() - if err != nil { - return common.Address{}, nil, nil, err - } - if parsed == nil { - return common.Address{}, nil, nil, errors.New("GetABI returned nil") - } - - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(UpkeepCounterBin), backend, _testRange, _interval) - if err != nil { - return common.Address{}, nil, nil, err - } - return address, tx, &UpkeepCounter{UpkeepCounterCaller: UpkeepCounterCaller{contract: contract}, UpkeepCounterTransactor: UpkeepCounterTransactor{contract: contract}, UpkeepCounterFilterer: UpkeepCounterFilterer{contract: contract}}, nil -} - -// UpkeepCounter is an auto generated Go binding around an Ethereum contract. -type UpkeepCounter struct { - UpkeepCounterCaller // Read-only binding to the contract - UpkeepCounterTransactor // Write-only binding to the contract - UpkeepCounterFilterer // Log filterer for contract events -} - -// UpkeepCounterCaller is an auto generated read-only Go binding around an Ethereum contract. -type UpkeepCounterCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// UpkeepCounterTransactor is an auto generated write-only Go binding around an Ethereum contract. -type UpkeepCounterTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// UpkeepCounterFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type UpkeepCounterFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// UpkeepCounterSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type UpkeepCounterSession struct { - Contract *UpkeepCounter // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// UpkeepCounterCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type UpkeepCounterCallerSession struct { - Contract *UpkeepCounterCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// UpkeepCounterTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type UpkeepCounterTransactorSession struct { - Contract *UpkeepCounterTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// UpkeepCounterRaw is an auto generated low-level Go binding around an Ethereum contract. -type UpkeepCounterRaw struct { - Contract *UpkeepCounter // Generic contract binding to access the raw methods on -} - -// UpkeepCounterCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type UpkeepCounterCallerRaw struct { - Contract *UpkeepCounterCaller // Generic read-only contract binding to access the raw methods on -} - -// UpkeepCounterTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type UpkeepCounterTransactorRaw struct { - Contract *UpkeepCounterTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewUpkeepCounter creates a new instance of UpkeepCounter, bound to a specific deployed contract. -func NewUpkeepCounter(address common.Address, backend bind.ContractBackend) (*UpkeepCounter, error) { - contract, err := bindUpkeepCounter(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &UpkeepCounter{UpkeepCounterCaller: UpkeepCounterCaller{contract: contract}, UpkeepCounterTransactor: UpkeepCounterTransactor{contract: contract}, UpkeepCounterFilterer: UpkeepCounterFilterer{contract: contract}}, nil -} - -// NewUpkeepCounterCaller creates a new read-only instance of UpkeepCounter, bound to a specific deployed contract. -func NewUpkeepCounterCaller(address common.Address, caller bind.ContractCaller) (*UpkeepCounterCaller, error) { - contract, err := bindUpkeepCounter(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &UpkeepCounterCaller{contract: contract}, nil -} - -// NewUpkeepCounterTransactor creates a new write-only instance of UpkeepCounter, bound to a specific deployed contract. -func NewUpkeepCounterTransactor(address common.Address, transactor bind.ContractTransactor) (*UpkeepCounterTransactor, error) { - contract, err := bindUpkeepCounter(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &UpkeepCounterTransactor{contract: contract}, nil -} - -// NewUpkeepCounterFilterer creates a new log filterer instance of UpkeepCounter, bound to a specific deployed contract. -func NewUpkeepCounterFilterer(address common.Address, filterer bind.ContractFilterer) (*UpkeepCounterFilterer, error) { - contract, err := bindUpkeepCounter(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &UpkeepCounterFilterer{contract: contract}, nil -} - -// bindUpkeepCounter binds a generic wrapper to an already deployed contract. -func bindUpkeepCounter(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(UpkeepCounterABI)) - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_UpkeepCounter *UpkeepCounterRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _UpkeepCounter.Contract.UpkeepCounterCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_UpkeepCounter *UpkeepCounterRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _UpkeepCounter.Contract.UpkeepCounterTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_UpkeepCounter *UpkeepCounterRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _UpkeepCounter.Contract.UpkeepCounterTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_UpkeepCounter *UpkeepCounterCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _UpkeepCounter.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_UpkeepCounter *UpkeepCounterTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _UpkeepCounter.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_UpkeepCounter *UpkeepCounterTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _UpkeepCounter.Contract.contract.Transact(opts, method, params...) -} - -// CheckUpkeep is a free data retrieval call binding the contract method 0x6e04ff0d. -// -// Solidity: function checkUpkeep(bytes data) view returns(bool, bytes) -func (_UpkeepCounter *UpkeepCounterCaller) CheckUpkeep(opts *bind.CallOpts, data []byte) (bool, []byte, error) { - var out []interface{} - err := _UpkeepCounter.contract.Call(opts, &out, "checkUpkeep", data) - - if err != nil { - return *new(bool), *new([]byte), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - out1 := *abi.ConvertType(out[1], new([]byte)).(*[]byte) - - return out0, out1, err - -} - -// CheckUpkeep is a free data retrieval call binding the contract method 0x6e04ff0d. -// -// Solidity: function checkUpkeep(bytes data) view returns(bool, bytes) -func (_UpkeepCounter *UpkeepCounterSession) CheckUpkeep(data []byte) (bool, []byte, error) { - return _UpkeepCounter.Contract.CheckUpkeep(&_UpkeepCounter.CallOpts, data) -} - -// CheckUpkeep is a free data retrieval call binding the contract method 0x6e04ff0d. -// -// Solidity: function checkUpkeep(bytes data) view returns(bool, bytes) -func (_UpkeepCounter *UpkeepCounterCallerSession) CheckUpkeep(data []byte) (bool, []byte, error) { - return _UpkeepCounter.Contract.CheckUpkeep(&_UpkeepCounter.CallOpts, data) -} - -// Counter is a free data retrieval call binding the contract method 0x61bc221a. -// -// Solidity: function counter() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterCaller) Counter(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _UpkeepCounter.contract.Call(opts, &out, "counter") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// Counter is a free data retrieval call binding the contract method 0x61bc221a. -// -// Solidity: function counter() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterSession) Counter() (*big.Int, error) { - return _UpkeepCounter.Contract.Counter(&_UpkeepCounter.CallOpts) -} - -// Counter is a free data retrieval call binding the contract method 0x61bc221a. -// -// Solidity: function counter() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterCallerSession) Counter() (*big.Int, error) { - return _UpkeepCounter.Contract.Counter(&_UpkeepCounter.CallOpts) -} - -// Eligible is a free data retrieval call binding the contract method 0xd832d92f. -// -// Solidity: function eligible() view returns(bool) -func (_UpkeepCounter *UpkeepCounterCaller) Eligible(opts *bind.CallOpts) (bool, error) { - var out []interface{} - err := _UpkeepCounter.contract.Call(opts, &out, "eligible") - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// Eligible is a free data retrieval call binding the contract method 0xd832d92f. -// -// Solidity: function eligible() view returns(bool) -func (_UpkeepCounter *UpkeepCounterSession) Eligible() (bool, error) { - return _UpkeepCounter.Contract.Eligible(&_UpkeepCounter.CallOpts) -} - -// Eligible is a free data retrieval call binding the contract method 0xd832d92f. -// -// Solidity: function eligible() view returns(bool) -func (_UpkeepCounter *UpkeepCounterCallerSession) Eligible() (bool, error) { - return _UpkeepCounter.Contract.Eligible(&_UpkeepCounter.CallOpts) -} - -// InitialBlock is a free data retrieval call binding the contract method 0x2cb15864. -// -// Solidity: function initialBlock() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterCaller) InitialBlock(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _UpkeepCounter.contract.Call(opts, &out, "initialBlock") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// InitialBlock is a free data retrieval call binding the contract method 0x2cb15864. -// -// Solidity: function initialBlock() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterSession) InitialBlock() (*big.Int, error) { - return _UpkeepCounter.Contract.InitialBlock(&_UpkeepCounter.CallOpts) -} - -// InitialBlock is a free data retrieval call binding the contract method 0x2cb15864. -// -// Solidity: function initialBlock() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterCallerSession) InitialBlock() (*big.Int, error) { - return _UpkeepCounter.Contract.InitialBlock(&_UpkeepCounter.CallOpts) -} - -// Interval is a free data retrieval call binding the contract method 0x947a36fb. -// -// Solidity: function interval() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterCaller) Interval(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _UpkeepCounter.contract.Call(opts, &out, "interval") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// Interval is a free data retrieval call binding the contract method 0x947a36fb. -// -// Solidity: function interval() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterSession) Interval() (*big.Int, error) { - return _UpkeepCounter.Contract.Interval(&_UpkeepCounter.CallOpts) -} - -// Interval is a free data retrieval call binding the contract method 0x947a36fb. -// -// Solidity: function interval() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterCallerSession) Interval() (*big.Int, error) { - return _UpkeepCounter.Contract.Interval(&_UpkeepCounter.CallOpts) -} - -// LastBlock is a free data retrieval call binding the contract method 0x806b984f. -// -// Solidity: function lastBlock() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterCaller) LastBlock(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _UpkeepCounter.contract.Call(opts, &out, "lastBlock") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// LastBlock is a free data retrieval call binding the contract method 0x806b984f. -// -// Solidity: function lastBlock() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterSession) LastBlock() (*big.Int, error) { - return _UpkeepCounter.Contract.LastBlock(&_UpkeepCounter.CallOpts) -} - -// LastBlock is a free data retrieval call binding the contract method 0x806b984f. -// -// Solidity: function lastBlock() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterCallerSession) LastBlock() (*big.Int, error) { - return _UpkeepCounter.Contract.LastBlock(&_UpkeepCounter.CallOpts) -} - -// PreviousPerformBlock is a free data retrieval call binding the contract method 0x917d895f. -// -// Solidity: function previousPerformBlock() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterCaller) PreviousPerformBlock(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _UpkeepCounter.contract.Call(opts, &out, "previousPerformBlock") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// PreviousPerformBlock is a free data retrieval call binding the contract method 0x917d895f. -// -// Solidity: function previousPerformBlock() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterSession) PreviousPerformBlock() (*big.Int, error) { - return _UpkeepCounter.Contract.PreviousPerformBlock(&_UpkeepCounter.CallOpts) -} - -// PreviousPerformBlock is a free data retrieval call binding the contract method 0x917d895f. -// -// Solidity: function previousPerformBlock() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterCallerSession) PreviousPerformBlock() (*big.Int, error) { - return _UpkeepCounter.Contract.PreviousPerformBlock(&_UpkeepCounter.CallOpts) -} - -// TestRange is a free data retrieval call binding the contract method 0x6250a13a. -// -// Solidity: function testRange() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterCaller) TestRange(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _UpkeepCounter.contract.Call(opts, &out, "testRange") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// TestRange is a free data retrieval call binding the contract method 0x6250a13a. -// -// Solidity: function testRange() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterSession) TestRange() (*big.Int, error) { - return _UpkeepCounter.Contract.TestRange(&_UpkeepCounter.CallOpts) -} - -// TestRange is a free data retrieval call binding the contract method 0x6250a13a. -// -// Solidity: function testRange() view returns(uint256) -func (_UpkeepCounter *UpkeepCounterCallerSession) TestRange() (*big.Int, error) { - return _UpkeepCounter.Contract.TestRange(&_UpkeepCounter.CallOpts) -} - -// PerformUpkeep is a paid mutator transaction binding the contract method 0x4585e33b. -// -// Solidity: function performUpkeep(bytes performData) returns() -func (_UpkeepCounter *UpkeepCounterTransactor) PerformUpkeep(opts *bind.TransactOpts, performData []byte) (*types.Transaction, error) { - return _UpkeepCounter.contract.Transact(opts, "performUpkeep", performData) -} - -// PerformUpkeep is a paid mutator transaction binding the contract method 0x4585e33b. -// -// Solidity: function performUpkeep(bytes performData) returns() -func (_UpkeepCounter *UpkeepCounterSession) PerformUpkeep(performData []byte) (*types.Transaction, error) { - return _UpkeepCounter.Contract.PerformUpkeep(&_UpkeepCounter.TransactOpts, performData) -} - -// PerformUpkeep is a paid mutator transaction binding the contract method 0x4585e33b. -// -// Solidity: function performUpkeep(bytes performData) returns() -func (_UpkeepCounter *UpkeepCounterTransactorSession) PerformUpkeep(performData []byte) (*types.Transaction, error) { - return _UpkeepCounter.Contract.PerformUpkeep(&_UpkeepCounter.TransactOpts, performData) -} - -// SetSpread is a paid mutator transaction binding the contract method 0x7f407edf. -// -// Solidity: function setSpread(uint256 _testRange, uint256 _interval) returns() -func (_UpkeepCounter *UpkeepCounterTransactor) SetSpread(opts *bind.TransactOpts, _testRange *big.Int, _interval *big.Int) (*types.Transaction, error) { - return _UpkeepCounter.contract.Transact(opts, "setSpread", _testRange, _interval) -} - -// SetSpread is a paid mutator transaction binding the contract method 0x7f407edf. -// -// Solidity: function setSpread(uint256 _testRange, uint256 _interval) returns() -func (_UpkeepCounter *UpkeepCounterSession) SetSpread(_testRange *big.Int, _interval *big.Int) (*types.Transaction, error) { - return _UpkeepCounter.Contract.SetSpread(&_UpkeepCounter.TransactOpts, _testRange, _interval) -} - -// SetSpread is a paid mutator transaction binding the contract method 0x7f407edf. -// -// Solidity: function setSpread(uint256 _testRange, uint256 _interval) returns() -func (_UpkeepCounter *UpkeepCounterTransactorSession) SetSpread(_testRange *big.Int, _interval *big.Int) (*types.Transaction, error) { - return _UpkeepCounter.Contract.SetSpread(&_UpkeepCounter.TransactOpts, _testRange, _interval) -} - -// UpkeepCounterPerformingUpkeepIterator is returned from FilterPerformingUpkeep and is used to iterate over the raw logs and unpacked data for PerformingUpkeep events raised by the UpkeepCounter contract. -type UpkeepCounterPerformingUpkeepIterator struct { - Event *UpkeepCounterPerformingUpkeep // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *UpkeepCounterPerformingUpkeepIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(UpkeepCounterPerformingUpkeep) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(UpkeepCounterPerformingUpkeep) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *UpkeepCounterPerformingUpkeepIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *UpkeepCounterPerformingUpkeepIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// UpkeepCounterPerformingUpkeep represents a PerformingUpkeep event raised by the UpkeepCounter contract. -type UpkeepCounterPerformingUpkeep struct { - From common.Address - InitialBlock *big.Int - LastBlock *big.Int - PreviousBlock *big.Int - Counter *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterPerformingUpkeep is a free log retrieval operation binding the contract event 0x8e8112f20a2134e18e591d2cdd68cd86a95d06e6328ede501fc6314f4a5075fa. -// -// Solidity: event PerformingUpkeep(address indexed from, uint256 initialBlock, uint256 lastBlock, uint256 previousBlock, uint256 counter) -func (_UpkeepCounter *UpkeepCounterFilterer) FilterPerformingUpkeep(opts *bind.FilterOpts, from []common.Address) (*UpkeepCounterPerformingUpkeepIterator, error) { - - var fromRule []interface{} - for _, fromItem := range from { - fromRule = append(fromRule, fromItem) - } - - logs, sub, err := _UpkeepCounter.contract.FilterLogs(opts, "PerformingUpkeep", fromRule) - if err != nil { - return nil, err - } - return &UpkeepCounterPerformingUpkeepIterator{contract: _UpkeepCounter.contract, event: "PerformingUpkeep", logs: logs, sub: sub}, nil -} - -// WatchPerformingUpkeep is a free log subscription operation binding the contract event 0x8e8112f20a2134e18e591d2cdd68cd86a95d06e6328ede501fc6314f4a5075fa. -// -// Solidity: event PerformingUpkeep(address indexed from, uint256 initialBlock, uint256 lastBlock, uint256 previousBlock, uint256 counter) -func (_UpkeepCounter *UpkeepCounterFilterer) WatchPerformingUpkeep(opts *bind.WatchOpts, sink chan<- *UpkeepCounterPerformingUpkeep, from []common.Address) (event.Subscription, error) { - - var fromRule []interface{} - for _, fromItem := range from { - fromRule = append(fromRule, fromItem) - } - - logs, sub, err := _UpkeepCounter.contract.WatchLogs(opts, "PerformingUpkeep", fromRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(UpkeepCounterPerformingUpkeep) - if err := _UpkeepCounter.contract.UnpackLog(event, "PerformingUpkeep", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParsePerformingUpkeep is a log parse operation binding the contract event 0x8e8112f20a2134e18e591d2cdd68cd86a95d06e6328ede501fc6314f4a5075fa. -// -// Solidity: event PerformingUpkeep(address indexed from, uint256 initialBlock, uint256 lastBlock, uint256 previousBlock, uint256 counter) -func (_UpkeepCounter *UpkeepCounterFilterer) ParsePerformingUpkeep(log types.Log) (*UpkeepCounterPerformingUpkeep, error) { - event := new(UpkeepCounterPerformingUpkeep) - if err := _UpkeepCounter.contract.UnpackLog(event, "PerformingUpkeep", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/integration-tests/contracts/ethereum/UpkeepPerformCounterRestrictive.go b/integration-tests/contracts/ethereum/UpkeepPerformCounterRestrictive.go deleted file mode 100644 index 092472fe99e..00000000000 --- a/integration-tests/contracts/ethereum/UpkeepPerformCounterRestrictive.go +++ /dev/null @@ -1,756 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package ethereum - -import ( - "errors" - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = errors.New - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription -) - -// UpkeepPerformCounterRestrictiveMetaData contains all meta data concerning the UpkeepPerformCounterRestrictive contract. -var UpkeepPerformCounterRestrictiveMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_testRange\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_averageEligibilityCadence\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"eligible\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"initialCall\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"nextEligible\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"PerformingUpkeep\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"averageEligibilityCadence\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"checkEligible\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"checkGasToBurn\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"checkUpkeep\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"dummyMap\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCountPerforms\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialCall\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nextEligible\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"performGasToBurn\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"performUpkeep\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"reset\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"setCheckGasToBurn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"setPerformGasToBurn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_newTestRange\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_newAverageEligibilityCadence\",\"type\":\"uint256\"}],\"name\":\"setSpread\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"testRange\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", - Bin: "0x6080604052600080556000600155600060075534801561001e57600080fd5b506040516105c93803806105c98339818101604052604081101561004157600080fd5b508051602090910151600291909155600355610567806100626000396000f3fe608060405234801561001057600080fd5b50600436106100c55760003560e01c806313bda75b146100ca5780632555d2cf146100e95780632ff3617d146101065780634585e33b14610120578063523d9b8a1461018e5780636250a13a146101965780636e04ff0d1461019e5780637145f11b1461028d5780637f407edf146102be578063926f086e146102e1578063a9a4c57c146102e9578063b30566b4146102f1578063c228a98e146102f9578063d826f88f14610301578063e303666f14610309575b600080fd5b6100e7600480360360208110156100e057600080fd5b5035610311565b005b6100e7600480360360208110156100ff57600080fd5b5035610316565b61010e61031b565b60408051918252519081900360200190f35b6100e76004803603602081101561013657600080fd5b810190602081018135600160201b81111561015057600080fd5b82018360208201111561016257600080fd5b803590602001918460018302840111600160201b8311171561018357600080fd5b509092509050610321565b61010e610404565b61010e61040a565b61020c600480360360208110156101b457600080fd5b810190602081018135600160201b8111156101ce57600080fd5b8201836020820111156101e057600080fd5b803590602001918460018302840111600160201b8311171561020157600080fd5b509092509050610410565b60405180831515815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610251578181015183820152602001610239565b50505050905090810190601f16801561027e5780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b6102aa600480360360208110156102a357600080fd5b503561048b565b604080519115158252519081900360200190f35b6100e7600480360360408110156102d457600080fd5b50803590602001356104a0565b61010e6104ab565b61010e6104b1565b61010e6104b7565b6102aa6104bd565b6100e76104cc565b61010e6104d6565b600455565b600555565b60045481565b60005a905060006103306104dc565b60005460015460408051841515815232602082015280820193909352606083019190915243608083018190529051929350917fbd6b6608a51477954e8b498c633bda87e5cd555e06ead50486398d9e3b9cebc09181900360a00190a18161039657600080fd5b6000546103a35760008190555b6003546002026103b1610500565b816103b857fe5b06810160019081018155600780549091019055600019015b6005545a840310156103fd5780406000908152600660205260409020805460ff19169055600019016103d0565b5050505050565b60015481565b60025481565b6000606060005a9050600019430160005b6004545a840310156104585780801561044a5750814060009081526006602052604090205460ff165b600019909201919050610421565b6104606104dc565b6040805192151560208085019190915281518085039091018152928101905297909650945050505050565b60066020526000908152604090205460ff1681565b600291909155600355565b60005481565b60035481565b60055481565b60006104c76104dc565b905090565b6000808055600755565b60075490565b6000805415806104c7575060025460005443031080156104c7575050600154431190565b604080516000194301406020808301919091523082840152825180830384018152606090920190925280519101209056fea2646970667358221220a317dab4792a9ae36241f654e15b5fbb29c4a249e54654ea0b02219f739b347a64736f6c63430007060033", -} - -// UpkeepPerformCounterRestrictiveABI is the input ABI used to generate the binding from. -// Deprecated: Use UpkeepPerformCounterRestrictiveMetaData.ABI instead. -var UpkeepPerformCounterRestrictiveABI = UpkeepPerformCounterRestrictiveMetaData.ABI - -// UpkeepPerformCounterRestrictiveBin is the compiled bytecode used for deploying new contracts. -// Deprecated: Use UpkeepPerformCounterRestrictiveMetaData.Bin instead. -var UpkeepPerformCounterRestrictiveBin = UpkeepPerformCounterRestrictiveMetaData.Bin - -// DeployUpkeepPerformCounterRestrictive deploys a new Ethereum contract, binding an instance of UpkeepPerformCounterRestrictive to it. -func DeployUpkeepPerformCounterRestrictive(auth *bind.TransactOpts, backend bind.ContractBackend, _testRange *big.Int, _averageEligibilityCadence *big.Int) (common.Address, *types.Transaction, *UpkeepPerformCounterRestrictive, error) { - parsed, err := UpkeepPerformCounterRestrictiveMetaData.GetAbi() - if err != nil { - return common.Address{}, nil, nil, err - } - if parsed == nil { - return common.Address{}, nil, nil, errors.New("GetABI returned nil") - } - - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(UpkeepPerformCounterRestrictiveBin), backend, _testRange, _averageEligibilityCadence) - if err != nil { - return common.Address{}, nil, nil, err - } - return address, tx, &UpkeepPerformCounterRestrictive{UpkeepPerformCounterRestrictiveCaller: UpkeepPerformCounterRestrictiveCaller{contract: contract}, UpkeepPerformCounterRestrictiveTransactor: UpkeepPerformCounterRestrictiveTransactor{contract: contract}, UpkeepPerformCounterRestrictiveFilterer: UpkeepPerformCounterRestrictiveFilterer{contract: contract}}, nil -} - -// UpkeepPerformCounterRestrictive is an auto generated Go binding around an Ethereum contract. -type UpkeepPerformCounterRestrictive struct { - UpkeepPerformCounterRestrictiveCaller // Read-only binding to the contract - UpkeepPerformCounterRestrictiveTransactor // Write-only binding to the contract - UpkeepPerformCounterRestrictiveFilterer // Log filterer for contract events -} - -// UpkeepPerformCounterRestrictiveCaller is an auto generated read-only Go binding around an Ethereum contract. -type UpkeepPerformCounterRestrictiveCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// UpkeepPerformCounterRestrictiveTransactor is an auto generated write-only Go binding around an Ethereum contract. -type UpkeepPerformCounterRestrictiveTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// UpkeepPerformCounterRestrictiveFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type UpkeepPerformCounterRestrictiveFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// UpkeepPerformCounterRestrictiveSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type UpkeepPerformCounterRestrictiveSession struct { - Contract *UpkeepPerformCounterRestrictive // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// UpkeepPerformCounterRestrictiveCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type UpkeepPerformCounterRestrictiveCallerSession struct { - Contract *UpkeepPerformCounterRestrictiveCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// UpkeepPerformCounterRestrictiveTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type UpkeepPerformCounterRestrictiveTransactorSession struct { - Contract *UpkeepPerformCounterRestrictiveTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// UpkeepPerformCounterRestrictiveRaw is an auto generated low-level Go binding around an Ethereum contract. -type UpkeepPerformCounterRestrictiveRaw struct { - Contract *UpkeepPerformCounterRestrictive // Generic contract binding to access the raw methods on -} - -// UpkeepPerformCounterRestrictiveCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type UpkeepPerformCounterRestrictiveCallerRaw struct { - Contract *UpkeepPerformCounterRestrictiveCaller // Generic read-only contract binding to access the raw methods on -} - -// UpkeepPerformCounterRestrictiveTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type UpkeepPerformCounterRestrictiveTransactorRaw struct { - Contract *UpkeepPerformCounterRestrictiveTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewUpkeepPerformCounterRestrictive creates a new instance of UpkeepPerformCounterRestrictive, bound to a specific deployed contract. -func NewUpkeepPerformCounterRestrictive(address common.Address, backend bind.ContractBackend) (*UpkeepPerformCounterRestrictive, error) { - contract, err := bindUpkeepPerformCounterRestrictive(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &UpkeepPerformCounterRestrictive{UpkeepPerformCounterRestrictiveCaller: UpkeepPerformCounterRestrictiveCaller{contract: contract}, UpkeepPerformCounterRestrictiveTransactor: UpkeepPerformCounterRestrictiveTransactor{contract: contract}, UpkeepPerformCounterRestrictiveFilterer: UpkeepPerformCounterRestrictiveFilterer{contract: contract}}, nil -} - -// NewUpkeepPerformCounterRestrictiveCaller creates a new read-only instance of UpkeepPerformCounterRestrictive, bound to a specific deployed contract. -func NewUpkeepPerformCounterRestrictiveCaller(address common.Address, caller bind.ContractCaller) (*UpkeepPerformCounterRestrictiveCaller, error) { - contract, err := bindUpkeepPerformCounterRestrictive(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &UpkeepPerformCounterRestrictiveCaller{contract: contract}, nil -} - -// NewUpkeepPerformCounterRestrictiveTransactor creates a new write-only instance of UpkeepPerformCounterRestrictive, bound to a specific deployed contract. -func NewUpkeepPerformCounterRestrictiveTransactor(address common.Address, transactor bind.ContractTransactor) (*UpkeepPerformCounterRestrictiveTransactor, error) { - contract, err := bindUpkeepPerformCounterRestrictive(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &UpkeepPerformCounterRestrictiveTransactor{contract: contract}, nil -} - -// NewUpkeepPerformCounterRestrictiveFilterer creates a new log filterer instance of UpkeepPerformCounterRestrictive, bound to a specific deployed contract. -func NewUpkeepPerformCounterRestrictiveFilterer(address common.Address, filterer bind.ContractFilterer) (*UpkeepPerformCounterRestrictiveFilterer, error) { - contract, err := bindUpkeepPerformCounterRestrictive(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &UpkeepPerformCounterRestrictiveFilterer{contract: contract}, nil -} - -// bindUpkeepPerformCounterRestrictive binds a generic wrapper to an already deployed contract. -func bindUpkeepPerformCounterRestrictive(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(UpkeepPerformCounterRestrictiveABI)) - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _UpkeepPerformCounterRestrictive.Contract.UpkeepPerformCounterRestrictiveCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.Contract.UpkeepPerformCounterRestrictiveTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.Contract.UpkeepPerformCounterRestrictiveTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _UpkeepPerformCounterRestrictive.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.Contract.contract.Transact(opts, method, params...) -} - -// AverageEligibilityCadence is a free data retrieval call binding the contract method 0xa9a4c57c. -// -// Solidity: function averageEligibilityCadence() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCaller) AverageEligibilityCadence(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _UpkeepPerformCounterRestrictive.contract.Call(opts, &out, "averageEligibilityCadence") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// AverageEligibilityCadence is a free data retrieval call binding the contract method 0xa9a4c57c. -// -// Solidity: function averageEligibilityCadence() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveSession) AverageEligibilityCadence() (*big.Int, error) { - return _UpkeepPerformCounterRestrictive.Contract.AverageEligibilityCadence(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// AverageEligibilityCadence is a free data retrieval call binding the contract method 0xa9a4c57c. -// -// Solidity: function averageEligibilityCadence() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCallerSession) AverageEligibilityCadence() (*big.Int, error) { - return _UpkeepPerformCounterRestrictive.Contract.AverageEligibilityCadence(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// CheckEligible is a free data retrieval call binding the contract method 0xc228a98e. -// -// Solidity: function checkEligible() view returns(bool) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCaller) CheckEligible(opts *bind.CallOpts) (bool, error) { - var out []interface{} - err := _UpkeepPerformCounterRestrictive.contract.Call(opts, &out, "checkEligible") - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// CheckEligible is a free data retrieval call binding the contract method 0xc228a98e. -// -// Solidity: function checkEligible() view returns(bool) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveSession) CheckEligible() (bool, error) { - return _UpkeepPerformCounterRestrictive.Contract.CheckEligible(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// CheckEligible is a free data retrieval call binding the contract method 0xc228a98e. -// -// Solidity: function checkEligible() view returns(bool) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCallerSession) CheckEligible() (bool, error) { - return _UpkeepPerformCounterRestrictive.Contract.CheckEligible(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// CheckGasToBurn is a free data retrieval call binding the contract method 0x2ff3617d. -// -// Solidity: function checkGasToBurn() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCaller) CheckGasToBurn(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _UpkeepPerformCounterRestrictive.contract.Call(opts, &out, "checkGasToBurn") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// CheckGasToBurn is a free data retrieval call binding the contract method 0x2ff3617d. -// -// Solidity: function checkGasToBurn() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveSession) CheckGasToBurn() (*big.Int, error) { - return _UpkeepPerformCounterRestrictive.Contract.CheckGasToBurn(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// CheckGasToBurn is a free data retrieval call binding the contract method 0x2ff3617d. -// -// Solidity: function checkGasToBurn() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCallerSession) CheckGasToBurn() (*big.Int, error) { - return _UpkeepPerformCounterRestrictive.Contract.CheckGasToBurn(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// CheckUpkeep is a free data retrieval call binding the contract method 0x6e04ff0d. -// -// Solidity: function checkUpkeep(bytes data) view returns(bool, bytes) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCaller) CheckUpkeep(opts *bind.CallOpts, data []byte) (bool, []byte, error) { - var out []interface{} - err := _UpkeepPerformCounterRestrictive.contract.Call(opts, &out, "checkUpkeep", data) - - if err != nil { - return *new(bool), *new([]byte), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - out1 := *abi.ConvertType(out[1], new([]byte)).(*[]byte) - - return out0, out1, err - -} - -// CheckUpkeep is a free data retrieval call binding the contract method 0x6e04ff0d. -// -// Solidity: function checkUpkeep(bytes data) view returns(bool, bytes) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveSession) CheckUpkeep(data []byte) (bool, []byte, error) { - return _UpkeepPerformCounterRestrictive.Contract.CheckUpkeep(&_UpkeepPerformCounterRestrictive.CallOpts, data) -} - -// CheckUpkeep is a free data retrieval call binding the contract method 0x6e04ff0d. -// -// Solidity: function checkUpkeep(bytes data) view returns(bool, bytes) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCallerSession) CheckUpkeep(data []byte) (bool, []byte, error) { - return _UpkeepPerformCounterRestrictive.Contract.CheckUpkeep(&_UpkeepPerformCounterRestrictive.CallOpts, data) -} - -// DummyMap is a free data retrieval call binding the contract method 0x7145f11b. -// -// Solidity: function dummyMap(bytes32 ) view returns(bool) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCaller) DummyMap(opts *bind.CallOpts, arg0 [32]byte) (bool, error) { - var out []interface{} - err := _UpkeepPerformCounterRestrictive.contract.Call(opts, &out, "dummyMap", arg0) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// DummyMap is a free data retrieval call binding the contract method 0x7145f11b. -// -// Solidity: function dummyMap(bytes32 ) view returns(bool) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveSession) DummyMap(arg0 [32]byte) (bool, error) { - return _UpkeepPerformCounterRestrictive.Contract.DummyMap(&_UpkeepPerformCounterRestrictive.CallOpts, arg0) -} - -// DummyMap is a free data retrieval call binding the contract method 0x7145f11b. -// -// Solidity: function dummyMap(bytes32 ) view returns(bool) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCallerSession) DummyMap(arg0 [32]byte) (bool, error) { - return _UpkeepPerformCounterRestrictive.Contract.DummyMap(&_UpkeepPerformCounterRestrictive.CallOpts, arg0) -} - -// GetCountPerforms is a free data retrieval call binding the contract method 0xe303666f. -// -// Solidity: function getCountPerforms() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCaller) GetCountPerforms(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _UpkeepPerformCounterRestrictive.contract.Call(opts, &out, "getCountPerforms") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// GetCountPerforms is a free data retrieval call binding the contract method 0xe303666f. -// -// Solidity: function getCountPerforms() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveSession) GetCountPerforms() (*big.Int, error) { - return _UpkeepPerformCounterRestrictive.Contract.GetCountPerforms(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// GetCountPerforms is a free data retrieval call binding the contract method 0xe303666f. -// -// Solidity: function getCountPerforms() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCallerSession) GetCountPerforms() (*big.Int, error) { - return _UpkeepPerformCounterRestrictive.Contract.GetCountPerforms(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// InitialCall is a free data retrieval call binding the contract method 0x926f086e. -// -// Solidity: function initialCall() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCaller) InitialCall(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _UpkeepPerformCounterRestrictive.contract.Call(opts, &out, "initialCall") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// InitialCall is a free data retrieval call binding the contract method 0x926f086e. -// -// Solidity: function initialCall() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveSession) InitialCall() (*big.Int, error) { - return _UpkeepPerformCounterRestrictive.Contract.InitialCall(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// InitialCall is a free data retrieval call binding the contract method 0x926f086e. -// -// Solidity: function initialCall() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCallerSession) InitialCall() (*big.Int, error) { - return _UpkeepPerformCounterRestrictive.Contract.InitialCall(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// NextEligible is a free data retrieval call binding the contract method 0x523d9b8a. -// -// Solidity: function nextEligible() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCaller) NextEligible(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _UpkeepPerformCounterRestrictive.contract.Call(opts, &out, "nextEligible") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// NextEligible is a free data retrieval call binding the contract method 0x523d9b8a. -// -// Solidity: function nextEligible() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveSession) NextEligible() (*big.Int, error) { - return _UpkeepPerformCounterRestrictive.Contract.NextEligible(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// NextEligible is a free data retrieval call binding the contract method 0x523d9b8a. -// -// Solidity: function nextEligible() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCallerSession) NextEligible() (*big.Int, error) { - return _UpkeepPerformCounterRestrictive.Contract.NextEligible(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// PerformGasToBurn is a free data retrieval call binding the contract method 0xb30566b4. -// -// Solidity: function performGasToBurn() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCaller) PerformGasToBurn(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _UpkeepPerformCounterRestrictive.contract.Call(opts, &out, "performGasToBurn") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// PerformGasToBurn is a free data retrieval call binding the contract method 0xb30566b4. -// -// Solidity: function performGasToBurn() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveSession) PerformGasToBurn() (*big.Int, error) { - return _UpkeepPerformCounterRestrictive.Contract.PerformGasToBurn(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// PerformGasToBurn is a free data retrieval call binding the contract method 0xb30566b4. -// -// Solidity: function performGasToBurn() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCallerSession) PerformGasToBurn() (*big.Int, error) { - return _UpkeepPerformCounterRestrictive.Contract.PerformGasToBurn(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// TestRange is a free data retrieval call binding the contract method 0x6250a13a. -// -// Solidity: function testRange() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCaller) TestRange(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _UpkeepPerformCounterRestrictive.contract.Call(opts, &out, "testRange") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// TestRange is a free data retrieval call binding the contract method 0x6250a13a. -// -// Solidity: function testRange() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveSession) TestRange() (*big.Int, error) { - return _UpkeepPerformCounterRestrictive.Contract.TestRange(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// TestRange is a free data retrieval call binding the contract method 0x6250a13a. -// -// Solidity: function testRange() view returns(uint256) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveCallerSession) TestRange() (*big.Int, error) { - return _UpkeepPerformCounterRestrictive.Contract.TestRange(&_UpkeepPerformCounterRestrictive.CallOpts) -} - -// PerformUpkeep is a paid mutator transaction binding the contract method 0x4585e33b. -// -// Solidity: function performUpkeep(bytes ) returns() -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveTransactor) PerformUpkeep(opts *bind.TransactOpts, arg0 []byte) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.contract.Transact(opts, "performUpkeep", arg0) -} - -// PerformUpkeep is a paid mutator transaction binding the contract method 0x4585e33b. -// -// Solidity: function performUpkeep(bytes ) returns() -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveSession) PerformUpkeep(arg0 []byte) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.Contract.PerformUpkeep(&_UpkeepPerformCounterRestrictive.TransactOpts, arg0) -} - -// PerformUpkeep is a paid mutator transaction binding the contract method 0x4585e33b. -// -// Solidity: function performUpkeep(bytes ) returns() -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveTransactorSession) PerformUpkeep(arg0 []byte) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.Contract.PerformUpkeep(&_UpkeepPerformCounterRestrictive.TransactOpts, arg0) -} - -// Reset is a paid mutator transaction binding the contract method 0xd826f88f. -// -// Solidity: function reset() returns() -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveTransactor) Reset(opts *bind.TransactOpts) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.contract.Transact(opts, "reset") -} - -// Reset is a paid mutator transaction binding the contract method 0xd826f88f. -// -// Solidity: function reset() returns() -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveSession) Reset() (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.Contract.Reset(&_UpkeepPerformCounterRestrictive.TransactOpts) -} - -// Reset is a paid mutator transaction binding the contract method 0xd826f88f. -// -// Solidity: function reset() returns() -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveTransactorSession) Reset() (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.Contract.Reset(&_UpkeepPerformCounterRestrictive.TransactOpts) -} - -// SetCheckGasToBurn is a paid mutator transaction binding the contract method 0x13bda75b. -// -// Solidity: function setCheckGasToBurn(uint256 value) returns() -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveTransactor) SetCheckGasToBurn(opts *bind.TransactOpts, value *big.Int) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.contract.Transact(opts, "setCheckGasToBurn", value) -} - -// SetCheckGasToBurn is a paid mutator transaction binding the contract method 0x13bda75b. -// -// Solidity: function setCheckGasToBurn(uint256 value) returns() -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveSession) SetCheckGasToBurn(value *big.Int) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.Contract.SetCheckGasToBurn(&_UpkeepPerformCounterRestrictive.TransactOpts, value) -} - -// SetCheckGasToBurn is a paid mutator transaction binding the contract method 0x13bda75b. -// -// Solidity: function setCheckGasToBurn(uint256 value) returns() -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveTransactorSession) SetCheckGasToBurn(value *big.Int) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.Contract.SetCheckGasToBurn(&_UpkeepPerformCounterRestrictive.TransactOpts, value) -} - -// SetPerformGasToBurn is a paid mutator transaction binding the contract method 0x2555d2cf. -// -// Solidity: function setPerformGasToBurn(uint256 value) returns() -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveTransactor) SetPerformGasToBurn(opts *bind.TransactOpts, value *big.Int) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.contract.Transact(opts, "setPerformGasToBurn", value) -} - -// SetPerformGasToBurn is a paid mutator transaction binding the contract method 0x2555d2cf. -// -// Solidity: function setPerformGasToBurn(uint256 value) returns() -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveSession) SetPerformGasToBurn(value *big.Int) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.Contract.SetPerformGasToBurn(&_UpkeepPerformCounterRestrictive.TransactOpts, value) -} - -// SetPerformGasToBurn is a paid mutator transaction binding the contract method 0x2555d2cf. -// -// Solidity: function setPerformGasToBurn(uint256 value) returns() -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveTransactorSession) SetPerformGasToBurn(value *big.Int) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.Contract.SetPerformGasToBurn(&_UpkeepPerformCounterRestrictive.TransactOpts, value) -} - -// SetSpread is a paid mutator transaction binding the contract method 0x7f407edf. -// -// Solidity: function setSpread(uint256 _newTestRange, uint256 _newAverageEligibilityCadence) returns() -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveTransactor) SetSpread(opts *bind.TransactOpts, _newTestRange *big.Int, _newAverageEligibilityCadence *big.Int) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.contract.Transact(opts, "setSpread", _newTestRange, _newAverageEligibilityCadence) -} - -// SetSpread is a paid mutator transaction binding the contract method 0x7f407edf. -// -// Solidity: function setSpread(uint256 _newTestRange, uint256 _newAverageEligibilityCadence) returns() -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveSession) SetSpread(_newTestRange *big.Int, _newAverageEligibilityCadence *big.Int) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.Contract.SetSpread(&_UpkeepPerformCounterRestrictive.TransactOpts, _newTestRange, _newAverageEligibilityCadence) -} - -// SetSpread is a paid mutator transaction binding the contract method 0x7f407edf. -// -// Solidity: function setSpread(uint256 _newTestRange, uint256 _newAverageEligibilityCadence) returns() -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveTransactorSession) SetSpread(_newTestRange *big.Int, _newAverageEligibilityCadence *big.Int) (*types.Transaction, error) { - return _UpkeepPerformCounterRestrictive.Contract.SetSpread(&_UpkeepPerformCounterRestrictive.TransactOpts, _newTestRange, _newAverageEligibilityCadence) -} - -// UpkeepPerformCounterRestrictivePerformingUpkeepIterator is returned from FilterPerformingUpkeep and is used to iterate over the raw logs and unpacked data for PerformingUpkeep events raised by the UpkeepPerformCounterRestrictive contract. -type UpkeepPerformCounterRestrictivePerformingUpkeepIterator struct { - Event *UpkeepPerformCounterRestrictivePerformingUpkeep // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *UpkeepPerformCounterRestrictivePerformingUpkeepIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(UpkeepPerformCounterRestrictivePerformingUpkeep) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(UpkeepPerformCounterRestrictivePerformingUpkeep) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *UpkeepPerformCounterRestrictivePerformingUpkeepIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *UpkeepPerformCounterRestrictivePerformingUpkeepIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// UpkeepPerformCounterRestrictivePerformingUpkeep represents a PerformingUpkeep event raised by the UpkeepPerformCounterRestrictive contract. -type UpkeepPerformCounterRestrictivePerformingUpkeep struct { - Eligible bool - From common.Address - InitialCall *big.Int - NextEligible *big.Int - BlockNumber *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterPerformingUpkeep is a free log retrieval operation binding the contract event 0xbd6b6608a51477954e8b498c633bda87e5cd555e06ead50486398d9e3b9cebc0. -// -// Solidity: event PerformingUpkeep(bool eligible, address from, uint256 initialCall, uint256 nextEligible, uint256 blockNumber) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveFilterer) FilterPerformingUpkeep(opts *bind.FilterOpts) (*UpkeepPerformCounterRestrictivePerformingUpkeepIterator, error) { - - logs, sub, err := _UpkeepPerformCounterRestrictive.contract.FilterLogs(opts, "PerformingUpkeep") - if err != nil { - return nil, err - } - return &UpkeepPerformCounterRestrictivePerformingUpkeepIterator{contract: _UpkeepPerformCounterRestrictive.contract, event: "PerformingUpkeep", logs: logs, sub: sub}, nil -} - -// WatchPerformingUpkeep is a free log subscription operation binding the contract event 0xbd6b6608a51477954e8b498c633bda87e5cd555e06ead50486398d9e3b9cebc0. -// -// Solidity: event PerformingUpkeep(bool eligible, address from, uint256 initialCall, uint256 nextEligible, uint256 blockNumber) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveFilterer) WatchPerformingUpkeep(opts *bind.WatchOpts, sink chan<- *UpkeepPerformCounterRestrictivePerformingUpkeep) (event.Subscription, error) { - - logs, sub, err := _UpkeepPerformCounterRestrictive.contract.WatchLogs(opts, "PerformingUpkeep") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(UpkeepPerformCounterRestrictivePerformingUpkeep) - if err := _UpkeepPerformCounterRestrictive.contract.UnpackLog(event, "PerformingUpkeep", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParsePerformingUpkeep is a log parse operation binding the contract event 0xbd6b6608a51477954e8b498c633bda87e5cd555e06ead50486398d9e3b9cebc0. -// -// Solidity: event PerformingUpkeep(bool eligible, address from, uint256 initialCall, uint256 nextEligible, uint256 blockNumber) -func (_UpkeepPerformCounterRestrictive *UpkeepPerformCounterRestrictiveFilterer) ParsePerformingUpkeep(log types.Log) (*UpkeepPerformCounterRestrictivePerformingUpkeep, error) { - event := new(UpkeepPerformCounterRestrictivePerformingUpkeep) - if err := _UpkeepPerformCounterRestrictive.contract.UnpackLog(event, "PerformingUpkeep", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/integration-tests/contracts/ethereum/VRFv2Consumer.go b/integration-tests/contracts/ethereum/VRFv2Consumer.go deleted file mode 100644 index 9793d96a11f..00000000000 --- a/integration-tests/contracts/ethereum/VRFv2Consumer.go +++ /dev/null @@ -1,1045 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package ethereum - -import ( - "errors" - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = errors.New - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription -) - -// VRFv2ConsumerMetaData contains all meta data concerning the VRFv2Consumer contract. -var VRFv2ConsumerMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vrfCoordinator\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"have\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"want\",\"type\":\"address\"}],\"name\":\"OnlyCoordinatorCanFulfill\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"OwnershipTransferRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"randomWords\",\"type\":\"uint256[]\"}],\"name\":\"RequestFulfilled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"numWords\",\"type\":\"uint32\"}],\"name\":\"RequestSent\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_requestId\",\"type\":\"uint256\"}],\"name\":\"getRequestStatus\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"fulfilled\",\"type\":\"bool\"},{\"internalType\":\"uint256[]\",\"name\":\"randomWords\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastRequestId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"requestId\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"randomWords\",\"type\":\"uint256[]\"}],\"name\":\"rawFulfillRandomWords\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"requestIds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"subId\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"callbackGasLimit\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"requestConfirmations\",\"type\":\"uint16\"},{\"internalType\":\"uint32\",\"name\":\"numWords\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"keyHash\",\"type\":\"bytes32\"}],\"name\":\"requestRandomWords\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"requestId\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"s_requests\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"fulfilled\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"exists\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x60a06040523480156200001157600080fd5b50604051620018a4380380620018a483398181016040528101906200003791906200034e565b33806000838073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603620000e3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620000da90620003e1565b60405180910390fd5b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146200016a576200016981620001b560201b60201c565b5b50505080600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505062000475565b3373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160362000226576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016200021d9062000453565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae127860405160405180910390a350565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006200031682620002e9565b9050919050565b620003288162000309565b81146200033457600080fd5b50565b60008151905062000348816200031d565b92915050565b600060208284031215620003675762000366620002e4565b5b6000620003778482850162000337565b91505092915050565b600082825260208201905092915050565b7f43616e6e6f7420736574206f776e657220746f207a65726f0000000000000000600082015250565b6000620003c960188362000380565b9150620003d68262000391565b602082019050919050565b60006020820190508181036000830152620003fc81620003ba565b9050919050565b7f43616e6e6f74207472616e7366657220746f2073656c66000000000000000000600082015250565b60006200043b60178362000380565b9150620004488262000403565b602082019050919050565b600060208201905081810360008301526200046e816200042c565b9050919050565b60805161140c62000498600039600081816101da015261022e015261140c6000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c80639561f023116100665780639561f0231461010c578063a168fa891461013c578063d8a4676f1461016d578063f2fde38b1461019e578063fc2a88c3146101ba57610093565b80631fe543e31461009857806379ba5097146100b45780638796ba8c146100be5780638da5cb5b146100ee575b600080fd5b6100b260048036038101906100ad9190610cc1565b6101d8565b005b6100bc610298565b005b6100d860048036038101906100d39190610d1d565b61042d565b6040516100e59190610d59565b60405180910390f35b6100f6610451565b6040516101039190610db5565b60405180910390f35b61012660048036038101906101219190610ebc565b61047a565b6040516101339190610d59565b60405180910390f35b61015660048036038101906101519190610d1d565b61067b565b604051610164929190610f52565b60405180910390f35b61018760048036038101906101829190610d1d565b6106b9565b604051610195929190611039565b60405180910390f35b6101b860048036038101906101b39190611095565b6107e4565b005b6101c26107f8565b6040516101cf9190610d59565b60405180910390f35b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461028a57337f00000000000000000000000000000000000000000000000000000000000000006040517f1cf993f40000000000000000000000000000000000000000000000000000000081526004016102819291906110c2565b60405180910390fd5b61029482826107fe565b5050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610328576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161031f90611148565b60405180910390fd5b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350565b6004818154811061043d57600080fd5b906000526020600020016000915090505481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006104846108f8565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16635d3b1d3083888789886040518663ffffffff1660e01b81526004016104e79594939291906111a4565b6020604051808303816000875af1158015610506573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052a919061120c565b90506040518060600160405280600015158152602001600115158152602001600067ffffffffffffffff81111561056457610563610b7e565b5b6040519080825280602002602001820160405280156105925781602001602082028036833780820191505090505b508152506002600083815260200190815260200160002060008201518160000160006101000a81548160ff02191690831515021790555060208201518160000160016101000a81548160ff0219169083151502179055506040820151816001019080519060200190610605929190610ab4565b509050506004819080600181540180825580915050600190039060005260206000200160009091909190915055806005819055507fcc58b13ad3eab50626c6a6300b1d139cd6ebb1688a7cced9461c2f7e762665ee818460405161066a929190611239565b60405180910390a195945050505050565b60026020528060005260406000206000915090508060000160009054906101000a900460ff16908060000160019054906101000a900460ff16905082565b600060606002600084815260200190815260200160002060000160019054906101000a900460ff16610720576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610717906112ae565b60405180910390fd5b6000600260008581526020019081526020016000206040518060600160405290816000820160009054906101000a900460ff161515151581526020016000820160019054906101000a900460ff16151515158152602001600182018054806020026020016040519081016040528092919081815260200182805480156107c557602002820191906000526020600020905b8154815260200190600101908083116107b1575b5050505050815250509050806000015181604001519250925050915091565b6107ec6108f8565b6107f581610988565b50565b60055481565b6002600083815260200190815260200160002060000160019054906101000a900460ff16610861576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610858906112ae565b60405180910390fd5b60016002600084815260200190815260200160002060000160006101000a81548160ff021916908315150217905550806002600084815260200190815260200160002060010190805190602001906108ba929190610ab4565b507ffe2e2d779dba245964d4e3ef9b994be63856fd568bf7d3ca9e224755cb1bd54d82826040516108ec9291906112ce565b60405180910390a15050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610986576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161097d9061134a565b60405180910390fd5b565b3373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036109f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ed906113b6565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae127860405160405180910390a350565b828054828255906000526020600020908101928215610af0579160200282015b82811115610aef578251825591602001919060010190610ad4565b5b509050610afd9190610b01565b5090565b5b80821115610b1a576000816000905550600101610b02565b5090565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b610b4581610b32565b8114610b5057600080fd5b50565b600081359050610b6281610b3c565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610bb682610b6d565b810181811067ffffffffffffffff82111715610bd557610bd4610b7e565b5b80604052505050565b6000610be8610b1e565b9050610bf48282610bad565b919050565b600067ffffffffffffffff821115610c1457610c13610b7e565b5b602082029050602081019050919050565b600080fd5b6000610c3d610c3884610bf9565b610bde565b90508083825260208201905060208402830185811115610c6057610c5f610c25565b5b835b81811015610c895780610c758882610b53565b845260208401935050602081019050610c62565b5050509392505050565b600082601f830112610ca857610ca7610b68565b5b8135610cb8848260208601610c2a565b91505092915050565b60008060408385031215610cd857610cd7610b28565b5b6000610ce685828601610b53565b925050602083013567ffffffffffffffff811115610d0757610d06610b2d565b5b610d1385828601610c93565b9150509250929050565b600060208284031215610d3357610d32610b28565b5b6000610d4184828501610b53565b91505092915050565b610d5381610b32565b82525050565b6000602082019050610d6e6000830184610d4a565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610d9f82610d74565b9050919050565b610daf81610d94565b82525050565b6000602082019050610dca6000830184610da6565b92915050565b600067ffffffffffffffff82169050919050565b610ded81610dd0565b8114610df857600080fd5b50565b600081359050610e0a81610de4565b92915050565b600063ffffffff82169050919050565b610e2981610e10565b8114610e3457600080fd5b50565b600081359050610e4681610e20565b92915050565b600061ffff82169050919050565b610e6381610e4c565b8114610e6e57600080fd5b50565b600081359050610e8081610e5a565b92915050565b6000819050919050565b610e9981610e86565b8114610ea457600080fd5b50565b600081359050610eb681610e90565b92915050565b600080600080600060a08688031215610ed857610ed7610b28565b5b6000610ee688828901610dfb565b9550506020610ef788828901610e37565b9450506040610f0888828901610e71565b9350506060610f1988828901610e37565b9250506080610f2a88828901610ea7565b9150509295509295909350565b60008115159050919050565b610f4c81610f37565b82525050565b6000604082019050610f676000830185610f43565b610f746020830184610f43565b9392505050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b610fb081610b32565b82525050565b6000610fc28383610fa7565b60208301905092915050565b6000602082019050919050565b6000610fe682610f7b565b610ff08185610f86565b9350610ffb83610f97565b8060005b8381101561102c5781516110138882610fb6565b975061101e83610fce565b925050600181019050610fff565b5085935050505092915050565b600060408201905061104e6000830185610f43565b81810360208301526110608184610fdb565b90509392505050565b61107281610d94565b811461107d57600080fd5b50565b60008135905061108f81611069565b92915050565b6000602082840312156110ab576110aa610b28565b5b60006110b984828501611080565b91505092915050565b60006040820190506110d76000830185610da6565b6110e46020830184610da6565b9392505050565b600082825260208201905092915050565b7f4d7573742062652070726f706f736564206f776e657200000000000000000000600082015250565b60006111326016836110eb565b915061113d826110fc565b602082019050919050565b6000602082019050818103600083015261116181611125565b9050919050565b61117181610e86565b82525050565b61118081610dd0565b82525050565b61118f81610e4c565b82525050565b61119e81610e10565b82525050565b600060a0820190506111b96000830188611168565b6111c66020830187611177565b6111d36040830186611186565b6111e06060830185611195565b6111ed6080830184611195565b9695505050505050565b60008151905061120681610b3c565b92915050565b60006020828403121561122257611221610b28565b5b6000611230848285016111f7565b91505092915050565b600060408201905061124e6000830185610d4a565b61125b6020830184611195565b9392505050565b7f72657175657374206e6f7420666f756e64000000000000000000000000000000600082015250565b60006112986011836110eb565b91506112a382611262565b602082019050919050565b600060208201905081810360008301526112c78161128b565b9050919050565b60006040820190506112e36000830185610d4a565b81810360208301526112f58184610fdb565b90509392505050565b7f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000600082015250565b60006113346016836110eb565b915061133f826112fe565b602082019050919050565b6000602082019050818103600083015261136381611327565b9050919050565b7f43616e6e6f74207472616e7366657220746f2073656c66000000000000000000600082015250565b60006113a06017836110eb565b91506113ab8261136a565b602082019050919050565b600060208201905081810360008301526113cf81611393565b905091905056fea2646970667358221220e3ffc5c5c5c9efece6a6dd560edba3d094c9853bc2c4400e1d3ea7e3d950ecfa64736f6c63430008110033", -} - -// VRFv2ConsumerABI is the input ABI used to generate the binding from. -// Deprecated: Use VRFv2ConsumerMetaData.ABI instead. -var VRFv2ConsumerABI = VRFv2ConsumerMetaData.ABI - -// VRFv2ConsumerBin is the compiled bytecode used for deploying new contracts. -// Deprecated: Use VRFv2ConsumerMetaData.Bin instead. -var VRFv2ConsumerBin = VRFv2ConsumerMetaData.Bin - -// DeployVRFv2Consumer deploys a new Ethereum contract, binding an instance of VRFv2Consumer to it. -func DeployVRFv2Consumer(auth *bind.TransactOpts, backend bind.ContractBackend, vrfCoordinator common.Address) (common.Address, *types.Transaction, *VRFv2Consumer, error) { - parsed, err := VRFv2ConsumerMetaData.GetAbi() - if err != nil { - return common.Address{}, nil, nil, err - } - if parsed == nil { - return common.Address{}, nil, nil, errors.New("GetABI returned nil") - } - - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(VRFv2ConsumerBin), backend, vrfCoordinator) - if err != nil { - return common.Address{}, nil, nil, err - } - return address, tx, &VRFv2Consumer{VRFv2ConsumerCaller: VRFv2ConsumerCaller{contract: contract}, VRFv2ConsumerTransactor: VRFv2ConsumerTransactor{contract: contract}, VRFv2ConsumerFilterer: VRFv2ConsumerFilterer{contract: contract}}, nil -} - -// VRFv2Consumer is an auto generated Go binding around an Ethereum contract. -type VRFv2Consumer struct { - VRFv2ConsumerCaller // Read-only binding to the contract - VRFv2ConsumerTransactor // Write-only binding to the contract - VRFv2ConsumerFilterer // Log filterer for contract events -} - -// VRFv2ConsumerCaller is an auto generated read-only Go binding around an Ethereum contract. -type VRFv2ConsumerCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// VRFv2ConsumerTransactor is an auto generated write-only Go binding around an Ethereum contract. -type VRFv2ConsumerTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// VRFv2ConsumerFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type VRFv2ConsumerFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// VRFv2ConsumerSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type VRFv2ConsumerSession struct { - Contract *VRFv2Consumer // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// VRFv2ConsumerCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type VRFv2ConsumerCallerSession struct { - Contract *VRFv2ConsumerCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// VRFv2ConsumerTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type VRFv2ConsumerTransactorSession struct { - Contract *VRFv2ConsumerTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// VRFv2ConsumerRaw is an auto generated low-level Go binding around an Ethereum contract. -type VRFv2ConsumerRaw struct { - Contract *VRFv2Consumer // Generic contract binding to access the raw methods on -} - -// VRFv2ConsumerCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type VRFv2ConsumerCallerRaw struct { - Contract *VRFv2ConsumerCaller // Generic read-only contract binding to access the raw methods on -} - -// VRFv2ConsumerTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type VRFv2ConsumerTransactorRaw struct { - Contract *VRFv2ConsumerTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewVRFv2Consumer creates a new instance of VRFv2Consumer, bound to a specific deployed contract. -func NewVRFv2Consumer(address common.Address, backend bind.ContractBackend) (*VRFv2Consumer, error) { - contract, err := bindVRFv2Consumer(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &VRFv2Consumer{VRFv2ConsumerCaller: VRFv2ConsumerCaller{contract: contract}, VRFv2ConsumerTransactor: VRFv2ConsumerTransactor{contract: contract}, VRFv2ConsumerFilterer: VRFv2ConsumerFilterer{contract: contract}}, nil -} - -// NewVRFv2ConsumerCaller creates a new read-only instance of VRFv2Consumer, bound to a specific deployed contract. -func NewVRFv2ConsumerCaller(address common.Address, caller bind.ContractCaller) (*VRFv2ConsumerCaller, error) { - contract, err := bindVRFv2Consumer(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &VRFv2ConsumerCaller{contract: contract}, nil -} - -// NewVRFv2ConsumerTransactor creates a new write-only instance of VRFv2Consumer, bound to a specific deployed contract. -func NewVRFv2ConsumerTransactor(address common.Address, transactor bind.ContractTransactor) (*VRFv2ConsumerTransactor, error) { - contract, err := bindVRFv2Consumer(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &VRFv2ConsumerTransactor{contract: contract}, nil -} - -// NewVRFv2ConsumerFilterer creates a new log filterer instance of VRFv2Consumer, bound to a specific deployed contract. -func NewVRFv2ConsumerFilterer(address common.Address, filterer bind.ContractFilterer) (*VRFv2ConsumerFilterer, error) { - contract, err := bindVRFv2Consumer(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &VRFv2ConsumerFilterer{contract: contract}, nil -} - -// bindVRFv2Consumer binds a generic wrapper to an already deployed contract. -func bindVRFv2Consumer(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(VRFv2ConsumerABI)) - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_VRFv2Consumer *VRFv2ConsumerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _VRFv2Consumer.Contract.VRFv2ConsumerCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_VRFv2Consumer *VRFv2ConsumerRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _VRFv2Consumer.Contract.VRFv2ConsumerTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_VRFv2Consumer *VRFv2ConsumerRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _VRFv2Consumer.Contract.VRFv2ConsumerTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_VRFv2Consumer *VRFv2ConsumerCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _VRFv2Consumer.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_VRFv2Consumer *VRFv2ConsumerTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _VRFv2Consumer.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_VRFv2Consumer *VRFv2ConsumerTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _VRFv2Consumer.Contract.contract.Transact(opts, method, params...) -} - -// GetRequestStatus is a free data retrieval call binding the contract method 0xd8a4676f. -// -// Solidity: function getRequestStatus(uint256 _requestId) view returns(bool fulfilled, uint256[] randomWords) -func (_VRFv2Consumer *VRFv2ConsumerCaller) GetRequestStatus(opts *bind.CallOpts, _requestId *big.Int) (struct { - Fulfilled bool - RandomWords []*big.Int -}, error) { - var out []interface{} - err := _VRFv2Consumer.contract.Call(opts, &out, "getRequestStatus", _requestId) - - outstruct := new(struct { - Fulfilled bool - RandomWords []*big.Int - }) - if err != nil { - return *outstruct, err - } - - outstruct.Fulfilled = *abi.ConvertType(out[0], new(bool)).(*bool) - outstruct.RandomWords = *abi.ConvertType(out[1], new([]*big.Int)).(*[]*big.Int) - - return *outstruct, err - -} - -// GetRequestStatus is a free data retrieval call binding the contract method 0xd8a4676f. -// -// Solidity: function getRequestStatus(uint256 _requestId) view returns(bool fulfilled, uint256[] randomWords) -func (_VRFv2Consumer *VRFv2ConsumerSession) GetRequestStatus(_requestId *big.Int) (struct { - Fulfilled bool - RandomWords []*big.Int -}, error) { - return _VRFv2Consumer.Contract.GetRequestStatus(&_VRFv2Consumer.CallOpts, _requestId) -} - -// GetRequestStatus is a free data retrieval call binding the contract method 0xd8a4676f. -// -// Solidity: function getRequestStatus(uint256 _requestId) view returns(bool fulfilled, uint256[] randomWords) -func (_VRFv2Consumer *VRFv2ConsumerCallerSession) GetRequestStatus(_requestId *big.Int) (struct { - Fulfilled bool - RandomWords []*big.Int -}, error) { - return _VRFv2Consumer.Contract.GetRequestStatus(&_VRFv2Consumer.CallOpts, _requestId) -} - -// LastRequestId is a free data retrieval call binding the contract method 0xfc2a88c3. -// -// Solidity: function lastRequestId() view returns(uint256) -func (_VRFv2Consumer *VRFv2ConsumerCaller) LastRequestId(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _VRFv2Consumer.contract.Call(opts, &out, "lastRequestId") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// LastRequestId is a free data retrieval call binding the contract method 0xfc2a88c3. -// -// Solidity: function lastRequestId() view returns(uint256) -func (_VRFv2Consumer *VRFv2ConsumerSession) LastRequestId() (*big.Int, error) { - return _VRFv2Consumer.Contract.LastRequestId(&_VRFv2Consumer.CallOpts) -} - -// LastRequestId is a free data retrieval call binding the contract method 0xfc2a88c3. -// -// Solidity: function lastRequestId() view returns(uint256) -func (_VRFv2Consumer *VRFv2ConsumerCallerSession) LastRequestId() (*big.Int, error) { - return _VRFv2Consumer.Contract.LastRequestId(&_VRFv2Consumer.CallOpts) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_VRFv2Consumer *VRFv2ConsumerCaller) Owner(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _VRFv2Consumer.contract.Call(opts, &out, "owner") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_VRFv2Consumer *VRFv2ConsumerSession) Owner() (common.Address, error) { - return _VRFv2Consumer.Contract.Owner(&_VRFv2Consumer.CallOpts) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_VRFv2Consumer *VRFv2ConsumerCallerSession) Owner() (common.Address, error) { - return _VRFv2Consumer.Contract.Owner(&_VRFv2Consumer.CallOpts) -} - -// RequestIds is a free data retrieval call binding the contract method 0x8796ba8c. -// -// Solidity: function requestIds(uint256 ) view returns(uint256) -func (_VRFv2Consumer *VRFv2ConsumerCaller) RequestIds(opts *bind.CallOpts, arg0 *big.Int) (*big.Int, error) { - var out []interface{} - err := _VRFv2Consumer.contract.Call(opts, &out, "requestIds", arg0) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// RequestIds is a free data retrieval call binding the contract method 0x8796ba8c. -// -// Solidity: function requestIds(uint256 ) view returns(uint256) -func (_VRFv2Consumer *VRFv2ConsumerSession) RequestIds(arg0 *big.Int) (*big.Int, error) { - return _VRFv2Consumer.Contract.RequestIds(&_VRFv2Consumer.CallOpts, arg0) -} - -// RequestIds is a free data retrieval call binding the contract method 0x8796ba8c. -// -// Solidity: function requestIds(uint256 ) view returns(uint256) -func (_VRFv2Consumer *VRFv2ConsumerCallerSession) RequestIds(arg0 *big.Int) (*big.Int, error) { - return _VRFv2Consumer.Contract.RequestIds(&_VRFv2Consumer.CallOpts, arg0) -} - -// SRequests is a free data retrieval call binding the contract method 0xa168fa89. -// -// Solidity: function s_requests(uint256 ) view returns(bool fulfilled, bool exists) -func (_VRFv2Consumer *VRFv2ConsumerCaller) SRequests(opts *bind.CallOpts, arg0 *big.Int) (struct { - Fulfilled bool - Exists bool -}, error) { - var out []interface{} - err := _VRFv2Consumer.contract.Call(opts, &out, "s_requests", arg0) - - outstruct := new(struct { - Fulfilled bool - Exists bool - }) - if err != nil { - return *outstruct, err - } - - outstruct.Fulfilled = *abi.ConvertType(out[0], new(bool)).(*bool) - outstruct.Exists = *abi.ConvertType(out[1], new(bool)).(*bool) - - return *outstruct, err - -} - -// SRequests is a free data retrieval call binding the contract method 0xa168fa89. -// -// Solidity: function s_requests(uint256 ) view returns(bool fulfilled, bool exists) -func (_VRFv2Consumer *VRFv2ConsumerSession) SRequests(arg0 *big.Int) (struct { - Fulfilled bool - Exists bool -}, error) { - return _VRFv2Consumer.Contract.SRequests(&_VRFv2Consumer.CallOpts, arg0) -} - -// SRequests is a free data retrieval call binding the contract method 0xa168fa89. -// -// Solidity: function s_requests(uint256 ) view returns(bool fulfilled, bool exists) -func (_VRFv2Consumer *VRFv2ConsumerCallerSession) SRequests(arg0 *big.Int) (struct { - Fulfilled bool - Exists bool -}, error) { - return _VRFv2Consumer.Contract.SRequests(&_VRFv2Consumer.CallOpts, arg0) -} - -// AcceptOwnership is a paid mutator transaction binding the contract method 0x79ba5097. -// -// Solidity: function acceptOwnership() returns() -func (_VRFv2Consumer *VRFv2ConsumerTransactor) AcceptOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { - return _VRFv2Consumer.contract.Transact(opts, "acceptOwnership") -} - -// AcceptOwnership is a paid mutator transaction binding the contract method 0x79ba5097. -// -// Solidity: function acceptOwnership() returns() -func (_VRFv2Consumer *VRFv2ConsumerSession) AcceptOwnership() (*types.Transaction, error) { - return _VRFv2Consumer.Contract.AcceptOwnership(&_VRFv2Consumer.TransactOpts) -} - -// AcceptOwnership is a paid mutator transaction binding the contract method 0x79ba5097. -// -// Solidity: function acceptOwnership() returns() -func (_VRFv2Consumer *VRFv2ConsumerTransactorSession) AcceptOwnership() (*types.Transaction, error) { - return _VRFv2Consumer.Contract.AcceptOwnership(&_VRFv2Consumer.TransactOpts) -} - -// RawFulfillRandomWords is a paid mutator transaction binding the contract method 0x1fe543e3. -// -// Solidity: function rawFulfillRandomWords(uint256 requestId, uint256[] randomWords) returns() -func (_VRFv2Consumer *VRFv2ConsumerTransactor) RawFulfillRandomWords(opts *bind.TransactOpts, requestId *big.Int, randomWords []*big.Int) (*types.Transaction, error) { - return _VRFv2Consumer.contract.Transact(opts, "rawFulfillRandomWords", requestId, randomWords) -} - -// RawFulfillRandomWords is a paid mutator transaction binding the contract method 0x1fe543e3. -// -// Solidity: function rawFulfillRandomWords(uint256 requestId, uint256[] randomWords) returns() -func (_VRFv2Consumer *VRFv2ConsumerSession) RawFulfillRandomWords(requestId *big.Int, randomWords []*big.Int) (*types.Transaction, error) { - return _VRFv2Consumer.Contract.RawFulfillRandomWords(&_VRFv2Consumer.TransactOpts, requestId, randomWords) -} - -// RawFulfillRandomWords is a paid mutator transaction binding the contract method 0x1fe543e3. -// -// Solidity: function rawFulfillRandomWords(uint256 requestId, uint256[] randomWords) returns() -func (_VRFv2Consumer *VRFv2ConsumerTransactorSession) RawFulfillRandomWords(requestId *big.Int, randomWords []*big.Int) (*types.Transaction, error) { - return _VRFv2Consumer.Contract.RawFulfillRandomWords(&_VRFv2Consumer.TransactOpts, requestId, randomWords) -} - -// RequestRandomWords is a paid mutator transaction binding the contract method 0x9561f023. -// -// Solidity: function requestRandomWords(uint64 subId, uint32 callbackGasLimit, uint16 requestConfirmations, uint32 numWords, bytes32 keyHash) returns(uint256 requestId) -func (_VRFv2Consumer *VRFv2ConsumerTransactor) RequestRandomWords(opts *bind.TransactOpts, subId uint64, callbackGasLimit uint32, requestConfirmations uint16, numWords uint32, keyHash [32]byte) (*types.Transaction, error) { - return _VRFv2Consumer.contract.Transact(opts, "requestRandomWords", subId, callbackGasLimit, requestConfirmations, numWords, keyHash) -} - -// RequestRandomWords is a paid mutator transaction binding the contract method 0x9561f023. -// -// Solidity: function requestRandomWords(uint64 subId, uint32 callbackGasLimit, uint16 requestConfirmations, uint32 numWords, bytes32 keyHash) returns(uint256 requestId) -func (_VRFv2Consumer *VRFv2ConsumerSession) RequestRandomWords(subId uint64, callbackGasLimit uint32, requestConfirmations uint16, numWords uint32, keyHash [32]byte) (*types.Transaction, error) { - return _VRFv2Consumer.Contract.RequestRandomWords(&_VRFv2Consumer.TransactOpts, subId, callbackGasLimit, requestConfirmations, numWords, keyHash) -} - -// RequestRandomWords is a paid mutator transaction binding the contract method 0x9561f023. -// -// Solidity: function requestRandomWords(uint64 subId, uint32 callbackGasLimit, uint16 requestConfirmations, uint32 numWords, bytes32 keyHash) returns(uint256 requestId) -func (_VRFv2Consumer *VRFv2ConsumerTransactorSession) RequestRandomWords(subId uint64, callbackGasLimit uint32, requestConfirmations uint16, numWords uint32, keyHash [32]byte) (*types.Transaction, error) { - return _VRFv2Consumer.Contract.RequestRandomWords(&_VRFv2Consumer.TransactOpts, subId, callbackGasLimit, requestConfirmations, numWords, keyHash) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address to) returns() -func (_VRFv2Consumer *VRFv2ConsumerTransactor) TransferOwnership(opts *bind.TransactOpts, to common.Address) (*types.Transaction, error) { - return _VRFv2Consumer.contract.Transact(opts, "transferOwnership", to) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address to) returns() -func (_VRFv2Consumer *VRFv2ConsumerSession) TransferOwnership(to common.Address) (*types.Transaction, error) { - return _VRFv2Consumer.Contract.TransferOwnership(&_VRFv2Consumer.TransactOpts, to) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address to) returns() -func (_VRFv2Consumer *VRFv2ConsumerTransactorSession) TransferOwnership(to common.Address) (*types.Transaction, error) { - return _VRFv2Consumer.Contract.TransferOwnership(&_VRFv2Consumer.TransactOpts, to) -} - -// VRFv2ConsumerOwnershipTransferRequestedIterator is returned from FilterOwnershipTransferRequested and is used to iterate over the raw logs and unpacked data for OwnershipTransferRequested events raised by the VRFv2Consumer contract. -type VRFv2ConsumerOwnershipTransferRequestedIterator struct { - Event *VRFv2ConsumerOwnershipTransferRequested // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *VRFv2ConsumerOwnershipTransferRequestedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(VRFv2ConsumerOwnershipTransferRequested) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(VRFv2ConsumerOwnershipTransferRequested) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *VRFv2ConsumerOwnershipTransferRequestedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *VRFv2ConsumerOwnershipTransferRequestedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// VRFv2ConsumerOwnershipTransferRequested represents a OwnershipTransferRequested event raised by the VRFv2Consumer contract. -type VRFv2ConsumerOwnershipTransferRequested struct { - From common.Address - To common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterOwnershipTransferRequested is a free log retrieval operation binding the contract event 0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278. -// -// Solidity: event OwnershipTransferRequested(address indexed from, address indexed to) -func (_VRFv2Consumer *VRFv2ConsumerFilterer) FilterOwnershipTransferRequested(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*VRFv2ConsumerOwnershipTransferRequestedIterator, error) { - - var fromRule []interface{} - for _, fromItem := range from { - fromRule = append(fromRule, fromItem) - } - var toRule []interface{} - for _, toItem := range to { - toRule = append(toRule, toItem) - } - - logs, sub, err := _VRFv2Consumer.contract.FilterLogs(opts, "OwnershipTransferRequested", fromRule, toRule) - if err != nil { - return nil, err - } - return &VRFv2ConsumerOwnershipTransferRequestedIterator{contract: _VRFv2Consumer.contract, event: "OwnershipTransferRequested", logs: logs, sub: sub}, nil -} - -// WatchOwnershipTransferRequested is a free log subscription operation binding the contract event 0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278. -// -// Solidity: event OwnershipTransferRequested(address indexed from, address indexed to) -func (_VRFv2Consumer *VRFv2ConsumerFilterer) WatchOwnershipTransferRequested(opts *bind.WatchOpts, sink chan<- *VRFv2ConsumerOwnershipTransferRequested, from []common.Address, to []common.Address) (event.Subscription, error) { - - var fromRule []interface{} - for _, fromItem := range from { - fromRule = append(fromRule, fromItem) - } - var toRule []interface{} - for _, toItem := range to { - toRule = append(toRule, toItem) - } - - logs, sub, err := _VRFv2Consumer.contract.WatchLogs(opts, "OwnershipTransferRequested", fromRule, toRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(VRFv2ConsumerOwnershipTransferRequested) - if err := _VRFv2Consumer.contract.UnpackLog(event, "OwnershipTransferRequested", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseOwnershipTransferRequested is a log parse operation binding the contract event 0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278. -// -// Solidity: event OwnershipTransferRequested(address indexed from, address indexed to) -func (_VRFv2Consumer *VRFv2ConsumerFilterer) ParseOwnershipTransferRequested(log types.Log) (*VRFv2ConsumerOwnershipTransferRequested, error) { - event := new(VRFv2ConsumerOwnershipTransferRequested) - if err := _VRFv2Consumer.contract.UnpackLog(event, "OwnershipTransferRequested", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// VRFv2ConsumerOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the VRFv2Consumer contract. -type VRFv2ConsumerOwnershipTransferredIterator struct { - Event *VRFv2ConsumerOwnershipTransferred // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *VRFv2ConsumerOwnershipTransferredIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(VRFv2ConsumerOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(VRFv2ConsumerOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *VRFv2ConsumerOwnershipTransferredIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *VRFv2ConsumerOwnershipTransferredIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// VRFv2ConsumerOwnershipTransferred represents a OwnershipTransferred event raised by the VRFv2Consumer contract. -type VRFv2ConsumerOwnershipTransferred struct { - From common.Address - To common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed from, address indexed to) -func (_VRFv2Consumer *VRFv2ConsumerFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*VRFv2ConsumerOwnershipTransferredIterator, error) { - - var fromRule []interface{} - for _, fromItem := range from { - fromRule = append(fromRule, fromItem) - } - var toRule []interface{} - for _, toItem := range to { - toRule = append(toRule, toItem) - } - - logs, sub, err := _VRFv2Consumer.contract.FilterLogs(opts, "OwnershipTransferred", fromRule, toRule) - if err != nil { - return nil, err - } - return &VRFv2ConsumerOwnershipTransferredIterator{contract: _VRFv2Consumer.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil -} - -// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed from, address indexed to) -func (_VRFv2Consumer *VRFv2ConsumerFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *VRFv2ConsumerOwnershipTransferred, from []common.Address, to []common.Address) (event.Subscription, error) { - - var fromRule []interface{} - for _, fromItem := range from { - fromRule = append(fromRule, fromItem) - } - var toRule []interface{} - for _, toItem := range to { - toRule = append(toRule, toItem) - } - - logs, sub, err := _VRFv2Consumer.contract.WatchLogs(opts, "OwnershipTransferred", fromRule, toRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(VRFv2ConsumerOwnershipTransferred) - if err := _VRFv2Consumer.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed from, address indexed to) -func (_VRFv2Consumer *VRFv2ConsumerFilterer) ParseOwnershipTransferred(log types.Log) (*VRFv2ConsumerOwnershipTransferred, error) { - event := new(VRFv2ConsumerOwnershipTransferred) - if err := _VRFv2Consumer.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// VRFv2ConsumerRequestFulfilledIterator is returned from FilterRequestFulfilled and is used to iterate over the raw logs and unpacked data for RequestFulfilled events raised by the VRFv2Consumer contract. -type VRFv2ConsumerRequestFulfilledIterator struct { - Event *VRFv2ConsumerRequestFulfilled // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *VRFv2ConsumerRequestFulfilledIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(VRFv2ConsumerRequestFulfilled) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(VRFv2ConsumerRequestFulfilled) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *VRFv2ConsumerRequestFulfilledIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *VRFv2ConsumerRequestFulfilledIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// VRFv2ConsumerRequestFulfilled represents a RequestFulfilled event raised by the VRFv2Consumer contract. -type VRFv2ConsumerRequestFulfilled struct { - RequestId *big.Int - RandomWords []*big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterRequestFulfilled is a free log retrieval operation binding the contract event 0xfe2e2d779dba245964d4e3ef9b994be63856fd568bf7d3ca9e224755cb1bd54d. -// -// Solidity: event RequestFulfilled(uint256 requestId, uint256[] randomWords) -func (_VRFv2Consumer *VRFv2ConsumerFilterer) FilterRequestFulfilled(opts *bind.FilterOpts) (*VRFv2ConsumerRequestFulfilledIterator, error) { - - logs, sub, err := _VRFv2Consumer.contract.FilterLogs(opts, "RequestFulfilled") - if err != nil { - return nil, err - } - return &VRFv2ConsumerRequestFulfilledIterator{contract: _VRFv2Consumer.contract, event: "RequestFulfilled", logs: logs, sub: sub}, nil -} - -// WatchRequestFulfilled is a free log subscription operation binding the contract event 0xfe2e2d779dba245964d4e3ef9b994be63856fd568bf7d3ca9e224755cb1bd54d. -// -// Solidity: event RequestFulfilled(uint256 requestId, uint256[] randomWords) -func (_VRFv2Consumer *VRFv2ConsumerFilterer) WatchRequestFulfilled(opts *bind.WatchOpts, sink chan<- *VRFv2ConsumerRequestFulfilled) (event.Subscription, error) { - - logs, sub, err := _VRFv2Consumer.contract.WatchLogs(opts, "RequestFulfilled") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(VRFv2ConsumerRequestFulfilled) - if err := _VRFv2Consumer.contract.UnpackLog(event, "RequestFulfilled", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseRequestFulfilled is a log parse operation binding the contract event 0xfe2e2d779dba245964d4e3ef9b994be63856fd568bf7d3ca9e224755cb1bd54d. -// -// Solidity: event RequestFulfilled(uint256 requestId, uint256[] randomWords) -func (_VRFv2Consumer *VRFv2ConsumerFilterer) ParseRequestFulfilled(log types.Log) (*VRFv2ConsumerRequestFulfilled, error) { - event := new(VRFv2ConsumerRequestFulfilled) - if err := _VRFv2Consumer.contract.UnpackLog(event, "RequestFulfilled", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// VRFv2ConsumerRequestSentIterator is returned from FilterRequestSent and is used to iterate over the raw logs and unpacked data for RequestSent events raised by the VRFv2Consumer contract. -type VRFv2ConsumerRequestSentIterator struct { - Event *VRFv2ConsumerRequestSent // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *VRFv2ConsumerRequestSentIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(VRFv2ConsumerRequestSent) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(VRFv2ConsumerRequestSent) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *VRFv2ConsumerRequestSentIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *VRFv2ConsumerRequestSentIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// VRFv2ConsumerRequestSent represents a RequestSent event raised by the VRFv2Consumer contract. -type VRFv2ConsumerRequestSent struct { - RequestId *big.Int - NumWords uint32 - Raw types.Log // Blockchain specific contextual infos -} - -// FilterRequestSent is a free log retrieval operation binding the contract event 0xcc58b13ad3eab50626c6a6300b1d139cd6ebb1688a7cced9461c2f7e762665ee. -// -// Solidity: event RequestSent(uint256 requestId, uint32 numWords) -func (_VRFv2Consumer *VRFv2ConsumerFilterer) FilterRequestSent(opts *bind.FilterOpts) (*VRFv2ConsumerRequestSentIterator, error) { - - logs, sub, err := _VRFv2Consumer.contract.FilterLogs(opts, "RequestSent") - if err != nil { - return nil, err - } - return &VRFv2ConsumerRequestSentIterator{contract: _VRFv2Consumer.contract, event: "RequestSent", logs: logs, sub: sub}, nil -} - -// WatchRequestSent is a free log subscription operation binding the contract event 0xcc58b13ad3eab50626c6a6300b1d139cd6ebb1688a7cced9461c2f7e762665ee. -// -// Solidity: event RequestSent(uint256 requestId, uint32 numWords) -func (_VRFv2Consumer *VRFv2ConsumerFilterer) WatchRequestSent(opts *bind.WatchOpts, sink chan<- *VRFv2ConsumerRequestSent) (event.Subscription, error) { - - logs, sub, err := _VRFv2Consumer.contract.WatchLogs(opts, "RequestSent") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(VRFv2ConsumerRequestSent) - if err := _VRFv2Consumer.contract.UnpackLog(event, "RequestSent", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseRequestSent is a log parse operation binding the contract event 0xcc58b13ad3eab50626c6a6300b1d139cd6ebb1688a7cced9461c2f7e762665ee. -// -// Solidity: event RequestSent(uint256 requestId, uint32 numWords) -func (_VRFv2Consumer *VRFv2ConsumerFilterer) ParseRequestSent(log types.Log) (*VRFv2ConsumerRequestSent, error) { - event := new(VRFv2ConsumerRequestSent) - if err := _VRFv2Consumer.contract.UnpackLog(event, "RequestSent", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/integration-tests/contracts/ethereum/src/KeeperBase.sol b/integration-tests/contracts/ethereum/src/KeeperBase.sol deleted file mode 120000 index dfff3da022f..00000000000 --- a/integration-tests/contracts/ethereum/src/KeeperBase.sol +++ /dev/null @@ -1 +0,0 @@ -../../../../contracts/src/v0.7/KeeperBase.sol \ No newline at end of file diff --git a/integration-tests/contracts/ethereum/src/KeeperCompatibleInterface.sol b/integration-tests/contracts/ethereum/src/KeeperCompatibleInterface.sol deleted file mode 120000 index 8e6eb6cf21e..00000000000 --- a/integration-tests/contracts/ethereum/src/KeeperCompatibleInterface.sol +++ /dev/null @@ -1 +0,0 @@ -../../../../contracts/src/v0.7/interfaces/KeeperCompatibleInterface.sol \ No newline at end of file diff --git a/integration-tests/contracts/ethereum/src/KeeperConsumer.sol b/integration-tests/contracts/ethereum/src/KeeperConsumer.sol deleted file mode 100644 index 1c2d772e632..00000000000 --- a/integration-tests/contracts/ethereum/src/KeeperConsumer.sol +++ /dev/null @@ -1,31 +0,0 @@ -pragma solidity ^0.7.0; - -import "./KeeperCompatibleInterface.sol"; -import "./KeeperBase.sol"; - -contract KeeperConsumer is KeeperCompatibleInterface, KeeperBase { - uint public counter; - uint public immutable interval; - uint public lastTimeStamp; - - - constructor(uint updateInterval) public { - interval = updateInterval; - lastTimeStamp = block.timestamp; - counter = 0; - } - - function checkUpkeep(bytes calldata checkData) - external - override - view - cannotExecute - returns (bool upkeepNeeded, bytes memory performData) { - return (true, checkData); - } - - function performUpkeep(bytes calldata performData) external override { - counter = counter + 1; - } -} - diff --git a/integration-tests/contracts/ethereum/src/PerformDataChecker.sol b/integration-tests/contracts/ethereum/src/PerformDataChecker.sol deleted file mode 100644 index df63415d76b..00000000000 --- a/integration-tests/contracts/ethereum/src/PerformDataChecker.sol +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.6; - -import "./KeeperCompatibleInterface.sol"; - -contract PerformDataChecker is KeeperCompatibleInterface { - uint256 public counter; - bytes public s_expectedData; - - constructor(bytes memory expectedData) { - s_expectedData = expectedData; - } - - function setExpectedData(bytes calldata expectedData) external { - s_expectedData = expectedData; - } - - function checkUpkeep(bytes calldata checkData) - external - view - override - returns (bool upkeepNeeded, bytes memory performData) - { - return (keccak256(checkData) == keccak256(s_expectedData), checkData); - } - - function performUpkeep(bytes calldata performData) external override { - if (keccak256(performData) == keccak256(s_expectedData)) { - counter++; - } - } -} diff --git a/integration-tests/contracts/ethereum/src/UpkeepCounter.sol b/integration-tests/contracts/ethereum/src/UpkeepCounter.sol deleted file mode 100644 index 3c42b58255f..00000000000 --- a/integration-tests/contracts/ethereum/src/UpkeepCounter.sol +++ /dev/null @@ -1,57 +0,0 @@ -pragma solidity ^0.7.6; - -contract UpkeepCounter { - event PerformingUpkeep( - address indexed from, - uint256 initialBlock, - uint256 lastBlock, - uint256 previousBlock, - uint256 counter - ); - - uint256 public testRange; - uint256 public interval; - uint256 public lastBlock; - uint256 public previousPerformBlock; - uint256 public initialBlock; - uint256 public counter; - - constructor(uint256 _testRange, uint256 _interval) { - testRange = _testRange; - interval = _interval; - previousPerformBlock = 0; - lastBlock = block.number; - initialBlock = 0; - counter = 0; - } - - function checkUpkeep(bytes calldata data) external view returns (bool, bytes memory) { - return (eligible(), data); - } - - function performUpkeep(bytes calldata performData) external { - if (initialBlock == 0) { - initialBlock = block.number; - } - lastBlock = block.number; - counter = counter + 1; - performData; - emit PerformingUpkeep(tx.origin, initialBlock, lastBlock, previousPerformBlock, counter); - previousPerformBlock = lastBlock; - } - - function eligible() public view returns (bool) { - if (initialBlock == 0) { - return true; - } - - return (block.number - initialBlock) < testRange && (block.number - lastBlock) >= interval; - } - - function setSpread(uint256 _testRange, uint256 _interval) external { - testRange = _testRange; - interval = _interval; - initialBlock = 0; - counter = 0; - } -} diff --git a/integration-tests/contracts/ethereum/src/VRFv2Consumer.sol b/integration-tests/contracts/ethereum/src/VRFv2Consumer.sol deleted file mode 100644 index 333318f4990..00000000000 --- a/integration-tests/contracts/ethereum/src/VRFv2Consumer.sol +++ /dev/null @@ -1,91 +0,0 @@ -// SPDX-License-Identifier: MIT -// An example of a consumer contract that relies on a subscription for funding. -pragma solidity ^0.8.7; - -import "../../../../../contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol"; -import "../../../../../contracts/src/v0.8/VRFConsumerBaseV2.sol"; -import "../../../../contracts/src/v0.8/shared/access/ConfirmedOwner.sol"; - -/** - * THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED VALUES FOR CLARITY. - * THIS IS AN EXAMPLE CONTRACT THAT USES UN-AUDITED CODE. - * DO NOT USE THIS CODE IN PRODUCTION. - */ - -contract VRFv2Consumer is VRFConsumerBaseV2, ConfirmedOwner { - event RequestSent(uint256 requestId, uint32 numWords); - event RequestFulfilled(uint256 requestId, uint256[] randomWords); - - struct RequestStatus { - bool fulfilled; // whether the request has been successfully fulfilled - bool exists; // whether a requestId exists - uint256[] randomWords; - } - mapping(uint256 => RequestStatus) - public s_requests; /* requestId --> requestStatus */ - VRFCoordinatorV2Interface COORDINATOR; - - // past requests Id. - uint256[] public requestIds; - uint256 public lastRequestId; - - constructor( - address vrfCoordinator - ) - VRFConsumerBaseV2(vrfCoordinator) - ConfirmedOwner(msg.sender) - { - COORDINATOR = VRFCoordinatorV2Interface( - vrfCoordinator - ); - } - - // Assumes the subscription is funded sufficiently. - function requestRandomWords( - uint64 subId, - uint32 callbackGasLimit, - uint16 requestConfirmations, - uint32 numWords, - bytes32 keyHash - ) - external - onlyOwner - returns (uint256 requestId) - { - // Will revert if subscription is not set and funded. - requestId = COORDINATOR.requestRandomWords( - keyHash, - subId, - requestConfirmations, - callbackGasLimit, - numWords - ); - s_requests[requestId] = RequestStatus({ - randomWords: new uint256[](0), - exists: true, - fulfilled: false - }); - requestIds.push(requestId); - lastRequestId = requestId; - emit RequestSent(requestId, numWords); - return requestId; - } - - function fulfillRandomWords( - uint256 _requestId, - uint256[] memory _randomWords - ) internal override { - require(s_requests[_requestId].exists, "request not found"); - s_requests[_requestId].fulfilled = true; - s_requests[_requestId].randomWords = _randomWords; - emit RequestFulfilled(_requestId, _randomWords); - } - - function getRequestStatus( - uint256 _requestId - ) external view returns (bool fulfilled, uint256[] memory randomWords) { - require(s_requests[_requestId].exists, "request not found"); - RequestStatus memory request = s_requests[_requestId]; - return (request.fulfilled, request.randomWords); - } -} diff --git a/integration-tests/contracts/ethereum_keeper_contracts.go b/integration-tests/contracts/ethereum_keeper_contracts.go index 5be147f2558..135b016ee55 100644 --- a/integration-tests/contracts/ethereum_keeper_contracts.go +++ b/integration-tests/contracts/ethereum_keeper_contracts.go @@ -19,6 +19,7 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/blockchain" + "github.com/smartcontractkit/chainlink/integration-tests/testreporters" cltypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_consumer_benchmark" registrar21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_registrar_wrapper2_1" @@ -33,12 +34,16 @@ import ( registry21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper_2_1" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/log_triggered_streams_lookup_wrapper" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/log_upkeep_counter_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/perform_data_checker_wrapper" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/streams_lookup_upkeep_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/upkeep_perform_counter_restrictive_wrapper" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/upkeep_transcoder" "github.com/smartcontractkit/chainlink/v2/core/utils" "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" - "github.com/smartcontractkit/chainlink/integration-tests/testreporters" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_consumer_performance_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_consumer_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/upkeep_counter_wrapper" ) var utilsABI = cltypes.MustGetABI(automation_utils_2_1.AutomationUtilsABI) @@ -1593,7 +1598,7 @@ func (o *KeeperConsumerBenchmarkRoundConfirmer) logDetails() { // EthereumUpkeepCounter represents keeper consumer (upkeep) counter contract type EthereumUpkeepCounter struct { client blockchain.EVMClient - consumer *ethereum.UpkeepCounter + consumer *upkeep_counter_wrapper.UpkeepCounter address *common.Address } @@ -1635,7 +1640,7 @@ func (v *EthereumUpkeepCounter) SetSpread(testRange *big.Int, interval *big.Int) // EthereumUpkeepPerformCounterRestrictive represents keeper consumer (upkeep) counter contract type EthereumUpkeepPerformCounterRestrictive struct { client blockchain.EVMClient - consumer *ethereum.UpkeepPerformCounterRestrictive + consumer *upkeep_perform_counter_restrictive_wrapper.UpkeepPerformCounterRestrictive address *common.Address } @@ -1674,7 +1679,7 @@ func (v *EthereumUpkeepPerformCounterRestrictive) SetSpread(testRange *big.Int, // EthereumKeeperConsumer represents keeper consumer (upkeep) contract type EthereumKeeperConsumer struct { client blockchain.EVMClient - consumer *ethereum.KeeperConsumer + consumer *keeper_consumer_wrapper.KeeperConsumer address *common.Address } @@ -1811,7 +1816,7 @@ func (v *EthereumAutomationLogCounterConsumer) Counter(ctx context.Context) (*bi // performance tests. type EthereumKeeperConsumerPerformance struct { client blockchain.EVMClient - consumer *ethereum.KeeperConsumerPerformance + consumer *keeper_consumer_performance_wrapper.KeeperConsumerPerformance address *common.Address } @@ -1872,7 +1877,7 @@ func (v *EthereumKeeperConsumerPerformance) SetPerformGasToBurn(ctx context.Cont // EthereumKeeperPerformDataCheckerConsumer represents keeper perform data checker contract type EthereumKeeperPerformDataCheckerConsumer struct { client blockchain.EVMClient - performDataChecker *ethereum.PerformDataChecker + performDataChecker *perform_data_checker_wrapper.PerformDataChecker address *common.Address } diff --git a/integration-tests/contracts/ethereum_vrfv2_contracts.go b/integration-tests/contracts/ethereum_vrfv2_contracts.go index 1bcd460c399..9c7e628dbd9 100644 --- a/integration-tests/contracts/ethereum_vrfv2_contracts.go +++ b/integration-tests/contracts/ethereum_vrfv2_contracts.go @@ -12,11 +12,12 @@ import ( "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_consumer_v2" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_load_test_with_metrics" - eth_contracts "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2_consumer_wrapper" ) // EthereumVRFCoordinatorV2 represents VRFV2 coordinator contract @@ -37,7 +38,7 @@ type EthereumVRFConsumerV2 struct { type EthereumVRFv2Consumer struct { address *common.Address client blockchain.EVMClient - consumer *eth_contracts.VRFv2Consumer + consumer *vrf_v2_consumer_wrapper.VRFv2Consumer } // EthereumVRFv2LoadTestConsumer represents VRFv2 consumer contract for performing Load Tests @@ -88,14 +89,14 @@ func (e *EthereumContractDeployer) DeployVRFv2Consumer(coordinatorAddr string) ( auth *bind.TransactOpts, backend bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return eth_contracts.DeployVRFv2Consumer(auth, backend, common.HexToAddress(coordinatorAddr)) + return vrf_v2_consumer_wrapper.DeployVRFv2Consumer(auth, backend, common.HexToAddress(coordinatorAddr)) }) if err != nil { return nil, err } return &EthereumVRFv2Consumer{ client: e.client, - consumer: instance.(*eth_contracts.VRFv2Consumer), + consumer: instance.(*vrf_v2_consumer_wrapper.VRFv2Consumer), address: address, }, err } @@ -363,7 +364,7 @@ func (v *EthereumVRFv2LoadTestConsumer) RequestRandomness(keyHash [32]byte, subI return v.client.ProcessTransaction(tx) } -func (v *EthereumVRFv2Consumer) GetRequestStatus(ctx context.Context, requestID *big.Int) (RequestStatus, error) { +func (v *EthereumVRFv2Consumer) GetRequestStatus(ctx context.Context, requestID *big.Int) (vrf_v2_consumer_wrapper.GetRequestStatus, error) { return v.consumer.GetRequestStatus(&bind.CallOpts{ From: common.HexToAddress(v.client.GetDefaultWallet().Address()), Context: ctx, diff --git a/integration-tests/docker/test_env/cl_node.go b/integration-tests/docker/test_env/cl_node.go index bf4d3285dcf..4c40e641210 100644 --- a/integration-tests/docker/test_env/cl_node.go +++ b/integration-tests/docker/test_env/cl_node.go @@ -49,6 +49,8 @@ type ClNode struct { NodeConfig *chainlink.Config `json:"-"` NodeSecretsConfigTOML string `json:"-"` PostgresDb *test_env.PostgresDb `json:"postgresDb"` + UserEmail string `json:"userEmail"` + UserPassword string `json:"userPassword"` t *testing.T l zerolog.Logger lw *logwatch.LogWatch @@ -86,18 +88,22 @@ func WithLogWatch(lw *logwatch.LogWatch) ClNodeOption { } } -func NewClNode(networks []string, nodeConfig *chainlink.Config, opts ...ClNodeOption) *ClNode { +func NewClNode(networks []string, imageName, imageVersion string, nodeConfig *chainlink.Config, opts ...ClNodeOption) *ClNode { nodeDefaultCName := fmt.Sprintf("%s-%s", "cl-node", uuid.NewString()[0:8]) pgDefaultCName := fmt.Sprintf("pg-%s", nodeDefaultCName) pgDb := test_env.NewPostgresDb(networks, test_env.WithPostgresDbContainerName(pgDefaultCName)) n := &ClNode{ EnvComponent: test_env.EnvComponent{ - ContainerName: nodeDefaultCName, - Networks: networks, + ContainerName: nodeDefaultCName, + ContainerImage: imageName, + ContainerVersion: imageVersion, + Networks: networks, }, - NodeConfig: nodeConfig, - PostgresDb: pgDb, - l: log.Logger, + UserEmail: "local@local.com", + UserPassword: "localdevpassword", + NodeConfig: nodeConfig, + PostgresDb: pgDb, + l: log.Logger, } for _, opt := range opts { opt(n) @@ -126,7 +132,7 @@ func (n *ClNode) UpgradeVersion(cfg *chainlink.Config, newImage, newVersion stri return fmt.Errorf("new version is empty") } if newImage == "" { - newImage = os.Getenv("CHAINLINK_IMAGE") + return fmt.Errorf("new image name is empty") } n.ContainerImage = newImage n.ContainerVersion = newVersion @@ -291,14 +297,19 @@ func (n *ClNode) StartContainer() error { if err != nil { return err } - n.l.Info().Str("containerName", n.ContainerName). + n.l.Info(). + Str("containerName", n.ContainerName). + Str("containerImage", n.ContainerImage). + Str("containerVersion", n.ContainerVersion). Str("clEndpoint", clEndpoint). Str("clInternalIP", ip). + Str("userEmail", n.UserEmail). + Str("userPassword", n.UserPassword). Msg("Started Chainlink Node container") clClient, err := client.NewChainlinkClient(&client.ChainlinkConfig{ URL: clEndpoint, - Email: "local@local.com", - Password: "localdevpassword", + Email: n.UserEmail, + Password: n.UserPassword, InternalIP: ip, }, n.l) @@ -360,21 +371,6 @@ func (n *ClNode) getContainerRequest(secrets string) ( adminCredsPath := "/home/admin-credentials.txt" apiCredsPath := "/home/api-credentials.txt" - if n.ContainerImage == "" { - image, ok := os.LookupEnv("CHAINLINK_IMAGE") - if !ok { - return nil, errors.New("CHAINLINK_IMAGE env must be set") - } - n.ContainerImage = image - } - if n.ContainerVersion == "" { - version, ok := os.LookupEnv("CHAINLINK_VERSION") - if !ok { - return nil, errors.New("CHAINLINK_VERSION env must be set") - } - n.ContainerVersion = version - } - return &tc.ContainerRequest{ Name: n.ContainerName, Image: fmt.Sprintf("%s:%s", n.ContainerImage, n.ContainerVersion), diff --git a/integration-tests/docker/test_env/test_env.go b/integration-tests/docker/test_env/test_env.go index 9eb9ed9f39b..07b193f102f 100644 --- a/integration-tests/docker/test_env/test_env.go +++ b/integration-tests/docker/test_env/test_env.go @@ -142,7 +142,7 @@ func (te *CLClusterTestEnv) StartClCluster(nodeConfig *chainlink.Config, count i } else { te.ClCluster = &ClCluster{} for i := 0; i < count; i++ { - ocrNode := NewClNode([]string{te.Network.Name}, nodeConfig, + ocrNode := NewClNode([]string{te.Network.Name}, os.Getenv("CHAINLINK_IMAGE"), os.Getenv("CHAINLINK_VERSION"), nodeConfig, WithSecrets(secretsConfig), ) te.ClCluster.Nodes = append(te.ClCluster.Nodes, ocrNode) diff --git a/integration-tests/load/vrfv2plus/config.go b/integration-tests/load/vrfv2plus/config.go index 5f3babfeab0..329e4abf135 100644 --- a/integration-tests/load/vrfv2plus/config.go +++ b/integration-tests/load/vrfv2plus/config.go @@ -12,6 +12,10 @@ import ( const ( DefaultConfigFilename = "config.toml" + SoakTestType = "Soak" + LoadTestType = "Load" + StressTestType = "Stress" + SpikeTestType = "Spike" ErrReadPerfConfig = "failed to read TOML config for performance tests" ErrUnmarshalPerfConfig = "failed to unmarshal TOML config for performance tests" @@ -38,7 +42,6 @@ type ExistingEnvConfig struct { type NewEnvConfig struct { Funding - NumberOfSubToCreate int `toml:"number_of_sub_to_create"` } type Common struct { @@ -68,6 +71,8 @@ type Spike struct { } type PerformanceTestConfig struct { + NumberOfSubToCreate int `toml:"number_of_sub_to_create"` + RPS int64 `toml:"rps"` //Duration *models.Duration `toml:"duration"` RateLimitUnitDuration *models.Duration `toml:"rate_limit_unit_duration"` @@ -101,24 +106,28 @@ func ReadConfig() (*PerformanceConfig, error) { return cfg, nil } -func SetPerformanceTestConfig(vrfv2PlusConfig *vrfv2plus_config.VRFV2PlusConfig, cfg *PerformanceConfig) { - switch os.Getenv("TEST_TYPE") { - case "Soak": +func SetPerformanceTestConfig(testType string, vrfv2PlusConfig *vrfv2plus_config.VRFV2PlusConfig, cfg *PerformanceConfig) { + switch testType { + case SoakTestType: + vrfv2PlusConfig.NumberOfSubToCreate = cfg.Soak.NumberOfSubToCreate vrfv2PlusConfig.RPS = cfg.Soak.RPS vrfv2PlusConfig.RateLimitUnitDuration = cfg.Soak.RateLimitUnitDuration.Duration() vrfv2PlusConfig.RandomnessRequestCountPerRequest = cfg.Soak.RandomnessRequestCountPerRequest vrfv2PlusConfig.RandomnessRequestCountPerRequestDeviation = cfg.Soak.RandomnessRequestCountPerRequestDeviation - case "Load": + case LoadTestType: + vrfv2PlusConfig.NumberOfSubToCreate = cfg.Load.NumberOfSubToCreate vrfv2PlusConfig.RPS = cfg.Load.RPS vrfv2PlusConfig.RateLimitUnitDuration = cfg.Load.RateLimitUnitDuration.Duration() vrfv2PlusConfig.RandomnessRequestCountPerRequest = cfg.Load.RandomnessRequestCountPerRequest vrfv2PlusConfig.RandomnessRequestCountPerRequestDeviation = cfg.Load.RandomnessRequestCountPerRequestDeviation - case "Stress": + case StressTestType: + vrfv2PlusConfig.NumberOfSubToCreate = cfg.Stress.NumberOfSubToCreate vrfv2PlusConfig.RPS = cfg.Stress.RPS vrfv2PlusConfig.RateLimitUnitDuration = cfg.Stress.RateLimitUnitDuration.Duration() vrfv2PlusConfig.RandomnessRequestCountPerRequest = cfg.Stress.RandomnessRequestCountPerRequest vrfv2PlusConfig.RandomnessRequestCountPerRequestDeviation = cfg.Stress.RandomnessRequestCountPerRequestDeviation - case "Spike": + case SpikeTestType: + vrfv2PlusConfig.NumberOfSubToCreate = cfg.Spike.NumberOfSubToCreate vrfv2PlusConfig.RPS = cfg.Spike.RPS vrfv2PlusConfig.RateLimitUnitDuration = cfg.Spike.RateLimitUnitDuration.Duration() vrfv2PlusConfig.RandomnessRequestCountPerRequest = cfg.Spike.RandomnessRequestCountPerRequest diff --git a/integration-tests/load/vrfv2plus/config.toml b/integration-tests/load/vrfv2plus/config.toml index 1208423dc0d..31a0bf56652 100644 --- a/integration-tests/load/vrfv2plus/config.toml +++ b/integration-tests/load/vrfv2plus/config.toml @@ -6,7 +6,7 @@ minimum_confirmations = 3 sub_funds_link = 1000 sub_funds_native = 1000 node_funds = 10 -number_of_sub_to_create = 10 + [ExistingEnvConfig] coordinator_address = "0x4931Ce2e341398c8eD8A5D0F6ADb920476D6DaBb" @@ -21,6 +21,7 @@ rate_limit_unit_duration = "6s" rps = 1 randomness_request_count_per_request = 1 # amount of randomness requests to make per one TX request randomness_request_count_per_request_deviation = 0 #NOTE - deviation should be less than randomness_request_count_per_request setting +number_of_sub_to_create = 1 # approx 60 RPM - 1 tx request with 4 rand requests in each tx every 3 seconds [Load] @@ -28,13 +29,15 @@ rate_limit_unit_duration = "3s" rps = 1 randomness_request_count_per_request = 3 # amount of randomness requests to make per one TX request randomness_request_count_per_request_deviation = 2 #NOTE - deviation should be less than randomness_request_count_per_request setting +number_of_sub_to_create = 10 # approx 540 RPM - 3 tx requests per second with 4 rand requests in each tx [Stress] -rate_limit_unit_duration = "0" +rate_limit_unit_duration = "1s" rps = 3 randomness_request_count_per_request = 4 # amount of randomness requests to make per one TX request randomness_request_count_per_request_deviation = 0 #NOTE - deviation should be less than randomness_request_count_per_request setting +number_of_sub_to_create = 20 # approx 150 RPM - 1 tx request with 150 rand requests in each tx every 60 seconds [Spike] @@ -42,3 +45,4 @@ rate_limit_unit_duration = "1m" rps = 1 randomness_request_count_per_request = 150 # amount of randomness requests to make per one TX request randomness_request_count_per_request_deviation = 0 #NOTE - deviation should be less than randomness_request_count_per_request setting +number_of_sub_to_create = 1 \ No newline at end of file diff --git a/integration-tests/load/vrfv2plus/onchain_monitoring.go b/integration-tests/load/vrfv2plus/onchain_monitoring.go index 0ae27fe6be0..c56d835234e 100644 --- a/integration-tests/load/vrfv2plus/onchain_monitoring.go +++ b/integration-tests/load/vrfv2plus/onchain_monitoring.go @@ -3,7 +3,7 @@ package loadvrfv2plus import ( "context" "github.com/rs/zerolog/log" - "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus" + "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/wasp" "testing" "time" @@ -18,11 +18,12 @@ const ( ErrLokiPush = "failed to push monitoring metrics to Loki" ) -func MonitorLoadStats(lc *wasp.LokiClient, vrfv2PlusContracts *vrfv2plus.VRFV2_5Contracts, labels map[string]string) { +func MonitorLoadStats(lc *wasp.LokiClient, consumer contracts.VRFv2PlusLoadTestConsumer, labels map[string]string) { go func() { for { time.Sleep(1 * time.Second) - SendLoadTestMetricsToLoki(vrfv2PlusContracts, lc, labels) + metrics := GetLoadTestMetrics(consumer) + SendMetricsToLoki(metrics, lc, labels) } }() } @@ -38,13 +39,16 @@ func UpdateLabels(labels map[string]string, t *testing.T) map[string]string { return updatedLabels } -func SendLoadTestMetricsToLoki(vrfv2PlusContracts *vrfv2plus.VRFV2_5Contracts, lc *wasp.LokiClient, updatedLabels map[string]string) { - //todo - should work with multiple consumers and consumers having different keyhashes and wallets - metrics, err := vrfv2PlusContracts.LoadTestConsumers[0].GetLoadTestMetrics(context.Background()) - if err != nil { - log.Error().Err(err).Msg(ErrMetrics) - } +func SendMetricsToLoki(metrics *contracts.VRFLoadTestMetrics, lc *wasp.LokiClient, updatedLabels map[string]string) { if err := lc.HandleStruct(wasp.LabelsMapToModel(updatedLabels), time.Now(), metrics); err != nil { log.Error().Err(err).Msg(ErrLokiPush) } } + +func GetLoadTestMetrics(consumer contracts.VRFv2PlusLoadTestConsumer) *contracts.VRFLoadTestMetrics { + metrics, err := consumer.GetLoadTestMetrics(context.Background()) + if err != nil { + log.Error().Err(err).Msg(ErrMetrics) + } + return metrics +} diff --git a/integration-tests/load/vrfv2plus/vrfv2plus_test.go b/integration-tests/load/vrfv2plus/vrfv2plus_test.go index 5c3ea6e8c6d..a3cb4d4b7f5 100644 --- a/integration-tests/load/vrfv2plus/vrfv2plus_test.go +++ b/integration-tests/load/vrfv2plus/vrfv2plus_test.go @@ -4,7 +4,9 @@ import ( "context" "github.com/ethereum/go-ethereum/common" "github.com/kelseyhightower/envconfig" + "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink-testing-framework/logging" + "github.com/smartcontractkit/chainlink/integration-tests/testreporters" "github.com/smartcontractkit/wasp" "github.com/stretchr/testify/require" "math/big" @@ -20,21 +22,46 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" ) -func TestVRFV2PlusLoad(t *testing.T) { +var ( + env *test_env.CLClusterTestEnv + vrfv2PlusContracts *vrfv2plus.VRFV2_5Contracts + vrfv2PlusData *vrfv2plus.VRFV2PlusData + subIDs []*big.Int + + labels = map[string]string{ + "branch": "vrfv2Plus_healthcheck", + "commit": "vrfv2Plus_healthcheck", + } + + testType = os.Getenv("TEST_TYPE") +) + +func TestVRFV2PlusPerformance(t *testing.T) { cfg, err := ReadConfig() require.NoError(t, err) var vrfv2PlusConfig vrfv2plus_config.VRFV2PlusConfig err = envconfig.Process("VRFV2PLUS", &vrfv2PlusConfig) require.NoError(t, err) - SetPerformanceTestConfig(&vrfv2PlusConfig, cfg) + testReporter := &testreporters.VRFV2PlusTestReporter{} + + SetPerformanceTestConfig(testType, &vrfv2PlusConfig, cfg) l := logging.GetTestLogger(t) //todo: temporary solution with envconfig and toml config until VRF-662 is implemented vrfv2PlusConfig.MinimumConfirmations = cfg.Common.MinimumConfirmations + lokiConfig := wasp.NewEnvLokiConfig() + lc, err := wasp.NewLokiClient(lokiConfig) + if err != nil { + l.Error().Err(err).Msg(ErrLokiClient) + return + } + + updatedLabels := UpdateLabels(labels, t) + l.Info(). - Str("Test Type", os.Getenv("TEST_TYPE")). + Str("Test Type", testType). Str("Test Duration", vrfv2PlusConfig.TestDuration.Truncate(time.Second).String()). Int64("RPS", vrfv2PlusConfig.RPS). Str("RateLimitUnitDuration", vrfv2PlusConfig.RateLimitUnitDuration.String()). @@ -43,11 +70,6 @@ func TestVRFV2PlusLoad(t *testing.T) { Bool("UseExistingEnv", vrfv2PlusConfig.UseExistingEnv). Msg("Performance Test Configuration") - var env *test_env.CLClusterTestEnv - var vrfv2PlusContracts *vrfv2plus.VRFV2_5Contracts - var vrfv2PlusData *vrfv2plus.VRFV2PlusData - var subIDs []*big.Int - if vrfv2PlusConfig.UseExistingEnv { //todo: temporary solution with envconfig and toml config until VRF-662 is implemented vrfv2PlusConfig.CoordinatorAddress = cfg.ExistingEnvConfig.CoordinatorAddress @@ -57,7 +79,10 @@ func TestVRFV2PlusLoad(t *testing.T) { env, err = test_env.NewCLTestEnvBuilder(). WithTestLogger(t). - WithoutCleanup(). + WithCustomCleanup( + func() { + teardown(t, vrfv2PlusContracts.LoadTestConsumers[0], lc, updatedLabels, testReporter, testType, vrfv2PlusConfig) + }). Build() require.NoError(t, err, "error creating test env") @@ -93,13 +118,18 @@ func TestVRFV2PlusLoad(t *testing.T) { vrfv2PlusConfig.ChainlinkNodeFunding = cfg.NewEnvConfig.NodeFunds vrfv2PlusConfig.SubscriptionFundingAmountLink = cfg.NewEnvConfig.Funding.SubFundsLink vrfv2PlusConfig.SubscriptionFundingAmountNative = cfg.NewEnvConfig.Funding.SubFundsNative - numberOfSubToCreate := cfg.NewEnvConfig.NumberOfSubToCreate env, err = test_env.NewCLTestEnvBuilder(). WithTestLogger(t). WithGeth(). WithCLNodes(1). WithFunding(big.NewFloat(vrfv2PlusConfig.ChainlinkNodeFunding)). - WithStandardCleanup(). + WithCustomCleanup( + func() { + teardown(t, vrfv2PlusContracts.LoadTestConsumers[0], lc, updatedLabels, testReporter, testType, vrfv2PlusConfig) + if err := env.Cleanup(); err != nil { + l.Error().Err(err).Msg("Error cleaning up test environment") + } + }). WithLogWatcher(). Build() @@ -113,29 +143,24 @@ func TestVRFV2PlusLoad(t *testing.T) { linkToken, err := actions.DeployLINKToken(env.ContractDeployer) require.NoError(t, err, "error deploying LINK contract") - vrfv2PlusContracts, subIDs, vrfv2PlusData, err = vrfv2plus.SetupVRFV2_5Environment(env, &vrfv2PlusConfig, linkToken, mockETHLinkFeed, 1, numberOfSubToCreate) + vrfv2PlusContracts, subIDs, vrfv2PlusData, err = vrfv2plus.SetupVRFV2_5Environment( + env, + &vrfv2PlusConfig, + linkToken, + mockETHLinkFeed, + 1, + vrfv2PlusConfig.NumberOfSubToCreate, + ) require.NoError(t, err, "error setting up VRF v2_5 env") } - l.Debug().Int("Number of Subs", len(subIDs)).Msg("Subs Involved in Load Test") + l.Debug().Int("Number of Subs", len(subIDs)).Msg("Subs involved in the test") for _, subID := range subIDs { subscription, err := vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), subID) require.NoError(t, err, "error getting subscription information for subscription %s", subID.String()) vrfv2plus.LogSubDetails(l, subscription, subID, vrfv2PlusContracts.Coordinator) } - labels := map[string]string{ - "branch": "vrfv2Plus_healthcheck", - "commit": "vrfv2Plus_healthcheck", - } - - lokiConfig := wasp.NewEnvLokiConfig() - lc, err := wasp.NewLokiClient(lokiConfig) - if err != nil { - l.Error().Err(err).Msg(ErrLokiClient) - return - } - singleFeedConfig := &wasp.Config{ T: t, LoadType: wasp.RPS, @@ -156,11 +181,10 @@ func TestVRFV2PlusLoad(t *testing.T) { consumer := vrfv2PlusContracts.LoadTestConsumers[0] err = consumer.ResetMetrics() require.NoError(t, err) - updatedLabels := UpdateLabels(labels, t) - MonitorLoadStats(lc, vrfv2PlusContracts, updatedLabels) + MonitorLoadStats(lc, consumer, updatedLabels) // is our "job" stable at all, no memory leaks, no flaking performance under some RPS? - t.Run("vrfv2plus soak test", func(t *testing.T) { + t.Run("vrfv2plus performance test", func(t *testing.T) { singleFeedConfig.Schedule = wasp.Plain( vrfv2PlusConfig.RPS, @@ -172,17 +196,44 @@ func TestVRFV2PlusLoad(t *testing.T) { require.NoError(t, err) var wg sync.WaitGroup - wg.Add(1) + //todo - timeout should be configurable depending on the perf test type requestCount, fulfilmentCount, err := vrfv2plus.WaitForRequestCountEqualToFulfilmentCount(consumer, 30*time.Second, &wg) + require.NoError(t, err) + wg.Wait() + l.Info(). Interface("Request Count", requestCount). Interface("Fulfilment Count", fulfilmentCount). Msg("Final Request/Fulfilment Stats") - require.NoError(t, err) - wg.Wait() - //send final results - SendLoadTestMetricsToLoki(vrfv2PlusContracts, lc, updatedLabels) }) +} +func teardown( + t *testing.T, + consumer contracts.VRFv2PlusLoadTestConsumer, + lc *wasp.LokiClient, updatedLabels map[string]string, + testReporter *testreporters.VRFV2PlusTestReporter, + testType string, + vrfv2PlusConfig vrfv2plus_config.VRFV2PlusConfig, +) { + //send final results to Loki + metrics := GetLoadTestMetrics(consumer) + SendMetricsToLoki(metrics, lc, updatedLabels) + //set report data for Slack notification + testReporter.SetReportData( + testType, + metrics.RequestCount, + metrics.FulfilmentCount, + metrics.AverageFulfillmentInMillions, + metrics.SlowestFulfillment, + metrics.FastestFulfillment, + vrfv2PlusConfig, + ) + + // send Slack notification + err := testReporter.SendSlackNotification(t, nil) + if err != nil { + log.Warn().Err(err).Msg("Error sending Slack notification") + } } diff --git a/integration-tests/testreporters/vrfv2plus.go b/integration-tests/testreporters/vrfv2plus.go new file mode 100644 index 00000000000..83d4678dfdd --- /dev/null +++ b/integration-tests/testreporters/vrfv2plus.go @@ -0,0 +1,91 @@ +package testreporters + +import ( + "fmt" + "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus/vrfv2plus_config" + "math/big" + "os" + "testing" + "time" + + "github.com/slack-go/slack" + + "github.com/smartcontractkit/chainlink-testing-framework/testreporters" +) + +type VRFV2PlusTestReporter struct { + TestType string + RequestCount *big.Int + FulfilmentCount *big.Int + AverageFulfillmentInMillions *big.Int + SlowestFulfillment *big.Int + FastestFulfillment *big.Int + Vrfv2PlusConfig *vrfv2plus_config.VRFV2PlusConfig +} + +func (o *VRFV2PlusTestReporter) SetReportData( + testType string, + RequestCount *big.Int, + FulfilmentCount *big.Int, + AverageFulfillmentInMillions *big.Int, + SlowestFulfillment *big.Int, + FastestFulfillment *big.Int, + vrfv2PlusConfig vrfv2plus_config.VRFV2PlusConfig, +) { + o.TestType = testType + o.RequestCount = RequestCount + o.FulfilmentCount = FulfilmentCount + o.AverageFulfillmentInMillions = AverageFulfillmentInMillions + o.SlowestFulfillment = SlowestFulfillment + o.FastestFulfillment = FastestFulfillment + o.Vrfv2PlusConfig = &vrfv2PlusConfig +} + +// SendSlackNotification sends a slack message to a slack webhook +func (o *VRFV2PlusTestReporter) SendSlackNotification(t *testing.T, slackClient *slack.Client) error { + if slackClient == nil { + slackClient = slack.New(testreporters.SlackAPIKey) + } + + testFailed := t.Failed() + headerText := fmt.Sprintf(":white_check_mark: VRF %s Test PASSED :white_check_mark:", o.TestType) + if testFailed { + headerText = fmt.Sprintf(":x: VRF %s Test FAILED :x:", o.TestType) + } + + messageBlocks := testreporters.SlackNotifyBlocks(headerText, fmt.Sprintf("%s", os.Getenv("SELECTED_NETWORKS")), []string{ + fmt.Sprintf( + "Summary\n"+ + "Perf Test Type: %s\n"+ + "Test Duration set in parameters: %s\n"+ + "Use Existing Env: %t\n"+ + "Request Count: %s\n"+ + "Fulfilment Count: %s\n"+ + "AverageFulfillmentInMillions: %s\n"+ + "Slowest Fulfillment: %s\n"+ + "Fastest Fulfillment: %s \n"+ + "RPS: %d\n"+ + "RateLimitUnitDuration: %s\n"+ + "RandomnessRequestCountPerRequest: %d\n"+ + "RandomnessRequestCountPerRequestDeviation: %d\n", + o.TestType, + o.Vrfv2PlusConfig.TestDuration.Truncate(time.Second).String(), + o.Vrfv2PlusConfig.UseExistingEnv, + o.RequestCount.String(), + o.FulfilmentCount.String(), + o.AverageFulfillmentInMillions.String(), + o.SlowestFulfillment.String(), + o.FastestFulfillment.String(), + o.Vrfv2PlusConfig.RPS, + o.Vrfv2PlusConfig.RateLimitUnitDuration.String(), + o.Vrfv2PlusConfig.RandomnessRequestCountPerRequest, + o.Vrfv2PlusConfig.RandomnessRequestCountPerRequestDeviation, + ), + }) + + _, err := testreporters.SendSlackMessage(slackClient, slack.MsgOptionBlocks(messageBlocks...)) + if err != nil { + return err + } + return nil +} diff --git a/tools/flakeytests/cmd/runner/main.go b/tools/flakeytests/cmd/runner/main.go index aea69a134b0..601832a8375 100644 --- a/tools/flakeytests/cmd/runner/main.go +++ b/tools/flakeytests/cmd/runner/main.go @@ -18,6 +18,8 @@ func main() { command := flag.String("command", "", "test command being rerun; used to tag metrics") ghSHA := flag.String("gh_sha", "", "commit sha for which we're rerunning tests") ghEventPath := flag.String("gh_event_path", "", "path to associated gh event") + ghEventName := flag.String("gh_event_name", "", "type of associated gh event") + ghRepo := flag.String("gh_repo", "", "name of gh repository") flag.Parse() if *grafanaHost == "" { @@ -45,7 +47,7 @@ func main() { readers = append(readers, r) } - ctx := flakeytests.GetGithubMetadata(*ghSHA, *ghEventPath) + ctx := flakeytests.GetGithubMetadata(*ghRepo, *ghEventName, *ghSHA, *ghEventPath) rep := flakeytests.NewLokiReporter(*grafanaHost, *grafanaAuth, *command, ctx) r := flakeytests.NewRunner(readers, rep, numReruns) err := r.Run() diff --git a/tools/flakeytests/reporter.go b/tools/flakeytests/reporter.go index beecd8b3e4f..db3890b5c7b 100644 --- a/tools/flakeytests/reporter.go +++ b/tools/flakeytests/reporter.go @@ -33,8 +33,10 @@ type numFlakes struct { } type Context struct { - CommitSHA string `json:"commit_sha,omitempty"` + CommitSHA string `json:"commit_sha"` PullRequestURL string `json:"pull_request_url,omitempty"` + Repository string `json:"repository"` + Type string `json:"event_type"` } type LokiReporter struct { diff --git a/tools/flakeytests/reporter_test.go b/tools/flakeytests/reporter_test.go index f63b89273c9..9cb2c8e9f7d 100644 --- a/tools/flakeytests/reporter_test.go +++ b/tools/flakeytests/reporter_test.go @@ -23,8 +23,8 @@ func TestMakeRequest_SingleTest(t *testing.T) { assert.Len(t, pr.Streams, 1) assert.Equal(t, pr.Streams[0].Stream, map[string]string{"command": "go_core_tests", "app": "flakey-test-reporter"}) assert.ElementsMatch(t, pr.Streams[0].Values, [][]string{ - {ts, "{\"package\":\"core/assets\",\"test_name\":\"TestLink\",\"fq_test_name\":\"core/assets:TestLink\"}"}, - {ts, "{\"num_flakes\":1}"}, + {ts, `{"package":"core/assets","test_name":"TestLink","fq_test_name":"core/assets:TestLink","commit_sha":"","repository":"","event_type":""}`}, + {ts, `{"num_flakes":1,"commit_sha":"","repository":"","event_type":""}`}, }) } @@ -44,9 +44,9 @@ func TestMakeRequest_MultipleTests(t *testing.T) { assert.Equal(t, pr.Streams[0].Stream, map[string]string{"command": "go_core_tests", "app": "flakey-test-reporter"}) assert.ElementsMatch(t, pr.Streams[0].Values, [][]string{ - {ts, "{\"package\":\"core/assets\",\"test_name\":\"TestLink\",\"fq_test_name\":\"core/assets:TestLink\"}"}, - {ts, "{\"package\":\"core/assets\",\"test_name\":\"TestCore\",\"fq_test_name\":\"core/assets:TestCore\"}"}, - {ts, "{\"num_flakes\":2}"}, + {ts, `{"package":"core/assets","test_name":"TestLink","fq_test_name":"core/assets:TestLink","commit_sha":"","repository":"","event_type":""}`}, + {ts, `{"package":"core/assets","test_name":"TestCore","fq_test_name":"core/assets:TestCore","commit_sha":"","repository":"","event_type":""}`}, + {ts, `{"num_flakes":2,"commit_sha":"","repository":"","event_type":""}`}, }) } @@ -60,7 +60,7 @@ func TestMakeRequest_NoTests(t *testing.T) { assert.Len(t, pr.Streams, 1) assert.Equal(t, pr.Streams[0].Stream, map[string]string{"command": "go_core_tests", "app": "flakey-test-reporter"}) assert.ElementsMatch(t, pr.Streams[0].Values, [][]string{ - {ts, "{\"num_flakes\":0}"}, + {ts, `{"num_flakes":0,"commit_sha":"","repository":"","event_type":""}`}, }) } @@ -74,6 +74,6 @@ func TestMakeRequest_WithContext(t *testing.T) { assert.Len(t, pr.Streams, 1) assert.Equal(t, pr.Streams[0].Stream, map[string]string{"command": "go_core_tests", "app": "flakey-test-reporter"}) assert.ElementsMatch(t, pr.Streams[0].Values, [][]string{ - {ts, "{\"num_flakes\":0,\"commit_sha\":\"42\"}"}, + {ts, `{"num_flakes":0,"commit_sha":"42","repository":"","event_type":""}`}, }) } diff --git a/tools/flakeytests/utils.go b/tools/flakeytests/utils.go index 0b95193b2b5..18ab43980b3 100644 --- a/tools/flakeytests/utils.go +++ b/tools/flakeytests/utils.go @@ -29,7 +29,7 @@ func DigString(mp map[string]interface{}, path []string) (string, error) { return vs, nil } -func GetGithubMetadata(sha string, path string) Context { +func GetGithubMetadata(repo string, eventName string, sha string, path string) Context { event := map[string]interface{}{} if path != "" { r, err := os.Open(path) @@ -48,14 +48,18 @@ func GetGithubMetadata(sha string, path string) Context { } } - prURL := "" - url, err := DigString(event, []string{"pull_request", "_links", "html", "href"}) - if err == nil { - prURL = url - } - ctx := Context{ - CommitSHA: sha, - PullRequestURL: prURL, + basicCtx := &Context{Repository: repo, CommitSHA: sha, Type: eventName} + switch eventName { + case "pull_request": + prURL := "" + url, err := DigString(event, []string{"pull_request", "_links", "html", "href"}) + if err == nil { + prURL = url + } + + basicCtx.PullRequestURL = prURL + return *basicCtx + default: + return *basicCtx } - return ctx }