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

feat(L2): basic sequencer #586

Merged
merged 139 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
bc150e9
Revert "fix: remove totalDifficulty (#347)"
fmoletta Sep 23, 2024
0c2cd4d
Complete forkChoiceUpdatedV3 up until payload validation
fmoletta Sep 23, 2024
1a1b781
Add BuildPayloadArgs + id
fmoletta Sep 24, 2024
7386f2b
Output proper payload id
fmoletta Sep 24, 2024
adf5204
Move execution payload to core
fmoletta Sep 24, 2024
772fac1
Revert "Move execution payload to core"
fmoletta Sep 24, 2024
f8409b0
Push uncommited file
fmoletta Sep 24, 2024
7446289
Add block building
fmoletta Sep 24, 2024
2b2f4dd
Clippy + fmt
fmoletta Sep 24, 2024
5e47673
Modularize fork choice update fn
fmoletta Sep 25, 2024
31c380f
Fix timestamp
fmoletta Sep 25, 2024
1bdf863
Fix ser
fmoletta Sep 25, 2024
69d280b
Fix
fmoletta Sep 25, 2024
36a45dc
Add `cfg-if` dep and `l2` feature
ilitteri Sep 25, 2024
66f02ab
Do not start networking when `l2` feature is enabled
ilitteri Sep 25, 2024
8ab630e
Add l2 genesis config
ilitteri Sep 25, 2024
677a7ec
Merge branch 'main' of github.com:lambdaclass/ethereum_rust into engi…
fmoletta Sep 26, 2024
9737674
Integrate previous changes (part 1)
fmoletta Sep 26, 2024
1e3d710
fetch only header instead of block
fmoletta Sep 26, 2024
a634c13
Fix typo + remove unwrap
fmoletta Sep 26, 2024
995aca8
fetch only header instead of block
fmoletta Sep 26, 2024
a856b7a
Clarify hardcoded values
fmoletta Sep 26, 2024
3f1e4ed
Add doc
fmoletta Sep 26, 2024
8adfe28
Add InvalidForkChoiceState RpcErr
fmoletta Sep 26, 2024
69607ae
revert uneeded changes
fmoletta Sep 26, 2024
858819b
Add l1 genesis, used by the L2 local setup
ilitteri Sep 26, 2024
45030bc
Add docker-compose for running a reth local node for the l2 local setup
ilitteri Sep 26, 2024
9618e32
Change miner to builder
fmoletta Sep 26, 2024
05bdc2f
Add `l2` crate scaffolding
ilitteri Sep 26, 2024
352750d
Add Makefile for PoC L2 setup
ilitteri Sep 26, 2024
9b42b9a
Add l2 crate to the workspace
ilitteri Sep 26, 2024
f6fc9e6
Add l2 crate as dep
ilitteri Sep 26, 2024
78210fb
Run both the operator and prover when starting the node
ilitteri Sep 26, 2024
76e4bdf
rename: local_block -> payload
fmoletta Sep 26, 2024
3fd2099
Fix Makefile
ilitteri Sep 26, 2024
517d45b
Add request + impl ExecutionPayloadV3::from_block
fmoletta Sep 26, 2024
b1bb89f
Make ExecutionPayloadV3 serializable
fmoletta Sep 26, 2024
dc6da98
Impl endpoint
fmoletta Sep 26, 2024
5ba2b60
Add empty missing fields
fmoletta Sep 26, 2024
d7ef72a
Fix Makefile
ilitteri Sep 26, 2024
754d2e1
Add contracts setup for l1 and l2
ilitteri Sep 26, 2024
956d7cb
Compute new state root when building payloads
fmoletta Sep 26, 2024
f3c356f
Map error
fmoletta Sep 26, 2024
8f3fdaa
fmt
fmoletta Sep 26, 2024
cf4f86e
remove some pointless clones in storage
fmoletta Sep 26, 2024
b14e226
Set newly added block as canonical in engine_NewPayloadV3
fmoletta Sep 26, 2024
72bd123
Add Create2Factory to the genesis
ilitteri Sep 26, 2024
a510ef0
Improve error handling
ilitteri Sep 26, 2024
694930f
Fix comment + trace paylaod get request
fmoletta Sep 26, 2024
a491e8f
Clippy
fmoletta Sep 26, 2024
6a9d884
Compute block value
fmoletta Sep 27, 2024
d76e76a
Index `l2MintTxHash` in `DepositInitiated` event
ilitteri Sep 27, 2024
26df969
Add filtering to mempool
fmoletta Sep 27, 2024
fd0a13b
Add logs requester
ManuelBilbao Sep 27, 2024
9bb9252
Cleanup scripts
ilitteri Sep 27, 2024
e3e7780
Rename Inbox -> CommonBridge
ilitteri Sep 27, 2024
cff0be8
Rename up -> init, add restart
ilitteri Sep 27, 2024
22d1161
Cleanup genesis
ilitteri Sep 27, 2024
a62f39c
Parametize logs filter args
ManuelBilbao Sep 27, 2024
5d5b0cc
Add `AmountToDepositIsZero` error
ilitteri Sep 27, 2024
2468865
Add basic deposit tests for `CommonBridge`
ilitteri Sep 27, 2024
7a2e40b
Add operator component `block_producer`
ilitteri Sep 27, 2024
a12f838
Refactor
ilitteri Sep 27, 2024
fbdde7a
Fix typo
ilitteri Sep 27, 2024
ca6943d
Fix `IBlockExecutor` docs
ilitteri Sep 27, 2024
9f0344b
Add individual restart cmds
ilitteri Sep 27, 2024
6953b77
Add docs
ilitteri Sep 27, 2024
38d1e0c
Improve README
ilitteri Sep 27, 2024
1bc5c0f
Change prints for tracing
ManuelBilbao Sep 27, 2024
5992bd1
Merge branch 'main' of github.com:lambdaclass/ethereum_rust into ethe…
ilitteri Sep 27, 2024
cc18793
chore: forge init
ilitteri Sep 27, 2024
ef1b259
forge install: forge-std
ilitteri Sep 27, 2024
1fbf64d
Fix contracts
ilitteri Sep 27, 2024
85e8841
Untrack forge-std
ilitteri Sep 27, 2024
e6da96d
Remove dir
ilitteri Sep 27, 2024
4cb732f
Untrack broadcast files
ilitteri Sep 27, 2024
5565768
Use L1 existing types for RPC
ManuelBilbao Sep 27, 2024
6b7fc21
Use already created RpcRequest
ManuelBilbao Sep 27, 2024
947469a
Push local changes
fmoletta Sep 27, 2024
4bab793
Move error control upwards
ManuelBilbao Sep 27, 2024
1b5f7fd
Merge remote-tracking branch 'origin/ethereum_rust_l2_scaffolding' in…
ManuelBilbao Sep 27, 2024
70dffed
Fix linter
ManuelBilbao Sep 27, 2024
696b15d
Add comment on used hex values
ManuelBilbao Sep 27, 2024
9841d1e
Update crates/l2/Cargo.toml
ManuelBilbao Sep 27, 2024
5e2e770
refactor: sort and group txs while fetching from db
fmoletta Sep 27, 2024
595ca8b
Push work in progress
fmoletta Sep 27, 2024
8601f38
Move jsonwebtoken to workspace deps
ilitteri Sep 28, 2024
df674b4
Add basic consensus mock structure
ilitteri Sep 28, 2024
23a5b65
Add deps to l2 crate
ilitteri Sep 28, 2024
048be61
Remove tx from mempool + add doc
fmoletta Sep 30, 2024
4dd45b3
Skip protected txs + refactor TransactionQueue
fmoletta Sep 30, 2024
9f851d8
Finish basic cycle
fmoletta Sep 30, 2024
08c8371
Move validated state trie creation to engine
fmoletta Sep 30, 2024
9d17b6a
refactor: Defer withdrawals processing until getPayload
fmoletta Sep 30, 2024
cecad11
Add tracing
fmoletta Sep 30, 2024
dd92e90
refactor: add PayloadBuildContext
fmoletta Sep 30, 2024
a9c62a3
Clippy
fmoletta Sep 30, 2024
c3e7614
Merge branch 'main' of github.com:lambdaclass/ethereum_rust into payl…
fmoletta Sep 30, 2024
f0dec81
Modularize
fmoletta Sep 30, 2024
8cb57ca
Fix logic + add doc
fmoletta Sep 30, 2024
f8b8147
Merge remote-tracking branch 'origin/payload-add-txs' into ethereum_r…
ilitteri Sep 30, 2024
c2a3e2f
Implement end to end block addition
ilitteri Oct 1, 2024
0b7ece0
Implement `Serialize` and `Deserialize` in rpc types
ilitteri Oct 1, 2024
bc80748
Improve logs
ilitteri Oct 1, 2024
5445172
Improve block header validation error handling
ilitteri Oct 1, 2024
9cf95f8
Add convenient method for PayloadStatus
ilitteri Oct 1, 2024
f29a52e
Improve PayloadStatus error handling
ilitteri Oct 1, 2024
b311bf8
Skip jwt authentication
ilitteri Oct 1, 2024
0e8ed67
Add known rich wallet to genesis execution genesis
ilitteri Oct 1, 2024
8ad7710
Fix PayloadAttributesV3 building
ilitteri Oct 1, 2024
5b47fac
Improve prints
ilitteri Oct 1, 2024
dde8321
Wrap up mock tests
ilitteri Oct 1, 2024
a4f9090
Add block producer loop
ManuelBilbao Oct 1, 2024
934a25a
feat(L2): implement `Into<RpcRequest>` for EngineAPI request structs …
ManuelBilbao Oct 2, 2024
c68b475
Merge branch 'main' into ethereum_rust_l2_consensus_mock
ManuelBilbao Oct 2, 2024
bd4614b
Apply suggestion
fmoletta Oct 3, 2024
2cd8524
Merge branch 'main' of github.com:lambdaclass/ethereum_rust into ethe…
ilitteri Oct 3, 2024
1ba8a5c
Fix
ilitteri Oct 3, 2024
6e3bd4c
Link github issues in TODOs
fmoletta Oct 3, 2024
68718f0
Merge branch 'main' of github.com:lambdaclass/ethereum_rust into payl…
fmoletta Oct 3, 2024
49751b5
Add doc link
fmoletta Oct 3, 2024
8cb1bf1
fix
fmoletta Oct 3, 2024
dddb869
swap info tracing for debug tracing
fmoletta Oct 3, 2024
c28ed99
rename txs -> txs_by_sender
fmoletta Oct 3, 2024
fc51790
use saturating sub and add comment
fmoletta Oct 3, 2024
222e4e7
Merge branch 'payload-add-txs' of github.com:lambdaclass/ethereum_rus…
ilitteri Oct 3, 2024
aec29db
Revert "Fix"
ilitteri Oct 3, 2024
72a86e7
Merge branch 'main' into ethereum_rust_l2_consensus_mock
ManuelBilbao Oct 7, 2024
d7e6bf1
Merge branch 'main' of github.com:lambdaclass/ethereum_rust into ethe…
ilitteri Oct 7, 2024
9e62a00
Implement deserialize for bytes48::vec and blob::vec modules
ilitteri Oct 7, 2024
abf7c1f
Derive Deserialize for BlobsBundle
ilitteri Oct 7, 2024
a34ea34
Replace Into with From
ilitteri Oct 7, 2024
1f20c44
Read file from default jwt secret path
ilitteri Oct 8, 2024
4a5b81e
Remove test
ilitteri Oct 8, 2024
3811487
Uncomment authentication
ilitteri Oct 8, 2024
a31b3ad
Rename consensus_mock -> engine
ilitteri Oct 8, 2024
ee4b8f3
Merge branch 'main' into ethereum_rust_l2_consensus_mock
ilitteri Oct 8, 2024
55741c7
Update Engine's capabilities
ilitteri Oct 8, 2024
f69e7c1
Pass initial block hash as a parameter to block producer
ilitteri Oct 8, 2024
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ crc32fast = "1.4.2"
lazy_static = "1.5.0"
sha3 = "0.10.8"
tokio-util = { version = "0.7.12", features = ["rt"] }
jsonwebtoken = "9.3.0"
rand = "0.8.5"
13 changes: 8 additions & 5 deletions cmd/ethereum_rust/ethereum_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,18 @@ async fn main() {
let size = blocks.len();
for block in blocks {
let hash = block.header.compute_block_hash();
info!("Adding block {} with hash {}.", block.header.number, hash);
info!(
"Adding block {} with hash {:#x}.",
block.header.number, hash
);
match add_block(&block, &store) {
Ok(()) => store
.set_canonical_block(block.header.number, hash)
.unwrap(),
_ => {
Err(error) => {
warn!(
"Failed to add block {} with hash {}.",
block.header.number, hash
"Failed to add block {} with hash {:#x}: {}",
block.header.number, hash, error
);
}
}
Expand Down Expand Up @@ -159,7 +162,7 @@ async fn main() {
// We do not want to start the networking module if the l2 feature is enabled.
cfg_if::cfg_if! {
if #[cfg(feature = "l2")] {
let l2_operator = ethereum_rust_l2::start_operator().into_future();
let l2_operator = ethereum_rust_l2::start_operator(store.clone()).into_future();
tracker.spawn(l2_operator);
let l2_prover = ethereum_rust_l2::start_prover().into_future();
tracker.spawn(l2_prover);
Expand Down
45 changes: 45 additions & 0 deletions crates/common/serde_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,28 @@ pub mod bytes48 {
{
serialize_vec_of_hex_encodables(value, serializer)
}

pub fn deserialize<'de, D>(d: D) -> Result<Vec<[u8; 48]>, D::Error>
where
D: Deserializer<'de>,
{
let value = Vec::<String>::deserialize(d)?;
let mut output = Vec::new();
for str in value {
let bytes = hex::decode(str.trim_start_matches("0x"))
.map_err(|e| D::Error::custom(e.to_string()))?;
if bytes.len() != 48 {
return Err(D::Error::custom(format!(
"Expected 48 bytes, got {}",
bytes.len()
)));
}
let mut blob = [0u8; 48];
blob.copy_from_slice(&bytes);
output.push(blob);
}
Ok(output)
}
}
}

Expand All @@ -310,6 +332,29 @@ pub mod blob {
{
serialize_vec_of_hex_encodables(value, serializer)
}

pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<[u8; BYTES_PER_BLOB]>, D::Error>
where
D: Deserializer<'de>,
{
let value = Vec::<String>::deserialize(deserializer)?;
let mut output = Vec::new();
for str in value {
let bytes = hex::decode(str.trim_start_matches("0x"))
.map_err(|e| D::Error::custom(e.to_string()))?;
if bytes.len() != BYTES_PER_BLOB {
return Err(D::Error::custom(format!(
"Expected {} bytes, got {}",
BYTES_PER_BLOB,
bytes.len()
)));
}
let mut blob = [0u8; BYTES_PER_BLOB];
blob.copy_from_slice(&bytes);
output.push(blob);
}
Ok(output)
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/common/types/blobs_bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use ethereum_rust_rlp::{
error::RLPDecodeError,
structs::{Decoder, Encoder},
};
use serde::Serialize;
use serde::{Deserialize, Serialize};

use super::BYTES_PER_BLOB;

Expand All @@ -14,7 +14,7 @@ pub type Blob = [u8; BYTES_PER_BLOB];
pub type Commitment = Bytes48;
pub type Proof = Bytes48;

#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
/// Struct containing all the blobs for a blob transaction, along with the corresponding commitments and proofs
pub struct BlobsBundle {
Expand Down
8 changes: 5 additions & 3 deletions crates/l2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ tokio-util.workspace = true
tracing.workspace = true
serde.workspace = true
serde_json.workspace = true
sp1-sdk = "2.0.0"
ethereum-types.workspace = true
ethereum_rust-core.workspace = true
ethereum_rust-rlp.workspace = true
ethereum_rust-rpc.workspace = true
ethereum_rust-blockchain.workspace = true
libsecp256k1 = "0.7.1"
ethereum_rust-storage.workspace = true
hex.workspace = true
bytes.workspace = true
jsonwebtoken.workspace = true
sp1-sdk = "2.0.0"
libsecp256k1 = "0.7.1"
keccak-hash = "0.10.0"
hex.workspace = true

[lib]
path = "./l2.rs"
49 changes: 47 additions & 2 deletions crates/l2/operator/block_producer.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
pub struct BlockProducer;
use crate::operator::engine::Engine;
use ethereum_rust_rpc::types::fork_choice::{ForkChoiceState, PayloadAttributesV3};
use ethereum_types::H256;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use tokio::time::sleep;

pub async fn start_block_producer() {}
pub async fn start_block_producer(current_block_hash: H256) {
let mut current_block_hash = current_block_hash;
loop {
let secret = std::fs::read("../../../jwt.hex").unwrap();
let engine = Engine::new("http://localhost:8551", secret.into());

let fork_choice_state = ForkChoiceState {
head_block_hash: current_block_hash,
safe_block_hash: current_block_hash,
finalized_block_hash: current_block_hash,
};
let payload_attributes = PayloadAttributesV3 {
timestamp: SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs(),
..Default::default()
};

let fork_choice_response = engine
.engine_forkchoice_updated_v3(fork_choice_state, payload_attributes)
.await
.unwrap();

let payload_id = fork_choice_response.payload_id.unwrap();

let execution_payload_response = engine.engine_get_payload_v3(payload_id).await.unwrap();

let payload_status = engine
.engine_new_payload_v3(
execution_payload_response.execution_payload,
Default::default(),
Default::default(),
)
.await
.unwrap();

current_block_hash = payload_status.latest_valid_hash.unwrap();

sleep(Duration::from_secs(5)).await;
}
}
145 changes: 145 additions & 0 deletions crates/l2/operator/engine.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
use bytes::Bytes;
use ethereum_rust_rpc::{
engine::{
fork_choice::ForkChoiceUpdatedV3,
payload::{GetPayloadV3Request, NewPayloadV3Request},
ExchangeCapabilitiesRequest,
},
types::{
fork_choice::{ForkChoiceResponse, ForkChoiceState, PayloadAttributesV3},
payload::{ExecutionPayloadResponse, ExecutionPayloadV3, PayloadStatus},
},
utils::{RpcErrorResponse, RpcRequest, RpcSuccessResponse},
};
use ethereum_types::H256;
use reqwest::Client;
use serde::Deserialize;
use serde_json::json;
use std::time::{SystemTime, UNIX_EPOCH};

#[derive(Deserialize)]
#[serde(untagged)]
pub enum RpcResponse {
Success(RpcSuccessResponse),
Error(RpcErrorResponse),
}

pub struct Engine {
client: Client,
secret: Bytes,
execution_client_url: String,
}

impl Engine {
pub fn new(execution_client_url: &str, secret: Bytes) -> Self {
Self {
client: Client::new(),
secret,
execution_client_url: execution_client_url.to_string(),
}
}

async fn send_request(&self, request: RpcRequest) -> Result<RpcResponse, reqwest::Error> {
self.client
.post(&self.execution_client_url)
.bearer_auth(self.auth_token())
.header("content-type", "application/json")
.body(serde_json::ser::to_string(&request).unwrap())
.send()
.await?
.json::<RpcResponse>()
.await
}

pub async fn engine_exchange_capabilities(&self) -> Result<Vec<String>, String> {
let request = ExchangeCapabilitiesRequest::from(Self::capabilities()).into();

match self.send_request(request).await {
Ok(RpcResponse::Success(result)) => Ok(serde_json::from_value(result.result).unwrap()),
Ok(RpcResponse::Error(e)) => Err(e.error.message),
Err(e) => Err(e.to_string()),
}
}

pub async fn engine_forkchoice_updated_v3(
&self,
state: ForkChoiceState,
payload_attributes: PayloadAttributesV3,
) -> Result<ForkChoiceResponse, String> {
let request = ForkChoiceUpdatedV3 {
fork_choice_state: state,
payload_attributes: Some(payload_attributes),
}
.into();

match self.send_request(request).await {
Ok(RpcResponse::Success(s)) => match serde_json::from_value(s.result.clone()) {
Ok(parsed_value) => Ok(parsed_value),
Err(error) => {
dbg!(s.result);
Err(error.to_string())
}
},
Ok(RpcResponse::Error(e)) => Err(e.error.message),
Err(e) => Err(e.to_string()),
}
}

pub async fn engine_get_payload_v3(
&self,
payload_id: u64,
) -> Result<ExecutionPayloadResponse, String> {
let request = GetPayloadV3Request { payload_id }.into();

match self.send_request(request).await {
Ok(RpcResponse::Success(s)) => Ok(serde_json::from_value(s.result).unwrap()),
Ok(RpcResponse::Error(e)) => Err(e.error.message),
Err(e) => Err(e.to_string()),
}
}

pub async fn engine_new_payload_v3(
&self,
execution_payload: ExecutionPayloadV3,
expected_blob_versioned_hashes: Vec<H256>,
parent_beacon_block_root: H256,
) -> Result<PayloadStatus, String> {
let request = NewPayloadV3Request {
payload: execution_payload,
expected_blob_versioned_hashes,
parent_beacon_block_root,
}
.into();

match self.send_request(request).await {
Ok(RpcResponse::Success(s)) => Ok(serde_json::from_value(s.result).unwrap()),
Ok(RpcResponse::Error(e)) => Err(e.error.message),
Err(e) => Err(e.to_string()),
}
}

fn auth_token(&self) -> String {
// Header
let header = jsonwebtoken::Header::default();
// Claims
let valid_iat = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs() as usize;
let claims = json!({"iat": valid_iat});
// Encoding Key
let decoded_secret = hex::decode(self.secret.clone()).unwrap();
let encoding_key = jsonwebtoken::EncodingKey::from_secret(decoded_secret.as_ref());
// JWT Token
jsonwebtoken::encode(&header, &claims, &encoding_key).unwrap()
}

fn capabilities() -> Vec<String> {
vec![
"engine_exchangeCapabilities".to_owned(),
"engine_forkchoiceUpdatedV3".to_owned(),
"engine_getPayloadV3".to_owned(),
"engine_newPayloadV3".to_owned(),
]
}
}
13 changes: 11 additions & 2 deletions crates/l2/operator/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
use ethereum_rust_storage::Store;
use std::net::{IpAddr, Ipv4Addr};

pub mod block_producer;
pub mod engine;
pub mod l1_tx_sender;
pub mod l1_watcher;
pub mod proof_data_provider;

pub async fn start_operator() {
pub async fn start_operator(store: Store) {
let l1_tx_sender = tokio::spawn(l1_tx_sender::start_l1_tx_sender());
let l1_watcher = tokio::spawn(l1_watcher::start_l1_watcher());
let block_producer = tokio::spawn(block_producer::start_block_producer());
let current_block_hash = {
let current_block_number = store.get_latest_block_number().unwrap().unwrap();
store
.get_canonical_block_hash(current_block_number)
.unwrap()
.unwrap()
};
let block_producer = tokio::spawn(block_producer::start_block_producer(current_block_hash));
let proof_data_provider = tokio::spawn(proof_data_provider::start_proof_data_provider(
IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
3000,
Expand Down
2 changes: 1 addition & 1 deletion crates/networking/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ethereum_rust-net.workspace = true
ethereum_rust-rlp.workspace = true
hex.workspace = true
axum-extra = {version = "0.9.3", features = ["typed-header"]}
jsonwebtoken = "9.3.0"
jsonwebtoken.workspace = true
rand.workspace = true

[dev-dependencies]
Expand Down
14 changes: 14 additions & 0 deletions crates/networking/rpc/engine/fork_choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
fork_choice::{ForkChoiceResponse, ForkChoiceState, PayloadAttributesV3},
payload::PayloadStatus,
},
utils::RpcRequest,
RpcErr, RpcHandler,
};

Expand All @@ -22,6 +23,19 @@ pub struct ForkChoiceUpdatedV3 {
pub payload_attributes: Option<PayloadAttributesV3>,
}

impl From<ForkChoiceUpdatedV3> for RpcRequest {
fn from(val: ForkChoiceUpdatedV3) -> Self {
RpcRequest {
method: "engine_forkchoiceUpdatedV3".to_string(),
params: Some(vec![
serde_json::json!(val.fork_choice_state),
serde_json::json!(val.payload_attributes),
]),
..Default::default()
}
}
}

impl RpcHandler for ForkChoiceUpdatedV3 {
fn parse(params: &Option<Vec<Value>>) -> Result<Self, RpcErr> {
let params = params
Expand Down
Loading
Loading