diff --git a/.changeset/metal-meals-mix.md b/.changeset/metal-meals-mix.md new file mode 100644 index 00000000000..66ebcec9982 --- /dev/null +++ b/.changeset/metal-meals-mix.md @@ -0,0 +1,5 @@ +--- +"chainlink": patch +--- + +Adjustments for usdc reader tests #internal diff --git a/core/capabilities/ccip/ccip_integration_tests/usdcreader/usdcreader_test.go b/core/capabilities/ccip/ccip_integration_tests/usdcreader/usdcreader_test.go index 8637cb67a03..dd4801260bd 100644 --- a/core/capabilities/ccip/ccip_integration_tests/usdcreader/usdcreader_test.go +++ b/core/capabilities/ccip/ccip_integration_tests/usdcreader/usdcreader_test.go @@ -12,8 +12,6 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/crypto" - "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/zap/zapcore" @@ -40,6 +38,8 @@ import ( ) func Test_USDCReader_MessageHashes(t *testing.T) { + finalityDepth := 5 + ctx := testutils.Context(t) ethereumChain := cciptypes.ChainSelector(sel.ETHEREUM_MAINNET_OPTIMISM_1.Selector) ethereumDomainCCTP := reader.CCTPDestDomains[uint64(ethereumChain)] @@ -48,9 +48,10 @@ func Test_USDCReader_MessageHashes(t *testing.T) { polygonChain := cciptypes.ChainSelector(sel.POLYGON_MAINNET.Selector) polygonDomainCCTP := reader.CCTPDestDomains[uint64(polygonChain)] - ts := testSetup(ctx, t, ethereumChain, evmconfig.USDCReaderConfig) + ts := testSetup(ctx, t, ethereumChain, evmconfig.USDCReaderConfig, finalityDepth) usdcReader, err := reader.NewUSDCMessageReader( + logger.TestLogger(t), map[cciptypes.ChainSelector]pluginconfig.USDCCCTPTokenConfig{ ethereumChain: { SourceMessageTransmitterAddr: ts.contractAddr.String(), @@ -67,6 +68,11 @@ func Test_USDCReader_MessageHashes(t *testing.T) { emitMessageSent(t, ts, ethereumDomainCCTP, avalancheDomainCCTP, 41) emitMessageSent(t, ts, ethereumDomainCCTP, polygonDomainCCTP, 31) emitMessageSent(t, ts, ethereumDomainCCTP, polygonDomainCCTP, 41) + // Finalize events + for i := 0; i < finalityDepth; i++ { + ts.sb.Commit() + } + emitMessageSent(t, ts, ethereumDomainCCTP, avalancheDomainCCTP, 51) // Need to replay as sometimes the logs are not picked up by the log poller (?) // Maybe another situation where chain reader doesn't register filters as expected. @@ -167,25 +173,30 @@ func Test_USDCReader_MessageHashes(t *testing.T) { reader.NewMessageTokenID(1, 3), }, }, + { + name: "not finalized events are not returned", + tokens: map[reader.MessageTokenID]cciptypes.RampTokenAmount{ + reader.NewMessageTokenID(1, 5): { + ExtraData: reader.NewSourceTokenDataPayload(51, ethereumDomainCCTP).ToBytes(), + }, + }, + sourceChain: ethereumChain, + destChain: avalancheChain, + expectedMsgIDs: []reader.MessageTokenID{}, + }, } for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { - require.Eventually(t, func() bool { - hashes, err1 := usdcReader.MessageHashes(ctx, tc.sourceChain, tc.destChain, tc.tokens) - require.NoError(t, err1) + hashes, err1 := usdcReader.MessageHashes(ctx, tc.sourceChain, tc.destChain, tc.tokens) + require.NoError(t, err1) - if len(tc.expectedMsgIDs) != len(hashes) { - return false - } + require.Equal(t, len(tc.expectedMsgIDs), len(hashes)) - for _, msgID := range tc.expectedMsgIDs { - if _, ok := hashes[msgID]; !ok { - return false - } - } - return true - }, tests.WaitTimeout(t), 50*time.Millisecond) + for _, msgID := range tc.expectedMsgIDs { + _, ok := hashes[msgID] + require.True(t, ok) + } }) } } @@ -207,7 +218,7 @@ func emitMessageSent(t *testing.T, testEnv *testSetupData, source, dest uint32, testEnv.sb.Commit() } -func testSetup(ctx context.Context, t *testing.T, readerChain cciptypes.ChainSelector, cfg evmtypes.ChainReaderConfig) *testSetupData { +func testSetup(ctx context.Context, t *testing.T, readerChain cciptypes.ChainSelector, cfg evmtypes.ChainReaderConfig, depth int) *testSetupData { const chainID = 1337 // Generate a new key pair for the simulated account @@ -239,7 +250,7 @@ func testSetup(ctx context.Context, t *testing.T, readerChain cciptypes.ChainSel db := pgtest.NewSqlxDB(t) lpOpts := logpoller.Opts{ PollPeriod: time.Millisecond, - FinalityDepth: 0, + FinalityDepth: int64(depth), BackfillBatchSize: 10, RpcBatchSize: 10, KeepFinalizedBlocksDepth: 100000, diff --git a/core/capabilities/ccip/configs/evm/contract_reader.go b/core/capabilities/ccip/configs/evm/contract_reader.go index 07ec7de4eb2..bbbcc6faa93 100644 --- a/core/capabilities/ccip/configs/evm/contract_reader.go +++ b/core/capabilities/ccip/configs/evm/contract_reader.go @@ -271,6 +271,16 @@ var USDCReaderConfig = evmrelaytypes.ChainReaderConfig{ consts.EventNameCCTPMessageSent: { ChainSpecificName: consts.EventNameCCTPMessageSent, ReadType: evmrelaytypes.Event, + EventDefinitions: &evmrelaytypes.EventDefinitions{ + GenericDataWordDetails: map[string]evmrelaytypes.DataWordDetail{ + consts.CCTPMessageSentValue: { + Name: consts.CCTPMessageSentValue, + // Filtering by the 3rd word (indexing starts from 0) so it's ptr(2) + Index: ptr(2), + Type: "bytes32", + }, + }, + }, }, }, }, @@ -327,3 +337,7 @@ func mustGetEventName(event string, tabi abi.ABI) string { } return e.Name } + +func ptr[T any](v T) *T { + return &v +} diff --git a/core/scripts/go.mod b/core/scripts/go.mod index 2a376f22b77..af7ddc2f98f 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -278,7 +278,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-20241008154535-20ff51a45385 // indirect + github.com/smartcontractkit/chainlink-ccip v0.0.0-20241009125450-4290917273fb // 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 1b321c04875..684155bba51 100644 --- a/core/scripts/go.sum +++ b/core/scripts/go.sum @@ -1097,8 +1097,8 @@ 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-20241008154535-20ff51a45385 h1:BLaoELbQm9Mr+v+TzqWIY/zp7E+zXaW/kfaDcobOF3k= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20241008154535-20ff51a45385/go.mod h1:WbtjuYMnDAYojL3CSWmruc1ecSBgSTggzXJ6F1U6bxw= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20241009125450-4290917273fb h1:bYT7j5syymCtAKv/gGG7CLp4APe/VDWkig9Ph7mc8fQ= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20241009125450-4290917273fb/go.mod h1:WbtjuYMnDAYojL3CSWmruc1ecSBgSTggzXJ6F1U6bxw= github.com/smartcontractkit/chainlink-common v0.2.3-0.20241001210038-dd59341432bd h1:DraA9kRpkyI02OEx7QDbSq3bCYxVFZ78TdOP2rUvHts= github.com/smartcontractkit/chainlink-common v0.2.3-0.20241001210038-dd59341432bd/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q= diff --git a/go.mod b/go.mod index 8c4fda45ae2..93696685c60 100644 --- a/go.mod +++ b/go.mod @@ -75,7 +75,7 @@ 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-20241008154535-20ff51a45385 + github.com/smartcontractkit/chainlink-ccip v0.0.0-20241009125450-4290917273fb github.com/smartcontractkit/chainlink-common v0.2.3-0.20241001210038-dd59341432bd github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 diff --git a/go.sum b/go.sum index c3829de0d35..2e4a7775a60 100644 --- a/go.sum +++ b/go.sum @@ -1058,8 +1058,8 @@ 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-20241008154535-20ff51a45385 h1:BLaoELbQm9Mr+v+TzqWIY/zp7E+zXaW/kfaDcobOF3k= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20241008154535-20ff51a45385/go.mod h1:WbtjuYMnDAYojL3CSWmruc1ecSBgSTggzXJ6F1U6bxw= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20241009125450-4290917273fb h1:bYT7j5syymCtAKv/gGG7CLp4APe/VDWkig9Ph7mc8fQ= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20241009125450-4290917273fb/go.mod h1:WbtjuYMnDAYojL3CSWmruc1ecSBgSTggzXJ6F1U6bxw= github.com/smartcontractkit/chainlink-common v0.2.3-0.20241001210038-dd59341432bd h1:DraA9kRpkyI02OEx7QDbSq3bCYxVFZ78TdOP2rUvHts= github.com/smartcontractkit/chainlink-common v0.2.3-0.20241001210038-dd59341432bd/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index b8e945f90f5..d3ad17f908c 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -39,7 +39,7 @@ 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-20241008154535-20ff51a45385 + github.com/smartcontractkit/chainlink-ccip v0.0.0-20241009125450-4290917273fb github.com/smartcontractkit/chainlink-common v0.2.3-0.20241001210038-dd59341432bd github.com/smartcontractkit/chainlink-testing-framework/havoc v1.50.0 github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.9 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 84c7a40fb29..90c7f08b0f9 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1437,8 +1437,8 @@ 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-20241008154535-20ff51a45385 h1:BLaoELbQm9Mr+v+TzqWIY/zp7E+zXaW/kfaDcobOF3k= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20241008154535-20ff51a45385/go.mod h1:WbtjuYMnDAYojL3CSWmruc1ecSBgSTggzXJ6F1U6bxw= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20241009125450-4290917273fb h1:bYT7j5syymCtAKv/gGG7CLp4APe/VDWkig9Ph7mc8fQ= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20241009125450-4290917273fb/go.mod h1:WbtjuYMnDAYojL3CSWmruc1ecSBgSTggzXJ6F1U6bxw= github.com/smartcontractkit/chainlink-common v0.2.3-0.20241001210038-dd59341432bd h1:DraA9kRpkyI02OEx7QDbSq3bCYxVFZ78TdOP2rUvHts= github.com/smartcontractkit/chainlink-common v0.2.3-0.20241001210038-dd59341432bd/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q= diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index d0826a0e790..8b3fed5432b 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -391,7 +391,7 @@ require ( github.com/sirupsen/logrus v1.9.3 // indirect github.com/smartcontractkit/chain-selectors v1.0.23 // indirect github.com/smartcontractkit/chainlink-automation v1.0.4 // indirect - github.com/smartcontractkit/chainlink-ccip v0.0.0-20241008154535-20ff51a45385 // indirect + github.com/smartcontractkit/chainlink-ccip v0.0.0-20241009125450-4290917273fb // 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/integration-tests/load/go.sum b/integration-tests/load/go.sum index 779f0ccd724..8bdc23dc35f 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -1413,8 +1413,8 @@ 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-20241008154535-20ff51a45385 h1:BLaoELbQm9Mr+v+TzqWIY/zp7E+zXaW/kfaDcobOF3k= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20241008154535-20ff51a45385/go.mod h1:WbtjuYMnDAYojL3CSWmruc1ecSBgSTggzXJ6F1U6bxw= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20241009125450-4290917273fb h1:bYT7j5syymCtAKv/gGG7CLp4APe/VDWkig9Ph7mc8fQ= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20241009125450-4290917273fb/go.mod h1:WbtjuYMnDAYojL3CSWmruc1ecSBgSTggzXJ6F1U6bxw= github.com/smartcontractkit/chainlink-common v0.2.3-0.20241001210038-dd59341432bd h1:DraA9kRpkyI02OEx7QDbSq3bCYxVFZ78TdOP2rUvHts= github.com/smartcontractkit/chainlink-common v0.2.3-0.20241001210038-dd59341432bd/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q=