Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions crates/node/p2p/src/gossip/block_validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,25 @@
// CHECK: The payload is valid for the specific version of this block.
Self::validate_version_specific_payload(envelope)?;

// CHECK: The signature is valid.
let msg = envelope.payload_hash.signature_message(self.rollup_config.l2_chain_id);
let block_signer = *self.signer_recv.borrow();

Check warning on line 148 in crates/node/p2p/src/gossip/block_validity.rs

View check run for this annotation

Codecov / codecov/patch

crates/node/p2p/src/gossip/block_validity.rs#L147-L148

Added lines #L147 - L148 were not covered by tests

// The block has a valid signature.
let Ok(msg_signer) = envelope.signature.recover_address_from_prehash(&msg) else {
return Err(BlockInvalidError::Signature);

Check warning on line 152 in crates/node/p2p/src/gossip/block_validity.rs

View check run for this annotation

Codecov / codecov/patch

crates/node/p2p/src/gossip/block_validity.rs#L151-L152

Added lines #L151 - L152 were not covered by tests
};

// The block is signed by the expected signer (the unsafe block signer).
if msg_signer != block_signer {
return Err(BlockInvalidError::Signer { expected: msg_signer, received: block_signer });
}

// Mark the block as seen.
if self.seen_hashes.len() >= Self::SEEN_HASH_CACHE_SIZE {
self.seen_hashes.pop_first();
}

Check warning on line 163 in crates/node/p2p/src/gossip/block_validity.rs

View check run for this annotation

Codecov / codecov/patch

crates/node/p2p/src/gossip/block_validity.rs#L156-L163

Added lines #L156 - L163 were not covered by tests

if let Some(seen_hashes_at_height) =
self.seen_hashes.get_mut(&envelope.payload.block_number())
{
Expand All @@ -169,25 +188,6 @@
);
}

// CHECK: The signature is valid.
let msg = envelope.payload_hash.signature_message(self.rollup_config.l2_chain_id);
let block_signer = *self.signer_recv.borrow();

// The block has a valid signature.
let Ok(msg_signer) = envelope.signature.recover_address_from_prehash(&msg) else {
return Err(BlockInvalidError::Signature);
};

// The block is signed by the expected signer (the unsafe block signer).
if msg_signer != block_signer {
return Err(BlockInvalidError::Signer { expected: msg_signer, received: block_signer });
}

// Mark the block as seen.
if self.seen_hashes.len() >= Self::SEEN_HASH_CACHE_SIZE {
self.seen_hashes.pop_first();
}

Ok(())
}

Expand Down