From 63ec29e7feec8e34a18af8ce61f131a8feabd3c7 Mon Sep 17 00:00:00 2001 From: Ryan Hall Date: Wed, 11 Sep 2024 12:52:56 -0400 Subject: [PATCH] add CCIPEncodingUtils contract and gethwrapper --- .../scripts/native_solc_compile_all_ccip | 4 + contracts/src/v0.8/ccip/CCIPEncodingUtils.sol | 16 ++ .../ccip_encoding_utils.go | 209 ++++++++++++++++++ ...rapper-dependency-versions-do-not-edit.txt | 1 + core/gethwrappers/ccip/go_generate.go | 3 + 5 files changed, 233 insertions(+) create mode 100644 contracts/src/v0.8/ccip/CCIPEncodingUtils.sol create mode 100644 core/gethwrappers/ccip/generated/ccip_encoding_utils/ccip_encoding_utils.go diff --git a/contracts/scripts/native_solc_compile_all_ccip b/contracts/scripts/native_solc_compile_all_ccip index 7c4ff56bd8..fd0edf20c2 100755 --- a/contracts/scripts/native_solc_compile_all_ccip +++ b/contracts/scripts/native_solc_compile_all_ccip @@ -102,6 +102,10 @@ compileContract ccip/test/mocks/MockE2EUSDCTokenMessenger.sol compileContract ccip/test/mocks/MockE2EUSDCTransmitter.sol compileContract ccip/test/WETH9.sol + +# Encoding Utils +compileContract ccip/CCIPEncodingUtils.sol + # Customer contracts compileContract ccip/pools/USDC/USDCTokenPool.sol diff --git a/contracts/src/v0.8/ccip/CCIPEncodingUtils.sol b/contracts/src/v0.8/ccip/CCIPEncodingUtils.sol new file mode 100644 index 0000000000..29f0049523 --- /dev/null +++ b/contracts/src/v0.8/ccip/CCIPEncodingUtils.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity 0.8.24; + +import {RMNRemote} from "./rmn/RMNRemote.sol"; + +/// @dev this file exposes structs that are otherwise internal to the CCIP codebase +/// doing this allows those structs to be encoded and decoded with type safety in offchain code +/// and tests because generated wrappers are available +contract CCIPEncodingUtils { + constructor() { + revert("do not deploy"); + } + + /// @dev the RMN Report struct is used in integration / E2E tests + function _rmnReport(RMNRemote.Report memory rmnReport) external {} +} diff --git a/core/gethwrappers/ccip/generated/ccip_encoding_utils/ccip_encoding_utils.go b/core/gethwrappers/ccip/generated/ccip_encoding_utils/ccip_encoding_utils.go new file mode 100644 index 0000000000..37f5749714 --- /dev/null +++ b/core/gethwrappers/ccip/generated/ccip_encoding_utils/ccip_encoding_utils.go @@ -0,0 +1,209 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package ccip_encoding_utils + +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 InternalMerkleRoot struct { + SourceChainSelector uint64 + OnRampAddress []byte + MinSeqNr uint64 + MaxSeqNr uint64 + MerkleRoot [32]byte +} + +type RMNRemoteReport struct { + DestChainId *big.Int + DestChainSelector uint64 + RmnRemoteContractAddress common.Address + OfframpAddress common.Address + RmnHomeContractConfigDigest [32]byte + DestLaneUpdates []InternalMerkleRoot +} + +var EncodingUtilsMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"destChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"destChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"address\",\"name\":\"rmnRemoteContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"offrampAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"rmnHomeContractConfigDigest\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint64\",\"name\":\"sourceChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"onRampAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"minSeqNr\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"maxSeqNr\",\"type\":\"uint64\"},{\"internalType\":\"bytes32\",\"name\":\"merkleRoot\",\"type\":\"bytes32\"}],\"internalType\":\"structInternal.MerkleRoot[]\",\"name\":\"destLaneUpdates\",\"type\":\"tuple[]\"}],\"internalType\":\"structRMNRemote.Report\",\"name\":\"rmnReport\",\"type\":\"tuple\"}],\"name\":\"_rmnReport\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x608060405234801561001057600080fd5b5060405162461bcd60e51b815260206004820152600d60248201526c646f206e6f74206465706c6f7960981b604482015260640160405180910390fdfe", +} + +var EncodingUtilsABI = EncodingUtilsMetaData.ABI + +var EncodingUtilsBin = EncodingUtilsMetaData.Bin + +func DeployEncodingUtils(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *EncodingUtils, error) { + parsed, err := EncodingUtilsMetaData.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(EncodingUtilsBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &EncodingUtils{address: address, abi: *parsed, EncodingUtilsCaller: EncodingUtilsCaller{contract: contract}, EncodingUtilsTransactor: EncodingUtilsTransactor{contract: contract}, EncodingUtilsFilterer: EncodingUtilsFilterer{contract: contract}}, nil +} + +type EncodingUtils struct { + address common.Address + abi abi.ABI + EncodingUtilsCaller + EncodingUtilsTransactor + EncodingUtilsFilterer +} + +type EncodingUtilsCaller struct { + contract *bind.BoundContract +} + +type EncodingUtilsTransactor struct { + contract *bind.BoundContract +} + +type EncodingUtilsFilterer struct { + contract *bind.BoundContract +} + +type EncodingUtilsSession struct { + Contract *EncodingUtils + CallOpts bind.CallOpts + TransactOpts bind.TransactOpts +} + +type EncodingUtilsCallerSession struct { + Contract *EncodingUtilsCaller + CallOpts bind.CallOpts +} + +type EncodingUtilsTransactorSession struct { + Contract *EncodingUtilsTransactor + TransactOpts bind.TransactOpts +} + +type EncodingUtilsRaw struct { + Contract *EncodingUtils +} + +type EncodingUtilsCallerRaw struct { + Contract *EncodingUtilsCaller +} + +type EncodingUtilsTransactorRaw struct { + Contract *EncodingUtilsTransactor +} + +func NewEncodingUtils(address common.Address, backend bind.ContractBackend) (*EncodingUtils, error) { + abi, err := abi.JSON(strings.NewReader(EncodingUtilsABI)) + if err != nil { + return nil, err + } + contract, err := bindEncodingUtils(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &EncodingUtils{address: address, abi: abi, EncodingUtilsCaller: EncodingUtilsCaller{contract: contract}, EncodingUtilsTransactor: EncodingUtilsTransactor{contract: contract}, EncodingUtilsFilterer: EncodingUtilsFilterer{contract: contract}}, nil +} + +func NewEncodingUtilsCaller(address common.Address, caller bind.ContractCaller) (*EncodingUtilsCaller, error) { + contract, err := bindEncodingUtils(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &EncodingUtilsCaller{contract: contract}, nil +} + +func NewEncodingUtilsTransactor(address common.Address, transactor bind.ContractTransactor) (*EncodingUtilsTransactor, error) { + contract, err := bindEncodingUtils(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &EncodingUtilsTransactor{contract: contract}, nil +} + +func NewEncodingUtilsFilterer(address common.Address, filterer bind.ContractFilterer) (*EncodingUtilsFilterer, error) { + contract, err := bindEncodingUtils(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &EncodingUtilsFilterer{contract: contract}, nil +} + +func bindEncodingUtils(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := EncodingUtilsMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +func (_EncodingUtils *EncodingUtilsRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _EncodingUtils.Contract.EncodingUtilsCaller.contract.Call(opts, result, method, params...) +} + +func (_EncodingUtils *EncodingUtilsRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _EncodingUtils.Contract.EncodingUtilsTransactor.contract.Transfer(opts) +} + +func (_EncodingUtils *EncodingUtilsRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _EncodingUtils.Contract.EncodingUtilsTransactor.contract.Transact(opts, method, params...) +} + +func (_EncodingUtils *EncodingUtilsCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _EncodingUtils.Contract.contract.Call(opts, result, method, params...) +} + +func (_EncodingUtils *EncodingUtilsTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _EncodingUtils.Contract.contract.Transfer(opts) +} + +func (_EncodingUtils *EncodingUtilsTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _EncodingUtils.Contract.contract.Transact(opts, method, params...) +} + +func (_EncodingUtils *EncodingUtilsTransactor) RmnReport(opts *bind.TransactOpts, rmnReport RMNRemoteReport) (*types.Transaction, error) { + return _EncodingUtils.contract.Transact(opts, "_rmnReport", rmnReport) +} + +func (_EncodingUtils *EncodingUtilsSession) RmnReport(rmnReport RMNRemoteReport) (*types.Transaction, error) { + return _EncodingUtils.Contract.RmnReport(&_EncodingUtils.TransactOpts, rmnReport) +} + +func (_EncodingUtils *EncodingUtilsTransactorSession) RmnReport(rmnReport RMNRemoteReport) (*types.Transaction, error) { + return _EncodingUtils.Contract.RmnReport(&_EncodingUtils.TransactOpts, rmnReport) +} + +func (_EncodingUtils *EncodingUtils) Address() common.Address { + return _EncodingUtils.address +} + +type EncodingUtilsInterface interface { + RmnReport(opts *bind.TransactOpts, rmnReport RMNRemoteReport) (*types.Transaction, error) + + Address() common.Address +} diff --git a/core/gethwrappers/ccip/generation/generated-wrapper-dependency-versions-do-not-edit.txt b/core/gethwrappers/ccip/generation/generated-wrapper-dependency-versions-do-not-edit.txt index d327839ed5..502fa0eb50 100644 --- a/core/gethwrappers/ccip/generation/generated-wrapper-dependency-versions-do-not-edit.txt +++ b/core/gethwrappers/ccip/generation/generated-wrapper-dependency-versions-do-not-edit.txt @@ -5,6 +5,7 @@ burn_mint_token_pool_and_proxy: ../../../contracts/solc/v0.8.24/BurnMintTokenPoo burn_with_from_mint_token_pool: ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPool/BurnWithFromMintTokenPool.abi ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPool/BurnWithFromMintTokenPool.bin 6333d0314d0bd29e75ea5e05fe62a4516ade0c6db91c30b6f93645035db52ed8 burn_with_from_mint_token_pool_and_proxy: ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPoolAndProxy/BurnWithFromMintTokenPoolAndProxy.abi ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPoolAndProxy/BurnWithFromMintTokenPoolAndProxy.bin 08ed1235dda921ce8841b26aa18d0c0f36db4884779dd7670857159801b6d597 ccip_config: ../../../contracts/solc/v0.8.24/CCIPConfig/CCIPConfig.abi ../../../contracts/solc/v0.8.24/CCIPConfig/CCIPConfig.bin 93e3bceec6fff366e876f636001253f1d9c60b43e2c95484674f7ae245b302e6 +ccip_encoding_utils: ../../../contracts/solc/v0.8.24/CCIPEncodingUtils/CCIPEncodingUtils.abi ../../../contracts/solc/v0.8.24/CCIPEncodingUtils/CCIPEncodingUtils.bin 3a4929b6678378e789407449dc994dd3a239deea68dc7996198d65a910ca3d30 ccip_reader_tester: ../../../contracts/solc/v0.8.24/CCIPReaderTester/CCIPReaderTester.abi ../../../contracts/solc/v0.8.24/CCIPReaderTester/CCIPReaderTester.bin 481d461f14c98308cd788b64be1151e92bac6f95ddd55eefc926296454316f13 commit_store: ../../../contracts/solc/v0.8.24/CommitStore/CommitStore.abi ../../../contracts/solc/v0.8.24/CommitStore/CommitStore.bin 274d87db70b643e00ab0a7e7845bb4b791f3b613bfc87708d33fc5a8369e2a41 commit_store_helper: ../../../contracts/solc/v0.8.24/CommitStoreHelper/CommitStoreHelper.abi ../../../contracts/solc/v0.8.24/CommitStoreHelper/CommitStoreHelper.bin f7128dcc2ee6dbcbc976288abcc16970ffb19b59412c5202ef6b259d2007f801 diff --git a/core/gethwrappers/ccip/go_generate.go b/core/gethwrappers/ccip/go_generate.go index ba51fe13fc..8f3102525a 100644 --- a/core/gethwrappers/ccip/go_generate.go +++ b/core/gethwrappers/ccip/go_generate.go @@ -45,6 +45,9 @@ package ccip //go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.24/MockE2EUSDCTokenMessenger/MockE2EUSDCTokenMessenger.abi ../../../contracts/solc/v0.8.24/MockE2EUSDCTokenMessenger/MockE2EUSDCTokenMessenger.bin MockE2EUSDCTokenMessenger mock_usdc_token_messenger //go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.24/MockE2EUSDCTransmitter/MockE2EUSDCTransmitter.abi ../../../contracts/solc/v0.8.24/MockE2EUSDCTransmitter/MockE2EUSDCTransmitter.bin MockE2EUSDCTransmitter mock_usdc_token_transmitter +// EncodingUtils +//go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.24/CCIPEncodingUtils/CCIPEncodingUtils.abi ../../../contracts/solc/v0.8.24/CCIPEncodingUtils/CCIPEncodingUtils.bin EncodingUtils ccip_encoding_utils + // To run these commands, you must either install docker, or the correct version // of abigen. The latter can be installed with these commands, at least on linux: //