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: Eip 6110 #8204

Merged
merged 7 commits into from May 13, 2024
Merged

feat: Eip 6110 #8204

merged 7 commits into from May 13, 2024

Conversation

gakonst
Copy link
Member

@gakonst gakonst commented May 11, 2024

Adds EIP-6110, blocked on #8053

@gakonst gakonst changed the base branch from main to devnet-0 May 11, 2024 16:07
@gakonst gakonst mentioned this pull request May 13, 2024
10 tasks
@gakonst gakonst force-pushed the eip-6110 branch 2 times, most recently from 99b4802 to e4f3932 Compare May 13, 2024 12:18
/// Error when decoding deposit requests from receipts [EIP-6110]
///
/// [EIP-6110]: https://eips.ethereum.org/EIPS/eip-6110
// TODO(gakonst): This is an RLP decoding error but we don't import alloy_rlp here,
Copy link
Member

Choose a reason for hiding this comment

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

why not? It should be in reth_primitives already

}

// Collect all EIP-6110 deposits
let deposits = parse_deposits_from_receipts(&receipts)?;

// Collect all EIP-7685 requests
let withdrawal_requests =
post_block_withdrawal_requests(&self.chain_spec, block.timestamp, &mut evm)?;
Copy link
Member

@DaniPopes DaniPopes May 13, 2024

Choose a reason for hiding this comment

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

Should accumulate, extending a vector, rather than two vecs and concatenating after. Can be done with &mut Vec as argument and transforming the iterator into a for loop

Copy link
Member Author

Choose a reason for hiding this comment

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

The withdrawal function returns a Vec<Request> via Vec<Request>::decode and I cannot break out of the iterator without collecting so not sure how to do that here, also prob not big perf given smol list

Copy link
Member

Choose a reason for hiding this comment

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

i see, what about moving the parse_deposits to after post_block and extending that list?

@onbjerg onbjerg added C-enhancement New feature or request E-prague Related to the prague network upgrade labels May 13, 2024
crates/ethereum/evm/src/eip6110.rs Outdated Show resolved Hide resolved
crates/ethereum/evm/src/eip6110.rs Outdated Show resolved Hide resolved
}

fn parse_deposit_from_log(log: &Log<DepositEvent>) -> DepositRequest {
// SAFETY: These `expect` https://github.com/ethereum/consensus-specs/blob/5f48840f4d768bf0e0a8156a3ed06ec333589007/solidity_deposit_contract/deposit_contract.sol#L107-L110
Copy link
Member

Choose a reason for hiding this comment

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

great

Copy link
Member

Choose a reason for hiding this comment

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

nit: should be NOTE or something else, SAFETY should be reserved for unsafe {}

Copy link
Member Author

@gakonst gakonst May 13, 2024

Choose a reason for hiding this comment

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

# Panics in the doc of the function actually

Copy link
Member

Choose a reason for hiding this comment

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

@@ -158,11 +158,11 @@ impl BundleStateWithReceipts {
/// Transform block number to the index of block.
fn block_number_to_index(&self, block_number: BlockNumber) -> Option<usize> {
if self.first_block > block_number {
return None
return None;
Copy link
Member

Choose a reason for hiding this comment

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

grrrr

use reth_primitives::Receipt;
use revm_primitives::Log;

pub(crate) fn parse_deposits_from_receipts(
Copy link
Member

Choose a reason for hiding this comment

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

make it pub

Comment on lines +31 to +42
sol! {
#[allow(missing_docs)]
event DepositEvent(
bytes pubkey,
bytes withdrawal_credentials,
bytes amount,
bytes signature,
bytes index
);
}

fn parse_deposit_from_log(log: &Log<DepositEvent>) -> DepositRequest {
Copy link
Member

Choose a reason for hiding this comment

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

maybe we should put the DepositEvent in alloy-eips for the relevant eip, and have a conversion from DepositEvent → DepositRequest in alloy

Copy link
Member Author

Choose a reason for hiding this comment

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

agreed, let's do it after

Comment on lines 221 to 222
// TODO: Does order matter?
let requests = [deposits, withdrawal_requests].concat();
Copy link
Member

Choose a reason for hiding this comment

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

yes and this is the correct order

crates/ethereum/evm/src/execute.rs Outdated Show resolved Hide resolved
crates/ethereum/evm/src/execute.rs Outdated Show resolved Hide resolved
crates/ethereum/evm/src/execute.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@shekhirin shekhirin left a comment

Choose a reason for hiding this comment

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

LGTM, only variable naming nits. We can move a bunch of stuff to alloy but let's merge it as is now to iterate faster.

Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
@@ -311,7 +315,7 @@ where
receipts.iter(),
) {
debug!(target: "evm", %error, ?receipts, "receipts verification failed");
return Err(error)
return Err(error);
Copy link
Collaborator

Choose a reason for hiding this comment

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

hehe

Suggested change
return Err(error);
return Err(error)

@gakonst gakonst merged commit 34e1312 into devnet-0 May 13, 2024
18 of 20 checks passed
@gakonst gakonst deleted the eip-6110 branch May 13, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement New feature or request E-prague Related to the prague network upgrade
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants