-
Notifications
You must be signed in to change notification settings - Fork 906
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{ | ||
"config": { | ||
"chainId": 1, | ||
"homesteadBlock": 0, | ||
"daoForkSupport": true, | ||
"eip150Block": 0, | ||
"eip155Block": 0, | ||
"eip158Block": 0, | ||
"byzantiumBlock": 0, | ||
"constantinopleBlock": 0, | ||
"petersburgBlock": 0, | ||
"istanbulBlock": 0, | ||
"muirGlacierBlock": 0, | ||
"berlinBlock": 0, | ||
"londonBlock": 0, | ||
"arrowGlacierBlock": 0, | ||
"grayGlacierBlock": 0, | ||
"shanghaiTime": 0, | ||
"cancunTime": 0, | ||
"terminalTotalDifficulty": "0x0", | ||
"terminalTotalDifficultyPassed": true | ||
}, | ||
"nonce": "0x0", | ||
"timestamp": "0x0", | ||
"extraData": "0x00", | ||
"gasLimit": "0x1c9c380", | ||
"difficulty": "0x0", | ||
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"coinbase": "0x0000000000000000000000000000000000000000", | ||
"alloc": { | ||
"0x14dc79964da2c08b23698b3d3cc7ca32193d9955": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0x1cbd3b2770909d4e10f157cabc84c7264073c9ec": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0x2546bcd3c84621e976d8185a91a922ae77ecec30": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0x70997970c51812dc3a010c7d01b50e0d17dc79c8": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0x71be63f3384f5fb98995898a86b02fb2426c5788": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0x8626f6940e2eb28930efb4cef49b2d1f2c9c1199": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0x90f79bf6eb2c4f870365e785982e1f101e93b906": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0x976ea74026e726554db657fa54763abd0c3a0aa9": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0x9c41de96b2088cdc640c6182dfcf5491dc574a57": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0xa0ee7a142d267c1f36714e4a8f75612f20a79720": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0xbcd4042de499d14e55001ccbb24a551f3b954096": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0xbda5747bfd65f08deb54cb465eb87d40e51b197e": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0xcd3b766ccdd6ae721141f452c550ca635964ce71": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0xdd2fd4581271e230360230f9337d5c0430bf44c0": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0xdf3e18d64bc6a983f673ab319ccae4f1a57c7097": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
}, | ||
"0xfabb0ac9d68b0b445fb7357272ff202c5651694a": { | ||
"balance": "0xd3c21bcecceda1000000" | ||
} | ||
}, | ||
"number": "0x0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
mod p2p; | ||
mod utils; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
use std::sync::Arc; | ||
|
||
use reth::{ | ||
args::{DiscoveryArgs, NetworkArgs, RpcServerArgs}, | ||
builder::{NodeBuilder, NodeConfig, NodeHandle}, | ||
tasks::TaskManager, | ||
}; | ||
use reth_e2e_test_utils::{node::NodeHelper, wallet::Wallet}; | ||
use reth_node_optimism::node::OptimismNode; | ||
use reth_primitives::{ChainSpecBuilder, Genesis, MAINNET}; | ||
use crate::utils::optimism_payload_attributes; | ||
|
||
#[tokio::test] | ||
async fn can_sync() -> eyre::Result<()> { | ||
reth_tracing::init_test_tracing(); | ||
|
||
let tasks = TaskManager::current(); | ||
let exec = tasks.executor(); | ||
|
||
let genesis: Genesis = serde_json::from_str(include_str!("../assets/genesis.json")).unwrap(); | ||
let chain_spec = Arc::new( | ||
ChainSpecBuilder::default() | ||
.chain(MAINNET.chain) | ||
.genesis(genesis) | ||
.cancun_activated() | ||
.build(), | ||
); | ||
|
||
let network_config = NetworkArgs { | ||
discovery: DiscoveryArgs { disable_discovery: true, ..DiscoveryArgs::default() }, | ||
..NetworkArgs::default() | ||
}; | ||
|
||
let node_config = NodeConfig::test() | ||
.with_chain(chain_spec) | ||
.with_network(network_config) | ||
.with_unused_ports() | ||
.with_rpc(RpcServerArgs::default().with_unused_ports().with_http()); | ||
|
||
let NodeHandle { node, node_exit_future: _ } = NodeBuilder::new(node_config.clone()) | ||
.testing_node(exec.clone()) | ||
.node(OptimismNode::default()) | ||
.launch() | ||
.await?; | ||
|
||
let mut first_node = NodeHelper::new(node.clone()).await?; | ||
|
||
let NodeHandle { node, node_exit_future: _ } = NodeBuilder::new(node_config) | ||
.testing_node(exec) | ||
.node(OptimismNode::default()) | ||
.launch() | ||
.await?; | ||
|
||
let mut second_node = NodeHelper::new(node).await?; | ||
|
||
let mut wallet = Wallet::default(); | ||
let raw_tx = wallet.transfer_tx().await; | ||
|
||
// Make them peer | ||
first_node.network.add_peer(second_node.network.record()).await; | ||
second_node.network.add_peer(first_node.network.record()).await; | ||
|
||
// Make sure they establish a new session | ||
first_node.network.expect_session().await; | ||
second_node.network.expect_session().await; | ||
|
||
// Make the first node advance | ||
let (block_hash, tx_hash) = first_node.advance(raw_tx.clone(), optimism_payload_attributes).await?; | ||
|
||
// only send forkchoice update to second node | ||
second_node.engine_api.update_forkchoice(block_hash).await?; | ||
|
||
// expect second node advanced via p2p gossip | ||
second_node.assert_new_block(tx_hash, block_hash, 1).await?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use reth::rpc::types::engine::PayloadAttributes; | ||
use reth_node_optimism::OptimismPayloadBuilderAttributes; | ||
use reth_payload_builder::EthPayloadBuilderAttributes; | ||
use reth_primitives::{Address, B256}; | ||
|
||
/// Helper function to create a new eth payload attributes | ||
pub(crate) fn optimism_payload_attributes(timestamp: u64) -> OptimismPayloadBuilderAttributes { | ||
let attributes = PayloadAttributes { | ||
timestamp, | ||
prev_randao: B256::ZERO, | ||
suggested_fee_recipient: Address::ZERO, | ||
withdrawals: Some(vec![]), | ||
parent_beacon_block_root: Some(B256::ZERO), | ||
}; | ||
|
||
OptimismPayloadBuilderAttributes { | ||
payload_attributes: EthPayloadBuilderAttributes::new(B256::ZERO, attributes), | ||
transactions: vec![], | ||
no_tx_pool: false, | ||
gas_limit: Some(30_000_000), | ||
} | ||
} |