-
Notifications
You must be signed in to change notification settings - Fork 3
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
Limit exec report based on gas estimate limits #56
Conversation
653a1e3
to
3e98152
Compare
6822ca0
to
e5ee623
Compare
Test Coverage
|
@@ -0,0 +1,81 @@ | |||
// Package evm provides an EVM implementation to the gas.EstimateProvider interface. | |||
// TODO: Move this package into the EVM repo, chainlink-ccip should be chain agnostic. |
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.
Lets have a ticket for this once you merge these changes 🙏
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.
var data []byte = msg.Data | ||
dataLength := len(data) | ||
|
||
// TODO: parse max gas from ExtraArgs. |
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.
To get this to work in the integration tests, for now I think we can duplicate the implementation here: https://github.com/smartcontractkit/chainlink/blob/6ab3eb5b67739ff88d3c4cf8ea125fd8273bc2b1/core/capabilities/ccip/ccipevm/helpers.go#L9-L13
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.
Ah dang actually this uses the ABI to decode. We definitely don't wanna import that here
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.
Maybe we can do a super hacky way for now, something like:
extraArgsNoTag := msg.ExtraArgs[4:]
// gas limit is always the first 32 bytes of ExtraArgs for EVM
gasLimitBytes := extraArgsNoTag[:32]
// convert bytes to big
gasLimit := new(big.Int).SetBytes(gasLimitBytes)
Maybe can pull this into a helper func and run a few test cases through it
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 was going to open a ticket and punt on that part until this function has access to go-ethereum.
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.
That's a good point - maybe implement the EVM version of this interface in the ccipevm package in chainlink? like e.g https://github.com/smartcontractkit/chainlink/blob/6ab3eb5b67739ff88d3c4cf8ea125fd8273bc2b1/core/capabilities/ccip/ccipevm/commitcodec.go#L21
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.
My understanding is that the ExtraArgs param is abi encoded, so it should be implemented somewhere that go-ethereum can be used, so probably not the ccip / chainlink repos.
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.
go-ethereum can (at least currently) be used in ccip and chainlink
"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" | ||
) | ||
|
||
const ( |
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.
How this gas cost estimations were made? Any risk of drifting after smart contract change or is the precision we are looking for enough even if a gas cost increase by x%?
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.
Yes, there is risk of drift. The current logic is taken from here, which are only accurate for 1.5. Hopefully v2 is similar.
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.
It would probably make sense to check it with onchain team when contracts are defined and audited.
Introduce
gas.EstimateProvider
interface for calculating whether estimated gas requirements should prevent an exec report from being created. This PR wires this interface into the plugin via standard factory methods, but hard codes it to theevm.EstimateProvider
implementation. This implementation will be moved to a separate repo in the future.Use
gas.EstimateProvider
as part of theverifyReport
check which is executed dynamically with different message sets to find the largest allowable report.The new factory parameter is initialized in the ccip repo with this PR: smartcontractkit/ccip#1274