diff --git a/.github/e2e-tests.yml b/.github/e2e-tests.yml index edde8da8162..7042610547c 100644 --- a/.github/e2e-tests.yml +++ b/.github/e2e-tests.yml @@ -960,6 +960,19 @@ runner-test-matrix: test_env_vars: E2E_TEST_SELECTED_NETWORK: SIMULATED_1,SIMULATED_2 E2E_JD_VERSION: 0.6.0 + + - id: smoke/ccip/ccip_batching_test.go:* + path: integration-tests/smoke/ccip/ccip_batching_test.go + test_env_type: docker + runs_on: ubuntu-latest + triggers: + - PR E2E Core Tests + - Nightly E2E Tests + test_cmd: cd integration-tests/ && go test smoke/ccip/ccip_batching_test.go -timeout 12m -test.parallel=1 -count=1 -json + pyroscope_env: ci-smoke-ccipv1_6-evm-simulated + test_env_vars: + E2E_TEST_SELECTED_NETWORK: SIMULATED_1,SIMULATED_2,SIMULATED_3 + E2E_JD_VERSION: 0.6.0 - id: smoke/ccip/ccip_usdc_test.go:* path: integration-tests/smoke/ccip/ccip_usdc_test.go diff --git a/contracts/scripts/native_solc_compile_all_shared b/contracts/scripts/native_solc_compile_all_shared index 3b397780aa0..841f94354e3 100755 --- a/contracts/scripts/native_solc_compile_all_shared +++ b/contracts/scripts/native_solc_compile_all_shared @@ -34,3 +34,4 @@ compileContract shared/token/ERC20/BurnMintERC20.sol compileContract shared/mocks/WERC20Mock.sol compileContract vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/ERC20.sol compileContract shared/test/helpers/ChainReaderTester.sol +compileContract vendor/multicall/ebd8b64/src/Multicall3.sol diff --git a/contracts/src/v0.8/vendor/multicall/ebd8b64/src/Multicall3.sol b/contracts/src/v0.8/vendor/multicall/ebd8b64/src/Multicall3.sol new file mode 100644 index 00000000000..81c9ff681d8 --- /dev/null +++ b/contracts/src/v0.8/vendor/multicall/ebd8b64/src/Multicall3.sol @@ -0,0 +1,216 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.12; + +/// @title Multicall3 +/// @notice Aggregate results from multiple function calls +/// @dev Multicall & Multicall2 backwards-compatible +/// @dev Aggregate methods are marked `payable` to save 24 gas per call +/// @author Michael Elliot +/// @author Joshua Levine +/// @author Nick Johnson +/// @author Andreas Bigger +/// @author Matt Solomon +contract Multicall3 { + struct Call { + address target; + bytes callData; + } + + struct Call3 { + address target; + bool allowFailure; + bytes callData; + } + + struct Call3Value { + address target; + bool allowFailure; + uint256 value; + bytes callData; + } + + struct Result { + bool success; + bytes returnData; + } + + /// @notice Backwards-compatible call aggregation with Multicall + /// @param calls An array of Call structs + /// @return blockNumber The block number where the calls were executed + /// @return returnData An array of bytes containing the responses + function aggregate(Call[] calldata calls) public payable returns (uint256 blockNumber, bytes[] memory returnData) { + blockNumber = block.number; + uint256 length = calls.length; + returnData = new bytes[](length); + Call calldata call; + for (uint256 i = 0; i < length;) { + bool success; + call = calls[i]; + (success, returnData[i]) = call.target.call(call.callData); + require(success, "Multicall3: call failed"); + unchecked { ++i; } + } + } + + /// @notice Backwards-compatible with Multicall2 + /// @notice Aggregate calls without requiring success + /// @param requireSuccess If true, require all calls to succeed + /// @param calls An array of Call structs + /// @return returnData An array of Result structs + function tryAggregate(bool requireSuccess, Call[] calldata calls) public payable returns (Result[] memory returnData) { + uint256 length = calls.length; + returnData = new Result[](length); + Call calldata call; + for (uint256 i = 0; i < length;) { + Result memory result = returnData[i]; + call = calls[i]; + (result.success, result.returnData) = call.target.call(call.callData); + if (requireSuccess) require(result.success, "Multicall3: call failed"); + unchecked { ++i; } + } + } + + /// @notice Backwards-compatible with Multicall2 + /// @notice Aggregate calls and allow failures using tryAggregate + /// @param calls An array of Call structs + /// @return blockNumber The block number where the calls were executed + /// @return blockHash The hash of the block where the calls were executed + /// @return returnData An array of Result structs + function tryBlockAndAggregate(bool requireSuccess, Call[] calldata calls) public payable returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData) { + blockNumber = block.number; + blockHash = blockhash(block.number); + returnData = tryAggregate(requireSuccess, calls); + } + + /// @notice Backwards-compatible with Multicall2 + /// @notice Aggregate calls and allow failures using tryAggregate + /// @param calls An array of Call structs + /// @return blockNumber The block number where the calls were executed + /// @return blockHash The hash of the block where the calls were executed + /// @return returnData An array of Result structs + function blockAndAggregate(Call[] calldata calls) public payable returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData) { + (blockNumber, blockHash, returnData) = tryBlockAndAggregate(true, calls); + } + + /// @notice Aggregate calls, ensuring each returns success if required + /// @param calls An array of Call3 structs + /// @return returnData An array of Result structs + function aggregate3(Call3[] calldata calls) public payable returns (Result[] memory returnData) { + uint256 length = calls.length; + returnData = new Result[](length); + Call3 calldata calli; + for (uint256 i = 0; i < length;) { + Result memory result = returnData[i]; + calli = calls[i]; + (result.success, result.returnData) = calli.target.call(calli.callData); + assembly { + // Revert if the call fails and failure is not allowed + // `allowFailure := calldataload(add(calli, 0x20))` and `success := mload(result)` + if iszero(or(calldataload(add(calli, 0x20)), mload(result))) { + // set "Error(string)" signature: bytes32(bytes4(keccak256("Error(string)"))) + mstore(0x00, 0x08c379a000000000000000000000000000000000000000000000000000000000) + // set data offset + mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020) + // set length of revert string + mstore(0x24, 0x0000000000000000000000000000000000000000000000000000000000000017) + // set revert string: bytes32(abi.encodePacked("Multicall3: call failed")) + mstore(0x44, 0x4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000) + revert(0x00, 0x64) + } + } + unchecked { ++i; } + } + } + + /// @notice Aggregate calls with a msg value + /// @notice Reverts if msg.value is less than the sum of the call values + /// @param calls An array of Call3Value structs + /// @return returnData An array of Result structs + function aggregate3Value(Call3Value[] calldata calls) public payable returns (Result[] memory returnData) { + uint256 valAccumulator; + uint256 length = calls.length; + returnData = new Result[](length); + Call3Value calldata calli; + for (uint256 i = 0; i < length;) { + Result memory result = returnData[i]; + calli = calls[i]; + uint256 val = calli.value; + // Humanity will be a Type V Kardashev Civilization before this overflows - andreas + // ~ 10^25 Wei in existence << ~ 10^76 size uint fits in a uint256 + unchecked { valAccumulator += val; } + (result.success, result.returnData) = calli.target.call{value: val}(calli.callData); + assembly { + // Revert if the call fails and failure is not allowed + // `allowFailure := calldataload(add(calli, 0x20))` and `success := mload(result)` + if iszero(or(calldataload(add(calli, 0x20)), mload(result))) { + // set "Error(string)" signature: bytes32(bytes4(keccak256("Error(string)"))) + mstore(0x00, 0x08c379a000000000000000000000000000000000000000000000000000000000) + // set data offset + mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020) + // set length of revert string + mstore(0x24, 0x0000000000000000000000000000000000000000000000000000000000000017) + // set revert string: bytes32(abi.encodePacked("Multicall3: call failed")) + mstore(0x44, 0x4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000) + revert(0x00, 0x84) + } + } + unchecked { ++i; } + } + // Finally, make sure the msg.value = SUM(call[0...i].value) + require(msg.value == valAccumulator, "Multicall3: value mismatch"); + } + + /// @notice Returns the block hash for the given block number + /// @param blockNumber The block number + function getBlockHash(uint256 blockNumber) public view returns (bytes32 blockHash) { + blockHash = blockhash(blockNumber); + } + + /// @notice Returns the block number + function getBlockNumber() public view returns (uint256 blockNumber) { + blockNumber = block.number; + } + + /// @notice Returns the block coinbase + function getCurrentBlockCoinbase() public view returns (address coinbase) { + coinbase = block.coinbase; + } + + /// @notice Returns the block difficulty + function getCurrentBlockDifficulty() public view returns (uint256 difficulty) { + difficulty = block.difficulty; + } + + /// @notice Returns the block gas limit + function getCurrentBlockGasLimit() public view returns (uint256 gaslimit) { + gaslimit = block.gaslimit; + } + + /// @notice Returns the block timestamp + function getCurrentBlockTimestamp() public view returns (uint256 timestamp) { + timestamp = block.timestamp; + } + + /// @notice Returns the (ETH) balance of a given address + function getEthBalance(address addr) public view returns (uint256 balance) { + balance = addr.balance; + } + + /// @notice Returns the block hash of the last block + function getLastBlockHash() public view returns (bytes32 blockHash) { + unchecked { + blockHash = blockhash(block.number - 1); + } + } + + /// @notice Gets the base fee of the given block + /// @notice Can revert if the BASEFEE opcode is not implemented by the given chain + function getBasefee() public view returns (uint256 basefee) { + basefee = block.basefee; + } + + /// @notice Returns the chain id + function getChainId() public view returns (uint256 chainid) { + chainid = block.chainid; + } +} diff --git a/core/gethwrappers/shared/generated/multicall3/multicall3.go b/core/gethwrappers/shared/generated/multicall3/multicall3.go new file mode 100644 index 00000000000..91d612756b8 --- /dev/null +++ b/core/gethwrappers/shared/generated/multicall3/multicall3.go @@ -0,0 +1,525 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package multicall3 + +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 +) + +type Multicall3Call struct { + Target common.Address + CallData []byte +} + +type Multicall3Call3 struct { + Target common.Address + AllowFailure bool + CallData []byte +} + +type Multicall3Call3Value struct { + Target common.Address + AllowFailure bool + Value *big.Int + CallData []byte +} + +type Multicall3Result struct { + Success bool + ReturnData []byte +} + +var Multicall3MetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"structMulticall3.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"aggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes[]\",\"name\":\"returnData\",\"type\":\"bytes[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"allowFailure\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"structMulticall3.Call3[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"aggregate3\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"structMulticall3.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"allowFailure\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"structMulticall3.Call3Value[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"aggregate3Value\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"structMulticall3.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"structMulticall3.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"blockAndAggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"structMulticall3.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBasefee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"basefee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBlockNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getChainId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"chainid\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockCoinbase\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"coinbase\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"difficulty\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockGasLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"gaslimit\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getEthBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLastBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"requireSuccess\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"structMulticall3.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"tryAggregate\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"structMulticall3.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"requireSuccess\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"structMulticall3.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"tryBlockAndAggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"structMulticall3.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}]", + Bin: "0x608060405234801561001057600080fd5b50610eb0806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b80634d2301cc146101ec57806372425d9d1461022157806382ad56cb1461023457806386d516e81461024757600080fd5b80633408e470116100c65780633408e47014610191578063399542e9146101a45780633e64a696146101c657806342cbb15c146101d957600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d610128366004610a85565b6102ba565b6040516101119190610bb7565b61014d610148366004610a85565b6104ef565b604051610111929190610bd1565b34801561016757600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b34801561019d57600080fd5b5046610107565b6101b76101b2366004610c59565b610690565b60405161011193929190610cb3565b3480156101d257600080fd5b5048610107565b3480156101e557600080fd5b5043610107565b3480156101f857600080fd5b50610107610207366004610cdb565b73ffffffffffffffffffffffffffffffffffffffff163190565b34801561022d57600080fd5b5044610107565b61012d610242366004610a85565b6106ab565b34801561025357600080fd5b5045610107565b34801561026657600080fd5b50604051418152602001610111565b61012d610283366004610c59565b61085a565b6101b7610296366004610a85565b610a1a565b3480156102a757600080fd5b506101076102b6366004610d11565b4090565b60606000828067ffffffffffffffff8111156102d8576102d8610d2a565b60405190808252806020026020018201604052801561031e57816020015b6040805180820190915260008152606060208201528152602001906001900390816102f65790505b5092503660005b8281101561047757600085828151811061034157610341610d59565b6020026020010151905087878381811061035d5761035d610d59565b905060200281019061036f9190610d88565b6040810135958601959093506103886020850185610cdb565b73ffffffffffffffffffffffffffffffffffffffff16816103ac6060870187610dc6565b6040516103ba929190610e2b565b60006040518083038185875af1925050503d80600081146103f7576040519150601f19603f3d011682016040523d82523d6000602084013e6103fc565b606091505b50602080850191909152901515808452908501351761046d577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b5050600101610325565b508234146104e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff81111561050c5761050c610d2a565b60405190808252806020026020018201604052801561053f57816020015b606081526020019060019003908161052a5790505b5091503660005b8281101561068657600087878381811061056257610562610d59565b90506020028101906105749190610e3b565b92506105836020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff166105a66020850185610dc6565b6040516105b4929190610e2b565b6000604051808303816000865af19150503d80600081146105f1576040519150601f19603f3d011682016040523d82523d6000602084013e6105f6565b606091505b5086848151811061060957610609610d59565b602090810291909101015290508061067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b50600101610546565b5050509250929050565b43804060606106a086868661085a565b905093509350939050565b6060818067ffffffffffffffff8111156106c7576106c7610d2a565b60405190808252806020026020018201604052801561070d57816020015b6040805180820190915260008152606060208201528152602001906001900390816106e55790505b5091503660005b828110156104e657600084828151811061073057610730610d59565b6020026020010151905086868381811061074c5761074c610d59565b905060200281019061075e9190610e6f565b925061076d6020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff166107906040850185610dc6565b60405161079e929190610e2b565b6000604051808303816000865af19150503d80600081146107db576040519150601f19603f3d011682016040523d82523d6000602084013e6107e0565b606091505b506020808401919091529015158083529084013517610851577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610714565b6060818067ffffffffffffffff81111561087657610876610d2a565b6040519080825280602002602001820160405280156108bc57816020015b6040805180820190915260008152606060208201528152602001906001900390816108945790505b5091503660005b82811015610a105760008482815181106108df576108df610d59565b602002602001015190508686838181106108fb576108fb610d59565b905060200281019061090d9190610e3b565b925061091c6020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff1661093f6020850185610dc6565b60405161094d929190610e2b565b6000604051808303816000865af19150503d806000811461098a576040519150601f19603f3d011682016040523d82523d6000602084013e61098f565b606091505b506020830152151581528715610a07578051610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b506001016108c3565b5050509392505050565b6000806060610a2b60018686610690565b919790965090945092505050565b60008083601f840112610a4b57600080fd5b50813567ffffffffffffffff811115610a6357600080fd5b6020830191508360208260051b8501011115610a7e57600080fd5b9250929050565b60008060208385031215610a9857600080fd5b823567ffffffffffffffff811115610aaf57600080fd5b610abb85828601610a39565b90969095509350505050565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b600082825180855260208086019550808260051b84010181860160005b84811015610baa578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001895281518051151584528401516040858501819052610b9681860183610ac7565b9a86019a9450505090830190600101610b48565b5090979650505050505050565b602081526000610bca6020830184610b2b565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610c4b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0888703018452610c39868351610ac7565b95509284019290840190600101610bff565b509398975050505050505050565b600080600060408486031215610c6e57600080fd5b83358015158114610c7e57600080fd5b9250602084013567ffffffffffffffff811115610c9a57600080fd5b610ca686828701610a39565b9497909650939450505050565b838152826020820152606060408201526000610cd26060830184610b2b565b95945050505050565b600060208284031215610ced57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610bca57600080fd5b600060208284031215610d2357600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81833603018112610dbc57600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610dfb57600080fd5b83018035915067ffffffffffffffff821115610e1657600080fd5b602001915036819003821315610a7e57600080fd5b8183823760009101908152919050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112610dbc57600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112610dbc57600080fdfea164736f6c6343000813000a", +} + +var Multicall3ABI = Multicall3MetaData.ABI + +var Multicall3Bin = Multicall3MetaData.Bin + +func DeployMulticall3(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Multicall3, error) { + parsed, err := Multicall3MetaData.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(Multicall3Bin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &Multicall3{address: address, abi: *parsed, Multicall3Caller: Multicall3Caller{contract: contract}, Multicall3Transactor: Multicall3Transactor{contract: contract}, Multicall3Filterer: Multicall3Filterer{contract: contract}}, nil +} + +type Multicall3 struct { + address common.Address + abi abi.ABI + Multicall3Caller + Multicall3Transactor + Multicall3Filterer +} + +type Multicall3Caller struct { + contract *bind.BoundContract +} + +type Multicall3Transactor struct { + contract *bind.BoundContract +} + +type Multicall3Filterer struct { + contract *bind.BoundContract +} + +type Multicall3Session struct { + Contract *Multicall3 + CallOpts bind.CallOpts + TransactOpts bind.TransactOpts +} + +type Multicall3CallerSession struct { + Contract *Multicall3Caller + CallOpts bind.CallOpts +} + +type Multicall3TransactorSession struct { + Contract *Multicall3Transactor + TransactOpts bind.TransactOpts +} + +type Multicall3Raw struct { + Contract *Multicall3 +} + +type Multicall3CallerRaw struct { + Contract *Multicall3Caller +} + +type Multicall3TransactorRaw struct { + Contract *Multicall3Transactor +} + +func NewMulticall3(address common.Address, backend bind.ContractBackend) (*Multicall3, error) { + abi, err := abi.JSON(strings.NewReader(Multicall3ABI)) + if err != nil { + return nil, err + } + contract, err := bindMulticall3(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Multicall3{address: address, abi: abi, Multicall3Caller: Multicall3Caller{contract: contract}, Multicall3Transactor: Multicall3Transactor{contract: contract}, Multicall3Filterer: Multicall3Filterer{contract: contract}}, nil +} + +func NewMulticall3Caller(address common.Address, caller bind.ContractCaller) (*Multicall3Caller, error) { + contract, err := bindMulticall3(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &Multicall3Caller{contract: contract}, nil +} + +func NewMulticall3Transactor(address common.Address, transactor bind.ContractTransactor) (*Multicall3Transactor, error) { + contract, err := bindMulticall3(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &Multicall3Transactor{contract: contract}, nil +} + +func NewMulticall3Filterer(address common.Address, filterer bind.ContractFilterer) (*Multicall3Filterer, error) { + contract, err := bindMulticall3(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &Multicall3Filterer{contract: contract}, nil +} + +func bindMulticall3(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := Multicall3MetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +func (_Multicall3 *Multicall3Raw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Multicall3.Contract.Multicall3Caller.contract.Call(opts, result, method, params...) +} + +func (_Multicall3 *Multicall3Raw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Multicall3.Contract.Multicall3Transactor.contract.Transfer(opts) +} + +func (_Multicall3 *Multicall3Raw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Multicall3.Contract.Multicall3Transactor.contract.Transact(opts, method, params...) +} + +func (_Multicall3 *Multicall3CallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Multicall3.Contract.contract.Call(opts, result, method, params...) +} + +func (_Multicall3 *Multicall3TransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Multicall3.Contract.contract.Transfer(opts) +} + +func (_Multicall3 *Multicall3TransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Multicall3.Contract.contract.Transact(opts, method, params...) +} + +func (_Multicall3 *Multicall3Caller) GetBasefee(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Multicall3.contract.Call(opts, &out, "getBasefee") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_Multicall3 *Multicall3Session) GetBasefee() (*big.Int, error) { + return _Multicall3.Contract.GetBasefee(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3CallerSession) GetBasefee() (*big.Int, error) { + return _Multicall3.Contract.GetBasefee(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3Caller) GetBlockHash(opts *bind.CallOpts, blockNumber *big.Int) ([32]byte, error) { + var out []interface{} + err := _Multicall3.contract.Call(opts, &out, "getBlockHash", blockNumber) + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +func (_Multicall3 *Multicall3Session) GetBlockHash(blockNumber *big.Int) ([32]byte, error) { + return _Multicall3.Contract.GetBlockHash(&_Multicall3.CallOpts, blockNumber) +} + +func (_Multicall3 *Multicall3CallerSession) GetBlockHash(blockNumber *big.Int) ([32]byte, error) { + return _Multicall3.Contract.GetBlockHash(&_Multicall3.CallOpts, blockNumber) +} + +func (_Multicall3 *Multicall3Caller) GetBlockNumber(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Multicall3.contract.Call(opts, &out, "getBlockNumber") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_Multicall3 *Multicall3Session) GetBlockNumber() (*big.Int, error) { + return _Multicall3.Contract.GetBlockNumber(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3CallerSession) GetBlockNumber() (*big.Int, error) { + return _Multicall3.Contract.GetBlockNumber(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3Caller) GetChainId(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Multicall3.contract.Call(opts, &out, "getChainId") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_Multicall3 *Multicall3Session) GetChainId() (*big.Int, error) { + return _Multicall3.Contract.GetChainId(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3CallerSession) GetChainId() (*big.Int, error) { + return _Multicall3.Contract.GetChainId(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3Caller) GetCurrentBlockCoinbase(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Multicall3.contract.Call(opts, &out, "getCurrentBlockCoinbase") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +func (_Multicall3 *Multicall3Session) GetCurrentBlockCoinbase() (common.Address, error) { + return _Multicall3.Contract.GetCurrentBlockCoinbase(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3CallerSession) GetCurrentBlockCoinbase() (common.Address, error) { + return _Multicall3.Contract.GetCurrentBlockCoinbase(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3Caller) GetCurrentBlockDifficulty(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Multicall3.contract.Call(opts, &out, "getCurrentBlockDifficulty") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_Multicall3 *Multicall3Session) GetCurrentBlockDifficulty() (*big.Int, error) { + return _Multicall3.Contract.GetCurrentBlockDifficulty(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3CallerSession) GetCurrentBlockDifficulty() (*big.Int, error) { + return _Multicall3.Contract.GetCurrentBlockDifficulty(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3Caller) GetCurrentBlockGasLimit(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Multicall3.contract.Call(opts, &out, "getCurrentBlockGasLimit") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_Multicall3 *Multicall3Session) GetCurrentBlockGasLimit() (*big.Int, error) { + return _Multicall3.Contract.GetCurrentBlockGasLimit(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3CallerSession) GetCurrentBlockGasLimit() (*big.Int, error) { + return _Multicall3.Contract.GetCurrentBlockGasLimit(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3Caller) GetCurrentBlockTimestamp(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Multicall3.contract.Call(opts, &out, "getCurrentBlockTimestamp") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_Multicall3 *Multicall3Session) GetCurrentBlockTimestamp() (*big.Int, error) { + return _Multicall3.Contract.GetCurrentBlockTimestamp(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3CallerSession) GetCurrentBlockTimestamp() (*big.Int, error) { + return _Multicall3.Contract.GetCurrentBlockTimestamp(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3Caller) GetEthBalance(opts *bind.CallOpts, addr common.Address) (*big.Int, error) { + var out []interface{} + err := _Multicall3.contract.Call(opts, &out, "getEthBalance", addr) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_Multicall3 *Multicall3Session) GetEthBalance(addr common.Address) (*big.Int, error) { + return _Multicall3.Contract.GetEthBalance(&_Multicall3.CallOpts, addr) +} + +func (_Multicall3 *Multicall3CallerSession) GetEthBalance(addr common.Address) (*big.Int, error) { + return _Multicall3.Contract.GetEthBalance(&_Multicall3.CallOpts, addr) +} + +func (_Multicall3 *Multicall3Caller) GetLastBlockHash(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _Multicall3.contract.Call(opts, &out, "getLastBlockHash") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +func (_Multicall3 *Multicall3Session) GetLastBlockHash() ([32]byte, error) { + return _Multicall3.Contract.GetLastBlockHash(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3CallerSession) GetLastBlockHash() ([32]byte, error) { + return _Multicall3.Contract.GetLastBlockHash(&_Multicall3.CallOpts) +} + +func (_Multicall3 *Multicall3Transactor) Aggregate(opts *bind.TransactOpts, calls []Multicall3Call) (*types.Transaction, error) { + return _Multicall3.contract.Transact(opts, "aggregate", calls) +} + +func (_Multicall3 *Multicall3Session) Aggregate(calls []Multicall3Call) (*types.Transaction, error) { + return _Multicall3.Contract.Aggregate(&_Multicall3.TransactOpts, calls) +} + +func (_Multicall3 *Multicall3TransactorSession) Aggregate(calls []Multicall3Call) (*types.Transaction, error) { + return _Multicall3.Contract.Aggregate(&_Multicall3.TransactOpts, calls) +} + +func (_Multicall3 *Multicall3Transactor) Aggregate3(opts *bind.TransactOpts, calls []Multicall3Call3) (*types.Transaction, error) { + return _Multicall3.contract.Transact(opts, "aggregate3", calls) +} + +func (_Multicall3 *Multicall3Session) Aggregate3(calls []Multicall3Call3) (*types.Transaction, error) { + return _Multicall3.Contract.Aggregate3(&_Multicall3.TransactOpts, calls) +} + +func (_Multicall3 *Multicall3TransactorSession) Aggregate3(calls []Multicall3Call3) (*types.Transaction, error) { + return _Multicall3.Contract.Aggregate3(&_Multicall3.TransactOpts, calls) +} + +func (_Multicall3 *Multicall3Transactor) Aggregate3Value(opts *bind.TransactOpts, calls []Multicall3Call3Value) (*types.Transaction, error) { + return _Multicall3.contract.Transact(opts, "aggregate3Value", calls) +} + +func (_Multicall3 *Multicall3Session) Aggregate3Value(calls []Multicall3Call3Value) (*types.Transaction, error) { + return _Multicall3.Contract.Aggregate3Value(&_Multicall3.TransactOpts, calls) +} + +func (_Multicall3 *Multicall3TransactorSession) Aggregate3Value(calls []Multicall3Call3Value) (*types.Transaction, error) { + return _Multicall3.Contract.Aggregate3Value(&_Multicall3.TransactOpts, calls) +} + +func (_Multicall3 *Multicall3Transactor) BlockAndAggregate(opts *bind.TransactOpts, calls []Multicall3Call) (*types.Transaction, error) { + return _Multicall3.contract.Transact(opts, "blockAndAggregate", calls) +} + +func (_Multicall3 *Multicall3Session) BlockAndAggregate(calls []Multicall3Call) (*types.Transaction, error) { + return _Multicall3.Contract.BlockAndAggregate(&_Multicall3.TransactOpts, calls) +} + +func (_Multicall3 *Multicall3TransactorSession) BlockAndAggregate(calls []Multicall3Call) (*types.Transaction, error) { + return _Multicall3.Contract.BlockAndAggregate(&_Multicall3.TransactOpts, calls) +} + +func (_Multicall3 *Multicall3Transactor) TryAggregate(opts *bind.TransactOpts, requireSuccess bool, calls []Multicall3Call) (*types.Transaction, error) { + return _Multicall3.contract.Transact(opts, "tryAggregate", requireSuccess, calls) +} + +func (_Multicall3 *Multicall3Session) TryAggregate(requireSuccess bool, calls []Multicall3Call) (*types.Transaction, error) { + return _Multicall3.Contract.TryAggregate(&_Multicall3.TransactOpts, requireSuccess, calls) +} + +func (_Multicall3 *Multicall3TransactorSession) TryAggregate(requireSuccess bool, calls []Multicall3Call) (*types.Transaction, error) { + return _Multicall3.Contract.TryAggregate(&_Multicall3.TransactOpts, requireSuccess, calls) +} + +func (_Multicall3 *Multicall3Transactor) TryBlockAndAggregate(opts *bind.TransactOpts, requireSuccess bool, calls []Multicall3Call) (*types.Transaction, error) { + return _Multicall3.contract.Transact(opts, "tryBlockAndAggregate", requireSuccess, calls) +} + +func (_Multicall3 *Multicall3Session) TryBlockAndAggregate(requireSuccess bool, calls []Multicall3Call) (*types.Transaction, error) { + return _Multicall3.Contract.TryBlockAndAggregate(&_Multicall3.TransactOpts, requireSuccess, calls) +} + +func (_Multicall3 *Multicall3TransactorSession) TryBlockAndAggregate(requireSuccess bool, calls []Multicall3Call) (*types.Transaction, error) { + return _Multicall3.Contract.TryBlockAndAggregate(&_Multicall3.TransactOpts, requireSuccess, calls) +} + +func (_Multicall3 *Multicall3) Address() common.Address { + return _Multicall3.address +} + +type Multicall3Interface interface { + GetBasefee(opts *bind.CallOpts) (*big.Int, error) + + GetBlockHash(opts *bind.CallOpts, blockNumber *big.Int) ([32]byte, error) + + GetBlockNumber(opts *bind.CallOpts) (*big.Int, error) + + GetChainId(opts *bind.CallOpts) (*big.Int, error) + + GetCurrentBlockCoinbase(opts *bind.CallOpts) (common.Address, error) + + GetCurrentBlockDifficulty(opts *bind.CallOpts) (*big.Int, error) + + GetCurrentBlockGasLimit(opts *bind.CallOpts) (*big.Int, error) + + GetCurrentBlockTimestamp(opts *bind.CallOpts) (*big.Int, error) + + GetEthBalance(opts *bind.CallOpts, addr common.Address) (*big.Int, error) + + GetLastBlockHash(opts *bind.CallOpts) ([32]byte, error) + + Aggregate(opts *bind.TransactOpts, calls []Multicall3Call) (*types.Transaction, error) + + Aggregate3(opts *bind.TransactOpts, calls []Multicall3Call3) (*types.Transaction, error) + + Aggregate3Value(opts *bind.TransactOpts, calls []Multicall3Call3Value) (*types.Transaction, error) + + BlockAndAggregate(opts *bind.TransactOpts, calls []Multicall3Call) (*types.Transaction, error) + + TryAggregate(opts *bind.TransactOpts, requireSuccess bool, calls []Multicall3Call) (*types.Transaction, error) + + TryBlockAndAggregate(opts *bind.TransactOpts, requireSuccess bool, calls []Multicall3Call) (*types.Transaction, error) + + Address() common.Address +} diff --git a/core/gethwrappers/shared/generation/generated-wrapper-dependency-versions-do-not-edit.txt b/core/gethwrappers/shared/generation/generated-wrapper-dependency-versions-do-not-edit.txt index 8380739406a..470cd477fe0 100644 --- a/core/gethwrappers/shared/generation/generated-wrapper-dependency-versions-do-not-edit.txt +++ b/core/gethwrappers/shared/generation/generated-wrapper-dependency-versions-do-not-edit.txt @@ -3,4 +3,5 @@ burn_mint_erc20: ../../../contracts/solc/v0.8.19/BurnMintERC20/BurnMintERC20.abi burn_mint_erc677: ../../../contracts/solc/v0.8.19/BurnMintERC677/BurnMintERC677.abi ../../../contracts/solc/v0.8.19/BurnMintERC677/BurnMintERC677.bin 405c9016171e614b17e10588653ef8d33dcea21dd569c3fddc596a46fcff68a3 erc20: ../../../contracts/solc/v0.8.19/ERC20/ERC20.abi ../../../contracts/solc/v0.8.19/ERC20/ERC20.bin 5b1a93d9b24f250e49a730c96335a8113c3f7010365cba578f313b483001d4fc link_token: ../../../contracts/solc/v0.8.19/LinkToken/LinkToken.abi ../../../contracts/solc/v0.8.19/LinkToken/LinkToken.bin c0ef9b507103aae541ebc31d87d051c2764ba9d843076b30ec505d37cdfffaba +multicall3: ../../../contracts/solc/v0.8.19/Multicall3/Multicall3.abi ../../../contracts/solc/v0.8.19/Multicall3/Multicall3.bin 66fff7368bbd7dfe1cb20d31cf29efa917a24cf5344e2d79b34994b8c3b9530a werc20_mock: ../../../contracts/solc/v0.8.19/WERC20Mock/WERC20Mock.abi ../../../contracts/solc/v0.8.19/WERC20Mock/WERC20Mock.bin ff2ca3928b2aa9c412c892cb8226c4d754c73eeb291bb7481c32c48791b2aa94 diff --git a/core/gethwrappers/shared/go_generate.go b/core/gethwrappers/shared/go_generate.go index c0d40a847b2..7fe9d6a8ef2 100644 --- a/core/gethwrappers/shared/go_generate.go +++ b/core/gethwrappers/shared/go_generate.go @@ -7,3 +7,4 @@ package gethwrappers //go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.19/BurnMintERC20/BurnMintERC20.abi ../../../contracts/solc/v0.8.19/BurnMintERC20/BurnMintERC20.bin BurnMintERC20 burn_mint_erc20 //go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.19/ERC20/ERC20.abi ../../../contracts/solc/v0.8.19/ERC20/ERC20.bin ERC20 erc20 //go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.19/WERC20Mock/WERC20Mock.abi ../../../contracts/solc/v0.8.19/WERC20Mock/WERC20Mock.bin WERC20Mock werc20_mock +//go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.19/Multicall3/Multicall3.abi ../../../contracts/solc/v0.8.19/Multicall3/Multicall3.bin Multicall3 multicall3 diff --git a/deployment/address_book.go b/deployment/address_book.go index 076e2a235d6..5a99216dda0 100644 --- a/deployment/address_book.go +++ b/deployment/address_book.go @@ -195,7 +195,7 @@ func (m *AddressBookMap) Remove(ab AddressBook) error { // State of m.addressesByChain storage must not be changed in case of an error // need to do double iteration over the address book. First validation, second actual deletion for chainSelector, chainAddresses := range addresses { - for address, _ := range chainAddresses { + for address := range chainAddresses { if _, exists := m.addressesByChain[chainSelector][address]; !exists { return errors.New("AddressBookMap does not contain address from the given address book") } @@ -203,7 +203,7 @@ func (m *AddressBookMap) Remove(ab AddressBook) error { } for chainSelector, chainAddresses := range addresses { - for address, _ := range chainAddresses { + for address := range chainAddresses { delete(m.addressesByChain[chainSelector], address) } } diff --git a/deployment/address_book_test.go b/deployment/address_book_test.go index 9040902a169..47eb507e126 100644 --- a/deployment/address_book_test.go +++ b/deployment/address_book_test.go @@ -206,14 +206,14 @@ func TestAddressBook_ConcurrencyAndDeadlock(t *testing.T) { require.NoError(t, err) for chainSelector, chainAddresses := range addresses { // concurrent read chainAddresses from Addresses() method - for address, _ := range chainAddresses { + for address := range chainAddresses { addresses[chainSelector][address] = onRamp110 } // concurrent read chainAddresses from AddressesForChain() method chainAddresses, err = baseAB.AddressesForChain(chainSelector) require.NoError(t, err) - for address, _ := range chainAddresses { + for address := range chainAddresses { _ = addresses[chainSelector][address] } } diff --git a/deployment/ccip/changeset/active_candidate_test.go b/deployment/ccip/changeset/active_candidate_test.go index be3cc9ac121..e53d3d177ad 100644 --- a/deployment/ccip/changeset/active_candidate_test.go +++ b/deployment/ccip/changeset/active_candidate_test.go @@ -37,6 +37,7 @@ func TestActiveCandidate(t *testing.T) { startBlocks := make(map[uint64]*uint64) // Send a message from each chain to every other chain. expectedSeqNum := make(map[SourceDestPair]uint64) + expectedSeqNumExec := make(map[SourceDestPair][]uint64) for src := range e.Chains { for dest, destChain := range e.Chains { if src == dest { @@ -57,6 +58,10 @@ func TestActiveCandidate(t *testing.T) { SourceChainSelector: src, DestChainSelector: dest, }] = msgSentEvent.SequenceNumber + expectedSeqNumExec[SourceDestPair{ + SourceChainSelector: src, + DestChainSelector: dest, + }] = []uint64{msgSentEvent.SequenceNumber} } } @@ -73,7 +78,7 @@ func TestActiveCandidate(t *testing.T) { } //Wait for all exec reports to land - ConfirmExecWithSeqNrForAll(t, e, state, expectedSeqNum, startBlocks) + ConfirmExecWithSeqNrsForAll(t, e, state, expectedSeqNumExec, startBlocks) // transfer ownership TransferAllOwnership(t, state, tenv.HomeChainSel, e) diff --git a/deployment/ccip/changeset/add_chain_test.go b/deployment/ccip/changeset/add_chain_test.go index d369a481c7d..81f9d2412ec 100644 --- a/deployment/ccip/changeset/add_chain_test.go +++ b/deployment/ccip/changeset/add_chain_test.go @@ -246,12 +246,22 @@ func TestAddChainInbound(t *testing.T) { ExtraArgs: nil, }) require.NoError(t, - ConfirmCommitWithExpectedSeqNumRange(t, e.Env.Chains[initialDeploy[0]], e.Env.Chains[newChain], state.Chains[newChain].OffRamp, &startBlock, cciptypes.SeqNumRange{ + commonutils.JustError(ConfirmCommitWithExpectedSeqNumRange(t, e.Env.Chains[initialDeploy[0]], e.Env.Chains[newChain], state.Chains[newChain].OffRamp, &startBlock, cciptypes.SeqNumRange{ cciptypes.SeqNum(1), cciptypes.SeqNum(msgSentEvent.SequenceNumber), - })) + }))) require.NoError(t, - commonutils.JustError(ConfirmExecWithSeqNr(t, e.Env.Chains[initialDeploy[0]], e.Env.Chains[newChain], state.Chains[newChain].OffRamp, &startBlock, msgSentEvent.SequenceNumber))) + commonutils.JustError( + ConfirmExecWithSeqNrs( + t, + e.Env.Chains[initialDeploy[0]], + e.Env.Chains[newChain], + state.Chains[newChain].OffRamp, + &startBlock, + []uint64{msgSentEvent.SequenceNumber}, + ), + ), + ) linkAddress := state.Chains[newChain].LinkToken.Address() feeQuoter := state.Chains[newChain].FeeQuoter diff --git a/deployment/ccip/changeset/add_lane_test.go b/deployment/ccip/changeset/add_lane_test.go index 367fd68ba75..1939d0da10a 100644 --- a/deployment/ccip/changeset/add_lane_test.go +++ b/deployment/ccip/changeset/add_lane_test.go @@ -101,7 +101,18 @@ func TestAddLane(t *testing.T) { ExtraArgs: nil, }) require.Equal(t, uint64(1), msgSentEvent2.SequenceNumber) - require.NoError(t, commonutils.JustError(ConfirmExecWithSeqNr(t, e.Env.Chains[chain2], e.Env.Chains[chain1], state.Chains[chain1].OffRamp, &startBlock2, msgSentEvent2.SequenceNumber))) + require.NoError(t, + commonutils.JustError( + ConfirmExecWithSeqNrs( + t, + e.Env.Chains[chain2], + e.Env.Chains[chain1], + state.Chains[chain1].OffRamp, + &startBlock2, + []uint64{msgSentEvent2.SequenceNumber}, + ), + ), + ) // now check for the previous message from chain 1 to chain 2 that it has not been executed till now as the onRamp was disabled ConfirmNoExecConsistentlyWithSeqNr(t, e.Env.Chains[chain1], e.Env.Chains[chain2], state.Chains[chain2].OffRamp, msgSentEvent1.SequenceNumber, 30*time.Second) @@ -127,5 +138,16 @@ func TestAddLane(t *testing.T) { ReplayLogs(t, e.Env.Offchain, replayBlocks) time.Sleep(30 * time.Second) // Now that the onRamp is enabled, the request should be processed - require.NoError(t, commonutils.JustError(ConfirmExecWithSeqNr(t, e.Env.Chains[chain1], e.Env.Chains[chain2], state.Chains[chain2].OffRamp, &startBlock, msgSentEvent1.SequenceNumber))) + require.NoError(t, + commonutils.JustError( + ConfirmExecWithSeqNrs( + t, + e.Env.Chains[chain1], + e.Env.Chains[chain2], + state.Chains[chain2].OffRamp, + &startBlock, + []uint64{msgSentEvent1.SequenceNumber}, + ), + ), + ) } diff --git a/deployment/ccip/changeset/deploy.go b/deployment/ccip/changeset/deploy.go index 8d2b6a63e12..a3736075c48 100644 --- a/deployment/ccip/changeset/deploy.go +++ b/deployment/ccip/changeset/deploy.go @@ -29,6 +29,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/token_admin_registry" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/weth9" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/burn_mint_erc677" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/multicall3" ) var ( @@ -52,6 +53,7 @@ var ( PriceFeed deployment.ContractType = "PriceFeed" // Note test router maps to a regular router contract. TestRouter deployment.ContractType = "TestRouter" + Multicall3 deployment.ContractType = "Multicall3" CCIPReceiver deployment.ContractType = "CCIPReceiver" BurnMintToken deployment.ContractType = "BurnMintToken" BurnMintTokenPool deployment.ContractType = "BurnMintTokenPool" @@ -125,6 +127,7 @@ func deployPrerequisiteContracts(e deployment.Environment, ab deployment.Address var registryModule *registry_module_owner_custom.RegistryModuleOwnerCustom var rmnProxy *rmn_proxy_contract.RMNProxyContract var r *router.Router + var mc3 *multicall3.Multicall3 if chainExists { weth9Contract = chainState.Weth9 linkTokenContract = chainState.LinkToken @@ -132,6 +135,7 @@ func deployPrerequisiteContracts(e deployment.Environment, ab deployment.Address registryModule = chainState.RegistryModule rmnProxy = chainState.RMNProxyExisting r = chainState.Router + mc3 = chainState.Multicall3 } if rmnProxy == nil { // we want to replicate the mainnet scenario where RMNProxy is already deployed with some existing RMN @@ -269,7 +273,6 @@ func deployPrerequisiteContracts(e deployment.Environment, ab deployment.Address return err } lggr.Infow("deployed linkToken", "addr", linkToken.Address) - linkTokenContract = linkToken.Contract } else { lggr.Infow("linkToken already deployed", "addr", linkTokenContract.Address) } @@ -296,6 +299,25 @@ func deployPrerequisiteContracts(e deployment.Environment, ab deployment.Address } else { e.Logger.Infow("router already deployed", "addr", chainState.Router.Address) } + if deployOpts.Multicall3Enabled && mc3 == nil { + multicall3Contract, err := deployment.DeployContract(e.Logger, chain, ab, + func(chain deployment.Chain) deployment.ContractDeploy[*multicall3.Multicall3] { + multicall3Addr, tx2, multicall3Wrapper, err2 := multicall3.DeployMulticall3( + chain.DeployerKey, + chain.Client, + ) + return deployment.ContractDeploy[*multicall3.Multicall3]{ + multicall3Addr, multicall3Wrapper, tx2, deployment.NewTypeAndVersion(Multicall3, deployment.Version1_0_0), err2, + } + }) + if err != nil { + e.Logger.Errorw("Failed to deploy ccip multicall", "err", err) + return err + } + e.Logger.Infow("deployed ccip multicall", "addr", multicall3Contract.Address) + } else { + e.Logger.Info("ccip multicall already deployed", "addr", mc3.Address) + } if isUSDC { token, pool, messenger, transmitter, err1 := DeployUSDC(e.Logger, chain, ab, rmnProxy.Address(), r.Address()) if err1 != nil { diff --git a/deployment/ccip/changeset/initial_deploy_test.go b/deployment/ccip/changeset/initial_deploy_test.go index ff68659102f..0318af8ffbb 100644 --- a/deployment/ccip/changeset/initial_deploy_test.go +++ b/deployment/ccip/changeset/initial_deploy_test.go @@ -26,6 +26,7 @@ func TestInitialDeploy(t *testing.T) { startBlocks := make(map[uint64]*uint64) // Send a message from each chain to every other chain. expectedSeqNum := make(map[SourceDestPair]uint64) + expectedSeqNumExec := make(map[SourceDestPair][]uint64) for src := range e.Chains { for dest, destChain := range e.Chains { @@ -47,6 +48,10 @@ func TestInitialDeploy(t *testing.T) { SourceChainSelector: src, DestChainSelector: dest, }] = msgSentEvent.SequenceNumber + expectedSeqNumExec[SourceDestPair{ + SourceChainSelector: src, + DestChainSelector: dest, + }] = []uint64{msgSentEvent.SequenceNumber} } } @@ -60,5 +65,5 @@ func TestInitialDeploy(t *testing.T) { //ConfirmGasPriceUpdatedForAll(t, e, state, startBlocks) // //// Wait for all exec reports to land - ConfirmExecWithSeqNrForAll(t, e, state, expectedSeqNum, startBlocks) + ConfirmExecWithSeqNrsForAll(t, e, state, expectedSeqNumExec, startBlocks) } diff --git a/deployment/ccip/changeset/state.go b/deployment/ccip/changeset/state.go index 0e1c76221fc..61b58b59af6 100644 --- a/deployment/ccip/changeset/state.go +++ b/deployment/ccip/changeset/state.go @@ -26,6 +26,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/mock_rmn_contract" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/registry_module_owner_custom" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_home" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/multicall3" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_home" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/fee_quoter" @@ -92,6 +93,7 @@ type CCIPChainState struct { USDCTokenPool *usdc_token_pool.USDCTokenPool MockUSDCTransmitter *mock_usdc_token_transmitter.MockE2EUSDCTransmitter MockUSDCTokenMessenger *mock_usdc_token_messenger.MockE2EUSDCTokenMessenger + Multicall3 *multicall3.Multicall3 } func (c CCIPChainState) GenerateView() (view.ChainView, error) { @@ -413,6 +415,12 @@ func LoadChainState(chain deployment.Chain, addresses map[string]deployment.Type return state, err } state.Receiver = mr + case deployment.NewTypeAndVersion(Multicall3, deployment.Version1_0_0).String(): + mc, err := multicall3.NewMulticall3(common.HexToAddress(address), chain.Client) + if err != nil { + return state, err + } + state.Multicall3 = mc case deployment.NewTypeAndVersion(PriceFeed, deployment.Version1_0_0).String(): feed, err := aggregator_v3_interface.NewAggregatorV3Interface(common.HexToAddress(address), chain.Client) if err != nil { diff --git a/deployment/ccip/changeset/test_assertions.go b/deployment/ccip/changeset/test_assertions.go index 693caa3050d..770b42e6265 100644 --- a/deployment/ccip/changeset/test_assertions.go +++ b/deployment/ccip/changeset/test_assertions.go @@ -14,6 +14,7 @@ import ( "golang.org/x/sync/errgroup" "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" + commonutils "github.com/smartcontractkit/chainlink-common/pkg/utils" "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" "github.com/smartcontractkit/chainlink/deployment/environment/memory" @@ -189,7 +190,7 @@ func ConfirmCommitForAllWithExpectedSeqNums( return nil } - return ConfirmCommitWithExpectedSeqNumRange( + return commonutils.JustError(ConfirmCommitWithExpectedSeqNumRange( t, srcChain, dstChain, @@ -198,7 +199,7 @@ func ConfirmCommitForAllWithExpectedSeqNums( ccipocr3.SeqNumRange{ ccipocr3.SeqNum(expectedSeqNum), ccipocr3.SeqNum(expectedSeqNum), - }) + })) }) } } @@ -233,14 +234,14 @@ func ConfirmCommitWithExpectedSeqNumRange( offRamp *offramp.OffRamp, startBlock *uint64, expectedSeqNumRange ccipocr3.SeqNumRange, -) error { +) (*offramp.OffRampCommitReportAccepted, error) { sink := make(chan *offramp.OffRampCommitReportAccepted) subscription, err := offRamp.WatchCommitReportAccepted(&bind.WatchOpts{ Context: context.Background(), Start: startBlock, }, sink) if err != nil { - return fmt.Errorf("error to subscribe CommitReportAccepted : %w", err) + return nil, fmt.Errorf("error to subscribe CommitReportAccepted : %w", err) } defer subscription.Unsubscribe() @@ -281,17 +282,17 @@ func ConfirmCommitWithExpectedSeqNumRange( if mr.SourceChainSelector == src.Selector && uint64(expectedSeqNumRange.Start()) >= mr.MinSeqNr && uint64(expectedSeqNumRange.End()) <= mr.MaxSeqNr { - t.Logf("Received commit report for [%d, %d] on selector %d from source selector %d expected seq nr range %s, token prices: %v", - mr.MinSeqNr, mr.MaxSeqNr, dest.Selector, src.Selector, expectedSeqNumRange.String(), event.PriceUpdates.TokenPriceUpdates) - return nil + t.Logf("Received commit report for [%d, %d] on selector %d from source selector %d expected seq nr range %s, token prices: %v, tx hash: %s", + mr.MinSeqNr, mr.MaxSeqNr, dest.Selector, src.Selector, expectedSeqNumRange.String(), event.PriceUpdates.TokenPriceUpdates, event.Raw.TxHash.String()) + return event, nil } } } } case subErr := <-subscription.Err(): - return fmt.Errorf("subscription error: %w", subErr) + return nil, fmt.Errorf("subscription error: %w", subErr) case <-timer.C: - return fmt.Errorf("timed out after waiting %s duration for commit report on chain selector %d from source selector %d expected seq nr range %s", + return nil, fmt.Errorf("timed out after waiting %s duration for commit report on chain selector %d from source selector %d expected seq nr range %s", duration.String(), dest.Selector, src.Selector, expectedSeqNumRange.String()) case report := <-sink: if len(report.MerkleRoots) > 0 { @@ -303,7 +304,7 @@ func ConfirmCommitWithExpectedSeqNumRange( uint64(expectedSeqNumRange.End()) <= mr.MaxSeqNr { t.Logf("Received commit report for [%d, %d] on selector %d from source selector %d expected seq nr range %s, token prices: %v", mr.MinSeqNr, mr.MaxSeqNr, dest.Selector, src.Selector, expectedSeqNumRange.String(), report.PriceUpdates.TokenPriceUpdates) - return nil + return report, nil } } } @@ -311,23 +312,24 @@ func ConfirmCommitWithExpectedSeqNumRange( } } -// ConfirmExecWithSeqNrForAll waits for all chains in the environment to execute the given expectedSeqNums. -// If successful, it returns a map that maps the expected sequence numbers to their respective execution state. -// expectedSeqNums is a map of destination chain selector to expected sequence number +// ConfirmExecWithSeqNrsForAll waits for all chains in the environment to execute the given expectedSeqNums. +// If successful, it returns a map that maps the SourceDestPair to the expected sequence number +// to its execution state. +// expectedSeqNums is a map of SourceDestPair to a slice of expected sequence numbers to be executed. // startBlocks is a map of destination chain selector to start block number to start watching from. // If startBlocks is nil, it will start watching from the latest block. -func ConfirmExecWithSeqNrForAll( +func ConfirmExecWithSeqNrsForAll( t *testing.T, e deployment.Environment, state CCIPOnChainState, - expectedSeqNums map[SourceDestPair]uint64, + expectedSeqNums map[SourceDestPair][]uint64, startBlocks map[uint64]*uint64, -) (executionStates map[uint64]int) { +) (executionStates map[SourceDestPair]map[uint64]int) { var ( wg errgroup.Group mx sync.Mutex ) - executionStates = make(map[uint64]int) + executionStates = make(map[SourceDestPair]map[uint64]int) for src, srcChain := range e.Chains { for dest, dstChain := range e.Chains { if src == dest { @@ -345,11 +347,11 @@ func ConfirmExecWithSeqNrForAll( SourceChainSelector: srcChain.Selector, DestChainSelector: dstChain.Selector, }] - if !ok || expectedSeqNum == 0 { + if !ok || len(expectedSeqNum) == 0 { return nil } - executionState, err := ConfirmExecWithSeqNr( + innerExecutionStates, err := ConfirmExecWithSeqNrs( t, srcChain, dstChain, @@ -362,30 +364,39 @@ func ConfirmExecWithSeqNrForAll( } mx.Lock() - executionStates[expectedSeqNum] = executionState + executionStates[SourceDestPair{ + SourceChainSelector: srcChain.Selector, + DestChainSelector: dstChain.Selector, + }] = innerExecutionStates mx.Unlock() return nil }) } } + require.NoError(t, wg.Wait()) return executionStates } -// ConfirmExecWithSeqNr waits for an execution state change on the destination chain with the expected sequence number. +// ConfirmExecWithSeqNrs waits for an execution state change on the destination chain with the expected sequence number. // startBlock is the block number to start watching from. // If startBlock is nil, it will start watching from the latest block. -func ConfirmExecWithSeqNr( +// Returns a map that maps the expected sequence number to its execution state. +func ConfirmExecWithSeqNrs( t *testing.T, source, dest deployment.Chain, offRamp *offramp.OffRamp, startBlock *uint64, - expectedSeqNr uint64, -) (executionState int, err error) { - timer := time.NewTimer(5 * time.Minute) + expectedSeqNrs []uint64, +) (executionStates map[uint64]int, err error) { + if len(expectedSeqNrs) == 0 { + return nil, fmt.Errorf("no expected sequence numbers provided") + } + + timer := time.NewTimer(3 * time.Minute) defer timer.Stop() - tick := time.NewTicker(5 * time.Second) + tick := time.NewTicker(3 * time.Second) defer tick.Stop() sink := make(chan *offramp.OffRampExecutionStateChanged) subscription, err := offRamp.WatchExecutionStateChanged(&bind.WatchOpts{ @@ -393,33 +404,55 @@ func ConfirmExecWithSeqNr( Start: startBlock, }, sink, nil, nil, nil) if err != nil { - return -1, fmt.Errorf("error to subscribe ExecutionStateChanged : %w", err) + return nil, fmt.Errorf("error to subscribe ExecutionStateChanged : %w", err) } defer subscription.Unsubscribe() + + // some state to efficiently track the execution states + // of all the expected sequence numbers. + executionStates = make(map[uint64]int) + seqNrsToWatch := make(map[uint64]struct{}) + for _, seqNr := range expectedSeqNrs { + seqNrsToWatch[seqNr] = struct{}{} + } for { select { case <-tick.C: - scc, executionState := GetExecutionState(t, source, dest, offRamp, expectedSeqNr) - t.Logf("Waiting for ExecutionStateChanged on chain %d (offramp %s) from chain %d with expected sequence number %d, current onchain minSeqNr: %d, execution state: %s", - dest.Selector, offRamp.Address().String(), source.Selector, expectedSeqNr, scc.MinSeqNr, executionStateToString(executionState)) - if executionState == EXECUTION_STATE_SUCCESS || executionState == EXECUTION_STATE_FAILURE { - t.Logf("Observed %s execution state on chain %d (offramp %s) from chain %d with expected sequence number %d", - executionStateToString(executionState), dest.Selector, offRamp.Address().String(), source.Selector, expectedSeqNr) - return int(executionState), nil + for expectedSeqNr := range seqNrsToWatch { + scc, executionState := GetExecutionState(t, source, dest, offRamp, expectedSeqNr) + t.Logf("Waiting for ExecutionStateChanged on chain %d (offramp %s) from chain %d with expected sequence number %d, current onchain minSeqNr: %d, execution state: %s", + dest.Selector, offRamp.Address().String(), source.Selector, expectedSeqNr, scc.MinSeqNr, executionStateToString(executionState)) + if executionState == EXECUTION_STATE_SUCCESS || executionState == EXECUTION_STATE_FAILURE { + t.Logf("Observed %s execution state on chain %d (offramp %s) from chain %d with expected sequence number %d", + executionStateToString(executionState), dest.Selector, offRamp.Address().String(), source.Selector, expectedSeqNr) + executionStates[expectedSeqNr] = int(executionState) + delete(seqNrsToWatch, expectedSeqNr) + if len(seqNrsToWatch) == 0 { + return executionStates, nil + } + } } case execEvent := <-sink: t.Logf("Received ExecutionStateChanged (state %s) for seqNum %d on chain %d (offramp %s) from chain %d", - executionStateToString(execEvent.State), execEvent.SequenceNumber, dest.Selector, offRamp.Address().String(), source.Selector) - if execEvent.SequenceNumber == expectedSeqNr && execEvent.SourceChainSelector == source.Selector { + executionStateToString(execEvent.State), execEvent.SequenceNumber, dest.Selector, offRamp.Address().String(), + source.Selector, + ) + + _, found := seqNrsToWatch[execEvent.SequenceNumber] + if found && execEvent.SourceChainSelector == source.Selector { t.Logf("Received ExecutionStateChanged (state %s) on chain %d (offramp %s) from chain %d with expected sequence number %d", - executionStateToString(execEvent.State), dest.Selector, offRamp.Address().String(), source.Selector, expectedSeqNr) - return int(execEvent.State), nil + executionStateToString(execEvent.State), dest.Selector, offRamp.Address().String(), source.Selector, execEvent.SequenceNumber) + executionStates[execEvent.SequenceNumber] = int(execEvent.State) + delete(seqNrsToWatch, execEvent.SequenceNumber) + if len(seqNrsToWatch) == 0 { + return executionStates, nil + } } case <-timer.C: - return -1, fmt.Errorf("timed out waiting for ExecutionStateChanged on chain %d (offramp %s) from chain %d with expected sequence number %d", - dest.Selector, offRamp.Address().String(), source.Selector, expectedSeqNr) + return nil, fmt.Errorf("timed out waiting for ExecutionStateChanged on chain %d (offramp %s) from chain %d with expected sequence numbers %+v", + dest.Selector, offRamp.Address().String(), source.Selector, expectedSeqNrs) case subErr := <-subscription.Err(): - return -1, fmt.Errorf("subscription error: %w", subErr) + return nil, fmt.Errorf("subscription error: %w", subErr) } } } diff --git a/deployment/ccip/changeset/test_helpers.go b/deployment/ccip/changeset/test_helpers.go index 921d0a222eb..251bff293d5 100644 --- a/deployment/ccip/changeset/test_helpers.go +++ b/deployment/ccip/changeset/test_helpers.go @@ -49,6 +49,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/aggregator_v3_interface" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/mock_ethusd_aggregator_wrapper" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/burn_mint_erc677" + "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" ) const ( @@ -59,6 +60,8 @@ const ( var ( // bytes4 public constant EVM_EXTRA_ARGS_V2_TAG = 0x181dcf10; evmExtraArgsV2Tag = hexutil.MustDecode("0x181dcf10") + + routerABI = abihelpers.MustParseABI(router.RouterABI) ) // Context returns a context with the test's deadline, if available. @@ -406,6 +409,25 @@ func CCIPSendRequest( return tx, blockNum, nil } +// CCIPSendCalldata packs the calldata for the Router's ccipSend method. +// This is expected to be used in Multicall scenarios (i.e multiple ccipSend calls +// in a single transaction). +func CCIPSendCalldata( + destChainSelector uint64, + evm2AnyMessage router.ClientEVM2AnyMessage, +) ([]byte, error) { + calldata, err := routerABI.Methods["ccipSend"].Inputs.Pack( + destChainSelector, + evm2AnyMessage, + ) + if err != nil { + return nil, fmt.Errorf("pack ccipSend calldata: %w", err) + } + + calldata = append(routerABI.Methods["ccipSend"].ID, calldata...) + return calldata, nil +} + func TestSendRequest( t *testing.T, e deployment.Environment, @@ -617,22 +639,22 @@ func ConfirmRequestOnSourceAndDest(t *testing.T, env deployment.Environment, sta fmt.Printf("Request sent for seqnr %d", msgSentEvent.SequenceNumber) require.NoError(t, - ConfirmCommitWithExpectedSeqNumRange(t, env.Chains[sourceCS], env.Chains[destCS], state.Chains[destCS].OffRamp, &startBlock, cciptypes.SeqNumRange{ + commonutils.JustError(ConfirmCommitWithExpectedSeqNumRange(t, env.Chains[sourceCS], env.Chains[destCS], state.Chains[destCS].OffRamp, &startBlock, cciptypes.SeqNumRange{ cciptypes.SeqNum(msgSentEvent.SequenceNumber), cciptypes.SeqNum(msgSentEvent.SequenceNumber), - })) + }))) fmt.Printf("Commit confirmed for seqnr %d", msgSentEvent.SequenceNumber) require.NoError( t, commonutils.JustError( - ConfirmExecWithSeqNr( + ConfirmExecWithSeqNrs( t, env.Chains[sourceCS], env.Chains[destCS], state.Chains[destCS].OffRamp, &startBlock, - msgSentEvent.SequenceNumber, + []uint64{msgSentEvent.SequenceNumber}, ), ), ) diff --git a/integration-tests/smoke/ccip/ccip_batching_test.go b/integration-tests/smoke/ccip/ccip_batching_test.go new file mode 100644 index 00000000000..d85924c1739 --- /dev/null +++ b/integration-tests/smoke/ccip/ccip_batching_test.go @@ -0,0 +1,415 @@ +package smoke + +import ( + "context" + "fmt" + "math/big" + "sync" + "testing" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/require" + "golang.org/x/exp/maps" + + "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" + "github.com/smartcontractkit/chainlink/deployment" + "github.com/smartcontractkit/chainlink/deployment/ccip/changeset" + "github.com/smartcontractkit/chainlink/integration-tests/testsetups" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/offramp" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/multicall3" + "github.com/smartcontractkit/chainlink/v2/core/logger" +) + +func Test_CCIPBatching(t *testing.T) { + // Setup 3 chains, with 2 lanes going to the dest. + lggr := logger.TestLogger(t) + ctx := changeset.Context(t) + // Will load 3 chains when specified by the overrides.toml or env vars (E2E_TEST_SELECTED_NETWORK). + // See e2e-tests.yml. + e, _, _ := testsetups.NewLocalDevEnvironmentWithDefaultPrice(t, lggr, &changeset.TestConfigs{ + IsUSDC: false, + IsMultiCall3: true, // needed for this test + }) + + state, err := changeset.LoadOnchainState(e.Env) + require.NoError(t, err) + + allChainSelectors := maps.Keys(e.Env.Chains) + require.Len(t, allChainSelectors, 3, "this test expects 3 chains") + sourceChain1 := allChainSelectors[0] + sourceChain2 := allChainSelectors[1] + destChain := allChainSelectors[2] + t.Log("All chain selectors:", allChainSelectors, + ", home chain selector:", e.HomeChainSel, + ", feed chain selector:", e.FeedChainSel, + ", source chain selector 1:", sourceChain1, + ", source chain selector 2:", sourceChain2, + ", dest chain selector:", destChain, + ) + + // connect sourceChain1 and sourceChain2 to destChain + require.NoError(t, changeset.AddLaneWithDefaultPrices(e.Env, state, sourceChain1, destChain)) + require.NoError(t, changeset.AddLaneWithDefaultPrices(e.Env, state, sourceChain2, destChain)) + + const ( + numMessages = 5 + ) + var ( + startSeqNum = map[uint64]ccipocr3.SeqNum{ + sourceChain1: 1, + sourceChain2: 1, + } + endSeqNum = map[uint64]ccipocr3.SeqNum{ + sourceChain1: ccipocr3.SeqNum(numMessages), + sourceChain2: ccipocr3.SeqNum(numMessages), + } + ) + + t.Run("batch data only messages from single source", func(t *testing.T) { + err := sendMessages( + ctx, + t, + e.Env.Chains[sourceChain1], + e.Env.Chains[sourceChain1].DeployerKey, + state.Chains[sourceChain1].OnRamp, + state.Chains[sourceChain1].Router, + state.Chains[sourceChain1].Multicall3, + destChain, + numMessages, + common.LeftPadBytes(state.Chains[destChain].Receiver.Address().Bytes(), 32), + ) + require.NoError(t, err) + + _, err = changeset.ConfirmCommitWithExpectedSeqNumRange( + t, + e.Env.Chains[sourceChain1], + e.Env.Chains[destChain], + state.Chains[destChain].OffRamp, + nil, + ccipocr3.NewSeqNumRange(startSeqNum[sourceChain1], endSeqNum[sourceChain1]), + ) + require.NoErrorf(t, err, "failed to confirm commit from chain %d", sourceChain1) + + states, err := changeset.ConfirmExecWithSeqNrs( + t, + e.Env.Chains[sourceChain1], + e.Env.Chains[destChain], + state.Chains[destChain].OffRamp, + nil, + genSeqNrRange(startSeqNum[sourceChain1], endSeqNum[sourceChain1]), + ) + require.NoError(t, err) + // assert that all states are successful + for _, state := range states { + require.Equal(t, changeset.EXECUTION_STATE_SUCCESS, state) + } + + startSeqNum[sourceChain1] = endSeqNum[sourceChain1] + 1 + endSeqNum[sourceChain1] = startSeqNum[sourceChain1] + ccipocr3.SeqNum(numMessages) - 1 + }) + + t.Run("batch data only messages from multiple sources", func(t *testing.T) { + var ( + wg sync.WaitGroup + sourceChains = []uint64{sourceChain1, sourceChain2} + errs = make(chan error, len(sourceChains)) + ) + + for _, srcChain := range sourceChains { + wg.Add(1) + go sendMessagesAsync( + ctx, + t, + e, + state, + srcChain, + destChain, + numMessages, + &wg, + errs, + ) + } + + wg.Wait() + + var i int + for i < len(sourceChains) { + select { + case err := <-errs: + require.NoError(t, err) + i++ + case <-ctx.Done(): + require.FailNow(t, "didn't get all errors before test context was done") + } + } + + // confirm the commit reports + outputErrs := make(chan outputErr[*offramp.OffRampCommitReportAccepted], len(sourceChains)) + for _, srcChain := range sourceChains { + wg.Add(1) + go assertCommitReportsAsync( + t, + e, + state, + srcChain, + destChain, + startSeqNum[srcChain], + endSeqNum[srcChain], + &wg, + outputErrs, + ) + } + + t.Log("waiting for commit report") + wg.Wait() + + i = 0 + var reports []*offramp.OffRampCommitReportAccepted + for i < len(sourceChains) { + select { + case outputErr := <-outputErrs: + require.NoError(t, outputErr.err) + reports = append(reports, outputErr.output) + i++ + case <-ctx.Done(): + require.FailNow(t, "didn't get all commit reports before test context was done") + } + } + + // the reports should be the same for both, since both roots should be batched within + // that one report. + require.Lenf(t, reports, len(sourceChains), "expected %d commit reports", len(sourceChains)) + require.NotNil(t, reports[0], "commit report should not be nil") + require.NotNil(t, reports[1], "commit report should not be nil") + // TODO: this assertion is failing, despite messages being sent at the same time. + // require.Equal(t, reports[0], reports[1], "commit reports should be the same") + + // confirm execution + execErrs := make(chan outputErr[map[uint64]int], len(sourceChains)) + for _, srcChain := range sourceChains { + wg.Add(1) + go assertExecAsync( + t, + e, + state, + srcChain, + destChain, + genSeqNrRange(startSeqNum[srcChain], endSeqNum[srcChain]), + &wg, + execErrs, + ) + } + + t.Log("waiting for exec reports") + wg.Wait() + + i = 0 + var execStates []map[uint64]int + for i < len(sourceChains) { + select { + case outputErr := <-execErrs: + require.NoError(t, outputErr.err) + execStates = append(execStates, outputErr.output) + i++ + case <-ctx.Done(): + require.FailNow(t, "didn't get all exec reports before test context was done") + } + } + + // assert that all states are successful + for _, states := range execStates { + for _, state := range states { + require.Equal(t, changeset.EXECUTION_STATE_SUCCESS, state) + } + } + }) +} + +type outputErr[T any] struct { + output T + err error +} + +func assertExecAsync( + t *testing.T, + e changeset.DeployedEnv, + state changeset.CCIPOnChainState, + sourceChainSelector, + destChainSelector uint64, + seqNums []uint64, + wg *sync.WaitGroup, + errs chan<- outputErr[map[uint64]int], +) { + defer wg.Done() + states, err := changeset.ConfirmExecWithSeqNrs( + t, + e.Env.Chains[sourceChainSelector], + e.Env.Chains[destChainSelector], + state.Chains[destChainSelector].OffRamp, + nil, + seqNums, + ) + + errs <- outputErr[map[uint64]int]{states, err} +} + +func assertCommitReportsAsync( + t *testing.T, + e changeset.DeployedEnv, + state changeset.CCIPOnChainState, + sourceChainSelector, + destChainSelector uint64, + startSeqNum, + endSeqNum ccipocr3.SeqNum, + wg *sync.WaitGroup, + errs chan<- outputErr[*offramp.OffRampCommitReportAccepted], +) { + defer wg.Done() + commitReport, err := changeset.ConfirmCommitWithExpectedSeqNumRange( + t, + e.Env.Chains[sourceChainSelector], + e.Env.Chains[destChainSelector], + state.Chains[destChainSelector].OffRamp, + nil, + ccipocr3.NewSeqNumRange(startSeqNum, endSeqNum), + ) + + errs <- outputErr[*offramp.OffRampCommitReportAccepted]{commitReport, err} +} + +func sendMessagesAsync( + ctx context.Context, + t *testing.T, + e changeset.DeployedEnv, + state changeset.CCIPOnChainState, + sourceChainSelector, + destChainSelector uint64, + numMessages int, + wg *sync.WaitGroup, + out chan<- error, +) { + defer wg.Done() + err := sendMessages( + ctx, + t, + e.Env.Chains[sourceChainSelector], + e.Env.Chains[sourceChainSelector].DeployerKey, + state.Chains[sourceChainSelector].OnRamp, + state.Chains[sourceChainSelector].Router, + state.Chains[sourceChainSelector].Multicall3, + destChainSelector, + numMessages, + common.LeftPadBytes(state.Chains[destChainSelector].Receiver.Address().Bytes(), 32), + ) + t.Log("sendMessagesAsync error:", err, ", writing to channel") + out <- err +} + +func sendMessages( + ctx context.Context, + t *testing.T, + sourceChain deployment.Chain, + sourceTransactOpts *bind.TransactOpts, + sourceOnRamp *onramp.OnRamp, + sourceRouter *router.Router, + sourceMulticall3 *multicall3.Multicall3, + destChainSelector uint64, + numMessages int, + receiver []byte, +) error { + calls, totalValue, err := genMessages( + ctx, + sourceRouter, + destChainSelector, + numMessages, + receiver, + ) + if err != nil { + return fmt.Errorf("generate messages: %w", err) + } + + // Send the tx with the messages through the multicall + tx, err := sourceMulticall3.Aggregate3Value( + &bind.TransactOpts{ + From: sourceTransactOpts.From, + Signer: sourceTransactOpts.Signer, + Value: totalValue, + }, + calls, + ) + _, err = deployment.ConfirmIfNoError(sourceChain, tx, err) + if err != nil { + return fmt.Errorf("send messages via multicall3: %w", err) + } + + // check that the message was emitted + iter, err := sourceOnRamp.FilterCCIPMessageSent( + nil, []uint64{destChainSelector}, nil, + ) + if err != nil { + return fmt.Errorf("get message sent event: %w", err) + } + defer iter.Close() + + // there should be numMessages messages emitted + for i := 0; i < numMessages; i++ { + if !iter.Next() { + return fmt.Errorf("expected %d messages, got %d", numMessages, i) + } + t.Logf("Message id of msg %d: %x", i, iter.Event.Message.Header.MessageId[:]) + } + + return nil +} + +func genMessages( + ctx context.Context, + sourceRouter *router.Router, + destChainSelector uint64, + count int, + receiver []byte, +) (calls []multicall3.Multicall3Call3Value, totalValue *big.Int, err error) { + totalValue = big.NewInt(0) + for i := 0; i < count; i++ { + msg := router.ClientEVM2AnyMessage{ + Receiver: receiver, + Data: []byte(fmt.Sprintf("hello world %d", i)), + TokenAmounts: nil, + FeeToken: common.HexToAddress("0x0"), + ExtraArgs: nil, + } + + fee, err := sourceRouter.GetFee(&bind.CallOpts{Context: ctx}, destChainSelector, msg) + if err != nil { + return nil, nil, fmt.Errorf("router get fee: %w", err) + } + + totalValue.Add(totalValue, fee) + + calldata, err := changeset.CCIPSendCalldata(destChainSelector, msg) + if err != nil { + return nil, nil, fmt.Errorf("generate calldata: %w", err) + } + + calls = append(calls, multicall3.Multicall3Call3Value{ + Target: sourceRouter.Address(), + AllowFailure: false, + CallData: calldata, + Value: fee, + }) + } + + return calls, totalValue, nil +} + +// creates an array of uint64 from start to end inclusive +func genSeqNrRange(start, end ccipocr3.SeqNum) []uint64 { + var seqNrs []uint64 + for i := start; i <= end; i++ { + seqNrs = append(seqNrs, uint64(i)) + } + return seqNrs +} diff --git a/integration-tests/smoke/ccip/ccip_messaging_test.go b/integration-tests/smoke/ccip/ccip_messaging_test.go index 696655d960c..1eb16838c92 100644 --- a/integration-tests/smoke/ccip/ccip_messaging_test.go +++ b/integration-tests/smoke/ccip/ccip_messaging_test.go @@ -318,11 +318,18 @@ func runMessagingTestCase( FeeToken: common.HexToAddress("0x0"), ExtraArgs: extraArgs, }) - expectedSeqNum := make(map[changeset.SourceDestPair]uint64) - expectedSeqNum[changeset.SourceDestPair{ - SourceChainSelector: tc.sourceChain, - DestChainSelector: tc.destChain, - }] = msgSentEvent.SequenceNumber + expectedSeqNum := map[changeset.SourceDestPair]uint64{ + { + SourceChainSelector: tc.sourceChain, + DestChainSelector: tc.destChain, + }: msgSentEvent.SequenceNumber, + } + expectedSeqNumExec := map[changeset.SourceDestPair][]uint64{ + { + SourceChainSelector: tc.sourceChain, + DestChainSelector: tc.destChain, + }: {msgSentEvent.SequenceNumber}, + } out.msgSentEvent = msgSentEvent // hack @@ -332,16 +339,22 @@ func runMessagingTestCase( } changeset.ConfirmCommitForAllWithExpectedSeqNums(tc.t, tc.deployedEnv.Env, tc.onchainState, expectedSeqNum, startBlocks) - execStates := changeset.ConfirmExecWithSeqNrForAll(tc.t, tc.deployedEnv.Env, tc.onchainState, expectedSeqNum, startBlocks) + execStates := changeset.ConfirmExecWithSeqNrsForAll(tc.t, tc.deployedEnv.Env, tc.onchainState, expectedSeqNumExec, startBlocks) require.Equalf( tc.t, expectedExecutionState, - execStates[msgSentEvent.SequenceNumber], + execStates[changeset.SourceDestPair{ + SourceChainSelector: tc.sourceChain, + DestChainSelector: tc.destChain, + }][msgSentEvent.SequenceNumber], "wrong execution state for seq nr %d, expected %d, got %d", msgSentEvent.SequenceNumber, expectedExecutionState, - execStates[msgSentEvent.SequenceNumber], + execStates[changeset.SourceDestPair{ + SourceChainSelector: tc.sourceChain, + DestChainSelector: tc.destChain, + }][msgSentEvent.SequenceNumber], ) // check the sender latestNonce on the dest, should be incremented diff --git a/integration-tests/smoke/ccip/ccip_rmn_test.go b/integration-tests/smoke/ccip/ccip_rmn_test.go index c49d227b410..d3b7205e5e5 100644 --- a/integration-tests/smoke/ccip/ccip_rmn_test.go +++ b/integration-tests/smoke/ccip/ccip_rmn_test.go @@ -342,6 +342,7 @@ func runRmnTestCase(t *testing.T, tc rmnTestCase) { // Need to keep track of the block number for each chain so that event subscription can be done from that block. startBlocks := make(map[uint64]*uint64) expectedSeqNum := make(map[changeset.SourceDestPair]uint64) + expectedSeqNumExec := make(map[changeset.SourceDestPair][]uint64) for _, msg := range tc.messagesToSend { fromChain := chainSelectors[msg.fromChainIdx] toChain := chainSelectors[msg.toChainIdx] @@ -358,6 +359,10 @@ func runRmnTestCase(t *testing.T, tc rmnTestCase) { SourceChainSelector: fromChain, DestChainSelector: toChain, }] = msgSentEvent.SequenceNumber + expectedSeqNumExec[changeset.SourceDestPair{ + SourceChainSelector: fromChain, + DestChainSelector: toChain, + }] = []uint64{msgSentEvent.SequenceNumber} t.Logf("Sent message from chain %d to chain %d with seqNum %d", fromChain, toChain, msgSentEvent.SequenceNumber) } @@ -390,7 +395,7 @@ func runRmnTestCase(t *testing.T, tc rmnTestCase) { if tc.waitForExec { t.Logf("⌛ Waiting for exec reports...") - changeset.ConfirmExecWithSeqNrForAll(t, envWithRMN.Env, onChainState, expectedSeqNum, startBlocks) + changeset.ConfirmExecWithSeqNrsForAll(t, envWithRMN.Env, onChainState, expectedSeqNumExec, startBlocks) t.Logf("✅ Exec report") } } diff --git a/integration-tests/smoke/ccip/ccip_test.go b/integration-tests/smoke/ccip/ccip_test.go index 5a89f9a5f2d..ee740496fa7 100644 --- a/integration-tests/smoke/ccip/ccip_test.go +++ b/integration-tests/smoke/ccip/ccip_test.go @@ -11,6 +11,7 @@ import ( "github.com/smartcontractkit/chainlink/deployment/ccip/changeset" "github.com/smartcontractkit/chainlink/integration-tests/testsetups" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router" "github.com/smartcontractkit/chainlink/v2/core/logger" ) @@ -29,6 +30,7 @@ func TestInitialDeployOnLocal(t *testing.T) { startBlocks := make(map[uint64]*uint64) // Send a message from each chain to every other chain. expectedSeqNum := make(map[changeset.SourceDestPair]uint64) + expectedSeqNumExec := make(map[changeset.SourceDestPair][]uint64) for src := range e.Chains { for dest, destChain := range e.Chains { if src == dest { @@ -49,6 +51,10 @@ func TestInitialDeployOnLocal(t *testing.T) { SourceChainSelector: src, DestChainSelector: dest, }] = msgSentEvent.SequenceNumber + expectedSeqNumExec[changeset.SourceDestPair{ + SourceChainSelector: src, + DestChainSelector: dest, + }] = []uint64{msgSentEvent.SequenceNumber} } } @@ -65,7 +71,7 @@ func TestInitialDeployOnLocal(t *testing.T) { } // Wait for all exec reports to land - changeset.ConfirmExecWithSeqNrForAll(t, e, state, expectedSeqNum, startBlocks) + changeset.ConfirmExecWithSeqNrsForAll(t, e, state, expectedSeqNumExec, startBlocks) // TODO: Apply the proposal. } @@ -95,6 +101,7 @@ func TestTokenTransfer(t *testing.T) { startBlocks := make(map[uint64]*uint64) // Send a message from each chain to every other chain. expectedSeqNum := make(map[changeset.SourceDestPair]uint64) + expectedSeqNumExec := make(map[changeset.SourceDestPair][]uint64) twoCoins := new(big.Int).Mul(big.NewInt(1e18), big.NewInt(2)) tx, err := srcToken.Mint( @@ -146,35 +153,37 @@ func TestTokenTransfer(t *testing.T) { startBlocks[dest] = &block var ( - receiver = common.LeftPadBytes(state.Chains[dest].Receiver.Address().Bytes(), 32) - data = []byte("hello world") - feeToken = common.HexToAddress("0x0") + receiver = common.LeftPadBytes(state.Chains[dest].Receiver.Address().Bytes(), 32) + data = []byte("hello world") + feeToken = common.HexToAddress("0x0") + msgSentEvent *onramp.OnRampCCIPMessageSent ) if src == tenv.HomeChainSel && dest == tenv.FeedChainSel { - msgSentEvent := changeset.TestSendRequest(t, e, state, src, dest, false, router.ClientEVM2AnyMessage{ + msgSentEvent = changeset.TestSendRequest(t, e, state, src, dest, false, router.ClientEVM2AnyMessage{ Receiver: receiver, Data: data, TokenAmounts: tokens[src], FeeToken: feeToken, ExtraArgs: nil, }) - expectedSeqNum[changeset.SourceDestPair{ - SourceChainSelector: src, - DestChainSelector: dest, - }] = msgSentEvent.SequenceNumber } else { - msgSentEvent := changeset.TestSendRequest(t, e, state, src, dest, false, router.ClientEVM2AnyMessage{ + msgSentEvent = changeset.TestSendRequest(t, e, state, src, dest, false, router.ClientEVM2AnyMessage{ Receiver: receiver, Data: data, TokenAmounts: nil, FeeToken: feeToken, ExtraArgs: nil, }) - expectedSeqNum[changeset.SourceDestPair{ - SourceChainSelector: src, - DestChainSelector: dest, - }] = msgSentEvent.SequenceNumber } + + expectedSeqNum[changeset.SourceDestPair{ + SourceChainSelector: src, + DestChainSelector: dest, + }] = msgSentEvent.SequenceNumber + expectedSeqNumExec[changeset.SourceDestPair{ + SourceChainSelector: src, + DestChainSelector: dest, + }] = []uint64{msgSentEvent.SequenceNumber} } } @@ -191,7 +200,7 @@ func TestTokenTransfer(t *testing.T) { } // Wait for all exec reports to land - changeset.ConfirmExecWithSeqNrForAll(t, e, state, expectedSeqNum, startBlocks) + changeset.ConfirmExecWithSeqNrsForAll(t, e, state, expectedSeqNumExec, startBlocks) balance, err := dstToken.BalanceOf(nil, state.Chains[tenv.FeedChainSel].Receiver.Address()) require.NoError(t, err) diff --git a/integration-tests/smoke/ccip/ccip_usdc_test.go b/integration-tests/smoke/ccip/ccip_usdc_test.go index 9e8a0dd57a5..ccc97a72715 100644 --- a/integration-tests/smoke/ccip/ccip_usdc_test.go +++ b/integration-tests/smoke/ccip/ccip_usdc_test.go @@ -217,6 +217,7 @@ func transferAndWaitForSuccess( ) { startBlocks := make(map[uint64]*uint64) expectedSeqNum := make(map[changeset.SourceDestPair]uint64) + expectedSeqNumExec := make(map[changeset.SourceDestPair][]uint64) latesthdr, err := env.Chains[destChain].Client.HeaderByNumber(testcontext.Get(t), nil) require.NoError(t, err) @@ -234,12 +235,16 @@ func transferAndWaitForSuccess( SourceChainSelector: sourceChain, DestChainSelector: destChain, }] = msgSentEvent.SequenceNumber + expectedSeqNumExec[changeset.SourceDestPair{ + SourceChainSelector: sourceChain, + DestChainSelector: destChain, + }] = []uint64{msgSentEvent.SequenceNumber} // Wait for all commit reports to land. changeset.ConfirmCommitForAllWithExpectedSeqNums(t, env, state, expectedSeqNum, startBlocks) // Wait for all exec reports to land - changeset.ConfirmExecWithSeqNrForAll(t, env, state, expectedSeqNum, startBlocks) + changeset.ConfirmExecWithSeqNrsForAll(t, env, state, expectedSeqNumExec, startBlocks) } func waitForTheTokenBalance( diff --git a/integration-tests/smoke/ccip/fee_boosting_test.go b/integration-tests/smoke/ccip/fee_boosting_test.go index 37d6d8523ce..1f9b1f9083a 100644 --- a/integration-tests/smoke/ccip/fee_boosting_test.go +++ b/integration-tests/smoke/ccip/fee_boosting_test.go @@ -92,6 +92,7 @@ func runFeeboostTestCase(tc feeboostTestCase) { startBlocks := make(map[uint64]*uint64) expectedSeqNum := make(map[changeset.SourceDestPair]uint64) + expectedSeqNumExec := make(map[changeset.SourceDestPair][]uint64) msgSentEvent := changeset.TestSendRequest(tc.t, tc.deployedEnv.Env, tc.onchainState, tc.sourceChain, tc.destChain, false, router.ClientEVM2AnyMessage{ Receiver: common.LeftPadBytes(tc.onchainState.Chains[tc.destChain].Receiver.Address().Bytes(), 32), Data: []byte("message that needs fee boosting"), @@ -103,6 +104,10 @@ func runFeeboostTestCase(tc feeboostTestCase) { SourceChainSelector: tc.sourceChain, DestChainSelector: tc.destChain, }] = msgSentEvent.SequenceNumber + expectedSeqNumExec[changeset.SourceDestPair{ + SourceChainSelector: tc.sourceChain, + DestChainSelector: tc.destChain, + }] = []uint64{msgSentEvent.SequenceNumber} // hack time.Sleep(30 * time.Second) @@ -112,5 +117,5 @@ func runFeeboostTestCase(tc feeboostTestCase) { changeset.ReplayLogs(tc.t, tc.deployedEnv.Env.Offchain, replayBlocks) changeset.ConfirmCommitForAllWithExpectedSeqNums(tc.t, tc.deployedEnv.Env, tc.onchainState, expectedSeqNum, startBlocks) - changeset.ConfirmExecWithSeqNrForAll(tc.t, tc.deployedEnv.Env, tc.onchainState, expectedSeqNum, startBlocks) + changeset.ConfirmExecWithSeqNrsForAll(tc.t, tc.deployedEnv.Env, tc.onchainState, expectedSeqNumExec, startBlocks) } diff --git a/integration-tests/testconfig/ccip/ccip.toml b/integration-tests/testconfig/ccip/ccip.toml index 5ccda6ab4e3..85e645ed0b9 100644 --- a/integration-tests/testconfig/ccip/ccip.toml +++ b/integration-tests/testconfig/ccip/ccip.toml @@ -39,6 +39,23 @@ evm_supports_eip1559 = true evm_default_gas_limit = 6000000 evm_finality_depth = 1 +[Network.EVMNetworks.SIMULATED_3] +evm_name = 'chain-3337' +evm_chain_id = 3337 +evm_keys = [ + "59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d", + "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", +] +evm_simulated = true +client_implementation = 'Ethereum' +evm_chainlink_transaction_limit = 50000 +evm_transaction_timeout = '2m' +evm_minimum_confirmations = 1 +evm_gas_estimation_buffer = 1000 +evm_supports_eip1559 = true +evm_default_gas_limit = 6000000 +evm_finality_depth = 1 + [NodeConfig] BaseConfigTOML = """ [Feature] @@ -151,6 +168,21 @@ addresses_to_fund = [ "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", ] +[CCIP.PrivateEthereumNetworks.SIMULATED_3] +ethereum_version = "eth1" +execution_layer = "geth" + +[CCIP.PrivateEthereumNetworks.SIMULATED_3.EthereumChainConfig] +seconds_per_slot = 3 +slots_per_epoch = 2 +genesis_delay = 15 +validator_count = 4 +chain_id = 3337 +addresses_to_fund = [ + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", +] + [Seth] # Seth specific configuration, no need for generating ephemeral addresses for ccip-tests. -ephemeral_addresses_number = 0 \ No newline at end of file +ephemeral_addresses_number = 0 diff --git a/integration-tests/testsetups/test_helpers.go b/integration-tests/testsetups/test_helpers.go index ed3e6aafea5..f11b343f155 100644 --- a/integration-tests/testsetups/test_helpers.go +++ b/integration-tests/testsetups/test_helpers.go @@ -92,6 +92,11 @@ func NewLocalDevEnvironment( linkPrice, wethPrice *big.Int, tCfg *changeset.TestConfigs, ) (changeset.DeployedEnv, *test_env.CLClusterTestEnv, tc.TestConfig) { + if tCfg == nil { + // set to the default constructed value + tCfg = &changeset.TestConfigs{} + } + ctx := testcontext.Get(t) // create a local docker environment with simulated chains and job-distributor // we cannot create the chainlink nodes yet as we need to deploy the capability registry first @@ -132,7 +137,7 @@ func NewLocalDevEnvironment( require.NoError(t, err) allChains := env.AllChainSelectors() var usdcChains []uint64 - if tCfg != nil && tCfg.IsUSDC { + if tCfg.IsUSDC { usdcChains = allChains } mcmsCfgPerChain := commontypes.MCMSWithTimelockConfig{ @@ -167,6 +172,7 @@ func NewLocalDevEnvironment( ChainSelectors: allChains, Opts: []changeset.PrerequisiteOpt{ changeset.WithUSDCChains(usdcChains), + changeset.WithMulticall3(tCfg.IsMultiCall3), }, }, },