-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: migrate to alloy TxEip1559 #10262
Conversation
…nsaction now (following bad merge)
cea58d8
to
41633de
Compare
41633de
to
04971f8
Compare
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.
lgtm, though same question as for eip4844 tx
/// A transaction with a priority fee ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)). | ||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Compact, Default, Serialize, Deserialize)] | ||
#[cfg_attr(test, derive(arbitrary::Arbitrary))] | ||
#[cfg_attr(test, crate::add_arbitrary_tests(compact))] | ||
pub(crate) struct TxEip1559 { | ||
/// Added as EIP-155: Simple replay attack protection | ||
chain_id: ChainId, | ||
|
||
/// A scalar value equal to the number of transactions sent by the sender; formally Tn. | ||
nonce: u64, | ||
|
||
/// A scalar value equal to the maximum | ||
/// amount of gas that should be used in executing | ||
/// this transaction. This is paid up-front, before any | ||
/// computation is done and may not be increased | ||
/// later; formally Tg. | ||
gas_limit: u64, | ||
|
||
/// A scalar value equal to the maximum | ||
/// amount of gas that should be used in executing | ||
/// this transaction. This is paid up-front, before any | ||
/// computation is done and may not be increased | ||
/// later; formally Tg. | ||
/// | ||
/// As ethereum circulation is around 120mil eth as of 2022 that is around | ||
/// 120000000000000000000000000 wei we are safe to use u128 as its max number is: | ||
/// 340282366920938463463374607431768211455 | ||
/// | ||
/// This is also known as `GasFeeCap` | ||
max_fee_per_gas: u128, | ||
|
||
/// Max Priority fee that transaction is paying | ||
/// | ||
/// As ethereum circulation is around 120mil eth as of 2022 that is around | ||
/// 120000000000000000000000000 wei we are safe to use u128 as its max number is: | ||
/// 340282366920938463463374607431768211455 | ||
/// | ||
/// This is also known as `GasTipCap` | ||
max_priority_fee_per_gas: u128, | ||
|
||
/// The 160-bit address of the message call’s recipient or, for a contract creation | ||
/// transaction, ∅, used here to denote the only member of B0 ; formally Tt. | ||
to: TxKind, | ||
|
||
/// A scalar value equal to the number of Wei to | ||
/// be transferred to the message call’s recipient or, | ||
/// in the case of contract creation, as an endowment | ||
/// to the newly created account; formally Tv. | ||
value: U256, | ||
|
||
/// The accessList specifies a list of addresses and storage keys; | ||
/// these addresses and storage keys are added into the `accessed_addresses` | ||
/// and `accessed_storage_keys` global sets (introduced in EIP-2929). | ||
/// A gas cost is charged, though at a discount relative to the cost of | ||
/// accessing outside the list. | ||
access_list: AccessList, | ||
|
||
/// Input has two uses depending if the transaction `to` field is [`TxKind::Create`] or | ||
/// [`TxKind::Call`]. | ||
/// | ||
/// Input as init code, or if `to` is [`TxKind::Create`]: An unlimited size byte array | ||
/// specifying the EVM-code for the account initialisation procedure `CREATE` | ||
/// | ||
/// Input as data, or if `to` is [`TxKind::Call`]: An unlimited size byte array specifying the | ||
/// input data of the message call, formally Td. | ||
input: Bytes, | ||
} |
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.
same q as on #10624, why are we not importing this type? the compact trait is defined in this crate, so is possible to impl on foreign type
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.
this is pretty much just a helper type to use derive
on. we could indeed just copy-paste previous derive expansion here, but it would require us to manually declare and maintain bitfield
fieldsets which might end up pretty vebose. also potential changes to Compact
derive won't be applied to those types
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.
ok, makes sense! please add @klkvr 's answer as a code comment above the type @leruaa . since this is an alloy duplicate, we should remove all the docs! instead just have docs above each field
/// See [`alloy_consensus::TxEip1559`].
this way we de-risk failing to update docs in reth if docs update in alloy. faulty docs/log output often leads to nasty bugs.
pub(crate) struct TxEip1559 { | ||
chain_id: ChainId, | ||
nonce: u64, | ||
gas_limit: u64, |
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.
gas_limit: u64, | |
#[cfg_attr(feature = "serde", serde(with = "alloy_serde::quantity"))] | |
gas_limit: u128, |
why can't we do this? nvm, realise it's essentially the same thing
Cf #9484
This PR is pending an alloy release in order to have the following commit included: alloy-rs/alloy#1138.
Also, this branch has been created on top of #9593.