Uh oh!
There was an error while loading. Please reload this page.
feat(utils): Utility functions for computing and estimating the max_fee of a proof - #1045
feat(utils): Utility functions for computing and estimating the max_fee of a proof#1045PatStiles wants to merge 23 commits into
max_fee of a proof#1045Conversation
MauroToscano
left a comment
There was a problem hiding this comment.
Decouple calculation from the fetching of the GasCost, and add tests assuming you have the GasCost. It can be just checking that one is bigger than another one
PatStiles
commented
Sep 23, 2024
@MauroToscano tests added |
MauroToscano
left a comment
There was a problem hiding this comment.
Mention this function in the one that is used to send a task, with ///, so the user knows this one should be used to get the right estimation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| /// Retrieves the `gas_price` from an rpc nodes. Specifically, it returns the max priority gas price. | ||
| async fn fetch_gas_price(eth_rpc_url: &str) -> Result<U256, errors::SubmitError> { | ||
| let eth_rpc_provider = | ||
| Provider::<Http>::try_from(eth_rpc_url).map_err(|e: url::ParseError| { | ||
| errors::VerificationError::EthereumProviderError(e.to_string()) | ||
| })?; | ||
| let gas_price = match eth_rpc_provider.get_gas_price().await { | ||
| Ok(price) => price, | ||
| Err(e) => { | ||
| return Err(SubmitError::GenericError(format!( | ||
| "Failed to fetch gas price: {:?}", | ||
| e | ||
| ))) | ||
| } | ||
| }; | ||
| Ok(gas_price) | ||
| } |
There was a problem hiding this comment.
I think it doesn't make much sense to define a function on our SDK just to call the rpc provider's get_gas_price method. Maybe a better pattern will be to instantiate a provider only once, and ask for the gas price directly to it. This data can be used directly in the other functions without the need need to instantiate a provider every time.
@Oppen if you have any thoughts on this please feel free to share them
There was a problem hiding this comment.
Decoupling fetching the gas cost was done in response to this comment above #1045 (review) in 514ca8d . Happy to revert the change if that is the consensus.
b94105f to
288737bCompareCo-authored-by: Urix <43704209+uri-99@users.noreply.github.com>
Co-authored-by: Urix <43704209+uri-99@users.noreply.github.com> Co-authored-by: JuArce <52429267+JuArce@users.noreply.github.com>
Co-authored-by: JuArce <52429267+JuArce@users.noreply.github.com>
Co-authored-by: Urix <43704209+uri-99@users.noreply.github.com>
Co-authored-by: Urix <43704209+uri-99@users.noreply.github.com>
This pr adds three functions to
aligned_sdk:estimate_max_fee: Returns to the user there estimatedmax_fee: Min, Default, Instant based on a theoretical batch of 32 proofs. 32 was decided upon as a suggested arbitrary large batch size.fee_per_proof: Returns thefee_per_proofof a batch size of sizenum_proofs_per_batchcompute_max_feee: returns the computingmax_feefor a proof based on (num_proofs/num_proofs_per_batch).It deduplicates constants originally found in
aligned-batcherthat can be imported once #964 is completed.