From 2cf361075d112c0071da01b9cbae717e709d6ac7 Mon Sep 17 00:00:00 2001 From: Mateusz Sekara Date: Mon, 30 Sep 2024 16:00:53 +0200 Subject: [PATCH] Providing evm specific implementation of tokenDataEncoder --- core/capabilities/ccip/ccipevm/tokendata.go | 38 +++++++++++++++++++ .../capabilities/ccip/oraclecreator/plugin.go | 4 +- core/scripts/go.mod | 4 +- core/scripts/go.sum | 8 ++-- go.mod | 4 +- go.sum | 10 +++-- integration-tests/go.mod | 4 +- integration-tests/go.sum | 8 ++-- integration-tests/load/go.mod | 4 +- integration-tests/load/go.sum | 8 ++-- 10 files changed, 66 insertions(+), 26 deletions(-) create mode 100644 core/capabilities/ccip/ccipevm/tokendata.go diff --git a/core/capabilities/ccip/ccipevm/tokendata.go b/core/capabilities/ccip/ccipevm/tokendata.go new file mode 100644 index 00000000000..011f0ed603c --- /dev/null +++ b/core/capabilities/ccip/ccipevm/tokendata.go @@ -0,0 +1,38 @@ +package ccipevm + +import ( + "context" + + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" + + "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" +) + +type usdcAttestationPayload struct { + Message []byte + Attestation []byte +} + +func (m usdcAttestationPayload) AbiString() string { + return ` + [{ + "components": [ + {"name": "message", "type": "bytes"}, + {"name": "attestation", "type": "bytes"} + ], + "type": "tuple" + }]` +} + +type EVMTokenDataEncoder struct{} + +func NewEVMTokenDataEncoder() EVMTokenDataEncoder { + return EVMTokenDataEncoder{} +} + +func (e EVMTokenDataEncoder) EncodeUSDC(_ context.Context, message cciptypes.Bytes, attestation cciptypes.Bytes) (cciptypes.Bytes, error) { + return abihelpers.EncodeAbiStruct[usdcAttestationPayload](usdcAttestationPayload{ + Message: message, + Attestation: attestation, + }) +} diff --git a/core/capabilities/ccip/oraclecreator/plugin.go b/core/capabilities/ccip/oraclecreator/plugin.go index 3515ae39994..07682ba60e9 100644 --- a/core/capabilities/ccip/oraclecreator/plugin.go +++ b/core/capabilities/ccip/oraclecreator/plugin.go @@ -11,7 +11,6 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper" - "github.com/smartcontractkit/chainlink-ccip/execute/tokendata" "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipevm" evmconfig "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/configs/evm" "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ocrimpls" @@ -33,6 +32,7 @@ import ( "github.com/smartcontractkit/chainlink-ccip/pluginconfig" "github.com/smartcontractkit/chainlink-common/pkg/types" + "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/job" @@ -242,7 +242,7 @@ func (i *pluginOracleCreator) createFactoryAndTransmitter( ccipevm.NewExecutePluginCodecV1(), ccipevm.NewMessageHasherV1(), i.homeChainReader, - &tokendata.NoopTokenDataObserver{}, + ccipevm.NewEVMTokenDataEncoder(), ccipevm.NewGasEstimateProvider(), contractReaders, chainWriters, diff --git a/core/scripts/go.mod b/core/scripts/go.mod index 82baeff7bdc..e1baca1f0d6 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -22,7 +22,7 @@ require ( github.com/prometheus/client_golang v1.20.0 github.com/shopspring/decimal v1.4.0 github.com/smartcontractkit/chainlink-automation v1.0.4 - github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57 + github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/libocr v0.0.0-20240717100443-f6226e09bee7 github.com/spf13/cobra v1.8.1 @@ -271,7 +271,7 @@ require ( github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/shirou/gopsutil/v3 v3.24.3 // indirect github.com/smartcontractkit/chain-selectors v1.0.23 // indirect - github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca // indirect + github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0 // indirect github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 // indirect github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 // indirect github.com/smartcontractkit/chainlink-feeds v0.0.0-20240910155501-42f20443189f // indirect diff --git a/core/scripts/go.sum b/core/scripts/go.sum index c94eb80a17c..9bcb82494f0 100644 --- a/core/scripts/go.sum +++ b/core/scripts/go.sum @@ -1081,10 +1081,10 @@ github.com/smartcontractkit/chain-selectors v1.0.23 h1:D2Eaex4Cw/O7Lg3tX6WklOqnj github.com/smartcontractkit/chain-selectors v1.0.23/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE= github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8= github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca h1:cvifSiZr9VifpKjgVtGaEqknz2MwpY4shQhoOLpgQUE= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca/go.mod h1:hxKOwuo3HBC9a5hoNOvstl2wVF6Z9kZDssHU5VCdqk8= -github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57 h1:pRiTiFOkPEyvgG0hchcCSZzwUbwYydnZBu0QbVaRnVk= -github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0 h1:gX08H/UOOZy04g3UjEqVdJpn4xstNjaLa3TrssMjg64= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0/go.mod h1:EjivXI/zFPSSo1uxt+C8JN2YnIB+gEf5SGzG+0pnx+c= +github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3 h1:Vd7ViAQVgefcvyHGdpMhF3GX7oXafumoxW5cSaOLM3k= +github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 h1:yRk4ektpx/UxwarqAfgxUXLrsYXlaNeP1NOwzHGrK2Q= diff --git a/go.mod b/go.mod index f49dabbad39..a41a31ae5b6 100644 --- a/go.mod +++ b/go.mod @@ -74,8 +74,8 @@ require ( github.com/shopspring/decimal v1.4.0 github.com/smartcontractkit/chain-selectors v1.0.23 github.com/smartcontractkit/chainlink-automation v1.0.4 - github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca - github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57 + github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930135917-1047cb4558ef + github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3 github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 github.com/smartcontractkit/chainlink-feeds v0.0.0-20240910155501-42f20443189f diff --git a/go.sum b/go.sum index e3b97a90da9..d3302b87a84 100644 --- a/go.sum +++ b/go.sum @@ -1042,10 +1042,12 @@ github.com/smartcontractkit/chain-selectors v1.0.23 h1:D2Eaex4Cw/O7Lg3tX6WklOqnj github.com/smartcontractkit/chain-selectors v1.0.23/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE= github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8= github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca h1:cvifSiZr9VifpKjgVtGaEqknz2MwpY4shQhoOLpgQUE= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca/go.mod h1:hxKOwuo3HBC9a5hoNOvstl2wVF6Z9kZDssHU5VCdqk8= -github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57 h1:pRiTiFOkPEyvgG0hchcCSZzwUbwYydnZBu0QbVaRnVk= -github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0 h1:gX08H/UOOZy04g3UjEqVdJpn4xstNjaLa3TrssMjg64= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0/go.mod h1:EjivXI/zFPSSo1uxt+C8JN2YnIB+gEf5SGzG+0pnx+c= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930135917-1047cb4558ef h1:BJCraQIMjFfbLuPSw5X0mzLkIMljfSBxN+g2u7W8mEE= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930135917-1047cb4558ef/go.mod h1:EjivXI/zFPSSo1uxt+C8JN2YnIB+gEf5SGzG+0pnx+c= +github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3 h1:Vd7ViAQVgefcvyHGdpMhF3GX7oXafumoxW5cSaOLM3k= +github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 h1:yRk4ektpx/UxwarqAfgxUXLrsYXlaNeP1NOwzHGrK2Q= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 2d46e7208d8..8d104b3ce1e 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -39,8 +39,8 @@ require ( github.com/smartcontractkit/ccip-owner-contracts v0.0.0-20240926212305-a6deabdfce86 github.com/smartcontractkit/chain-selectors v1.0.23 github.com/smartcontractkit/chainlink-automation v1.0.4 - github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca - github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57 + github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0 + github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3 github.com/smartcontractkit/chainlink-testing-framework/havoc v1.50.0 github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.9 github.com/smartcontractkit/chainlink-testing-framework/lib/grafana v1.50.0 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 4ff2f7169d1..7111b15ef64 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1423,10 +1423,10 @@ github.com/smartcontractkit/chain-selectors v1.0.23 h1:D2Eaex4Cw/O7Lg3tX6WklOqnj github.com/smartcontractkit/chain-selectors v1.0.23/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE= github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8= github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca h1:cvifSiZr9VifpKjgVtGaEqknz2MwpY4shQhoOLpgQUE= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca/go.mod h1:hxKOwuo3HBC9a5hoNOvstl2wVF6Z9kZDssHU5VCdqk8= -github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57 h1:pRiTiFOkPEyvgG0hchcCSZzwUbwYydnZBu0QbVaRnVk= -github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0 h1:gX08H/UOOZy04g3UjEqVdJpn4xstNjaLa3TrssMjg64= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0/go.mod h1:EjivXI/zFPSSo1uxt+C8JN2YnIB+gEf5SGzG+0pnx+c= +github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3 h1:Vd7ViAQVgefcvyHGdpMhF3GX7oXafumoxW5cSaOLM3k= +github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 h1:yRk4ektpx/UxwarqAfgxUXLrsYXlaNeP1NOwzHGrK2Q= diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index 4efb4622274..5543a7b46dd 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -15,7 +15,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.33.0 github.com/slack-go/slack v0.12.2 - github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57 + github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3 github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.9 github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.1 github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.0 @@ -30,7 +30,7 @@ require ( require ( github.com/AlekSi/pointer v1.1.0 // indirect github.com/smartcontractkit/chainlink-automation v1.0.4 // indirect - github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca // indirect + github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0 // indirect github.com/smartcontractkit/libocr v0.0.0-20240717100443-f6226e09bee7 // indirect ) diff --git a/integration-tests/load/go.sum b/integration-tests/load/go.sum index 2d606ba6f98..2ed89c390e0 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -1397,10 +1397,10 @@ github.com/smartcontractkit/chain-selectors v1.0.23 h1:D2Eaex4Cw/O7Lg3tX6WklOqnj github.com/smartcontractkit/chain-selectors v1.0.23/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE= github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8= github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca h1:cvifSiZr9VifpKjgVtGaEqknz2MwpY4shQhoOLpgQUE= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca/go.mod h1:hxKOwuo3HBC9a5hoNOvstl2wVF6Z9kZDssHU5VCdqk8= -github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57 h1:pRiTiFOkPEyvgG0hchcCSZzwUbwYydnZBu0QbVaRnVk= -github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0 h1:gX08H/UOOZy04g3UjEqVdJpn4xstNjaLa3TrssMjg64= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0/go.mod h1:EjivXI/zFPSSo1uxt+C8JN2YnIB+gEf5SGzG+0pnx+c= +github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3 h1:Vd7ViAQVgefcvyHGdpMhF3GX7oXafumoxW5cSaOLM3k= +github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 h1:yRk4ektpx/UxwarqAfgxUXLrsYXlaNeP1NOwzHGrK2Q=