Fix eth66 and eth67 handshake (#1214)

* bump nim-eth

* fix eth66 and eth67 handshake
This commit is contained in:
andri lim 2022-09-06 04:37:58 +07:00 committed by GitHub
parent d6322aab22
commit ad4e25b27e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 8 deletions

View File

@ -67,9 +67,10 @@ method getAncestorHeader*(c: Chain, h: BlockHeader, output: var BlockHeader,
result = c.db.getBlockHeader(h.blockNumber - offset, output)
method getBlockBody*(c: Chain, blockHash: KeccakHash): BlockBodyRef =
## Always `nil`
result = nil
method getBlockBody*(c: Chain, blockHash: KeccakHash): BlockBodyRef {.gcsafe, raises: [Defect,RlpError].} =
result = BlockBodyRef()
if not c.db.getBlockBody(blockHash, result[]):
result = nil
method getForkId*(c: Chain, n: BlockNumber): ForkID {.gcsafe.} =
@ -77,6 +78,10 @@ method getForkId*(c: Chain, n: BlockNumber): ForkID {.gcsafe.} =
let fork = c.db.config.toChainFork(n)
c.forkIds[fork]
method getTotalDifficulty*(c: Chain): DifficultyInt {.gcsafe, raises: [Defect,RlpError].} =
c.db.headTotalDifficulty()
# ------------------------------------------------------------------------------
# End
# ------------------------------------------------------------------------------

View File

@ -131,13 +131,14 @@ p2pProtocol eth66(version = ethVersion,
network = peer.network
chain = network.chain
bestBlock = chain.getBestBlockHeader
totalDifficulty = chain.getTotalDifficulty
chainForkId = chain.getForkId(bestBlock.blockNumber)
forkId = ForkId(
forkHash: chainForkId.crc.toBytesBE,
forkNext: chainForkId.nextFork.toBlockNumber)
trace trEthSendSending & "Status (0x00)", peer,
td=bestBlock.difficulty,
td=totalDifficulty,
bestHash=bestBlock.blockHash.toHex,
networkId=network.networkId,
genesis=chain.genesisHash.toHex,
@ -145,7 +146,7 @@ p2pProtocol eth66(version = ethVersion,
let m = await peer.status(ethVersion,
network.networkId,
bestBlock.difficulty,
totalDifficulty,
bestBlock.blockHash,
chain.genesisHash,
forkId,

View File

@ -91,13 +91,14 @@ p2pProtocol eth67(version = ethVersion,
network = peer.network
chain = network.chain
bestBlock = chain.getBestBlockHeader
totalDifficulty = chain.getTotalDifficulty
chainForkId = chain.getForkId(bestBlock.blockNumber)
forkId = ForkId(
forkHash: chainForkId.crc.toBytesBE,
forkNext: chainForkId.nextFork.toBlockNumber)
trace trEthSendSending & "Status (0x00)", peer,
td=bestBlock.difficulty,
td=totalDifficulty,
bestHash=bestBlock.blockHash.toHex,
networkId=network.networkId,
genesis=chain.genesisHash.toHex,
@ -105,7 +106,7 @@ p2pProtocol eth67(version = ethVersion,
let m = await peer.status(ethVersion,
network.networkId,
bestBlock.difficulty,
totalDifficulty,
bestBlock.blockHash,
chain.genesisHash,
forkId,

2
vendor/nim-eth vendored

@ -1 +1 @@
Subproject commit d31abca0104528dbca040e9fc1984edd280003c0
Subproject commit 2186d671636c19233064b6124335105a67853082