Numeric type audit: network, consensus, provider, rpc-types#454
Numeric type audit: network, consensus, provider, rpc-types#454prestwich merged 13 commits intoalloy-rs:mainfrom
Conversation
* `gas_limit` -> `u128` * `gas` -> `u128` * `gas_price` -> `u128` * `max_fee_per_blob_gas` -> `u128` * `transaction_type` -> `u8` * `max_fee_per_gas` -> `u128` * `max_priority_fee_per_gas` -> `u128` * Consequently, changed fn args and return values accordingly. * Satisfies clippy, tests will fail.
mattsse
left a comment
There was a problem hiding this comment.
I think all of these make sense, primitive types are preferable imo.
gas being u128 should make some operations easier but should not affect math for any call arguments etc
Evalir
left a comment
There was a problem hiding this comment.
This mostly looks good to me, I'd just like to ensure we get the TODOs taken care of and add enough tests to be 100% sure we're not breaking serde
| /// later; formally Tg. | ||
| #[cfg_attr(feature = "serde", serde(with = "alloy_serde::u64_hex_or_decimal"))] | ||
| pub gas_limit: u64, | ||
| #[cfg_attr(feature = "serde", serde(with = "alloy_serde::u128_hex_or_decimal"))] |
There was a problem hiding this comment.
do any endpoints use decimal here? in other PRs we've avoided allowing decimal when nobody actually uses it
| #[serde( | ||
| default, | ||
| skip_serializing_if = "Option::is_none", | ||
| with = "alloy_serde::num::u128_hex_or_decimal_opt" |
There was a problem hiding this comment.
same question. pretty sure decimal would be illegal rpc response here? I don't mind tolerating it, but @mattsse asked for removal of decimal in other PRs
There was a problem hiding this comment.
+ 1 to removing decimal support
There was a problem hiding this comment.
makes sense, let's enforce strict quantity rules everywhere for core eth types
There was a problem hiding this comment.
side note, the U*** type deser DO accept decimal. so this is technically a breaking behavior change
|
followup work: #465 |
…#454) * num_type_audit: network, consensus, provider, rpc-types * `gas_limit` -> `u128` * `gas` -> `u128` * `gas_price` -> `u128` * `max_fee_per_blob_gas` -> `u128` * `transaction_type` -> `u8` * `max_fee_per_gas` -> `u128` * `max_priority_fee_per_gas` -> `u128` * Consequently, changed fn args and return values accordingly. * Satisfies clippy, tests will fail. * fix(rpc-type): transaction requests tests * fix(rpc-types): tests - transaction type * add u128_hex_or_decimal_opt serde * fix(providers): provider::tests * fix(providers): layers::gas::tests * fix: docs ci * fix(provider): estimate_gas should return u128 * add(serde): unit test for u128_hex_or_decimal_opt * fix(rpc-types, provider): use primitives in FeeHistory and its related methods * add u128_vec serde methods * ci nits * nit
Motivation
Ref #433
Solution
gas_limit->u128gas->u128gas_price->u128max_fee_per_blob_gas->u128transaction_type->u8max_fee_per_gas->u128max_priority_fee_per_gas->u128PR Checklist