rename ElectraIndexedAttestation/ElectraAttesterSlashing for consistency (#6252)

This commit is contained in:
tersec 2024-04-29 02:19:10 +00:00 committed by GitHub
parent abc8bbbf23
commit e70fa6d6de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 35 additions and 39 deletions

View File

@ -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
proc is_valid_indexed_attestation*(
state: ForkyBeaconState,
indexed_attestation: SomeIndexedAttestation | ElectraIndexedAttestation |
TrustedElectraIndexedAttestation,
indexed_attestation: SomeIndexedAttestation | electra.IndexedAttestation |
electra.TrustedIndexedAttestation,
flags: UpdateFlags): Result[void, cstring] =
## Check if ``indexed_attestation`` is not empty, has sorted and unique
## indices and has a valid aggregate signature.

View File

@ -48,9 +48,6 @@ const
CURRENT_SYNC_COMMITTEE_GINDEX = 86.GeneralizedIndex # current_sync_committee
NEXT_SYNC_COMMITTEE_GINDEX = 87.GeneralizedIndex # next_sync_committee
debugRaiseAssert "rename ElectraIndexedAttestation to IndexedAttestation"
debugRaiseAssert "rename ElectraAttesterSlashing to AttesterSlashing"
type
# https://github.com/ethereum/consensus-specs/blob/94a0b6c581f2809aa8aca4ef7ee6fbb63f9d74e9/specs/electra/beacon-chain.md#depositreceipt
DepositReceipt* = object
@ -61,13 +58,13 @@ type
index*: uint64
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/electra/beacon-chain.md#indexedattestation
ElectraIndexedAttestation* = object
IndexedAttestation* = object
attesting_indices*:
List[uint64, Limit MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]
data*: AttestationData
signature*: ValidatorSig
TrustedElectraIndexedAttestation* = object
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
@ -77,11 +74,11 @@ type
signature*: TrustedSig
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/electra/beacon-chain.md#attesterslashing
ElectraAttesterSlashing* = object
attestation_1*: ElectraIndexedAttestation # [Modified in Electra:EIP7549]
attestation_2*: ElectraIndexedAttestation # [Modified in Electra:EIP7549]
AttesterSlashing* = object
attestation_1*: IndexedAttestation # [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.
# 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
@ -461,7 +458,7 @@ type
# Operations
proposer_slashings*: List[ProposerSlashing, Limit MAX_PROPOSER_SLASHINGS]
attester_slashings*:
List[ElectraAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS_ELECTRA]
List[AttesterSlashing, Limit MAX_ATTESTER_SLASHINGS_ELECTRA]
## [Modified in Electra:EIP7549]
attestations*: List[electra.Attestation, Limit MAX_ATTESTATIONS_ELECTRA]
## [Modified in Electra:EIP7549]
@ -502,7 +499,7 @@ type
proposer_slashings*:
List[TrustedProposerSlashing, Limit MAX_PROPOSER_SLASHINGS]
attester_slashings*:
List[TrustedElectraAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS_ELECTRA]
List[TrustedAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS_ELECTRA]
## [Modified in Electra:EIP7549]
attestations*: List[TrustedAttestation, Limit MAX_ATTESTATIONS_ELECTRA]
## [Modified in Electra:EIP7549]
@ -531,7 +528,7 @@ type
proposer_slashings*:
List[TrustedProposerSlashing, Limit MAX_PROPOSER_SLASHINGS]
attester_slashings*:
List[TrustedElectraAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS_ELECTRA]
List[TrustedAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS_ELECTRA]
## [Modified in Electra:EIP7549]
attestations*: List[TrustedAttestation, Limit MAX_ATTESTATIONS_ELECTRA]
## [Modified in Electra:EIP7549]
@ -708,7 +705,7 @@ debugRaiseAssert "this whole section with getValidatorIndices/shortLog needs ref
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_2(): auto = attester_slashing.attestation_2

View File

@ -247,14 +247,14 @@ RestJson.useDefaultSerializationFor(
deneb_mev.SignedBlindedBeaconBlock,
deneb_mev.SignedBuilderBid,
electra.Attestation,
ElectraAttesterSlashing,
electra.AttesterSlashing,
electra.BeaconBlock,
electra.BeaconState,
electra.BeaconBlockBody,
electra.BlockContents,
electra.ExecutionPayload,
electra.ExecutionPayloadHeader,
ElectraIndexedAttestation,
electra.IndexedAttestation,
electra.SignedBeaconBlock,
electra.TrustedAttestation,
electra_mev.BlindedBeaconBlock,

View File

@ -34,7 +34,7 @@ type
graffiti*: GraffitiBytes
proposer_slashings*: List[ProposerSlashing, Limit MAX_PROPOSER_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]
deposits*: List[Deposit, Limit MAX_DEPOSITS]
voluntary_exits*: List[SignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS]

View File

@ -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
proc check_attester_slashing*(
state: ForkyBeaconState,
attester_slashing: SomeAttesterSlashing | ElectraAttesterSlashing |
TrustedElectraAttesterSlashing,
attester_slashing: SomeAttesterSlashing | electra.AttesterSlashing |
electra.TrustedAttesterSlashing,
flags: UpdateFlags): Result[seq[ValidatorIndex], cstring] =
let
attestation_1 = attester_slashing.attestation_1
@ -243,8 +243,8 @@ proc check_attester_slashing*(
proc check_attester_slashing*(
state: var ForkedHashedBeaconState,
attester_slashing: SomeAttesterSlashing | ElectraAttesterSlashing |
TrustedElectraAttesterSlashing,
attester_slashing: SomeAttesterSlashing | electra.AttesterSlashing |
electra.TrustedAttesterSlashing,
flags: UpdateFlags): Result[seq[ValidatorIndex], cstring] =
withState(state):
check_attester_slashing(forkyState.data, attester_slashing, flags)
@ -253,8 +253,8 @@ proc check_attester_slashing*(
proc process_attester_slashing*(
cfg: RuntimeConfig,
state: var ForkyBeaconState,
attester_slashing: SomeAttesterSlashing | ElectraAttesterSlashing |
TrustedElectraAttesterSlashing,
attester_slashing: SomeAttesterSlashing | electra.AttesterSlashing |
electra.TrustedAttesterSlashing,
flags: UpdateFlags,
exit_queue_info: ExitQueueInfo, cache: var StateCache
): 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)
withdrawable_epoch =
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(
index: index.uint64,
amount: to_withdraw,

View File

@ -106,7 +106,7 @@ suite baseDescription & "Attestation " & preset():
suite baseDescription & "Attester Slashing " & preset():
proc applyAttesterSlashing(
preState: var electra.BeaconState,
attesterSlashing: ElectraAttesterSlashing): Result[void, cstring] =
attesterSlashing: electra.AttesterSlashing): Result[void, cstring] =
var cache: StateCache
doAssert (? process_attester_slashing(
defaultRuntimeConfig, preState, attesterSlashing, {},
@ -114,7 +114,7 @@ suite baseDescription & "Attester Slashing " & preset():
ok()
for path in walkTests(OpAttSlashingDir):
runTest[ElectraAttesterSlashing, typeof applyAttesterSlashing](
runTest[electra.AttesterSlashing, typeof applyAttesterSlashing](
OpAttSlashingDir, suiteName, "Attester Slashing", "attester_slashing",
applyAttesterSlashing, path)

View File

@ -121,7 +121,7 @@ suite "EF - Electra - SSZ consensus objects " & preset():
of "AggregateAndProof": discard # checkSSZ(AggregateAndProof, path, hash)
of "Attestation": checkSSZ(electra.Attestation, 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 "BeaconBlockBody": checkSSZ(electra.BeaconBlockBody, 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 "HistoricalBatch": checkSSZ(HistoricalBatch, path, hash)
of "HistoricalSummary": checkSSZ(HistoricalSummary, path, hash)
of "IndexedAttestation": checkSSZ(ElectraIndexedAttestation, path, hash)
of "IndexedAttestation": checkSSZ(electra.IndexedAttestation, path, hash)
of "LightClientBootstrap":
checkSSZ(electra.LightClientBootstrap, path, hash)
of "LightClientHeader": checkSSZ(electra.LightClientHeader, path, hash)

View File

@ -68,13 +68,11 @@ suite "EF - Light client - Single merkle proof" & preset():
continue
let objName = path
withConsensusFork(fork):
debugRaiseAssert ""
when consensusFork != ConsensusFork.Electra:
for kind, path in walkDir(suitePath, relative = true, checkDir = true):
case objName
of "BeaconBlockBody":
runTest(suiteName, suitePath/path, consensusFork.BeaconBlockBody)
of "BeaconState":
runTest(suiteName, suitePath/path, consensusFork.BeaconState)
else:
raiseAssert "Unknown test object: " & suitePath/path
for kind, path in walkDir(suitePath, relative = true, checkDir = true):
case objName
of "BeaconBlockBody":
runTest(suiteName, suitePath/path, consensusFork.BeaconBlockBody)
of "BeaconState":
runTest(suiteName, suitePath/path, consensusFork.BeaconState)
else:
raiseAssert "Unknown test object: " & suitePath/path