Skip to content

Commit

Permalink
Respond to PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHinshelwood committed Dec 9, 2024
1 parent bf4341d commit cf34026
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
2 changes: 2 additions & 0 deletions config-example.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
p2p_port = 0

[[nodes]]
enabled_apis = [ "admin", "erigon", "eth", "net", "ots", "trace", "txpool", "web3", "zilliqa" ]
json_rpc_port = 4201
eth_chain_id = 0x8001
consensus.consensus_timeout = { secs = 5, nanos = 0 }
Expand Down Expand Up @@ -28,6 +29,7 @@ consensus.eth_block_gas_limit = 84000000
consensus.gas_price = "4_761_904_800_000"

[[nodes]]
enabled_apis = [ "admin", "erigon", "eth", "net", "ots", "trace", "txpool", "web3", "zilliqa" ]
json_rpc_port = 4202
eth_chain_id = 0x8002
[nodes.consensus]
Expand Down
1 change: 1 addition & 0 deletions config-single-node.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
p2p_port = 0

[[nodes]]
enabled_apis = [ "admin", "erigon", "eth", "net", "ots", "trace", "txpool", "web3", "zilliqa" ]
json_rpc_port = 4201
eth_chain_id = 0x8001
consensus.consensus_timeout = { secs = 5, nanos = 0 }
Expand Down
1 change: 1 addition & 0 deletions infra/config_rpc_disabled.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
otlp_collector_endpoint = "http://otel-collector:4317"

[[nodes]]
enabled_apis = [ "admin", "erigon", "eth", "net", "ots", "trace", "txpool", "web3", "zilliqa" ]
# These (public key, peerId, stake, rewardAddress) tuples correspond to the private keys of all four nodes in `docker-compose.yaml`.
consensus.genesis_deposits = [
["b27aebb3b54effd7af87c4a064a711554ee0f3f5abf56ca910b46422f2b21603bc383d42eb3b927c4c3b0b8381ca30a3", "12D3KooWESMZ2ttSxDwjfnNe23sHCqsJf6sNEKwgHkdgtCHDsbWU", "10000000000000000000000000", "7E5F4552091A69125d5DfCb7b8C2659029395Bdf", "7E5F4552091A69125d5DfCb7b8C2659029395Bdf"],
Expand Down
2 changes: 1 addition & 1 deletion z2/src/chain/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ impl ChainNode {
};

let mut ctx = Context::new();
ctx.insert("key", &role_name);
ctx.insert("role", &role_name);
ctx.insert("eth_chain_id", &eth_chain_id);
ctx.insert("bootstrap_public_ip", &bootstrap_public_ip);
ctx.insert("bootstrap_peer_id", &bootstrap_node.peer_id);
Expand Down
44 changes: 23 additions & 21 deletions zilliqa/src/node_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,28 +125,30 @@ impl NodeLauncher {

let rpc_module = api::rpc_module(Arc::clone(&node));

trace!("Launching JSON-RPC server");
// Construct the JSON-RPC API server. We inject a [CorsLayer] to ensure web browsers can call our API directly.
let cors = CorsLayer::new()
.allow_methods(Method::POST)
.allow_origin(Any)
.allow_headers([header::CONTENT_TYPE]);
let middleware = tower::ServiceBuilder::new().layer(HealthLayer).layer(cors);
let port = config.json_rpc_port;
let server = jsonrpsee::server::ServerBuilder::new()
.set_http_middleware(middleware)
.set_id_provider(EthIdProvider)
.build((Ipv4Addr::UNSPECIFIED, port))
.await;
if !config.enabled_apis.is_empty() {
trace!("Launching JSON-RPC server");
// Construct the JSON-RPC API server. We inject a [CorsLayer] to ensure web browsers can call our API directly.
let cors = CorsLayer::new()
.allow_methods(Method::POST)
.allow_origin(Any)
.allow_headers([header::CONTENT_TYPE]);
let middleware = tower::ServiceBuilder::new().layer(HealthLayer).layer(cors);
let port = config.json_rpc_port;
let server = jsonrpsee::server::ServerBuilder::new()
.set_http_middleware(middleware)
.set_id_provider(EthIdProvider)
.build((Ipv4Addr::UNSPECIFIED, port))
.await;

match server {
Ok(server) => {
info!("JSON-RPC server listening on port {}", port);
let handle = server.start(rpc_module.clone());
tokio::spawn(handle.stopped());
}
Err(e) => {
error!("Failed to start JSON-RPC server: {}", e);
match server {
Ok(server) => {
info!("JSON-RPC server listening on port {}", port);
let handle = server.start(rpc_module.clone());
tokio::spawn(handle.stopped());
}
Err(e) => {
error!("Failed to start JSON-RPC server: {}", e);
}
}
}

Expand Down

0 comments on commit cf34026

Please sign in to comment.