-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat: Custom Base Token Gas Price Oracle #996
Conversation
This reverts commit 6e0c812.
…component feat(Gas Oracle): Conversion rate component
…emove-token-fetcher-singleton
…cher-singleton feat(Gas Oracle): Remove Fetcher singleton
@popzxc how would you recommend we test correct functionality of the added components? Any example we can use as a template? |
@juan518munoz I don't think that there exists a good template that would help testing this feature, though we do have some infra that may help with it. For instance, we already run tests in a matrix in CI. You can add a value for custom base token there, and when tests are ran for custom token, you may add the relevant config and spawn the server with the dev conversion rate fetcher. An example of such integration in CI could be found in this PR. That said, I believe that it should be done as a separate PR to not overly extend the scope for this PR. |
Implements a way to get the resource from the context Used at core/node/node_framework/src/implementations/layers/fee_input.rs
This reverts commit 08d67f5.
What ❔
This PR adds a new
BaseTokenFetcher
component to be used by custom base token stacks. It's in charge of caching the latest conversion rate between the base token andeth
so gas prices can be converted accordingly (bothl1_gas_price
andl1_pubdata_price
).A new config
toml
file is added holding the configuration for it, currently just ahost
andpoll_interval
variables to get the host from which the conversion rate is queried and how often the conversion rate is refreshed. The component is initialized by addingbase_token_fetcher
as a server--component
.There is also an example server component that acts like a sample conversion rate api, it returns a fixed conversion rate of value
42
. This component can instantiated by adding thedev_conversion_rate_api
argument to the the server components at initialization.To see a complete the implementations as a whole, run:
to quickly test out the fetcher component. This will be deleted once proper tests are written.
Disclaimer
As explained here, current implementation is not overflow safe, this is left for a pending continuation of this PR, as of this one, it's stated that there's no u64 safety.
Why ❔
Gas Prices in a custom base token setting need to be in the native currency of the chain. These prices are partially determined by l1 gas prices in L1, which are in
eth
, so a conversion is required.Checklist
zk fmt
andzk lint
.zk spellcheck
.zk linkcheck
.