From 707fcd99cb14d7a1fc8f4427afa9ffcb29084cce Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Mon, 1 Feb 2021 12:41:27 +0100 Subject: [PATCH] remove unused beacon chain spec and test code --- beacon_chain/spec/datatypes.nim | 3 --- beacon_chain/spec/digest.nim | 8 +------- tests/mocking/mock_attestations.nim | 30 ++--------------------------- tests/testutil.nim | 9 --------- 4 files changed, 3 insertions(+), 47 deletions(-) diff --git a/beacon_chain/spec/datatypes.nim b/beacon_chain/spec/datatypes.nim index 9bed9c645..b51c64c04 100644 --- a/beacon_chain/spec/datatypes.nim +++ b/beacon_chain/spec/datatypes.nim @@ -764,9 +764,6 @@ func `[]`*[T](a: var seq[T], b: ValidatorIndex): var T = func `[]`*[T](a: seq[T], b: ValidatorIndex): auto = a[b.int] -func `[]=`*[T](a: var seq[T], b: ValidatorIndex, c: T) = - a[b.int] = c - # `ValidatorIndex` Nim integration proc `==`*(x, y: ValidatorIndex) : bool {.borrow, noSideEffect.} proc `<`*(x, y: ValidatorIndex) : bool {.borrow, noSideEffect.} diff --git a/beacon_chain/spec/digest.nim b/beacon_chain/spec/digest.nim index a6afb7310..afa6883ae 100644 --- a/beacon_chain/spec/digest.nim +++ b/beacon_chain/spec/digest.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018-2020 Status Research & Development GmbH +# Copyright (c) 2018-2021 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). @@ -66,12 +66,6 @@ func eth2digest*(v: openArray[byte]): Eth2Digest {.noInit.} = ctx.update(v) ctx.finish() -when BLS_BACKEND == BLST: - func update*(ctx: var BLST_SHA256_CTX; digest: Eth2Digest) = - ctx.update digest.data -func update*(ctx: var sha256; digest: Eth2Digest) = - ctx.update digest.data - template withEth2Hash*(body: untyped): Eth2Digest = ## This little helper will init the hash function and return the sliced ## hash: diff --git a/tests/mocking/mock_attestations.nim b/tests/mocking/mock_attestations.nim index cff17849a..58750a8af 100644 --- a/tests/mocking/mock_attestations.nim +++ b/tests/mocking/mock_attestations.nim @@ -15,9 +15,9 @@ import chronicles, # Specs ../../beacon_chain/spec/[datatypes, beaconstate, helpers, validator, crypto, - signatures, state_transition, presets], + signatures, presets], # Internals - ../../beacon_chain/[ssz, extras], + ../../beacon_chain/ssz, # Mocking procs ./mock_blocks, ./mock_validator_keys @@ -113,29 +113,3 @@ proc mockAttestation*( state: BeaconState, slot: Slot): Attestation = mockAttestationImpl(state, slot) - -func fillAggregateAttestation*(state: BeaconState, attestation: var Attestation) = - var cache = StateCache() - let beacon_committee = get_beacon_committee( - state, - attestation.data.slot, - attestation.data.index.CommitteeIndex, - cache - ) - for i in 0 ..< beacon_committee.len: - attestation.aggregation_bits[i] = true - -proc add*(state: var HashedBeaconState, attestation: Attestation, slot: Slot) = - var - signedBlock = mockBlockForNextSlot(state.data) - cache = StateCache() - signedBlock.message.slot = slot - signedBlock.message.body.attestations.add attestation - doAssert process_slots(state, slot, cache) - signMockBlock(state.data, signedBlock) - - let success = state_transition( - defaultRuntimePreset, state, signedBlock, cache, - flags = {skipStateRootValidation}, noRollback) - - doAssert success diff --git a/tests/testutil.nim b/tests/testutil.nim index f17ae90be..a3ff2f805 100644 --- a/tests/testutil.nim +++ b/tests/testutil.nim @@ -21,15 +21,6 @@ func preset*(): string = " [Preset: " & const_preset & ']' # For state_sim -template withTimer*(stats: var RunningStat, body: untyped) = - let start = getMonoTime() - - block: - body - - let stop = getMonoTime() - stats.push (stop - start).inMicroseconds.float / 1000000.0 - template withTimer*(duration: var float, body: untyped) = let start = getMonoTime()