From 87c244b789634c145251a5c9ec85a4fdd528fe46 Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Wed, 3 Jul 2024 13:50:39 +0200 Subject: [PATCH 1/6] build Eip1559 transaction --- Node/src/ethereum_l1/mod.rs | 47 +++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/Node/src/ethereum_l1/mod.rs b/Node/src/ethereum_l1/mod.rs index b8f42f4..5e0e542 100644 --- a/Node/src/ethereum_l1/mod.rs +++ b/Node/src/ethereum_l1/mod.rs @@ -1,9 +1,11 @@ #![allow(unused)] //TODO remove after the EthereumL1 is used in release code use alloy::{ + consensus::transaction::TypedTransaction, network::{Ethereum, EthereumWallet, NetworkWallet}, primitives::{Address, Bytes, FixedBytes, U256, U32, U64}, providers::ProviderBuilder, + rpc::types::{TransactionInput, TransactionRequest}, signers::local::PrivateKeySigner, sol, sol_types::SolValue, @@ -54,12 +56,12 @@ impl EthereumL1 { }) } - pub async fn propose_new_block( + pub async fn create_propose_new_block_tx( &self, contract_address: Address, tx_list: Vec, parent_meta_hash: [u8; 32], - ) -> Result<(), Error> { + ) -> Result, Error> { let provider = ProviderBuilder::new() .with_recommended_fillers() .wallet(self.wallet.clone()) @@ -84,17 +86,34 @@ impl EthereumL1 { let tx_list = Bytes::from(tx_list); let lookahead_set_param: Vec = Vec::new(); - let builder = contract.newBlockProposal( - encoded_block_params, - tx_list, - U256::from(0), - lookahead_set_param, - ); - let tx_hash = builder.send().await?.watch().await?; - tracing::debug!("Proposed new block: {tx_hash}"); + let builder = contract + .newBlockProposal( + encoded_block_params, + tx_list, + U256::from(0), + lookahead_set_param, + ) + .nonce(1) //TODO how to get it? + .gas(100000) + .max_fee_per_gas(10000000000000000) + .max_priority_fee_per_gas(10000000000000000); + + let tx = builder.as_ref().clone().build_typed_tx(); + let Ok(TypedTransaction::Eip1559(mut tx)) = tx else { + return Err(anyhow::anyhow!("expect tx in EIP1559")); + }; - Ok(()) + let signature = self + .wallet + .default_signer() + .sign_transaction(&mut tx) + .await?; + + let mut buf = vec![]; + tx.encode_with_signature(&signature, &mut buf, false); + + Ok(buf) } #[cfg(test)] @@ -177,8 +196,8 @@ mod tests { let ethereum_l1 = EthereumL1::new_from_pk(rpc_url, private_key).unwrap(); // some random address for test - ethereum_l1 - .propose_new_block( + let encoded_tx = ethereum_l1 + .create_propose_new_block_tx( "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" .parse() .unwrap(), @@ -187,5 +206,7 @@ mod tests { ) .await .unwrap(); + + assert!(encoded_tx.len() > 0); } } From 288bd76a3b2690bdb44f09c74fa134a4c9a1eabe Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Wed, 3 Jul 2024 17:16:11 +0200 Subject: [PATCH 2/6] Handling additional arguments passed by JSON RPC from proposer --- Node/Cargo.lock | 1 + Node/Cargo.toml | 2 +- Node/src/main.rs | 4 +- Node/src/node/mod.rs | 12 +++- Node/src/taiko/l2_tx_lists.rs | 117 ++++++++++++++++++++++++++++++++++ Node/src/taiko/mod.rs | 37 ++++++----- Node/src/utils/rpc_server.rs | 62 +++++++----------- 7 files changed, 173 insertions(+), 62 deletions(-) create mode 100644 Node/src/taiko/l2_tx_lists.rs diff --git a/Node/Cargo.lock b/Node/Cargo.lock index 23426db..8774cdc 100644 --- a/Node/Cargo.lock +++ b/Node/Cargo.lock @@ -3052,6 +3052,7 @@ dependencies = [ "alloy", "anyhow", "elliptic-curve", + "hex", "jsonrpsee", "k256", "lazy_static", diff --git a/Node/Cargo.toml b/Node/Cargo.toml index 5e927f9..a3b74a0 100644 --- a/Node/Cargo.toml +++ b/Node/Cargo.toml @@ -21,4 +21,4 @@ anyhow = "1.0.86" k256 = "0.13" elliptic-curve = "0.13" reqwest = "0.12" - +hex = "0.4" diff --git a/Node/src/main.rs b/Node/src/main.rs index ae09709..57ae886 100644 --- a/Node/src/main.rs +++ b/Node/src/main.rs @@ -18,8 +18,8 @@ async fn main() -> Result<(), Error> { let (node_tx, node_rx) = mpsc::channel(MESSAGE_QUEUE_SIZE); let p2p = p2p_network::AVSp2p::new(node_tx.clone(), avs_p2p_rx); p2p.start(); - - let node = node::Node::new(node_rx, avs_p2p_tx); + let ethereum_l1 = ethereum_l1::EthereumL1::new("http://localhost:8545", "private_key")?; + let node = node::Node::new(node_rx, avs_p2p_tx, ethereum_l1); node.entrypoint().await?; Ok(()) } diff --git a/Node/src/node/mod.rs b/Node/src/node/mod.rs index 7f439bf..1dacafb 100644 --- a/Node/src/node/mod.rs +++ b/Node/src/node/mod.rs @@ -1,3 +1,4 @@ +use crate::ethereum_l1::EthereumL1; use crate::taiko::Taiko; use anyhow::{anyhow as any_err, Error, Ok}; use tokio::sync::mpsc::{Receiver, Sender}; @@ -7,16 +8,22 @@ pub struct Node { node_rx: Option>, avs_p2p_tx: Sender, gas_used: u64, + ethereum_l1: EthereumL1, } impl Node { - pub fn new(node_rx: Receiver, avs_p2p_tx: Sender) -> Self { + pub fn new( + node_rx: Receiver, + avs_p2p_tx: Sender, + ethereum_l1: EthereumL1, + ) -> Self { let taiko = Taiko::new("http://127.0.0.1:1234", "http://127.0.0.1:1235"); Self { taiko, node_rx: Some(node_rx), avs_p2p_tx, gas_used: 0, + ethereum_l1, } } @@ -70,8 +77,9 @@ impl Node { self.commit_to_the_tx_lists(); self.send_preconfirmations_to_the_avs_p2p().await?; self.taiko - .advance_head_to_new_l2_block(pending_tx_lists, self.gas_used) + .advance_head_to_new_l2_block(pending_tx_lists.tx_lists, self.gas_used) .await?; + // self.ethereum_l1.propose_new_block(pending_tx_lists).await?; Ok(()) } diff --git a/Node/src/taiko/l2_tx_lists.rs b/Node/src/taiko/l2_tx_lists.rs new file mode 100644 index 0000000..db10ca3 --- /dev/null +++ b/Node/src/taiko/l2_tx_lists.rs @@ -0,0 +1,117 @@ +use anyhow::Error; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_json::Value; + +#[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "PascalCase")] +pub struct RPCReplyL2TxLists { + pub tx_lists: Value, + #[serde(deserialize_with = "deserialize_tx_lists_bytes")] + pub tx_list_bytes: Vec>, + #[serde(deserialize_with = "deserialize_parent_meta_hash")] + pub parent_meta_hash: [u8; 32], +} + +fn deserialize_tx_lists_bytes<'de, D>(deserializer: D) -> Result>, D::Error> +where + D: Deserializer<'de>, +{ + let vec: Vec = Deserialize::deserialize(deserializer)?; + let result = vec + .iter() + .map(|s| s.as_bytes().to_vec()) + .collect::>>(); + Ok(result) +} + +fn deserialize_parent_meta_hash<'de, D>(deserializer: D) -> Result<[u8; 32], D::Error> +where + D: Deserializer<'de>, +{ + let s: String = Deserialize::deserialize(deserializer)?; + let s = s.trim_start_matches("0x"); + let bytes = hex::decode(s).map_err(serde::de::Error::custom)?; + if bytes.len() != 32 { + return Err(serde::de::Error::custom( + "Invalid length for parent_meta_hash", + )); + } + let mut array = [0u8; 32]; + array.copy_from_slice(&bytes); + Ok(array) +} + +pub fn decompose_pending_lists_json(json: Value) -> Result { + // Deserialize the JSON string into the struct + let rpc_reply: RPCReplyL2TxLists = serde_json::from_value(json)?; + Ok(rpc_reply) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_decompose_pending_lists_json() { + let json_data = serde_json::json!( + { + "TxLists": [ + [ + { + "type": "0x0", + "chainId": "0x28c61", + "nonce": "0x8836", + "to": "0x8b14d287b4150ff22ac73df8be720e933f659abc", + "gas": "0x35f30", + "gasPrice": "0xf4b87001", + "maxPriorityFeePerGas": null, + "maxFeePerGas": null, + "value": "0x0", + "input": "0x3161b7f60000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000027e9000000000000000000000000000000000000000000000005751b6fc9babade290000000000000000000000000000000000000000000000000000000008f811330000000000000000000000000000000000000000000000000000000000000010", + "v": "0x518e5", + "r": "0xb7b4b5540e08775ebb3c077ca7d572378cdb6ed55e3387173f8248578cc073e9", + "s": "0x1f8860f90b61202d4070d1eba494d38c2cb02c749ea1ec542c8d02e5ceeb6439", + "hash": "0xc653e446eafe51eea1f46e6e351adbd1cc8a3271e6935f1441f613a58d441f6a" + }, + { + "type": "0x2", + "chainId": "0x28c61", + "nonce": "0x26d0", + "to": "0x2f6ef5baae08ae9df23528c217a77f03f93b690e", + "gas": "0x1a09b", + "gasPrice": null, + "maxPriorityFeePerGas": "0xcbef0801", + "maxFeePerGas": "0xcbef0801", + "value": "0x0", + "input": "0xbb2cd728000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000ae2c46ddb314b9ba743c6dee4878f151881333d90000000000000000000000007d16e966c879ed6ad9972ddd5376c41a427d2c2a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000004cd712049c0000000000000000000000000000000000000000000000000000057b3ac2af84", + "accessList": [], + "v": "0x0", + "r": "0xbfc407896ee6ed36962d1a591b41aa9a17fe19e176e61cb54a1cd69e3a337508", + "s": "0x621b2448dda4d797447935c051e3908f65dfb3729415280a04cb02c4474baefe", + "yParity": "0x0", + "hash": "0xffbcd2fab90f1bf314ca2da1bf83eeab3d17fd58a0393d29a697b2ff05d0e65c" + } + ] + ], + "TxListBytes": [ + "eJz6ybTuJ6NeU4dZy5cdBYzNzPEGU7pFLrVvEeX/pHXc9se+Ir7J9qmz9jTsOGKYuP0bA36gQECeEb+0+kscEqyl0vknd+26p4lPN8cPQWMC9gs0s0o8XbB9y9YQPo7yuN027DXLrxaZ99zOuxpn3C5u3+QR3nOg+OUC+Y6En9yJCroOBRdfL5lyuUdng07JvIVvQnR6mZ6ee51iuZOxiuknY1kzU09ik9qFltPvORjBRDPjgtlT9PO+7lrHsW7uJ1ONQ+LL65l/WmfyNexkZNmtc12DgPMcCMgvICDPhMxZp+N2d7PIzl0lNrnvPCo+BnYIG99Elq8Ve5l2ovJt1s3puneDy45IOdXqaJFiPhrwuS7EMge3NGu11aH1LQcaFuw/wt6Z9+yt2TRdqUhpx1WzxP9JPix7JrPVS+baPCvjUo4FSdIqHneXXJ/uUml6IPDxhP7U+5uLpohqcLGcZjri7r3uHyAAAP//huiQHQ==" + ], + "ParentMetaHash": "0x2bcf3b1bb0c4066aa46ba6e99b79d7602f124d5ae8fcffd2977b1c2138aa61bc" + } + ); + + let result = decompose_pending_lists_json(json_data).unwrap(); + + assert_eq!(result.tx_lists.as_array().unwrap().len(), 1); + assert_eq!( + result.tx_lists.as_array().unwrap()[0] + .as_array() + .unwrap() + .len(), + 2 + ); + assert_eq!(result.tx_list_bytes.len(), 1); + assert_eq!(result.tx_list_bytes[0].len(), 492); + assert_eq!(result.parent_meta_hash.len(), 32); + } +} diff --git a/Node/src/taiko/mod.rs b/Node/src/taiko/mod.rs index f48c2e9..15f0c23 100644 --- a/Node/src/taiko/mod.rs +++ b/Node/src/taiko/mod.rs @@ -2,6 +2,8 @@ use crate::utils::rpc_client::RpcClient; use anyhow::Error; use serde_json::Value; +pub mod l2_tx_lists; + pub struct Taiko { rpc_proposer: RpcClient, rpc_driver: RpcClient, @@ -15,11 +17,13 @@ impl Taiko { } } - pub async fn get_pending_l2_tx_lists(&self) -> Result { + pub async fn get_pending_l2_tx_lists(&self) -> Result { tracing::debug!("Getting L2 tx lists"); - self.rpc_proposer - .call_method("RPC.GetL2TxLists", vec![]) - .await + l2_tx_lists::decompose_pending_lists_json( + self.rpc_proposer + .call_method("RPC.GetL2TxLists", vec![]) + .await?, + ) } pub async fn advance_head_to_new_l2_block( @@ -29,7 +33,7 @@ impl Taiko { ) -> Result { tracing::debug!("Submitting new L2 blocks"); let payload = serde_json::json!({ - "TxLists": tx_lists["TxLists"], + "TxLists": tx_lists, "gasUsed": gas_used, }); self.rpc_driver @@ -49,24 +53,19 @@ mod test { tracing_subscriber::fmt::init(); let (mut rpc_server, taiko) = setup_rpc_server_and_taiko(3030).await; - let json = taiko.get_pending_l2_tx_lists().await.unwrap(); + let json = taiko.get_pending_l2_tx_lists().await.unwrap().tx_lists; - assert_eq!(json["TxLists"].as_array().unwrap().len(), 1); - assert_eq!(json["TxLists"][0].as_array().unwrap().len(), 3); - assert_eq!(json["TxLists"][0][0]["type"], "0x0"); - assert_eq!( - json["TxLists"][0][0]["hash"], - "0x7c76b9906579e54df54fe77ad1706c47aca706b3eb5cfd8a30ccc3c5a19e8ecd" - ); - assert_eq!(json["TxLists"][0][1]["type"], "0x2"); + assert_eq!(json.as_array().unwrap().len(), 1); + assert_eq!(json[0].as_array().unwrap().len(), 2); + assert_eq!(json[0][0]["type"], "0x0"); assert_eq!( - json["TxLists"][0][1]["hash"], - "0xece2a3c6ca097cfe5d97aad4e79393240f63865210f9c763703d1136f065298b" + json[0][0]["hash"], + "0xc653e446eafe51eea1f46e6e351adbd1cc8a3271e6935f1441f613a58d441f6a" ); - assert_eq!(json["TxLists"][0][2]["type"], "0x2"); + assert_eq!(json[0][1]["type"], "0x2"); assert_eq!( - json["TxLists"][0][2]["hash"], - "0xb105d9f16e8fb913093c8a2c595bf4257328d256f218a05be8dcc626ddeb4193" + json[0][1]["hash"], + "0xffbcd2fab90f1bf314ca2da1bf83eeab3d17fd58a0393d29a697b2ff05d0e65c" ); rpc_server.stop().await; } diff --git a/Node/src/utils/rpc_server.rs b/Node/src/utils/rpc_server.rs index b1443f8..1311da6 100644 --- a/Node/src/utils/rpc_server.rs +++ b/Node/src/utils/rpc_server.rs @@ -61,57 +61,43 @@ pub mod test { { "type": "0x0", "chainId": "0x28c61", - "nonce": "0x1", - "to": "0xbfadd5365bb2890ad832038837115e60b71f7cbb", - "gas": "0x267ac", - "gasPrice": "0x5e76e0800", + "nonce": "0x8836", + "to": "0x8b14d287b4150ff22ac73df8be720e933f659abc", + "gas": "0x35f30", + "gasPrice": "0xf4b87001", "maxPriorityFeePerGas": null, "maxFeePerGas": null, "value": "0x0", - "input": "0x40d097c30000000000000000000000004cea2c7d358e313f5d0287c475f9ae943fe1a913", - "v": "0x518e6", - "r": "0xb22da5cdc4c091ec85d2dda9054aa497088e55bd9f0335f39864ae1c598dd35", - "s": "0x6eee1bcfe6a1855e89dd23d40942c90a036f273159b4c4fd217d58169493f055", - "hash": "0x7c76b9906579e54df54fe77ad1706c47aca706b3eb5cfd8a30ccc3c5a19e8ecd" + "input": "0x3161b7f60000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000027e9000000000000000000000000000000000000000000000005751b6fc9babade290000000000000000000000000000000000000000000000000000000008f811330000000000000000000000000000000000000000000000000000000000000010", + "v": "0x518e5", + "r": "0xb7b4b5540e08775ebb3c077ca7d572378cdb6ed55e3387173f8248578cc073e9", + "s": "0x1f8860f90b61202d4070d1eba494d38c2cb02c749ea1ec542c8d02e5ceeb6439", + "hash": "0xc653e446eafe51eea1f46e6e351adbd1cc8a3271e6935f1441f613a58d441f6a" }, { "type": "0x2", "chainId": "0x28c61", - "nonce": "0x3f", - "to": "0x380a5ba81efe70fe98ab56613ebf9244a2f3d4c9", - "gas": "0x2c2c8", + "nonce": "0x26d0", + "to": "0x2f6ef5baae08ae9df23528c217a77f03f93b690e", + "gas": "0x1a09b", "gasPrice": null, - "maxPriorityFeePerGas": "0x1", - "maxFeePerGas": "0x3", - "value": "0x5af3107a4000", - "input": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006672d0a400000000000000000000000000000000000000000000000000000000000000020b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000005af3107a40000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000005af3107a400000000000000000000000000000000000000000000000000000000353ca3e629a00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bae2c46ddb314b9ba743c6dee4878f151881333d9000bb8ebf1f662bf092ff0d913a9fe9d7179b0efef1611000000000000000000000000000000000000000000", - "accessList": [], - "v": "0x1", - "r": "0x36517a175a60d3026380318917976fa32c82e542850357a611af05d2212ab9a4", - "s": "0x32d89dce30d76287ddba907b0c662cd09dc30891b1c9c2ef644edfc53160b298", - "yParity": "0x1", - "hash": "0xece2a3c6ca097cfe5d97aad4e79393240f63865210f9c763703d1136f065298b" - }, - { - "type": "0x2", - "chainId": "0x28c61", - "nonce": "0x39", - "to": "0x380a5ba81efe70fe98ab56613ebf9244a2f3d4c9", - "gas": "0x2c2c8", - "gasPrice": null, - "maxPriorityFeePerGas": "0x1", - "maxFeePerGas": "0x3", - "value": "0x5af3107a4000", - "input": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006672d0d400000000000000000000000000000000000000000000000000000000000000020b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000005af3107a40000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000005af3107a400000000000000000000000000000000000000000000000000000000353ca3e629a00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bae2c46ddb314b9ba743c6dee4878f151881333d9000bb8ebf1f662bf092ff0d913a9fe9d7179b0efef1611000000000000000000000000000000000000000000", + "maxPriorityFeePerGas": "0xcbef0801", + "maxFeePerGas": "0xcbef0801", + "value": "0x0", + "input": "0xbb2cd728000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000ae2c46ddb314b9ba743c6dee4878f151881333d90000000000000000000000007d16e966c879ed6ad9972ddd5376c41a427d2c2a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000004cd712049c0000000000000000000000000000000000000000000000000000057b3ac2af84", "accessList": [], "v": "0x0", - "r": "0xc779421d1ee81dbd3dfbfad5fd632b45303b4513ea1b8ac0bc647f5430cd97b9", - "s": "0x13cedef844bf5a954183182992ffbf9b8b23331de255157528be7da6614618b2", + "r": "0xbfc407896ee6ed36962d1a591b41aa9a17fe19e176e61cb54a1cd69e3a337508", + "s": "0x621b2448dda4d797447935c051e3908f65dfb3729415280a04cb02c4474baefe", "yParity": "0x0", - "hash": "0xb105d9f16e8fb913093c8a2c595bf4257328d256f218a05be8dcc626ddeb4193" + "hash": "0xffbcd2fab90f1bf314ca2da1bf83eeab3d17fd58a0393d29a697b2ff05d0e65c" } ] - ] + ], + "TxListBytes": [ + "eJz6ybTuJ6NeU4dZy5cdBYzNzPEGU7pFLrVvEeX/pHXc9se+Ir7J9qmz9jTsOGKYuP0bA36gQECeEb+0+kscEqyl0vknd+26p4lPN8cPQWMC9gs0s0o8XbB9y9YQPo7yuN027DXLrxaZ99zOuxpn3C5u3+QR3nOg+OUC+Y6En9yJCroOBRdfL5lyuUdng07JvIVvQnR6mZ6ee51iuZOxiuknY1kzU09ik9qFltPvORjBRDPjgtlT9PO+7lrHsW7uJ1ONQ+LL65l/WmfyNexkZNmtc12DgPMcCMgvICDPhMxZp+N2d7PIzl0lNrnvPCo+BnYIG99Elq8Ve5l2ovJt1s3puneDy45IOdXqaJFiPhrwuS7EMge3NGu11aH1LQcaFuw/wt6Z9+yt2TRdqUhpx1WzxP9JPix7JrPVS+baPCvjUo4FSdIqHneXXJ/uUml6IPDxhP7U+5uLpohqcLGcZjri7r3uHyAAAP//huiQHQ==" + ], + "ParentMetaHash": "0x2bcf3b1bb0c4066aa46ba6e99b79d7602f124d5ae8fcffd2977b1c2138aa61bc" }); } } From 752e1697c41b02c373faacaab899763b2c0a9d3a Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Wed, 3 Jul 2024 22:32:56 +0200 Subject: [PATCH 3/6] Forwarding of encoded tx to the mev boost module --- Node/src/main.rs | 9 +++++++-- Node/src/mev_boost/mod.rs | 17 +++++++++++++++++ Node/src/node/mod.rs | 24 ++++++++++++++++++++---- Node/src/taiko/mod.rs | 26 ++++++++++++++++++++++++-- 4 files changed, 68 insertions(+), 8 deletions(-) diff --git a/Node/src/main.rs b/Node/src/main.rs index 57ae886..0f9357e 100644 --- a/Node/src/main.rs +++ b/Node/src/main.rs @@ -18,8 +18,13 @@ async fn main() -> Result<(), Error> { let (node_tx, node_rx) = mpsc::channel(MESSAGE_QUEUE_SIZE); let p2p = p2p_network::AVSp2p::new(node_tx.clone(), avs_p2p_rx); p2p.start(); - let ethereum_l1 = ethereum_l1::EthereumL1::new("http://localhost:8545", "private_key")?; - let node = node::Node::new(node_rx, avs_p2p_tx, ethereum_l1); + let taiko = taiko::Taiko::new("http://127.0.0.1:1234", "http://127.0.0.1:1235"); + let ethereum_l1 = ethereum_l1::EthereumL1::new( + "http://localhost:8545", + "0x4c0883a69102937d6231471b5dbb6204fe512961708279f2e3e8a5d4b8e3e3e8", + )?; + let mev_boost = mev_boost::MevBoost::new("http://localhost:8545"); + let node = node::Node::new(node_rx, avs_p2p_tx, taiko, ethereum_l1, mev_boost); node.entrypoint().await?; Ok(()) } diff --git a/Node/src/mev_boost/mod.rs b/Node/src/mev_boost/mod.rs index 8b13789..96b26d8 100644 --- a/Node/src/mev_boost/mod.rs +++ b/Node/src/mev_boost/mod.rs @@ -1 +1,18 @@ +use crate::utils::rpc_client::RpcClient; +pub struct MevBoost { + _rpc_client: RpcClient, +} + +impl MevBoost { + pub fn new(rpc_url: &str) -> Self { + let rpc_client = RpcClient::new(rpc_url); + Self { + _rpc_client: rpc_client, + } + } + + pub fn send_transaction(&self, _tx: &[u8], _validator_index: u64, _slot: u64) { + //TODO: implement + } +} diff --git a/Node/src/node/mod.rs b/Node/src/node/mod.rs index 1dacafb..61d5262 100644 --- a/Node/src/node/mod.rs +++ b/Node/src/node/mod.rs @@ -1,5 +1,4 @@ -use crate::ethereum_l1::EthereumL1; -use crate::taiko::Taiko; +use crate::{ethereum_l1::EthereumL1, mev_boost::MevBoost, taiko::Taiko}; use anyhow::{anyhow as any_err, Error, Ok}; use tokio::sync::mpsc::{Receiver, Sender}; @@ -9,21 +8,24 @@ pub struct Node { avs_p2p_tx: Sender, gas_used: u64, ethereum_l1: EthereumL1, + mev_boost: MevBoost, } impl Node { pub fn new( node_rx: Receiver, avs_p2p_tx: Sender, + taiko: Taiko, ethereum_l1: EthereumL1, + mev_boost: MevBoost, ) -> Self { - let taiko = Taiko::new("http://127.0.0.1:1234", "http://127.0.0.1:1235"); Self { taiko, node_rx: Some(node_rx), avs_p2p_tx, gas_used: 0, ethereum_l1, + mev_boost, } } @@ -74,12 +76,26 @@ impl Node { .get_pending_l2_tx_lists() .await .map_err(Error::from)?; + if pending_tx_lists.tx_list_bytes.len() == 0 { + return Ok(()); + } + self.commit_to_the_tx_lists(); self.send_preconfirmations_to_the_avs_p2p().await?; self.taiko .advance_head_to_new_l2_block(pending_tx_lists.tx_lists, self.gas_used) .await?; - // self.ethereum_l1.propose_new_block(pending_tx_lists).await?; + let tx = self + .ethereum_l1 + .create_propose_new_block_tx( + "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" + .parse() + .unwrap(), + pending_tx_lists.tx_list_bytes[0].clone(), //TODO: handle rest tx lists + pending_tx_lists.parent_meta_hash, + ) + .await?; + self.mev_boost.send_transaction(&tx, 1, 1); Ok(()) } diff --git a/Node/src/taiko/mod.rs b/Node/src/taiko/mod.rs index 15f0c23..d24490a 100644 --- a/Node/src/taiko/mod.rs +++ b/Node/src/taiko/mod.rs @@ -19,11 +19,33 @@ impl Taiko { pub async fn get_pending_l2_tx_lists(&self) -> Result { tracing::debug!("Getting L2 tx lists"); - l2_tx_lists::decompose_pending_lists_json( + let result = l2_tx_lists::decompose_pending_lists_json( self.rpc_proposer .call_method("RPC.GetL2TxLists", vec![]) .await?, - ) + )?; + + if result.tx_list_bytes.len() > 0 { + Self::print_number_of_received_txs(&result); + } + + Ok(result) + } + + fn print_number_of_received_txs(result: &l2_tx_lists::RPCReplyL2TxLists) { + if let Some(tx_lists) = result.tx_lists.as_array() { + let mut hashes = Vec::new(); + for (_, tx_list) in tx_lists.iter().enumerate() { + if let Some(tx_list_array) = tx_list.as_array() { + for (_, tx) in tx_list_array.iter().enumerate() { + if let Some(hash) = tx.get("hash") { + hashes.push(hash.as_str().unwrap_or("").get(0..8).unwrap_or("")); + } + } + } + } + tracing::debug!("Received L2 txs: [{}]", hashes.join(" ")); + } } pub async fn advance_head_to_new_l2_block( From 762300d6e55f628f695aa3b3512e03caec94d153 Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Thu, 4 Jul 2024 09:33:01 +0200 Subject: [PATCH 4/6] Configuration parameters take form the ENV --- Node/src/ethereum_l1/mod.rs | 26 +++++++++++-------- Node/src/main.rs | 10 +++++--- Node/src/node/mod.rs | 5 +--- Node/src/taiko/mod.rs | 6 ++--- Node/src/utils/config.rs | 50 +++++++++++++++++++++++++++++++++++++ Node/src/utils/mod.rs | 1 + 6 files changed, 76 insertions(+), 22 deletions(-) create mode 100644 Node/src/utils/config.rs diff --git a/Node/src/ethereum_l1/mod.rs b/Node/src/ethereum_l1/mod.rs index 5e0e542..e44a30a 100644 --- a/Node/src/ethereum_l1/mod.rs +++ b/Node/src/ethereum_l1/mod.rs @@ -16,6 +16,7 @@ use std::str::FromStr; pub struct EthereumL1 { rpc_url: reqwest::Url, wallet: EthereumWallet, + new_block_proposal_contract_address: Address, } sol!( @@ -46,19 +47,23 @@ sol! { } impl EthereumL1 { - pub fn new(rpc_url: &str, private_key: &str) -> Result { + pub fn new( + rpc_url: &str, + private_key: &str, + new_block_proposal_contract_address: &str, + ) -> Result { let signer = PrivateKeySigner::from_str(private_key)?; let wallet = EthereumWallet::from(signer); Ok(Self { rpc_url: rpc_url.parse()?, wallet, + new_block_proposal_contract_address: new_block_proposal_contract_address.parse()?, }) } pub async fn create_propose_new_block_tx( &self, - contract_address: Address, tx_list: Vec, parent_meta_hash: [u8; 32], ) -> Result, Error> { @@ -67,7 +72,7 @@ impl EthereumL1 { .wallet(self.wallet.clone()) .on_http(self.rpc_url.clone()); - let contract = PreconfTaskManager::new(contract_address, provider); + let contract = PreconfTaskManager::new(self.new_block_proposal_contract_address, provider); let block_params = BlockParams { assignedProver: Address::ZERO, @@ -124,7 +129,12 @@ impl EthereumL1 { let signer = PrivateKeySigner::from_signing_key(private_key.into()); let wallet = EthereumWallet::from(signer); - Ok(Self { rpc_url, wallet }) + Ok(Self { + rpc_url, + wallet, + new_block_proposal_contract_address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" + .parse()?, + }) } #[cfg(test)] @@ -197,13 +207,7 @@ mod tests { // some random address for test let encoded_tx = ethereum_l1 - .create_propose_new_block_tx( - "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" - .parse() - .unwrap(), - vec![0; 32], - [0; 32], - ) + .create_propose_new_block_tx(vec![0; 32], [0; 32]) .await .unwrap(); diff --git a/Node/src/main.rs b/Node/src/main.rs index 0f9357e..0adc7c4 100644 --- a/Node/src/main.rs +++ b/Node/src/main.rs @@ -13,17 +13,19 @@ const MESSAGE_QUEUE_SIZE: usize = 100; #[tokio::main] async fn main() -> Result<(), Error> { init_logging(); + let config = utils::config::Config::read_env_variables(); let (avs_p2p_tx, avs_p2p_rx) = mpsc::channel(MESSAGE_QUEUE_SIZE); let (node_tx, node_rx) = mpsc::channel(MESSAGE_QUEUE_SIZE); let p2p = p2p_network::AVSp2p::new(node_tx.clone(), avs_p2p_rx); p2p.start(); - let taiko = taiko::Taiko::new("http://127.0.0.1:1234", "http://127.0.0.1:1235"); + let taiko = taiko::Taiko::new(&config.taiko_proposer_url, &config.taiko_driver_url); let ethereum_l1 = ethereum_l1::EthereumL1::new( - "http://localhost:8545", - "0x4c0883a69102937d6231471b5dbb6204fe512961708279f2e3e8a5d4b8e3e3e8", + &config.mev_boost_url, + &config.ethereum_private_key, + &config.new_block_proposal_contract_address, )?; - let mev_boost = mev_boost::MevBoost::new("http://localhost:8545"); + let mev_boost = mev_boost::MevBoost::new(&config.mev_boost_url); let node = node::Node::new(node_rx, avs_p2p_tx, taiko, ethereum_l1, mev_boost); node.entrypoint().await?; Ok(()) diff --git a/Node/src/node/mod.rs b/Node/src/node/mod.rs index 61d5262..32b2768 100644 --- a/Node/src/node/mod.rs +++ b/Node/src/node/mod.rs @@ -76,7 +76,7 @@ impl Node { .get_pending_l2_tx_lists() .await .map_err(Error::from)?; - if pending_tx_lists.tx_list_bytes.len() == 0 { + if pending_tx_lists.tx_list_bytes.is_empty() { return Ok(()); } @@ -88,9 +88,6 @@ impl Node { let tx = self .ethereum_l1 .create_propose_new_block_tx( - "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" - .parse() - .unwrap(), pending_tx_lists.tx_list_bytes[0].clone(), //TODO: handle rest tx lists pending_tx_lists.parent_meta_hash, ) diff --git a/Node/src/taiko/mod.rs b/Node/src/taiko/mod.rs index d24490a..3c41a11 100644 --- a/Node/src/taiko/mod.rs +++ b/Node/src/taiko/mod.rs @@ -25,7 +25,7 @@ impl Taiko { .await?, )?; - if result.tx_list_bytes.len() > 0 { + if !result.tx_list_bytes.is_empty() { Self::print_number_of_received_txs(&result); } @@ -35,9 +35,9 @@ impl Taiko { fn print_number_of_received_txs(result: &l2_tx_lists::RPCReplyL2TxLists) { if let Some(tx_lists) = result.tx_lists.as_array() { let mut hashes = Vec::new(); - for (_, tx_list) in tx_lists.iter().enumerate() { + for tx_list in tx_lists { if let Some(tx_list_array) = tx_list.as_array() { - for (_, tx) in tx_list_array.iter().enumerate() { + for tx in tx_list_array { if let Some(hash) = tx.get("hash") { hashes.push(hash.as_str().unwrap_or("").get(0..8).unwrap_or("")); } diff --git a/Node/src/utils/config.rs b/Node/src/utils/config.rs new file mode 100644 index 0000000..b93b86d --- /dev/null +++ b/Node/src/utils/config.rs @@ -0,0 +1,50 @@ +use tracing::{info, warn}; + +pub struct Config { + pub taiko_proposer_url: String, + pub taiko_driver_url: String, + pub ethereum_private_key: String, + pub mev_boost_url: String, + pub new_block_proposal_contract_address: String, +} + +impl Config { + pub fn read_env_variables() -> Self { + const ETHEREUM_PRIVATE_KEY: &str = "ETHEREUM_PRIVATE_KEY"; + const NEW_BLOCK_PROPOSAL_CONTRACT_ADDRESS: &str = "NEW_BLOCK_PROPOSAL_CONTRACT_ADDRESS"; + + let config = Self { + taiko_proposer_url: std::env::var("TAIKO_PROPOSER_URL") + .unwrap_or_else(|_| "http://127.0.0.1:1234".to_string()), + taiko_driver_url: std::env::var("TAIKO_DRIVER_URL") + .unwrap_or_else(|_| "http://127.0.0.1:1235".to_string()), + new_block_proposal_contract_address: std::env::var(NEW_BLOCK_PROPOSAL_CONTRACT_ADDRESS) + .unwrap_or_else(|_| { + warn!( + "No new block proposal contract address found in {} env var, using default", + NEW_BLOCK_PROPOSAL_CONTRACT_ADDRESS + ); + "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2".to_string() + }), + ethereum_private_key: std::env::var(ETHEREUM_PRIVATE_KEY).unwrap_or_else(|_| { + warn!( + "No Ethereum private key found in {} env var, using default", + ETHEREUM_PRIVATE_KEY + ); + "0x4c0883a69102937d6231471b5dbb6204fe512961708279f2e3e8a5d4b8e3e3e8".to_string() + }), + mev_boost_url: std::env::var("MEV_BOOST_URL") + .unwrap_or_else(|_| "http://127.0.0.1:8080".to_string()), + }; + + info!( + "\nConfiguration: \nTaiko proposer URL: {}, \nTaiko driver URL: {}, \nMEV Boost URL: {}, \nNew block proposal contract address: {}", + config.taiko_proposer_url, + config.taiko_driver_url, + config.mev_boost_url, + config.new_block_proposal_contract_address + ); + + config + } +} diff --git a/Node/src/utils/mod.rs b/Node/src/utils/mod.rs index e0ca3dc..29186bd 100644 --- a/Node/src/utils/mod.rs +++ b/Node/src/utils/mod.rs @@ -1,2 +1,3 @@ +pub mod config; pub mod rpc_client; pub mod rpc_server; From 9a8152fbc5ac04c02cf0827c6723c3891385c9f6 Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Thu, 4 Jul 2024 17:00:33 +0200 Subject: [PATCH 5/6] sending new block proposal using builder.send --- Node/src/ethereum_l1/mod.rs | 60 ++++++++++--------------------------- Node/src/mev_boost/mod.rs | 2 ++ Node/src/node/mod.rs | 10 +++---- 3 files changed, 22 insertions(+), 50 deletions(-) diff --git a/Node/src/ethereum_l1/mod.rs b/Node/src/ethereum_l1/mod.rs index e44a30a..4959334 100644 --- a/Node/src/ethereum_l1/mod.rs +++ b/Node/src/ethereum_l1/mod.rs @@ -1,11 +1,7 @@ -#![allow(unused)] //TODO remove after the EthereumL1 is used in release code - use alloy::{ - consensus::transaction::TypedTransaction, network::{Ethereum, EthereumWallet, NetworkWallet}, - primitives::{Address, Bytes, FixedBytes, U256, U32, U64}, + primitives::{Address, Bytes, FixedBytes, U256}, providers::ProviderBuilder, - rpc::types::{TransactionInput, TransactionRequest}, signers::local::PrivateKeySigner, sol, sol_types::SolValue, @@ -62,11 +58,11 @@ impl EthereumL1 { }) } - pub async fn create_propose_new_block_tx( + pub async fn propose_new_block( &self, tx_list: Vec, parent_meta_hash: [u8; 32], - ) -> Result, Error> { + ) -> Result<(), Error> { let provider = ProviderBuilder::new() .with_recommended_fillers() .wallet(self.wallet.clone()) @@ -91,34 +87,17 @@ impl EthereumL1 { let tx_list = Bytes::from(tx_list); let lookahead_set_param: Vec = Vec::new(); + let builder = contract.newBlockProposal( + encoded_block_params, + tx_list, + U256::from(0), + lookahead_set_param, + ); - let builder = contract - .newBlockProposal( - encoded_block_params, - tx_list, - U256::from(0), - lookahead_set_param, - ) - .nonce(1) //TODO how to get it? - .gas(100000) - .max_fee_per_gas(10000000000000000) - .max_priority_fee_per_gas(10000000000000000); - - let tx = builder.as_ref().clone().build_typed_tx(); - let Ok(TypedTransaction::Eip1559(mut tx)) = tx else { - return Err(anyhow::anyhow!("expect tx in EIP1559")); - }; - - let signature = self - .wallet - .default_signer() - .sign_transaction(&mut tx) - .await?; - - let mut buf = vec![]; - tx.encode_with_signature(&signature, &mut buf, false); + let tx_hash = builder.send().await?.watch().await?; + tracing::debug!("Proposed new block: {tx_hash}"); - Ok(buf) + Ok(()) } #[cfg(test)] @@ -132,7 +111,7 @@ impl EthereumL1 { Ok(Self { rpc_url, wallet, - new_block_proposal_contract_address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" + new_block_proposal_contract_address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" // some random address for test .parse()?, }) } @@ -161,7 +140,6 @@ impl EthereumL1 { .on_http(self.rpc_url.clone()); let contract = Counter::deploy(&provider).await?; - let address = contract.address().clone(); let builder = contract.setNumber(U256::from(42)); let tx_hash = builder.send().await?.watch().await?; @@ -183,10 +161,7 @@ impl EthereumL1 { #[cfg(test)] mod tests { use super::*; - use alloy::hex; - use alloy::node_bindings::{Anvil, AnvilInstance}; - use alloy::providers::Provider; - use alloy::rpc::types::TransactionRequest; + use alloy::node_bindings::Anvil; #[tokio::test] async fn test_call_contract() { @@ -205,12 +180,9 @@ mod tests { let private_key = anvil.keys()[0].clone(); let ethereum_l1 = EthereumL1::new_from_pk(rpc_url, private_key).unwrap(); - // some random address for test - let encoded_tx = ethereum_l1 - .create_propose_new_block_tx(vec![0; 32], [0; 32]) + ethereum_l1 + .propose_new_block(vec![0; 32], [0; 32]) .await .unwrap(); - - assert!(encoded_tx.len() > 0); } } diff --git a/Node/src/mev_boost/mod.rs b/Node/src/mev_boost/mod.rs index 96b26d8..388d95c 100644 --- a/Node/src/mev_boost/mod.rs +++ b/Node/src/mev_boost/mod.rs @@ -1,3 +1,5 @@ +#![allow(unused)] //TODO remove after the EthereumL1 is used in release code + use crate::utils::rpc_client::RpcClient; pub struct MevBoost { diff --git a/Node/src/node/mod.rs b/Node/src/node/mod.rs index 32b2768..ad1d3c8 100644 --- a/Node/src/node/mod.rs +++ b/Node/src/node/mod.rs @@ -8,7 +8,7 @@ pub struct Node { avs_p2p_tx: Sender, gas_used: u64, ethereum_l1: EthereumL1, - mev_boost: MevBoost, + _mev_boost: MevBoost, // temporary unused } impl Node { @@ -25,7 +25,7 @@ impl Node { avs_p2p_tx, gas_used: 0, ethereum_l1, - mev_boost, + _mev_boost: mev_boost, } } @@ -85,14 +85,12 @@ impl Node { self.taiko .advance_head_to_new_l2_block(pending_tx_lists.tx_lists, self.gas_used) .await?; - let tx = self - .ethereum_l1 - .create_propose_new_block_tx( + self.ethereum_l1 + .propose_new_block( pending_tx_lists.tx_list_bytes[0].clone(), //TODO: handle rest tx lists pending_tx_lists.parent_meta_hash, ) .await?; - self.mev_boost.send_transaction(&tx, 1, 1); Ok(()) } From a31733a4218d82004517a59371238da2341dcda2 Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Thu, 4 Jul 2024 20:30:19 +0200 Subject: [PATCH 6/6] renamed according to the review --- Node/src/ethereum_l1/mod.rs | 10 +++++----- Node/src/main.rs | 2 +- Node/src/taiko/l2_tx_lists.rs | 2 +- Node/src/utils/config.rs | 15 ++++++++------- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Node/src/ethereum_l1/mod.rs b/Node/src/ethereum_l1/mod.rs index 4959334..445924a 100644 --- a/Node/src/ethereum_l1/mod.rs +++ b/Node/src/ethereum_l1/mod.rs @@ -12,7 +12,7 @@ use std::str::FromStr; pub struct EthereumL1 { rpc_url: reqwest::Url, wallet: EthereumWallet, - new_block_proposal_contract_address: Address, + taiko_preconfirming_address: Address, } sol!( @@ -46,7 +46,7 @@ impl EthereumL1 { pub fn new( rpc_url: &str, private_key: &str, - new_block_proposal_contract_address: &str, + taiko_preconfirming_address: &str, ) -> Result { let signer = PrivateKeySigner::from_str(private_key)?; let wallet = EthereumWallet::from(signer); @@ -54,7 +54,7 @@ impl EthereumL1 { Ok(Self { rpc_url: rpc_url.parse()?, wallet, - new_block_proposal_contract_address: new_block_proposal_contract_address.parse()?, + taiko_preconfirming_address: taiko_preconfirming_address.parse()?, }) } @@ -68,7 +68,7 @@ impl EthereumL1 { .wallet(self.wallet.clone()) .on_http(self.rpc_url.clone()); - let contract = PreconfTaskManager::new(self.new_block_proposal_contract_address, provider); + let contract = PreconfTaskManager::new(self.taiko_preconfirming_address, provider); let block_params = BlockParams { assignedProver: Address::ZERO, @@ -111,7 +111,7 @@ impl EthereumL1 { Ok(Self { rpc_url, wallet, - new_block_proposal_contract_address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" // some random address for test + taiko_preconfirming_address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" // some random address for test .parse()?, }) } diff --git a/Node/src/main.rs b/Node/src/main.rs index 0adc7c4..0c705b8 100644 --- a/Node/src/main.rs +++ b/Node/src/main.rs @@ -23,7 +23,7 @@ async fn main() -> Result<(), Error> { let ethereum_l1 = ethereum_l1::EthereumL1::new( &config.mev_boost_url, &config.ethereum_private_key, - &config.new_block_proposal_contract_address, + &config.taiko_preconfirming_address, )?; let mev_boost = mev_boost::MevBoost::new(&config.mev_boost_url); let node = node::Node::new(node_rx, avs_p2p_tx, taiko, ethereum_l1, mev_boost); diff --git a/Node/src/taiko/l2_tx_lists.rs b/Node/src/taiko/l2_tx_lists.rs index db10ca3..d842710 100644 --- a/Node/src/taiko/l2_tx_lists.rs +++ b/Node/src/taiko/l2_tx_lists.rs @@ -5,7 +5,7 @@ use serde_json::Value; #[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "PascalCase")] pub struct RPCReplyL2TxLists { - pub tx_lists: Value, + pub tx_lists: Value, // TODO: decode and create tx_list_bytes on AVS node side #[serde(deserialize_with = "deserialize_tx_lists_bytes")] pub tx_list_bytes: Vec>, #[serde(deserialize_with = "deserialize_parent_meta_hash")] diff --git a/Node/src/utils/config.rs b/Node/src/utils/config.rs index b93b86d..6bddc74 100644 --- a/Node/src/utils/config.rs +++ b/Node/src/utils/config.rs @@ -5,27 +5,28 @@ pub struct Config { pub taiko_driver_url: String, pub ethereum_private_key: String, pub mev_boost_url: String, - pub new_block_proposal_contract_address: String, + pub taiko_preconfirming_address: String, } impl Config { pub fn read_env_variables() -> Self { const ETHEREUM_PRIVATE_KEY: &str = "ETHEREUM_PRIVATE_KEY"; - const NEW_BLOCK_PROPOSAL_CONTRACT_ADDRESS: &str = "NEW_BLOCK_PROPOSAL_CONTRACT_ADDRESS"; + const TAIKO_PRECONFIRMING_ADDRESS: &str = "TAIKO_PRECONFIRMING_ADDRESS"; let config = Self { taiko_proposer_url: std::env::var("TAIKO_PROPOSER_URL") .unwrap_or_else(|_| "http://127.0.0.1:1234".to_string()), taiko_driver_url: std::env::var("TAIKO_DRIVER_URL") .unwrap_or_else(|_| "http://127.0.0.1:1235".to_string()), - new_block_proposal_contract_address: std::env::var(NEW_BLOCK_PROPOSAL_CONTRACT_ADDRESS) - .unwrap_or_else(|_| { + taiko_preconfirming_address: std::env::var(TAIKO_PRECONFIRMING_ADDRESS).unwrap_or_else( + |_| { warn!( "No new block proposal contract address found in {} env var, using default", - NEW_BLOCK_PROPOSAL_CONTRACT_ADDRESS + TAIKO_PRECONFIRMING_ADDRESS ); "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2".to_string() - }), + }, + ), ethereum_private_key: std::env::var(ETHEREUM_PRIVATE_KEY).unwrap_or_else(|_| { warn!( "No Ethereum private key found in {} env var, using default", @@ -42,7 +43,7 @@ impl Config { config.taiko_proposer_url, config.taiko_driver_url, config.mev_boost_url, - config.new_block_proposal_contract_address + config.taiko_preconfirming_address ); config