diff --git a/beacon_chain/el/engine_api_conversions.nim b/beacon_chain/el/engine_api_conversions.nim index 54939f9c8..9bcf6a06a 100644 --- a/beacon_chain/el/engine_api_conversions.nim +++ b/beacon_chain/el/engine_api_conversions.nim @@ -329,7 +329,8 @@ func asConsensusType*(rpcExecutionPayload: ExecutionPayloadV4): withdrawals: List[capella.Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD].init( mapIt(rpcExecutionPayload.withdrawals, it.asConsensusWithdrawal)), 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): electra.ExecutionPayloadForSigning = @@ -609,4 +610,5 @@ func asEngineExecutionPayload*(blockBody: electra.BeaconBlockBody): withdrawalRequests: mapIt( blockBody.execution_requests.withdrawals, it.getWithdrawalRequest), consolidationRequests: mapIt( - blockBody.execution_requests.consolidations, it.getConsolidationRequest)) + blockBody.execution_requests.consolidations, it.getConsolidationRequest), + systemLogsRoot: executionPayload.system_logs_root.asBlockHash) diff --git a/beacon_chain/libnimbus_lc/libnimbus_lc.nim b/beacon_chain/libnimbus_lc/libnimbus_lc.nim index 7ae000dae..c35cff545 100644 --- a/beacon_chain/libnimbus_lc/libnimbus_lc.nim +++ b/beacon_chain/libnimbus_lc/libnimbus_lc.nim @@ -1173,6 +1173,21 @@ func ETHExecutionPayloadHeaderGetExcessBlobGas( ## * Excess blob gas. 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 ETHWithdrawal = object index: uint64 @@ -1261,16 +1276,21 @@ proc ETHExecutionBlockHeaderCreateFromJson( data.withdrawals.isSome or data.withdrawalsRoot.isSome or data.blobGasUsed.isSome or data.excessBlobGas.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.withdrawalsRoot.isNone and ( data.blobGasUsed.isSome or data.excessBlobGas.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.blobGasUsed.isNone and ( 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 if data.withdrawals.isSome != data.withdrawalsRoot.isSome: return nil @@ -1327,6 +1347,11 @@ proc ETHExecutionBlockHeaderCreateFromJson( requestsRoot: if data.requestsRoot.isSome: 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: Opt.none(ExecutionHash256)) if rlpHash(blockHeader) != executionHash[]: diff --git a/beacon_chain/libnimbus_lc/test_libnimbus_lc.c b/beacon_chain/libnimbus_lc/test_libnimbus_lc.c index c9fed9b19..3888d04cc 100644 --- a/beacon_chain/libnimbus_lc/test_libnimbus_lc.c +++ b/beacon_chain/libnimbus_lc/test_libnimbus_lc.c @@ -255,6 +255,11 @@ static void visualizeHeader(const ETHLightClientHeader *header, const ETHConsens int executionExcessBlobGas = ETHExecutionPayloadHeaderGetExcessBlobGas(execution); 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 diff --git a/beacon_chain/spec/datatypes/electra.nim b/beacon_chain/spec/datatypes/electra.nim index 59686feb2..4815c14e3 100644 --- a/beacon_chain/spec/datatypes/electra.nim +++ b/beacon_chain/spec/datatypes/electra.nim @@ -133,6 +133,7 @@ type withdrawals*: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD] blob_gas_used*: uint64 excess_blob_gas*: uint64 + system_logs_root*: Eth2Digest ExecutionPayloadForSigning* = object executionPayload*: ExecutionPayload @@ -162,6 +163,7 @@ type withdrawals_root*: Eth2Digest blob_gas_used*: uint64 excess_blob_gas*: uint64 + system_logs_root*: Eth2Digest ExecutePayload* = proc( execution_payload: ExecutionPayload): bool {.gcsafe, raises: [].} @@ -712,7 +714,8 @@ func shortLog*(v: ExecutionPayload): auto = num_transactions: len(v.transactions), num_withdrawals: len(v.withdrawals), 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*( @@ -839,6 +842,10 @@ func is_valid_light_client_header*( header: LightClientHeader, cfg: RuntimeConfig): bool = 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 header.execution.blob_gas_used != 0 or header.execution.excess_blob_gas != 0: diff --git a/beacon_chain/spec/datatypes/stable.nim b/beacon_chain/spec/datatypes/stable.nim index f8cb5436c..e4ff7ab84 100644 --- a/beacon_chain/spec/datatypes/stable.nim +++ b/beacon_chain/spec/datatypes/stable.nim @@ -147,6 +147,7 @@ type withdrawals*: Opt[List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD]] blob_gas_used*: Opt[uint64] excess_blob_gas*: Opt[uint64] + system_logs_root*: Opt[Eth2Digest] StableExecutionPayloadHeader* {. sszStableContainer: MAX_EXECUTION_PAYLOAD_FIELDS.} = object @@ -171,6 +172,7 @@ type withdrawals_root*: Opt[Eth2Digest] blob_gas_used*: Opt[uint64] excess_blob_gas*: Opt[uint64] + system_logs_root*: Opt[Eth2Digest] StableExecutionRequests* {. sszStableContainer: MAX_EXECUTION_REQUESTS_FIELDS.} = object diff --git a/beacon_chain/spec/forks_light_client.nim b/beacon_chain/spec/forks_light_client.nim index 11caedd9a..8e9000a4b 100644 --- a/beacon_chain/spec/forks_light_client.nim +++ b/beacon_chain/spec/forks_light_client.nim @@ -1231,7 +1231,8 @@ func toElectraLightClientHeader( transactions_root: hash_tree_root(payload.transactions), withdrawals_root: hash_tree_root(payload.withdrawals), 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: blck.message.body.build_proof(EXECUTION_PAYLOAD_GINDEX_ELECTRA).get) diff --git a/beacon_chain/spec/helpers.nim b/beacon_chain/spec/helpers.nim index 1e01c91f6..4a4a316a1 100644 --- a/beacon_chain/spec/helpers.nim +++ b/beacon_chain/spec/helpers.nim @@ -538,6 +538,11 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader = Opt.some blck.body.execution_requests.computeRequestsTrieRoot() else: Opt.none(ExecutionHash256) + systemLogsRoot = + when typeof(payload).kind >= ConsensusFork.Electra: + Opt.some payload.system_logs_root.to(Root) + else: + Opt.none(Root) ExecutionBlockHeader( parentHash : payload.parent_hash.to(Hash32), @@ -560,7 +565,8 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader = blobGasUsed : blobGasUsed, # EIP-4844 excessBlobGas : excessBlobGas, # EIP-4844 parentBeaconBlockRoot : parentBeaconBlockRoot, # EIP-4788 - requestsRoot : requestsRoot) # EIP-7685 + requestsRoot : requestsRoot, # EIP-7685 + systemLogsRoot : systemLogsRoot) # Fusaka-Light proc compute_execution_block_hash*(blck: ForkyBeaconBlock): Eth2Digest = rlpHash(blockToBlockHeader(blck)).to(Eth2Digest) diff --git a/beacon_chain/spec/mev/electra_mev.nim b/beacon_chain/spec/mev/electra_mev.nim index 4b195494c..611084568 100644 --- a/beacon_chain/spec/mev/electra_mev.nim +++ b/beacon_chain/spec/mev/electra_mev.nim @@ -145,7 +145,9 @@ func toSignedBlindedBeaconBlock*(blck: electra.SignedBeaconBlock): withdrawals_root: hash_tree_root(blck.message.body.execution_payload.withdrawals), 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, blob_kzg_commitments: blck.message.body.blob_kzg_commitments, execution_requests: blck.message.body.execution_requests)), diff --git a/beacon_chain/spec/state_transition_block.nim b/beacon_chain/spec/state_transition_block.nim index e809d85d5..0cce6e97d 100644 --- a/beacon_chain/spec/state_transition_block.nim +++ b/beacon_chain/spec/state_transition_block.nim @@ -1040,7 +1040,8 @@ proc process_execution_payload*( transactions_root: hash_tree_root(payload.transactions), withdrawals_root: hash_tree_root(payload.withdrawals), 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() diff --git a/vendor/nim-eth b/vendor/nim-eth index 00c91a1dc..f5017bd2a 160000 --- a/vendor/nim-eth +++ b/vendor/nim-eth @@ -1 +1 @@ -Subproject commit 00c91a1dcaf488046bbc9b9fcbd430934312930f +Subproject commit f5017bd2a2159a94629b2eaeb5aba94d08cab9ce diff --git a/vendor/nim-web3 b/vendor/nim-web3 index 078727472..09fa93245 160000 --- a/vendor/nim-web3 +++ b/vendor/nim-web3 @@ -1 +1 @@ -Subproject commit 078727472f933fe962c759365a3c2cddf626cc7e +Subproject commit 09fa93245333c2702815f57bb15bc65ecbc85d14