Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ExecutionEngine #245

Merged
merged 4 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
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
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