2022-01-24 20:15:22 +00:00
|
|
|
# beacon_chain
|
2023-01-10 11:26:25 +00:00
|
|
|
# Copyright (c) 2022-2023 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.
|
|
|
|
|
2022-05-08 22:42:21 +00:00
|
|
|
import ".."/datatypes/[altair, bellatrix]
|
2022-11-24 09:14:05 +00:00
|
|
|
from stew/byteutils import to0xHex
|
2022-01-24 20:15:22 +00:00
|
|
|
|
2023-01-20 14:14:37 +00:00
|
|
|
{.push raises: [].}
|
2022-02-27 16:55:02 +00:00
|
|
|
|
2022-01-24 20:15:22 +00:00
|
|
|
type
|
2023-02-18 00:54:30 +00:00
|
|
|
# https://github.com/ethereum/builder-specs/blob/v0.3.0/specs/bellatrix/builder.md#validatorregistrationv1
|
2022-07-12 17:50:12 +00:00
|
|
|
ValidatorRegistrationV1* = object
|
2022-05-09 14:55:15 +00:00
|
|
|
fee_recipient*: ExecutionAddress
|
|
|
|
gas_limit*: uint64
|
2022-05-08 22:42:21 +00:00
|
|
|
timestamp*: uint64
|
|
|
|
pubkey*: ValidatorPubKey
|
|
|
|
|
2023-02-18 00:54:30 +00:00
|
|
|
# https://github.com/ethereum/builder-specs/blob/v0.3.0/specs/bellatrix/builder.md#signedvalidatorregistrationv1
|
2022-05-17 13:56:19 +00:00
|
|
|
SignedValidatorRegistrationV1* = object
|
2022-05-09 11:19:20 +00:00
|
|
|
message*: ValidatorRegistrationV1
|
|
|
|
signature*: ValidatorSig
|
|
|
|
|
2023-02-18 00:54:30 +00:00
|
|
|
# https://github.com/ethereum/builder-specs/blob/v0.3.0/specs/bellatrix/builder.md#builderbid
|
2022-08-01 06:41:47 +00:00
|
|
|
BuilderBid* = object
|
2022-05-08 22:42:21 +00:00
|
|
|
header*: ExecutionPayloadHeader
|
2022-06-06 13:55:02 +00:00
|
|
|
value*: UInt256
|
2022-05-08 22:42:21 +00:00
|
|
|
pubkey*: ValidatorPubKey
|
|
|
|
|
2023-02-18 00:54:30 +00:00
|
|
|
# https://github.com/ethereum/builder-specs/blob/v0.3.0/specs/bellatrix/builder.md#signedbuilderbid
|
2022-05-17 13:56:19 +00:00
|
|
|
SignedBuilderBid* = object
|
2022-05-09 14:55:15 +00:00
|
|
|
message*: BuilderBid
|
2022-05-09 11:19:20 +00:00
|
|
|
signature*: ValidatorSig
|
|
|
|
|
2023-02-18 00:54:30 +00:00
|
|
|
# https://github.com/ethereum/builder-specs/blob/v0.3.0/specs/bellatrix/builder.md#blindedbeaconblockbody
|
2023-05-09 08:16:43 +00:00
|
|
|
BlindedBeaconBlockBody* = object
|
2022-01-24 20:15:22 +00:00
|
|
|
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*: ExecutionPayloadHeader
|
2022-05-17 13:56:19 +00:00
|
|
|
|
2023-02-18 00:54:30 +00:00
|
|
|
# https://github.com/ethereum/builder-specs/blob/v0.3.0/specs/bellatrix/builder.md#blindedbeaconblock
|
2022-05-17 13:56:19 +00:00
|
|
|
BlindedBeaconBlock* = object
|
|
|
|
slot*: Slot
|
|
|
|
proposer_index*: uint64
|
|
|
|
parent_root*: Eth2Digest
|
|
|
|
state_root*: Eth2Digest
|
|
|
|
body*: BlindedBeaconBlockBody
|
|
|
|
|
2023-02-18 00:54:30 +00:00
|
|
|
# https://github.com/ethereum/builder-specs/blob/v0.3.0/specs/bellatrix/builder.md#signedblindedbeaconblock
|
2022-05-17 13:56:19 +00:00
|
|
|
SignedBlindedBeaconBlock* = object
|
|
|
|
message*: BlindedBeaconBlock
|
|
|
|
signature*: ValidatorSig
|
|
|
|
|
|
|
|
const
|
2023-02-18 00:54:30 +00:00
|
|
|
# https://github.com/ethereum/builder-specs/blob/v0.3.0/specs/bellatrix/builder.md#domain-types
|
2022-07-12 17:50:12 +00:00
|
|
|
DOMAIN_APPLICATION_BUILDER* = DomainType([byte 0x00, 0x00, 0x00, 0x01])
|
|
|
|
|
2023-02-18 00:54:30 +00:00
|
|
|
# https://github.com/ethereum/builder-specs/blob/v0.3.0/specs/bellatrix/validator.md#constants
|
2022-08-01 06:41:47 +00:00
|
|
|
EPOCHS_PER_VALIDATOR_REGISTRATION_SUBMISSION* = 1
|
2023-05-16 13:41:55 +00:00
|
|
|
|
|
|
|
# Spec is 1 second, but mev-boost indirection can induce delay when the relay
|
|
|
|
# itself has already consumed the entire second.
|
|
|
|
BUILDER_PROPOSAL_DELAY_TOLERANCE* = 1500.milliseconds
|
2022-08-19 21:51:30 +00:00
|
|
|
|
|
|
|
func shortLog*(v: BlindedBeaconBlock): auto =
|
|
|
|
(
|
|
|
|
slot: shortLog(v.slot),
|
|
|
|
proposer_index: v.proposer_index,
|
|
|
|
parent_root: shortLog(v.parent_root),
|
|
|
|
state_root: shortLog(v.state_root),
|
2022-11-24 09:14:05 +00:00
|
|
|
eth1data: v.body.eth1_data,
|
|
|
|
graffiti: $v.body.graffiti,
|
|
|
|
proposer_slashings_len: v.body.proposer_slashings.len(),
|
|
|
|
attester_slashings_len: v.body.attester_slashings.len(),
|
|
|
|
attestations_len: v.body.attestations.len(),
|
|
|
|
deposits_len: v.body.deposits.len(),
|
|
|
|
voluntary_exits_len: v.body.voluntary_exits.len(),
|
2023-01-10 11:26:25 +00:00
|
|
|
sync_committee_participants: v.body.sync_aggregate.num_active_participants,
|
2022-11-24 09:14:05 +00:00
|
|
|
block_number: v.body.execution_payload_header.block_number,
|
|
|
|
# TODO checksum hex? shortlog?
|
|
|
|
fee_recipient: to0xHex(v.body.execution_payload_header.fee_recipient.data),
|
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 =
|
|
|
|
(
|
|
|
|
blck: shortLog(v.message),
|
|
|
|
signature: shortLog(v.signature)
|
|
|
|
)
|