plugeth/les
Felix Lange d6f49bf764
core/types: faster RLP encoding of Header, StateAcccount, ReceiptForStorage (#24420)
This change makes use of the new code generator rlp/rlpgen to improve the
performance of RLP encoding for Header and StateAccount. It also speeds up
encoding of ReceiptForStorage using the new rlp.EncoderBuffer API.

The change is much less transparent than I wanted it to be, because Header and
StateAccount now have an EncodeRLP method defined with pointer receiver. It
used to be possible to encode non-pointer values of these types, but the new
method prevents that and attempting to encode unadressable values (even if
part of another value) will return an error. The error can be surprising and may
pop up in places that previously didn't expect any errors.

To make things work, I also needed to update all code paths (mostly in unit tests)
that lead to encoding of non-pointer values, and pass a pointer instead.

Benchmark results:

    name                             old time/op    new time/op    delta
    EncodeRLP/legacy-header-8           328ns ± 0%     237ns ± 1%   -27.63%  (p=0.000 n=8+8)
    EncodeRLP/london-header-8           353ns ± 0%     247ns ± 1%   -30.06%  (p=0.000 n=8+8)
    EncodeRLP/receipt-for-storage-8     237ns ± 0%     123ns ± 0%   -47.86%  (p=0.000 n=8+7)
    EncodeRLP/receipt-full-8            297ns ± 0%     301ns ± 1%    +1.39%  (p=0.000 n=8+8)

    name                             old speed      new speed      delta
    EncodeRLP/legacy-header-8        1.66GB/s ± 0%  2.29GB/s ± 1%   +38.19%  (p=0.000 n=8+8)
    EncodeRLP/london-header-8        1.55GB/s ± 0%  2.22GB/s ± 1%   +42.99%  (p=0.000 n=8+8)
    EncodeRLP/receipt-for-storage-8  38.0MB/s ± 0%  64.8MB/s ± 0%   +70.48%  (p=0.000 n=8+7)
    EncodeRLP/receipt-full-8          910MB/s ± 0%   897MB/s ± 1%    -1.37%  (p=0.000 n=8+8)

    name                             old alloc/op   new alloc/op   delta
    EncodeRLP/legacy-header-8           0.00B          0.00B           ~     (all equal)
    EncodeRLP/london-header-8           0.00B          0.00B           ~     (all equal)
    EncodeRLP/receipt-for-storage-8     64.0B ± 0%      0.0B       -100.00%  (p=0.000 n=8+8)
    EncodeRLP/receipt-full-8             320B ± 0%      320B ± 0%      ~     (all equal)
2022-02-18 08:10:26 +01:00
..
catalyst all: separate catalyst package (#24280) 2022-01-31 14:22:35 +02:00
checkpointoracle les: update checktime even if check fails 2020-08-07 10:57:02 +02:00
downloader core, eth, les, trie: remove the sync bloom, used by fast sync 2021-12-03 12:32:41 +02:00
fetcher eth: request id dispatcher and direct req/reply APIs (#23576) 2021-11-26 13:26:03 +02:00
flowcontrol les: move client pool to les/vflux/server (#22495) 2021-04-06 20:42:50 +02:00
utils les/utils: UDP rate limiter (#21930) 2021-01-28 22:47:15 +01:00
vflux les/vflux/client, p2p/nodestate: fix data races (#24058) 2021-12-14 11:34:50 +01:00
api_backend.go eth: make traceChain avoid OOM on long-running tracing (#23736) 2021-11-04 18:54:00 +01:00
api_test.go les: duplicate downloader and fetcher to allow progressive refactoring 2021-09-10 11:11:59 +03:00
api.go les: move client pool to les/vflux/server (#22495) 2021-04-06 20:42:50 +02:00
benchmark.go all: add support for EIP-2718, EIP-2930 transactions (#21502) 2021-02-25 15:26:57 +01:00
bloombits.go les: handler separation (#19639) 2019-08-21 11:29:34 +02:00
client_handler.go core, eth, les, trie: remove the sync bloom, used by fast sync 2021-12-03 12:32:41 +02:00
client.go eth, les: update unclean shutdown markers regularly (#24077) 2021-12-17 15:18:51 +01:00
commons.go les: fix balance expiration (#22343) 2021-02-19 15:53:12 +01:00
costtracker.go eth: move eth.Config to a common package (#22205) 2021-02-05 13:51:15 +01:00
distributor_test.go les: separate peer into clientPeer and serverPeer (#19991) 2020-02-26 11:41:24 +02:00
distributor.go les, les/lespay: implement new server pool (#20758) 2020-05-22 13:46:34 +02:00
enr_entry.go cmd/devp2p: skip ENR field tails properly in nodeset filter (#22565) 2021-03-24 12:32:39 +01:00
fetcher_test.go core: use block difficulty for genesis (#23793) 2021-10-26 08:44:43 +02:00
fetcher.go all: core rework for the merge transition (#23761) 2021-11-26 13:23:02 +02:00
handler_test.go les: duplicate downloader and fetcher to allow progressive refactoring 2021-09-10 11:11:59 +03:00
metrics.go les: polish code (#22625) 2021-04-27 09:44:59 +02:00
odr_requests.go les, light: improve txstatus retrieval (#22349) 2021-02-25 14:24:04 +01:00
odr_test.go les: fix data races in tests (#23457) 2021-08-25 11:56:25 +02:00
odr.go les: generate random nums directly, not via strange conversions 2021-05-21 12:36:04 +03:00
peer_test.go les: introduce forkID (#21974) 2020-12-10 17:20:55 +01:00
peer.go core/types: faster RLP encoding of Header, StateAcccount, ReceiptForStorage (#24420) 2022-02-18 08:10:26 +01:00
protocol.go eth/protocols/eth, les: avoid Raw() when decoding HashOrNumber (#22841) 2021-05-10 12:38:54 +02:00
pruner_test.go les, light: improve txstatus retrieval (#22349) 2021-02-25 14:24:04 +01:00
pruner.go trie, les: add missing calls to Ticker.Stop (#23415) 2021-08-24 10:51:28 +02:00
request_test.go les, light: improve txstatus retrieval (#22349) 2021-02-25 14:24:04 +01:00
retrieve.go les: generate random nums directly, not via strange conversions 2021-05-21 12:36:04 +03:00
server_handler.go les: fix serverHandler crash after setHead (#24200) 2022-01-05 16:40:45 +01:00
server_requests.go tests/fuzzers: fix goroutine leak in les fuzzer (#22455) 2021-03-16 09:43:33 +01:00
server.go les: fix goroutine leaks in tests (#22707) 2021-04-21 10:19:28 +02:00
servingqueue.go les: avoid shutdown hang (#23139) 2021-07-01 14:01:19 +02:00
state_accessor.go all: removed blockhash from statedb (#23126) 2021-06-30 15:17:01 +02:00
sync_test.go les: fix data races in tests (#23457) 2021-08-25 11:56:25 +02:00
sync.go les: duplicate downloader and fetcher to allow progressive refactoring 2021-09-10 11:11:59 +03:00
test_helper.go core/types: faster RLP encoding of Header, StateAcccount, ReceiptForStorage (#24420) 2022-02-18 08:10:26 +01:00
txrelay.go les: generate random nums directly, not via strange conversions 2021-05-21 12:36:04 +03:00
ulc_test.go les: fix data races in tests (#23457) 2021-08-25 11:56:25 +02:00
ulc.go cmd, eth, les: fix up ultra light config integration 2019-07-09 20:34:42 +03:00