state_transition implements the spec fairly directly (#1220)

This commit is contained in:
tersec 2020-06-23 13:54:24 +00:00 committed by GitHub
parent a683656238
commit 807b920c19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 45 additions and 47 deletions

View File

@ -4,8 +4,8 @@ import
typetraits, stew/[results, objects, endians2], typetraits, stew/[results, objects, endians2],
serialization, chronicles, snappy, serialization, chronicles, snappy,
eth/db/kvstore, eth/db/kvstore,
./spec/[datatypes, digest, crypto], ./spec/[datatypes, digest, crypto, state_transition],
./ssz/[ssz_serialization, merkleization], ./state_transition ./ssz/[ssz_serialization, merkleization]
type type
BeaconChainDB* = ref object BeaconChainDB* = ref object

View File

@ -19,15 +19,14 @@ import
# Local modules # Local modules
spec/[datatypes, digest, crypto, beaconstate, helpers, network, signatures], spec/[datatypes, digest, crypto, beaconstate, helpers, network, signatures],
spec/presets/custom, spec/state_transition, spec/presets/custom,
conf, time, beacon_chain_db, validator_pool, extras, conf, time, beacon_chain_db, validator_pool, extras,
attestation_pool, block_pool, eth2_network, eth2_discovery, attestation_pool, block_pool, eth2_network, eth2_discovery,
beacon_node_common, beacon_node_types, block_pools/block_pools_types, beacon_node_common, beacon_node_types, block_pools/block_pools_types,
nimbus_binary_common, nimbus_binary_common,
mainchain_monitor, version, ssz/[merkleization], sszdump, mainchain_monitor, version, ssz/[merkleization], sszdump,
sync_protocol, request_manager, keystore_management, interop, statusbar, sync_protocol, request_manager, keystore_management, interop, statusbar,
sync_manager, state_transition, sync_manager, validator_duties, validator_api, attestation_aggregation
validator_duties, validator_api, attestation_aggregation
const const
genesisFile* = "genesis.ssz" genesisFile* = "genesis.ssz"

View File

@ -10,8 +10,8 @@
import import
chronicles, options, sequtils, tables, chronicles, options, sequtils, tables,
metrics, metrics,
../ssz/merkleization, ../beacon_chain_db, ../state_transition, ../extras, ../ssz/merkleization, ../beacon_chain_db, ../extras,
../spec/[crypto, datatypes, digest, helpers, validator], ../spec/[crypto, datatypes, digest, helpers, validator, state_transition],
block_pools_types block_pools_types
declareCounter beacon_reorgs_total, "Total occurrences of reorganizations of the chain" # On fork choice declareCounter beacon_reorgs_total, "Total occurrences of reorganizations of the chain" # On fork choice

View File

@ -10,8 +10,8 @@
import import
chronicles, sequtils, tables, chronicles, sequtils, tables,
metrics, stew/results, metrics, stew/results,
../ssz/merkleization, ../state_transition, ../extras, ../ssz/merkleization, ../extras,
../spec/[crypto, datatypes, digest, helpers, signatures], ../spec/[crypto, datatypes, digest, helpers, signatures, state_transition],
block_pools_types, candidate_chains, quarantine block_pools_types, candidate_chains, quarantine
export results export results

View File

@ -31,10 +31,10 @@ import
tables, tables,
chronicles, chronicles,
stew/results, stew/results,
./extras, ./ssz/merkleization, metrics, ../extras, ../ssz/merkleization, metrics,
./spec/[datatypes, crypto, digest, helpers, signatures, validator], datatypes, crypto, digest, helpers, signatures, validator,
./spec/[state_transition_block, state_transition_epoch], state_transition_block, state_transition_epoch,
../nbench/bench_lab ../../nbench/bench_lab
# https://github.com/ethereum/eth2.0-metrics/blob/master/metrics.md#additional-metrics # https://github.com/ethereum/eth2.0-metrics/blob/master/metrics.md#additional-metrics
declareGauge beacon_current_validators, """Number of status="pending|active|exited|withdrawable" validators in current epoch""" # On epoch transition declareGauge beacon_current_validators, """Number of status="pending|active|exited|withdrawable" validators in current epoch""" # On epoch transition

View File

@ -19,7 +19,8 @@ import
# Local modules # Local modules
spec/[datatypes, digest, crypto, beaconstate, helpers, validator, network], spec/[datatypes, digest, crypto, beaconstate, helpers, validator, network],
conf, time, validator_pool, state_transition, spec/state_transition,
conf, time, validator_pool,
attestation_pool, block_pool, block_pools/candidate_chains, eth2_network, attestation_pool, block_pool, block_pools/candidate_chains, eth2_network,
keystore_management, beacon_node_common, beacon_node_types, keystore_management, beacon_node_common, beacon_node_types,
nimbus_binary_common, mainchain_monitor, version, ssz/merkleization, interop, nimbus_binary_common, mainchain_monitor, version, ssz/merkleization, interop,

View File

@ -13,8 +13,8 @@ import
# Beacon-chain # Beacon-chain
../beacon_chain/spec/[ ../beacon_chain/spec/[
datatypes, crypto, helpers, beaconstate, validator, datatypes, crypto, helpers, beaconstate, validator,
state_transition_block, state_transition_epoch], state_transition_block, state_transition_epoch, state_transition],
../beacon_chain/[state_transition, extras], ../beacon_chain/extras,
../beacon_chain/ssz/[merkleization, ssz_serialization] ../beacon_chain/ssz/[merkleization, ssz_serialization]
# Nimbus Bench - Scenario configuration # Nimbus Bench - Scenario configuration

View File

@ -1,8 +1,8 @@
import import
confutils, stats, chronicles, strformat, tables, confutils, stats, chronicles, strformat, tables,
stew/byteutils, stew/byteutils,
../beacon_chain/[beacon_chain_db, block_pool, extras, state_transition], ../beacon_chain/[beacon_chain_db, block_pool, extras],
../beacon_chain/spec/[crypto, datatypes, digest, helpers], ../beacon_chain/spec/[crypto, datatypes, digest, helpers, state_transition],
../beacon_chain/sszdump, ../beacon_chain/sszdump,
../research/simutils, ../research/simutils,
eth/db/[kvstore, kvstore_sqlite3] eth/db/[kvstore, kvstore_sqlite3]

View File

@ -1,7 +1,7 @@
import import
confutils, chronicles, confutils, chronicles,
../beacon_chain/spec/[crypto, datatypes], ../beacon_chain/spec/[crypto, datatypes, state_transition],
../beacon_chain/[extras, state_transition], ../beacon_chain/extras,
../beacon_chain/ssz/[merkleization, ssz_serialization] ../beacon_chain/ssz/[merkleization, ssz_serialization]
cli do(pre: string, blck: string, post: string, verifyStateRoot = false): cli do(pre: string, blck: string, post: string, verifyStateRoot = false):

View File

@ -3,9 +3,9 @@
import import
stew/ptrops, stew/ranges/ptr_arith, stew/ptrops, stew/ranges/ptr_arith,
../beacon_chain/[extras, state_transition], ../beacon_chain/extras,
../beacon_chain/spec/[crypto, datatypes, digest, validator, beaconstate, ../beacon_chain/spec/[crypto, datatypes, digest, validator, beaconstate,
state_transition_block], state_transition_block, state_transition],
../beacon_chain/ssz/[merkleization, ssz_serialization] ../beacon_chain/ssz/[merkleization, ssz_serialization]
type type

View File

@ -20,10 +20,11 @@ import
options, random, tables, options, random, tables,
../tests/[testblockutil], ../tests/[testblockutil],
../beacon_chain/spec/[ ../beacon_chain/spec/[
beaconstate, crypto, datatypes, digest, helpers, validator, signatures], beaconstate, crypto, datatypes, digest, helpers, validator, signatures,
state_transition],
../beacon_chain/[ ../beacon_chain/[
attestation_pool, block_pool, beacon_node_types, beacon_chain_db, attestation_pool, block_pool, beacon_node_types, beacon_chain_db,
interop, state_transition, validator_pool], interop, validator_pool],
eth/db/[kvstore, kvstore_sqlite3], eth/db/[kvstore, kvstore_sqlite3],
../beacon_chain/ssz/[merkleization, ssz_serialization], ../beacon_chain/ssz/[merkleization, ssz_serialization],
./simutils ./simutils

View File

@ -13,9 +13,9 @@ import
sets, sets,
# Specs # Specs
../../beacon_chain/spec/[datatypes, beaconstate, helpers, validator, crypto, ../../beacon_chain/spec/[datatypes, beaconstate, helpers, validator, crypto,
signatures], signatures, state_transition],
# Internals # Internals
../../beacon_chain/[ssz, extras, state_transition], ../../beacon_chain/[ssz, extras],
# Mocking procs # Mocking procs
./mock_blocks, ./mock_blocks,
./mock_validator_keys ./mock_validator_keys

View File

@ -10,9 +10,7 @@
import import
# Specs # Specs
../../beacon_chain/spec/[datatypes], ../../beacon_chain/spec/[datatypes, state_transition]
# Internals
../../beacon_chain/state_transition
proc nextEpoch*(state: var HashedBeaconState) = proc nextEpoch*(state: var HashedBeaconState) =
## Transition to the start of the next epoch ## Transition to the start of the next epoch

View File

@ -11,8 +11,8 @@ import
# Standard library # Standard library
os, sequtils, unittest, os, sequtils, unittest,
# Beacon chain internals # Beacon chain internals
../../beacon_chain/spec/[crypto, datatypes], ../../beacon_chain/spec/[crypto, datatypes, state_transition],
../../beacon_chain/[ssz, state_transition], ../../beacon_chain/ssz,
# Test utilities # Test utilities
../testutil, ../testutil,
./fixtures_utils ./fixtures_utils

View File

@ -11,8 +11,7 @@ import
# Standard library # Standard library
os, strutils, unittest, os, strutils, unittest,
# Beacon chain internals # Beacon chain internals
../../beacon_chain/spec/datatypes, ../../beacon_chain/spec/[datatypes, state_transition],
../../beacon_chain/state_transition,
# Test utilities # Test utilities
../testutil, ../testutil,
./fixtures_utils, ./fixtures_utils,

View File

@ -7,9 +7,8 @@
import import
# Specs # Specs
../../beacon_chain/spec/[datatypes, state_transition_epoch, validator], ../../beacon_chain/spec/[
# Internals datatypes, state_transition_epoch, validator, state_transition]
../../beacon_chain/[state_transition]
proc processSlotsUntilEndCurrentEpoch(state: var HashedBeaconState) = proc processSlotsUntilEndCurrentEpoch(state: var HashedBeaconState) =
# Process all slots until the end of the last slot of the current epoch # Process all slots until the end of the last slot of the current epoch

View File

@ -16,8 +16,8 @@ import
chronicles, chronicles,
stew/byteutils, stew/byteutils,
./testutil, ./testblockutil, ./testutil, ./testblockutil,
../beacon_chain/spec/[digest, validator], ../beacon_chain/spec/[digest, validator, state_transition],
../beacon_chain/[beacon_node_types, attestation_pool, block_pool, state_transition] ../beacon_chain/[beacon_node_types, attestation_pool, block_pool]
suiteReport "Attestation pool processing" & preset(): suiteReport "Attestation pool processing" & preset():
## For now just test that we can compile and execute block processing with ## For now just test that we can compile and execute block processing with

View File

@ -8,8 +8,9 @@
{.used.} {.used.}
import options, unittest, sequtils, import options, unittest, sequtils,
../beacon_chain/[beacon_chain_db, extras, interop, ssz, state_transition], ../beacon_chain/[beacon_chain_db, extras, interop, ssz],
../beacon_chain/spec/[beaconstate, datatypes, digest, crypto], ../beacon_chain/spec/[
beaconstate, datatypes, digest, crypto, state_transition],
eth/db/kvstore, eth/db/kvstore,
# test utilies # test utilies
./testutil, ./testblockutil ./testutil, ./testblockutil

View File

@ -10,8 +10,8 @@
import import
options, sequtils, unittest, options, sequtils, unittest,
./testutil, ./testblockutil, ./testutil, ./testblockutil,
../beacon_chain/spec/[datatypes, digest, validator], ../beacon_chain/spec/[datatypes, digest, validator, state_transition],
../beacon_chain/[beacon_node_types, block_pool, state_transition, ssz] ../beacon_chain/[beacon_node_types, block_pool, ssz]
when isMainModule: when isMainModule:
import chronicles # or some random compile error happens... import chronicles # or some random compile error happens...

View File

@ -10,8 +10,9 @@
import import
unittest, unittest,
./testutil, ./testblockutil, ./testutil, ./testblockutil,
../beacon_chain/spec/[beaconstate, datatypes, digest, validator], ../beacon_chain/spec/[
../beacon_chain/[state_transition, ssz] beaconstate, datatypes, digest, validator, state_transition],
../beacon_chain/ssz
suiteReport "Block processing" & preset(): suiteReport "Block processing" & preset():
## For now just test that we can compile and execute block processing with ## For now just test that we can compile and execute block processing with

View File

@ -9,10 +9,9 @@ import
options, stew/endians2, options, stew/endians2,
chronicles, eth/trie/[db], chronicles, eth/trie/[db],
../beacon_chain/[beacon_chain_db, block_pool, extras, merkle_minimal, ../beacon_chain/[beacon_chain_db, block_pool, extras, merkle_minimal,
../beacon_chain/ssz/merkleization, ../beacon_chain/ssz/merkleization, validator_pool],
state_transition, validator_pool],
../beacon_chain/spec/[beaconstate, crypto, datatypes, digest, ../beacon_chain/spec/[beaconstate, crypto, datatypes, digest,
helpers, validator, signatures] helpers, validator, signatures, state_transition]
func makeFakeValidatorPrivKey(i: int): ValidatorPrivKey = func makeFakeValidatorPrivKey(i: int): ValidatorPrivKey =
# 0 is not a valid BLS private key - 1000 helps interop with rust BLS library, # 0 is not a valid BLS private key - 1000 helps interop with rust BLS library,