From d139c92df9ace7f41a03d4d99d8cd16ed94d7198 Mon Sep 17 00:00:00 2001 From: tersec Date: Sun, 21 Apr 2024 05:49:11 +0000 Subject: [PATCH] explicitly scope AttesterSlashing and IndexedAttestation types to phase0 (#6224) --- beacon_chain/beacon_node.nim | 2 +- .../validator_change_pool.nim | 14 ++++++++------ beacon_chain/gossip_processing/eth2_processor.nim | 2 +- .../gossip_processing/gossip_validation.nim | 2 +- beacon_chain/networking/eth2_network.nim | 4 ++-- beacon_chain/nimbus_beacon_node.nim | 4 ++-- beacon_chain/rpc/rest_beacon_api.nim | 2 +- beacon_chain/spec/datatypes/capella.nim | 12 ++++++++---- beacon_chain/spec/datatypes/deneb.nim | 9 ++++++--- .../spec/eth2_apis/eth2_rest_serialization.nim | 11 ++++++----- beacon_chain/spec/eth2_apis/rest_beacon_calls.nim | 3 ++- beacon_chain/spec/eth2_apis/rest_types.nim | 3 ++- beacon_chain/validators/message_router.nim | 2 +- beacon_chain/validators/validator_monitor.nim | 3 ++- ncli/ncli.nim | 2 +- nfuzz/libnfuzz.nim | 2 +- .../altair/test_fixture_operations.nim | 6 +++--- .../bellatrix/test_fixture_operations.nim | 6 +++--- .../test_fixture_ssz_consensus_objects.nim | 7 ++++--- .../phase0/test_fixture_operations.nim | 6 +++--- tests/consensus_spec/test_fixture_fork_choice.nim | 4 ++-- tests/test_toblindedblock.nim | 3 ++- tests/test_validator_change_pool.nim | 12 +++++++----- 23 files changed, 69 insertions(+), 52 deletions(-) diff --git a/beacon_chain/beacon_node.nim b/beacon_chain/beacon_node.nim index e54406176..71c3ab6d4 100644 --- a/beacon_chain/beacon_node.nim +++ b/beacon_chain/beacon_node.nim @@ -48,7 +48,7 @@ type exitQueue*: AsyncEventQueue[SignedVoluntaryExit] blsToExecQueue*: AsyncEventQueue[SignedBLSToExecutionChange] propSlashQueue*: AsyncEventQueue[ProposerSlashing] - attSlashQueue*: AsyncEventQueue[AttesterSlashing] + attSlashQueue*: AsyncEventQueue[phase0.AttesterSlashing] blobSidecarQueue*: AsyncEventQueue[BlobSidecarInfoObject] finalQueue*: AsyncEventQueue[FinalizationInfoObject] reorgQueue*: AsyncEventQueue[ReorgInfoObject] diff --git a/beacon_chain/consensus_object_pools/validator_change_pool.nim b/beacon_chain/consensus_object_pools/validator_change_pool.nim index 418821f98..e369be853 100644 --- a/beacon_chain/consensus_object_pools/validator_change_pool.nim +++ b/beacon_chain/consensus_object_pools/validator_change_pool.nim @@ -35,14 +35,14 @@ type OnProposerSlashingCallback = proc(data: ProposerSlashing) {.gcsafe, raises: [].} OnAttesterSlashingCallback = - proc(data: AttesterSlashing) {.gcsafe, raises: [].} + proc(data: phase0.AttesterSlashing) {.gcsafe, raises: [].} ValidatorChangePool* = object ## The validator change pool tracks attester slashings, proposer slashings, ## voluntary exits, and BLS to execution changes that could be added to a ## proposed block. - attester_slashings*: Deque[AttesterSlashing] ## \ + attester_slashings*: Deque[phase0.AttesterSlashing] ## \ ## Not a function of chain DAG branch; just used as a FIFO queue for blocks proposer_slashings*: Deque[ProposerSlashing] ## \ @@ -86,7 +86,8 @@ func init*(T: type ValidatorChangePool, dag: ChainDAGRef, T( # Allow filtering some validator change messages during block production attester_slashings: - initDeque[AttesterSlashing](initialSize = ATTESTER_SLASHINGS_BOUND.int), + initDeque[phase0.AttesterSlashing]( + initialSize = ATTESTER_SLASHINGS_BOUND.int), proposer_slashings: initDeque[ProposerSlashing](initialSize = PROPOSER_SLASHINGS_BOUND.int), voluntary_exits: @@ -132,7 +133,7 @@ iterator getValidatorIndices( bls_to_execution_change: SignedBLSToExecutionChange): uint64 = yield bls_to_execution_change.message.validator_index -func isSeen*(pool: ValidatorChangePool, msg: AttesterSlashing): bool = +func isSeen*(pool: ValidatorChangePool, msg: phase0.AttesterSlashing): bool = for idx in getValidatorIndices(msg): # One index is enough! if idx notin pool.prior_seen_attester_slashed_indices: @@ -150,7 +151,7 @@ func isSeen*(pool: ValidatorChangePool, msg: SignedBLSToExecutionChange): bool = msg.message.validator_index in pool.prior_seen_bls_to_execution_change_indices -func addMessage*(pool: var ValidatorChangePool, msg: AttesterSlashing) = +func addMessage*(pool: var ValidatorChangePool, msg: phase0.AttesterSlashing) = for idx in getValidatorIndices(msg): pool.prior_seen_attester_slashed_indices.incl idx if pool.attestationPool != nil: @@ -191,7 +192,8 @@ proc validateValidatorChangeMessage( cfg: RuntimeConfig, state: ForkyBeaconState, msg: ProposerSlashing): bool = check_proposer_slashing(state, msg, {}).isOk proc validateValidatorChangeMessage( - cfg: RuntimeConfig, state: ForkyBeaconState, msg: AttesterSlashing): bool = + cfg: RuntimeConfig, state: ForkyBeaconState, msg: + phase0.AttesterSlashing): bool = check_attester_slashing(state, msg, {}).isOk proc validateValidatorChangeMessage( cfg: RuntimeConfig, state: ForkyBeaconState, msg: SignedVoluntaryExit): diff --git a/beacon_chain/gossip_processing/eth2_processor.nim b/beacon_chain/gossip_processing/eth2_processor.nim index c00b735e8..7410b23cc 100644 --- a/beacon_chain/gossip_processing/eth2_processor.nim +++ b/beacon_chain/gossip_processing/eth2_processor.nim @@ -493,7 +493,7 @@ proc processBlsToExecutionChange*( proc processAttesterSlashing*( self: var Eth2Processor, src: MsgSource, - attesterSlashing: AttesterSlashing): ValidationRes = + attesterSlashing: phase0.AttesterSlashing): ValidationRes = logScope: attesterSlashing = shortLog(attesterSlashing) diff --git a/beacon_chain/gossip_processing/gossip_validation.nim b/beacon_chain/gossip_processing/gossip_validation.nim index 84ee3f8cb..b5ff84485 100644 --- a/beacon_chain/gossip_processing/gossip_validation.nim +++ b/beacon_chain/gossip_processing/gossip_validation.nim @@ -1087,7 +1087,7 @@ proc validateBlsToExecutionChange*( # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#attester_slashing proc validateAttesterSlashing*( - pool: ValidatorChangePool, attester_slashing: AttesterSlashing): + pool: ValidatorChangePool, attester_slashing: phase0.AttesterSlashing): Result[void, ValidationError] = # [IGNORE] At least one index in the intersection of the attesting indices of # each attestation has not yet been seen in any prior attester_slashing (i.e. diff --git a/beacon_chain/networking/eth2_network.nim b/beacon_chain/networking/eth2_network.nim index c24c19c7e..9f0ac16ac 100644 --- a/beacon_chain/networking/eth2_network.nim +++ b/beacon_chain/networking/eth2_network.nim @@ -837,7 +837,7 @@ template gossipMaxSize(T: untyped): uint32 = # Attestation, AttesterSlashing, and SignedAggregateAndProof, which all # have lists bounded at MAX_VALIDATORS_PER_COMMITTEE (2048) items, thus # having max sizes significantly smaller than GOSSIP_MAX_SIZE. - elif T is phase0.Attestation or T is AttesterSlashing or + elif T is phase0.Attestation or T is phase0.AttesterSlashing or T is SignedAggregateAndProof or T is phase0.SignedBeaconBlock or T is altair.SignedBeaconBlock or T is SomeForkyLightClientObject: GOSSIP_MAX_SIZE @@ -2585,7 +2585,7 @@ proc broadcastVoluntaryExit*( node.broadcast(topic, exit) proc broadcastAttesterSlashing*( - node: Eth2Node, slashing: AttesterSlashing): + node: Eth2Node, slashing: phase0.AttesterSlashing): Future[SendResult] {.async: (raises: [CancelledError], raw: true).} = let topic = getAttesterSlashingsTopic( node.forkDigestAtEpoch(node.getWallEpoch)) diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index d686a8682..1c7fb2139 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -287,7 +287,7 @@ proc initFullNode( node.eventBus.blsToExecQueue.emit(data) proc onProposerSlashingAdded(data: ProposerSlashing) = node.eventBus.propSlashQueue.emit(data) - proc onAttesterSlashingAdded(data: AttesterSlashing) = + proc onAttesterSlashingAdded(data: phase0.AttesterSlashing) = node.eventBus.attSlashQueue.emit(data) proc onBlobSidecarAdded(data: BlobSidecar) = node.eventBus.blobSidecarQueue.emit( @@ -1773,7 +1773,7 @@ proc installMessageValidators(node: BeaconNode) = # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#attester_slashing node.network.addValidator( getAttesterSlashingsTopic(digest), proc ( - attesterSlashing: AttesterSlashing + attesterSlashing: phase0.AttesterSlashing ): ValidationResult = toValidationResult( node.processor[].processAttesterSlashing( diff --git a/beacon_chain/rpc/rest_beacon_api.nim b/beacon_chain/rpc/rest_beacon_api.nim index 404ec62e9..60444a14e 100644 --- a/beacon_chain/rpc/rest_beacon_api.nim +++ b/beacon_chain/rpc/rest_beacon_api.nim @@ -1257,7 +1257,7 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) = block: if contentBody.isNone(): return RestApiResponse.jsonError(Http400, EmptyRequestBodyError) - let dres = decodeBody(AttesterSlashing, contentBody.get()) + let dres = decodeBody(phase0.AttesterSlashing, contentBody.get()) if dres.isErr(): return RestApiResponse.jsonError(Http400, InvalidAttesterSlashingObjectError, diff --git a/beacon_chain/spec/datatypes/capella.nim b/beacon_chain/spec/datatypes/capella.nim index 4d5630f44..3b0aaeac5 100644 --- a/beacon_chain/spec/datatypes/capella.nim +++ b/beacon_chain/spec/datatypes/capella.nim @@ -368,7 +368,8 @@ type # Operations proposer_slashings*: List[ProposerSlashing, Limit MAX_PROPOSER_SLASHINGS] - attester_slashings*: List[AttesterSlashing, Limit MAX_ATTESTER_SLASHINGS] + attester_slashings*: + List[phase0.AttesterSlashing, Limit MAX_ATTESTER_SLASHINGS] attestations*: List[Attestation, Limit MAX_ATTESTATIONS] deposits*: List[Deposit, Limit MAX_DEPOSITS] voluntary_exits*: List[SignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS] @@ -405,7 +406,8 @@ type # Operations proposer_slashings*: List[TrustedProposerSlashing, Limit MAX_PROPOSER_SLASHINGS] - attester_slashings*: List[TrustedAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS] + attester_slashings*: + List[phase0.TrustedAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS] attestations*: List[TrustedAttestation, Limit MAX_ATTESTATIONS] deposits*: List[Deposit, Limit MAX_DEPOSITS] voluntary_exits*: List[TrustedSignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS] @@ -429,7 +431,8 @@ type # Operations proposer_slashings*: List[TrustedProposerSlashing, Limit MAX_PROPOSER_SLASHINGS] - attester_slashings*: List[TrustedAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS] + attester_slashings*: + List[phase0.TrustedAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS] attestations*: List[TrustedAttestation, Limit MAX_ATTESTATIONS] deposits*: List[Deposit, Limit MAX_DEPOSITS] voluntary_exits*: List[TrustedSignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS] @@ -497,7 +500,8 @@ type BeaconBlockValidatorChanges* = object # Collection of exits that are suitable for block production proposer_slashings*: List[ProposerSlashing, Limit MAX_PROPOSER_SLASHINGS] - attester_slashings*: List[AttesterSlashing, Limit MAX_ATTESTER_SLASHINGS] + attester_slashings*: + List[phase0.AttesterSlashing, Limit MAX_ATTESTER_SLASHINGS] voluntary_exits*: List[SignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS] bls_to_execution_changes*: List[SignedBLSToExecutionChange, Limit MAX_BLS_TO_EXECUTION_CHANGES] diff --git a/beacon_chain/spec/datatypes/deneb.nim b/beacon_chain/spec/datatypes/deneb.nim index 160e3ddd6..d94ed7e69 100644 --- a/beacon_chain/spec/datatypes/deneb.nim +++ b/beacon_chain/spec/datatypes/deneb.nim @@ -393,7 +393,8 @@ type # Operations proposer_slashings*: List[ProposerSlashing, Limit MAX_PROPOSER_SLASHINGS] - attester_slashings*: List[AttesterSlashing, Limit MAX_ATTESTER_SLASHINGS] + attester_slashings*: + List[phase0.AttesterSlashing, Limit MAX_ATTESTER_SLASHINGS] attestations*: List[Attestation, Limit MAX_ATTESTATIONS] deposits*: List[Deposit, Limit MAX_DEPOSITS] voluntary_exits*: List[SignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS] @@ -428,7 +429,8 @@ type # Operations proposer_slashings*: List[TrustedProposerSlashing, Limit MAX_PROPOSER_SLASHINGS] - attester_slashings*: List[TrustedAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS] + attester_slashings*: + List[phase0.TrustedAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS] attestations*: List[TrustedAttestation, Limit MAX_ATTESTATIONS] deposits*: List[Deposit, Limit MAX_DEPOSITS] voluntary_exits*: List[TrustedSignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS] @@ -451,7 +453,8 @@ type # Operations proposer_slashings*: List[TrustedProposerSlashing, Limit MAX_PROPOSER_SLASHINGS] - attester_slashings*: List[TrustedAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS] + attester_slashings*: + List[phase0.TrustedAttesterSlashing, Limit MAX_ATTESTER_SLASHINGS] attestations*: List[TrustedAttestation, Limit MAX_ATTESTATIONS] deposits*: List[Deposit, Limit MAX_DEPOSITS] voluntary_exits*: List[TrustedSignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS] diff --git a/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim b/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim index 4c3b5074a..17d136252 100644 --- a/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim +++ b/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim @@ -46,7 +46,6 @@ createJsonFlavor RestJson RestJson.useDefaultSerializationFor( AggregateAndProof, AttestationData, - AttesterSlashing, BLSToExecutionChange, BeaconBlockHeader, BlobSidecar, @@ -107,7 +106,6 @@ RestJson.useDefaultSerializationFor( HistoricalSummary, ImportDistributedKeystoresBody, ImportRemoteKeystoresBody, - IndexedAttestation, KeymanagerGenericError, KeystoreInfo, ListFeeRecipientResponse, @@ -262,9 +260,11 @@ RestJson.useDefaultSerializationFor( electra_mev.SignedBlindedBeaconBlock, electra_mev.SignedBuilderBid, phase0.Attestation, + phase0.AttesterSlashing, phase0.BeaconBlock, phase0.BeaconBlockBody, phase0.BeaconState, + phase0.IndexedAttestation, phase0.SignedBeaconBlock, phase0.TrustedAttestation ) @@ -323,7 +323,6 @@ const type EncodeTypes* = - AttesterSlashing | BlobSidecarInfoObject | DeleteKeystoresBody | EmptyBody | @@ -338,6 +337,7 @@ type capella_mev.SignedBlindedBeaconBlock | deneb_mev.SignedBlindedBeaconBlock | electra_mev.SignedBlindedBeaconBlock | + phase0.AttesterSlashing | SignedValidatorRegistrationV1 | SignedVoluntaryExit | Web3SignerRequest | @@ -1709,7 +1709,7 @@ proc readValue*(reader: var JsonReader[RestJson], proposer_slashings: Opt[List[ProposerSlashing, Limit MAX_PROPOSER_SLASHINGS]] attester_slashings: - Opt[List[AttesterSlashing, Limit MAX_ATTESTER_SLASHINGS]] + Opt[List[phase0.AttesterSlashing, Limit MAX_ATTESTER_SLASHINGS]] attestations: Opt[List[phase0.Attestation, Limit MAX_ATTESTATIONS]] deposits: Opt[List[Deposit, Limit MAX_DEPOSITS]] voluntary_exits: Opt[List[SignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS]] @@ -1748,7 +1748,8 @@ proc readValue*(reader: var JsonReader[RestJson], "Multiple `attester_slashings` fields found", "RestPublishedBeaconBlockBody") attester_slashings = Opt.some( - reader.readValue(List[AttesterSlashing, Limit MAX_ATTESTER_SLASHINGS])) + reader.readValue( + List[phase0.AttesterSlashing, Limit MAX_ATTESTER_SLASHINGS])) of "attestations": if attestations.isSome(): reader.raiseUnexpectedField("Multiple `attestations` fields found", diff --git a/beacon_chain/spec/eth2_apis/rest_beacon_calls.nim b/beacon_chain/spec/eth2_apis/rest_beacon_calls.nim index 62724e382..370b3dff5 100644 --- a/beacon_chain/spec/eth2_apis/rest_beacon_calls.nim +++ b/beacon_chain/spec/eth2_apis/rest_beacon_calls.nim @@ -332,7 +332,8 @@ proc getPoolAttesterSlashings*(): RestResponse[GetPoolAttesterSlashingsResponse] meth: MethodGet.} ## https://ethereum.github.io/beacon-APIs/#/Beacon/getPoolAttesterSlashings -proc submitPoolAttesterSlashings*(body: AttesterSlashing): RestPlainResponse {. +proc submitPoolAttesterSlashings*(body: phase0.AttesterSlashing): + RestPlainResponse {. rest, endpoint: "/eth/v1/beacon/pool/attester_slashings", meth: MethodPost.} ## https://ethereum.github.io/beacon-APIs/#/Beacon/submitPoolAttesterSlashings diff --git a/beacon_chain/spec/eth2_apis/rest_types.nim b/beacon_chain/spec/eth2_apis/rest_types.nim index 06f537094..2691b063b 100644 --- a/beacon_chain/spec/eth2_apis/rest_types.nim +++ b/beacon_chain/spec/eth2_apis/rest_types.nim @@ -554,7 +554,8 @@ type GetPeerResponse* = DataMetaEnclosedObject[RestNodePeer] GetPeersResponse* = DataMetaEnclosedObject[seq[RestNodePeer]] GetPoolAttestationsResponse* = DataEnclosedObject[seq[phase0.Attestation]] - GetPoolAttesterSlashingsResponse* = DataEnclosedObject[seq[AttesterSlashing]] + GetPoolAttesterSlashingsResponse* = + DataEnclosedObject[seq[phase0.AttesterSlashing]] GetPoolProposerSlashingsResponse* = DataEnclosedObject[seq[ProposerSlashing]] GetPoolVoluntaryExitsResponse* = DataEnclosedObject[seq[SignedVoluntaryExit]] GetProposerDutiesResponse* = DataRootEnclosedObject[seq[RestProposerDuty]] diff --git a/beacon_chain/validators/message_router.nim b/beacon_chain/validators/message_router.nim index 30d630a64..50a6ec059 100644 --- a/beacon_chain/validators/message_router.nim +++ b/beacon_chain/validators/message_router.nim @@ -468,7 +468,7 @@ proc routeSignedVoluntaryExit*( return ok() proc routeAttesterSlashing*( - router: ref MessageRouter, slashing: AttesterSlashing): + router: ref MessageRouter, slashing: phase0.AttesterSlashing): Future[SendResult] {.async: (raises: [CancelledError]).} = block: let res = diff --git a/beacon_chain/validators/validator_monitor.nim b/beacon_chain/validators/validator_monitor.nim index 7ebb9b3e2..bc7c79696 100644 --- a/beacon_chain/validators/validator_monitor.nim +++ b/beacon_chain/validators/validator_monitor.nim @@ -884,7 +884,8 @@ proc registerProposerSlashing*( epochSummary.proposer_slashings += 1 proc registerAttesterSlashing*( - self: var ValidatorMonitor, src: MsgSource, slashing: AttesterSlashing) = + self: var ValidatorMonitor, src: MsgSource, + slashing: phase0.AttesterSlashing) = let data = slashing.attestation_1.data for idx in slashing.attestation_2.attesting_indices: diff --git a/ncli/ncli.nim b/ncli/ncli.nim index 2ceefbcb1..25d3dd123 100644 --- a/ncli/ncli.nim +++ b/ncli/ncli.nim @@ -232,7 +232,7 @@ proc doSSZ(conf: NcliConf) = printTimers(false, timers) case kind - of "attester_slashing": printit(AttesterSlashing) + of "attester_slashing": printit(phase0.AttesterSlashing) of "attestation": printit(phase0.Attestation) of "phase0_signed_block": printit(phase0.SignedBeaconBlock) of "altair_signed_block": printit(altair.SignedBeaconBlock) diff --git a/nfuzz/libnfuzz.nim b/nfuzz/libnfuzz.nim index 7b9565e41..102ee1b5b 100644 --- a/nfuzz/libnfuzz.nim +++ b/nfuzz/libnfuzz.nim @@ -24,7 +24,7 @@ type attestation: phase0.Attestation AttesterSlashingInput = object state: phase0.BeaconState - attesterSlashing: AttesterSlashing + attesterSlashing: phase0.AttesterSlashing BlockInput = object state: phase0.BeaconState beaconBlock: phase0.SignedBeaconBlock diff --git a/tests/consensus_spec/altair/test_fixture_operations.nim b/tests/consensus_spec/altair/test_fixture_operations.nim index 6565a876a..7187e1eb0 100644 --- a/tests/consensus_spec/altair/test_fixture_operations.nim +++ b/tests/consensus_spec/altair/test_fixture_operations.nim @@ -91,8 +91,8 @@ suite baseDescription & "Attestation " & preset(): suite baseDescription & "Attester Slashing " & preset(): proc applyAttesterSlashing( - preState: var altair.BeaconState, attesterSlashing: AttesterSlashing): - Result[void, cstring] = + preState: var altair.BeaconState, + attesterSlashing: phase0.AttesterSlashing): Result[void, cstring] = var cache: StateCache doAssert (? process_attester_slashing( defaultRuntimeConfig, preState, attesterSlashing, {strictVerification}, @@ -100,7 +100,7 @@ suite baseDescription & "Attester Slashing " & preset(): ok() for path in walkTests(OpAttSlashingDir): - runTest[AttesterSlashing, typeof applyAttesterSlashing]( + runTest[phase0.AttesterSlashing, typeof applyAttesterSlashing]( OpAttSlashingDir, suiteName, "Attester Slashing", "attester_slashing", applyAttesterSlashing, path) diff --git a/tests/consensus_spec/bellatrix/test_fixture_operations.nim b/tests/consensus_spec/bellatrix/test_fixture_operations.nim index 7ba569c4b..16aecc9d8 100644 --- a/tests/consensus_spec/bellatrix/test_fixture_operations.nim +++ b/tests/consensus_spec/bellatrix/test_fixture_operations.nim @@ -97,8 +97,8 @@ suite baseDescription & "Attestation " & preset(): suite baseDescription & "Attester Slashing " & preset(): proc applyAttesterSlashing( - preState: var bellatrix.BeaconState, attesterSlashing: AttesterSlashing): - Result[void, cstring] = + preState: var bellatrix.BeaconState, + attesterSlashing: phase0.AttesterSlashing): Result[void, cstring] = var cache: StateCache doAssert (? process_attester_slashing( defaultRuntimeConfig, preState, attesterSlashing, {strictVerification}, @@ -106,7 +106,7 @@ suite baseDescription & "Attester Slashing " & preset(): ok() for path in walkTests(OpAttSlashingDir): - runTest[AttesterSlashing, typeof applyAttesterSlashing]( + runTest[phase0.AttesterSlashing, typeof applyAttesterSlashing]( OpAttSlashingDir, suiteName, "Attester Slashing", "attester_slashing", applyAttesterSlashing, path) diff --git a/tests/consensus_spec/bellatrix/test_fixture_ssz_consensus_objects.nim b/tests/consensus_spec/bellatrix/test_fixture_ssz_consensus_objects.nim index 6d097b75d..db028599a 100644 --- a/tests/consensus_spec/bellatrix/test_fixture_ssz_consensus_objects.nim +++ b/tests/consensus_spec/bellatrix/test_fixture_ssz_consensus_objects.nim @@ -111,7 +111,7 @@ suite "EF - Bellatrix - SSZ consensus objects " & preset(): of "AggregateAndProof": checkSSZ(AggregateAndProof, path, hash) of "Attestation": checkSSZ(Attestation, path, hash) of "AttestationData": checkSSZ(AttestationData, path, hash) - of "AttesterSlashing": checkSSZ(AttesterSlashing, path, hash) + of "AttesterSlashing": checkSSZ(phase0.AttesterSlashing, path, hash) of "BeaconBlock": checkSSZ(bellatrix.BeaconBlock, path, hash) of "BeaconBlockBody": checkSSZ(bellatrix.BeaconBlockBody, path, hash) of "BeaconBlockHeader": checkSSZ(BeaconBlockHeader, path, hash) @@ -129,7 +129,8 @@ suite "EF - Bellatrix - SSZ consensus objects " & preset(): of "Fork": checkSSZ(Fork, path, hash) of "ForkData": checkSSZ(ForkData, path, hash) of "HistoricalBatch": checkSSZ(HistoricalBatch, path, hash) - of "IndexedAttestation": checkSSZ(IndexedAttestation, path, hash) + of "IndexedAttestation": + checkSSZ(phase0.IndexedAttestation, path, hash) of "LightClientBootstrap": checkSSZ(altair.LightClientBootstrap, path, hash) of "LightClientHeader": @@ -163,4 +164,4 @@ suite "EF - Bellatrix - SSZ consensus objects " & preset(): of "Validator": checkSSZ(Validator, path, hash) of "VoluntaryExit": checkSSZ(VoluntaryExit, path, hash) else: - raise newException(ValueError, "Unsupported test: " & sszType) + raise newException(ValueError, "Unsupported test: " & sszType) \ No newline at end of file diff --git a/tests/consensus_spec/phase0/test_fixture_operations.nim b/tests/consensus_spec/phase0/test_fixture_operations.nim index aeefa9bd3..7a6cb1d93 100644 --- a/tests/consensus_spec/phase0/test_fixture_operations.nim +++ b/tests/consensus_spec/phase0/test_fixture_operations.nim @@ -82,8 +82,8 @@ suite baseDescription & "Attestation " & preset(): suite baseDescription & "Attester Slashing " & preset(): proc applyAttesterSlashing( - preState: var phase0.BeaconState, attesterSlashing: AttesterSlashing): - Result[void, cstring] = + preState: var phase0.BeaconState, + attesterSlashing: phase0.AttesterSlashing): Result[void, cstring] = var cache: StateCache doAssert (? process_attester_slashing( defaultRuntimeConfig, preState, attesterSlashing, {strictVerification}, @@ -91,7 +91,7 @@ suite baseDescription & "Attester Slashing " & preset(): ok() for path in walkTests(OpAttSlashingDir): - runTest[AttesterSlashing, typeof applyAttesterSlashing]( + runTest[phase0.AttesterSlashing, typeof applyAttesterSlashing]( OpAttSlashingDir, suiteName, "Attester Slashing", "attester_slashing", applyAttesterSlashing, path) diff --git a/tests/consensus_spec/test_fixture_fork_choice.nim b/tests/consensus_spec/test_fixture_fork_choice.nim index 05e90faff..849e2276c 100644 --- a/tests/consensus_spec/test_fixture_fork_choice.nim +++ b/tests/consensus_spec/test_fixture_fork_choice.nim @@ -62,7 +62,7 @@ type of opOnMergeBlock: powBlock: PowBlock of opOnAttesterSlashing: - attesterSlashing: AttesterSlashing + attesterSlashing: phase0.AttesterSlashing of opInvalidateHash: invalidatedHash: Eth2Digest latestValidHash: Eth2Digest @@ -151,7 +151,7 @@ proc loadOps( let filename = step["attester_slashing"].getStr() let attesterSlashing = parseTest( path/filename & ".ssz_snappy", - SSZ, AttesterSlashing + SSZ, phase0.AttesterSlashing ) result.add Operation(kind: opOnAttesterSlashing, attesterSlashing: attesterSlashing) diff --git a/tests/test_toblindedblock.nim b/tests/test_toblindedblock.nim index 646220835..50d8900bd 100644 --- a/tests/test_toblindedblock.nim +++ b/tests/test_toblindedblock.nim @@ -53,7 +53,8 @@ template bellatrix_steps() = do_check check: b.message.body.proposer_slashings.add(default(ProposerSlashing)) do_check - check: b.message.body.attester_slashings.add(default(AttesterSlashing)) + check: + b.message.body.attester_slashings.add(default(phase0.AttesterSlashing)) do_check check: b.message.body.attestations.add( phase0.Attestation(aggregation_bits: CommitteeValidatorsBits.init(1))) diff --git a/tests/test_validator_change_pool.nim b/tests/test_validator_change_pool.nim index 065c9ebcb..b78aa8cfc 100644 --- a/tests/test_validator_change_pool.nim +++ b/tests/test_validator_change_pool.nim @@ -29,12 +29,14 @@ func makeSignedBeaconBlockHeader( func makeIndexedAttestation( fork: Fork, genesis_validators_root: Eth2Digest, slot: Slot, - validator_index: uint64, beacon_block_root: Eth2Digest): IndexedAttestation = + validator_index: uint64, beacon_block_root: Eth2Digest): + phase0.IndexedAttestation = let tmp = AttestationData(slot: slot, beacon_block_root: beacon_block_root) - IndexedAttestation( + phase0.IndexedAttestation( data: tmp, - attesting_indices: List[uint64, Limit MAX_VALIDATORS_PER_COMMITTEE](@[validator_index]), + attesting_indices: + List[uint64, Limit MAX_VALIDATORS_PER_COMMITTEE](@[validator_index]), signature: get_attestation_signature( fork, genesis_validators_root, tmp, MockPrivKeys[validator_index]).toValidatorSig) @@ -97,7 +99,7 @@ suite "Validator change pool testing suite": for i in 0'u64 .. MAX_ATTESTER_SLASHINGS + 5: for j in 0'u64 .. i: let - msg = AttesterSlashing( + msg = phase0.AttesterSlashing( attestation_1: makeIndexedAttestation( fork, genesis_validators_root, Slot(1), j, makeFakeHash(0)), attestation_2: makeIndexedAttestation( @@ -237,4 +239,4 @@ suite "Validator change pool testing suite": # Message signed with a (fork-2) domain can no longer be added as that # fork is not present in the BeaconState and thus fails transition pool[].getBeaconBlockValidatorChanges( - cfg, forkyState.data).voluntary_exits.lenu64 == 0 + cfg, forkyState.data).voluntary_exits.lenu64 == 0 \ No newline at end of file