Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report L1 base fee set by L2s #111

Merged
merged 34 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c35425e
CCIP plugin code sketch
matYang Sep 2, 2023
0978d8f
Merge branch 'ccip-develop' into feature/offchain-report-l1-base-fee-…
matYang Sep 19, 2023
27d328d
revert models changes
matYang Sep 19, 2023
6fd2486
update gas price encoding and deviation
matYang Sep 20, 2023
4288094
udpate exec cost estimation
matYang Sep 20, 2023
65ec92f
Update exec cost estimation
matYang Sep 20, 2023
d68a786
update offchain config
matYang Sep 21, 2023
fb7b0af
use gas price struct instead of encoding where applicable
matYang Sep 21, 2023
b2c5866
do not use v2 suffix for latest version of offchain config
matYang Sep 21, 2023
3985918
add nil check for gas update
matYang Sep 21, 2023
159cc13
Merge branch 'ccip-develop' into feature/offchain-report-l1-base-fee-…
matYang Sep 22, 2023
bc94b46
Adding price estimator interfaces
matYang Sep 22, 2023
78ab531
update commit plugin
matYang Sep 23, 2023
a6cd7c4
update name to prices
matYang Sep 24, 2023
71992a3
update exec plugin
matYang Sep 24, 2023
436eef3
comments and nits
matYang Sep 25, 2023
5e4ec20
change the loaders to also return version
matYang Sep 25, 2023
9b52b04
address comments
matYang Sep 26, 2023
3367405
making tests build
matYang Sep 26, 2023
5fb58a2
validate observed token prices match token with decimals
matYang Sep 26, 2023
4bfb882
fixed commit reporting tests
matYang Sep 27, 2023
d3e7142
add test for validateObservations
matYang Sep 27, 2023
37badf1
pass tests
matYang Sep 27, 2023
76aa3ef
Merge branch 'ccip-develop' into feature/offchain-report-l1-base-fee-…
matYang Sep 27, 2023
3d9d6ba
add test for exec getPrice
matYang Sep 27, 2023
3237406
couple more tests in exec price estimator
matYang Sep 27, 2023
337a715
complete exec price estimator test
matYang Sep 27, 2023
9717f92
add da price estimator test
matYang Sep 28, 2023
d795be9
Merge branch 'ccip-develop' into feature/offchain-report-l1-base-fee-…
matYang Sep 28, 2023
c4f9718
resolve exec logpoller fiter test
matYang Sep 28, 2023
f619ede
address comments
matYang Sep 29, 2023
42fa3bd
remove price estimator deviation and computeCost opts
matYang Sep 30, 2023
9d7673f
Merge branch 'ccip-develop' into feature/offchain-report-l1-base-fee-…
matYang Oct 2, 2023
db7be89
fix 1.21 import
matYang Oct 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/src/v0.8/ccip/libraries/Internal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ library Internal {
uint256 public constant MESSAGE_FIXED_BYTES = 32 * 17;

/// @dev Each token transfer adds 1 EVMTokenAmount and 1 bytes.
/// When abiEncoded, each EVMTokenAmount takes 2 slots, each bytes takes 2 slots.
uint256 public constant MESSAGE_BYTES_PER_TOKEN = 32 * 4;
/// When abiEncoded, each EVMTokenAmount takes 2 slots, each bytes takes 2 slots, excl bytes contents
uint256 public constant MESSAGE_FIXED_BYTES_PER_TOKEN = 32 * 4;

function _toAny2EVMMessage(
EVM2EVMMessage memory original,
Expand Down
13 changes: 7 additions & 6 deletions contracts/src/v0.8/ccip/onRamp/EVM2EVMOnRamp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ contract EVM2EVMOnRamp is IEVM2AnyOnRamp, ILinkAvailable, AggregateRateLimiter,
address router; // -------------------------┐ Router address
uint16 maxTokensLength; // | Maximum number of ERC20 token transfers per message
uint32 destGasOverhead; // | Extra gas charged on top of the gasLimit
uint16 destGasPerPayloadByte; // | Destination chain gas charged per byte of `data` payload
uint32 destDataAvailabilityOverheadGas; // | Extra data availability gas charged on top of message data
uint16 destGasPerDataAvailabilityByte; // --┘ Amount of gas to charge per byte of data that needs availability
uint16 destGasPerPayloadByte; // | Destination chain gas charged for passing each byte of `data` payload to receiver
uint32 destDataAvailabilityOverheadGas; // | Extra data availability gas charged on top of the message, e.g. for OCR
uint16 destGasPerDataAvailabilityByte; // --┘ Amount of gas to charge per byte of message data that needs availability
uint16 destDataAvailabilityMultiplier; // --┐ Multiplier for data availability gas, multples of 1e-4, or 0.0001
address priceRegistry; // | Price registry address
uint32 maxDataSize; // | Maximum payload data size, max 4GB
Expand Down Expand Up @@ -115,7 +115,7 @@ contract EVM2EVMOnRamp is IEVM2AnyOnRamp, ILinkAvailable, AggregateRateLimiter,
struct TokenTransferFeeConfig {
uint16 ratio; // -------------------┐ Ratio of token transfer value to charge as fee, multiples of 0.1bps, or 1e-5
uint32 destGasOverhead; // | Gas charged to execute the token transfer on the destination chain
uint32 destBytesOverhead; // -------┘ Extra data availability bytes on top of transfer data, e.g. USDC offchain data
uint32 destBytesOverhead; // -------┘ Extra data availability bytes on top of fixed transfer data, e.g. USDC source token data and offchain data
}

/// @dev Same as TokenTransferFeeConfig
Expand All @@ -124,7 +124,7 @@ contract EVM2EVMOnRamp is IEVM2AnyOnRamp, ILinkAvailable, AggregateRateLimiter,
address token; // ------------------┐ Token address
uint16 ratio; // | Ratio of token transfer value to charge as fee, multiples of 0.1bps, or 1e-5
uint32 destGasOverhead; // | Gas charged to execute the token transfer on the destination chain
uint32 destBytesOverhead; // -------┘ Extra data availability bytes on top of transfer data, e.g. USDC offchain data
uint32 destBytesOverhead; // -------┘ Extra data availability bytes on top of fixed transfer data, e.g. USDC source token data and offchain data
}

/// @dev Nop address and weight, used to set the nops and their weights
Expand Down Expand Up @@ -550,9 +550,10 @@ contract EVM2EVMOnRamp is IEVM2AnyOnRamp, ILinkAvailable, AggregateRateLimiter,
) internal view returns (uint256 dataAvailabilityCostUSD) {
uint256 dataAvailabilityLengthBytes = Internal.MESSAGE_FIXED_BYTES +
messageDataLength +
(numberOfTokens * Internal.MESSAGE_BYTES_PER_TOKEN) +
(numberOfTokens * Internal.MESSAGE_FIXED_BYTES_PER_TOKEN) +
tokenTransferBytesOverhead;

// destDataAvailabilityOverheadGas is a separate config value for flexibility to be updated independently of message cost.
uint256 dataAvailabilityGas = (dataAvailabilityLengthBytes * s_dynamicConfig.destGasPerDataAvailabilityByte) +
s_dynamicConfig.destDataAvailabilityOverheadGas;

Expand Down
4 changes: 2 additions & 2 deletions contracts/src/v0.8/ccip/test/onRamp/EVM2EVMOnRamp.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ contract EVM2EVMOnRamp_getDataAvailabilityCostUSD is EVM2EVMOnRamp_getFeeSetup {

uint256 dataAvailabilityLengthBytes = Internal.MESSAGE_FIXED_BYTES +
100 +
(5 * Internal.MESSAGE_BYTES_PER_TOKEN) +
(5 * Internal.MESSAGE_FIXED_BYTES_PER_TOKEN) +
50;
uint256 dataAvailabilityGas = dynamicConfig.destDataAvailabilityOverheadGas +
dynamicConfig.destGasPerDataAvailabilityByte *
Expand Down Expand Up @@ -747,7 +747,7 @@ contract EVM2EVMOnRamp_getDataAvailabilityCostUSD is EVM2EVMOnRamp_getFeeSetup {

uint256 dataAvailabilityLengthBytes = Internal.MESSAGE_FIXED_BYTES +
messageDataLength +
(numberOfTokens * Internal.MESSAGE_BYTES_PER_TOKEN) +
(numberOfTokens * Internal.MESSAGE_FIXED_BYTES_PER_TOKEN) +
tokenTransferBytesOverhead;

uint256 dataAvailabilityGas = destDataAvailabilityOverheadGas +
Expand Down
10 changes: 10 additions & 0 deletions core/services/ocr2/plugins/ccip/commit_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
libocr2 "github.com/smartcontractkit/libocr/offchainreporting2plus"

relaylogger "github.com/smartcontractkit/chainlink-relay/pkg/logger"

"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/contractutil"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/hashlib"
Expand Down Expand Up @@ -66,6 +67,14 @@ func NewCommitServices(lggr logger.Logger, jb job.Job, chainSet evm.LegacyChainC
if err != nil {
return nil, errors.Wrap(err, "failed getting the static config from the commitStore")
}
typeAndVersion, err := commitStore.TypeAndVersion(&bind.CallOpts{})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should change the loaders to also return the version, as we already parse it in LoadCommitStore

if err != nil {
return nil, errors.Wrap(err, "failed to get commitStore type and version")
}
_, commitStoreVersion, err := ccipconfig.ParseTypeAndVersion(typeAndVersion)
if err != nil {
return nil, errors.Wrap(err, "failed to parse commitStore type and version")
}
chainId, err := chainselectors.ChainIdFromSelector(staticConfig.SourceChainSelector)
if err != nil {
return nil, err
Expand Down Expand Up @@ -120,6 +129,7 @@ func NewCommitServices(lggr logger.Logger, jb job.Job, chainSet evm.LegacyChainC
destClient: destChain.Client(),
sourceClient: sourceChain.Client(),
commitStore: commitStore,
commitStoreVersion: commitStoreVersion,
leafHasher: leafHasher,
checkFinalityTags: sourceChain.Config().EVM().FinalityTagEnabled(),
})
Expand Down
Loading