Remove merge transition code (#8761)

Co-Authored-By: dapplion <35266934+dapplion@users.noreply.github.com>
This commit is contained in:
Lion - dapplion
2026-02-24 20:20:28 -07:00
committed by GitHub
parent e59f1f03ef
commit d6bf53834f
39 changed files with 581 additions and 2433 deletions

View File

@@ -28,8 +28,6 @@ use types::{
Transactions, Uint256,
};
use super::DEFAULT_TERMINAL_BLOCK;
const TEST_BLOB_BUNDLE: &[u8] = include_bytes!("fixtures/mainnet/test_blobs_bundle.ssz");
const TEST_BLOB_BUNDLE_V2: &[u8] = include_bytes!("fixtures/mainnet/test_blobs_bundle_v2.ssz");
@@ -172,9 +170,6 @@ fn make_rng() -> Arc<Mutex<StdRng>> {
impl<E: EthSpec> ExecutionBlockGenerator<E> {
#[allow(clippy::too_many_arguments)]
pub fn new(
terminal_total_difficulty: Uint256,
terminal_block_number: u64,
terminal_block_hash: ExecutionBlockHash,
shanghai_time: Option<u64>,
cancun_time: Option<u64>,
prague_time: Option<u64>,
@@ -187,9 +182,9 @@ impl<E: EthSpec> ExecutionBlockGenerator<E> {
finalized_block_hash: <_>::default(),
blocks: <_>::default(),
block_hashes: <_>::default(),
terminal_total_difficulty,
terminal_block_number,
terminal_block_hash,
terminal_total_difficulty: Default::default(),
terminal_block_number: 0,
terminal_block_hash: Default::default(),
pending_payloads: <_>::default(),
next_payload_id: 0,
payload_ids: <_>::default(),
@@ -293,25 +288,6 @@ impl<E: EthSpec> ExecutionBlockGenerator<E> {
.and_then(|block| block.as_execution_payload())
}
pub fn move_to_block_prior_to_terminal_block(&mut self) -> Result<(), String> {
let target_block = self
.terminal_block_number
.checked_sub(1)
.ok_or("terminal pow block is 0")?;
self.move_to_pow_block(target_block)
}
pub fn move_to_terminal_block(&mut self) -> Result<(), String> {
self.move_to_pow_block(self.terminal_block_number)
}
pub fn move_to_pow_block(&mut self, target_block: u64) -> Result<(), String> {
let next_block = self.latest_block().unwrap().block_number() + 1;
assert!(target_block >= next_block);
self.insert_pow_blocks(next_block..=target_block)
}
pub fn drop_all_blocks(&mut self) {
self.blocks = <_>::default();
self.block_hashes = <_>::default();
@@ -879,27 +855,22 @@ fn payload_id_from_u64(n: u64) -> PayloadId {
n.to_le_bytes()
}
pub fn generate_genesis_header<E: EthSpec>(
spec: &ChainSpec,
post_transition_merge: bool,
) -> Option<ExecutionPayloadHeader<E>> {
pub fn generate_genesis_header<E: EthSpec>(spec: &ChainSpec) -> Option<ExecutionPayloadHeader<E>> {
let genesis_fork = spec.fork_name_at_slot::<E>(spec.genesis_slot);
let genesis_block_hash =
generate_genesis_block(spec.terminal_total_difficulty, DEFAULT_TERMINAL_BLOCK)
.ok()
.map(|block| block.block_hash);
let genesis_block_hash = generate_genesis_block(Default::default(), 0)
.ok()
.map(|block| block.block_hash);
let empty_transactions_root = Transactions::<E>::empty().tree_hash_root();
match genesis_fork {
ForkName::Base | ForkName::Altair => None,
ForkName::Base | ForkName::Altair => {
// Pre-Bellatrix forks have no execution payload
None
}
ForkName::Bellatrix => {
if post_transition_merge {
let mut header = ExecutionPayloadHeader::Bellatrix(<_>::default());
*header.block_hash_mut() = genesis_block_hash.unwrap_or_default();
*header.transactions_root_mut() = empty_transactions_root;
Some(header)
} else {
Some(ExecutionPayloadHeader::<E>::Bellatrix(<_>::default()))
}
let mut header = ExecutionPayloadHeader::Bellatrix(<_>::default());
*header.block_hash_mut() = genesis_block_hash.unwrap_or_default();
*header.transactions_root_mut() = empty_transactions_root;
Some(header)
}
ForkName::Capella => {
let mut header = ExecutionPayloadHeader::Capella(<_>::default());
@@ -985,70 +956,6 @@ mod test {
use kzg::{Bytes48, CellRef, KzgBlobRef, trusted_setup::get_trusted_setup};
use types::{MainnetEthSpec, MinimalEthSpec};
#[test]
fn pow_chain_only() {
const TERMINAL_DIFFICULTY: u64 = 10;
const TERMINAL_BLOCK: u64 = 10;
const DIFFICULTY_INCREMENT: u64 = 1;
let mut generator: ExecutionBlockGenerator<MainnetEthSpec> = ExecutionBlockGenerator::new(
Uint256::from(TERMINAL_DIFFICULTY),
TERMINAL_BLOCK,
ExecutionBlockHash::zero(),
None,
None,
None,
None,
None,
None,
);
for i in 0..=TERMINAL_BLOCK {
if i > 0 {
generator.insert_pow_block(i).unwrap();
}
/*
* Generate a block, inspect it.
*/
let block = generator.latest_block().unwrap();
assert_eq!(block.block_number(), i);
let expected_parent = i
.checked_sub(1)
.map(|i| generator.block_by_number(i).unwrap().block_hash())
.unwrap_or_else(ExecutionBlockHash::zero);
assert_eq!(block.parent_hash(), expected_parent);
assert_eq!(
block.total_difficulty().unwrap(),
Uint256::from(i * DIFFICULTY_INCREMENT)
);
assert_eq!(generator.block_by_hash(block.block_hash()).unwrap(), block);
assert_eq!(generator.block_by_number(i).unwrap(), block);
/*
* Check the parent is accessible.
*/
if let Some(prev_i) = i.checked_sub(1) {
assert_eq!(
generator.block_by_number(prev_i).unwrap(),
generator.block_by_hash(block.parent_hash()).unwrap()
);
}
/*
* Check the next block is inaccessible.
*/
let next_i = i + 1;
assert!(generator.block_by_number(next_i).is_none());
}
}
#[test]
fn valid_test_blobs_bundle_v1() {
assert!(

View File

@@ -1,9 +1,4 @@
use crate::{
test_utils::{
DEFAULT_JWT_SECRET, DEFAULT_TERMINAL_BLOCK, DEFAULT_TERMINAL_DIFFICULTY, MockServer,
},
*,
};
use crate::{test_utils::DEFAULT_JWT_SECRET, test_utils::MockServer, *};
use alloy_primitives::B256 as H256;
use fixed_bytes::FixedBytesExtended;
use kzg::Kzg;
@@ -20,12 +15,10 @@ pub struct MockExecutionLayer<E: EthSpec> {
impl<E: EthSpec> MockExecutionLayer<E> {
pub fn default_params(executor: TaskExecutor) -> Self {
let mut spec = MainnetEthSpec::default_spec();
spec.terminal_total_difficulty = Uint256::from(DEFAULT_TERMINAL_DIFFICULTY);
spec.terminal_block_hash = ExecutionBlockHash::zero();
spec.terminal_block_hash_activation_epoch = Epoch::new(0);
Self::new(
executor,
DEFAULT_TERMINAL_BLOCK,
None,
None,
None,
@@ -40,7 +33,6 @@ impl<E: EthSpec> MockExecutionLayer<E> {
#[allow(clippy::too_many_arguments)]
pub fn new(
executor: TaskExecutor,
terminal_block: u64,
shanghai_time: Option<u64>,
cancun_time: Option<u64>,
prague_time: Option<u64>,
@@ -56,9 +48,6 @@ impl<E: EthSpec> MockExecutionLayer<E> {
let server = MockServer::new(
&handle,
jwt_key,
spec.terminal_total_difficulty,
terminal_block,
spec.terminal_block_hash,
shanghai_time,
cancun_time,
prague_time,
@@ -293,53 +282,4 @@ impl<E: EthSpec> MockExecutionLayer<E> {
assert_eq!(head_execution_block.block_hash(), block_hash);
assert_eq!(head_execution_block.parent_hash(), parent_hash);
}
pub fn move_to_block_prior_to_terminal_block(self) -> Self {
self.server
.execution_block_generator()
.move_to_block_prior_to_terminal_block()
.unwrap();
self
}
pub fn move_to_terminal_block(self) -> Self {
self.server
.execution_block_generator()
.move_to_terminal_block()
.unwrap();
self
}
pub fn produce_forked_pow_block(self) -> (Self, ExecutionBlockHash) {
let head_block = self
.server
.execution_block_generator()
.latest_block()
.unwrap();
let block_hash = self
.server
.execution_block_generator()
.insert_pow_block_by_hash(head_block.parent_hash(), 1)
.unwrap();
(self, block_hash)
}
pub async fn with_terminal_block<U, V>(self, func: U) -> Self
where
U: Fn(Arc<ChainSpec>, ExecutionLayer<E>, Option<ExecutionBlock>) -> V,
V: Future<Output = ()>,
{
let terminal_block_number = self
.server
.execution_block_generator()
.terminal_block_number;
let terminal_block = self
.server
.execution_block_generator()
.execution_block_by_number(terminal_block_number);
func(self.spec.clone(), self.el.clone(), terminal_block).await;
self
}
}

View File

@@ -35,8 +35,6 @@ pub use hook::Hook;
pub use mock_builder::{MockBuilder, Operation, mock_builder_extra_data};
pub use mock_execution_layer::MockExecutionLayer;
pub const DEFAULT_TERMINAL_DIFFICULTY: u64 = 6400;
pub const DEFAULT_TERMINAL_BLOCK: u64 = 64;
pub const DEFAULT_JWT_SECRET: [u8; 32] = [42; 32];
pub const DEFAULT_MOCK_EL_PAYLOAD_VALUE_WEI: u128 = 10_000_000_000_000_000;
pub const DEFAULT_BUILDER_PAYLOAD_VALUE_WEI: u128 = 20_000_000_000_000_000;
@@ -79,9 +77,6 @@ mod mock_execution_layer;
pub struct MockExecutionConfig {
pub server_config: Config,
pub jwt_key: JwtKey,
pub terminal_difficulty: Uint256,
pub terminal_block: u64,
pub terminal_block_hash: ExecutionBlockHash,
pub shanghai_time: Option<u64>,
pub cancun_time: Option<u64>,
pub prague_time: Option<u64>,
@@ -93,9 +88,6 @@ impl Default for MockExecutionConfig {
fn default() -> Self {
Self {
jwt_key: JwtKey::random(),
terminal_difficulty: Uint256::from(DEFAULT_TERMINAL_DIFFICULTY),
terminal_block: DEFAULT_TERMINAL_BLOCK,
terminal_block_hash: ExecutionBlockHash::zero(),
server_config: Config::default(),
shanghai_time: None,
cancun_time: None,
@@ -118,9 +110,6 @@ impl<E: EthSpec> MockServer<E> {
Self::new(
&runtime::Handle::current(),
JwtKey::from_slice(&DEFAULT_JWT_SECRET).unwrap(),
Uint256::from(DEFAULT_TERMINAL_DIFFICULTY),
DEFAULT_TERMINAL_BLOCK,
ExecutionBlockHash::zero(),
None, // FIXME(capella): should this be the default?
None, // FIXME(deneb): should this be the default?
None, // FIXME(electra): should this be the default?
@@ -138,9 +127,6 @@ impl<E: EthSpec> MockServer<E> {
create_test_tracing_subscriber();
let MockExecutionConfig {
jwt_key,
terminal_difficulty,
terminal_block,
terminal_block_hash,
server_config,
shanghai_time,
cancun_time,
@@ -151,9 +137,6 @@ impl<E: EthSpec> MockServer<E> {
let last_echo_request = Arc::new(RwLock::new(None));
let preloaded_responses = Arc::new(Mutex::new(vec![]));
let execution_block_generator = ExecutionBlockGenerator::new(
terminal_difficulty,
terminal_block,
terminal_block_hash,
shanghai_time,
cancun_time,
prague_time,
@@ -215,9 +198,6 @@ impl<E: EthSpec> MockServer<E> {
pub fn new(
handle: &runtime::Handle,
jwt_key: JwtKey,
terminal_difficulty: Uint256,
terminal_block: u64,
terminal_block_hash: ExecutionBlockHash,
shanghai_time: Option<u64>,
cancun_time: Option<u64>,
prague_time: Option<u64>,
@@ -230,9 +210,6 @@ impl<E: EthSpec> MockServer<E> {
MockExecutionConfig {
server_config: Config::default(),
jwt_key,
terminal_difficulty,
terminal_block,
terminal_block_hash,
shanghai_time,
cancun_time,
prague_time,