this is the beginning of tracking block-slots more precisely, so we can
the justification epoch slot bug.
* avoid asyncDiscard (swallows assertions)
* fix attestation delay
* fix several state root cache bugs
* introduce workaround for genesis epoch spec issue
* On the testnet site, the first N instead of the last N validators
will be considered reserved for users
* The number of validators is consistently named `totalValidators`
in all commands
* Proper keys are generated by default in validator_keygen
* no need to pass prev_block_root when updating state
* some Slot fixes
* fix `hash_tree_root` for Slot, Epoch
* detect missing hash_tree_root type support
* remove some <0.5 state checks
* ssz: update to 0.5.1:ish
* slightly fewer seq allocations
* still a lot of potential for optimization
* fixes#174
* ssz: avoid reallocating leaves (logN merkle impl)
* rm gone-in-0.5.0 Proposal, verifyBlockSignature, and slot check which moved to spec function processBlockHeader
* mark get_attestation_participants and get_epoch_committee_count as 0.5.1; finish updating processAttestations to 0.5.1; add kludgy workaround for bug relating to get_winning_roots_etc using crosslink_data_root as index when we have that as ZERO_HASH for all leading to it confusing attesters on different shards; rm BeaconState.latest_attestations, which splits into previous_epoch_attestations and current_epoch_attestations
* Fix CI due to removed latest_attestations field
* add simple bitfield type (fixes#19)
* fix bit endianess to match spec
* consolidate attestation and block logging
* cruft cleanup
* run optimizer on tests, speeds up build
* begin refactoring 0.5.0 epoch transition at justification and finalization
* update processTransfers to 0.5.0 spec
* update get_crosslink_committees_at_slot to 0.5.0 except for noted workaround for pre-0.5.0 spec bug related to epoch boundary conditions, to be flipped in more coordinated way with other epoch processing changes
* mark ejection processing as 0.5.0
* 0.5.0 epoch update finalization
* rm BEACON_CHAIN_SHARD_NUMBER to complete updating miscellaneous constants to 0.5.0
* mark verify_slashable_attestation as 0.5.0
* update process_attester_slashing to 0.5.0
* update process_slashings(...) to 0.5.0 and mark process_exit_queue as 0.5.0
* refactor epoch processing by implementing 0.5.0's update_registry_and_shuffling_data(...)
With these changes, running a simulation is very close to running
an actual testnet. Some checks have been added in the client to
make sure you are not connecting to an incompatible network (e.g.
a network running with a different number of shards).
* begin 0.5.0 spec update: parent_root -> previous_block_root, BeaconState.justified_epoch -> BeaconState.current_justified_epoch, DOMAIN_PROPOSAL -> DOMAIN_BEACON_BLOCK, temporarily rename BeaconBlockHeader to BeaconBlockHeaderRLP to allow for gradual re-merging without disrupting RLP; mark a few unchanged functions and data types, implement get_temporary_block_header/get_empty_block/should_update_validator_registry/processBlockHeader/cacheState; update a few others
* a dozen or so more trivial mostly comment changes, finding more unchanged parts of 0.5.0
* several more trivial changes; goal is to reduce noise around the upcoming substantial changes (epoch processing, etc)
* keep track of a finalized block
* keep track of all justified blocks
* use naive spec version of LMD ghost
* cache slot number and a few more things in BlockRef
* keep track of the latest vote of each validator
* depend less on the state of node.state (it's a cache, effectively)
Passing along no-name command line arguments when using make (from Nimbus) would need make target revamps that are a bit clumsy AFAIK, so using environment variables in the spirit of USE_MULTITAIL to get the number of validators and nodes makes more sense to me.
This lets us run the sim from nim-beacon-chain with
```bash
VALIDATORS=512 NODES=100 USE_MULTITAIL="yes" tests/simulation/start.sh
```
and from Nimbus with:
```bash
VALIDATORS=512 NODES=100 USE_MULTITAIL="yes" make eth2_network_simulation
```
Also makes for a more verbose launch process.
To enable it, comment out the 'withLibp2p' line in nim.cfg
The history was squashed in order to remove an accidentally
commited binary file.
Other changes:
* SSZ was adapted to use the common serialization framework
* gossibsup.subscribe is not using async handlers at the moment
and this allowed me to simplify it
* set epoch_boundary_root - chain finalizes!
* fix slotStart to offset GENESIS_SLOT
* work around bug that will be fixed by
https://github.com/ethereum/eth2.0-specs/pull/732
* compile with debug info (there was a GC-related crash in C land)
* fix state db lookup typo
* fix randao reveal slot when proposing blocks
* only store blocks that can be applied to a state
* store state at every epoch boundary (yes, needs pruning!)
* split out state advancement function when there's no block
* default state sim to 0.9 attestation ratio
* allow running more or fewer validators
* use deterministic key generation for tests to avoid exhausting system
RNG
* update README with simulator docs
* write the data of each validator to separate file, instead of a big
chainstart.json (makes it easier to run different validator counts)
* prevent balance underflow, per spec implementation note
* verify that permutation shuffing works: add YAML dependency to be used for ingesting test cases; switch from blake2 to keccak256 to match EF test cases; remove inefficient naive-spec-version of shuffling algorithm now that protolambda's can be tested directly
* Complete scan through v0.3.0 spec; remaining known discreptancy is in bls_verify_multiple
* switch remaining slot-misuses of get_active_validator_indices to epochs
* spec workaround
* finish first 0.3.0 pass by getting slow, naive version of bls_verify_multiple running
* implement in-memory block graph
* store tail block in database
* resolve unknown parents by syncing them from peers
* introduce concept of resolved blocks and attestations - those that
follow minimal protocol rules
* update state head lazily
* log more stuff
* shortHash -> shortLog
* start 9/10 beacon nodes by default, last can be started manually
* see also #134
* fix start.sh epoch length
* convert some asserts to doAsserts to keep them in release mode builds; rename get_initial_beacon_state to get_genesis_beacon_state to track spec; switch target spec version to 0.3.0; switch references to penalize_validator to slash_validator/slashValidator to track spec; make some function returns safer by omitting 'return'
* 2x shuffling speedup by hoisting pivot calculations per https://github.com/protolambda/eth2-shuffle
* fix initial attestation pool on reordered attestations
* simplify db layer api
* load head block from database on startup, then load state
* significantly changes database format
* move subscriptions to separate proc's
* implement block replay from historical state
* avoid rescheduling epoch actions on block receipt (why?)
* make sure genesis block is created and used
* relax initial state sim parameters a bit
* move attestation pool to separate file
* combine attestations lazily when needed
* advance state when there's a gap while attesting
* compile beacon node with optimizations - it's tooo slow right now
* log when unable to keep up
* s/slot_included/inclusion_slot/; s/participation_bitfield/aggregation_bitfield/; rearrange some type definitions to match spec order
* a couple more Eth1Data-related spec syncs
* s/CrosslinkRecord/Crosslink/
* {MIN,MAX}_DEPOSIT to {MIN,MAX}_DEPOSIT_AMOUNT; rm SHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD; per https://github.com/ethereum/eth2.0-specs/issues/378 and 35adc9c61a rm persistent_committees, persistent_committee_reassignments, and ShardReassignmentRecord
* complete switchover from status/ValidatorStatusCodes to status_flags/INITIATED_EXIT/WITHDRAWABLE validator representation
You'll need the latest versions of nim-eth-p2p, nim-serialization
and nim-json-serialization.
Before starting the simulation script, make sure to delete any previous
json files from the simulation folder:
```
rm tests/simulation/*.json
tests/simulation/start.sh
```
This should survive the creation of few blocks before diying with a
block validation error.
* spec updates
* balances move out to separate seq
* bunch of placeholders for proof-of-custody / phase1
* fix inclusion distance adjustment
* modify state in-place in `updateState` (tests spent over 80% time
copying state! now it's down to 25-50)
* document several conditions and conversations
* some renames here and there to follow spec
* spec updates
* random small updates
* ssz no longer sorts by field, fix enum serialization
* rewire block processing a little to avoid a few state copies
* add a state simulation tool that writes out jsons
* ssz: finish implementation
* add object support, simplify implementation
* fix extra round of hashing in tree_hash_root
* ssz: cleanups
* work around Nim range bug for Uint24, cleanups
* some minor renames
* fix some leftover block slot references (replaced by state slot)
* fix some more uint underflows
* update epoch calculations (reward et al)
* now works past 100 epochs at least with empty blocks (very slow)
* use repeat_hash from spec in randao
* add some logging to state processing
* export crypto string converters in spec insulation layer
* enable block signature verification
* ssz: add support for arrays, remove custom data type code
* correctly handle previous and new block
* add trivial block processing tests
* prefer iterative repeat_hash
* state transition mostly done
* handle most specials and slashings
* spec updates
* make several constants uint64 to help minimize casting
* document data type woes - will have to revisit these
* change comment style on fields and constants to make room for better
comments
* add BLSVerify and BLSAddPbkeys facades to insulate spec code from
milagro
* fix proof of possession type
* drop explicitly ordered container fields from ssz - there's an issue
open to sort this out before committing it to the spec
* more work on block processing
* fix some unsigned issues
* fix ssz issue when last chunk is not full
* work around empty const seq compiler bug
* XXX -> TODO
* rename from tree_ssz
* add special cases for some types based on beacon chain code
* add smoke test
* avoids some trivial allocations, but the big one remains - the
temporary
chunk buffer is still heap allocated
* update to handle zero-length buffer case same as latest spec
* first part of spec updating; some constants, structure changes, data type changes from int to uint
* Update beacon_chain/datatypes.nim
Co-Authored-By: tersec <tersec@users.noreply.github.com>