Bump nim-eth and adjust API to support binding to specific address (#994)

- Fixes also a bug which would not start an EthereumNode properly
when no bootstrap nodes are provided
This commit is contained in:
Kim De Mey 2022-03-16 09:01:35 +01:00 committed by GitHub
parent 534fb528a4
commit b00ac490a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 18 deletions

View File

@ -103,10 +103,15 @@ proc setupP2P(nimbus: NimbusNode, conf: NimbusConf,
if extPorts.isSome:
(address.tcpPort, address.udpPort) = extPorts.get()
nimbus.ethNode = newEthereumNode(keypair, address, conf.networkId,
nil, conf.agentString,
addAllCapabilities = false,
minPeers = conf.maxPeers)
let bootstrapNodes = conf.getBootNodes()
nimbus.ethNode = newEthereumNode(
keypair, address, conf.networkId, nil, conf.agentString,
addAllCapabilities = false, minPeers = conf.maxPeers,
bootstrapNodes = bootstrapNodes,
bindUdpPort = conf.udpPort, bindTcpPort = conf.tcpPort,
bindIp = conf.listenAddress)
# Add protocol capabilities based on protocol flags
if ProtocolFlag.Eth in protocols:
nimbus.ethNode.addCapability eth
@ -126,11 +131,9 @@ proc setupP2P(nimbus: NimbusNode, conf: NimbusConf,
for enode in staticPeers:
asyncCheck nimbus.ethNode.peerPool.connectToNode(newNode(enode))
# Connect via discovery
let bootNodes = conf.getBootNodes()
if bootNodes.len > 0:
waitFor nimbus.ethNode.connectToNetwork(bootNodes,
enableDiscovery = conf.discovery != DiscoveryType.None)
# Start Eth node
waitFor nimbus.ethNode.connectToNetwork(
enableDiscovery = conf.discovery != DiscoveryType.None)
proc localServices(nimbus: NimbusNode, conf: NimbusConf,
chainDB: BaseChainDB, protocols: set[ProtocolFlag]) =

View File

@ -275,19 +275,24 @@ proc getFixtureTransaction*(j: JsonNode, dataIndex, gasIndex, valueIndex: int):
proc hashLogEntries*(logs: seq[Log]): string =
toLowerAscii("0x" & $keccakHash(rlp.encode(logs)))
proc setupEthNode*(conf: NimbusConf, ctx: EthContext, capabilities: varargs[ProtocolInfo, `protocolInfo`]): EthereumNode =
proc setupEthNode*(
conf: NimbusConf, ctx: EthContext,
capabilities: varargs[ProtocolInfo, `protocolInfo`]): EthereumNode =
let keypair = ctx.hexToKeyPair(conf.nodeKeyHex).tryGet()
var srvAddress: Address
srvAddress.ip = conf.listenAddress
srvAddress.tcpPort = conf.tcpPort
srvAddress.udpPort = conf.udpPort
result = newEthereumNode(
let srvAddress = Address(
ip: conf.listenAddress, tcpPort: conf.tcpPort, udpPort: conf.udpPort)
var node = newEthereumNode(
keypair, srvAddress,
conf.networkId,
nil, conf.agentString,
addAllCapabilities = false)
addAllCapabilities = false,
bindUdpPort = conf.udpPort, bindTcpPort = conf.tcpPort)
for capability in capabilities:
result.addCapability capability
node.addCapability capability
node
proc makeTestConfig*(): NimbusConf =
# commandLineParams() will not works inside all_tests

2
vendor/nim-eth vendored

@ -1 +1 @@
Subproject commit dff9040cc164d0ae0c2cb108b33dd81d010fb245
Subproject commit e62fdfe6f1c8cbef48768a4d12fb2929518649d8