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_1*: TrustedSignedBeaconBlockHeader
|
||||||
signed_header_2*: 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]
|
CommitteeValidatorsBits* = BitList[Limit MAX_VALIDATORS_PER_COMMITTEE]
|
||||||
|
|
||||||
ForkDigest* = distinct array[4, byte]
|
ForkDigest* = distinct array[4, byte]
|
||||||
|
@ -304,9 +278,7 @@ type
|
||||||
## Earliest epoch when voluntary exit can be processed
|
## Earliest epoch when voluntary exit can be processed
|
||||||
validator_index*: uint64 # `ValidatorIndex` after validation
|
validator_index*: uint64 # `ValidatorIndex` after validation
|
||||||
|
|
||||||
SomeIndexedAttestation* = IndexedAttestation | TrustedIndexedAttestation
|
|
||||||
SomeProposerSlashing* = ProposerSlashing | TrustedProposerSlashing
|
SomeProposerSlashing* = ProposerSlashing | TrustedProposerSlashing
|
||||||
SomeAttesterSlashing* = AttesterSlashing | TrustedAttesterSlashing
|
|
||||||
SomeSignedBeaconBlockHeader* = SignedBeaconBlockHeader | TrustedSignedBeaconBlockHeader
|
SomeSignedBeaconBlockHeader* = SignedBeaconBlockHeader | TrustedSignedBeaconBlockHeader
|
||||||
SomeSignedVoluntaryExit* = SignedVoluntaryExit | TrustedSignedVoluntaryExit
|
SomeSignedVoluntaryExit* = SignedVoluntaryExit | TrustedSignedVoluntaryExit
|
||||||
|
|
||||||
|
@ -816,29 +788,6 @@ func shortLog*(v: PendingAttestation): auto =
|
||||||
proposer_index: v.proposer_index
|
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 =
|
func shortLog*(v: SomeProposerSlashing): auto =
|
||||||
(
|
(
|
||||||
signed_header_1: shortLog(v.signed_header_1),
|
signed_header_1: shortLog(v.signed_header_1),
|
||||||
|
|
|
@ -19,6 +19,8 @@ import
|
||||||
chronicles,
|
chronicles,
|
||||||
./base
|
./base
|
||||||
|
|
||||||
|
from std/sets import toHashSet
|
||||||
|
|
||||||
export base
|
export base
|
||||||
|
|
||||||
type
|
type
|
||||||
|
@ -257,6 +259,32 @@ type
|
||||||
|
|
||||||
root* {.dontSerialize.}: Eth2Digest # cached root of signed beacon block
|
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
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#attestation
|
||||||
Attestation* = object
|
Attestation* = object
|
||||||
aggregation_bits*: CommitteeValidatorsBits
|
aggregation_bits*: CommitteeValidatorsBits
|
||||||
|
@ -282,6 +310,8 @@ type
|
||||||
message*: AggregateAndProof
|
message*: AggregateAndProof
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
|
|
||||||
|
SomeIndexedAttestation* = IndexedAttestation | TrustedIndexedAttestation
|
||||||
|
SomeAttesterSlashing* = AttesterSlashing | TrustedAttesterSlashing
|
||||||
SomeSignedBeaconBlock* =
|
SomeSignedBeaconBlock* =
|
||||||
SignedBeaconBlock |
|
SignedBeaconBlock |
|
||||||
SigVerifiedSignedBeaconBlock |
|
SigVerifiedSignedBeaconBlock |
|
||||||
|
@ -309,6 +339,29 @@ func clear*(info: var EpochInfo) =
|
||||||
info.validators.setLen(0)
|
info.validators.setLen(0)
|
||||||
info.balances = TotalBalances()
|
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 =
|
func shortLog*(v: SomeBeaconBlock): auto =
|
||||||
(
|
(
|
||||||
slot: shortLog(v.slot),
|
slot: shortLog(v.slot),
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import ".."/datatypes/altair
|
import ".."/datatypes/altair
|
||||||
from ".."/datatypes/phase0 import Attestation
|
from ".."/datatypes/phase0 import Attestation, AttesterSlashing
|
||||||
from ".."/datatypes/bellatrix import ExecutionPayloadHeader
|
from ".."/datatypes/bellatrix import ExecutionPayloadHeader
|
||||||
from ".."/eth2_merkleization import hash_tree_root
|
from ".."/eth2_merkleization import hash_tree_root
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import ".."/datatypes/[altair, capella]
|
import ".."/datatypes/[altair, capella]
|
||||||
from ".."/datatypes/phase0 import Attestation
|
from ".."/datatypes/phase0 import Attestation, AttesterSlashing
|
||||||
from stew/byteutils import to0xHex
|
from stew/byteutils import to0xHex
|
||||||
|
|
||||||
from ../eth2_merkleization import fromSszBytes, hash_tree_root, toSszType
|
from ../eth2_merkleization import fromSszBytes, hash_tree_root, toSszType
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
import ".."/datatypes/[altair, deneb]
|
import ".."/datatypes/[altair, deneb]
|
||||||
|
|
||||||
from stew/byteutils import to0xHex
|
from stew/byteutils import to0xHex
|
||||||
from ".."/datatypes/phase0 import Attestation
|
from ".."/datatypes/phase0 import Attestation, AttesterSlashing
|
||||||
from ../datatypes/bellatrix import ExecutionAddress
|
from ../datatypes/bellatrix import ExecutionAddress
|
||||||
from ".."/datatypes/capella import SignedBLSToExecutionChange
|
from ".."/datatypes/capella import SignedBLSToExecutionChange
|
||||||
from ".."/eth2_merkleization import hash_tree_root
|
from ".."/eth2_merkleization import hash_tree_root
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
import ".."/datatypes/[altair, electra]
|
import ".."/datatypes/[altair, electra]
|
||||||
|
|
||||||
from stew/byteutils import to0xHex
|
from stew/byteutils import to0xHex
|
||||||
from ".."/datatypes/phase0 import Attestation
|
from ".."/datatypes/phase0 import Attestation, AttesterSlashing
|
||||||
from ../datatypes/bellatrix import ExecutionAddress
|
from ../datatypes/bellatrix import ExecutionAddress
|
||||||
from ".."/datatypes/capella import SignedBLSToExecutionChange
|
from ".."/datatypes/capella import SignedBLSToExecutionChange
|
||||||
from ".."/datatypes/deneb import BlobsBundle, KzgCommitments
|
from ".."/datatypes/deneb import BlobsBundle, KzgCommitments
|
||||||
|
|
Loading…
Reference in New Issue