bump `nim-eth` for `eip4844` support

The `BlockHeader` structure in `nim-eth` was updated with support for
EIP-4844 (danksharding). To enable the `nim-eth` bump, the ingress of
`BlockHeader` structures has been hardened to reject headers that have
the new `excessDataGas` field until proper EIP4844 support exists.
https://github.com/status-im/nim-eth/pull/570
This commit is contained in:
Etan Kissling 2022-12-13 21:06:26 +01:00 committed by zah
parent c962bafd5a
commit 22338b7870
7 changed files with 41 additions and 5 deletions

View File

@ -132,6 +132,9 @@ func validateBlockHeaderBytes*(
let header = ? decodeRlp(bytes, BlockHeader)
if header.excessDataGas.isSome:
return err("EIP-4844 not yet implemented")
if header.withdrawalsRoot.isSome:
return err("Withdrawals not yet implemented")

21
nimbus/core/eip4844.nim Normal file
View File

@ -0,0 +1,21 @@
# Nimbus
# Copyright (c) 2022 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
# http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.
import
stew/results,
../common/common
# https://eips.ethereum.org/EIPS/eip-4844
func validateEip4844Header*(
com: CommonRef, header: BlockHeader
): Result[void, string] {.raises: [Defect].} =
if header.excessDataGas.isSome:
return err("EIP-4844 not yet implemented")
return ok()

View File

@ -13,7 +13,7 @@ import
../db/accounts_cache,
".."/[transaction, common/common],
".."/[vm_state, vm_types, errors],
"."/[dao, gaslimit, withdrawals],
"."/[dao, eip4844, gaslimit, withdrawals],
./pow/[difficulty, header],
./pow,
chronicles,
@ -129,7 +129,10 @@ proc validateHeader(com: CommonRef; header, parentHeader: BlockHeader;
if checkSealOK:
return pow.validateSeal(header)
com.validateWithdrawals(header)
? com.validateWithdrawals(header)
? com.validateEip4844Header(header)
ok()
func validateUncle(currBlock, uncle, uncleParent: BlockHeader):
Result[void,string] =

View File

@ -17,7 +17,7 @@ import
eth/p2p/[private/p2p_types, peer_pool],
stew/byteutils,
"."/[protocol, types],
../core/[chain, clique/clique_sealer, gaslimit, withdrawals],
../core/[chain, clique/clique_sealer, eip4844, gaslimit, withdrawals],
../core/pow/difficulty,
../constants,
../utils/utils,
@ -239,6 +239,12 @@ proc validateHeader(ctx: LegacySyncRef, header: BlockHeader,
msg=res.error
return false
res = com.validateEip4844Header(header)
if res.isErr:
trace "validate eip4844 error",
msg=res.error
return false
return true
# ------------------------------------------------------------------------------

View File

@ -49,6 +49,8 @@ proc debug*(h: BlockHeader): string =
result.add "fee : " & $h.fee.get() & "\n"
if h.withdrawalsRoot.isSome:
result.add "withdrawalsRoot: " & $h.withdrawalsRoot.get() & "\n"
if h.excessDataGas.isSome:
result.add "excessDataGas: " & $h.excessDataGas.get() & "\n"
result.add "blockHash : " & $blockHash(h) & "\n"
proc dumpAccount(stateDB: AccountsCache, address: EthAddress): JsonNode =

View File

@ -55,7 +55,8 @@ proc pp*(h: BlockHeader; sep = " "): string =
&"receiptRoot={h.receiptRoot.pp}{sep}" &
&"stateRoot={h.stateRoot.pp}{sep}" &
&"baseFee={h.baseFee}{sep}" &
&"withdrawalsRoot={h.withdrawalsRoot.get(EMPTY_ROOT_HASH)}"
&"withdrawalsRoot={h.withdrawalsRoot.get(EMPTY_ROOT_HASH)}{sep}" &
&"excessDataGas={h.excessDataGas.get(GasInt(0))}"
proc pp*(g: Genesis; sep = " "): string =
"" &

2
vendor/nim-eth vendored

@ -1 +1 @@
Subproject commit 22d0ac81e1495960e61df65d80d8a9c6f31d0726
Subproject commit 2b5f2a27e303b13127bb525b0c7a309eaa7fbed9