latest EIP-6493 changes: switch to vector based fees

Consolidate fees in vectors.
This commit is contained in:
Etan Kissling 2024-05-24 00:32:22 +02:00
parent b489adc93e
commit 0c59f31fd1
No known key found for this signature in database
GPG Key ID: B21DA824C5A3D03D
4 changed files with 68 additions and 30 deletions

View File

@ -518,11 +518,21 @@ func asConsensusType*(rpcExecutionPayload: ExecutionPayloadV4):
Opt.some(tt.payload.nonce.get.uint64)
else:
Opt.none(uint64),
max_fee_per_gas:
if tt.payload.maxFeePerGas.isSome:
Opt.some(tt.payload.maxFeePerGas.get)
max_fees_per_gas:
if tt.payload.maxFeesPerGas.isSome:
Opt.some(Eip6493FeesPerGas(
regular:
if tt.payload.maxFeesPerGas.get.regular.isSome:
Opt.some(tt.payload.maxFeesPerGas.get.regular.get)
else:
Opt.none(UInt256),
Opt.none(Uint256),
blob:
if tt.payload.maxFeesPerGas.get.blob.isSome:
Opt.some(tt.payload.maxFeesPerGas.get.blob.get)
else:
Opt.none(Uint256)))
else:
Opt.none(Eip6493FeesPerGas),
gas:
if tt.payload.gas.isSome:
Opt.some(tt.payload.gas.get.uint64)
@ -556,16 +566,21 @@ func asConsensusType*(rpcExecutionPayload: ExecutionPayloadV4):
Eth2Digest(data: distinctBase(it))))))))
else:
Opt.none(List[Eip6493AccessTuple, Limit MAX_ACCESS_LIST_SIZE]),
max_priority_fee_per_gas:
if tt.payload.maxPriorityFeePerGas.isSome:
Opt.some(tt.payload.maxPriorityFeePerGas.get)
max_priority_fees_per_gas:
if tt.payload.maxPriorityFeesPerGas.isSome:
Opt.some(Eip6493FeesPerGas(
regular:
if tt.payload.maxPriorityFeesPerGas.get.regular.isSome:
Opt.some(tt.payload.maxPriorityFeesPerGas.get.regular.get)
else:
Opt.none(UInt256),
max_fee_per_blob_gas:
if tt.payload.maxFeePerBlobGas.isSome:
Opt.some(tt.payload.maxFeePerBlobGas.get)
Opt.none(Uint256),
blob:
if tt.payload.maxPriorityFeesPerGas.get.blob.isSome:
Opt.some(tt.payload.maxPriorityFeesPerGas.get.blob.get)
else:
Opt.none(UInt256),
Opt.none(Uint256)))
else:
Opt.none(Eip6493FeesPerGas),
blob_versioned_hashes:
if tt.payload.blobVersionedHashes.isSome:
Opt.some(
@ -749,11 +764,21 @@ func asEngineExecutionPayload*(executionPayload: electra.ExecutionPayload):
options.some(tt.payload.nonce.get.Quantity)
else:
options.none(Quantity),
maxFeePerGas:
if tt.payload.max_fee_per_gas.isSome:
options.some(tt.payload.max_fee_per_gas.get)
maxFeesPerGas:
if tt.payload.max_fees_per_gas.isSome:
options.some(engine_api_types.TransactionFeesPerGas(
regular:
if tt.payload.max_fees_per_gas.get.regular.isSome:
options.some(tt.payload.max_fees_per_gas.get.regular.get)
else:
options.none(UInt256),
blob:
if tt.payload.max_fees_per_gas.get.blob.isSome:
options.some(tt.payload.max_fees_per_gas.get.blob.get)
else:
options.none(UInt256)))
else:
options.none(engine_api_types.TransactionFeesPerGas),
gas:
if tt.payload.gas.isSome:
options.some(tt.payload.gas.get.Quantity)
@ -783,16 +808,23 @@ func asEngineExecutionPayload*(executionPayload: electra.ExecutionPayload):
.mapIt(FixedBytes[32](it.data)))))
else:
options.none(seq[AccessTuple]),
maxPriorityFeePerGas:
if tt.payload.max_priority_fee_per_gas.isSome:
options.some(tt.payload.max_priority_fee_per_gas.get)
maxPriorityFeesPerGas:
if tt.payload.max_priority_fees_per_gas.isSome:
options.some(engine_api_types.TransactionFeesPerGas(
regular:
if tt.payload.max_priority_fees_per_gas.get.regular.isSome:
options.some(
tt.payload.max_priority_fees_per_gas.get.regular.get)
else:
options.none(UInt256),
maxFeePerBlobGas:
if tt.payload.max_fee_per_blob_gas.isSome:
options.some(tt.payload.max_fee_per_blob_gas.get)
blob:
if tt.payload.max_priority_fees_per_gas.get.blob.isSome:
options.some(
tt.payload.max_priority_fees_per_gas.get.blob.get)
else:
options.none(UInt256),
options.none(UInt256)))
else:
options.none(engine_api_types.TransactionFeesPerGas),
blobVersionedHashes:
if tt.payload.blob_versioned_hashes.isSome:
options.some(distinctBase(tt.payload.blob_versioned_hashes.get)

View File

@ -56,6 +56,12 @@ const
type
ChainId* = uint64
Eip6493FeesPerGas* {.sszStableContainer: 16.} = object
regular*: Opt[UInt256]
# EIP-4844
blob*: Opt[UInt256]
Eip6493AccessTuple* = object
address*: ExecutionAddress
storage_keys*: List[Eth2Digest, Limit MAX_ACCESS_LIST_STORAGE_KEYS]
@ -68,7 +74,7 @@ type
chain_id*: Opt[ChainId]
nonce*: Opt[uint64]
max_fee_per_gas*: Opt[UInt256]
max_fees_per_gas*: Opt[Eip6493FeesPerGas]
gas*: Opt[uint64]
to*: Opt[ExecutionAddress]
value*: Opt[UInt256]
@ -78,10 +84,9 @@ type
access_list*: Opt[List[Eip6493AccessTuple, Limit MAX_ACCESS_LIST_SIZE]]
# EIP-1559
max_priority_fee_per_gas*: Opt[UInt256]
max_priority_fees_per_gas*: Opt[Eip6493FeesPerGas]
# EIP-4844
max_fee_per_blob_gas*: Opt[UInt256]
blob_versioned_hashes*:
Opt[List[deneb.VersionedHash, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK]]

View File

@ -69,6 +69,7 @@ RestJson.useDefaultSerializationFor(
DepositTreeSnapshot,
DistributedKeystoreInfo,
Eip6493AccessTuple,
Eip6493FeesPerGas,
Eip6493Transaction,
Eip6493TransactionPayload,
Eip6493TransactionSignature,

2
vendor/nim-web3 vendored

@ -1 +1 @@
Subproject commit bf5e6aa63357bd6a099d0e2b0b5dc5c8865984d9
Subproject commit 2e4c259d1bc6debc80ceff611e1ff6071af89ea9