diff --git a/core/services/ocr2/plugins/ccip/ccipexec/gashelpers.go b/core/services/ocr2/plugins/ccip/ccipexec/gashelpers.go index 8b8261f123..7e208296c5 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/gashelpers.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/gashelpers.go @@ -7,61 +7,62 @@ import ( ) const ( - EVM_ADDRESS_LENGTH_BYTES = 20 - EVM_WORD_BYTES = 32 - CALLDATA_GAS_PER_BYTE = 16 - PER_TOKEN_OVERHEAD_GAS = 2_100 + // COLD_SLOAD_COST for first reading the pool - 2_100 + // COLD_SLOAD_COST for pool to ensure allowed offramp calls it - 2_100 + // COLD_SLOAD_COST for accessing pool balance slot - 5_000 + // SSTORE_RESET_GAS for decreasing pool balance from non-zero to non-zero - 2_100 + // COLD_SLOAD_COST for accessing receiver balance - 20_000 + // SSTORE_SET_GAS for increasing receiver balance from zero to non-zero - 2_100 // COLD_SLOAD_COST for obtanining price of token to use for aggregate token bucket - RATE_LIMITER_OVERHEAD_GAS = 2_100 + // COLD_SLOAD_COST for accessing token bucket - 5_000 // SSTORE_RESET_GAS for updating & decreasing token bucket - EXTERNAL_CALL_OVERHEAD_GAS = 2600 + // because the receiver will be untouched initially + EvmAddressLengthBytes = 20 + EvmWordBytes = 32 + CalldataGasPerByte = 16 + TokenAdminRegistryWarmupCost = 2_500 + TokenAdminRegistryPoolLookupGas = 100 + // WARM_ACCESS_COST TokenAdminRegistry + 700 + // CALL cost for TokenAdminRegistry + 2_100 // COLD_SLOAD_COST loading the pool address + SupportsInterfaceCheck = 2600 + // because the receiver will be untouched initially 30_000*3 // supportsInterface of ERC165Checker library performs 3 static-calls of 30k gas each - FEE_BOOSTING_OVERHEAD_GAS = 200_000 - CONSTANT_MESSAGE_PART_BYTES = 10 * 32 // A message consists of 10 abi encoded fields 32B each (after encoding) - EXECUTION_STATE_PROCESSING_OVERHEAD_GAS = 2_100 + // COLD_SLOAD_COST for first reading the state + PerTokenOverheadGas = TokenAdminRegistryPoolLookupGas + + SupportsInterfaceCheck + + 200_000 + // releaseOrMint using callWithExactGas + 50_000 // transfer using callWithExactGas + RateLimiterOverheadGas = 2_100 + // COLD_SLOAD_COST for accessing token bucket + 5_000 // SSTORE_RESET_GAS for updating & decreasing token bucket + ConstantMessagePartBytes = 10 * 32 // A message consists of 10 abi encoded fields 32B each (after encoding) + ExecutionStateProcessingOverheadGas = 2_100 + // COLD_SLOAD_COST for first reading the state 20_000 + // SSTORE_SET_GAS for writing from 0 (untouched) to non-zero (in-progress) 100 //# SLOAD_GAS = WARM_STORAGE_READ_COST for rewriting from non-zero (in-progress) to non-zero (success/failure) - EVM_MESSAGE_FIXED_BYTES = 448 // Byte size of fixed-size fields in EVM2EVMMessage - EVM_MESSAGE_BYTES_PER_TOKEN = 128 // Byte size of each token transfer, consisting of 1 EVMTokenAmount and 1 bytes, excl length of bytes - DA_MULTIPLIER_BASE = int64(10000) ) // return the size of bytes for msg tokens func bytesForMsgTokens(numTokens int) int { // token address (address) + token amount (uint256) - return (EVM_ADDRESS_LENGTH_BYTES + EVM_WORD_BYTES) * numTokens + return (EvmAddressLengthBytes + EvmWordBytes) * numTokens } // Offchain: we compute the max overhead gas to determine msg executability. func overheadGas(dataLength, numTokens int) uint64 { - messageBytes := CONSTANT_MESSAGE_PART_BYTES + + messageBytes := ConstantMessagePartBytes + bytesForMsgTokens(numTokens) + dataLength - messageCallDataGas := uint64(messageBytes * CALLDATA_GAS_PER_BYTE) + messageCallDataGas := uint64(messageBytes * CalldataGasPerByte) // Rate limiter only limits value in tokens. It's not called if there are no - // tokens in the message. + // tokens in the message. The same goes for the admin registry, it's only loaded + // if there are tokens, and it's only loaded once. rateLimiterOverhead := uint64(0) + adminRegistryOverhead := uint64(0) if numTokens >= 1 { - rateLimiterOverhead = RATE_LIMITER_OVERHEAD_GAS + rateLimiterOverhead = RateLimiterOverheadGas + adminRegistryOverhead = TokenAdminRegistryWarmupCost } return messageCallDataGas + - EXECUTION_STATE_PROCESSING_OVERHEAD_GAS + - PER_TOKEN_OVERHEAD_GAS*uint64(numTokens) + + ExecutionStateProcessingOverheadGas + + SupportsInterfaceCheck + + adminRegistryOverhead + rateLimiterOverhead + - EXTERNAL_CALL_OVERHEAD_GAS + PerTokenOverheadGas*uint64(numTokens) } func maxGasOverHeadGas(numMsgs, dataLength, numTokens int) uint64 { merkleProofBytes := (math.Ceil(math.Log2(float64(numMsgs))))*32 + (1+2)*32 // only ever one outer root hash - merkleGasShare := uint64(merkleProofBytes * CALLDATA_GAS_PER_BYTE) + merkleGasShare := uint64(merkleProofBytes * CalldataGasPerByte) return overheadGas(dataLength, numTokens) + merkleGasShare } diff --git a/core/services/ocr2/plugins/ccip/ccipexec/gashelpers_test.go b/core/services/ocr2/plugins/ccip/ccipexec/gashelpers_test.go index b8d7cbcf01..15607cc310 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/gashelpers_test.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/gashelpers_test.go @@ -25,7 +25,7 @@ func TestOverheadGas(t *testing.T) { { dataLength: len([]byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0}), numberOfTokens: 1, - want: 163448, + want: 475948, }, } @@ -56,7 +56,7 @@ func TestMaxGasOverHeadGas(t *testing.T) { numMsgs: 3, dataLength: len([]byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0}), numberOfTokens: 1, - want: 166008, + want: 478508, }, } @@ -169,7 +169,7 @@ func TestWaitBoostedFee(t *testing.T) { diff := big.NewInt(0).Sub(boosted, tc.fee) assert.Equal(t, diff, tc.diff) // we check that the actual diff is approximately equals to expected diff, - // as we might get slightly different results locally vs. CI therefore normal Equal() would be instable + // as we might get slightly different results locally vs. CI therefore normal Equal() would be unstable //diffUpperLimit := big.NewInt(0).Add(tc.diff, big.NewInt(1e9)) //diffLowerLimit := big.NewInt(0).Add(tc.diff, big.NewInt(-1e9)) //require.Equalf(t, -1, diff.Cmp(diffUpperLimit), "actual diff (%s) is larger than expected (%s)", diff.String(), diffUpperLimit.String()) diff --git a/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go b/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go index 15e1ef3718..35b7d6b076 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go @@ -500,80 +500,80 @@ func TestExecutionReportingPlugin_buildBatch(t *testing.T) { msg5.Nonce = msg5.Nonce + 1 var tt = []struct { - name string - reqs []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta - inflight *big.Int - tokenLimit, destGasPrice *big.Int - srcPrices, dstPrices map[cciptypes.Address]*big.Int - offRampNoncesBySender map[cciptypes.Address]uint64 - srcToDestTokens map[cciptypes.Address]cciptypes.Address - expectedSeqNrs []ccip.ObservedMessage - expectedStates []messageExecStatus + name string + reqs []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta + inflight *big.Int + tokenRateLimitCapacity, destGasPrice *big.Int + srcPrices, dstPrices map[cciptypes.Address]*big.Int + offRampNoncesBySender map[cciptypes.Address]uint64 + srcToDestTokens map[cciptypes.Address]cciptypes.Address + expectedSeqNrs []ccip.ObservedMessage + expectedStates []messageExecStatus }{ { - name: "single message no tokens", - reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg1}, - inflight: big.NewInt(0), - tokenLimit: big.NewInt(0), - destGasPrice: big.NewInt(10), - srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, - dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, - offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, - expectedSeqNrs: []ccip.ObservedMessage{{SeqNr: uint64(1)}}, - expectedStates: []messageExecStatus{newMessageExecState(msg1.SequenceNumber, msg1.MessageID, AddedToBatch)}, - }, - { - name: "executed non finalized messages should be skipped", - reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg2}, - inflight: big.NewInt(0), - tokenLimit: big.NewInt(0), - destGasPrice: big.NewInt(10), - srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, - dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, - offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, - expectedStates: []messageExecStatus{newMessageExecState(msg2.SequenceNumber, msg2.MessageID, AlreadyExecuted)}, - }, - { - name: "finalized executed log", - reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg3}, - inflight: big.NewInt(0), - tokenLimit: big.NewInt(0), - destGasPrice: big.NewInt(10), - srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, - dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, - offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, - expectedStates: []messageExecStatus{newMessageExecState(msg3.SequenceNumber, msg3.MessageID, AlreadyExecuted)}, - }, - { - name: "dst token price does not exist", - reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg1}, - inflight: big.NewInt(0), - tokenLimit: big.NewInt(0), - destGasPrice: big.NewInt(10), - srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, - dstPrices: map[cciptypes.Address]*big.Int{}, - offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, - expectedStates: []messageExecStatus{newMessageExecState(msg1.SequenceNumber, msg1.MessageID, TokenNotInDestTokenPrices)}, - }, - { - name: "src token price does not exist", - reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg1}, - inflight: big.NewInt(0), - tokenLimit: big.NewInt(0), - destGasPrice: big.NewInt(10), - srcPrices: map[cciptypes.Address]*big.Int{}, - dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, - offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, - expectedStates: []messageExecStatus{newMessageExecState(msg1.SequenceNumber, msg1.MessageID, TokenNotInSrcTokenPrices)}, - }, - { - name: "message with tokens is not executed if limit is reached", - reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg4}, - inflight: big.NewInt(0), - tokenLimit: big.NewInt(2), - destGasPrice: big.NewInt(10), - srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1e18)}, - dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1e18)}, + name: "single message no tokens", + reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg1}, + inflight: big.NewInt(0), + tokenRateLimitCapacity: big.NewInt(0), + destGasPrice: big.NewInt(10), + srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, + dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, + offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, + expectedSeqNrs: []ccip.ObservedMessage{{SeqNr: uint64(1)}}, + expectedStates: []messageExecStatus{newMessageExecState(msg1.SequenceNumber, msg1.MessageID, AddedToBatch)}, + }, + { + name: "executed non finalized messages should be skipped", + reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg2}, + inflight: big.NewInt(0), + tokenRateLimitCapacity: big.NewInt(0), + destGasPrice: big.NewInt(10), + srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, + dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, + offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, + expectedStates: []messageExecStatus{newMessageExecState(msg2.SequenceNumber, msg2.MessageID, AlreadyExecuted)}, + }, + { + name: "finalized executed log", + reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg3}, + inflight: big.NewInt(0), + tokenRateLimitCapacity: big.NewInt(0), + destGasPrice: big.NewInt(10), + srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, + dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, + offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, + expectedStates: []messageExecStatus{newMessageExecState(msg3.SequenceNumber, msg3.MessageID, AlreadyExecuted)}, + }, + { + name: "dst token price does not exist", + reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg1}, + inflight: big.NewInt(0), + tokenRateLimitCapacity: big.NewInt(0), + destGasPrice: big.NewInt(10), + srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, + dstPrices: map[cciptypes.Address]*big.Int{}, + offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, + expectedStates: []messageExecStatus{newMessageExecState(msg1.SequenceNumber, msg1.MessageID, TokenNotInDestTokenPrices)}, + }, + { + name: "src token price does not exist", + reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg1}, + inflight: big.NewInt(0), + tokenRateLimitCapacity: big.NewInt(0), + destGasPrice: big.NewInt(10), + srcPrices: map[cciptypes.Address]*big.Int{}, + dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, + offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, + expectedStates: []messageExecStatus{newMessageExecState(msg1.SequenceNumber, msg1.MessageID, TokenNotInSrcTokenPrices)}, + }, + { + name: "message with tokens is not executed if limit is reached", + reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg4}, + inflight: big.NewInt(0), + tokenRateLimitCapacity: big.NewInt(2), + destGasPrice: big.NewInt(10), + srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1e18)}, + dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1e18)}, srcToDestTokens: map[cciptypes.Address]cciptypes.Address{ srcNative: destNative, }, @@ -581,13 +581,13 @@ func TestExecutionReportingPlugin_buildBatch(t *testing.T) { expectedStates: []messageExecStatus{newMessageExecState(msg4.SequenceNumber, msg4.MessageID, AggregateTokenLimitExceeded)}, }, { - name: "message with tokens is not executed if limit is reached when inflight is full", - reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg5}, - inflight: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(100)), - tokenLimit: big.NewInt(19), - destGasPrice: big.NewInt(10), - srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1e18)}, - dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1e18)}, + name: "message with tokens is not executed if limit is reached when inflight is full", + reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg5}, + inflight: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(100)), + tokenRateLimitCapacity: big.NewInt(19), + destGasPrice: big.NewInt(10), + srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1e18)}, + dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1e18)}, srcToDestTokens: map[cciptypes.Address]cciptypes.Address{ srcNative: destNative, }, @@ -595,26 +595,26 @@ func TestExecutionReportingPlugin_buildBatch(t *testing.T) { expectedStates: []messageExecStatus{newMessageExecState(msg5.SequenceNumber, msg5.MessageID, AggregateTokenLimitExceeded)}, }, { - name: "skip when nonce doesn't match chain value", - reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg1}, - inflight: big.NewInt(0), - tokenLimit: big.NewInt(0), - destGasPrice: big.NewInt(10), - srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, - dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, - offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 123}, - expectedStates: []messageExecStatus{newMessageExecState(msg1.SequenceNumber, msg1.MessageID, InvalidNonce)}, + name: "skip when nonce doesn't match chain value", + reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg1}, + inflight: big.NewInt(0), + tokenRateLimitCapacity: big.NewInt(0), + destGasPrice: big.NewInt(10), + srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, + dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, + offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 123}, + expectedStates: []messageExecStatus{newMessageExecState(msg1.SequenceNumber, msg1.MessageID, InvalidNonce)}, }, { - name: "skip when nonce not found", - reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg1}, - inflight: big.NewInt(0), - tokenLimit: big.NewInt(0), - destGasPrice: big.NewInt(10), - srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, - dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, - offRampNoncesBySender: map[cciptypes.Address]uint64{}, - expectedStates: []messageExecStatus{newMessageExecState(msg1.SequenceNumber, msg1.MessageID, MissingNonce)}, + name: "skip when nonce not found", + reqs: []cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta{msg1}, + inflight: big.NewInt(0), + tokenRateLimitCapacity: big.NewInt(0), + destGasPrice: big.NewInt(10), + srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, + dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, + offRampNoncesBySender: map[cciptypes.Address]uint64{}, + expectedStates: []messageExecStatus{newMessageExecState(msg1.SequenceNumber, msg1.MessageID, MissingNonce)}, }, { name: "skip when batch gas limit is reached", @@ -659,13 +659,13 @@ func TestExecutionReportingPlugin_buildBatch(t *testing.T) { BlockTimestamp: time.Date(2010, 1, 1, 12, 12, 12, 0, time.UTC), }, }, - inflight: big.NewInt(0), - tokenLimit: big.NewInt(0), - destGasPrice: big.NewInt(10), - srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, - dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, - offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, - expectedSeqNrs: []ccip.ObservedMessage{{SeqNr: uint64(10)}}, + inflight: big.NewInt(0), + tokenRateLimitCapacity: big.NewInt(0), + destGasPrice: big.NewInt(10), + srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, + dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, + offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, + expectedSeqNrs: []ccip.ObservedMessage{{SeqNr: uint64(10)}}, expectedStates: []messageExecStatus{ newMessageExecState(10, [32]byte{}, AddedToBatch), newMessageExecState(11, [32]byte{}, InsufficientRemainingBatchGas), @@ -715,13 +715,13 @@ func TestExecutionReportingPlugin_buildBatch(t *testing.T) { BlockTimestamp: time.Date(2010, 1, 1, 12, 12, 12, 0, time.UTC), }, }, - inflight: big.NewInt(0), - tokenLimit: big.NewInt(0), - destGasPrice: big.NewInt(10), - srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, - dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, - offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, - expectedSeqNrs: []ccip.ObservedMessage{{SeqNr: uint64(10)}}, + inflight: big.NewInt(0), + tokenRateLimitCapacity: big.NewInt(0), + destGasPrice: big.NewInt(10), + srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, + dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, + offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, + expectedSeqNrs: []ccip.ObservedMessage{{SeqNr: uint64(10)}}, expectedStates: []messageExecStatus{ newMessageExecState(10, [32]byte{}, AddedToBatch), newMessageExecState(11, [32]byte{}, InsufficientRemainingBatchDataLength), @@ -745,13 +745,13 @@ func TestExecutionReportingPlugin_buildBatch(t *testing.T) { BlockTimestamp: time.Date(2010, 1, 1, 12, 12, 12, 0, time.UTC), }, }, - inflight: big.NewInt(0), - tokenLimit: big.NewInt(0), - destGasPrice: big.NewInt(10), - srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, - dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, - offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, - expectedSeqNrs: []ccip.ObservedMessage{{SeqNr: uint64(10)}}, + inflight: big.NewInt(0), + tokenRateLimitCapacity: big.NewInt(0), + destGasPrice: big.NewInt(10), + srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, + dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, + offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 0}, + expectedSeqNrs: []ccip.ObservedMessage{{SeqNr: uint64(10)}}, expectedStates: []messageExecStatus{ newMessageExecState(10, [32]byte{}, AddedToBatch), }, @@ -786,13 +786,13 @@ func TestExecutionReportingPlugin_buildBatch(t *testing.T) { BlockTimestamp: time.Date(2010, 1, 1, 12, 12, 12, 0, time.UTC), }, }, - inflight: big.NewInt(0), - tokenLimit: big.NewInt(0), - destGasPrice: big.NewInt(10), - srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, - dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, - offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 3}, - expectedSeqNrs: []ccip.ObservedMessage{{SeqNr: uint64(10)}}, + inflight: big.NewInt(0), + tokenRateLimitCapacity: big.NewInt(0), + destGasPrice: big.NewInt(10), + srcPrices: map[cciptypes.Address]*big.Int{srcNative: big.NewInt(1)}, + dstPrices: map[cciptypes.Address]*big.Int{destNative: big.NewInt(1)}, + offRampNoncesBySender: map[cciptypes.Address]uint64{sender1: 3}, + expectedSeqNrs: []ccip.ObservedMessage{{SeqNr: uint64(10)}}, expectedStates: []messageExecStatus{ newMessageExecState(9, [32]byte{}, InvalidNonce), newMessageExecState(10, [32]byte{}, AddedToBatch), @@ -820,7 +820,7 @@ func TestExecutionReportingPlugin_buildBatch(t *testing.T) { destWrappedNative: destNative, offchainConfig: cciptypes.ExecOffchainConfig{ DestOptimisticConfirmations: 1, - BatchGasLimit: 300_000, + BatchGasLimit: 500_000, RelativeBoostPerWaitHour: 1, }, lggr: logger.TestLogger(t), @@ -832,7 +832,7 @@ func TestExecutionReportingPlugin_buildBatch(t *testing.T) { lggr, commitReportWithSendRequests{sendRequestsWithMeta: tc.reqs}, tc.inflight, - tc.tokenLimit, + tc.tokenRateLimitCapacity, tc.srcPrices, tc.dstPrices, tc.destGasPrice, @@ -1247,19 +1247,19 @@ func Test_calculateMessageMaxGas(t *testing.T) { { name: "base", args: args{gasLimit: big.NewInt(1000), numRequests: 5, dataLen: 5, numTokens: 2}, - want: 203836, + want: 826_336, wantErr: false, }, { name: "large", args: args{gasLimit: big.NewInt(1000), numRequests: 1000, dataLen: 1000, numTokens: 1000}, - want: 36482676, + want: 346_485_176, wantErr: false, }, { name: "gas limit overflow", args: args{gasLimit: big.NewInt(0).Mul(big.NewInt(math.MaxInt64), big.NewInt(math.MaxInt64))}, - want: 36391540, + want: 36_391_540, wantErr: true, }, }