Skip to content
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

Merged
merged 42 commits into from
Aug 31, 2024
Merged

Conversation

leruaa
Copy link
Contributor

@leruaa leruaa commented Aug 11, 2024

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.

leruaa added 30 commits July 17, 2024 20:22
@klkvr klkvr force-pushed the alloy_tx_eip1559 branch from cea58d8 to 41633de Compare August 29, 2024 16:46
@klkvr klkvr force-pushed the alloy_tx_eip1559 branch from 41633de to 04971f8 Compare August 29, 2024 18:09
@klkvr klkvr mentioned this pull request Aug 30, 2024
1 task
@klkvr klkvr marked this pull request as ready for review August 30, 2024 13:26
Copy link
Member

@emhane emhane left a 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

Comment on lines 7 to 73
/// 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,
}
Copy link
Member

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

Copy link
Collaborator

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

Copy link
Member

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.

@klkvr klkvr requested a review from emhane August 31, 2024 12:41
pub(crate) struct TxEip1559 {
chain_id: ChainId,
nonce: u64,
gas_limit: u64,
Copy link
Member

@emhane emhane Aug 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

@emhane emhane added this pull request to the merge queue Aug 31, 2024
Merged via the queue into paradigmxyz:main with commit 3a49a55 Aug 31, 2024
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-debt Refactor of code section that is hard to understand or maintain
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants