Skip to content

Commit d686138

Browse files
Delete legacy payload reconstruction (#6213)
* Delete legacy payload reconstruction * Delete unneeded failing test * Merge remote-tracking branch 'origin/unstable' into remove-more-ethers * Merge remote-tracking branch 'origin/unstable' into remove-more-ethers * Cleanups
1 parent c0b4f01 commit d686138

File tree

10 files changed

+111
-756
lines changed

10 files changed

+111
-756
lines changed

beacon_node/beacon_chain/src/beacon_block_streamer.rs

Lines changed: 1 addition & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -710,10 +710,8 @@ impl From<Error> for BeaconChainError {
710710
mod tests {
711711
use crate::beacon_block_streamer::{BeaconBlockStreamer, CheckCaches};
712712
use crate::test_utils::{test_spec, BeaconChainHarness, EphemeralHarnessType};
713-
use execution_layer::test_utils::{Block, DEFAULT_ENGINE_CAPABILITIES};
714-
use execution_layer::EngineCapabilities;
713+
use execution_layer::test_utils::Block;
715714
use std::sync::LazyLock;
716-
use std::time::Duration;
717715
use tokio::sync::mpsc;
718716
use types::{
719717
ChainSpec, Epoch, EthSpec, FixedBytesExtended, Hash256, Keypair, MinimalEthSpec, Slot,
@@ -864,147 +862,4 @@ mod tests {
864862
}
865863
}
866864
}
867-
868-
#[tokio::test]
869-
async fn check_fallback_altair_to_electra() {
870-
let slots_per_epoch = MinimalEthSpec::slots_per_epoch() as usize;
871-
let num_epochs = 10;
872-
let bellatrix_fork_epoch = 2usize;
873-
let capella_fork_epoch = 4usize;
874-
let deneb_fork_epoch = 6usize;
875-
let electra_fork_epoch = 8usize;
876-
let num_blocks_produced = num_epochs * slots_per_epoch;
877-
878-
let mut spec = test_spec::<MinimalEthSpec>();
879-
spec.altair_fork_epoch = Some(Epoch::new(0));
880-
spec.bellatrix_fork_epoch = Some(Epoch::new(bellatrix_fork_epoch as u64));
881-
spec.capella_fork_epoch = Some(Epoch::new(capella_fork_epoch as u64));
882-
spec.deneb_fork_epoch = Some(Epoch::new(deneb_fork_epoch as u64));
883-
spec.electra_fork_epoch = Some(Epoch::new(electra_fork_epoch as u64));
884-
885-
let harness = get_harness(VALIDATOR_COUNT, spec);
886-
887-
// modify execution engine so it doesn't support engine_payloadBodiesBy* methods
888-
let mock_execution_layer = harness.mock_execution_layer.as_ref().unwrap();
889-
mock_execution_layer
890-
.server
891-
.set_engine_capabilities(EngineCapabilities {
892-
get_payload_bodies_by_hash_v1: false,
893-
get_payload_bodies_by_range_v1: false,
894-
..DEFAULT_ENGINE_CAPABILITIES
895-
});
896-
// refresh capabilities cache
897-
harness
898-
.chain
899-
.execution_layer
900-
.as_ref()
901-
.unwrap()
902-
.get_engine_capabilities(Some(Duration::ZERO))
903-
.await
904-
.unwrap();
905-
906-
// go to bellatrix fork
907-
harness
908-
.extend_slots(bellatrix_fork_epoch * slots_per_epoch)
909-
.await;
910-
// extend half an epoch
911-
harness.extend_slots(slots_per_epoch / 2).await;
912-
// trigger merge
913-
harness
914-
.execution_block_generator()
915-
.move_to_terminal_block()
916-
.expect("should move to terminal block");
917-
let timestamp = harness.get_timestamp_at_slot() + harness.spec.seconds_per_slot;
918-
harness
919-
.execution_block_generator()
920-
.modify_last_block(|block| {
921-
if let Block::PoW(terminal_block) = block {
922-
terminal_block.timestamp = timestamp;
923-
}
924-
});
925-
// finish out merge epoch
926-
harness.extend_slots(slots_per_epoch / 2).await;
927-
// finish rest of epochs
928-
harness
929-
.extend_slots((num_epochs - 1 - bellatrix_fork_epoch) * slots_per_epoch)
930-
.await;
931-
932-
let head = harness.chain.head_snapshot();
933-
let state = &head.beacon_state;
934-
935-
assert_eq!(
936-
state.slot(),
937-
Slot::new(num_blocks_produced as u64),
938-
"head should be at the current slot"
939-
);
940-
assert_eq!(
941-
state.current_epoch(),
942-
num_blocks_produced as u64 / MinimalEthSpec::slots_per_epoch(),
943-
"head should be at the expected epoch"
944-
);
945-
assert_eq!(
946-
state.current_justified_checkpoint().epoch,
947-
state.current_epoch() - 1,
948-
"the head should be justified one behind the current epoch"
949-
);
950-
assert_eq!(
951-
state.finalized_checkpoint().epoch,
952-
state.current_epoch() - 2,
953-
"the head should be finalized two behind the current epoch"
954-
);
955-
956-
let block_roots: Vec<Hash256> = harness
957-
.chain
958-
.forwards_iter_block_roots(Slot::new(0))
959-
.expect("should get iter")
960-
.map(Result::unwrap)
961-
.map(|(root, _)| root)
962-
.collect();
963-
964-
let mut expected_blocks = vec![];
965-
// get all blocks the old fashioned way
966-
for root in &block_roots {
967-
let block = harness
968-
.chain
969-
.get_block(root)
970-
.await
971-
.expect("should get block")
972-
.expect("block should exist");
973-
expected_blocks.push(block);
974-
}
975-
976-
for epoch in 0..num_epochs {
977-
let start = epoch * slots_per_epoch;
978-
let mut epoch_roots = vec![Hash256::zero(); slots_per_epoch];
979-
epoch_roots[..].clone_from_slice(&block_roots[start..(start + slots_per_epoch)]);
980-
let streamer = BeaconBlockStreamer::new(&harness.chain, CheckCaches::No)
981-
.expect("should create streamer");
982-
let (block_tx, mut block_rx) = mpsc::unbounded_channel();
983-
streamer.stream(epoch_roots.clone(), block_tx).await;
984-
985-
for (i, expected_root) in epoch_roots.into_iter().enumerate() {
986-
let (found_root, found_block_result) =
987-
block_rx.recv().await.expect("should get block");
988-
989-
assert_eq!(
990-
found_root, expected_root,
991-
"expected block root should match"
992-
);
993-
match found_block_result.as_ref() {
994-
Ok(maybe_block) => {
995-
let found_block = maybe_block.clone().expect("should have a block");
996-
let expected_block = expected_blocks
997-
.get(start + i)
998-
.expect("should get expected block");
999-
assert_eq!(
1000-
found_block.as_ref(),
1001-
expected_block,
1002-
"expected block should match found block"
1003-
);
1004-
}
1005-
Err(e) => panic!("Error retrieving block {}: {:?}", expected_root, e),
1006-
}
1007-
}
1008-
}
1009-
}
1010865
}

beacon_node/beacon_chain/src/bellatrix_readiness.rs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use crate::{BeaconChain, BeaconChainError as Error, BeaconChainTypes};
55
use execution_layer::BlockByNumberQuery;
66
use serde::{Deserialize, Serialize, Serializer};
7-
use slog::debug;
87
use std::fmt;
98
use std::fmt::Write;
109
use types::*;
@@ -199,7 +198,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
199198
else {
200199
return Ok(GenesisExecutionPayloadStatus::Irrelevant);
201200
};
202-
let fork = self.spec.fork_name_at_epoch(Epoch::new(0));
203201

204202
let execution_layer = self
205203
.execution_layer
@@ -222,49 +220,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
222220
});
223221
}
224222

225-
// Double-check the block by reconstructing it.
226-
let execution_payload = execution_layer
227-
.get_payload_by_hash_legacy(exec_block_hash, fork)
228-
.await
229-
.map_err(|e| Error::ExecutionLayerGetBlockByHashFailed(Box::new(e)))?
230-
.ok_or(Error::BlockHashMissingFromExecutionLayer(exec_block_hash))?;
231-
232-
// Verify payload integrity.
233-
let header_from_payload = ExecutionPayloadHeader::from(execution_payload.to_ref());
234-
235-
let got_transactions_root = header_from_payload.transactions_root();
236-
let expected_transactions_root = latest_execution_payload_header.transactions_root();
237-
let got_withdrawals_root = header_from_payload.withdrawals_root().ok();
238-
let expected_withdrawals_root = latest_execution_payload_header.withdrawals_root().ok();
239-
240-
if got_transactions_root != expected_transactions_root {
241-
return Ok(GenesisExecutionPayloadStatus::TransactionsRootMismatch {
242-
got: got_transactions_root,
243-
expected: expected_transactions_root,
244-
});
245-
}
246-
247-
if let Some(expected) = expected_withdrawals_root {
248-
if let Some(got) = got_withdrawals_root {
249-
if got != expected {
250-
return Ok(GenesisExecutionPayloadStatus::WithdrawalsRootMismatch {
251-
got,
252-
expected,
253-
});
254-
}
255-
}
256-
}
257-
258-
if header_from_payload.to_ref() != latest_execution_payload_header {
259-
debug!(
260-
self.log,
261-
"Genesis execution payload reconstruction failure";
262-
"consensus_node_header" => ?latest_execution_payload_header,
263-
"execution_node_header" => ?header_from_payload
264-
);
265-
return Ok(GenesisExecutionPayloadStatus::OtherMismatch);
266-
}
267-
268223
Ok(GenesisExecutionPayloadStatus::Correct(exec_block_hash))
269224
}
270225
}

0 commit comments

Comments
 (0)