Skip to content

Commit

Permalink
pr findings
Browse files Browse the repository at this point in the history
  • Loading branch information
Keszey Dániel authored and Keszey Dániel committed Aug 26, 2024
1 parent 95787f5 commit 7125b8b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
3 changes: 2 additions & 1 deletion bin/reth/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ use reth_provider::providers::BlockchainProvider;
use reth_rpc_api::{eth::{helpers::AddDevSigners, FullEthApiServer}, EngineApiClient};
use reth_tasks::TaskManager;
use reth_transaction_pool::{blobstore::DiskFileBlobStore, CoinbaseTipOrdering, EthPooledTransaction, EthTransactionValidator, Pool, TransactionValidationTaskExecutor};
use traits::RpcServerArgsExEx;
use std::{future::Future, marker::PhantomData, pin::Pin, sync::Arc};

use alloy_rlp::Decodable;
Expand Down Expand Up @@ -278,7 +279,7 @@ fn main() -> eyre::Result<()> {
.with_chain(chain_spec.clone())
.with_network(network_config.clone())
.with_unused_ports()
.with_rpc(RpcServerArgs::default().with_unused_ports().with_http_and_custom_exex_values())
.with_rpc(RpcServerArgs::default().with_unused_ports().with_static_l2_rpc_ip_and_port())
.set_dev(true);

let NodeHandle { node, node_exit_future: _ } = NodeBuilder::new(node_config.clone())
Expand Down
16 changes: 16 additions & 0 deletions bin/reth/src/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::net::Ipv4Addr;

use alloy_consensus::TxEnvelope;
use alloy_network::eip2718::Decodable2718;
use reth::{
Expand All @@ -10,8 +12,11 @@ use reth::{
server_types::eth::EthResult,
},
};
use reth_node_core::args::RpcServerArgs;
use reth_primitives::{Bytes, B256};

use crate::traits::RpcServerArgsExEx;

pub struct RpcTestContext<Node: FullNodeComponents, EthApi> {
pub inner: RpcRegistry<Node, EthApi>,
}
Expand All @@ -33,3 +38,14 @@ where
Ok(TxEnvelope::decode_2718(&mut tx.as_ref()).unwrap())
}
}

impl RpcServerArgsExEx for RpcServerArgs {
fn with_static_l2_rpc_ip_and_port(mut self) -> Self {
self.http = true;
// On the instance the program is running, we wanna have 10111 exposed as the (exex) L2's RPC port.
self.http_addr = Ipv4Addr::new(0, 0, 0, 0).into();
self.http_port = 10110u16;
self.ws_port = 10111u16;
self
}
}
3 changes: 3 additions & 0 deletions bin/reth/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ impl PayloadEnvelopeExt for ExecutionPayloadEnvelopeV3 {
self.execution_payload.clone()
}
}
pub trait RpcServerArgsExEx {
fn with_static_l2_rpc_ip_and_port(self) -> Self;
}
17 changes: 4 additions & 13 deletions crates/node/core/src/args/rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,6 @@ impl RpcServerArgs {
self
}

// Enables the HTTP-RPC server.
pub fn with_http_and_custom_exex_values(mut self) -> Self {
self.http = true;
self.http_addr = Ipv4Addr::new(0,0,0,0).into();
self.http_port= 10110u16;
self.ws_port= 10111u16;
self
}

/// Enables the WS-RPC server.
pub const fn with_ws(mut self) -> Self {
self.ws = true;
Expand Down Expand Up @@ -283,19 +274,19 @@ impl RpcServerArgs {
impl Default for RpcServerArgs {
fn default() -> Self {
Self {
http: true,
http: false,
http_addr: Ipv4Addr::LOCALHOST.into(),
http_port: constants::DEFAULT_HTTP_RPC_PORT,
http_api: None,
http_corsdomain: None,
ws: true,
ws_addr: Ipv4Addr::LOCALHOST.into(),//Ipv4Addr::new(0,0,0,0).into(),
ws: false,
ws_addr: Ipv4Addr::LOCALHOST.into(),
ws_port: constants::DEFAULT_WS_RPC_PORT,
ws_allowed_origins: None,
ws_api: None,
ipcdisable: false,
ipcpath: constants::DEFAULT_IPC_ENDPOINT.to_string(),
auth_addr: Ipv4Addr::LOCALHOST.into(),//Ipv4Addr::new(0,0,0,0).into(),
auth_addr: Ipv4Addr::LOCALHOST.into(),
auth_port: constants::DEFAULT_AUTH_PORT,
auth_jwtsecret: None,
auth_ipc: false,
Expand Down
7 changes: 0 additions & 7 deletions crates/node/core/src/node_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,6 @@ impl NodeConfig {
/// Set the rpc args for the node
pub fn with_rpc(mut self, rpc: RpcServerArgs) -> Self {
self.rpc = rpc;
let new_rpc = self.rpc.clone();

println!("Server details:");

println!("{:?}", new_rpc.http_addr);
println!("{:?}", new_rpc.http_port);

self
}

Expand Down
8 changes: 6 additions & 2 deletions packages/protocol/scripts/setup_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ echo "Running Kurtosis command..."
KURTOSIS_OUTPUT=$(kurtosis run github.com/adaki2004/ethereum-package --args-file ./scripts/confs/network_params.yaml)

# Print the entire Kurtosis output for debugging
echo "Kurtosis Output:"
echo "$KURTOSIS_OUTPUT"
# echo "Kurtosis Output:"
# echo "$KURTOSIS_OUTPUT"

# Extract the "User Services" section
USER_SERVICES_SECTION=$(echo "$KURTOSIS_OUTPUT" | awk '/^========================================== User Services ==========================================/{flag=1;next}/^$/{flag=0}flag')
Expand All @@ -99,13 +99,15 @@ echo "$USER_SERVICES_SECTION"

# Extract the dynamic port assigned to the rpc service for "el-1-reth-lighthouse"
RPC_PORT=$(echo "$USER_SERVICES_SECTION" | grep -A 5 "el-1-reth-lighthouse" | grep "rpc: 8545/tcp" | sed -E 's/.* -> 127.0.0.1:([0-9]+).*/\1/')

if [ -z "$RPC_PORT" ]; then
echo "Failed to extract RPC port from User Services section."
exit 1
else
echo "Extracted RPC port: $RPC_PORT"
echo "$RPC_PORT" > /tmp/kurtosis_rpc_port
fi

# Load the .env file and extract the PRIVATE_KEY
if [ -f .env ]; then
export $(grep -v '^#' .env | xargs)
Expand All @@ -114,10 +116,12 @@ else
echo ".env file not found. Please create a .env file with your PRIVATE_KEY."
exit 1
fi

if [ -z "$PRIVATE_KEY" ]; then
echo "PRIVATE_KEY not found in the .env file."
exit 1
fi

# Run the forge foundry script using the extracted RPC port and PRIVATE_KEY
FORGE_COMMAND="forge script --rpc-url http://127.0.0.1:$RPC_PORT scripts/DeployL1Locally.s.sol -vvvv --broadcast --private-key $PRIVATE_KEY --legacy"
echo "Running forge foundry script..."
Expand Down

0 comments on commit 7125b8b

Please sign in to comment.