Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename ElectraIndexedAttestation/ElectraAttesterSlashing for consistency #6252

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions beacon_chain/spec/beaconstate.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 10 additions & 13 deletions beacon_chain/spec/datatypes/electra.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/spec/mev/electra_mev.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
15 changes: 8 additions & 7 deletions beacon_chain/spec/state_transition_block.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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] =
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/consensus_spec/electra/test_fixture_operations.nim
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ 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, {},
get_state_exit_queue_info(preState), cache))[0] > 0.Gwei
ok()

for path in walkTests(OpAttSlashingDir):
runTest[ElectraAttesterSlashing, typeof applyAttesterSlashing](
runTest[electra.AttesterSlashing, typeof applyAttesterSlashing](
OpAttSlashingDir, suiteName, "Attester Slashing", "attester_slashing",
applyAttesterSlashing, path)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading