diff --git a/Cargo.lock b/Cargo.lock index 7b5a80b..64a159c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1728,6 +1728,7 @@ checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" name = "eleel" version = "0.1.0" dependencies = [ + "async-channel", "axum", "clap", "eth2", diff --git a/Cargo.toml b/Cargo.toml index 54d3c95..cc3ae75 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,3 +32,4 @@ hmac = "0.12.1" sha2 = "0.10.7" toml = "0.8.0" hex = "0.4.3" +async-channel = "1.9.0" diff --git a/src/main.rs b/src/main.rs index 68ee1c6..087d935 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,6 @@ use execution_layer::http::{ ENGINE_GET_PAYLOAD_V3, ENGINE_NEW_PAYLOAD_V1, ENGINE_NEW_PAYLOAD_V2, ENGINE_NEW_PAYLOAD_V3, ETH_SYNCING, }; -use futures::channel::mpsc::channel; use slog::Logger; use std::net::SocketAddr; use std::sync::Arc; @@ -90,9 +89,9 @@ struct AppState { // TODO: do something with signal/signal_rx async fn new_task_executor(log: Logger) -> TaskExecutor { let handle = Handle::current(); - let (_signal, exit) = exit_future::signal(); - let (signal_tx, _signal_rx) = channel(1); - TaskExecutor::new(handle, exit, log, signal_tx) + let (_signal, exit) = async_channel::bounded(1); + let (shutdown_tx, _) = futures::channel::mpsc::channel(1); + TaskExecutor::new(handle, exit, log, shutdown_tx) } async fn handle_client_json_rpc( diff --git a/src/new_payload.rs b/src/new_payload.rs index a7c5b18..128e33b 100644 --- a/src/new_payload.rs +++ b/src/new_payload.rs @@ -3,8 +3,8 @@ use crate::{ multiplexer::{Multiplexer, NewPayloadCacheEntry}, types::{ ErrorResponse, JsonExecutionPayload, JsonPayloadStatusV1, JsonPayloadStatusV1Status, - JsonValue, NewPayloadRequest, NewPayloadRequestCapella, NewPayloadRequestDeneb, - NewPayloadRequestMerge, QuantityU64, Request, Response, + JsonValue, NewPayloadRequest, NewPayloadRequestBellatrix, NewPayloadRequestCapella, + NewPayloadRequestDeneb, QuantityU64, Request, Response, }, }; use eth2::types::{ @@ -156,8 +156,8 @@ impl Multiplexer { parent_beacon_block_root: Option, ) -> NewPayloadRequest { match execution_payload { - ExecutionPayload::Merge(execution_payload) => { - NewPayloadRequest::Merge(NewPayloadRequestMerge { execution_payload }) + ExecutionPayload::Bellatrix(execution_payload) => { + NewPayloadRequest::Bellatrix(NewPayloadRequestBellatrix { execution_payload }) } ExecutionPayload::Capella(execution_payload) => { NewPayloadRequest::Capella(NewPayloadRequestCapella { execution_payload }) @@ -172,6 +172,8 @@ impl Multiplexer { parent_beacon_block_root: parent_beacon_block_root.unwrap_or_default(), }) } + // TODO: Electra + ExecutionPayload::Electra(_) => todo!("Electra"), } } @@ -234,7 +236,7 @@ impl Multiplexer { let fork_name = self.spec.fork_name_at_slot::(slot); - let payload = if method == ENGINE_NEW_PAYLOAD_V1 || fork_name == ForkName::Merge { + let payload = if method == ENGINE_NEW_PAYLOAD_V1 || fork_name == ForkName::Bellatrix { serde_json::from_value(payload_json).map(JsonExecutionPayload::V1) } else if method == ENGINE_NEW_PAYLOAD_V2 || fork_name == ForkName::Capella { serde_json::from_value(payload_json).map(JsonExecutionPayload::V2) diff --git a/src/payload_builder.rs b/src/payload_builder.rs index 529411d..fc08622 100644 --- a/src/payload_builder.rs +++ b/src/payload_builder.rs @@ -8,8 +8,8 @@ use crate::{ ErrorResponse, Multiplexer, Request, Response, }; use eth2::types::{ - BlobsBundle, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadCapella, - ExecutionPayloadDeneb, ExecutionPayloadMerge, FixedVector, ForkName, Hash256, Uint256, + BlobsBundle, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadBellatrix, + ExecutionPayloadCapella, ExecutionPayloadDeneb, FixedVector, ForkName, Hash256, Uint256, Unsigned, VariableList, }; use execution_layer::{calculate_execution_block_hash, PayloadAttributes}; @@ -113,7 +113,7 @@ impl Multiplexer { let block_hash = ExecutionBlockHash::zero(); let mut payload = match fork_name { - ForkName::Merge => ExecutionPayload::Merge(ExecutionPayloadMerge { + ForkName::Bellatrix => ExecutionPayload::Bellatrix(ExecutionPayloadBellatrix { parent_hash, fee_recipient, state_root, @@ -179,6 +179,8 @@ impl Multiplexer { excess_blob_gas, }) } + // TODO: support Electra + ForkName::Electra => todo!(), ForkName::Base | ForkName::Altair => return Err(format!("invalid fork: {fork_name}")), }; @@ -281,6 +283,10 @@ impl Multiplexer { }, ) } + // TODO: Electra support + JsonExecutionPayload::V4(_) => { + todo!("Electra") + } } } } diff --git a/src/types.rs b/src/types.rs index 4ff1888..b8ddd88 100644 --- a/src/types.rs +++ b/src/types.rs @@ -12,7 +12,8 @@ pub use execution_layer::{ JsonPayloadAttributes, JsonPayloadAttributesV2, JsonPayloadStatusV1, JsonPayloadStatusV1Status, TransparentJsonPayloadId, }, - NewPayloadRequest, NewPayloadRequestCapella, NewPayloadRequestDeneb, NewPayloadRequestMerge, + NewPayloadRequest, NewPayloadRequestBellatrix, NewPayloadRequestCapella, + NewPayloadRequestDeneb, }; pub use serde_json::Value as JsonValue; pub use task_executor::TaskExecutor;