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

View File

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

View File

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

2
vendor/nim-web3 vendored

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