-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add L1 gas cost estimation feature to L1 gas oracle #11812
Conversation
I see that you haven't updated any README files. Would it make sense to do so? |
…ptimism, and Scroll
b88192f
to
3c38d6f
Compare
precompile := common.HexToAddress(o.l1GasPriceAddress) | ||
callData, err = o.l1GasPriceMethodAbi.Pack(o.gasPriceMethod) | ||
if err != nil { | ||
o.logger.Errorf("failed to pack calldata for %s L1 gas price method: %w", o.chainType, err) |
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 know this behavior is same as previously.
But in these cases of errors, could we set them somewhere, and let it be reportable via HealthReport()?
Currently I see HealthReport always reports Healthy.
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 updated the code to append these errors to the SvcErrBuffer
which should return all of the errors joined together when Healthy()
is called.
PollPeriod = 12 * time.Second | ||
|
||
// RPC call timeout | ||
queryTimeout = 10 * time.Second |
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.
Not sure, but is it possible to use a configured RPC timeout like other components are doing?
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.
Ideally let's reuse something that already exists
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 tried to look through existing configs and didn't find one for RPC timeouts. Even in chains/evm/client
, we have 10s hard coded which is used by ContextWithDefaultTimeout
. It makes sense for this to be configurable but I think I'd have to add a new config for this.
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.
Actually I see RequestTimeout for Starknet which I could maybe leverage. But it may be misleading if the rest of our code isn't using this config for RPC timeouts.
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.
Yeah, QueryTimeout was the config I was thinking of. You can probably use evmclient.ContextWithDefaultTimeout()
here instead of having a new config and let the client handle the timeout.
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 updated the code to use the client.QueryTimeout
. I was avoiding using ContextWithDefaultTimeout
since it just uses context.Background()
under the hood and we have a ctx passed into the method we could use.
KromaGasOracle_l1BaseFee = "l1BaseFee" | ||
|
||
// Interval at which to poll for L1BaseFee. A good starting point is the L1 block time. | ||
PollPeriod = 12 * time.Second |
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 know this is same as previously.
But 12 seconds could sometimes mean our price estimates can be 11-12 seconds stale.
Could we make this a configurable setting, or if not, atleast change the default to 6 seconds?
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.
} | ||
} | ||
|
||
func (o *l1Oracle) refresh() (t *time.Timer) { |
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 for a future PR.
But we ought to have some logic to start giving errors to all methods from the l1Oracle, if we fail to fetch fresh prices for last 12-20 seconds.
Otherwise with current logic, we keep using stale prices, which may be worse behavior for applications.
Perhaps if we just report errors in such cases, it may be better.
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 added tracking for when the price was refreshed so we can validate for stale prices on read. Is this what you had in mind?
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, perfect!
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 there a link where we can find these ABIs? It would be nice to add it 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.
Good idea. I just got them from arbiscan and optimistic.etherscan but I can link those in the comments.
SonarQube Quality Gate |
Added the ability to retrieve L1 gas cost estimation from the L1 gas oracle for Arbitrum, Optimism, and Scroll