Merge branch 'dev/etan/im-base' into feat_eip-7688
This commit is contained in:
commit
36f939b514
|
@ -75,20 +75,6 @@ static: doAssert TIMELY_SOURCE_WEIGHT + TIMELY_TARGET_WEIGHT +
|
|||
type
|
||||
### New types
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#custom-types
|
||||
ParticipationFlags* = uint8
|
||||
|
||||
EpochParticipationFlags* =
|
||||
distinct List[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT]
|
||||
## Not a HashList because the list sees significant updates every block
|
||||
## effectively making the cost of clearing the cache higher than the typical
|
||||
## gains
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#synccommittee
|
||||
SyncCommittee* = object
|
||||
pubkeys*: HashArray[Limit SYNC_COMMITTEE_SIZE, ValidatorPubKey]
|
||||
aggregate_pubkey*: ValidatorPubKey
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/altair/validator.md#synccommitteemessage
|
||||
SyncCommitteeMessage* = object
|
||||
slot*: Slot
|
||||
|
@ -246,8 +232,6 @@ type
|
|||
## (used to compute safety threshold)
|
||||
current_max_active_participants*: uint64
|
||||
|
||||
InactivityScores* = HashList[uint64, Limit VALIDATOR_REGISTRY_LIMIT]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#beaconstate
|
||||
BeaconState* = object
|
||||
# Versioning
|
||||
|
@ -536,45 +520,6 @@ template `[]`*(arr: array[SYNC_COMMITTEE_SIZE, auto] | seq;
|
|||
makeLimitedU8(SyncSubcommitteeIndex, SYNC_COMMITTEE_SUBNET_COUNT)
|
||||
makeLimitedU16(IndexInSyncCommittee, SYNC_COMMITTEE_SIZE)
|
||||
|
||||
template asList*(epochFlags: EpochParticipationFlags): untyped =
|
||||
List[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT] epochFlags
|
||||
template asList*(epochFlags: var EpochParticipationFlags): untyped =
|
||||
let tmp = cast[ptr List[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT]](addr epochFlags)
|
||||
tmp[]
|
||||
|
||||
template asSeq*(epochFlags: EpochParticipationFlags): untyped =
|
||||
seq[ParticipationFlags] asList(epochFlags)
|
||||
|
||||
template asSeq*(epochFlags: var EpochParticipationFlags): untyped =
|
||||
let tmp = cast[ptr seq[ParticipationFlags]](addr epochFlags)
|
||||
tmp[]
|
||||
|
||||
template item*(epochFlags: EpochParticipationFlags, idx: ValidatorIndex): ParticipationFlags =
|
||||
asList(epochFlags)[idx]
|
||||
|
||||
template `[]`*(epochFlags: EpochParticipationFlags, idx: ValidatorIndex|uint64|int): ParticipationFlags =
|
||||
asList(epochFlags)[idx]
|
||||
|
||||
template `[]=`*(epochFlags: EpochParticipationFlags, idx: ValidatorIndex, flags: ParticipationFlags) =
|
||||
asList(epochFlags)[idx] = flags
|
||||
|
||||
template add*(epochFlags: var EpochParticipationFlags, flags: ParticipationFlags): bool =
|
||||
asList(epochFlags).add flags
|
||||
|
||||
template len*(epochFlags: EpochParticipationFlags): int =
|
||||
asList(epochFlags).len
|
||||
|
||||
template low*(epochFlags: EpochParticipationFlags): int =
|
||||
asSeq(epochFlags).low
|
||||
template high*(epochFlags: EpochParticipationFlags): int =
|
||||
asSeq(epochFlags).high
|
||||
|
||||
template assign*(v: var EpochParticipationFlags, src: EpochParticipationFlags) =
|
||||
# TODO https://github.com/nim-lang/Nim/issues/21123
|
||||
mixin assign
|
||||
var tmp = cast[ptr seq[ParticipationFlags]](addr v)
|
||||
assign(tmp[], distinctBase src)
|
||||
|
||||
func shortLog*(v: SomeBeaconBlock): auto =
|
||||
(
|
||||
slot: shortLog(v.slot),
|
||||
|
|
|
@ -70,9 +70,11 @@ import
|
|||
../../version,
|
||||
".."/[beacon_time, crypto, digest, presets]
|
||||
|
||||
from kzg4844 import KzgCommitment
|
||||
|
||||
export
|
||||
tables, results, endians2, json_serialization, sszTypes, beacon_time, crypto,
|
||||
digest, presets
|
||||
digest, presets, kzg4844
|
||||
|
||||
const SPEC_VERSION* = "1.5.0-alpha.2"
|
||||
## Spec version we're aiming to be compatible with, right now
|
||||
|
@ -408,6 +410,38 @@ type
|
|||
validator_pubkey*: ValidatorPubKey
|
||||
amount*: Gwei
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/beacon-chain.md#blstoexecutionchange
|
||||
BLSToExecutionChange* = object
|
||||
validator_index*: uint64
|
||||
from_bls_pubkey*: ValidatorPubKey
|
||||
to_execution_address*: ExecutionAddress
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/capella/beacon-chain.md#signedblstoexecutionchange
|
||||
SignedBLSToExecutionChange* = object
|
||||
message*: BLSToExecutionChange
|
||||
signature*: ValidatorSig
|
||||
|
||||
SignedBLSToExecutionChangeList* =
|
||||
List[SignedBLSToExecutionChange, Limit MAX_BLS_TO_EXECUTION_CHANGES]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#beaconblockbody
|
||||
KzgCommitments* = List[KzgCommitment, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/electra/beacon-chain.md#consolidation
|
||||
Consolidation* = object
|
||||
source_index*: uint64
|
||||
target_index*: uint64
|
||||
epoch*: Epoch
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/82133085a1295e93394ebdf71df8f2f6e0962588/specs/electra/beacon-chain.md#signedconsolidation
|
||||
SignedConsolidation* = object
|
||||
message*: Consolidation
|
||||
signature*: ValidatorSig
|
||||
|
||||
TrustedSignedConsolidation* = object
|
||||
message*: Consolidation
|
||||
signature*: TrustedSig
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/capella/beacon-chain.md#historicalsummary
|
||||
HistoricalSummary* = object
|
||||
# `HistoricalSummary` matches the components of the phase0
|
||||
|
@ -415,6 +449,38 @@ type
|
|||
block_summary_root*: Eth2Digest
|
||||
state_summary_root*: Eth2Digest
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/82133085a1295e93394ebdf71df8f2f6e0962588/specs/electra/beacon-chain.md#depositreceipt
|
||||
PendingBalanceDeposit* = object
|
||||
index*: uint64
|
||||
amount*: Gwei
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/electra/beacon-chain.md#pendingpartialwithdrawal
|
||||
PendingPartialWithdrawal* = object
|
||||
index*: uint64
|
||||
amount*: Gwei
|
||||
withdrawable_epoch*: Epoch
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/82133085a1295e93394ebdf71df8f2f6e0962588/specs/electra/beacon-chain.md#pendingconsolidation
|
||||
PendingConsolidation* = object
|
||||
source_index*: uint64
|
||||
target_index*: uint64
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#custom-types
|
||||
ParticipationFlags* = uint8
|
||||
|
||||
EpochParticipationFlags* =
|
||||
distinct List[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT]
|
||||
## Not a HashList because the list sees significant updates every block
|
||||
## effectively making the cost of clearing the cache higher than the typical
|
||||
## gains
|
||||
|
||||
InactivityScores* = HashList[uint64, Limit VALIDATOR_REGISTRY_LIMIT]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#synccommittee
|
||||
SyncCommittee* = object
|
||||
pubkeys*: HashArray[Limit SYNC_COMMITTEE_SIZE, ValidatorPubKey]
|
||||
aggregate_pubkey*: ValidatorPubKey
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#beaconblockheader
|
||||
BeaconBlockHeader* = object
|
||||
slot*: Slot
|
||||
|
@ -903,9 +969,61 @@ proc readValue*(
|
|||
func `$`*(v: ExecutionAddress): string =
|
||||
v.data.toHex()
|
||||
|
||||
func shortLog*(v: BLSToExecutionChange): auto =
|
||||
(
|
||||
validator_index: v.validator_index,
|
||||
from_bls_pubkey: shortLog(v.from_bls_pubkey),
|
||||
to_execution_address: $v.to_execution_address
|
||||
)
|
||||
|
||||
func shortLog*(v: SignedBLSToExecutionChange): auto =
|
||||
(
|
||||
bls_to_execution_change: shortLog(v.message),
|
||||
signature: shortLog(v.signature)
|
||||
)
|
||||
|
||||
chronicles.formatIt AttestationData: it.shortLog
|
||||
chronicles.formatIt Checkpoint: it.shortLog
|
||||
|
||||
template asList*(epochFlags: EpochParticipationFlags): untyped =
|
||||
List[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT] epochFlags
|
||||
template asList*(epochFlags: var EpochParticipationFlags): untyped =
|
||||
let tmp = cast[ptr List[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT]](addr epochFlags)
|
||||
tmp[]
|
||||
|
||||
template asSeq*(epochFlags: EpochParticipationFlags): untyped =
|
||||
seq[ParticipationFlags] asList(epochFlags)
|
||||
|
||||
template asSeq*(epochFlags: var EpochParticipationFlags): untyped =
|
||||
let tmp = cast[ptr seq[ParticipationFlags]](addr epochFlags)
|
||||
tmp[]
|
||||
|
||||
template item*(epochFlags: EpochParticipationFlags, idx: ValidatorIndex): ParticipationFlags =
|
||||
asList(epochFlags)[idx]
|
||||
|
||||
template `[]`*(epochFlags: EpochParticipationFlags, idx: ValidatorIndex|uint64|int): ParticipationFlags =
|
||||
asList(epochFlags)[idx]
|
||||
|
||||
template `[]=`*(epochFlags: EpochParticipationFlags, idx: ValidatorIndex, flags: ParticipationFlags) =
|
||||
asList(epochFlags)[idx] = flags
|
||||
|
||||
template add*(epochFlags: var EpochParticipationFlags, flags: ParticipationFlags): bool =
|
||||
asList(epochFlags).add flags
|
||||
|
||||
template len*(epochFlags: EpochParticipationFlags): int =
|
||||
asList(epochFlags).len
|
||||
|
||||
template low*(epochFlags: EpochParticipationFlags): int =
|
||||
asSeq(epochFlags).low
|
||||
template high*(epochFlags: EpochParticipationFlags): int =
|
||||
asSeq(epochFlags).high
|
||||
|
||||
template assign*(v: var EpochParticipationFlags, src: EpochParticipationFlags) =
|
||||
# TODO https://github.com/nim-lang/Nim/issues/21123
|
||||
mixin assign
|
||||
var tmp = cast[ptr seq[ParticipationFlags]](addr v)
|
||||
assign(tmp[], distinctBase src)
|
||||
|
||||
const
|
||||
# http://facweb.cs.depaul.edu/sjost/it212/documents/ascii-pr.htm
|
||||
PrintableAsciiChars = {' '..'~'}
|
||||
|
|
|
@ -36,20 +36,6 @@ const
|
|||
EXECUTION_PAYLOAD_GINDEX* = 25.GeneralizedIndex # execution_payload
|
||||
|
||||
type
|
||||
SignedBLSToExecutionChangeList* =
|
||||
List[SignedBLSToExecutionChange, Limit MAX_BLS_TO_EXECUTION_CHANGES]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/beacon-chain.md#blstoexecutionchange
|
||||
BLSToExecutionChange* = object
|
||||
validator_index*: uint64
|
||||
from_bls_pubkey*: ValidatorPubKey
|
||||
to_execution_address*: ExecutionAddress
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/capella/beacon-chain.md#signedblstoexecutionchange
|
||||
SignedBLSToExecutionChange* = object
|
||||
message*: BLSToExecutionChange
|
||||
signature*: ValidatorSig
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/beacon-chain.md#executionpayload
|
||||
ExecutionPayload* = object
|
||||
# Execution block header fields
|
||||
|
@ -630,19 +616,6 @@ func shortLog*(v: ExecutionPayload): auto =
|
|||
num_withdrawals: len(v.withdrawals)
|
||||
)
|
||||
|
||||
func shortLog*(v: BLSToExecutionChange): auto =
|
||||
(
|
||||
validator_index: v.validator_index,
|
||||
from_bls_pubkey: shortLog(v.from_bls_pubkey),
|
||||
to_execution_address: $v.to_execution_address
|
||||
)
|
||||
|
||||
func shortLog*(v: SignedBLSToExecutionChange): auto =
|
||||
(
|
||||
bls_to_execution_change: shortLog(v.message),
|
||||
signature: shortLog(v.signature)
|
||||
)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/light-client/sync-protocol.md#get_lc_execution_root
|
||||
func get_lc_execution_root*(
|
||||
header: LightClientHeader, cfg: RuntimeConfig): Eth2Digest =
|
||||
|
|
|
@ -36,9 +36,6 @@ const
|
|||
BLS_MODULUS* = "52435875175126190479447740508185965837690552500527637822603658699938581184513".u256
|
||||
|
||||
type
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#beaconblockbody
|
||||
KzgCommitments* = List[KzgCommitment, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK]
|
||||
|
||||
# TODO this apparently is suppposed to be SSZ-equivalent to Bytes32, but
|
||||
# current spec doesn't ever SSZ-serialize it or hash_tree_root it
|
||||
# TODO make `distinct` then add a REST serialization for it specifically, via
|
||||
|
@ -51,7 +48,8 @@ type
|
|||
BlobIndex* = uint64
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/deneb/polynomial-commitments.md#custom-types
|
||||
Blob* = array[BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB, byte]
|
||||
Blob* = array[
|
||||
BYTES_PER_FIELD_ELEMENT * deneb_preset.FIELD_ELEMENTS_PER_BLOB, byte]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/p2p-interface.md#blobsidecar
|
||||
BlobSidecar* = object
|
||||
|
@ -616,7 +614,7 @@ func kzg_commitment_inclusion_proof_gindex*(
|
|||
(BLOB_KZG_COMMITMENTS_GINDEX shl 1) + 0
|
||||
# List depth
|
||||
BLOB_KZG_COMMITMENTS_PROOF_DEPTH =
|
||||
log2trunc(nextPow2(deneb.KzgCommitments.maxLen.uint64))
|
||||
log2trunc(nextPow2(KzgCommitments.maxLen.uint64))
|
||||
# First item
|
||||
BLOB_KZG_COMMITMENTS_FIRST_GINDEX =
|
||||
(BLOB_KZG_COMMITMENTS_BASE_GINDEX shl BLOB_KZG_COMMITMENTS_PROOF_DEPTH)
|
||||
|
|
|
@ -333,37 +333,6 @@ type
|
|||
ExecutePayload* = proc(
|
||||
execution_payload: ExecutionPayload): bool {.gcsafe, raises: [].}
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/82133085a1295e93394ebdf71df8f2f6e0962588/specs/electra/beacon-chain.md#depositreceipt
|
||||
PendingBalanceDeposit* = object
|
||||
index*: uint64
|
||||
amount*: Gwei
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/electra/beacon-chain.md#pendingpartialwithdrawal
|
||||
PendingPartialWithdrawal* = object
|
||||
index*: uint64
|
||||
amount*: Gwei
|
||||
withdrawable_epoch*: Epoch
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/electra/beacon-chain.md#consolidation
|
||||
Consolidation* = object
|
||||
source_index*: uint64
|
||||
target_index*: uint64
|
||||
epoch*: Epoch
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/82133085a1295e93394ebdf71df8f2f6e0962588/specs/electra/beacon-chain.md#signedconsolidation
|
||||
SignedConsolidation* = object
|
||||
message*: Consolidation
|
||||
signature*: ValidatorSig
|
||||
|
||||
TrustedSignedConsolidation* = object
|
||||
message*: Consolidation
|
||||
signature*: TrustedSig
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/82133085a1295e93394ebdf71df8f2f6e0962588/specs/electra/beacon-chain.md#pendingconsolidation
|
||||
PendingConsolidation* = object
|
||||
source_index*: uint64
|
||||
target_index*: uint64
|
||||
|
||||
FinalityBranch =
|
||||
array[log2trunc(FINALIZED_ROOT_GINDEX), Eth2Digest]
|
||||
|
||||
|
|
Loading…
Reference in New Issue