Commit Graph

1562 Commits

Author SHA1 Message Date
Igor Mandrigin
fbcf48f29d
Store ethash datafiles in a separate directory. (#949) 2020-08-20 15:59:06 +01:00
ledgerwatch
01f211f3b8
Revert "IH: no retain list (#946)" (#948)
This reverts commit f86ed64288.
2020-08-20 13:37:34 +01:00
Alex Sharov
f86ed64288
IH: no retain list (#946)
* experiment of not using retain list

* better handle sub-tx

* save progress

* don't touch collector

* don't run collector on sub-tx because of `mdb_cursor_put: MDB_TXN_FULL: Transaction has too many dirty pages - transaction too big`

* clear

* clear
2020-08-20 11:42:43 +01:00
Igor Mandrigin
3f81472831
Never store Ethash caches to disk (#944)
* always keep ethash caches in ram

* fix tests
2020-08-20 11:12:51 +01:00
Alex Sharov
1dcc2b141a
Rpcdaemon as lib (#940)
* share config object

* create default config and logger

* move db connection to common func

* move server start to cli package

* clear

* clear

* rename cli to rpc

* use unified SetupLogger func

* make all root flag persistent

* use common flags in different packages

* use common flags in different packages

* move TraceTx method to eth package

* use native slice flags

* create package "turbo"

* disable geth api

* disable geth api

* move more data types to turbo/adapter package

* add support for customApiList

* run more

* run more

* run more

* dog-food

* move DoCall

* move DoCall

* fix tests

* fix test
2020-08-19 12:46:20 +01:00
Evgeny Danilenko
3b40819444
grpc regenerate (#936)
* grpc regenerate

* use string type for id in net_version
2020-08-18 20:22:49 +03:00
ledgerwatch
09440dccd3
Print memory stats (#934) 2020-08-17 16:27:42 +01:00
Alex Sharov
0e253e7336
lmdb transactions of unlimited size (#918)
* add logging to loader

* use pure tx in etl loading, logs in mutation commit

* clean

* bletter logging and more cleanup

* bletter logging and more cleanup

* increase batch size to 500M

* better batch commit logging

* async fsync

* sync fsync

* sync fsync

* unify logging

* fix corner-case when etl can use empty bucket name

* fix tests

* better logging

* better logging

* rebase master

* remove lmdb.NoMetaSync flag for now

* consistent walk and multi-walk

* clean

* sub tx

* add consistent multi-put

* implement dupsort support in one new cursor method

* clear
2020-08-17 07:45:52 +01:00
Alex Sharov
6379516a0f
add support of blocks compression to txpool stage (#925) 2020-08-17 10:17:40 +07:00
Igor Mandrigin
db6a0c43ee linter 2020-08-15 22:17:38 +02:00
Igor Mandrigin
ae784e4b0a fixups1 2020-08-15 22:08:57 +02:00
Igor Mandrigin
d848233275 Merge branch 'master' into geth-1.9.19
# Conflicts:
#	cmd/geth/consolecmd.go
#	cmd/rpcdaemon/service/service.go
#	cmd/utils/flags.go
#	eth/backend.go
2020-08-15 21:55:09 +02:00
Igor Mandrigin
71758e1fcc fixups 2020-08-15 21:34:22 +02:00
Igor Mandrigin
19ffb68e8c fix fetcher 2020-08-15 21:04:45 +02:00
Igor Mandrigin
9cc5690483 fix downloader tests 2020-08-15 20:32:50 +02:00
Igor Mandrigin
d6fe697ee1 fixups. make geth successful 2020-08-15 19:32:05 +02:00
Alex Sharov
90fa69a9e5
Swap IH and HashState stages (#922)
* move ih stage v0

* save progress

* save working version

* baby step

* baby step

* baby step

* non-baby step

* cleanup
2020-08-15 14:49:36 +01:00
Igor Mandrigin
a06f7b2d9e fixups 2020-08-14 17:05:15 +02:00
timcooijmans
9e79642dfe eth: use maxQueuedTxAnns for to limit the number of transactions announced (#21419) 2020-08-14 16:42:00 +02:00
rene
b03de86a5c downloader: add eth65 tests (#21383)
* eth65 tests

linted

* remove non-latest eth light tests
# Conflicts:
#	eth/downloader/downloader_test.go
2020-08-14 16:39:16 +02:00
rene
fe1bb62bad node: refactor package node (#21105)
This PR significantly changes the APIs for instantiating Ethereum nodes in
a Go program. The new APIs are not backwards-compatible, but we feel that
this is made up for by the much simpler way of registering services on
node.Node. You can find more information and rationale in the design
document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775.

There is also a new feature in Node's Go API: it is now possible to
register arbitrary handlers on the user-facing HTTP server. In geth, this
facility is used to enable GraphQL.

There is a single minor change relevant for geth users in this PR: The
GraphQL API is no longer available separately from the JSON-RPC HTTP
server. If you want GraphQL, you need to enable it using the
./geth --http --graphql flag combination.

The --graphql.port and --graphql.addr flags are no longer available.

# Conflicts:
#	cmd/faucet/faucet.go
#	cmd/geth/chaincmd.go
#	cmd/geth/config.go
#	cmd/geth/consolecmd.go
#	cmd/geth/main.go
#	cmd/utils/flags.go
#	cmd/wnode/main.go
#	core/rawdb/freezer.go
#	eth/api_backend.go
#	eth/backend.go
#	ethclient/ethclient_test.go
#	ethstats/ethstats.go
#	graphql/service.go
#	internal/ethapi/backend.go
#	les/api_backend.go
#	les/api_test.go
#	les/checkpointoracle/oracle.go
#	les/client.go
#	les/commons.go
#	les/server.go
#	miner/stresstest/stress_clique.go
#	miner/stresstest/stress_ethash.go
#	mobile/geth.go
#	node/api.go
#	node/node.go
#	node/node_example_test.go
#	node/node_test.go
#	node/rpcstack.go
#	node/rpcstack_test.go
#	node/service.go
#	node/service_test.go
#	node/utils_test.go
#	p2p/simulations/examples/ping-pong.go
#	p2p/testing/peerpool.go
#	p2p/testing/protocolsession.go
#	p2p/testing/protocoltester.go
#	whisper/mailserver/server_test.go
#	whisper/whisperv6/api_test.go
#	whisper/whisperv6/filter_test.go
#	whisper/whisperv6/whisper.go
#	whisper/whisperv6/whisper_test.go
2020-08-14 16:33:59 +02:00
Igor Mandrigin
f4102e115d
Update README.md 2020-08-13 10:42:32 +02:00
Evgeny Danilenko
5d39fe8873
RPCDeamon coinbase, net_version (#911)
* use eth.backend

* net_version

* add coinbase to the console test
2020-08-12 14:47:59 +01:00
rene
018cfd0b6d eth/downloader: remove eth62 (#21378)
* init

notes

removed some mentions of eth62, bumped protocol err too old to >=63

* remove sanity checks and bump supported protocol version up to 63

* remove 62 tests, still need to add 65

* remove 65 tests
# Conflicts:
#	eth/downloader/downloader_test.go
#	eth/downloader/peer.go
2020-08-12 12:42:36 +02:00
gary rong
09753dff15 les: implement new les fetcher (#20692)
* cmd, consensus, eth, les: implement light fetcher

* les: address comment

* les: address comment

* les: address comments

* les: check td after delivery

* les: add linearExpiredValue for error counter

* les: fix import

* les: fix dead lock

* les: order announces by td

* les: encapsulate invalid counter

* les: address comment

* les: add more checks during the delivery

* les: fix log

* eth, les: fix lint

* eth/fetcher: address comment
# Conflicts:
#	cmd/geth/retesteth.go
#	consensus/clique/clique.go
#	consensus/consensus.go
#	consensus/ethash/consensus.go
#	consensus/ethash/sealer.go
#	eth/fetcher/block_fetcher.go
#	eth/fetcher/block_fetcher_test.go
#	eth/handler.go
#	les/client.go
#	les/client_handler.go
#	les/clientpool.go
#	les/fetcher.go
#	les/odr_test.go
#	les/peer.go
#	les/server.go
#	les/server_handler.go
#	les/test_helper.go
#	les/utils/expiredvalue.go
#	les/utils/expiredvalue_test.go
2020-08-12 12:22:51 +02:00
gary rong
1bc2bef061 cmd, core, eth, light, trie: dump clean cache periodically (#20391)
* cmd, core, eth, light, trie: dump clean cache periodically

* eth: update config

* trie: minor fix

* core, trie: address comments

* eth: remove useless

* trie: print clean cache dump start too

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
# Conflicts:
#	core/blockchain.go
#	core/genesis.go
#	core/state/database.go
#	eth/api_tracer.go
#	eth/backend.go
#	eth/config.go
#	light/postprocess.go
#	trie/database.go
2020-08-12 12:01:13 +02:00
Evgeny Danilenko
3980fa7d45
Grps eth_sendTransaction (#882)
* implementation

* tidy gomod

* linters

* fix cmd test

* fix

* fix lint
2020-08-11 22:09:30 +01:00
Alex Sharov
3899f2defe
recover_from_hashstate_stage_interruption (#903) 2020-08-11 17:41:06 +07:00
Alex Sharov
6df97dec22
save progress (#886) 2020-08-11 17:36:29 +07:00
Alex Sharov
d9d9e14f45
change bucket type to string (#894) 2020-08-11 06:55:32 +07:00
Giulio rebuffo
057894994d
add blockhashes stage (#862)
* add blockhashes stage

* unwindOrder specified

* fixed typo

* added common.copybytes

* fixed little typo

* better progress

* better progress

* refactoring with etl

* added blockhashes to disabled stages in cmd/integration

* added migraations

* fixed go.mod

* better migrations

* rename unwind

* simplified migrations

* added onloadcommit
2020-08-10 18:46:06 +01:00
Igor Mandrigin
8600616c3d geth 1.9.18 post-rebase fixups 2020-08-08 17:33:35 +02:00
Martin Holst Swende
e3e00089f4 eth/downloader: refactor downloader + queue (#21263)
* eth/downloader: refactor downloader + queue

downloader, fetcher: throttle-metrics, fetcher filter improvements, standalone resultcache

downloader: more accurate deliverytime calculation, less mem overhead in state requests

downloader/queue: increase underlying buffer of results, new throttle mechanism

eth/downloader: updates to tests

eth/downloader: fix up some review concerns

eth/downloader/queue: minor fixes

eth/downloader: minor fixes after review call

eth/downloader: testcases for queue.go

eth/downloader: minor change, don't set progress unless progress...

eth/downloader: fix flaw which prevented useless peers from being dropped

eth/downloader: try to fix tests

eth/downloader: verify non-deliveries against advertised remote head

eth/downloader: fix flaw with checking closed-status causing hang

eth/downloader: hashing avoidance

eth/downloader: review concerns + simplify resultcache and queue

eth/downloader: add back some locks, address review concerns

downloader/queue: fix remaining lock flaw

* eth/downloader: nitpick fixes

* eth/downloader: remove the *2*3/4 throttling threshold dance

* eth/downloader: print correct throttle threshold in stats

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
# Conflicts:
#	eth/downloader/downloader.go
#	eth/downloader/downloader_test.go
#	eth/downloader/queue.go
#	eth/downloader/statesync.go
#	eth/fetcher/block_fetcher.go
2020-08-07 14:23:49 +02:00
Martin Holst Swende
a4b70f9ee9 core/vm: less allocations for various call variants (#21222)
* core/vm/runtime/tests: add more benchmarks

* core/vm: initial work on improving alloc count for calls to precompiles

name                                  old time/op    new time/op    delta
SimpleLoop/identity-precompile-10M-6     117ms ±75%      43ms ± 1%  -63.09%  (p=0.008 n=5+5)
SimpleLoop/loop-10M-6                   79.6ms ± 4%    70.5ms ± 1%  -11.42%  (p=0.008 n=5+5)

name                                  old alloc/op   new alloc/op   delta
SimpleLoop/identity-precompile-10M-6    24.4MB ± 0%     4.9MB ± 0%  -79.94%  (p=0.008 n=5+5)
SimpleLoop/loop-10M-6                   13.2kB ± 0%    13.2kB ± 0%     ~     (p=0.357 n=5+5)

name                                  old allocs/op  new allocs/op  delta
SimpleLoop/identity-precompile-10M-6      382k ± 0%      153k ± 0%  -59.99%  (p=0.000 n=5+4)
SimpleLoop/loop-10M-6                     40.0 ± 0%      40.0 ± 0%     ~     (all equal)

* core/vm: don't allocate big.int for touch

name                                  old time/op    new time/op    delta
SimpleLoop/identity-precompile-10M-6    43.3ms ± 1%    42.4ms ± 7%     ~     (p=0.151 n=5+5)
SimpleLoop/loop-10M-6                   70.5ms ± 1%    76.7ms ± 1%   +8.67%  (p=0.008 n=5+5)

name                                  old alloc/op   new alloc/op   delta
SimpleLoop/identity-precompile-10M-6    4.90MB ± 0%    2.46MB ± 0%  -49.83%  (p=0.008 n=5+5)
SimpleLoop/loop-10M-6                   13.2kB ± 0%    13.2kB ± 1%     ~     (p=0.571 n=5+5)

name                                  old allocs/op  new allocs/op  delta
SimpleLoop/identity-precompile-10M-6      153k ± 0%       76k ± 0%  -49.98%  (p=0.029 n=4+4)
SimpleLoop/loop-10M-6                     40.0 ± 0%      40.0 ± 0%     ~     (all equal)

* core/vm: reduce allocs in staticcall

name                                  old time/op    new time/op    delta
SimpleLoop/identity-precompile-10M-6    42.4ms ± 7%    37.5ms ± 6%  -11.68%  (p=0.008 n=5+5)
SimpleLoop/loop-10M-6                   76.7ms ± 1%    69.1ms ± 1%   -9.82%  (p=0.008 n=5+5)

name                                  old alloc/op   new alloc/op   delta
SimpleLoop/identity-precompile-10M-6    2.46MB ± 0%    0.02MB ± 0%  -99.35%  (p=0.008 n=5+5)
SimpleLoop/loop-10M-6                   13.2kB ± 1%    13.2kB ± 0%     ~     (p=0.143 n=5+5)

name                                  old allocs/op  new allocs/op  delta
SimpleLoop/identity-precompile-10M-6     76.4k ± 0%      0.1k ± 0%     ~     (p=0.079 n=4+5)
SimpleLoop/loop-10M-6                     40.0 ± 0%      40.0 ± 0%     ~     (all equal)

* trie: better use of hasher keccakState

* core/state/statedb: reduce allocations in getDeletedStateObject

* core/vm: reduce allocations in all call derivates

* core/vm: reduce allocations in call variants

- Make returnstack `uint32`
- Use a `sync.Pool` of `stack`s

* core/vm: fix tests

* core/vm: goimports

* core/vm: tracer fix + staticcall gas fix

* core/vm: add back snapshot to staticcall

* core/vm: review concerns + make returnstack pooled + enable returndata in traces

* core/vm: fix some test tracer method signatures

* core/vm: run gencodec, minor comment polish

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
# Conflicts:
#	core/state/statedb.go
#	core/vm/contracts_test.go
#	core/vm/evm.go
#	core/vm/instructions.go
#	core/vm/interpreter.go
#	core/vm/logger.go
#	core/vm/logger_json.go
#	core/vm/logger_test.go
#	core/vm/runtime/runtime_test.go
#	core/vm/stack/stack.go
#	eth/tracers/tracer.go
#	eth/tracers/tracer_test.go
#	trie/secure_trie.go
2020-08-07 13:46:26 +02:00
gary rong
8738c90219 les: historical data garbage collection (#19570)
This change introduces garbage collection for the light client. Historical
chain data is deleted periodically. If you want to disable the GC, use
the --light.nopruning flag.
# Conflicts:
#	cmd/geth/main.go
#	cmd/utils/flags.go
#	core/blockchain.go
#	core/chain_indexer.go
#	core/chain_indexer_test.go
#	core/chain_makers.go
#	core/dao_test.go
#	core/genesis.go
#	core/rawdb/accessors_chain_test.go
#	core/rawdb/accessors_indexes_test.go
#	core/rawdb/freezer.go
#	core/state/statedb_test.go
#	eth/downloader/downloader.go
#	eth/downloader/downloader_test.go
#	eth/downloader/testchain_test.go
#	eth/gen_config.go
#	internal/ethapi/api.go
#	internal/ethapi/backend.go
#	les/api_backend.go
#	les/client.go
#	les/odr_requests.go
#	les/odr_test.go
#	les/request_test.go
#	les/server.go
#	les/sync_test.go
#	les/test_helper.go
#	les/ulc_test.go
#	light/lightchain.go
#	light/odr.go
#	light/odr_util.go
#	light/postprocess.go
#	trie/database.go
#	trie/iterator_test.go
#	trie/trie_test.go
2020-08-07 13:16:46 +02:00
Martin Holst Swende
0d23ff42aa eth/downloader: fix peer idleness tracking when restarting state sync (#21260)
This fixes two issues with state sync restarts:

When sync restarts with a new root, some peers can have in-flight requests.
Since all peers with active requests were marked idle when exiting sync,
the new sync would schedule more requests for those peers. When the
response for the earlier request arrived, the new sync would reject it and
mark the peer idle again, rendering the peer useless until it disconnected.

The other issue was that peers would not be marked idle when they had
delivered a response, but the response hadn't been processed before
restarting the state sync. This also made the peer useless because it
would be permanently marked busy.

Co-authored-by: Felix Lange <fjl@twurst.com>
# Conflicts:
#	eth/downloader/downloader.go
#	eth/downloader/statesync.go
2020-08-07 12:52:02 +02:00
Martin Holst Swende
45140488f0 eth: increase timeout in TestBroadcastBlock (#21299) 2020-08-07 12:49:19 +02:00
gary rong
1a99c54719 eth/gasprice: lighter gas price oracle for light client (#20409)
This PR reduces the bandwidth used by the light client to compute the
recommended gas price. The current mechanism for suggesting the price is:

- retrieve recent 20 blocks
- get the lowest gas price of these blocks
- sort the price array and return the middle(60%) one

This works for full nodes, which have all blocks available locally.
However, this is very expensive for the light client because the light
client needs to retrieve block bodies from the network.

The PR changes the default options for light client. With the new config,
the light client only retrieves the two latest blocks, but in order to
collect more sample transactions, the 3 lowest prices are collected from
each block.

This PR also changes the behavior for empty blocks. If the block is empty,
the lastest price is reused for sampling.

# Conflicts:
#	eth/gasprice/gasprice.go
2020-08-07 12:29:19 +02:00
Martin Holst Swende
5d0b4ca3ff rpc, internal/ethapi: default rpc gascap at 25M + better error message (#21229)
* rpc, internal/ethapi: default rpc gascap at 50M + better error message

* eth,internal: make globalgascap uint64

* core/tests: fix compilation failure

* eth/config: gascap at 25M + minor review concerns
# Conflicts:
#	core/tx_pool_test.go
#	internal/ethapi/api.go
#	les/api_backend.go
2020-08-07 12:27:17 +02:00
Marius van der Wijden
12de9c3f65 eth/downloader: fixes data race between synchronize and other methods (#21201)
* eth/downloaded: fixed datarace between synchronize and Progress

There was a race condition between `downloader.synchronize()` and `Progress` `syncWithPeer` `fetchHeight` `findAncestors` and `processHeaders`
This PR changes the behavior of the downloader a bit.
Previously the functions `Progress` `syncWithPeer` `fetchHeight` `findAncestors` and `processHeaders` read the syncMode anew within their loops. Now they read the syncMode at the start of their function and don't change it during their runtime.

* eth/downloaded: comment

* eth/downloader: added comment
# Conflicts:
#	eth/downloader/downloader.go
2020-08-07 11:51:38 +02:00
Marius van der Wijden
9de5600229 core: types: less allocations when hashing and tx handling (#21265)
* core, crypto: various allocation savings regarding tx handling

* core: reduce allocs for gas price comparison

This change reduces the allocations needed for comparing different transactions to each other.
A call to `tx.GasPrice()` copies the gas price as it has to be safe against modifications and
also needs to be threadsafe. For comparing and ordering different transactions we don't need
these guarantees

* core: added tx.GasPriceIntCmp for comparison without allocation

adds a method to remove unneeded allocation in comparison to tx.gasPrice

* core/types: pool legacykeccak256 objects in rlpHash

rlpHash is by far the most used function in core that allocates a legacyKeccak256 object on each call.
Since it is so widely used it makes sense to add pooling here so we relieve the GC.
On my machine these changes result in > 100 MILLION less allocations and > 30 GB less allocated memory.

* reverted some changes

* reverted some changes

* trie: use crypto.KeccakState instead of replicating code

Co-authored-by: Martin Holst Swende <martin@swende.se>
# Conflicts:
#	core/tx_list.go
#	core/tx_pool.go
#	core/types/block.go
#	core/types/transaction.go
#	trie/committer.go
#	trie/hasher.go
2020-08-07 11:46:33 +02:00
Marius van der Wijden
0cd5872378 eth: returned revert reason in traceTx (#21195)
* eth: returned revert reason in traceTx

* eth: return result data
2020-08-07 11:23:14 +02:00
gary rong
20de87c1bf eth: don't block if transaction broadcast loop fails (#21255)
* eth: don't block if transaction broadcast loop is returned

* eth: kick out peer if we failed to send message

* eth: address comment
2020-08-07 11:22:09 +02:00
gary rong
2740fc90d9 cmd, eth, internal, les: add txfee cap (#21212)
* cmd, eth, internal, les: add gasprice cap

* cmd/utils, eth: add default value for gasprice cap

* all: use txfee cap

* cmd, eth: add fix

* cmd, internal: address comments
# Conflicts:
#	les/api_backend.go
2020-08-07 11:18:39 +02:00
sixdays
287abd928b eth/downloader: don't use defer for unlock before return (#21227)
Co-authored-by: linjing <linjingjing@baidu.com>
2020-08-07 11:17:56 +02:00
Martin Holst Swende
bb5f890c0c eth/downloader: fix spuriously failing tests (#21149)
* eth/downloader tests: fix spurious failing test due to race between receipts/headers

* miner tests: fix travis failure on arm64

* eth/downloader: tests - store td in ancients too
# Conflicts:
#	eth/downloader/downloader_test.go
#	miner/worker_test.go
2020-08-07 11:15:45 +02:00
Alexey Akhunov
b72fae75c9 Fix some snags in stage 6 2020-08-05 11:31:41 +01:00
Alexey Akhunov
11637c4c89 Fix some snags in stage 6 2020-08-05 11:25:57 +01:00
Alex Sharov
d458c4cc1e
Migrations: use stage name as db key (#868) 2020-08-05 17:13:35 +07:00
Igor Mandrigin
8bc293b3f7
Remove unnecessary memory profiling (#872)
* remove separate memory profiling from staged sync

* don’t run pprof globally always
2020-08-05 10:54:19 +01:00
Igor Mandrigin
8b5903f6f2 docs: add a piechart with stages 2020-08-05 10:29:15 +02:00
ledgerwatch
0514501937
Revert "Use stage name as db key (#858)" (#867)
This reverts commit 7290bf519e.
2020-08-04 11:05:27 +01:00
Alex Sharov
7290bf519e
Use stage name as db key (#858) 2020-08-04 16:25:28 +07:00
pk
91baa688bd
Update stagedsync.go (#866)
fixed a typo from `compiting` to `computing `
2020-08-04 09:03:47 +01:00
Alex Sharov
9c0f6cd166
stage3_block_compression_support (#859) 2020-08-03 14:42:10 +03:00
Igor Mandrigin
ad15e52391 fixup 2020-08-02 14:47:30 +02:00
Igor Mandrigin
3aedcbcd7d Use datadir for temp files when generating indexes 2020-08-02 12:32:41 +02:00
ledgerwatch
cf799157cc
Jumpdest skip optimisation (#851)
* Jumpdest skipping optimisation

* Fix formatting

* Move skipAnalysis into vmConfig, introduce tracing ability

* Improve detection logging

* Added release instructions

* Fix lint
2020-08-01 17:56:57 +01:00
Igor Mandrigin
79ed493678
Fixup for TestSendTransactions65 (#838) 2020-07-31 10:44:42 +02:00
Alex Sharov
8c8433302e
remove eth/63, add tests for eth/65 (#823) 2020-07-30 11:16:55 +01:00
ledgerwatch
ddfec0828d
Delete receipts in unwind stage4 (#818) 2020-07-29 18:04:49 +01:00
ledgerwatch
ba6c6aaef2
Move BadHashes to stage1 (#812) 2020-07-29 15:33:01 +01:00
ledgerwatch
7bc45fab80
Remove preimage storage mode, write receipts by default (#809) 2020-07-29 14:00:39 +01:00
Alex Sharov
c5b5eacc7a
fix stage5 interruption (#800)
* fix stage5 interruption

* clean

* fix test

* Simplification

* Fix to the txpool logic and renaming

* Fix array size in stage3

* remove 'interrupted stage' concept, simplify integration state_stages

* remove blockchain interface

* revive staged sync tests

Co-authored-by: Alexey Akhunov <akhounov@gmail.com>
2020-07-29 05:30:44 +01:00
ledgerwatch
32fa0ed3ec
Txpool test6 (#797)
* Fix tx propagation and announcement tests

* Fix checkpoint challenge test

* Save current state of code

* Fix compile errors

* Fixes

* Fix formatting

* Printouts

* Printouts

* Printouts

* Too much printing, not close db when stopping

* Better handing of interruptions

* No need to reset after incremental interruption

* Fix stages

* Fixes

* Giving up

* Fix formatting

* Cleanup
2020-07-27 23:00:08 +01:00
Alex Sharov
f500148b86
remove BoltDatabase, BadgerDatabase, RemoteDatabase classes (replaced by objectDb) (#794) 2020-07-27 22:59:54 +01:00
Alex Sharov
f037aed6e5
wait for verify_headers method (#793) 2020-07-27 19:26:24 +07:00
Igor Mandrigin
6ca3e36024
Use CalVer for turbo-geth versioning. (#792) 2020-07-27 14:18:26 +02:00
Alex Sharov
c4a1ffa4f0
Grpc-based remoteDb (#788) 2020-07-27 19:15:48 +07:00
b00ris
9fc51a3efd
Account range (#781)
* save state

* cleanup

* add walkasof test for storage with chunks

* fix lint

* fix lint

* remove useless comments

* fix dump test

* move accountRange test to plain state

* get last block fixes
2020-07-27 07:09:50 +01:00
Igor Mandrigin
d05cfa22f6
Make plain state + staged sync the default (#782)
* make plain state + staged sync the default

* remove sync mode flag completely

* one thing

* fix the console

* simplify code

* fix and skip tests

* fixup for console tests
2020-07-25 18:18:18 +01:00
ledgerwatch
cf5b0c8836
Integrate txPool into staged sync, fix tx_pool_test (#778)
* cmd/tester to initiate reorg

* Second commit

* Turn on profile

* More

* Unwind function

* More fixes

* Before fixing tests

* Fix compile error

* Fix lint

* Fix formatting

* Fix lint

* Fix nil in tests

* Fix lint

* Decouple txpool from rawdb

* Fix some tx tests

* One more test

* Fix the rest of tests in tx_pool_test.go

* Fix formatting
2020-07-23 21:52:41 +01:00
Igor Mandrigin
9b599b8ce4
Workaround panic in staged sync. (#777)
Fixes #776
2020-07-23 21:52:25 +01:00
Alex Sharov
e65b743878
Prometheus dashboard revisit (#767) 2020-07-21 15:33:03 +07:00
Alex Sharov
621e3a2074
Ci lmdb - reduce memory usage (#762) 2020-07-21 08:58:00 +07:00
ledgerwatch
b765ff0e33
cmd/tester initiates staged sync, and unwind (but not reorg) (#758)
* First push

* Remove batch from Blockchain

* Fix compile error in cmd/integration

* Fix compile errors in cmd/state

* Fix compile errors

* Save changes

* Fix core tests (skip tx tests)

* More test fixes

* Fix compile error

* Fix formatting

* Fix formatting

* Fix lint

* Fixes

* Skip some miner tests

* Fix tests

* Cleanup
2020-07-19 09:11:53 +01:00
Alex Sharov
7f60d1b535
Remove load start key from etl (#757)
* limit incremental step size of stages 5 and 6

* remove limit, make incremental

* remove_load_start_key_from_etl

* switch to "struct of arrays" from "array of structs"

* switch to "struct of arrays" from "array of structs"

Co-authored-by: Alexey Akhunov <akhounov@gmail.com>
2020-07-18 10:17:04 +01:00
Evgeny Danilenko
f79b156a0b
delete keys (#756) 2020-07-17 08:34:52 +01:00
Alex Sharov
c8a594dec6
Limit incremental step size of stages 5 and 6. (#754) 2020-07-17 12:52:09 +07:00
Alex Sharov
4d54f0ec0c
fix error "could not apply NextKey for the empty key" (#753) 2020-07-17 06:59:22 +07:00
Alex Sharov
086435117f
remove atomic from stage4 (#751) 2020-07-17 06:59:03 +07:00
Evgeny Danilenko
5ead20e288
close tx_cache and peer.handle goruotines properly (#748)
* close goruotines

* fix using defer

* close pm managers a bit later

* fmt

* finalizer for in-mem db

* after cr

* revert finalizer

Co-authored-by: alex.sharov <AskAlexSharov@gmail.com>
2020-07-16 14:27:24 +01:00
ledgerwatch
18e67cd07d
cmd/tester to initiate correct staged sync (but not reorg yet) (#747)
* Disable caches

* Fix cmd/integration?

* state root hash matches

* Cleanup

* Skip TestForkIDSplit

* Try to fix the test
2020-07-15 13:26:59 +01:00
Alex Sharov
8b8094d72c
integration: fix problem with interruption (#743)
* store stageData correctly

* integration: use State of sync, use stage data, don't skip persistent steps even if they complete before interruption

* reset_state: clear unwind stages info

* stage4: stop where previous stage stopped, print to logs digits which represent what exactly is in DB, rename variable 'nextBlockNumber' to 'stateProgress'

* rebase to master

* simplify chainconfig

* try increase sleep time on ci

* try increase sleep time on ci

* try increase sleep time on ci

* try increase sleep time on ci
2020-07-15 12:53:12 +01:00
ledgerwatch
3359ba7a04
Make cmd/tester initiate staged sync, remove some pools and caches (#746)
* no pools

* Remove excessive logging

* Revert

* Initial commit

* Cleanup

* Fix some compile errors

* Fix core tests

* Fix more tests

* Fix eth/downloader

* go mod tidy

* Fix core/vm

* Fix formatting

* Fix formatting

* Fix lint

* Fix lint

* Switch tests to StagedSync

* Cleanup

* Reuse cache in stage4

* Fix

* Fix formatting

* Try to fix test
2020-07-15 07:15:48 +01:00
Evgeny Danilenko
2ce24c3274
dont stop txPool stage on error (#745) 2020-07-15 06:10:17 +01:00
ledgerwatch
665b1d88b9
Speed up GenerateChain by using intermediate hashes (#736)
* GenerateChain to support intermediate hashes

* Fix formatting

* Changeset stats

* Fix formatting
2020-07-10 22:37:34 +01:00
ledgerwatch
16695eb100
Log Info and duplication fix (#735) 2020-07-10 11:40:13 +01:00
Alex Sharov
8335700331
Integration: compare to reference_db after all cycles, better cancelation, add to makefile (#733)
* cmp to reference db if --reference_chaindata provided

* graceful shutdown

* add ./cmd/integration to makefile

* add interruption support for different stages

* don't compare errors directly
2020-07-10 07:03:18 +01:00
Alex Sharov
d98382fdf8
Integration add checkChangeSet into state_stages command (#728)
Integration add checkChangeSet into state_stages command (#728)
2020-07-10 10:25:40 +07:00
Andrew Ashikhmin
bae2e7094a
Fix limit = 0 (unlimited) (#731) 2020-07-09 16:08:26 +01:00
Alex Sharov
686f186545
integration - to use same blockchain config as production (#727) 2020-07-09 13:54:10 +01:00
Evgeny Danilenko
5f77570556
Make transaction pool startable and stoppable. Staged sync. (#730)
* after concurrency testing

* fixes for linters

* add an extra parameter

* change init order for protocolManager

* green tests
2020-07-09 13:53:35 +01:00
ledgerwatch
887fc4f99c
GenerateChain without using TrieDbState (#726)
* Different chain generation

* More fixes

* Fix TestSideLogRebirth

* Fix the rest of core tests

* Fix accounts/abi/bind

* Fix compile errors for cmd/pics

* Fix consensus/clique tests

* More fixes

* Fix core/state tests

* Fix eth tests

* Fix eth/downloader tests

* Fix more tests

* Fix compile errors

* Some more fixes

* Save

* Exists

* Fix last tests

* Clean up

* Fix formatting

* Fix linter

* Fix formatting

* Fix linter

* Fix lint

* Fix lint

* Fix lint

* Fix lint

* Fix lint

* Fix lint

* Fix lint

* Fix lint
2020-07-09 07:15:28 +01:00
b00ris
eca0f233ec
[WIP] WalkAsOf (#724)
* save state

* walkAsOf by cs test passed

* cs search for plain state

* save state

* fix accounts tests

* refactor walkAsOf account tests

* fix storage test

* refactor walkAsOf storage tests

* fix lint

* fix test

* save state

* save state

* add test with fixed bits

* fmt

* add stages check

* fix lint

* fix lint

* remove obsoleted methods
2020-07-09 07:13:45 +01:00
Alex Sharov
2689b35da9
TxLookup unwind: Remove entries for blocks between unwindPoint+1 and stage.BlockNumber (#723) 2020-07-08 05:46:04 +01:00
Alex Sharov
495f95f688
Add commands "compare_states", add command "stage9", fix unwind of stage9 (it walked over whole db) (#722)
* ./cmd/integration compare_states, ./cmd/integration stage9

* TxLookup fix unwind - it walked over all db
2020-07-07 17:07:14 +07:00
Alex Sharov
305f8aff02
Integration tests2 (#714)
```
go run ./cmd/integration reset --chaindata=...
go run ./cmd/integration state_stages -h
go run ./cmd/integration state_stages  --chaindata=... --verbosity=3 --block=2_000_000 --unwind=10 --unwind_every=1_000 
```
Also, it inherits flags from geth:
```
--pprof.cpuprofile=./cpu.out   // to file
--pprof --pprof.port=6060     // launch pprof server
--metrics                  //  sends to prometheus 
```
2020-07-07 11:00:25 +07:00
Alex Sharov
8363cb0535
pass deleted code to collector (#718) 2020-07-07 09:33:26 +07:00
Alex Sharov
d3ede58ff0
stage3, fix: if header stage is ehead of body stage (#717)
* fix case: if header stage is ehead of body stage

* fix case: if header stage is ehead of body stage

* fix case: if header stage is ehead of body stage

* allow stage3 to sync to given block

* allow stage3 to sync to given block
2020-07-06 11:11:01 +01:00
ledgerwatch
d713de4713
Fix index generation for storage when incarnation changes (#716)
* Fixing history generation

* Try fixes

* Reset from 0

* Cleanup
2020-07-06 07:34:24 +01:00
Alex Sharov
98f8ccc561
Command for long and heavy integration tests (#712)
* cmd for integration tests

* cmd for integration tests
2020-07-05 07:18:21 +01:00
Alex Sharov
2aadd94acb
remove mgr feature and stateSize calculation feature (#711) 2020-07-05 07:17:27 +01:00
ledgerwatch
cccc3ab460
Stage3 optimise (#708)
* Cherry-picked

* Reset3

* Fix formatting

* Print before commit

* Use ETL

* Fix linter

* Use different keys for ETL

* Fix formatting

* Update progress correctly

* Reset stage5

* Fix stage3 hack
2020-07-03 18:55:43 +01:00
ledgerwatch
49181a298b
Special bucket for transaction senders (#707)
* Senders in the separate bucket

* Pre-create txSenders bucket

* Fix compile error

* Fix compile error

* Fix compile error, remove block transformations

* Fix formatting

* Fix test
2020-07-03 08:23:49 +01:00
ledgerwatch
b498419dcb
Fix loader crash (kludge) (#706)
* Kludge to remove duplicates

* Fix

* Fix formatting

* Fix in Len function
2020-07-03 08:08:35 +01:00
Giulio rebuffo
011a15350b
fix stage 2 (#705)
* removed unused actions in stage 2

* fixed stage 2
2020-07-02 19:44:08 +01:00
Alex Sharov
ec70cd2a9c
Revert "Only useful IH cursor (#694)" (#703)
This reverts commit 63c998c91f.

# Conflicts:
#	cmd/hack/hack.go
#	eth/stagedsync/stage_interhashes.go
2020-07-02 17:55:35 +07:00
ledgerwatch
aaf3ab9161
Fix (#702) 2020-07-02 11:23:21 +01:00
ledgerwatch
137daa6c67
Fixes in generated changeSet and checkChangeSets (#698)
* Debugging changesets

* Kinda works

* Fix compile error

* Fix formatting

* Fix lint

* Duplicate entries kludge

* Fix compile error

* Cleanup
2020-07-01 15:56:56 +01:00
Giulio rebuffo
3ee1435ac2
integration of insertBodies instead of insertChain (#700)
* integration of insertBodies instead of insertChain

* remove seal verification from stage2

* fixed seals
2020-07-01 08:23:15 +01:00
Alex Sharov
e28e455b77
small fix of miss-type in ih stage (#697) 2020-06-30 05:44:41 +01:00
Giulio rebuffo
85ab6ff8aa
added insertBodies (#695) 2020-06-29 17:26:33 +01:00
Alex Sharov
63c998c91f
Only useful IH cursor (#694)
* cursor which returns only useful IH

* cursor which returns only useful IH
2020-06-28 13:51:18 +01:00
ledgerwatch
ed866e6934
non-concurrent ETL, debug_traceTransaction in rcpdaemon (#692)
* Fixing history index

* Remove chunk generation, fix formatting

* Fix compile error, clean up hack.go

* Fix output tests

* Fix index generator test

* Fixed checkChangeSets

* Fix linter
2020-06-28 07:10:27 +01:00
ledgerwatch
4c456a649f
Separating HashState and IntermediateHashes stages again, fixing errors (#688)
* TestWatchNoDir not to be parallel

* Print ks and inc

* Print addrHash

* Change the buffer

* Print loading

* Skip

* More logging

* Error out earlier

* Handle empty codes

* Handle empty codes

* Remove logging

* Compare states

* Not do stage5

* compareBucket

* Preimage

* Clearer errors

* No need to clean up contract code

* Restore stage6

* Printing

* Skip the skipping

* Print all

* Change buffer type

* Add limit to stage5

* Always fail

* Remove exessive logging

* Restore buffer type

* Revert

* Print when exception

* Reenable skipping

* Skip storage items for deleted contracts

* not shortcut

* Remove removeAccount

* Re-enable state hashing

* Default to plain state

* Disable hashing state

* Reenable reset5

* Print unfurl list

* Enable removingAccount

* No printing

* Reenable stage5 commit

* Swap order of stages

* Prevent backwards promotion, reset tx lookup

* reset finish

* Introduce storage item replacement

* See if unwind works

* Restore removingAccount

* Don't do removeAccount for unwinding

* Possible fix

* Proper(er) fix

* Don't exclude unwinding

* Remove unwinding flag

* Fix formatting

* Fix lint

* Not to ignore blocks if they cause reorg

* Fix test, separate stages again

* Fix TestUnwind

* Fix stage

* Swap unwinding

* Revert to unwinding flag

* Print unfurl list

* Print

* Print inside receive

* Print after

* No printing

* Cleanup

* Not use blockCache when doing GetBlock
2020-06-26 07:46:05 +01:00
Alex Sharov
392bf6e517
Reduce amount of c.Next calls in loader (#687)
* reduce amount of c.Next calls

* add timings of gen IH to logs
2020-06-25 08:36:03 +01:00
ledgerwatch
5812a649ce
Combine stage5 and stage6 (#679)
* Handle bucket error

* Replace with 0

* SetMaxDBs

* Set MaxDb before opening'

* Merge stage5 and stage6

* Fix lint

* Make downloader tests not parallel
2020-06-20 10:07:22 +01:00
ledgerwatch
fd98914c28
Stage6 - intermediate hashes (#677)
* First cut of the stage6

* Fix formatter

* Introduce state6

* Fix target number for stage6

* Fix linter

* Fix linter

* Reset in regenerate

* Correct block number

* Fix linter

* Fix linter

* Fix

* Upper case

* Skeleton to debug'

* Fix formatting

* Added codehash correction

* Fix TestUnwind

* fix test

* Fix linter

* Introduce unwind6

* Report adjustment error

* Code hashes included into stage5 incremental promotion and unwind

* Fix formatting

* Cleanup

* fix TestUnwind

* Cleanup

* Fix compile error

* Fix formatting

* unwind4

* Disable verifyRoot in stage5, fix hacks

* Remove verifyRoot function

Co-authored-by: alex.sharov <AskAlexSharov@gmail.com>
2020-06-18 22:27:11 +01:00
Alex Sharov
5b051d9ab3
Lmdb: avoid empty key values in put and seek (#673)
* avoid 0 length key/values and seek arguments

* less abstractions in .get method, and copy memory from C space without unsafe conversion into go memory

* fix test
2020-06-17 10:57:48 +01:00
Igor Mandrigin
8112cf1f9f
Fix total difficulty calculation in staged sync. (#672) 2020-06-16 19:14:50 +03:00
Alex Sharov
57777e7c60
Prepare codebase for future default DB change (#670)
* Add kv.tx.bucket.Clear() and db.ClearBuckets() methods

* Add kv.tx.bucket.Clear() and db.ClearBuckets() methods

* choose db based on file suffix

* implement db.id method

* implement db.id method

* use ethdb.NewDatabase method

* use ethb.MustOpen method

* cleanup

* support TEST_DB env flag

* create db path automatically needed

* bolt - don't change prefix on happy path
2020-06-16 14:36:16 +01:00
Alex Sharov
8d04689041
close db in tests (#669) 2020-06-16 12:05:40 +07:00
ledgerwatch
dec30b698d
Fix execution for block 10094566 (#665)
* First sketch of the fix

* Re-enable stage4

* Fix formatting

* Park the changes

* Save updates

* Save update

* Cleanup

* Cleanup

* Cleanup

* Fix lint

* Cleanup

* Update

* Tx tracing

* Update

* Cleanup

* Switch tests back to bolt

* Test cleanup

* Update

* Polymorthic CREATE2 test

* Add assertions

* Fix formatting

* Fix test

* Cleanup

* Cleanup

* Cleanup
2020-06-15 22:24:08 +01:00
Igor Mandrigin
93f6c4c01a post-rebase fixups 2020-06-15 19:38:54 +03:00
Greg Colvin
57e88afcd4 core/vm: EIP-2315, JUMPSUB for the EVM (#20619)
* core/vm: implement EIP 2315, subroutines for the EVM

* core/vm: eip 2315 - lintfix + check jump dest validity + check ret stack size constraints

  logger: markdown-friendly traces, validate jumpdest, more testcase, correct opcodes

* core/vm: update subroutines acc to eip: disallow walk-into

* core/vm/eips: gas cost changes for subroutines

* core/vm: update opcodes for EIP-2315

* core/vm: define RETURNSUB as a 'jumping' operation + review concerns

Co-authored-by: Martin Holst Swende <martin@swende.se>
# Conflicts:
#	core/vm/contract.go
#	core/vm/instructions_test.go
#	core/vm/interpreter.go
#	core/vm/logger.go
#	core/vm/logger_json.go
#	core/vm/logger_test.go
#	core/vm/runtime/runtime_test.go
#	eth/tracers/tracer.go
2020-06-15 19:38:13 +03:00
Martin Holst Swende
74b93c5ee8 eth/downloader: more context in errors (#21067)
This PR makes use of go 1.13 error handling, wrapping errors and using
errors.Is to check a wrapped root-cause. It also removes the travis
builders for go 1.11 and go 1.12.
# Conflicts:
#	eth/downloader/downloader.go
#	eth/downloader/downloader_test.go
2020-06-15 19:38:13 +03:00
Felix Lange
a9f5546d2e eth: interrupt chain insertion on shutdown (#21114)
This adds a new API method on core.BlockChain to allow interrupting
running data inserts, and calls the method before shutting down the
downloader.

The BlockChain interrupt checks are now done through a method instead
of inlining the atomic load everywhere. There is no loss of efficiency from
this and it makes the interrupt protocol a lot clearer because the check is
defined next to the method that sets the flag.

# Conflicts:
#	core/blockchain.go
#	light/lightchain.go
2020-06-15 19:38:13 +03:00
Martin Michlmayr
732a20d468 all: fix typos in comments (#21118)
# Conflicts:
#	accounts/abi/bind/backends/simulated.go
#	cmd/puppeth/module_dashboard.go
#	core/blockchain_test.go
#	core/rawdb/chain_iterator.go
#	core/state/snapshot/difflayer.go
#	core/state/snapshot/iterator.go
#	core/state/snapshot/iterator_fast.go
#	core/state/snapshot/snapshot.go
#	core/state/snapshot/wipe.go
#	core/tx_pool.go
#	les/clientpool.go
#	les/peer.go
#	mobile/doc.go
#	trie/committer.go
#	trie/database.go
2020-06-15 19:38:13 +03:00
Felföldi Zsolt
1ca95e8352 les, les/lespay: implement new server pool (#20758)
This PR reimplements the light client server pool. It is also a first step
to move certain logic into a new lespay package. This package will contain
the implementation of the lespay token sale functions, the token buying and
selling logic and other components related to peer selection/prioritization
and service quality evaluation. Over the long term this package will be
reusable for incentivizing future protocols.

Since the LES peer logic is now based on enode.Iterator, it can now use
DNS-based fallback discovery to find servers.

This document describes the function of the new components:
https://gist.github.com/zsfelfoldi/3c7ace895234b7b345ab4f71dab102d4

# Conflicts:
#	cmd/utils/flags.go
#	core/forkid/forkid.go
#	les/client.go
#	les/client_handler.go
#	les/commons.go
#	les/distributor.go
#	les/enr_entry.go
#	les/fetcher.go
#	les/lespay/client/valuetracker.go
#	les/metrics.go
#	les/peer.go
#	les/protocol.go
#	les/retrieve.go
#	les/server.go
#	les/serverpool.go
#	les/test_helper.go
#	les/utils/expiredvalue.go
#	les/utils/weighted_select.go
#	les/utils/weighted_select_test.go
#	params/bootnodes.go
2020-06-15 19:38:12 +03:00
ledgerwatch
a8c9910f04
Various fixes to make sync work (#663)
* Fix body fetch

* Reduce spurious reorgs

* Exit the sync cycle after unwinds

* Fix out of range

* No stalling check for staged sync

* Disable failing tests

* Remove duplicate log message

* Fix UnwindTest and add assertions

* Fix formatting

* Cleanup

* Fix off by one error with bodies

* Remove rollback
2020-06-13 22:39:55 +01:00
Igor Mandrigin
96750b3711
Support ETL interruptions while promoting plain state (#662)
* lil etl changez

* fix test compile

* fixups to the unwinds

* add new buffer mode

* support unfinished transitions

* fixups

* fix tests

* linters

* linters
2020-06-13 16:03:38 +01:00
ledgerwatch
d6c89da694
Re-enable skeleton assembly mode (#661) 2020-06-13 15:13:30 +01:00
ledgerwatch
99b9c0fa99
Re-enable TestUnwind test and fix issues in the stage sync (#659)
* Fixes to stages

* Fix formatting

* Fixes to stages

* Fix formatting

* Fix linter

* Fix lint

* Updates

* Next update

* Update

* Test works

* Cleanup

* Fix formatting

* Fix formatting

* Cleanup

* Fix core test

* Reinstate randomness for reorgs
2020-06-13 13:39:04 +01:00
Andrew Ashikhmin
ebdac3a192
AVX2 fnvHash. Bump numOfGoroutines to 8 in stage_senders.go (#656)
* Profile all stages

* Try to recover senders with 8 goroutines

* fix CPU profiling for stage_bodies

* fix out-of-index

* Try full DAG for verfication of header seals

* Try to unroll fnvHash for performance

* SSE2 assembly for fnvHash16

* fnvHash16AVX2

* Revert changes to state.go

* check we're on 64-bit in useAVX2

* Shave a move off fnvHash16AVX2

* asmdecl doesn't know about VMOVD

* disable linter in the right place
2020-06-12 12:48:59 +01:00
b00ris
b4ba764fb1
[WIP] TxLookup stage (#646)
* save state

* txlookup full results

* save state

* save state

* remove experiments

* some fix&lint

* add end key to txLookup and index generation

* change log message

* change log

* fix lint

* lint

* fix test
2020-06-10 23:07:14 +03:00
Andrew Ashikhmin
cf7b9a75a7
Issue 635: Stage4 to optionally generate persisted receipts (#644)
* Euphemerally -> Ephemerally

* Move StorageMode to ethdb and pass it to PrepareStagedSync

* linter

* Remove StorageModeThinHistory and move SetStorageModeIfNotExist into storage_mode.go

* Optionally write receipts in the execute stage

* memory profiler

* linter

* proper linter fix

* linter

* typo

* Merge stateDb with changeDb so that all-or-nothing is commited in stage_execute
2020-06-09 14:11:09 +01:00
Igor Mandrigin
0ee2d83970
stagedsync: allow long stages/unwinds to be interrupted (#643)
use `s.UpdateWithStageData(db, <block number>, <key>)` to store the key

use `s.StageData` with `etl.NextKey` to restart ETL from where it was interrupted.
2020-06-09 15:49:49 +03:00
ledgerwatch
462edc2345
CheckChangeSets to work with plain state and changeSets, optionally generate receipts (#639)
* Start from 9m7

* Regenerate IH + receipts

* Only stats for iH bucket

* Persist receipts

* Go all in

* Start from block 10m

* Convert DbState to use plain state

* Fix findHistory

* Hard-code export

* More fixes

* Fix test

* Fix formatting

* Introduce PlainDbState

* Actually return PlainDbState

* Fix formatting

* Fix name style lint

* Fix linters

* Fix history_test

* Fix blockchain_test

* Fix compile error

* Bucket stats from all buckets
2020-06-09 06:52:38 +01:00
Igor Mandrigin
1d740fc78e
refactor stagedsync unwind, add tests(#636)
* some stubs

* post rebase

* fixups

* linter

* linter 2

* Update stages.go
2020-06-08 07:01:26 +03:00
ledgerwatch
0fb37c807e
Introduce intermediate hashes stage (#634)
* Query progress

* Run stage4 offline

* More thorough resetState

* Correct BlockNumber

* Fix formatting

* State loop

* do every 200k blocks

* Shift to 6.6m

* Close dbs in tests

* Stage2 with option of no reset

* every 100k blocks

* Reset state before stage5

* Introduce another stage

* Check compile errors

* Fix linter

* Fix linter

* Disable unreliable test

* Fix test

* Remove unreachable code
2020-06-07 09:56:46 +01:00
Evgeny Danilenko
41ee460a27
optimize codeBitmap (#626)
* optimize codeBitmap

* add lru

* remove custom lru

* jumpDests as explocit parameter

* lint

* lint

* linters

* default jumpDestsCache

* remove common.rand
2020-06-06 21:49:06 +01:00
Evgeny Danilenko
3134066bba
Fix stage 3 shutdown (#629)
* check stop on every block inside jobs

* stop spawnRecoverSendersStage properly

* fmt

* close recoverSenders goroutines

* fmt
2020-06-06 16:09:57 +01:00
ledgerwatch
cd9813b82c
Stage5 unwind (#631)
* Unwinding for stage5 - start

* Fix formatting

* Integrated unwind, but no tests yet

* Fix formatting

* Fix lint

* Fix lint

* Test for unwind stage5

* Fix formatting
2020-06-06 12:03:29 +01:00
ledgerwatch
a8b438d21d
Incremental promotion for stage 5 (#628)
* Incremental promotion

* Fix compile errors

* Fix linter

* Transform state keys before loading

* Re-enable and fix the tests

* Fix formatting
2020-06-06 06:36:29 +01:00
Evgeny Danilenko
199ede36a2
Prevent slice make and copy in Pushes (#625)
* prevent slice make and copy in Pushes

* do not pad if the same length

* after CR

* linters

* linters

* linters
2020-06-05 19:46:34 +03:00
Evgeny Danilenko
8d7e603f07
stack pool (#627) 2020-06-05 17:45:56 +03:00
Alex Sharov
f0bc2b2146
Run tests on lmdb and badger (#624)
* lmdb tests

* trigger ci

* fix tests

* disable parallelism

* disable parallelism

* cleanup resources

* cleanup resources

* reduce concurency

* try run tests on bolt

* try run tests on bolt

* fix downloader test

* run bolt tests

* rely on interface instead of exact instance

* Rename AbstractKV to KV

* don't use separator for badger

* don't initialize badger cursor - because it not used here

* fix linter

* try reduce badger compactors

* compat with master

* try lmdb

* try lmdb

* try lmdb

* reduce badger's MaxTableSize, reduce badger's minGoMaxProc for inMem option

* allow to close closed db

* release

* release

* ideal batch size for badger

* ideal batch size for badger
2020-06-05 10:25:33 +01:00
ledgerwatch
b20cdbe399
Enable staged sync (#618) 2020-06-04 12:34:22 +01:00
Alex Sharov
7aa050ca79
[Breaking change in db!] UI for Buckets stat (#607)
* UI for buckets size
2020-06-04 16:35:42 +07:00
Andrew Ashikhmin
33c28f7fac
[GC] uint256 rather than big.Int in Transaction (#614)
* uint256 in rlp

* uint256 rather than big.Int in Transation

* linters

* more linters

* still linters

* Reduce garbage in writeUint256

* Experiment with GC in writeByteArray
2020-06-04 08:43:08 +01:00
Igor Mandrigin
0533eed812
Refactor Stagedsync part 1 (#610) 2020-06-03 17:25:44 +03:00
ledgerwatch
e5692d1726
Various fixes to staged sync and experiments (#608)
* First commit

* Fix the one-off error

* Fix formatting

* Ability to execute stage5 separately

* Clean up intermediate hashes and stage5 progress

* Fix linter

* Print original keys when extracting

* channel

* More logging

* More logging

* Remove excess logging

* fix stage2

* Revert

* Fix stage2

* Add provider exhausted

* Sort sortable buffer

* Fix test

* Another cleanup

* Remove exhaust log
2020-06-03 13:03:40 +01:00
Igor Mandrigin
1e20ed255d
move staged sync to its own package (#605) 2020-06-02 17:52:50 +03:00
Igor Mandrigin
c16d3da1b4
etl: startkey for Load + OnLoadCommit callback (#601) 2020-06-01 17:14:40 +03:00
ledgerwatch
7ab10c85af
Separate Collector pattern out of ETL, hash collector for rebuilding Intermediate Hashes (#597)
* Introduce hashCollector

* Add HashCollector to SubTrieLoader

* Fix linter

* Reset hashed state

* Not to regenerate the hashed state

* Not to delete state

* Fix linter

* Print expected hash in the beginning

* Simplify

* Remove initialTrie

* Use etl to buffer intermediate hashes

* Copy values, not insert empty key

* Compress instead of decompress

* Enhance file buffer logging, fix linter

* Fix compile errors

* Fix log

* Fix logging

* Exclude zero key again

* Add rewind

* Restrict timestamps

* Fix

* Fix formatting

* Incorporate separation

* Extract identityLoadFunction

* Fix formatting
2020-05-31 13:23:34 +01:00
b00ris
266f9a5208
Plain state index (#595)
* plain state indexes

* generalize index generation&tests

* add plain state tests

* fix regenerate index

* сoncurrent changeset chunks processing

* remove concurrency

* fix lint

* remove comments

* add test to truncate

* fix conflicts

* fmt

* remove shadowing
2020-05-31 07:57:47 +01:00
Evgeny Danilenko
32ec443572
Restore graceful shutdown (#591)
* initial

* gracefull shutdown for staged

* more wg fixes

* fmt

* linters

* remove generalization

* linters

* linters

* fix

* fix

* fmt

* quit into etl

* after CR

* after CR
2020-05-30 16:44:54 +03:00
Igor Mandrigin
ebe7aec14e
Generalize "insert into DB though sorted files" pattern. (#592) 2020-05-30 10:00:35 +03:00
Andrew Ashikhmin
12d6851be4
[Issue 552] Disable debug protocol by default (#588) 2020-05-28 18:58:08 +01:00
Alex Sharov
daa359c363
Mgr schedule iterator (#566)
* db based version of PrefixByCumulativeWitnessSize

* db based version of PrefixByCumulativeWitnessSize

* retain all in Trie by default

* fix WitnessLen logic in calcTrie roots

* Rename IntermediateTrieWitnessLenBucket to IntermediateWitnessLenBucket

* handle corner cases in WL

* Use correct incarnation for IH bucket

* use name WitnessSize

* save progress towards db-only witness estimation

* results from trie and from db are still different

* less recursion

* correct incarnation in CumulativeSearch

* reuse results from previous Tick, separate concepts of parent and startKey

* experiment: if not including trie structure to WitnessSize will reduce cumulative error

* tool to generate all IH and tool to calculate assessment of cumulative error

* tool to generate all IH

* Calculate totalWitnessSize based on DB data - then schedule will not overrun state during MGR cycle

* better stats

* Calculate totalWitnessSize based on DB data - then schedule will not overrun state during MGR cycle

* Calculate totalWitnessSize based on DB data - then schedule will not overrun state during MGR cycle

* calculate ticks size distribution

* estimate cumulative error

* fix linter

* resetIH from scratch if needed

* cleanup

* fix test

* fix test
2020-05-28 12:33:05 +01:00
ledgerwatch
dba3363b52
Fix RestAPI for tx_retrace and make it work for local boltdb (#584)
* Not hash, keep the files

* Calculate savings

* Fix

* Fix

* Fix

* Fix

* RestAPI to support local boltdb

* Not error on read-only db

* Changes so far

* Continue

* More

* Roll back a bit

* Restore newline

* something compiles

* Fix restapi

* Fix block number

* Fix reads

* Use plain writer

* Maps for storage reads and writes

* Clean up coersions

* Fix accounts/abi/bind

* Fix tests

* More fixes

* more fixes

* More fixes

* Fixes

* Fixed core/state

* Fixed eth tests

* Move code, fix linter

* Fix test

* Fix linter

* Fix linter

* Fix linter, badger_db to support AbstractKV

* Increase IdealBatchSize for badger

* Fix linter

* Fix linter
2020-05-27 17:24:34 +01:00
ledgerwatch
e348dcb846 Move promotion before the shortcut (#582)
* Move promotion before the shortcut

* Correct the logs

* Trying without the encoder

* Revert "Trying without the encoder"

This reverts commit 24c526bc2791fb6806b1c0d4f52a43b87c3959b9.

* Commit to db, not to the mutation

* Fix log more

* No need to log every deleted file
2020-05-27 09:26:56 +01:00
Andrew Ashikhmin
5bbdb6a4b9
Use uint256 for account balance (#580)
* Use uint256 for account balance

* linter
2020-05-26 17:53:50 +01:00
Igor Mandrigin
4f339a1c81
reset the size of sortableBuffer when flushing to disk (#579) 2020-05-26 17:02:19 +03:00
Igor Mandrigin
c60aff8058
Promote hashed state initially (#577) 2020-05-26 16:37:25 +03:00
ledgerwatch
810cf13bf8
Explicit incarnation map in the database for deleted contracts (#578)
* Explicit map of incarnations

* Fix linter
2020-05-26 13:27:21 +01:00
andrew
8d6ff0b769 Post-merge fix 2020-05-25 13:36:19 +02:00
Andrew Ashikhmin
b16e560529
Use uint256.Int rather than common.Hash for storage values to reduce memory allocation in opSload & opSstore (#575)
* Produce less garbage in GetState

* Still playing with mem allocation in GetCommittedState

* Pass key by pointer in GetState as well

* linter

* Avoid a memory allocation in opSload

* Use uint256.Int rather than common.Hash for storage values to reduce memory allocation in opSload & opSstore

* linter

* linters

* small clean up
2020-05-25 12:12:25 +01:00
Igor Mandrigin
db746bba7a
"Unwind" for the execution phase when plain state is selected (#571)
* "Unwind" for the execution phase when plain state is selected

* test stub (fails)

* tests (one with incarnations fails)

* test fixups

* fix tests: cleanup contract code bucket
2020-05-25 12:11:56 +01:00
ledgerwatch
154b9a9ca2
Stop blockchain when terminating downloader (#574)
* Print

* Stop blockchain on Terminate

* Remove prints
2020-05-25 08:19:08 +01:00
Andrew Ashikhmin
df28575420
Use pointers to hashes in Get(Commited)State to reduce memory allocation (#573)
* Produce less garbage in GetState

* Still playing with mem allocation in GetCommittedState

* Pass key by pointer in GetState as well

* linter

* Avoid a memory allocation in opSload
2020-05-24 18:43:54 +02:00
ledgerwatch
f6be0b601e
Fix history generation and optimise via pre-sorting in the files (#572)
* Rewrite

* Fix linter, make counter

* Skip hash stage

* Fix linter

* Add common

* Fix wrong bucket

* Use temp files to generate index

* Fix hack, defer

* Add logging when creating files

* Properly pass datadir

* Bigger buffers, less logging

* Log current key, enforce batching

* Limit to 4m, print more

* Use ReadFull

* Optimised version of storage generation

* Don't print entire key

* Commit at the end

* Fix linter

* Remove a bit of copy-paste

* More copy-paste reduction

* Fixes

* Fix key length

* Not delete files too early

* Fix linter

* Fix logging

* Fix starting block

* Skip test

* Remove limit on the stage 4

* Fix test while disabling the hash check

* Fix tests

* Fix unreachable
2020-05-24 15:48:15 +01:00
ledgerwatch
f06db2f37b
Stages 6 and 7 for generating history indices (#569)
* save state

* add current index feature

* fix test

* remove logs

* Only execute 1000 blocks

* Reset history index

* Correct action

* Increase batch size

* Increase chunk size, print memory stats

* Fix linter

* Remove unused from

* Split into 2 staged

* Use storage history gen

* remove log

* Not to run tx_cacher in staged mode

* Not to recover during stage 2

* Not to recover during stage 2

* Remove counter

Co-authored-by: b00ris <b00ris@mail.ru>
2020-05-23 10:19:56 +01:00
ledgerwatch
6d883b5350
Fix staged sync issue introduced by LRU caches (#568)
* readPlainAccount

* readPlainAccount

* Try to disable accountCache

* Try to not separate changeBatch

* The actual fix
?

* Move to fastcache, include incarnation

* Fix linter

* Fix linter

* Disable caches

* Fix linter

* Reenable all except storage cache

* Cosmetics

* Disable account cache

* Disable code size cache

* Fix code caching

* Apply the same fix to db_state_writer
2020-05-22 16:11:00 +01:00
ledgerwatch
8b97c5c620
Remove memory leak caused by accountCache, count batch size in bytes (#565)
* Lower cache sizes

* Add memory profiling over http

* No code cache

* Calculate db batch size in bytes

* Fixes

* Fixes

* Increase batch

* Fix linter

* Restore account caching, with copying

* Reintroduce code cache

* Add fixed overhead per key

* Print batch size

* Fix batch size

* Reduce batch size

* 50 Mb

* Fix linter
2020-05-21 21:55:39 +01:00
ledgerwatch
e2848ac666
Staged exec: RLU cache between StateReader and StateWriter, separate batches for state and changesets (#542)
* Add cpu profiling

* Splt state and change batches

* Log commits

* Remove

* Log memory

* Add lru caches for staged execution

* Fix

* Fix for nil account

* Fix linter

* Fix linter

* Increase state batch size

* Add memory profiling over http

* Reduce cache sizes

* Fix storage cache

* Fix

* Fix

* Fix

* Fix

* Cleanup

* Fix linter

* Reduce logging

* Reduce logging
2020-05-21 13:27:52 +01:00
ledgerwatch
5904332035
hack --action resetState to create both hashed and plain genesis, clean all buckets (#563)
* Reset plain genesis

* Change to optimised freelist implementation

* Fix linter

* Revert "Change to optimised freelist implementation"

This reverts commit 65e28f1737801178e95585381a789785504ec318.

* Noerrcheck
2020-05-21 06:18:25 +01:00
Igor Mandrigin
0dae3ade0d post-rebase fixups 2020-05-20 15:26:22 +03:00
Martin Holst Swende
f66c118cad cmd, core, eth: background transaction indexing (#20302)
* cmd, core, eth: init tx lookup in background

* core/rawdb: tiny log fixes to make it clearer what's happening

* core, eth: fix rebase errors

* core/rawdb: make reindexing less generic, but more optimal

* rlp: implement rlp list iterator

* core/rawdb: new implementation of tx indexing/unindex using generic tx iterator and hashing rlp-data

* core/rawdb, cmd/utils: fix review concerns

* cmd/utils: fix merge issue

* core/rawdb: add some log formatting polishes

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
# Conflicts:
#	accounts/abi/bind/backends/simulated.go
#	cmd/geth/main.go
#	cmd/geth/usage.go
#	cmd/utils/flags.go
#	consensus/clique/snapshot_test.go
#	core/bench_test.go
#	core/block_validator_test.go
#	core/blockchain.go
#	core/blockchain_test.go
#	core/chain_makers_test.go
#	core/dao_test.go
#	core/rawdb/accessors_indexes.go
#	core/rawdb/schema.go
#	eth/config.go
#	eth/helper_test.go
#	eth/sync.go
#	light/odr_test.go
#	light/trie_test.go
#	light/txpool_test.go
#	miner/worker_test.go
#	tests/block_test_util.go
2020-05-20 15:26:22 +03:00
Guillaume Ballet
61d8a49ece eth/downloader: minor typo fixes in comments (#21035)
# Conflicts:
#	trie/sync.go
2020-05-20 15:26:22 +03:00
ploui
1d0688c7cc eth: don't inadvertently enable snapshots in archive nodes (#21025)
* eth: don't reassign more cache than is being made available

* eth: don't inadvertently enable snapshot in a case where --snapshot wasn't given
# Conflicts:
#	eth/backend.go
2020-05-20 15:26:22 +03:00
Péter Szilágyi
60086a33e3 eth: skip transaction announcer goroutine on eth<65 2020-05-20 15:26:22 +03:00
Péter Szilágyi
2f13f9835a eth: fix shutdown regression to abort downloads, not just cancel 2020-05-20 15:26:22 +03:00
gary rong
ad9e4241b1 all: seperate consensus error and evm internal error (#20830)
* all: seperate consensus error and evm internal error

There are actually two types of error will be returned when
a tranaction/message call is executed: (a) consensus error
(b) evm internal error. The former should be converted to
a consensus issue, e.g. The sender doesn't enough asset to
purchase the gas it specifies. The latter is allowed since
evm itself is a blackbox and internal error is allowed to happen.

This PR emphasizes the difference by introducing a executionResult
structure. The evm error is embedded inside. So if any error
returned, it indicates consensus issue happens.

And also this PR improve the `EstimateGas` API to return the concrete
revert reason if the transaction always fails

* all: polish

* accounts/abi/bind/backends: add tests

* accounts/abi/bind/backends, internal: cleanup error message

* all: address comments

* core: fix lint

* accounts, core, eth, internal: address comments

* accounts, internal: resolve revert reason if possible

* accounts, internal: address comments
# Conflicts:
#	accounts/abi/abi.go
#	accounts/abi/bind/backends/simulated.go
#	cmd/geth/retesteth.go
#	core/state/snapshot/difflayer_test.go
#	core/state/snapshot/disklayer_test.go
#	core/state/snapshot/iterator_test.go
#	core/state_processor.go
#	core/state_transition.go
#	core/vm/evm.go
#	core/vm/instructions.go
#	core/vm/jump_table.go
#	eth/api_tracer.go
#	internal/ethapi/api.go
#	les/odr_test.go
#	light/odr_test.go
#	tests/state_test_util.go
2020-05-20 15:26:22 +03:00
rene
aa2f2b742a cmd, core: remove override muir glacier and override istanbul (#20942)
# Conflicts:
#	core/genesis.go
#	eth/backend.go
#	les/client.go
2020-05-20 15:26:22 +03:00
Andrew Ashikhmin
5bc45f2426
Use uint256 in EVM implementation (kudos to Pawel Bylica) (#551)
* core/vm: improve jumpdest lookup

* Use uint256 in EVM implementation (kudos to Pawel Bylica)

* Safety precaution in opMulmod

Co-authored-by: Martin Holst Swende <martin@swende.se>
2020-05-18 08:10:59 +01:00
Alex Sharov
02dd405e93
MGR Schedule v0 (#550)
* MGR Make Schedule v0
2020-05-15 15:58:36 +07:00
ledgerwatch
f9d83c655b
Cap number of goroutines to 3 (#549) 2020-05-15 08:52:58 +01:00
Igor Mandrigin
fd77eaf86a
Staged Sync: Execution phase should use "plain state" (#548)
* introduce PlainStateReader with fallbacks

* no 10.000 changes in tests

* even less iterations

* remove even more iterations

* add `go run ./cmd/geth --syncmode staged --plainstate` flag

* fix serialization calls

* make a more sensible file default

doesn’t affect anything, because this flag is always overriden when parsing CLI. but still.
2020-05-15 08:52:45 +01:00
ledgerwatch
9f3f768ab4
Rename Resolver => SubTrieLoader, ResolveSet => RetainList (#544)
* Rename Resolver => SubTrieLoader, ResolveSet => RetainList

* Fix linter

* Fix linter

* Fix linter

* Fix linter
2020-05-12 15:24:43 +01:00
ledgerwatch
82a67f4d48
eth_getProof step2 - Decouple Resolver from Trie, remove ResolveRequest (#543)
* Removing PrepareResolveParams and NeedResolution

* Remove ResolveRequest

* Decouple resolver from trie

* Remove hooks from resolver

* Fix util compilation

* More test fixes

* Compiled tests in trie

* Fix trie tests

* Fix linter

* Fix linter

* Fix linter

* Fix linter
2020-05-12 08:22:45 +01:00
ledgerwatch
41b5fce078
resolver: merge HashBuilder-s and ResolveSet-s, decouple from ResolveRequest-s (#540)
* merge hbStorage and hb in resolver

* Fix prepare

* Remove tracing by default

* cleanup

* Fix linter

* Not to include incarnation into the ResolveRequest

* Fix linter

* Fix linter

* Fix test

* Fix linter

* Revert

* Fix for infinite loop

* Fix linter

* Collapse rss into rs

* remove reliance of requests in resolver

* Remove currentReq

* Remove fields from ResolveRequest

* Fix linter
2020-05-11 05:46:07 +01:00
ledgerwatch
b4d2e57428
Introduce incarnationMap in both DbStateReader and DbStateWriter (#534)
* Add incarnationMap into db_state_reader

* Fix test

* Add incarnationMap back to the DbStateWriter
2020-05-08 05:52:55 +01:00
b00ris
2a6f12520c
remove pruning option. Inverse enabling pruning logic. (#532) 2020-05-07 14:31:14 +01:00
ledgerwatch
2fd8f1704c
Restore EVMC integration for staged sync (accidentally broken), resetState (#529)
* Add resetState

* resetState not to disturb header chain

* Fix linter

* Fix linter

* Restore evmc integration
2020-05-07 06:59:00 +01:00
ledgerwatch
f47d661c34
Proper unwinding in the staged sync (#521)
* introduce fork

* Fix unwind test

* Unwind now really works in the test

* Fix linter

* Fix linter

* Fix linter

* Not to handle block and block hash announced in staged sync
2020-05-06 18:42:10 +01:00
Alex Sharov
2686bf2f3b
Remove topLevels param of resolver (#515)
* remove topLevels param of resolver

* revert to master version of ih
2020-05-05 21:08:00 +01:00
Igor Mandrigin
cea453be74
Support EVMC (EVMone) (#509)
* add stuff

* vendor evmc and patch import paths

* some fixups

* compiles!

* fixups for evm initialization

* less chatty logs

* fix wrong import in test

* better (time based) logging

* remove unnecessary printf

* evmc as a module

* glue evmc code

* use a proper fork for evmc

* post-rebase fixups

* fix linterz
2020-05-04 17:13:51 +01:00
b00ris
d0af8a2139
Blocks compression (#510)
* block compression

* rerun lint

* fix lint
2020-05-04 06:55:51 +01:00