Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add/change Deneb fields per https://github.com/ethereum/execution-apis/pull/417 #616

Merged
merged 1 commit into from
Jun 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion eth/common/eth_types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ type
address* : EthAddress
amount* : uint64

# https://eips.ethereum.org/EIPS/eip-4844#header-extension
BlockHeader* = object
parentHash*: Hash256
ommersHash*: Hash256
Expand All @@ -118,7 +119,8 @@ type
# `baseFee` is the get/set of `fee`
fee*: Option[UInt256] # EIP-1559
withdrawalsRoot*: Option[Hash256] # EIP-4895
excessDataGas*: Option[UInt256] # EIP-4844
dataGasUsed*: Option[uint64] # EIP-4844
excessDataGas*: Option[uint64] # EIP-4844

BlockBody* = object
transactions*: seq[Transaction]
Expand Down
2 changes: 1 addition & 1 deletion eth/p2p/discovery.nim
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ proc recoverMsgPublicKey(msg: openArray[byte]): DiscResult[PublicKey] =

proc unpack(msg: openArray[byte]): tuple[cmdId: CommandId, payload: seq[byte]]
{.raises: [DiscProtocolError].} =
# Check against possible RangeError
# Check against possible RangeDefect
if msg[HEAD_SIZE].int < CommandId.low.ord or
msg[HEAD_SIZE].int > CommandId.high.ord:
raise newException(DiscProtocolError, "Unsupported packet id")
Expand Down
2 changes: 1 addition & 1 deletion eth/trie/nibbles.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ proc initNibbleRange*(bytes: openArray[byte]): NibblesSeq =
proc `{}`(r: NibblesSeq, pos: int): byte {.inline.} =
## This is a helper for a more raw access to the nibbles.
## It works with absolute positions.
if pos > r.iend: raise newException(RangeError, "index out of range")
if pos > r.iend: raise newException(RangeDefect, "index out of range")
return if (pos and 1) != 0: (r.bytes[pos div 2] and 0xf)
else: (r.bytes[pos div 2] shr 4)

Expand Down
3 changes: 2 additions & 1 deletion tests/rlp/test_common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ proc suite2() =
doTest h

# EIP-4844
h.excessDataGas = some 1234.u256
h.dataGasUsed = some 1234'u64
h.excessDataGas = some 1234'u64
doTest h

suite1()
Expand Down
15 changes: 10 additions & 5 deletions tests/rlp/test_rlp_codec.nim
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,25 @@ suite "BlockHeader roundtrip test":
test "Header + none(baseFee) + some(withdrawalsRoot) + some(excessDataGas)":
let h = BlockHeader(
withdrawalsRoot: some(Hash256()),
excessDataGas: some(1.u256)
dataGasUsed: some(1'u64),
excessDataGas: some(1'u64)
)
expect AssertionDefect:
roundTrip(h)

test "Header + none(baseFee) + none(withdrawalsRoot) + some(excessDataGas)":
let h = BlockHeader(
excessDataGas: some(1.u256)
dataGasUsed: some(1'u64),
excessDataGas: some(1'u64)
)
expect AssertionDefect:
roundTrip(h)

test "Header + some(baseFee) + none(withdrawalsRoot) + some(excessDataGas)":
let h = BlockHeader(
fee: some(2.u256),
excessDataGas: some(1.u256)
dataGasUsed: some(1'u64),
excessDataGas: some(1'u64)
)
expect AssertionDefect:
roundTrip(h)
Expand All @@ -95,7 +98,8 @@ suite "BlockHeader roundtrip test":
let h = BlockHeader(
fee: some(2.u256),
withdrawalsRoot: some(Hash256()),
excessDataGas: some(1.u256)
dataGasUsed: some(1'u64),
excessDataGas: some(1'u64)
)
roundTrip(h)

Expand Down Expand Up @@ -173,7 +177,8 @@ type
nonce*: BlockNonce
fee*: Opt[UInt256]
withdrawalsRoot*: Opt[Hash256]
excessDataGas*: Opt[UInt256]
dataGasUsed*: Opt[GasInt]
excessDataGas*: Opt[GasInt]

BlockBodyOpt* = object
transactions*: seq[Transaction]
Expand Down