|
7 | 7 |
|
8 | 8 | {.push raises: [].}
|
9 | 9 |
|
10 |
| -from ../datatypes/base import Eth1Data |
| 10 | +import ".."/datatypes/altair |
| 11 | +from ".."/datatypes/bellatrix import ExecutionPayloadHeader |
| 12 | +from ".."/eth2_merkleization import hash_tree_root |
11 | 13 |
|
12 | 14 | type
|
| 15 | + # https://github.com/ethereum/builder-specs/blob/v0.4.0/specs/bellatrix/builder.md#blindedbeaconblockbody |
| 16 | + BlindedBeaconBlockBody* = object |
| 17 | + randao_reveal*: ValidatorSig |
| 18 | + eth1_data*: Eth1Data |
| 19 | + graffiti*: GraffitiBytes |
| 20 | + proposer_slashings*: List[ProposerSlashing, Limit MAX_PROPOSER_SLASHINGS] |
| 21 | + attester_slashings*: List[AttesterSlashing, Limit MAX_ATTESTER_SLASHINGS] |
| 22 | + attestations*: List[Attestation, Limit MAX_ATTESTATIONS] |
| 23 | + deposits*: List[Deposit, Limit MAX_DEPOSITS] |
| 24 | + voluntary_exits*: List[SignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS] |
| 25 | + sync_aggregate*: SyncAggregate |
| 26 | + execution_payload_header*: bellatrix.ExecutionPayloadHeader |
| 27 | + |
| 28 | + # https://github.com/ethereum/builder-specs/blob/v0.4.0/specs/bellatrix/builder.md#blindedbeaconblock |
13 | 29 | BlindedBeaconBlock* = object
|
| 30 | + slot*: Slot |
| 31 | + proposer_index*: uint64 |
| 32 | + parent_root*: Eth2Digest |
| 33 | + state_root*: Eth2Digest |
| 34 | + body*: BlindedBeaconBlockBody |
| 35 | + |
| 36 | + # https://github.com/ethereum/builder-specs/blob/v0.4.0/specs/bellatrix/builder.md#signedblindedbeaconblock |
14 | 37 | SignedBlindedBeaconBlock* = object
|
| 38 | + message*: BlindedBeaconBlock |
| 39 | + signature*: ValidatorSig |
15 | 40 |
|
16 | 41 | func shortLog*(v: BlindedBeaconBlock): auto =
|
17 | 42 | (
|
@@ -40,3 +65,40 @@ func shortLog*(v: SignedBlindedBeaconBlock): auto =
|
40 | 65 | blck: shortLog(default(BlindedBeaconBlock)),
|
41 | 66 | signature: ""
|
42 | 67 | )
|
| 68 | + |
| 69 | +func toSignedBlindedBeaconBlock*(blck: bellatrix.SignedBeaconBlock): |
| 70 | + SignedBlindedBeaconBlock = |
| 71 | + SignedBlindedBeaconBlock( |
| 72 | + message: BlindedBeaconBlock( |
| 73 | + slot: blck.message.slot, |
| 74 | + proposer_index: blck.message.proposer_index, |
| 75 | + parent_root: blck.message.parent_root, |
| 76 | + state_root: blck.message.state_root, |
| 77 | + body: BlindedBeaconBlockBody( |
| 78 | + randao_reveal: blck.message.body.randao_reveal, |
| 79 | + eth1_data: blck.message.body.eth1_data, |
| 80 | + graffiti: blck.message.body.graffiti, |
| 81 | + proposer_slashings: blck.message.body.proposer_slashings, |
| 82 | + attester_slashings: blck.message.body.attester_slashings, |
| 83 | + attestations: blck.message.body.attestations, |
| 84 | + deposits: blck.message.body.deposits, |
| 85 | + voluntary_exits: blck.message.body.voluntary_exits, |
| 86 | + sync_aggregate: blck.message.body.sync_aggregate, |
| 87 | + execution_payload_header: ExecutionPayloadHeader( |
| 88 | + parent_hash: blck.message.body.execution_payload.parent_hash, |
| 89 | + fee_recipient: blck.message.body.execution_payload.fee_recipient, |
| 90 | + state_root: blck.message.body.execution_payload.state_root, |
| 91 | + receipts_root: blck.message.body.execution_payload.receipts_root, |
| 92 | + logs_bloom: blck.message.body.execution_payload.logs_bloom, |
| 93 | + prev_randao: blck.message.body.execution_payload.prev_randao, |
| 94 | + block_number: blck.message.body.execution_payload.block_number, |
| 95 | + gas_limit: blck.message.body.execution_payload.gas_limit, |
| 96 | + gas_used: blck.message.body.execution_payload.gas_used, |
| 97 | + timestamp: blck.message.body.execution_payload.timestamp, |
| 98 | + extra_data: blck.message.body.execution_payload.extra_data, |
| 99 | + base_fee_per_gas: |
| 100 | + blck.message.body.execution_payload.base_fee_per_gas, |
| 101 | + block_hash: blck.message.body.execution_payload.block_hash, |
| 102 | + transactions_root: |
| 103 | + hash_tree_root(blck.message.body.execution_payload.transactions)))), |
| 104 | + signature: blck.signature) |
0 commit comments