Skip to content

Commit 83158ad

Browse files
authored
fix(l1): fixed proper parent when receiveing a NewPayloadRequest (#2690)
**Motivation** This pr aims to fix a bug with the parent assigned in NewPayloadRequest if the parent is valid. From the [Paris fork documentation](https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md) "latestValidHash: DATA|null, 32 Bytes - the hash of the most recent valid block in the branch defined by payload and its ancestors" **Description** Removed storage get for the canonical latest valid ancestor and replaced with the parent hash (if it's valid). Fixes 27 tests in #1285 in "engine-cancun"
1 parent 7da4c07 commit 83158ad

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

.github/workflows/pr-main_l1.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ jobs:
155155
ethrex_flags: ""
156156
- name: "Cancun Engine tests"
157157
simulation: ethereum/engine
158-
test_pattern: "engine-cancun/Blob Transactions On Block 1|Blob Transaction Ordering, Single|Blob Transaction Ordering, Multiple Accounts|Replace Blob Transactions|Parallel Blob Transactions|ForkchoiceUpdatedV3|ForkchoiceUpdatedV2|ForkchoiceUpdated Version|GetPayload|NewPayloadV3 After Cancun|NewPayloadV3 Before Cancun|NewPayloadV3 Versioned Hashes|Incorrect BlobGasUsed|ParentHash equals BlockHash|RPC:|in ForkchoiceState|Unknown SafeBlockHash|Unknown FinalizedBlockHash|Unique|Re-Execute Payload|Multiple New Payloads|NewPayload with|Build Payload with|Re-org to Previously|Safe Re-Org to Side Chain|Transaction Re-Org|Re-Org Back into Canonical Chain, Depth=5|Suggested Fee Recipient Test|PrevRandao Opcode|Fork ID: *|Request Blob Pooled Transactions|Invalid NewPayload, Incomplete Transactions|Re-Org Back to Canonical Chain*|Invalid PayloadAttributes*|Invalid NewPayload, VersionedHashes|Invalid NewPayload, Incomplete VersionedHashes|Invalid NewPayload, Extra VersionedHashes|Bad Hash on NewPayload|Unknown HeadBlockHash|In-Order Consecutive Payload Execution|Valid NewPayload->ForkchoiceUpdated|Invalid NewPayload, ParentHash|Syncing=False|Payload Build after New Invalid Payload" # Invalid Missing Ancestor Syncing ReOrg|Invalid P9|Invalid P10 -> flaky
158+
test_pattern: "engine-cancun/Blob Transactions On Block 1|Blob Transaction Ordering, Single|Blob Transaction Ordering, Multiple Accounts|Replace Blob Transactions|Parallel Blob Transactions|ForkchoiceUpdatedV3|ForkchoiceUpdatedV2|ForkchoiceUpdated Version|GetPayload|NewPayloadV3 After Cancun|NewPayloadV3 Before Cancun|NewPayloadV3 Versioned Hashes|Incorrect BlobGasUsed|ParentHash equals BlockHash|RPC:|in ForkchoiceState|Unknown SafeBlockHash|Unknown FinalizedBlockHash|Unique|Re-Execute Payload|Multiple New Payloads|NewPayload with|Build Payload with|Re-org to Previously|Safe Re-Org to Side Chain|Transaction Re-Org|Re-Org Back into Canonical Chain, Depth=5|Suggested Fee Recipient Test|PrevRandao Opcode|Fork ID: *|Request Blob Pooled Transactions|Invalid NewPayload, Incomplete Transactions|Re-Org Back to Canonical Chain*|Invalid PayloadAttributes*|Invalid NewPayload, VersionedHashes|Invalid NewPayload, Incomplete VersionedHashes|Invalid NewPayload, Extra VersionedHashes|Bad Hash on NewPayload|Unknown HeadBlockHash|In-Order Consecutive Payload Execution|Valid NewPayload->ForkchoiceUpdated|Invalid NewPayload, ParentHash|Syncing=False|Payload Build after New Invalid Payload|Invalid NewPayload|Invalid Missing Ancestor"
159159
ethrex_flags: ""
160160
- name: "Paris Engine tests"
161161
simulation: ethereum/engine

crates/networking/rpc/engine/payload.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -622,13 +622,16 @@ async fn handle_new_payload_v1_v2(
622622
return Ok(status);
623623
}
624624

625+
// We have validated ancestors, the parent is correct
626+
let latest_valid_hash = block.header.parent_hash;
627+
625628
if context.syncer.sync_mode() == SyncMode::Snap {
626629
warn!("Snap sync in progress, skipping new payload validation");
627630
return Ok(PayloadStatus::syncing());
628631
}
629632

630633
// All checks passed, execute payload
631-
let payload_status = try_execute_payload(&block, &context).await?;
634+
let payload_status = try_execute_payload(&block, &context, latest_valid_hash).await?;
632635
Ok(payload_status)
633636
}
634637

@@ -699,6 +702,7 @@ fn validate_block_hash(payload: &ExecutionPayload, block: &Block) -> Result<(),
699702
async fn try_execute_payload(
700703
block: &Block,
701704
context: &RpcApiContext,
705+
latest_valid_hash: H256,
702706
) -> Result<PayloadStatus, RpcErr> {
703707
let block_hash = block.hash();
704708
let storage = &context.storage;
@@ -710,16 +714,6 @@ async fn try_execute_payload(
710714
// Execute and store the block
711715
info!("Executing payload with block hash: {block_hash:#x}");
712716

713-
// TODO: this is not correct, the block being validated it no necesarily a descendant
714-
// of the latest canonical block
715-
let latest_valid_hash = context
716-
.storage
717-
.get_latest_canonical_block_hash()
718-
.await?
719-
.ok_or(RpcErr::Internal(
720-
"Missing latest canonical block".to_owned(),
721-
))?;
722-
723717
match context.blockchain.add_block(block).await {
724718
Err(ChainError::ParentNotFound) => {
725719
// Start sync

0 commit comments

Comments
 (0)