move AttesterSlashing and IndexedAttestation from base to phase0 (#6223)
This commit is contained in:
parent
41f8400f97
commit
caa3b73dbb
|
@ -222,32 +222,6 @@ type
|
|||
signed_header_1*: TrustedSignedBeaconBlockHeader
|
||||
signed_header_2*: TrustedSignedBeaconBlockHeader
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#attesterslashing
|
||||
AttesterSlashing* = object
|
||||
attestation_1*: IndexedAttestation
|
||||
attestation_2*: IndexedAttestation
|
||||
|
||||
TrustedAttesterSlashing* = object
|
||||
# The Trusted version, at the moment, implies that the cryptographic signature was checked.
|
||||
# It DOES NOT imply that the state transition was verified.
|
||||
# Currently the code MUST verify the state transition as soon as the signature is verified
|
||||
attestation_1*: TrustedIndexedAttestation
|
||||
attestation_2*: TrustedIndexedAttestation
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#indexedattestation
|
||||
IndexedAttestation* = object
|
||||
attesting_indices*: List[uint64, Limit MAX_VALIDATORS_PER_COMMITTEE]
|
||||
data*: AttestationData
|
||||
signature*: ValidatorSig
|
||||
|
||||
TrustedIndexedAttestation* = object
|
||||
# The Trusted version, at the moment, implies that the cryptographic signature was checked.
|
||||
# It DOES NOT imply that the state transition was verified.
|
||||
# Currently the code MUST verify the state transition as soon as the signature is verified
|
||||
attesting_indices*: List[uint64, Limit MAX_VALIDATORS_PER_COMMITTEE]
|
||||
data*: AttestationData
|
||||
signature*: TrustedSig
|
||||
|
||||
CommitteeValidatorsBits* = BitList[Limit MAX_VALIDATORS_PER_COMMITTEE]
|
||||
|
||||
ForkDigest* = distinct array[4, byte]
|
||||
|
@ -304,9 +278,7 @@ type
|
|||
## Earliest epoch when voluntary exit can be processed
|
||||
validator_index*: uint64 # `ValidatorIndex` after validation
|
||||
|
||||
SomeIndexedAttestation* = IndexedAttestation | TrustedIndexedAttestation
|
||||
SomeProposerSlashing* = ProposerSlashing | TrustedProposerSlashing
|
||||
SomeAttesterSlashing* = AttesterSlashing | TrustedAttesterSlashing
|
||||
SomeSignedBeaconBlockHeader* = SignedBeaconBlockHeader | TrustedSignedBeaconBlockHeader
|
||||
SomeSignedVoluntaryExit* = SignedVoluntaryExit | TrustedSignedVoluntaryExit
|
||||
|
||||
|
@ -816,29 +788,6 @@ func shortLog*(v: PendingAttestation): auto =
|
|||
proposer_index: v.proposer_index
|
||||
)
|
||||
|
||||
func shortLog*(v: SomeIndexedAttestation): auto =
|
||||
(
|
||||
attestating_indices: v.attesting_indices,
|
||||
data: shortLog(v.data),
|
||||
signature: shortLog(v.signature)
|
||||
)
|
||||
|
||||
iterator getValidatorIndices*(attester_slashing: SomeAttesterSlashing): uint64 =
|
||||
template attestation_1(): auto = attester_slashing.attestation_1
|
||||
template attestation_2(): auto = attester_slashing.attestation_2
|
||||
|
||||
let attestation_2_indices = toHashSet(attestation_2.attesting_indices.asSeq)
|
||||
for validator_index in attestation_1.attesting_indices.asSeq:
|
||||
if validator_index notin attestation_2_indices:
|
||||
continue
|
||||
yield validator_index
|
||||
|
||||
func shortLog*(v: SomeAttesterSlashing): auto =
|
||||
(
|
||||
attestation_1: shortLog(v.attestation_1),
|
||||
attestation_2: shortLog(v.attestation_2),
|
||||
)
|
||||
|
||||
func shortLog*(v: SomeProposerSlashing): auto =
|
||||
(
|
||||
signed_header_1: shortLog(v.signed_header_1),
|
||||
|
|
|
@ -19,6 +19,8 @@ import
|
|||
chronicles,
|
||||
./base
|
||||
|
||||
from std/sets import toHashSet
|
||||
|
||||
export base
|
||||
|
||||
type
|
||||
|
@ -257,6 +259,32 @@ type
|
|||
|
||||
root* {.dontSerialize.}: Eth2Digest # cached root of signed beacon block
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#attesterslashing
|
||||
AttesterSlashing* = object
|
||||
attestation_1*: IndexedAttestation
|
||||
attestation_2*: IndexedAttestation
|
||||
|
||||
TrustedAttesterSlashing* = object
|
||||
# The Trusted version, at the moment, implies that the cryptographic signature was checked.
|
||||
# It DOES NOT imply that the state transition was verified.
|
||||
# Currently the code MUST verify the state transition as soon as the signature is verified
|
||||
attestation_1*: TrustedIndexedAttestation
|
||||
attestation_2*: TrustedIndexedAttestation
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#indexedattestation
|
||||
IndexedAttestation* = object
|
||||
attesting_indices*: List[uint64, Limit MAX_VALIDATORS_PER_COMMITTEE]
|
||||
data*: AttestationData
|
||||
signature*: ValidatorSig
|
||||
|
||||
TrustedIndexedAttestation* = object
|
||||
# The Trusted version, at the moment, implies that the cryptographic signature was checked.
|
||||
# It DOES NOT imply that the state transition was verified.
|
||||
# Currently the code MUST verify the state transition as soon as the signature is verified
|
||||
attesting_indices*: List[uint64, Limit MAX_VALIDATORS_PER_COMMITTEE]
|
||||
data*: AttestationData
|
||||
signature*: TrustedSig
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#attestation
|
||||
Attestation* = object
|
||||
aggregation_bits*: CommitteeValidatorsBits
|
||||
|
@ -282,6 +310,8 @@ type
|
|||
message*: AggregateAndProof
|
||||
signature*: ValidatorSig
|
||||
|
||||
SomeIndexedAttestation* = IndexedAttestation | TrustedIndexedAttestation
|
||||
SomeAttesterSlashing* = AttesterSlashing | TrustedAttesterSlashing
|
||||
SomeSignedBeaconBlock* =
|
||||
SignedBeaconBlock |
|
||||
SigVerifiedSignedBeaconBlock |
|
||||
|
@ -309,6 +339,29 @@ func clear*(info: var EpochInfo) =
|
|||
info.validators.setLen(0)
|
||||
info.balances = TotalBalances()
|
||||
|
||||
func shortLog*(v: SomeIndexedAttestation): auto =
|
||||
(
|
||||
attestating_indices: v.attesting_indices,
|
||||
data: shortLog(v.data),
|
||||
signature: shortLog(v.signature)
|
||||
)
|
||||
|
||||
iterator getValidatorIndices*(attester_slashing: SomeAttesterSlashing): uint64 =
|
||||
template attestation_1(): auto = attester_slashing.attestation_1
|
||||
template attestation_2(): auto = attester_slashing.attestation_2
|
||||
|
||||
let attestation_2_indices = toHashSet(attestation_2.attesting_indices.asSeq)
|
||||
for validator_index in attestation_1.attesting_indices.asSeq:
|
||||
if validator_index notin attestation_2_indices:
|
||||
continue
|
||||
yield validator_index
|
||||
|
||||
func shortLog*(v: SomeAttesterSlashing): auto =
|
||||
(
|
||||
attestation_1: shortLog(v.attestation_1),
|
||||
attestation_2: shortLog(v.attestation_2),
|
||||
)
|
||||
|
||||
func shortLog*(v: SomeBeaconBlock): auto =
|
||||
(
|
||||
slot: shortLog(v.slot),
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{.push raises: [].}
|
||||
|
||||
import ".."/datatypes/altair
|
||||
from ".."/datatypes/phase0 import Attestation
|
||||
from ".."/datatypes/phase0 import Attestation, AttesterSlashing
|
||||
from ".."/datatypes/bellatrix import ExecutionPayloadHeader
|
||||
from ".."/eth2_merkleization import hash_tree_root
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{.push raises: [].}
|
||||
|
||||
import ".."/datatypes/[altair, capella]
|
||||
from ".."/datatypes/phase0 import Attestation
|
||||
from ".."/datatypes/phase0 import Attestation, AttesterSlashing
|
||||
from stew/byteutils import to0xHex
|
||||
|
||||
from ../eth2_merkleization import fromSszBytes, hash_tree_root, toSszType
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import ".."/datatypes/[altair, deneb]
|
||||
|
||||
from stew/byteutils import to0xHex
|
||||
from ".."/datatypes/phase0 import Attestation
|
||||
from ".."/datatypes/phase0 import Attestation, AttesterSlashing
|
||||
from ../datatypes/bellatrix import ExecutionAddress
|
||||
from ".."/datatypes/capella import SignedBLSToExecutionChange
|
||||
from ".."/eth2_merkleization import hash_tree_root
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import ".."/datatypes/[altair, electra]
|
||||
|
||||
from stew/byteutils import to0xHex
|
||||
from ".."/datatypes/phase0 import Attestation
|
||||
from ".."/datatypes/phase0 import Attestation, AttesterSlashing
|
||||
from ../datatypes/bellatrix import ExecutionAddress
|
||||
from ".."/datatypes/capella import SignedBLSToExecutionChange
|
||||
from ".."/datatypes/deneb import BlobsBundle, KzgCommitments
|
||||
|
|
Loading…
Reference in New Issue