Skip to content

Commit

Permalink
refactor bellatrix::ExecutionEngine
Browse files Browse the repository at this point in the history
drop extra implementations we don't necessary need
lay the ground work for future forks' implementation
  • Loading branch information
ralexstokes committed Sep 17, 2023
1 parent c5ebcf3 commit f529e41
Show file tree
Hide file tree
Showing 1,017 changed files with 21,662 additions and 16,861 deletions.
4 changes: 2 additions & 2 deletions ethereum-consensus/examples/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ fn main() {
let current_epoch = bellatrix::get_current_epoch(&state, &context);
dbg!(current_epoch);

let execution_engine = bellatrix::NoOpExecutionEngine;
let execution_engine = bellatrix::DefaultExecutionEngine::default();
let _ = bellatrix::state_transition(
&mut state,
&mut signed_block,
execution_engine,
&execution_engine,
Validation::Enabled,
&context,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use ethereum_consensus::{
altair::mainnet as altair,
bellatrix::{mainnet as bellatrix, NoOpExecutionEngine},
bellatrix::mainnet as bellatrix,
phase0::mainnet as phase0,
state_transition::mainnet::{Context, Executor},
state_transition::mainnet::{Context, ExecutionEngine, Executor},
};
use ssz_rs::prelude::*;
use std::error::Error;
Expand All @@ -13,7 +13,8 @@ fn main() -> std::result::Result<(), Box<dyn Error>> {

let genesis_state = phase0::BeaconState::default();
let context = Context::for_mainnet();
let mut executor = Executor::new(genesis_state.into(), NoOpExecutionEngine, context);
let execution_engine = ExecutionEngine::Bellatrix(bellatrix::DefaultExecutionEngine::default());
let mut executor = Executor::new(genesis_state.into(), execution_engine, context);

let mut block = phase0::SignedBeaconBlock::default();
block.message.slot = 1;
Expand Down
9 changes: 5 additions & 4 deletions ethereum-consensus/src/bellatrix/block_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
compute_timestamp_at_slot, get_current_epoch, get_randao_mix, is_execution_enabled,
is_merge_transition_complete, process_block_header, process_eth1_data, process_operations,
process_randao, process_sync_aggregate, BeaconBlock, BeaconState, ExecutionEngine,
ExecutionPayload, ExecutionPayloadHeader,
ExecutionPayload, ExecutionPayloadHeader, NewPayloadRequest,
},
state_transition::{invalid_operation_error, Context, InvalidExecutionPayload, Result},
};
Expand Down Expand Up @@ -47,7 +47,7 @@ pub fn process_execution_payload<
MAX_BYTES_PER_TRANSACTION,
MAX_TRANSACTIONS_PER_PAYLOAD,
>,
execution_engine: E,
execution_engine: &E,
context: &Context,
) -> Result<()> {
let parent_hash_invalid =
Expand Down Expand Up @@ -85,7 +85,8 @@ pub fn process_execution_payload<
))
}

execution_engine.notify_new_payload(payload)?;
let new_payload_request = NewPayloadRequest(payload);
execution_engine.verify_and_notify_new_payload(&new_payload_request)?;

state.latest_execution_payload_header = ExecutionPayloadHeader {
parent_hash: payload.parent_hash.clone(),
Expand Down Expand Up @@ -157,7 +158,7 @@ pub fn process_block<
MAX_BYTES_PER_TRANSACTION,
MAX_TRANSACTIONS_PER_PAYLOAD,
>,
execution_engine: E,
execution_engine: &E,
context: &Context,
) -> Result<()> {
process_block_header(state, block, context)?;
Expand Down
256 changes: 0 additions & 256 deletions ethereum-consensus/src/bellatrix/execution.rs

This file was deleted.

Loading

0 comments on commit f529e41

Please sign in to comment.