go-pulse/eth
Martin Holst Swende db03faa10d
core, eth: improve delivery speed on header requests (#23105)
This PR reduces the amount of work we do when answering header queries, e.g. when a peer
is syncing from us.

For some items, e.g block bodies, when we read the rlp-data from database, we plug it
directly into the response package. We didn't do that for headers, but instead read
headers-rlp, decode to types.Header, and re-encode to rlp. This PR changes that to keep it
in RLP-form as much as possible. When a node is syncing from us, it typically requests 192
contiguous headers. On master it has the following effect:

- For headers not in ancient: 2 db lookups. One for translating hash->number (even though
  the request is by number), and another for reading by hash (this latter one is sometimes
  cached).
  
- For headers in ancient: 1 file lookup/syscall for translating hash->number (even though
  the request is by number), and another for reading the header itself. After this, it
  also performes a hashing of the header, to ensure that the hash is what it expected. In
  this PR, I instead move the logic for "give me a sequence of blocks" into the lower
  layers, where the database can determine how and what to read from leveldb and/or
  ancients.

There are basically four types of requests; three of them are improved this way. The
fourth, by hash going backwards, is more tricky to optimize. However, since we know that
the gap is 0, we can look up by the parentHash, and stlil shave off all the number->hash
lookups.

The gapped collection can be optimized similarly, as a follow-up, at least in three out of
four cases.

Co-authored-by: Felix Lange <fjl@twurst.com>
2021-12-07 17:50:58 +01:00
..
catalyst eth/catalyst: implement kintsugi spec v1.0.0-alpha.4 (#23984) 2021-12-03 16:26:28 +01:00
downloader core, eth: improve delivery speed on header requests (#23105) 2021-12-07 17:50:58 +01:00
ethconfig all: core rework for the merge transition (#23761) 2021-11-26 13:23:02 +02:00
fetcher eth: request id dispatcher and direct req/reply APIs (#23576) 2021-11-26 13:26:03 +02:00
filters eth/filters: remove unused field 'chaindb' in PublicFilterAPI (#24072) 2021-12-07 02:36:01 +01:00
gasprice all: core rework for the merge transition (#23761) 2021-11-26 13:23:02 +02:00
protocols core, eth: improve delivery speed on header requests (#23105) 2021-12-07 17:50:58 +01:00
tracers eth/tracers/js: add support for REVERT/SELFDESTRUCT in evmdis_tracer (#24016) 2021-12-01 10:34:52 +01:00
api_backend.go all: core rework for the merge transition (#23761) 2021-11-26 13:23:02 +02:00
api_test.go cmd/geth, eth, core: snapshot dump + unify with trie dump (#22795) 2021-05-12 11:05:39 +03:00
api.go eth: fix typo in comment (#23941) 2021-11-22 02:53:16 +01:00
backend.go all: core rework for the merge transition (#23761) 2021-11-26 13:23:02 +02:00
bloombits.go eth: move eth.Config to a common package (#22205) 2021-02-05 13:51:15 +01:00
discovery.go cmd/utils: use eth DNS tree for snap discovery (#22808) 2021-05-04 11:29:32 +02:00
handler_eth_test.go core, eth: improve delivery speed on header requests (#23105) 2021-12-07 17:50:58 +01:00
handler_eth.go core, eth, les, trie: remove the sync bloom, used by fast sync 2021-12-03 12:32:41 +02:00
handler_snap.go eth: check snap satelliteness, delegate drop to eth (#22235) 2021-02-02 10:44:36 +02:00
handler_test.go eth: request id dispatcher and direct req/reply APIs (#23576) 2021-11-26 13:26:03 +02:00
handler.go core, eth, les, trie: remove the sync bloom, used by fast sync 2021-12-03 12:32:41 +02:00
peer.go eth: request id dispatcher and direct req/reply APIs (#23576) 2021-11-26 13:26:03 +02:00
peerset.go eth: don't wait for snap registration if we're not running snap (#22272) 2021-02-05 14:15:22 +01:00
state_accessor.go all: core rework for the merge transition (#23761) 2021-11-26 13:23:02 +02:00
sync_test.go eth: request id dispatcher and direct req/reply APIs (#23576) 2021-11-26 13:26:03 +02:00
sync.go eth: request id dispatcher and direct req/reply APIs (#23576) 2021-11-26 13:26:03 +02:00