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: Duplicate Withdrawal and move try from impls to rpc-compat #4186

Merged
merged 30 commits into from
Sep 19, 2023

Conversation

supernovahs
Copy link
Contributor

@supernovahs supernovahs commented Aug 14, 2023

@codecov
Copy link

codecov bot commented Aug 14, 2023

Codecov Report

Merging #4186 (d9a5306) into main (55339d7) will increase coverage by 0.19%.
Report is 5 commits behind head on main.
The diff coverage is 47.11%.

Impacted file tree graph

Files Changed Coverage Δ
crates/payload/builder/src/payload.rs 0.00% <0.00%> (ø)
crates/rpc/rpc-types/src/eth/engine/payload.rs 74.56% <ø> (+9.51%) ⬆️
crates/rpc/rpc-types-compat/src/engine/payload.rs 44.23% <44.23%> (ø)
crates/rpc/rpc-types/src/eth/withdrawal.rs 75.00% <75.00%> (ø)
crates/consensus/beacon/src/engine/mod.rs 74.58% <100.00%> (+0.15%) ⬆️
crates/rpc/rpc-engine-api/src/engine_api.rs 79.44% <100.00%> (+0.10%) ⬆️
crates/rpc/rpc-engine-api/src/payload.rs 75.00% <100.00%> (ø)

... and 25 files with indirect coverage changes

Flag Coverage Δ
integration-tests 16.80% <37.50%> (-0.15%) ⬇️
unit-tests 63.40% <40.70%> (+0.22%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
reth binary 32.17% <ø> (+0.20%) ⬆️
blockchain tree 83.59% <ø> (ø)
pipeline 88.54% <ø> (ø)
storage (db) 73.47% <ø> (ø)
trie 94.73% <ø> (-0.04%) ⬇️
txpool 49.91% <ø> (+0.46%) ⬆️
networking 77.43% <ø> (+0.20%) ⬆️
rpc 57.44% <47.70%> (+0.09%) ⬆️
consensus 62.66% <100.00%> (+0.07%) ⬆️
revm 28.04% <ø> (+8.38%) ⬆️
payload builder 8.45% <0.00%> (-0.61%) ⬇️
primitives 86.54% <ø> (+0.10%) ⬆️

@supernovahs supernovahs marked this pull request as ready for review August 14, 2023 12:17
@supernovahs
Copy link
Contributor Author

Since SealedBlock is also using Withdrawal under the hood, I think we would also have to move it, for now I have not moved it.

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

great start,

this requires some cleaning up

crates/rpc/rpc-engine-api/tests/it/payload.rs Outdated Show resolved Hide resolved
crates/rpc/rpc-types/src/eth/withdrawal.rs Outdated Show resolved Hide resolved
crates/rpc/rpc-types/src/eth/withdrawal.rs Outdated Show resolved Hide resolved
crates/rpc/rpc-types/src/eth/withdrawal.rs Outdated Show resolved Hide resolved
crates/rpc/rpc-types/Cargo.toml Outdated Show resolved Hide resolved
crates/rpc/rpc-types/Cargo.toml Outdated Show resolved Hide resolved
Comment on lines 14 to 34
impl From<&Withdrawal> for StandaloneWithdraw {
fn from(withdrawal: &Withdrawal) -> Self {
StandaloneWithdraw {
index: withdrawal.index,
validator_index: withdrawal.validator_index,
address: withdrawal.address,
amount: withdrawal.amount,
}
}
}

impl From<StandaloneWithdraw> for Withdrawal {
fn from(standalone: StandaloneWithdraw) -> Self {
Withdrawal {
index: standalone.index,
validator_index: standalone.validator_index,
address: standalone.address,
amount: standalone.amount,
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

if we include the conversion here then we cannot get rid of it which defeats the point of moving the conversions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad . Will fix

Copy link
Contributor Author

@supernovahs supernovahs Aug 16, 2023

Choose a reason for hiding this comment

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

If I implement the conversion in block.rs in primitives, then it leads to cyclic dependency error as I would have to import StandaloneWithdraw from rpc-types.
The. only way I can think is to duplicate block.rs as well in rpc-types?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

right, we should convert this tryfrom into a function instead, like the other things we moved to compat

@mattsse mattsse added the C-debt Refactor of code section that is hard to understand or maintain label Aug 15, 2023
@@ -98,13 +98,19 @@ impl PayloadBuilderAttributes {
/// Derives the unique [PayloadId] for the given parent and attributes
pub fn new(parent: H256, attributes: PayloadAttributes) -> Self {
let id = payload_id(&parent, &attributes);
let withdraw = attributes.withdrawals.as_ref().map(|withdrawals| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let withdraw = attributes.withdrawals.as_ref().map(|withdrawals| {
let withdrawals = attributes.withdrawals.as_ref().map(|withdrawals| {

Comment on lines 14 to 34
impl From<&Withdrawal> for StandaloneWithdraw {
fn from(withdrawal: &Withdrawal) -> Self {
StandaloneWithdraw {
index: withdrawal.index,
validator_index: withdrawal.validator_index,
address: withdrawal.address,
amount: withdrawal.amount,
}
}
}

impl From<StandaloneWithdraw> for Withdrawal {
fn from(standalone: StandaloneWithdraw) -> Self {
Withdrawal {
index: standalone.index,
validator_index: standalone.validator_index,
address: standalone.address,
amount: standalone.amount,
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

right, we should convert this tryfrom into a function instead, like the other things we moved to compat

@supernovahs
Copy link
Contributor Author

4 tests are failing in https://github.com/paradigmxyz/reth/blob/main/crates/consensus/beacon/src/engine/mod.rs

Investigating why it happened
`failures:

engine::tests::new_payload::new_payload_before_forkchoice

engine::tests::new_payload::payload_known

engine::tests::new_payload::payload_parent_unknown

engine::tests::new_payload::payload_pre_merge

`

failures:

---- engine::tests::new_payload::new_payload_before_forkchoice stdout ----
thread 'engine::tests::new_payload::new_payload_before_forkchoice' panicked at 'assertion failed: `(left == right)`
  left: `PayloadStatus { status: Invalid { validation_error: "blockhash mismatch, want 0xb4c1…c075, got 0x5053…ad13" }, latest_valid_hash: None }`,
 right: `PayloadStatus { status: Syncing, latest_valid_hash: None }`', crates/consensus/beacon/src/engine/mod.rs:2261:48
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- engine::tests::new_payload::payload_parent_unknown stdout ----
thread 'engine::tests::new_payload::payload_parent_unknown' panicked at 'assertion failed: `(left == right)`
  left: `PayloadStatus { status: Invalid { validation_error: "blockhash mismatch, want 0x6d5a…81a7, got 0x03e0…9bf6" }, latest_valid_hash: None }`,
 right: `PayloadStatus { status: Syncing, latest_valid_hash: None }`', crates/consensus/beacon/src/engine/mod.rs:2409:48

---- engine::tests::new_payload::payload_known stdout ----
thread 'engine::tests::new_payload::payload_known' panicked at 'assertion failed: `(left == right)`
  left: `PayloadStatus { status: Invalid { validation_error: "blockhash mismatch, want 0x9429…222a, got 0x853a…eb91" }, latest_valid_hash: None }`,
 right: `PayloadStatus { status: Valid, latest_valid_hash: Some(0x94292372ffb7a28138c3f2dcdacdc3f09f64203f641868af37c6e75fcdfe222a) }`', crates/consensus/beacon/src/engine/mod.rs:2312:13

---- engine::tests::new_payload::payload_pre_merge stdout ----
thread 'engine::tests::new_payload::payload_pre_merge' panicked at 'assertion failed: `(left == right)`
  left: `PayloadStatus { status: Invalid { validation_error: "blockhash mismatch, want 0x19ac…db7a, got 0x9895…3ff9" }, latest_valid_hash: None }`,
 right: `PayloadStatus { status: Invalid { validation_error: "Block 0x19acdf9d012fd0453a12b0c302f107c2f9836b2fcfc28f753b1399d68e97db7a is pre merge" }, latest_valid_hash: Some(0x0000000000000000000000000000000000000000000000000000000000000000) }`', crates/consensus/beacon/src/engine/mod.rs:2477:13

@mattsse
Copy link
Collaborator

mattsse commented Aug 29, 2023

any updates here @supernovahs?

this will become a blocker for us shortly,
if you don't have the bandwidth, lmk, happy to help getting this over the line

@supernovahs
Copy link
Contributor Author

Yeah actually I could not find why are the 4 tests failing . Any pointers would help

@supernovahs
Copy link
Contributor Author

@mattsse Can u take a look ? I'm not able to figure out why they are failing?Thx

@supernovahs
Copy link
Contributor Author

supernovahs commented Sep 16, 2023

@mattsse Can u review ? thx
Also clippy wants changes in pruner.

@supernovahs
Copy link
Contributor Author

Ready i think

@mattsse
Copy link
Collaborator

mattsse commented Sep 18, 2023

cool, checking shortly

@supernovahs
Copy link
Contributor Author

Yeah , got errors due to a recent update . Will update it tomorrow

@supernovahs
Copy link
Contributor Author

Fixed

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

great, a few nits.

wdyt @Rjected

crates/rpc/rpc-engine-api/src/payload.rs Show resolved Hide resolved
crates/rpc/rpc-types/src/eth/engine/payload.rs Outdated Show resolved Hide resolved
crates/rpc/rpc-types-compat/src/engine/payload.rs Outdated Show resolved Hide resolved
crates/rpc/rpc-types-compat/src/engine/payload.rs Outdated Show resolved Hide resolved
Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

This looks very close! Just one question and a few nits, otherwise lgtm

crates/rpc/rpc-types-compat/Cargo.toml Outdated Show resolved Hide resolved
@@ -0,0 +1,6 @@
//! Standalone functions for engine specific
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
//! Standalone functions for engine specific
//! Standalone functions for engine specific rpc type conversions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Comment on lines 7 to 13
pub mod payload;
mod transition;

pub use self::{cancun::*, forkchoice::*, payload::*, transition::*};
pub use payload::{
ExecutionPayload, ExecutionPayloadBodyV1, ExecutionPayloadFieldV2, ExecutionPayloadV1,
ExecutionPayloadV2, ExecutionPayloadV3, PayloadError, Withdrawal,
};
Copy link
Member

Choose a reason for hiding this comment

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

why wasn't the previous pub use self::payload::* sufficient here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

@mattsse mattsse added this pull request to the merge queue Sep 19, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Sep 19, 2023
@Rjected Rjected added this pull request to the merge queue Sep 19, 2023
Merged via the queue into paradigmxyz:main with commit 8012942 Sep 19, 2023
23 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