Skip to content

Commit cb3f1fd

Browse files
authored
remove nbench (#3152)
Used during initial development of the spec, `nbench` has fallen behind and by and large been superceded by `block_sim`, `state_sim` and `ncli_db bench`.
1 parent fa2cf02 commit cb3f1fd

File tree

15 files changed

+51
-1046
lines changed

15 files changed

+51
-1046
lines changed

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ TOOLS := \
4343
deposit_contract \
4444
resttest \
4545
logtrace \
46-
nbench \
47-
nbench_spec_scenarios \
4846
ncli \
4947
ncli_db \
5048
stack_sizes \
@@ -59,7 +57,6 @@ TOOLS_DIRS := \
5957
beacon_chain/eth1 \
6058
benchmarks \
6159
ncli \
62-
nbench \
6360
research \
6461
tools
6562
TOOLS_CSV := $(subst $(SPACE),$(COMMA),$(TOOLS))

beacon_chain/spec/beaconstate.nim

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import
1414
chronicles,
1515
../extras,
1616
./datatypes/[phase0, altair, merge],
17-
"."/[eth2_merkleization, forks, signatures, validator],
18-
../../nbench/bench_lab
17+
"."/[eth2_merkleization, forks, signatures, validator]
1918

2019
export extras, forks, validator
2120

@@ -195,7 +194,7 @@ proc initialize_beacon_state_from_eth1*(
195194
eth1_block_hash: Eth2Digest,
196195
eth1_timestamp: uint64,
197196
deposits: openArray[DepositData],
198-
flags: UpdateFlags = {}): phase0.BeaconState {.nbench.} =
197+
flags: UpdateFlags = {}): phase0.BeaconState =
199198
## Get the genesis ``BeaconState``.
200199
##
201200
## Before the beacon chain starts, validators will register in the Eth1 chain
@@ -627,7 +626,7 @@ proc check_attestation*(
627626
proc process_attestation*(
628627
state: var ForkyBeaconState, attestation: SomeAttestation, flags: UpdateFlags,
629628
base_reward_per_increment: Gwei, cache: var StateCache):
630-
Result[void, cstring] {.nbench.} =
629+
Result[void, cstring] =
631630
# In the spec, attestation validation is mixed with state mutation, so here
632631
# we've split it into two functions so that the validation logic can be
633632
# reused when looking for suitable blocks to include in attestations.

beacon_chain/spec/state_transition.nim

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,17 @@ import
4949
./datatypes/[phase0, altair, merge],
5050
"."/[
5151
beaconstate, eth2_merkleization, forks, helpers, signatures,
52-
state_transition_block, state_transition_epoch, validator],
53-
../../nbench/bench_lab
52+
state_transition_block, state_transition_epoch, validator]
5453

5554
export extras, phase0, altair
5655

5756
type Foo = phase0.SignedBeaconBlock | altair.SignedBeaconBlock | phase0.TrustedSignedBeaconBlock | altair.TrustedSignedBeaconBlock | phase0.SigVerifiedSignedBeaconBlock | altair.SigVerifiedSignedBeaconBlock | merge.TrustedSignedBeaconBlock | merge.SigVerifiedSignedBeaconBlock | merge.SignedBeaconBlock
5857

5958
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
6059
proc verify_block_signature(
61-
#state: ForkyBeaconState, signed_block: SomeSomeSignedBeaconBlock): bool {.nbench.} =
62-
state: ForkyBeaconState, signed_block: Foo): bool {.nbench.} =
63-
#state: ForkyBeaconState, signed_block: phase0.SomeSignedBeaconBlock | altair.SomeSignedBeaconBlock): bool {.nbench.} =
60+
#state: ForkyBeaconState, signed_block: SomeSomeSignedBeaconBlock): bool =
61+
state: ForkyBeaconState, signed_block: Foo): bool =
62+
#state: ForkyBeaconState, signed_block: phase0.SomeSignedBeaconBlock | altair.SomeSignedBeaconBlock): bool =
6463
let
6564
proposer_index = signed_block.message.proposer_index
6665
if proposer_index >= state.validators.lenu64:
@@ -135,7 +134,7 @@ type
135134

136135
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
137136
func process_slot*(
138-
state: var ForkyBeaconState, pre_state_root: Eth2Digest) {.nbench.} =
137+
state: var ForkyBeaconState, pre_state_root: Eth2Digest) =
139138
# `process_slot` is the first stage of per-slot processing - it is run for
140139
# every slot, including epoch slots - it does not however update the slot
141140
# number! `pre_state_root` refers to the state root of the incoming
@@ -165,7 +164,7 @@ func clear_epoch_from_cache(cache: var StateCache, epoch: Epoch) =
165164
proc advance_slot(
166165
cfg: RuntimeConfig,
167166
state: var ForkyBeaconState, previous_slot_state_root: Eth2Digest,
168-
flags: UpdateFlags, cache: var StateCache, info: var ForkyEpochInfo) {.nbench.} =
167+
flags: UpdateFlags, cache: var StateCache, info: var ForkyEpochInfo) =
169168
# Do the per-slot and potentially the per-epoch processing, then bump the
170169
# slot number - we've now arrived at the slot state on top of which a block
171170
# optionally can be applied.
@@ -221,7 +220,7 @@ proc maybeUpgradeState*(
221220

222221
proc process_slots*(
223222
cfg: RuntimeConfig, state: var ForkedHashedBeaconState, slot: Slot,
224-
cache: var StateCache, info: var ForkedEpochInfo, flags: UpdateFlags): bool {.nbench.} =
223+
cache: var StateCache, info: var ForkedEpochInfo, flags: UpdateFlags): bool =
225224
if not (getStateField(state, slot) < slot):
226225
if slotProcessed notin flags or getStateField(state, slot) != slot:
227226
notice "Unusual request for a slot in the past",
@@ -255,7 +254,7 @@ proc state_transition_block_aux(
255254
altair.SigVerifiedSignedBeaconBlock | altair.TrustedSignedBeaconBlock |
256255
merge.TrustedSignedBeaconBlock | merge.SigVerifiedSignedBeaconBlock |
257256
merge.SignedBeaconBlock,
258-
cache: var StateCache, flags: UpdateFlags): bool {.nbench.} =
257+
cache: var StateCache, flags: UpdateFlags): bool =
259258
# Block updates - these happen when there's a new block being suggested
260259
# by the block proposer. Every actor in the network will update its state
261260
# according to the contents of this block - but first they will validate
@@ -307,7 +306,7 @@ proc state_transition_block*(
307306
altair.TrustedSignedBeaconBlock | merge.TrustedSignedBeaconBlock |
308307
merge.SigVerifiedSignedBeaconBlock | merge.SignedBeaconBlock,
309308
cache: var StateCache, flags: UpdateFlags,
310-
rollback: RollbackForkedHashedProc): bool {.nbench.} =
309+
rollback: RollbackForkedHashedProc): bool =
311310
## `rollback` is called if the transition fails and the given state has been
312311
## partially changed. If a temporary state was given to `state_transition`,
313312
## it is safe to use `noRollback` and leave it broken, else the state
@@ -335,7 +334,7 @@ proc state_transition*(
335334
altair.TrustedSignedBeaconBlock | merge.TrustedSignedBeaconBlock |
336335
merge.SignedBeaconBlock,
337336
cache: var StateCache, info: var ForkedEpochInfo, flags: UpdateFlags,
338-
rollback: RollbackForkedHashedProc): bool {.nbench.} =
337+
rollback: RollbackForkedHashedProc): bool =
339338
## Apply a block to the state, advancing the slot counter as necessary. The
340339
## given state must be of a lower slot, or, in case the `slotProcessed` flag
341340
## is set, can be the slot state of the same slot as the block (where the

beacon_chain/spec/state_transition_block.nim

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@ import
2424
chronicles, metrics,
2525
../extras,
2626
./datatypes/[phase0, altair, merge],
27-
"."/[beaconstate, eth2_merkleization, helpers, validator, signatures],
28-
../../nbench/bench_lab
27+
"."/[beaconstate, eth2_merkleization, helpers, validator, signatures]
2928

3029
export extras, phase0, altair
3130

3231
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/specs/phase0/beacon-chain.md#block-header
3332
func process_block_header*(
3433
state: var ForkyBeaconState, blck: SomeSomeBeaconBlock, flags: UpdateFlags,
35-
cache: var StateCache): Result[void, cstring] {.nbench.} =
34+
cache: var StateCache): Result[void, cstring] =
3635
# Verify that the slots match
3736
if not (blck.slot == state.slot):
3837
return err("process_block_header: slot mismatch")
@@ -75,7 +74,7 @@ func `xor`[T: array](a, b: T): T =
7574
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/specs/phase0/beacon-chain.md#randao
7675
proc process_randao(
7776
state: var ForkyBeaconState, body: SomeSomeBeaconBlockBody, flags: UpdateFlags,
78-
cache: var StateCache): Result[void, cstring] {.nbench.} =
77+
cache: var StateCache): Result[void, cstring] =
7978
let
8079
proposer_index = get_beacon_proposer_index(state, cache)
8180

@@ -106,7 +105,7 @@ proc process_randao(
106105
ok()
107106

108107
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/specs/phase0/beacon-chain.md#eth1-data
109-
func process_eth1_data(state: var ForkyBeaconState, body: SomeSomeBeaconBlockBody): Result[void, cstring] {.nbench.}=
108+
func process_eth1_data(state: var ForkyBeaconState, body: SomeSomeBeaconBlockBody): Result[void, cstring]=
110109
if not state.eth1_data_votes.add body.eth1_data:
111110
# Count is reset in process_final_updates, so this should never happen
112111
return err("process_eth1_data: no more room for eth1 data")
@@ -127,7 +126,7 @@ func is_slashable_validator(validator: Validator, epoch: Epoch): bool =
127126
proc check_proposer_slashing*(
128127
state: var ForkyBeaconState, proposer_slashing: SomeProposerSlashing,
129128
flags: UpdateFlags):
130-
Result[void, cstring] {.nbench.} =
129+
Result[void, cstring] =
131130

132131
let
133132
header_1 = proposer_slashing.signed_header_1.message
@@ -177,7 +176,7 @@ proc process_proposer_slashing*(
177176
cfg: RuntimeConfig, state: var ForkyBeaconState,
178177
proposer_slashing: SomeProposerSlashing, flags: UpdateFlags,
179178
cache: var StateCache):
180-
Result[void, cstring] {.nbench.} =
179+
Result[void, cstring] =
181180
? check_proposer_slashing(state, proposer_slashing, flags)
182181
slash_validator(
183182
cfg, state,
@@ -202,7 +201,7 @@ proc check_attester_slashing*(
202201
state: var ForkyBeaconState,
203202
attester_slashing: SomeAttesterSlashing,
204203
flags: UpdateFlags
205-
): Result[seq[ValidatorIndex], cstring] {.nbench.} =
204+
): Result[seq[ValidatorIndex], cstring] =
206205
let
207206
attestation_1 = attester_slashing.attestation_1
208207
attestation_2 = attester_slashing.attestation_2
@@ -244,7 +243,7 @@ proc process_attester_slashing*(
244243
attester_slashing: SomeAttesterSlashing,
245244
flags: UpdateFlags,
246245
cache: var StateCache
247-
): Result[void, cstring] {.nbench.} =
246+
): Result[void, cstring] =
248247
let attester_slashing_validity =
249248
check_attester_slashing(state, attester_slashing, flags)
250249

@@ -259,7 +258,7 @@ proc process_attester_slashing*(
259258
proc process_deposit*(cfg: RuntimeConfig,
260259
state: var ForkyBeaconState,
261260
deposit: Deposit,
262-
flags: UpdateFlags): Result[void, cstring] {.nbench.} =
261+
flags: UpdateFlags): Result[void, cstring] =
263262
## Process an Eth1 deposit, registering a validator or increasing its balance.
264263

265264
# Verify the Merkle branch
@@ -328,7 +327,7 @@ proc check_voluntary_exit*(
328327
cfg: RuntimeConfig,
329328
state: ForkyBeaconState,
330329
signed_voluntary_exit: SomeSignedVoluntaryExit,
331-
flags: UpdateFlags): Result[void, cstring] {.nbench.} =
330+
flags: UpdateFlags): Result[void, cstring] =
332331

333332
let voluntary_exit = signed_voluntary_exit.message
334333

@@ -389,7 +388,7 @@ proc process_voluntary_exit*(
389388
state: var ForkyBeaconState,
390389
signed_voluntary_exit: SomeSignedVoluntaryExit,
391390
flags: UpdateFlags,
392-
cache: var StateCache): Result[void, cstring] {.nbench.} =
391+
cache: var StateCache): Result[void, cstring] =
393392
? check_voluntary_exit(cfg, state, signed_voluntary_exit, flags)
394393
initiate_validator_exit(
395394
cfg, state, signed_voluntary_exit.message.validator_index.ValidatorIndex,
@@ -402,7 +401,7 @@ proc process_operations(cfg: RuntimeConfig,
402401
body: SomeSomeBeaconBlockBody,
403402
base_reward_per_increment: Gwei,
404403
flags: UpdateFlags,
405-
cache: var StateCache): Result[void, cstring] {.nbench.} =
404+
cache: var StateCache): Result[void, cstring] =
406405
# Verify that outstanding deposits are processed up to the maximum number of
407406
# deposits
408407
let
@@ -430,7 +429,7 @@ proc process_operations(cfg: RuntimeConfig,
430429
proc process_sync_aggregate*(
431430
state: var (altair.BeaconState | merge.BeaconState),
432431
aggregate: SomeSyncAggregate, total_active_balance: Gwei, cache: var StateCache):
433-
Result[void, cstring] {.nbench.} =
432+
Result[void, cstring] =
434433
# Verify sync committee aggregate signature signing over the previous slot
435434
# block root
436435
let
@@ -491,7 +490,7 @@ proc process_sync_aggregate*(
491490
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/specs/merge/beacon-chain.md#process_execution_payload
492491
proc process_execution_payload*(
493492
state: var merge.BeaconState, payload: ExecutionPayload,
494-
execute_payload: ExecutePayload): Result[void, cstring] {.nbench.} =
493+
execute_payload: ExecutePayload): Result[void, cstring] =
495494
## Verify consistency of the parent hash with respect to the previous
496495
## execution payload header
497496
if is_merge_complete(state):
@@ -537,7 +536,7 @@ type SomePhase0Block =
537536
proc process_block*(
538537
cfg: RuntimeConfig,
539538
state: var phase0.BeaconState, blck: SomePhase0Block, flags: UpdateFlags,
540-
cache: var StateCache): Result[void, cstring] {.nbench.}=
539+
cache: var StateCache): Result[void, cstring]=
541540
## When there's a new block, we need to verify that the block is sane and
542541
## update the state accordingly - the state is left in an unknown state when
543542
## block application fails (!)
@@ -552,13 +551,13 @@ proc process_block*(
552551
proc process_block*(
553552
cfg: RuntimeConfig,
554553
state: var altair.BeaconState, blck: SomePhase0Block, flags: UpdateFlags,
555-
cache: var StateCache): Result[void, cstring] {.nbench.} =
554+
cache: var StateCache): Result[void, cstring] =
556555
err("process_block: Altair state with Phase 0 block")
557556

558557
proc process_block*(
559558
cfg: RuntimeConfig,
560559
state: var merge.BeaconState, blck: SomePhase0Block, flags: UpdateFlags,
561-
cache: var StateCache): Result[void, cstring] {.nbench.} =
560+
cache: var StateCache): Result[void, cstring] =
562561
err("process_block: Merge state with Phase 0 block")
563562

564563
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/specs/altair/beacon-chain.md#block-processing
@@ -569,7 +568,7 @@ type SomeAltairBlock =
569568
proc process_block*(
570569
cfg: RuntimeConfig,
571570
state: var altair.BeaconState, blck: SomeAltairBlock, flags: UpdateFlags,
572-
cache: var StateCache): Result[void, cstring] {.nbench.}=
571+
cache: var StateCache): Result[void, cstring]=
573572
## When there's a new block, we need to verify that the block is sane and
574573
## update the state accordingly - the state is left in an unknown state when
575574
## block application fails (!)
@@ -596,7 +595,7 @@ type SomeMergeBlock =
596595
proc process_block*(
597596
cfg: RuntimeConfig,
598597
state: var merge.BeaconState, blck: SomeMergeBlock, flags: UpdateFlags,
599-
cache: var StateCache): Result[void, cstring] {.nbench.}=
598+
cache: var StateCache): Result[void, cstring]=
600599
## When there's a new block, we need to verify that the block is sane and
601600
## update the state accordingly - the state is left in an unknown state when
602601
## block application fails (!)
@@ -624,23 +623,23 @@ proc process_block*(
624623
proc process_block*(
625624
cfg: RuntimeConfig,
626625
state: var phase0.BeaconState, blck: SomeAltairBlock, flags: UpdateFlags,
627-
cache: var StateCache): Result[void, cstring] {.nbench.}=
626+
cache: var StateCache): Result[void, cstring]=
628627
err("process_block: Phase 0 state with Altair block")
629628

630629
proc process_block*(
631630
cfg: RuntimeConfig,
632631
state: var phase0.BeaconState, blck: SomeMergeBlock, flags: UpdateFlags,
633-
cache: var StateCache): Result[void, cstring] {.nbench.}=
632+
cache: var StateCache): Result[void, cstring]=
634633
err("process_block: Phase 0 state with Merge block")
635634

636635
proc process_block*(
637636
cfg: RuntimeConfig,
638637
state: var altair.BeaconState, blck: SomeMergeBlock, flags: UpdateFlags,
639-
cache: var StateCache): Result[void, cstring] {.nbench.}=
638+
cache: var StateCache): Result[void, cstring]=
640639
err("process_block: Altair state with Merge block")
641640

642641
proc process_block*(
643642
cfg: RuntimeConfig,
644643
state: var merge.BeaconState, blck: SomeAltairBlock, flags: UpdateFlags,
645-
cache: var StateCache): Result[void, cstring] {.nbench.}=
644+
cache: var StateCache): Result[void, cstring]=
646645
err("process_block: Merge state with Altair block")

0 commit comments

Comments
 (0)