Add `systemLogsRoot`
This commit is contained in:
parent
97deb2339d
commit
c0d15c54de
|
@ -329,7 +329,8 @@ func asConsensusType*(rpcExecutionPayload: ExecutionPayloadV4):
|
||||||
withdrawals: List[capella.Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD].init(
|
withdrawals: List[capella.Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD].init(
|
||||||
mapIt(rpcExecutionPayload.withdrawals, it.asConsensusWithdrawal)),
|
mapIt(rpcExecutionPayload.withdrawals, it.asConsensusWithdrawal)),
|
||||||
blob_gas_used: rpcExecutionPayload.blobGasUsed.uint64,
|
blob_gas_used: rpcExecutionPayload.blobGasUsed.uint64,
|
||||||
excess_blob_gas: rpcExecutionPayload.excessBlobGas.uint64)
|
excess_blob_gas: rpcExecutionPayload.excessBlobGas.uint64,
|
||||||
|
system_logs_root: rpcExecutionPayload.systemLogsRoot.asEth2Digest)
|
||||||
|
|
||||||
func asConsensusType*(payload: engine_api.GetPayloadV4Response):
|
func asConsensusType*(payload: engine_api.GetPayloadV4Response):
|
||||||
electra.ExecutionPayloadForSigning =
|
electra.ExecutionPayloadForSigning =
|
||||||
|
@ -609,4 +610,5 @@ func asEngineExecutionPayload*(blockBody: electra.BeaconBlockBody):
|
||||||
withdrawalRequests: mapIt(
|
withdrawalRequests: mapIt(
|
||||||
blockBody.execution_requests.withdrawals, it.getWithdrawalRequest),
|
blockBody.execution_requests.withdrawals, it.getWithdrawalRequest),
|
||||||
consolidationRequests: mapIt(
|
consolidationRequests: mapIt(
|
||||||
blockBody.execution_requests.consolidations, it.getConsolidationRequest))
|
blockBody.execution_requests.consolidations, it.getConsolidationRequest),
|
||||||
|
systemLogsRoot: executionPayload.system_logs_root.asBlockHash)
|
||||||
|
|
|
@ -1173,6 +1173,21 @@ func ETHExecutionPayloadHeaderGetExcessBlobGas(
|
||||||
## * Excess blob gas.
|
## * Excess blob gas.
|
||||||
execution[].excess_blob_gas.cint
|
execution[].excess_blob_gas.cint
|
||||||
|
|
||||||
|
func ETHExecutionPayloadHeaderGetSystemLogsRoot(
|
||||||
|
execution: ptr ExecutionPayloadHeader): ptr Eth2Digest {.exported.} =
|
||||||
|
## Obtains the system logs root of a given execution payload header.
|
||||||
|
##
|
||||||
|
## * The returned value is allocated in the given execution payload header.
|
||||||
|
## It must neither be released nor written to, and the execution payload
|
||||||
|
## header must not be released while the returned value is in use.
|
||||||
|
##
|
||||||
|
## Parameters:
|
||||||
|
## * `execution` - Execution payload header.
|
||||||
|
##
|
||||||
|
## Returns:
|
||||||
|
## * Execution system logs root.
|
||||||
|
addr execution[].system_logs_root
|
||||||
|
|
||||||
type
|
type
|
||||||
ETHWithdrawal = object
|
ETHWithdrawal = object
|
||||||
index: uint64
|
index: uint64
|
||||||
|
@ -1261,16 +1276,21 @@ proc ETHExecutionBlockHeaderCreateFromJson(
|
||||||
data.withdrawals.isSome or data.withdrawalsRoot.isSome or
|
data.withdrawals.isSome or data.withdrawalsRoot.isSome or
|
||||||
data.blobGasUsed.isSome or data.excessBlobGas.isSome or
|
data.blobGasUsed.isSome or data.excessBlobGas.isSome or
|
||||||
data.depositRequests.isSome or data.withdrawalRequests.isSome or
|
data.depositRequests.isSome or data.withdrawalRequests.isSome or
|
||||||
data.consolidationRequests.isSome or data.requestsRoot.isSome):
|
data.consolidationRequests.isSome or data.requestsRoot.isSome or
|
||||||
|
data.systemLogsRoot.isSome):
|
||||||
return nil
|
return nil
|
||||||
if data.withdrawalsRoot.isNone and (
|
if data.withdrawalsRoot.isNone and (
|
||||||
data.blobGasUsed.isSome or data.excessBlobGas.isSome or
|
data.blobGasUsed.isSome or data.excessBlobGas.isSome or
|
||||||
data.depositRequests.isSome or data.withdrawalRequests.isSome or
|
data.depositRequests.isSome or data.withdrawalRequests.isSome or
|
||||||
data.consolidationRequests.isSome or data.requestsRoot.isSome):
|
data.consolidationRequests.isSome or data.requestsRoot.isSome or
|
||||||
|
data.systemLogsRoot.isSome):
|
||||||
return nil
|
return nil
|
||||||
if data.blobGasUsed.isNone and (
|
if data.blobGasUsed.isNone and (
|
||||||
data.depositRequests.isSome or data.withdrawalRequests.isSome or
|
data.depositRequests.isSome or data.withdrawalRequests.isSome or
|
||||||
data.consolidationRequests.isSome or data.requestsRoot.isSome):
|
data.consolidationRequests.isSome or data.requestsRoot.isSome or
|
||||||
|
data.systemLogsRoot.isSome):
|
||||||
|
return nil
|
||||||
|
if data.depositRequests.isNone and data.systemLogsRoot.isSome:
|
||||||
return nil
|
return nil
|
||||||
if data.withdrawals.isSome != data.withdrawalsRoot.isSome:
|
if data.withdrawals.isSome != data.withdrawalsRoot.isSome:
|
||||||
return nil
|
return nil
|
||||||
|
@ -1327,6 +1347,11 @@ proc ETHExecutionBlockHeaderCreateFromJson(
|
||||||
requestsRoot:
|
requestsRoot:
|
||||||
if data.requestsRoot.isSome:
|
if data.requestsRoot.isSome:
|
||||||
Opt.some(data.requestsRoot.get.asEth2Digest.to(Hash32))
|
Opt.some(data.requestsRoot.get.asEth2Digest.to(Hash32))
|
||||||
|
else:
|
||||||
|
Opt.none(ExecutionHash256),
|
||||||
|
systemLogsRoot:
|
||||||
|
if data.systemLogsRoot.isSome:
|
||||||
|
Opt.some(data.systemLogsRoot.get.asEth2Digest.to(Hash32))
|
||||||
else:
|
else:
|
||||||
Opt.none(ExecutionHash256))
|
Opt.none(ExecutionHash256))
|
||||||
if rlpHash(blockHeader) != executionHash[]:
|
if rlpHash(blockHeader) != executionHash[]:
|
||||||
|
|
|
@ -255,6 +255,11 @@ static void visualizeHeader(const ETHLightClientHeader *header, const ETHConsens
|
||||||
|
|
||||||
int executionExcessBlobGas = ETHExecutionPayloadHeaderGetExcessBlobGas(execution);
|
int executionExcessBlobGas = ETHExecutionPayloadHeaderGetExcessBlobGas(execution);
|
||||||
printf(" - excess_blob_gas: %d\n", executionExcessBlobGas);
|
printf(" - excess_blob_gas: %d\n", executionExcessBlobGas);
|
||||||
|
|
||||||
|
const ETHRoot *executionSystemLogsRoot = ETHExecutionPayloadHeaderGetSystemLogsRoot(execution);
|
||||||
|
printf(" - system_logs_root: ");
|
||||||
|
printHexString(executionSystemLogsRoot, sizeof *executionSystemLogsRoot);
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
ETH_RESULT_USE_CHECK
|
ETH_RESULT_USE_CHECK
|
||||||
|
|
|
@ -133,6 +133,7 @@ type
|
||||||
withdrawals*: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD]
|
withdrawals*: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD]
|
||||||
blob_gas_used*: uint64
|
blob_gas_used*: uint64
|
||||||
excess_blob_gas*: uint64
|
excess_blob_gas*: uint64
|
||||||
|
system_logs_root*: Eth2Digest
|
||||||
|
|
||||||
ExecutionPayloadForSigning* = object
|
ExecutionPayloadForSigning* = object
|
||||||
executionPayload*: ExecutionPayload
|
executionPayload*: ExecutionPayload
|
||||||
|
@ -162,6 +163,7 @@ type
|
||||||
withdrawals_root*: Eth2Digest
|
withdrawals_root*: Eth2Digest
|
||||||
blob_gas_used*: uint64
|
blob_gas_used*: uint64
|
||||||
excess_blob_gas*: uint64
|
excess_blob_gas*: uint64
|
||||||
|
system_logs_root*: Eth2Digest
|
||||||
|
|
||||||
ExecutePayload* = proc(
|
ExecutePayload* = proc(
|
||||||
execution_payload: ExecutionPayload): bool {.gcsafe, raises: [].}
|
execution_payload: ExecutionPayload): bool {.gcsafe, raises: [].}
|
||||||
|
@ -712,7 +714,8 @@ func shortLog*(v: ExecutionPayload): auto =
|
||||||
num_transactions: len(v.transactions),
|
num_transactions: len(v.transactions),
|
||||||
num_withdrawals: len(v.withdrawals),
|
num_withdrawals: len(v.withdrawals),
|
||||||
blob_gas_used: $(v.blob_gas_used),
|
blob_gas_used: $(v.blob_gas_used),
|
||||||
excess_blob_gas: $(v.excess_blob_gas)
|
excess_blob_gas: $(v.excess_blob_gas),
|
||||||
|
system_logs_root: $(v.system_logs_root)
|
||||||
)
|
)
|
||||||
|
|
||||||
func kzg_commitment_inclusion_proof_gindex*(
|
func kzg_commitment_inclusion_proof_gindex*(
|
||||||
|
@ -839,6 +842,10 @@ func is_valid_light_client_header*(
|
||||||
header: LightClientHeader, cfg: RuntimeConfig): bool =
|
header: LightClientHeader, cfg: RuntimeConfig): bool =
|
||||||
let epoch = header.beacon.slot.epoch
|
let epoch = header.beacon.slot.epoch
|
||||||
|
|
||||||
|
if epoch < cfg.ELECTRA_FORK_EPOCH:
|
||||||
|
if not header.execution.system_logs_root.isZero:
|
||||||
|
return false
|
||||||
|
|
||||||
if epoch < cfg.DENEB_FORK_EPOCH:
|
if epoch < cfg.DENEB_FORK_EPOCH:
|
||||||
if header.execution.blob_gas_used != 0 or
|
if header.execution.blob_gas_used != 0 or
|
||||||
header.execution.excess_blob_gas != 0:
|
header.execution.excess_blob_gas != 0:
|
||||||
|
|
|
@ -147,6 +147,7 @@ type
|
||||||
withdrawals*: Opt[List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD]]
|
withdrawals*: Opt[List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD]]
|
||||||
blob_gas_used*: Opt[uint64]
|
blob_gas_used*: Opt[uint64]
|
||||||
excess_blob_gas*: Opt[uint64]
|
excess_blob_gas*: Opt[uint64]
|
||||||
|
system_logs_root*: Opt[Eth2Digest]
|
||||||
|
|
||||||
StableExecutionPayloadHeader* {.
|
StableExecutionPayloadHeader* {.
|
||||||
sszStableContainer: MAX_EXECUTION_PAYLOAD_FIELDS.} = object
|
sszStableContainer: MAX_EXECUTION_PAYLOAD_FIELDS.} = object
|
||||||
|
@ -171,6 +172,7 @@ type
|
||||||
withdrawals_root*: Opt[Eth2Digest]
|
withdrawals_root*: Opt[Eth2Digest]
|
||||||
blob_gas_used*: Opt[uint64]
|
blob_gas_used*: Opt[uint64]
|
||||||
excess_blob_gas*: Opt[uint64]
|
excess_blob_gas*: Opt[uint64]
|
||||||
|
system_logs_root*: Opt[Eth2Digest]
|
||||||
|
|
||||||
StableExecutionRequests* {.
|
StableExecutionRequests* {.
|
||||||
sszStableContainer: MAX_EXECUTION_REQUESTS_FIELDS.} = object
|
sszStableContainer: MAX_EXECUTION_REQUESTS_FIELDS.} = object
|
||||||
|
|
|
@ -1231,7 +1231,8 @@ func toElectraLightClientHeader(
|
||||||
transactions_root: hash_tree_root(payload.transactions),
|
transactions_root: hash_tree_root(payload.transactions),
|
||||||
withdrawals_root: hash_tree_root(payload.withdrawals),
|
withdrawals_root: hash_tree_root(payload.withdrawals),
|
||||||
blob_gas_used: payload.blob_gas_used,
|
blob_gas_used: payload.blob_gas_used,
|
||||||
excess_blob_gas: payload.excess_blob_gas),
|
excess_blob_gas: payload.excess_blob_gas,
|
||||||
|
system_logs_root: payload.system_logs_root),
|
||||||
execution_branch:
|
execution_branch:
|
||||||
blck.message.body.build_proof(EXECUTION_PAYLOAD_GINDEX_ELECTRA).get)
|
blck.message.body.build_proof(EXECUTION_PAYLOAD_GINDEX_ELECTRA).get)
|
||||||
|
|
||||||
|
|
|
@ -538,6 +538,11 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader =
|
||||||
Opt.some blck.body.execution_requests.computeRequestsTrieRoot()
|
Opt.some blck.body.execution_requests.computeRequestsTrieRoot()
|
||||||
else:
|
else:
|
||||||
Opt.none(ExecutionHash256)
|
Opt.none(ExecutionHash256)
|
||||||
|
systemLogsRoot =
|
||||||
|
when typeof(payload).kind >= ConsensusFork.Electra:
|
||||||
|
Opt.some payload.system_logs_root.to(Root)
|
||||||
|
else:
|
||||||
|
Opt.none(Root)
|
||||||
|
|
||||||
ExecutionBlockHeader(
|
ExecutionBlockHeader(
|
||||||
parentHash : payload.parent_hash.to(Hash32),
|
parentHash : payload.parent_hash.to(Hash32),
|
||||||
|
@ -560,7 +565,8 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader =
|
||||||
blobGasUsed : blobGasUsed, # EIP-4844
|
blobGasUsed : blobGasUsed, # EIP-4844
|
||||||
excessBlobGas : excessBlobGas, # EIP-4844
|
excessBlobGas : excessBlobGas, # EIP-4844
|
||||||
parentBeaconBlockRoot : parentBeaconBlockRoot, # EIP-4788
|
parentBeaconBlockRoot : parentBeaconBlockRoot, # EIP-4788
|
||||||
requestsRoot : requestsRoot) # EIP-7685
|
requestsRoot : requestsRoot, # EIP-7685
|
||||||
|
systemLogsRoot : systemLogsRoot) # Fusaka-Light
|
||||||
|
|
||||||
proc compute_execution_block_hash*(blck: ForkyBeaconBlock): Eth2Digest =
|
proc compute_execution_block_hash*(blck: ForkyBeaconBlock): Eth2Digest =
|
||||||
rlpHash(blockToBlockHeader(blck)).to(Eth2Digest)
|
rlpHash(blockToBlockHeader(blck)).to(Eth2Digest)
|
||||||
|
|
|
@ -145,7 +145,9 @@ func toSignedBlindedBeaconBlock*(blck: electra.SignedBeaconBlock):
|
||||||
withdrawals_root:
|
withdrawals_root:
|
||||||
hash_tree_root(blck.message.body.execution_payload.withdrawals),
|
hash_tree_root(blck.message.body.execution_payload.withdrawals),
|
||||||
blob_gas_used: blck.message.body.execution_payload.blob_gas_used,
|
blob_gas_used: blck.message.body.execution_payload.blob_gas_used,
|
||||||
excess_blob_gas: blck.message.body.execution_payload.excess_blob_gas),
|
excess_blob_gas: blck.message.body.execution_payload.excess_blob_gas,
|
||||||
|
system_logs_root:
|
||||||
|
blck.message.body.execution_payload.system_logs_root),
|
||||||
bls_to_execution_changes: blck.message.body.bls_to_execution_changes,
|
bls_to_execution_changes: blck.message.body.bls_to_execution_changes,
|
||||||
blob_kzg_commitments: blck.message.body.blob_kzg_commitments,
|
blob_kzg_commitments: blck.message.body.blob_kzg_commitments,
|
||||||
execution_requests: blck.message.body.execution_requests)),
|
execution_requests: blck.message.body.execution_requests)),
|
||||||
|
|
|
@ -1040,7 +1040,8 @@ proc process_execution_payload*(
|
||||||
transactions_root: hash_tree_root(payload.transactions),
|
transactions_root: hash_tree_root(payload.transactions),
|
||||||
withdrawals_root: hash_tree_root(payload.withdrawals),
|
withdrawals_root: hash_tree_root(payload.withdrawals),
|
||||||
blob_gas_used: payload.blob_gas_used,
|
blob_gas_used: payload.blob_gas_used,
|
||||||
excess_blob_gas: payload.excess_blob_gas)
|
excess_blob_gas: payload.excess_blob_gas,
|
||||||
|
system_logs_root: payload.system_logs_root)
|
||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 00c91a1dcaf488046bbc9b9fcbd430934312930f
|
Subproject commit f5017bd2a2159a94629b2eaeb5aba94d08cab9ce
|
|
@ -1 +1 @@
|
||||||
Subproject commit 078727472f933fe962c759365a3c2cddf626cc7e
|
Subproject commit 09fa93245333c2702815f57bb15bc65ecbc85d14
|
Loading…
Reference in New Issue