2022-01-24 20:15:22 +00:00
|
|
|
# beacon_chain
|
2024-01-06 14:26:56 +00:00
|
|
|
# Copyright (c) 2022-2024 Status Research & Development GmbH
|
2022-01-24 20:15:22 +00:00
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2023-01-20 14:14:37 +00:00
|
|
|
{.push raises: [].}
|
2022-02-27 16:55:02 +00:00
|
|
|
|
2024-01-31 03:18:55 +00:00
|
|
|
import ".."/datatypes/altair
|
|
|
|
from ".."/datatypes/bellatrix import ExecutionPayloadHeader
|
|
|
|
from ".."/eth2_merkleization import hash_tree_root
|
2022-05-08 22:42:21 +00:00
|
|
|
|
2023-08-06 09:20:43 +00:00
|
|
|
type
|
2024-01-31 03:18:55 +00:00
|
|
|
# https://github.com/ethereum/builder-specs/blob/v0.4.0/specs/bellatrix/builder.md#blindedbeaconblockbody
|
|
|
|
BlindedBeaconBlockBody* = object
|
|
|
|
randao_reveal*: ValidatorSig
|
|
|
|
eth1_data*: Eth1Data
|
|
|
|
graffiti*: GraffitiBytes
|
|
|
|
proposer_slashings*: List[ProposerSlashing, Limit MAX_PROPOSER_SLASHINGS]
|
|
|
|
attester_slashings*: List[AttesterSlashing, Limit MAX_ATTESTER_SLASHINGS]
|
|
|
|
attestations*: List[Attestation, Limit MAX_ATTESTATIONS]
|
|
|
|
deposits*: List[Deposit, Limit MAX_DEPOSITS]
|
|
|
|
voluntary_exits*: List[SignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS]
|
|
|
|
sync_aggregate*: SyncAggregate
|
|
|
|
execution_payload_header*: bellatrix.ExecutionPayloadHeader
|
|
|
|
|
|
|
|
# https://github.com/ethereum/builder-specs/blob/v0.4.0/specs/bellatrix/builder.md#blindedbeaconblock
|
2022-05-17 13:56:19 +00:00
|
|
|
BlindedBeaconBlock* = object
|
2024-01-31 03:18:55 +00:00
|
|
|
slot*: Slot
|
|
|
|
proposer_index*: uint64
|
|
|
|
parent_root*: Eth2Digest
|
|
|
|
state_root*: Eth2Digest
|
|
|
|
body*: BlindedBeaconBlockBody
|
|
|
|
|
|
|
|
# https://github.com/ethereum/builder-specs/blob/v0.4.0/specs/bellatrix/builder.md#signedblindedbeaconblock
|
2022-05-17 13:56:19 +00:00
|
|
|
SignedBlindedBeaconBlock* = object
|
2024-01-31 03:18:55 +00:00
|
|
|
message*: BlindedBeaconBlock
|
|
|
|
signature*: ValidatorSig
|
2022-05-17 13:56:19 +00:00
|
|
|
|
2022-08-19 21:51:30 +00:00
|
|
|
func shortLog*(v: BlindedBeaconBlock): auto =
|
|
|
|
(
|
2023-08-06 09:20:43 +00:00
|
|
|
slot: 0'u64,
|
|
|
|
proposer_index: 0'u64,
|
|
|
|
parent_root: "",
|
|
|
|
state_root: "",
|
2023-08-05 05:13:08 +00:00
|
|
|
eth1data: default(Eth1Data),
|
2023-08-08 00:05:17 +00:00
|
|
|
graffiti: "",
|
2023-08-05 05:13:08 +00:00
|
|
|
proposer_slashings_len: 0,
|
|
|
|
attester_slashings_len: 0,
|
|
|
|
attestations_len: 0,
|
|
|
|
deposits_len: 0,
|
|
|
|
voluntary_exits_len: 0,
|
|
|
|
sync_committee_participants: 0,
|
|
|
|
block_number: 0'u64,
|
2023-12-10 00:25:51 +00:00
|
|
|
block_hash: "",
|
|
|
|
parent_hash: "",
|
2023-08-05 05:13:08 +00:00
|
|
|
fee_recipient: "",
|
2023-05-13 04:29:46 +00:00
|
|
|
bls_to_execution_changes_len: 0, # Capella compat
|
2023-05-11 00:36:35 +00:00
|
|
|
blob_kzg_commitments_len: 0, # Deneb compat
|
2022-08-19 21:51:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func shortLog*(v: SignedBlindedBeaconBlock): auto =
|
|
|
|
(
|
2023-08-08 00:05:17 +00:00
|
|
|
blck: shortLog(default(BlindedBeaconBlock)),
|
|
|
|
signature: ""
|
2022-08-19 21:51:30 +00:00
|
|
|
)
|
2024-01-31 03:18:55 +00:00
|
|
|
|
|
|
|
func toSignedBlindedBeaconBlock*(blck: bellatrix.SignedBeaconBlock):
|
|
|
|
SignedBlindedBeaconBlock =
|
|
|
|
SignedBlindedBeaconBlock(
|
|
|
|
message: BlindedBeaconBlock(
|
|
|
|
slot: blck.message.slot,
|
|
|
|
proposer_index: blck.message.proposer_index,
|
|
|
|
parent_root: blck.message.parent_root,
|
|
|
|
state_root: blck.message.state_root,
|
|
|
|
body: BlindedBeaconBlockBody(
|
|
|
|
randao_reveal: blck.message.body.randao_reveal,
|
|
|
|
eth1_data: blck.message.body.eth1_data,
|
|
|
|
graffiti: blck.message.body.graffiti,
|
|
|
|
proposer_slashings: blck.message.body.proposer_slashings,
|
|
|
|
attester_slashings: blck.message.body.attester_slashings,
|
|
|
|
attestations: blck.message.body.attestations,
|
|
|
|
deposits: blck.message.body.deposits,
|
|
|
|
voluntary_exits: blck.message.body.voluntary_exits,
|
|
|
|
sync_aggregate: blck.message.body.sync_aggregate,
|
|
|
|
execution_payload_header: ExecutionPayloadHeader(
|
|
|
|
parent_hash: blck.message.body.execution_payload.parent_hash,
|
|
|
|
fee_recipient: blck.message.body.execution_payload.fee_recipient,
|
|
|
|
state_root: blck.message.body.execution_payload.state_root,
|
|
|
|
receipts_root: blck.message.body.execution_payload.receipts_root,
|
|
|
|
logs_bloom: blck.message.body.execution_payload.logs_bloom,
|
|
|
|
prev_randao: blck.message.body.execution_payload.prev_randao,
|
|
|
|
block_number: blck.message.body.execution_payload.block_number,
|
|
|
|
gas_limit: blck.message.body.execution_payload.gas_limit,
|
|
|
|
gas_used: blck.message.body.execution_payload.gas_used,
|
|
|
|
timestamp: blck.message.body.execution_payload.timestamp,
|
|
|
|
extra_data: blck.message.body.execution_payload.extra_data,
|
|
|
|
base_fee_per_gas:
|
|
|
|
blck.message.body.execution_payload.base_fee_per_gas,
|
|
|
|
block_hash: blck.message.body.execution_payload.block_hash,
|
|
|
|
transactions_root:
|
|
|
|
hash_tree_root(blck.message.body.execution_payload.transactions)))),
|
|
|
|
signature: blck.signature)
|