add more config options and log compile parameters (#114)

default sim runs with smaller chain now
This commit is contained in:
Jacek Sieka 2019-02-14 13:32:33 -06:00 committed by GitHub
parent c2a52d7fc5
commit a71424d768
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 8 deletions

View File

@ -28,7 +28,7 @@ const
topicBeaconBlocks = "ethereum/2.1/beacon_chain/blocks" topicBeaconBlocks = "ethereum/2.1/beacon_chain/blocks"
topicAttestations = "ethereum/2.1/beacon_chain/attestations" topicAttestations = "ethereum/2.1/beacon_chain/attestations"
stateStoragePeriod = EPOCH_LENGTH * 10 # Save states once per this number of slots. TODO: Find a good number. stateStoragePeriod = EPOCH_LENGTH.uint64 * 10 # Save states once per this number of slots. TODO: Find a good number.
func shortHash(x: auto): string = func shortHash(x: auto): string =
@ -434,7 +434,11 @@ when isMainModule:
info "Starting beacon node", info "Starting beacon node",
slotsSinceFinalization = node.beaconState.slotDistanceFromNow(), slotsSinceFinalization = node.beaconState.slotDistanceFromNow(),
stateSlot = humaneSlotNum(node.beaconState.slot) stateSlot = humaneSlotNum(node.beaconState.slot),
SHARD_COUNT,
EPOCH_LENGTH,
SLOT_DURATION,
SPEC_VERSION
node.addLocalValidators() node.addLocalValidators()
node.processBlocks() node.processBlocks()

View File

@ -40,11 +40,16 @@ import
# TODO Many of these constants should go into a config object that can be used # TODO Many of these constants should go into a config object that can be used
# to run.. well.. a chain with different constants! # to run.. well.. a chain with different constants!
const const
SPEC_VERSION* = "0.2.0" ## \
## Spec version we're aiming to be compatible with, right now
## TODO: improve this scheme once we can negotiate versions in protocol
# Misc # Misc
# https://github.com/ethereum/eth2.0-specs/blob/v0.2.0/specs/core/0_beacon-chain.md#misc # https://github.com/ethereum/eth2.0-specs/blob/v0.2.0/specs/core/0_beacon-chain.md#misc
SHARD_COUNT* = 1024 ##\ SHARD_COUNT* {.intdefine.} = 1024 ##\
## Number of shards supported by the network - validators will jump around ## Number of shards supported by the network - validators will jump around
## between these shards and provide attestations to their state. ## between these shards and provide attestations to their state.
## Compile with -d:SHARD_COUNT=4 for fewer shard (= better with low validator counts)
TARGET_COMMITTEE_SIZE* = 2^7 ##\ TARGET_COMMITTEE_SIZE* = 2^7 ##\
## Number of validators in the committee attesting to one shard ## Number of validators in the committee attesting to one shard
@ -89,10 +94,11 @@ const
## the validator pool ## the validator pool
# Time parameter, here so that GENESIS_EPOCH can access it # Time parameter, here so that GENESIS_EPOCH can access it
EPOCH_LENGTH* = 64 ##\ EPOCH_LENGTH* {.intdefine.} = 64 ##\
## (~6.4 minutes) ## (~6.4 minutes)
## slots that make up an epoch, at the end of which more heavy ## slots that make up an epoch, at the end of which more heavy
## processing is done ## processing is done
## Compile with -d:EPOCH_LENGTH=4 for shorter epochs
# Initial values # Initial values
# https://github.com/ethereum/eth2.0-specs/blob/v0.2.0/specs/core/0_beacon-chain.md#initial-values # https://github.com/ethereum/eth2.0-specs/blob/v0.2.0/specs/core/0_beacon-chain.md#initial-values

View File

@ -517,7 +517,8 @@ func processEpoch(state: var BeaconState) =
let # Previous epoch boundary let # Previous epoch boundary
# TODO check this with spec... # TODO check this with spec...
negative_uint_hack = negative_uint_hack =
if state.slot < 2 * EPOCH_LENGTH: 0'u64 else: state.slot - 2 * EPOCH_LENGTH if state.slot < 2'u64 * EPOCH_LENGTH: 0'u64
else: state.slot - 2'u64 * EPOCH_LENGTH
previous_epoch_boundary_attestations = previous_epoch_boundary_attestations =
boundary_attestations( boundary_attestations(
state, get_block_root(state, negative_uint_hack), state, get_block_root(state, negative_uint_hack),

View File

@ -25,11 +25,15 @@ mkdir -p $BUILD_OUTPUTS_DIR
BEACON_NODE_BIN=$BUILD_OUTPUTS_DIR/beacon_node BEACON_NODE_BIN=$BUILD_OUTPUTS_DIR/beacon_node
VALIDATOR_KEYGEN_BIN=$BUILD_OUTPUTS_DIR/validator_keygen VALIDATOR_KEYGEN_BIN=$BUILD_OUTPUTS_DIR/validator_keygen
SLOT_DURATION="-d:SLOT_DURATION=3" # Default is 6
# Run with "SHARD_COUNT=4 ./start.sh" to change these
DEFS="-d:SHARD_COUNT=${SHARD_COUNT:-4} "
DEFS+="-d:EPOCH_LENGTH=${EPOCH_LENGTH:-8} "
DEFS+="-d:SLOT_DURATION=${SLOT_DURATION:-3} "
if [[ -z "$SKIP_BUILDS" ]]; then if [[ -z "$SKIP_BUILDS" ]]; then
nim c -o:"$VALIDATOR_KEYGEN_BIN" "$SLOT_DURATION" -d:release beacon_chain/validator_keygen nim c -o:"$VALIDATOR_KEYGEN_BIN" $DEFS -d:release beacon_chain/validator_keygen
nim c -o:"$BEACON_NODE_BIN" "$SLOT_DURATION" beacon_chain/beacon_node nim c -o:"$BEACON_NODE_BIN" $DEFS beacon_chain/beacon_node
fi fi
if [ ! -f $STARTUP_FILE ]; then if [ ! -f $STARTUP_FILE ]; then