rename ElectraIndexedAttestation/ElectraAttesterSlashing for consistency (#6252)
This commit is contained in:
parent
abc8bbbf23
commit
e70fa6d6de
|
@ -533,8 +533,8 @@ func is_eligible_for_activation*(
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
|
||||||
proc is_valid_indexed_attestation*(
|
proc is_valid_indexed_attestation*(
|
||||||
state: ForkyBeaconState,
|
state: ForkyBeaconState,
|
||||||
indexed_attestation: SomeIndexedAttestation | ElectraIndexedAttestation |
|
indexed_attestation: SomeIndexedAttestation | electra.IndexedAttestation |
|
||||||
TrustedElectraIndexedAttestation,
|
electra.TrustedIndexedAttestation,
|
||||||
flags: UpdateFlags): Result[void, cstring] =
|
flags: UpdateFlags): Result[void, cstring] =
|
||||||
## Check if ``indexed_attestation`` is not empty, has sorted and unique
|
## Check if ``indexed_attestation`` is not empty, has sorted and unique
|
||||||
## indices and has a valid aggregate signature.
|
## indices and has a valid aggregate signature.
|
||||||
|
|
|
@ -48,9 +48,6 @@ const
|
||||||
CURRENT_SYNC_COMMITTEE_GINDEX = 86.GeneralizedIndex # current_sync_committee
|
CURRENT_SYNC_COMMITTEE_GINDEX = 86.GeneralizedIndex # current_sync_committee
|
||||||
NEXT_SYNC_COMMITTEE_GINDEX = 87.GeneralizedIndex # next_sync_committee
|
NEXT_SYNC_COMMITTEE_GINDEX = 87.GeneralizedIndex # next_sync_committee
|
||||||
|
|
||||||
debugRaiseAssert "rename ElectraIndexedAttestation to IndexedAttestation"
|
|
||||||
debugRaiseAssert "rename ElectraAttesterSlashing to AttesterSlashing"
|
|
||||||
|
|
||||||
type
|
type
|
||||||
# https://github.com/ethereum/consensus-specs/blob/94a0b6c581f2809aa8aca4ef7ee6fbb63f9d74e9/specs/electra/beacon-chain.md#depositreceipt
|
# https://github.com/ethereum/consensus-specs/blob/94a0b6c581f2809aa8aca4ef7ee6fbb63f9d74e9/specs/electra/beacon-chain.md#depositreceipt
|
||||||
DepositReceipt* = object
|
DepositReceipt* = object
|
||||||
|
@ -61,13 +58,13 @@ type
|
||||||
index*: uint64
|
index*: uint64
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/electra/beacon-chain.md#indexedattestation
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/electra/beacon-chain.md#indexedattestation
|
||||||
ElectraIndexedAttestation* = object
|
IndexedAttestation* = object
|
||||||
attesting_indices*:
|
attesting_indices*:
|
||||||
List[uint64, Limit MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]
|
List[uint64, Limit MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]
|
||||||
data*: AttestationData
|
data*: AttestationData
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
|
|
||||||
TrustedElectraIndexedAttestation* = object
|
TrustedIndexedAttestation* = object
|
||||||
# The Trusted version, at the moment, implies that the cryptographic signature was checked.
|
# The Trusted version, at the moment, implies that the cryptographic signature was checked.
|
||||||
# It DOES NOT imply that the state transition was verified.
|
# 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
|
# Currently the code MUST verify the state transition as soon as the signature is verified
|
||||||
|
@ -77,11 +74,11 @@ type
|
||||||
signature*: TrustedSig
|
signature*: TrustedSig
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/electra/beacon-chain.md#attesterslashing
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/electra/beacon-chain.md#attesterslashing
|
||||||
ElectraAttesterSlashing* = object
|
AttesterSlashing* = object
|
||||||
attestation_1*: ElectraIndexedAttestation # [Modified in Electra:EIP7549]
|
attestation_1*: IndexedAttestation # [Modified in Electra:EIP7549]
|
||||||
attestation_2*: ElectraIndexedAttestation # [Modified in Electra:EIP7549]
|
attestation_2*: IndexedAttestation # [Modified in Electra:EIP7549]
|
||||||
|
|
||||||
TrustedElectraAttesterSlashing* = object
|
TrustedAttesterSlashing* = object
|
||||||
# The Trusted version, at the moment, implies that the cryptographic signature was checked.
|
# The Trusted version, at the moment, implies that the cryptographic signature was checked.
|
||||||
# It DOES NOT imply that the state transition was verified.
|
# 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
|
# Currently the code MUST verify the state transition as soon as the signature is verified
|
||||||
|
@ -461,7 +458,7 @@ type
|
||||||
# Operations
|
# Operations
|
||||||
proposer_slashings*: List[ProposerSlashing, Limit MAX_PROPOSER_SLASHINGS]
|
proposer_slashings*: List[ProposerSlashing, Limit MAX_PROPOSER_SLASHINGS]
|
||||||
attester_slashings*:
|
attester_slashings*:
|
||||||
List[ElectraAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS_ELECTRA]
|
List[AttesterSlashing, Limit MAX_ATTESTER_SLASHINGS_ELECTRA]
|
||||||
## [Modified in Electra:EIP7549]
|
## [Modified in Electra:EIP7549]
|
||||||
attestations*: List[electra.Attestation, Limit MAX_ATTESTATIONS_ELECTRA]
|
attestations*: List[electra.Attestation, Limit MAX_ATTESTATIONS_ELECTRA]
|
||||||
## [Modified in Electra:EIP7549]
|
## [Modified in Electra:EIP7549]
|
||||||
|
@ -502,7 +499,7 @@ type
|
||||||
proposer_slashings*:
|
proposer_slashings*:
|
||||||
List[TrustedProposerSlashing, Limit MAX_PROPOSER_SLASHINGS]
|
List[TrustedProposerSlashing, Limit MAX_PROPOSER_SLASHINGS]
|
||||||
attester_slashings*:
|
attester_slashings*:
|
||||||
List[TrustedElectraAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS_ELECTRA]
|
List[TrustedAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS_ELECTRA]
|
||||||
## [Modified in Electra:EIP7549]
|
## [Modified in Electra:EIP7549]
|
||||||
attestations*: List[TrustedAttestation, Limit MAX_ATTESTATIONS_ELECTRA]
|
attestations*: List[TrustedAttestation, Limit MAX_ATTESTATIONS_ELECTRA]
|
||||||
## [Modified in Electra:EIP7549]
|
## [Modified in Electra:EIP7549]
|
||||||
|
@ -531,7 +528,7 @@ type
|
||||||
proposer_slashings*:
|
proposer_slashings*:
|
||||||
List[TrustedProposerSlashing, Limit MAX_PROPOSER_SLASHINGS]
|
List[TrustedProposerSlashing, Limit MAX_PROPOSER_SLASHINGS]
|
||||||
attester_slashings*:
|
attester_slashings*:
|
||||||
List[TrustedElectraAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS_ELECTRA]
|
List[TrustedAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS_ELECTRA]
|
||||||
## [Modified in Electra:EIP7549]
|
## [Modified in Electra:EIP7549]
|
||||||
attestations*: List[TrustedAttestation, Limit MAX_ATTESTATIONS_ELECTRA]
|
attestations*: List[TrustedAttestation, Limit MAX_ATTESTATIONS_ELECTRA]
|
||||||
## [Modified in Electra:EIP7549]
|
## [Modified in Electra:EIP7549]
|
||||||
|
@ -708,7 +705,7 @@ debugRaiseAssert "this whole section with getValidatorIndices/shortLog needs ref
|
||||||
|
|
||||||
from std/sets import toHashSet
|
from std/sets import toHashSet
|
||||||
|
|
||||||
iterator getValidatorIndices*(attester_slashing: ElectraAttesterSlashing | TrustedElectraAttesterSlashing): uint64 =
|
iterator getValidatorIndices*(attester_slashing: AttesterSlashing | TrustedAttesterSlashing): uint64 =
|
||||||
template attestation_1(): auto = attester_slashing.attestation_1
|
template attestation_1(): auto = attester_slashing.attestation_1
|
||||||
template attestation_2(): auto = attester_slashing.attestation_2
|
template attestation_2(): auto = attester_slashing.attestation_2
|
||||||
|
|
||||||
|
|
|
@ -247,14 +247,14 @@ RestJson.useDefaultSerializationFor(
|
||||||
deneb_mev.SignedBlindedBeaconBlock,
|
deneb_mev.SignedBlindedBeaconBlock,
|
||||||
deneb_mev.SignedBuilderBid,
|
deneb_mev.SignedBuilderBid,
|
||||||
electra.Attestation,
|
electra.Attestation,
|
||||||
ElectraAttesterSlashing,
|
electra.AttesterSlashing,
|
||||||
electra.BeaconBlock,
|
electra.BeaconBlock,
|
||||||
electra.BeaconState,
|
electra.BeaconState,
|
||||||
electra.BeaconBlockBody,
|
electra.BeaconBlockBody,
|
||||||
electra.BlockContents,
|
electra.BlockContents,
|
||||||
electra.ExecutionPayload,
|
electra.ExecutionPayload,
|
||||||
electra.ExecutionPayloadHeader,
|
electra.ExecutionPayloadHeader,
|
||||||
ElectraIndexedAttestation,
|
electra.IndexedAttestation,
|
||||||
electra.SignedBeaconBlock,
|
electra.SignedBeaconBlock,
|
||||||
electra.TrustedAttestation,
|
electra.TrustedAttestation,
|
||||||
electra_mev.BlindedBeaconBlock,
|
electra_mev.BlindedBeaconBlock,
|
||||||
|
|
|
@ -34,7 +34,7 @@ type
|
||||||
graffiti*: GraffitiBytes
|
graffiti*: GraffitiBytes
|
||||||
proposer_slashings*: List[ProposerSlashing, Limit MAX_PROPOSER_SLASHINGS]
|
proposer_slashings*: List[ProposerSlashing, Limit MAX_PROPOSER_SLASHINGS]
|
||||||
attester_slashings*:
|
attester_slashings*:
|
||||||
List[ElectraAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS_ELECTRA]
|
List[electra.AttesterSlashing, Limit MAX_ATTESTER_SLASHINGS_ELECTRA]
|
||||||
attestations*: List[electra.Attestation, Limit MAX_ATTESTATIONS_ELECTRA]
|
attestations*: List[electra.Attestation, Limit MAX_ATTESTATIONS_ELECTRA]
|
||||||
deposits*: List[Deposit, Limit MAX_DEPOSITS]
|
deposits*: List[Deposit, Limit MAX_DEPOSITS]
|
||||||
voluntary_exits*: List[SignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS]
|
voluntary_exits*: List[SignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS]
|
||||||
|
|
|
@ -208,8 +208,8 @@ func is_slashable_attestation_data(
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#attester-slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#attester-slashings
|
||||||
proc check_attester_slashing*(
|
proc check_attester_slashing*(
|
||||||
state: ForkyBeaconState,
|
state: ForkyBeaconState,
|
||||||
attester_slashing: SomeAttesterSlashing | ElectraAttesterSlashing |
|
attester_slashing: SomeAttesterSlashing | electra.AttesterSlashing |
|
||||||
TrustedElectraAttesterSlashing,
|
electra.TrustedAttesterSlashing,
|
||||||
flags: UpdateFlags): Result[seq[ValidatorIndex], cstring] =
|
flags: UpdateFlags): Result[seq[ValidatorIndex], cstring] =
|
||||||
let
|
let
|
||||||
attestation_1 = attester_slashing.attestation_1
|
attestation_1 = attester_slashing.attestation_1
|
||||||
|
@ -243,8 +243,8 @@ proc check_attester_slashing*(
|
||||||
|
|
||||||
proc check_attester_slashing*(
|
proc check_attester_slashing*(
|
||||||
state: var ForkedHashedBeaconState,
|
state: var ForkedHashedBeaconState,
|
||||||
attester_slashing: SomeAttesterSlashing | ElectraAttesterSlashing |
|
attester_slashing: SomeAttesterSlashing | electra.AttesterSlashing |
|
||||||
TrustedElectraAttesterSlashing,
|
electra.TrustedAttesterSlashing,
|
||||||
flags: UpdateFlags): Result[seq[ValidatorIndex], cstring] =
|
flags: UpdateFlags): Result[seq[ValidatorIndex], cstring] =
|
||||||
withState(state):
|
withState(state):
|
||||||
check_attester_slashing(forkyState.data, attester_slashing, flags)
|
check_attester_slashing(forkyState.data, attester_slashing, flags)
|
||||||
|
@ -253,8 +253,8 @@ proc check_attester_slashing*(
|
||||||
proc process_attester_slashing*(
|
proc process_attester_slashing*(
|
||||||
cfg: RuntimeConfig,
|
cfg: RuntimeConfig,
|
||||||
state: var ForkyBeaconState,
|
state: var ForkyBeaconState,
|
||||||
attester_slashing: SomeAttesterSlashing | ElectraAttesterSlashing |
|
attester_slashing: SomeAttesterSlashing | electra.AttesterSlashing |
|
||||||
TrustedElectraAttesterSlashing,
|
electra.TrustedAttesterSlashing,
|
||||||
flags: UpdateFlags,
|
flags: UpdateFlags,
|
||||||
exit_queue_info: ExitQueueInfo, cache: var StateCache
|
exit_queue_info: ExitQueueInfo, cache: var StateCache
|
||||||
): Result[(Gwei, ExitQueueInfo), cstring] =
|
): Result[(Gwei, ExitQueueInfo), cstring] =
|
||||||
|
@ -1108,7 +1108,8 @@ func process_execution_layer_withdrawal_request*(
|
||||||
compute_exit_epoch_and_update_churn(cfg, state, to_withdraw, cache)
|
compute_exit_epoch_and_update_churn(cfg, state, to_withdraw, cache)
|
||||||
withdrawable_epoch =
|
withdrawable_epoch =
|
||||||
Epoch(exit_queue_epoch + cfg.MIN_VALIDATOR_WITHDRAWABILITY_DELAY)
|
Epoch(exit_queue_epoch + cfg.MIN_VALIDATOR_WITHDRAWABILITY_DELAY)
|
||||||
debugRaiseAssert "check return value of HashList.add"
|
|
||||||
|
# In theory can fail, but failing/early returning here is indistinguishable
|
||||||
discard state.pending_partial_withdrawals.add(PendingPartialWithdrawal(
|
discard state.pending_partial_withdrawals.add(PendingPartialWithdrawal(
|
||||||
index: index.uint64,
|
index: index.uint64,
|
||||||
amount: to_withdraw,
|
amount: to_withdraw,
|
||||||
|
|
|
@ -106,7 +106,7 @@ suite baseDescription & "Attestation " & preset():
|
||||||
suite baseDescription & "Attester Slashing " & preset():
|
suite baseDescription & "Attester Slashing " & preset():
|
||||||
proc applyAttesterSlashing(
|
proc applyAttesterSlashing(
|
||||||
preState: var electra.BeaconState,
|
preState: var electra.BeaconState,
|
||||||
attesterSlashing: ElectraAttesterSlashing): Result[void, cstring] =
|
attesterSlashing: electra.AttesterSlashing): Result[void, cstring] =
|
||||||
var cache: StateCache
|
var cache: StateCache
|
||||||
doAssert (? process_attester_slashing(
|
doAssert (? process_attester_slashing(
|
||||||
defaultRuntimeConfig, preState, attesterSlashing, {},
|
defaultRuntimeConfig, preState, attesterSlashing, {},
|
||||||
|
@ -114,7 +114,7 @@ suite baseDescription & "Attester Slashing " & preset():
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
for path in walkTests(OpAttSlashingDir):
|
for path in walkTests(OpAttSlashingDir):
|
||||||
runTest[ElectraAttesterSlashing, typeof applyAttesterSlashing](
|
runTest[electra.AttesterSlashing, typeof applyAttesterSlashing](
|
||||||
OpAttSlashingDir, suiteName, "Attester Slashing", "attester_slashing",
|
OpAttSlashingDir, suiteName, "Attester Slashing", "attester_slashing",
|
||||||
applyAttesterSlashing, path)
|
applyAttesterSlashing, path)
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ suite "EF - Electra - SSZ consensus objects " & preset():
|
||||||
of "AggregateAndProof": discard # checkSSZ(AggregateAndProof, path, hash)
|
of "AggregateAndProof": discard # checkSSZ(AggregateAndProof, path, hash)
|
||||||
of "Attestation": checkSSZ(electra.Attestation, path, hash)
|
of "Attestation": checkSSZ(electra.Attestation, path, hash)
|
||||||
of "AttestationData": checkSSZ(AttestationData, path, hash)
|
of "AttestationData": checkSSZ(AttestationData, path, hash)
|
||||||
of "AttesterSlashing": checkSSZ(ElectraAttesterSlashing, path, hash)
|
of "AttesterSlashing": checkSSZ(electra.AttesterSlashing, path, hash)
|
||||||
of "BeaconBlock": checkSSZ(electra.BeaconBlock, path, hash)
|
of "BeaconBlock": checkSSZ(electra.BeaconBlock, path, hash)
|
||||||
of "BeaconBlockBody": checkSSZ(electra.BeaconBlockBody, path, hash)
|
of "BeaconBlockBody": checkSSZ(electra.BeaconBlockBody, path, hash)
|
||||||
of "BeaconBlockHeader": checkSSZ(BeaconBlockHeader, path, hash)
|
of "BeaconBlockHeader": checkSSZ(BeaconBlockHeader, path, hash)
|
||||||
|
@ -147,7 +147,7 @@ suite "EF - Electra - SSZ consensus objects " & preset():
|
||||||
of "ForkData": checkSSZ(ForkData, path, hash)
|
of "ForkData": checkSSZ(ForkData, path, hash)
|
||||||
of "HistoricalBatch": checkSSZ(HistoricalBatch, path, hash)
|
of "HistoricalBatch": checkSSZ(HistoricalBatch, path, hash)
|
||||||
of "HistoricalSummary": checkSSZ(HistoricalSummary, path, hash)
|
of "HistoricalSummary": checkSSZ(HistoricalSummary, path, hash)
|
||||||
of "IndexedAttestation": checkSSZ(ElectraIndexedAttestation, path, hash)
|
of "IndexedAttestation": checkSSZ(electra.IndexedAttestation, path, hash)
|
||||||
of "LightClientBootstrap":
|
of "LightClientBootstrap":
|
||||||
checkSSZ(electra.LightClientBootstrap, path, hash)
|
checkSSZ(electra.LightClientBootstrap, path, hash)
|
||||||
of "LightClientHeader": checkSSZ(electra.LightClientHeader, path, hash)
|
of "LightClientHeader": checkSSZ(electra.LightClientHeader, path, hash)
|
||||||
|
|
|
@ -68,13 +68,11 @@ suite "EF - Light client - Single merkle proof" & preset():
|
||||||
continue
|
continue
|
||||||
let objName = path
|
let objName = path
|
||||||
withConsensusFork(fork):
|
withConsensusFork(fork):
|
||||||
debugRaiseAssert ""
|
for kind, path in walkDir(suitePath, relative = true, checkDir = true):
|
||||||
when consensusFork != ConsensusFork.Electra:
|
case objName
|
||||||
for kind, path in walkDir(suitePath, relative = true, checkDir = true):
|
of "BeaconBlockBody":
|
||||||
case objName
|
runTest(suiteName, suitePath/path, consensusFork.BeaconBlockBody)
|
||||||
of "BeaconBlockBody":
|
of "BeaconState":
|
||||||
runTest(suiteName, suitePath/path, consensusFork.BeaconBlockBody)
|
runTest(suiteName, suitePath/path, consensusFork.BeaconState)
|
||||||
of "BeaconState":
|
else:
|
||||||
runTest(suiteName, suitePath/path, consensusFork.BeaconState)
|
raiseAssert "Unknown test object: " & suitePath/path
|
||||||
else:
|
|
||||||
raiseAssert "Unknown test object: " & suitePath/path
|
|
Loading…
Reference in New Issue