Small fixes relating to genesis

This commit is contained in:
Michael Sproul
2026-02-26 10:20:47 +11:00
parent adfa3b882d
commit edf77a5298
2 changed files with 16 additions and 5 deletions

View File

@@ -5671,14 +5671,25 @@ async fn test_gloas_block_replay_with_envelopes() {
!blocks_pending.is_empty(), !blocks_pending.is_empty(),
"should have blocks for pending replay" "should have blocks for pending replay"
); );
// For Pending, no envelope for the last block; envelopes for intermediate blocks // For Pending, no envelope for the first block (slot 0) or last block; envelopes for
// whose payloads are canonical. // intermediate blocks whose payloads are canonical.
let expected_pending_envelopes = blocks_pending.len().saturating_sub(1); let expected_pending_envelopes = blocks_pending.len().saturating_sub(2);
assert_eq!( assert_eq!(
envelopes_pending.len(), envelopes_pending.len(),
expected_pending_envelopes, expected_pending_envelopes,
"pending replay should have envelopes for all blocks except the last" "pending replay should have envelopes for all blocks except the last"
); );
assert!(
blocks_pending
.iter()
.skip(1)
.take(envelopes_pending.len())
.map(|block| block.slot())
.eq(envelopes_pending
.iter()
.map(|envelope| envelope.message.slot)),
"block and envelope slots should match"
);
// Load blocks for Full replay (envelopes for all blocks including the last). // Load blocks for Full replay (envelopes for all blocks including the last).
let (blocks_full, envelopes_full) = store let (blocks_full, envelopes_full) = store

View File

@@ -320,8 +320,8 @@ where
.block_hash; .block_hash;
// Similar to `is_parent_block_full`, but reading the block hash from the // Similar to `is_parent_block_full`, but reading the block hash from the
// not-yet-applied `block`. // not-yet-applied `block`. The 0x0 case covers genesis (no block replay reqd).
if block.is_parent_block_full(latest_bid_block_hash) { if self.state.slot() != 0 && block.is_parent_block_full(latest_bid_block_hash) {
let envelope = next_envelope_at_slot(self.state.slot())?; let envelope = next_envelope_at_slot(self.state.slot())?;
// State root for the next slot processing is now the envelope's state root. // State root for the next slot processing is now the envelope's state root.
self.apply_payload_envelope(&envelope, state_root)? self.apply_payload_envelope(&envelope, state_root)?