2189 Commits

Author SHA1 Message Date
tersec
8912196335
Fix Altair epoch processing and add/enable remaining epoch processing tests (#2619)
* fix Altair epoch state transitions

* re-enable and re-add near-complete Altair epoch processing test vectors: inactivity, justification & finalization, participation flag, slashings, and sync committee updates
2021-05-30 20:23:10 +00:00
Jacek Sieka
60df17786e avoid reading legacy db on write
* don't consider legacy database when writing state - this read is slow
on kvstore
* avoid epoch transition when there's an exact match in cache already
* simplify init to only consider checkpoint states
2021-05-30 12:32:51 +03:00
Jacek Sieka
df7bc87af5 Pre-compute slot transition for clearance state
This way we perform the expensive epoch processing before the block
arrives.

Of course, this may lead to speculative misses which in turn lead to
replays - it's likely that in the case of a miss, we'll see a replay
regardless.
2021-05-30 12:04:09 +03:00
tersec
aa6177814e
re-enable state_transition() rollback in phase0 (#2613) 2021-05-29 03:54:56 +00:00
Jacek Sieka
2df8a3b28d
add more block processing durations (#2611) 2021-05-28 21:03:20 +02:00
Zahary Karadjov
0afb5be6b4 A simple script for fetching detailed deposit data 2021-05-28 19:34:20 +03:00
Jacek Sieka
7f52ffb8d9
clean up block processing (#2610)
* gossip_to_consensus -> block_processor (it's processing only blocks,
but not only from gossip)
* measure queue and validation time for blocks
* measure assignment and state loading times for updateStateData
* avoid some unnecessary block copies in block sync
* warn that database is corrupt if we hit tail without a state
2021-05-28 19:34:00 +03:00
tersec
c06ffc7804
proposed structure for altair (#2323)
* proposed structure for hf1

* refactor datatypes.nim into datatypes/{base, phase0, hf1}.nim

* hf1 is Altair

* some syncing with alpha 2

* adjust epoch processing to disambiguate access to RewardFlags

* relocate StateData to stay consistent with meaning phase 0 StateData

* passes v1.1.0 alpha 5 SSZ consensus object tests

* Altair block header test fixtures work

* fix slash_validator() so that Altair attester slashings, proposer slashings, and voluntary exit textures work

* deposit operation Altair test fixtures work

* slot sanity and all but a couple epoch transition tests switched to Altair

* attestation Altair test fixtures work

* Altair block sanity test fixtures work

* add working altair sync committee tests

* improve workarounds for sum-types-across-modules Nim bug; incorporate SignedBeaconBlock root reconstuction to SSZ byte reader
2021-05-28 15:25:58 +00:00
tersec
46c5a0110a
log doppelganger attestation signature; rm withState.HashedBeaconState uses (#2608) 2021-05-28 15:51:15 +03:00
Jacek Sieka
5be1f8bf93
Revert "increase sqlite cache size (#2607)"
This reverts commit f55c4bc40238be7fa6f0ad658bef38e8489a6d97.
2021-05-28 11:35:23 +02:00
Jacek Sieka
f55c4bc402
increase sqlite cache size (#2607)
This is a test to see how the prater nodes react
2021-05-27 21:16:04 +02:00
Jacek Sieka
d16da06c92 ncli_db: validator performance database tool
Record attestation performance per epoch in sqlite database
2021-05-27 19:14:26 +03:00
cheatfate
90e3fb246f Fix assertion crash when posting block via REST API. 2021-05-27 18:59:30 +03:00
Jacek Sieka
ab70f371e1
Revert "create new database in separate file (#2596)" (#2604)
This reverts commit eebc828778ea4fd6ce907cfee075153173b27b8f.

Adding a separate file turns out not to be enough. This PR reverts the
separate file change.

Another theory is that the large kvstore table causes cache thrashing -
all database connections share a common page cache which would explain
the poor performance of the separate file solution.
2021-05-27 12:59:42 +02:00
Mamy André-Ratsimbazafy
d05c9dbcf4 improve batch crypto sanity checks error reporting 2021-05-26 18:17:12 +03:00
Jacek Sieka
18d26071d8
hotfix migration
should have just kept the full copy-pasted dbseq init
2021-05-26 09:56:21 +02:00
Jacek Sieka
eebc828778
create new database in separate file (#2596)
The V1 table structure shows great improvements in performance, but if
there's an old `kvstore` without rowid:s, these benefits are nullified:
reorgs during writes and deletes remain expensive (even if the
degradation is reduced somewhat).

This PR creates the tables in a new file instead, and uses the old file
as a read-only store - this has several interesting properties:

* the old database is left completely untouched - this guarantees that
downgrades work smooth (they'll only need to resync their missing
portions)
* starting sync after this PR means only a v1 database is created
* v0 databases stick around - no migration is performed (for now)

Future PR:s can introduce migration of the data from one database to
another - a simply copy will take hours which is downtime we want to
avoid - at that point, it might make sense to migrate straight to era
files instead.
2021-05-26 09:07:18 +02:00
tersec
3a59dc16c2
use v1.1.0 phase 0 test vectors (#2592)
* use v1.1.0 phase 0 test vectors

* re-export process_final_updates()
2021-05-24 10:42:40 +02:00
Jacek Sieka
584fcd50c1
ncli: fix inclusion distance statistic (#2587) 2021-05-24 10:40:45 +02:00
tersec
0b0bfd1de0
use StateData in place of BeaconState outside state transition code (#2551)
* use StateData in place of BeaconState outside state transition code

* propagate more StateData usage

* remove withStateVars().state

* wrap get_beacon_committee(BeaconState, ...) as gbc(StateData, ...)

* switch makeAttestation() to use StateData

* use StateData wrapper/dispatcher for get_committee_count_per_slot()

* convert AttestationCache.init(), weak subjectivity functions, and updateValidatorMetrics()

* add get_shuffled_active_validator_indices(StateData) and get_block_root_at_slot(StateData)

* switch makeAttestationData() to StateData

* sync AllTests-mainnet.md after rebase
2021-05-21 09:23:28 +00:00
cheatfate
be5661eebc Fix /api/eth/v1/validator/aggregate_and_proofs call 2021-05-21 09:47:13 +03:00
cheatfate
6869a1ad33 Convert all the tuples to objects because of de-serialization of tuples issue. 2021-05-21 09:47:13 +03:00
cheatfate
d61b5f46e1 Added missing redirection for POST /eth/v1/beacon/pool/attestations. 2021-05-20 19:42:08 +03:00
cheatfate
d4970e07d2 Use atSlot() instead of getBlockByXXX(). 2021-05-20 19:42:08 +03:00
Jacek Sieka
8dbd796401 prune validatorIndexFromPubKey table 2021-05-20 14:10:23 +03:00
Zahary Karadjov
acee2d3709
Remove an inappropriate merge artifact 2021-05-20 13:55:33 +03:00
Zahary Karadjov
dc49a51654
Merge stable into unstable (take 2) 2021-05-20 13:52:09 +03:00
Zahary Karadjov
b7aa30adfd
Merge stable into unstable 2021-05-20 13:50:40 +03:00
tersec
d8bb91d9a9
partially integrate eth1 merge changes (#2548)
* partially integrate eth1 merge changes

* use hexToSeqByte() and validate execution engine opaque transaction length

* remove incorrect REST serialization code
2021-05-20 10:44:13 +00:00
Eugene Kabanov
5b5ea2e813
Fix integer overflow issue in sync_manager. (#2564)
* Make Refactor rewind point assignment more concrete.

* Fix overflow issue in getRewindPoint().
Add tests.
2021-05-18 12:25:14 +02:00
Eugene Kabanov
cf06c4e87e
Make REST server more compatible with Lighthouse and Teku validator clients. (#2575)
* Allow REST server to parse arrays with comma delimiter.

* Fix compilation issues because of new presto framework.
2021-05-18 12:24:57 +02:00
Zahary Karadjov
2cb1396969
Log the slashing DB pruning time 2021-05-17 21:42:28 +03:00
Zahary Karadjov
f6a1f602b4
Handle changes in the latest version of Confutils 2021-05-17 21:42:28 +03:00
Zahary Karadjov
b9924214ab
Better error-handling for the slashingdb import/export feature
* Error when specifying an invalid --data-dir (or --validator-dir)
* Error when entering an invalid validator public key (e.g. invalid hex value)
* Warning when attempting to export a validator not present in the local database

Some unnecessary remains of the v1 mode has been removed as well
2021-05-17 21:42:23 +03:00
Jacek Sieka
97f4e1fffe
Db1 cont (#2573)
* Revert "Revert "Upgrade database schema" (#2570)"

This reverts commit 6057c2ffb4a481d3994c8fe5a46e7b754d12ae8f.

* ssz: fix loading empty lists into existing instances

Not a problem earlier because we didn't reuse instances

* bump nim-eth

* bump nim-web3
2021-05-17 18:37:26 +02:00
Zahary Karadjov
5c313b958e
Simplify the slashing db import/export CLI 2021-05-17 17:12:03 +03:00
tersec
6057c2ffb4
Revert "Upgrade database schema" (#2570)
This reverts commit 22ddf747520dce279f8ff13b77589f2a9cfd05e9.
2021-05-17 06:34:44 +00:00
Mamy André-Ratsimbazafy
dacc508992
slashing import integrated in NBC 2021-05-16 21:48:38 +03:00
Mamy André-Ratsimbazafy
0574531c43
add restore from slashing DB 2021-05-16 21:45:24 +03:00
Jacek Sieka
895ccd1c95 clean up imports (#2557) 2021-05-14 20:08:07 +03:00
Jacek Sieka
22ddf74752 Upgrade database schema
The `kvstore` design we're using now turns out to not be the best way to
use `sqlite` - in particular, there are some significant benefits to
using rowid in certain situations and to keep data in separate tables.

With this branch, there are massive improvements in startup time
(seconds instead of minutes) and state/block storage and pruning times
(milliseconds instead of seconds) - these improvements can in particular
be seen on slow drives and translate directly into better attestation
performance.

* update kvstore to new keyspace design
* remove `DirStoreRef` and the hidden `--state-db-kind` option - this
was an experiment to store large blobs in files, but with the new
kvstore, there's no compelling reason to do so
* remove `DbMap` - unused and would need updating for new keyspace
design
* introduce separate tables for each data type (blocks, states etc)
* remove "WITHOUT ROWID" pessimization for tables with large blobs
* close DbSeq statements explicitly (and earlier)
* store beacon block summaries in separate table, without SSZ
compression and load them all with single query on startup
* stop storing backwards compat full states
* mark genesis beacon block as trusted
* avoid faststreams when loading SSZ data
* remove `DisagreementBehavior` (unused)
2021-05-14 20:05:23 +03:00
Zahary Karadjov
0a91c3c592
Prepare for the v1.3.0 release (more to come) 2021-05-12 16:28:10 +03:00
Jacek Sieka
0022015a91
clean up imports (#2557) 2021-05-12 14:31:02 +02:00
Jacek Sieka
0a477eb2d3
fix subnet logic (#2555)
This PR decreases the lead subscription time which should help
decrease bandwidth usage and CPU making the subscription for future
aggregation happen a bit later. There's room for more tuning here,
probably.

* fix missing negation from in #2550
* fix silly bitarray issues
* decrease subnet lead subscription time
* log all subnet switching source data
* rename subnet trackers to refer to stability and aggregate subnets
* more tests
2021-05-11 22:03:40 +02:00
Mamy Ratsimbazafy
149ff49c8e
Remove correlated queries in finalization pruning, all use indexes (#2554) 2021-05-11 10:41:37 +02:00
Mamy Ratsimbazafy
e6b559a35a
Slashing db pruning [Merge only after v2 has been default for 1 noticeable release] (#2452)
* Enable slashing DB pruning

* integrate slashing DB pruning with onSlotEnd

* rebase tests
2021-05-10 16:32:28 +02:00
Jacek Sieka
867d8f3223
Perform attestation check before broadcast (#2550)
Currently, we have a bit of a convoluted flow where when sending
attestations, we start broadcasting them over gossip then pass them to
the attestation validation to include them in the local attestation pool
- it should be the other way around: we should be checking attestations
_before_ gossipping them - this serves as an additional safety net to
ensure that we don't publish junk - this becomes more important when
publishing attestations from the API.

Also, the REST API was performing its own validation meaning
attestations coming from REST would be validated twice - finally, the
JSON RPC wasn't pre-validating and would happily broadcast invalid
attestations.

* Unified attestation production pipeline with the same flow for gossip,
locally and API-produced attestations: all are now validated and entered
into the pool, then broadcast/republished
* Refactor subnet handling with specific SubnetId alias, streamlining
where subnets are computed, avoiding the need to pass around the number
of active validators
* Move some of the subnet handling code to eth2_network
* Use BitArray throughout for subnet handling
2021-05-10 09:13:36 +02:00
Jacek Sieka
646923c3dd
add attestation stats tool to ncli_db (#2539)
This also makes future efforts to provide metrics and logs for
attestation efficiency easier

* Export rewards from epoch transition
* Use less memory for reward calculation (bool -> set[enum], field
alignment)
* Reuse reward memory when replaying, avoiding spike
* Allow replaying any range in ncli_db benchmark
2021-05-07 13:36:21 +02:00
Jacek Sieka
5cd5da74c4
Gossipsub unsubscribe fixes (fixes #2540) (#2545) 2021-05-07 06:31:28 +02:00
tersec
1d6c8ee9ab
store full state 4x less often (#2542) 2021-05-06 07:36:18 +02:00