-
Notifications
You must be signed in to change notification settings - Fork 2
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
Exec v2 scaffolding to observes prices/costs #154
Conversation
15582d6
to
9c81cb9
Compare
Adds scaffolding to the V2 Exec Plugin to enable observing prices and costs (but does not yet observe these values). Once prices and costs are observed, message fees and costs can be computed, and messages with higher costs than paid fees can be filtered.
9c81cb9
to
9c01010
Compare
Test Coverage
|
// The price of Juels (the smallest denomination of LINK) in USD. Each CCIP message has a fee denominated in Juels. | ||
JuelPriceUSD cciptypes.BigInt `json:"juelPriceUSD"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add two things to this comment:
- price is in USD, but how many decimals?
- where is this price expected to be fetched from? e.g which price registry / feed contract
// The price of gas in the destination chain, denoted in the native token of the destination chain | ||
GasPrice cciptypes.BigInt `json:"gasPrice"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small rename to be consistent w/ the rest of the codebase:
// The price of gas in the destination chain, denoted in the native token of the destination chain | |
GasPrice cciptypes.BigInt `json:"gasPrice"` | |
// The price of gas in the destination chain, denoted in the native token of the destination chain | |
DestChainFee cciptypes.BigInt `json:"gasPrice"` |
Also, is this only execution fees or also data availability fees (like for L2's)? We should also state where this is fetched from, I believe in this case the source price registry. Make sure to update the comment to reflect this information as well.
// The price of the native token of the destination chain in USD | ||
DestNativeTokenPriceUSD cciptypes.BigInt `json:"destNativeTokenPriceUSD"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the juels comment, we need the number of decimals and the source of this information (I think in this case dest price registry)
// Maps message IDs to the estimated gas cost of executing these messages | ||
MessageExecutionGasCosts map[string]cciptypes.BigInt `json:"messageExecutionCosts"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Estimated gas cost is a chain-specific metric, do we want this to be USD instead?
Also, if it is USD, include the decimals count in the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, for this mapping, I believe we can use cciptypes.Bytes32
as the key type to bring it home that this is a msg ID. JSON encoding/decoding is already implemented for this type.
|
||
prices := exectypes.PriceObservations{} | ||
if p.messageExecutionEconomicsEnabled { | ||
prices, err = p.priceObserver.ObservePrices(messages) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really sufficient to just call this here? I believe the price observations are a mix of source and dest information, some nodes may have source info, some may have dest info, wouldn't we need to consensus-ify these values (median, etc.) and only then do the boosting on the medianized values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or is this stuff going to be done in upcoming PRs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Medianizing is happening in the outcome phase based on these observations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the price observations are a mix of source and dest information
Minor point, but I believe everything should be on the dest chain.
wouldn't we need to consensus-ify these values (median, etc.) and only then do the boosting on the medianized values?
We do this consensus in mergePriceObservations
in execute/plugin_functions.go
@@ -391,6 +454,7 @@ func getConsensusObservation( | |||
destChainSelector cciptypes.ChainSelector, | |||
F int, | |||
fChain map[cciptypes.ChainSelector]int, | |||
messageExecutionEconomicsEnabled bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could leave this out. The prices would be empty by default on account of no price observations being present. Add a check to VerifiyObservation that there are no price observations when the flag is false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks on track to me.
Adds scaffolding to the V2 Exec Plugin to enable observing prices and costs (but does not yet observe these values). Once prices and costs are observed, message fees and costs can be computed, and messages with higher costs than paid fees can be filtered.
The core data type is PriceObservations:
The message fee in USD will be:
message.jeuls * JuelPriceUSD * feeBoostFactor
The message execution cost will be
GasPrice * MessageExecutionGasCosts * DestNativeTokenPriceUSD