From d2b7ee27de7d8d91ccafd3a2f873b81134392107 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 18 Mar 2020 21:36:22 +0200 Subject: [PATCH] The RPC service listens on localhost by default --- beacon_chain/beacon_node.nim | 4 +- beacon_chain/conf.nim | 74 ++++++++++++++++++--------------- beacon_chain/eth2_network.nim | 2 +- scripts/connect_to_testnet.nims | 2 +- 4 files changed, 45 insertions(+), 37 deletions(-) diff --git a/beacon_chain/beacon_node.nim b/beacon_chain/beacon_node.nim index 2ce4c50a4..72dd129d8 100644 --- a/beacon_chain/beacon_node.nim +++ b/beacon_chain/beacon_node.nim @@ -363,7 +363,7 @@ proc sendAttestation(node: BeaconNode, node.network.broadcast( getAttestationTopic(attestationData.index), attestation) - if node.config.dump: + if node.config.dumpEnabled: SSZ.saveFile( node.config.dumpDir / "att-" & $attestationData.slot & "-" & $attestationData.index & "-" & validator.pubKey.shortLog & @@ -444,7 +444,7 @@ proc proposeBlock(node: BeaconNode, validator = shortLog(validator), cat = "consensus" - if node.config.dump: + if node.config.dumpEnabled: SSZ.saveFile( node.config.dumpDir / "block-" & $newBlock.message.slot & "-" & shortLog(newBlockRef.root) & ".ssz", newBlock) diff --git a/beacon_chain/conf.nim b/beacon_chain/conf.nim index fd22ad006..5ef9a3ed1 100644 --- a/beacon_chain/conf.nim +++ b/beacon_chain/conf.nim @@ -60,34 +60,6 @@ type desc: "Address of the deposit contract." name: "deposit-contract" }: string - statusBarEnabled* {. - defaultValue: true - desc: "Display a status bar at the bottom of the terminal screen." - name: "status-bar" }: bool - - statusBarContents* {. - defaultValue: "peers: $connected_peers; " & - "epoch: $epoch, slot: $epoch_slot/$slots_per_epoch ($slot); " & - "finalized epoch: $last_finalized_epoch |" & - "ETH: $attached_validators_balance" - desc: "Textual template for the contents of the status bar." - name: "status-bar-contents" }: string - - rpcEnabled* {. - defaultValue: false - desc: "Enable the JSON-RPC server" - name: "rpc" }: bool - - rpcPort* {. - defaultValue: defaultEth2RpcPort - desc: "HTTP port for the JSON-RPC service." - name: "rpc-port" }: Port - - rpcAddress* {. - defaultValue: defaultListenAddress(config) - desc: "Listening address of the RPC server" - name: "rpc-address" }: IpAddress - case cmd* {. command defaultValue: noCommand }: StartUpCmd @@ -103,14 +75,19 @@ type desc: "Specifies a line-delimited file of bootsrap Ethereum network addresses." name: "bootstrap-file" }: InputFile + libp2pAddress* {. + defaultValue: defaultListenAddress(config) + desc: "Listening address for the Ethereum LibP2P traffic." + name: "listen-address"}: IpAddress + tcpPort* {. defaultValue: defaultEth2TcpPort - desc: "TCP listening port." + desc: "Listening TCP port for Ethereum LibP2P traffic." name: "tcp-port" }: Port udpPort* {. defaultValue: defaultEth2TcpPort - desc: "UDP listening port." + desc: "Listening UDP port for node discovery." name: "udp-port" }: Port maxPeers* {. @@ -156,7 +133,7 @@ type name: "metrics" }: bool metricsAddress* {. - defaultValue: defaultListenAddress(config) + defaultValue: defaultAdminListenAddress(config) desc: "Listening address of the metrics server." name: "metrics-address" }: IpAddress @@ -165,10 +142,38 @@ type desc: "Listening HTTP port of the metrics server." name: "metrics-port" }: Port - dump* {. + statusBarEnabled* {. + defaultValue: true + desc: "Display a status bar at the bottom of the terminal screen." + name: "status-bar" }: bool + + statusBarContents* {. + defaultValue: "peers: $connected_peers; " & + "epoch: $epoch, slot: $epoch_slot/$slots_per_epoch ($slot); " & + "finalized epoch: $last_finalized_epoch |" & + "ETH: $attached_validators_balance" + desc: "Textual template for the contents of the status bar." + name: "status-bar-contents" }: string + + rpcEnabled* {. + defaultValue: false + desc: "Enable the JSON-RPC server" + name: "rpc" }: bool + + rpcPort* {. + defaultValue: defaultEth2RpcPort + desc: "HTTP port for the JSON-RPC service." + name: "rpc-port" }: Port + + rpcAddress* {. + defaultValue: defaultAdminListenAddress(config) + desc: "Listening address of the RPC server" + name: "rpc-address" }: IpAddress + + dumpEnabled* {. defaultValue: false desc: "Write SSZ dumps of blocks, attestations and states to data dir" - .}: bool + name: "dump" }: bool of createTestnet: validatorsDir* {. @@ -289,6 +294,9 @@ func defaultListenAddress*(conf: BeaconNodeConf): IpAddress = # Maybe there should be a config option for this. parseIpAddress("0.0.0.0") +func defaultAdminListenAddress*(conf: BeaconNodeConf): IpAddress = + parseIpAddress("127.0.0.1") + iterator validatorKeys*(conf: BeaconNodeConf): ValidatorPrivKey = for validatorKeyFile in conf.validators: try: diff --git a/beacon_chain/eth2_network.nim b/beacon_chain/eth2_network.nim index a7daed141..bb71ef73b 100644 --- a/beacon_chain/eth2_network.nim +++ b/beacon_chain/eth2_network.nim @@ -141,7 +141,7 @@ when networkBackend in [libp2p, libp2pDaemon]: bootstrapNodes: seq[ENode]): Future[Eth2Node] {.async.} = var (extIp, extTcpPort, _) = setupNat(conf) - hostAddress = tcpEndPoint(globalListeningAddr, conf.tcpPort) + hostAddress = tcpEndPoint(conf.libp2pAddress, conf.tcpPort) announcedAddresses = if extIp == globalListeningAddr: @[] else: @[tcpEndPoint(extIp, extTcpPort)] diff --git a/scripts/connect_to_testnet.nims b/scripts/connect_to_testnet.nims index bff824dab..f30d4c2cf 100644 --- a/scripts/connect_to_testnet.nims +++ b/scripts/connect_to_testnet.nims @@ -142,7 +142,7 @@ cli do (skipGoerliKey {. mode = Verbose execIgnoringExitCode replace(&"""{beaconNodeBinary} --data-dir="{dataDir}" - --dump=true + --dump --web3-url={web3Url} {bootstrapFileOpt} {logLevelOpt}