go-ethereum/trie
Péter Szilágyi e3717b48c3
eth/downloader, trie: various polishes around duplicate items
This commit explicitly tracks duplicate and unexpected state
delieveries done against a trie Sync structure, also adding
there to import info logs.

The commit moves the db batch used to commit trie changes one
level deeper so its flushed after every node insertion. This
is needed to avoid a lot of duplicate retrievals caused by
inconsistencies between Sync internals and database. A better
approach is to track not-yet-written states in trie.Sync and
flush on commit, but I'm focuing on correctness first now.

The commit fixes a regression around pivot block fail count.
The counter previously was reset to 1 if and only if a sync
cycle progressed (inserted at least 1 entry to the database).
The current code reset it already if a node was delivered,
which is not stong enough, because unless it ends up written
to disk, an attacker can just loop and attack ad infinitum.

The commit also fixes a regression around state deliveries
and timeouts. The old downloader tracked if a delivery is
stale (none of the deliveries were requestedt), in which
case it didn't mark the node idle and did not send further
requests, since it signals a past timeout. The current code
did mark it idle even on stale deliveries, which eventually
caused two requests to be in flight at the same time, making
the deliveries always stale and mass duplicating retrievals
between multiple peers.
2017-06-19 13:15:45 +03:00
..
encoding.go trie: rework and document key encoding 2017-04-25 02:14:31 +02:00
encoding_test.go trie: rework and document key encoding 2017-04-25 02:14:31 +02:00
errors.go trie: remove Key in MissingNodeError 2017-04-18 14:52:11 +02:00
hasher.go rlp, trie, contracts, compression, consensus: improve comments (#14580) 2017-06-12 14:45:17 +02:00
iterator.go trie: add start key to NodeIterator constructors 2017-04-25 02:14:31 +02:00
iterator_test.go trie: add start key to NodeIterator constructors 2017-04-25 02:14:31 +02:00
node.go trie: rework and document key encoding 2017-04-25 02:14:31 +02:00
node_test.go trie, core/state: improve memory usage and performance (#3135) 2016-10-14 19:04:33 +03:00
proof.go trie: rework and document key encoding 2017-04-25 02:14:31 +02:00
proof_test.go all: fix go vet warnings 2016-04-15 11:17:27 +02:00
secure_trie.go trie: add start key to NodeIterator constructors 2017-04-25 02:14:31 +02:00
secure_trie_test.go rlp, trie, contracts, compression, consensus: improve comments (#14580) 2017-06-12 14:45:17 +02:00
sync.go eth/downloader, trie: various polishes around duplicate items 2017-06-19 13:15:45 +03:00
sync_test.go rlp, trie, contracts, compression, consensus: improve comments (#14580) 2017-06-12 14:45:17 +02:00
trie.go rlp, trie, contracts, compression, consensus: improve comments (#14580) 2017-06-12 14:45:17 +02:00
trie_test.go trie: add start key to NodeIterator constructors 2017-04-25 02:14:31 +02:00