mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 13:07:17 +00:00
222bb666e9
``` ➜ erigon-lib git:(fieldalign) ✗ fieldalignment -fix ./... /Users/estensen/Developer/erigon-lib/commitment/bin_patricia_hashed.go:81:16: struct of size 1065120 could be 1065112 /Users/estensen/Developer/erigon-lib/commitment/bin_patricia_hashed.go:1063:14: struct of size 1032 could be 1024 /Users/estensen/Developer/erigon-lib/commitment/hex_patricia_hashed.go:62:24: struct of size 952776 could be 952768 /Users/estensen/Developer/erigon-lib/commitment/hex_patricia_hashed.go:98:12: struct of size 1832 could be 1824 /Users/estensen/Developer/erigon-lib/commitment/hex_patricia_hashed.go:113:12: struct with 208 pointer bytes could be 152 /Users/estensen/Developer/erigon-lib/commitment/hex_patricia_hashed.go:143:11: struct of size 464 could be 456 /Users/estensen/Developer/erigon-lib/gointerfaces/types/types.pb.go:24:11: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/types/types.pb.go:79:11: struct of size 56 could be 48 /Users/estensen/Developer/erigon-lib/gointerfaces/types/types.pb.go:134:11: struct with 56 pointer bytes could be 32 /Users/estensen/Developer/erigon-lib/gointerfaces/types/types.pb.go:189:11: struct with 56 pointer bytes could be 32 /Users/estensen/Developer/erigon-lib/gointerfaces/types/types.pb.go:244:12: struct with 56 pointer bytes could be 32 /Users/estensen/Developer/erigon-lib/gointerfaces/types/types.pb.go:299:12: struct with 56 pointer bytes could be 32 /Users/estensen/Developer/erigon-lib/gointerfaces/types/types.pb.go:355:19: struct of size 56 could be 48 /Users/estensen/Developer/erigon-lib/gointerfaces/types/types.pb.go:418:23: struct with 168 pointer bytes could be 128 /Users/estensen/Developer/erigon-lib/gointerfaces/types/types.pb.go:571:20: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/types/types.pb.go:626:20: struct with 136 pointer bytes could be 128 /Users/estensen/Developer/erigon-lib/gointerfaces/types/types.pb.go:721:15: struct of size 168 could be 160 /Users/estensen/Developer/erigon-lib/etl/buffers.go:75:21: struct with 88 pointer bytes could be 64 /Users/estensen/Developer/erigon-lib/etl/buffers.go:182:27: struct with 56 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/etl/buffers.go:274:32: struct with 56 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/etl/collector.go:41:16: struct with 72 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/etl/etl.go:66:20: struct with 96 pointer bytes could be 64 /Users/estensen/Developer/erigon-lib/etl/heap.go:25:15: struct with 40 pointer bytes could be 32 /Users/estensen/Developer/erigon-lib/patricia/patricia.go:29:11: struct with 40 pointer bytes could be 32 /Users/estensen/Developer/erigon-lib/patricia/patricia.go:347:12: struct with 32 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/patricia/patricia.go:367:18: struct with 48 pointer bytes could be 32 /Users/estensen/Developer/erigon-lib/patricia/patricia.go:377:19: struct with 168 pointer bytes could be 144 /Users/estensen/Developer/erigon-lib/compress/compress.go:52:17: struct with 176 pointer bytes could be 136 /Users/estensen/Developer/erigon-lib/compress/compress.go:241:24: struct with 48 pointer bytes could be 32 /Users/estensen/Developer/erigon-lib/compress/compress.go:327:14: struct with 40 pointer bytes could be 8 /Users/estensen/Developer/erigon-lib/compress/compress.go:353:18: struct with 48 pointer bytes could be 32 /Users/estensen/Developer/erigon-lib/compress/compress.go:450:19: struct with 48 pointer bytes could be 32 /Users/estensen/Developer/erigon-lib/compress/compress.go:670:21: struct with 48 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/compress/compress.go:734:23: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/compress/decompress.go:31:15: struct with 32 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/compress/decompress.go:39:19: struct with 40 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/compress/decompress.go:117:15: struct with 64 pointer bytes could be 56 /Users/estensen/Developer/erigon-lib/compress/decompress.go:125:19: struct with 96 pointer bytes could be 80 /Users/estensen/Developer/erigon-lib/compress/decompress.go:386:13: struct with 64 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/compress/parallel_compress.go:208:22: struct with 16 pointer bytes could be 8 /Users/estensen/Developer/erigon-lib/recsplit/golomb_rice.go:32:17: struct with 16 pointer bytes could be 8 /Users/estensen/Developer/erigon-lib/recsplit/index.go:35:12: struct of size 432 could be 424 /Users/estensen/Developer/erigon-lib/recsplit/index_reader.go:26:18: struct with 48 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/recsplit/recsplit.go:64:15: struct of size 704 could be 680 /Users/estensen/Developer/erigon-lib/recsplit/recsplit.go:111:19: struct of size 104 could be 96 /Users/estensen/Developer/erigon-lib/aggregator/aggregator.go:171:17: struct of size 640 could be 632 /Users/estensen/Developer/erigon-lib/aggregator/aggregator.go:198:17: struct with 168 pointer bytes could be 144 /Users/estensen/Developer/erigon-lib/aggregator/aggregator.go:389:14: struct with 584 pointer bytes could be 568 /Users/estensen/Developer/erigon-lib/aggregator/aggregator.go:921:21: struct with 72 pointer bytes could be 56 /Users/estensen/Developer/erigon-lib/aggregator/aggregator.go:1195:22: struct with 2432 pointer bytes could be 2416 /Users/estensen/Developer/erigon-lib/aggregator/aggregator.go:2123:13: struct with 2448 pointer bytes could be 2416 /Users/estensen/Developer/erigon-lib/aggregator/aggregator.go:2634:17: struct with 96 pointer bytes could be 64 /Users/estensen/Developer/erigon-lib/aggregator/history.go:39:14: struct with 96 pointer bytes could be 88 /Users/estensen/Developer/erigon-lib/bptree/binary_file.go:33:17: struct with 40 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/bptree/node.go:79:13: struct of size 88 could be 80 /Users/estensen/Developer/erigon-lib/chain/chain_config.go:28:13: struct with 136 pointer bytes could be 120 /Users/estensen/Developer/erigon-lib/common/background/progress.go:26:18: struct with 40 pointer bytes could be 8 /Users/estensen/Developer/erigon-lib/gointerfaces/downloader/downloader.pb.go:25:19: struct with 64 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/downloader/downloader.pb.go:80:22: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/downloader/downloader.pb.go:127:20: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/downloader/downloader.pb.go:165:19: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/downloader/downloader.pb.go:203:17: struct of size 104 could be 96 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:135:23: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:173:21: struct with 48 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:220:24: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:258:22: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:305:26: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:343:24: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:390:30: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:437:26: struct of size 72 could be 64 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:500:30: struct with 64 pointer bytes could be 32 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:563:28: struct with 64 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:626:37: struct with 56 pointer bytes could be 32 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:681:35: struct with 48 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:736:29: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:774:27: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:821:27: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:859:25: struct with 48 pointer bytes could be 32 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:906:23: struct of size 48 could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:953:21: struct of size 72 could be 64 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:1008:24: struct of size 104 could be 88 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:1079:25: struct of size 144 could be 136 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:1190:19: struct with 56 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:1245:17: struct with 72 pointer bytes could be 64 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:1300:23: struct with 48 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:1347:21: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:1394:23: struct of size 48 could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:1441:21: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:1488:17: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/ethbackend.pb.go:1535:24: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/kv.pb.go:220:13: struct of size 120 could be 112 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/kv.pb.go:299:11: struct of size 104 could be 96 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/kv.pb.go:370:20: struct with 56 pointer bytes could be 48 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/kv.pb.go:425:20: struct of size 136 could be 128 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/kv.pb.go:513:23: struct with 56 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/kv.pb.go:585:18: struct of size 112 could be 104 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/kv.pb.go:664:25: struct of size 48 could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/kv.pb.go:719:23: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/remote/kv.pb.go:757:21: struct with 72 pointer bytes could be 64 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:300:26: struct of size 72 could be 64 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:355:35: struct with 48 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:410:29: struct with 56 pointer bytes could be 32 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:465:38: struct with 48 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:520:16: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:567:26: struct of size 56 could be 48 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:622:26: struct with 48 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:677:21: struct of size 80 could be 72 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:740:12: struct with 56 pointer bytes could be 48 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:795:17: struct with 72 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:874:21: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:912:21: struct of size 48 could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:959:22: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:1006:17: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:1053:23: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:1091:21: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:1138:22: struct with 48 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:1185:20: struct with 48 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:1232:24: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/sentry/sentry.pb.go:1270:16: struct of size 56 could be 48 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:25:28: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:63:26: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:110:26: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:148:24: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:195:27: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:233:25: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:280:21: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:318:19: struct with 96 pointer bytes could be 80 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:389:24: struct with 96 pointer bytes could be 88 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:452:22: struct of size 48 could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:499:28: struct with 56 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:554:26: struct of size 48 could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:601:22: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:639:20: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:686:20: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/mining.pb.go:724:18: struct of size 48 could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:132:15: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:179:17: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:226:15: struct with 72 pointer bytes could be 64 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:281:26: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:328:24: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:375:19: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:413:17: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:460:17: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:498:15: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:545:19: struct with 48 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:592:20: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:630:18: struct of size 56 could be 48 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:693:19: struct with 48 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:740:17: struct of size 56 could be 48 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:795:18: struct of size 80 could be 72 /Users/estensen/Developer/erigon-lib/gointerfaces/txpool/txpool.pb.go:858:22: struct of size 80 could be 72 /Users/estensen/Developer/erigon-lib/direct/sentry_client.go:171:25: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/kv/mdbx/kv_mdbx.go:50:15: struct with 104 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/kv/mdbx/kv_mdbx.go:355:13: struct with 160 pointer bytes could be 152 /Users/estensen/Developer/erigon-lib/kv/memdb/memory_mutation_cursor.go:39:27: struct with 200 pointer bytes could be 184 /Users/estensen/Developer/erigon-lib/kv/remotedb/kv_remote.go:22:17: struct with 72 pointer bytes could be 48 /Users/estensen/Developer/erigon-lib/kv/remotedb/kv_remote.go:38:15: struct with 80 pointer bytes could be 64 /Users/estensen/Developer/erigon-lib/kv/remotedbserver/server.go:314:24: struct with 40 pointer bytes could be 8 /Users/estensen/Developer/erigon-lib/state/aggregator.go:44:17: struct with 192 pointer bytes could be 128 /Users/estensen/Developer/erigon-lib/state/aggregator.go:422:13: struct of size 384 could be 360 /Users/estensen/Developer/erigon-lib/state/aggregator.go:455:26: struct with 424 pointer bytes could be 368 /Users/estensen/Developer/erigon-lib/state/aggregator.go:853:22: struct with 24 pointer bytes could be 8 /Users/estensen/Developer/erigon-lib/state/aggregator22.go:37:19: struct with 176 pointer bytes could be 136 /Users/estensen/Developer/erigon-lib/state/aggregator22.go:643:15: struct of size 240 could be 216 /Users/estensen/Developer/erigon-lib/state/aggregator22.go:674:28: struct with 272 pointer bytes could be 224 /Users/estensen/Developer/erigon-lib/state/aggregator22.go:1126:26: struct with 104 pointer bytes could be 88 /Users/estensen/Developer/erigon-lib/state/aggregator22.go:1156:23: struct with 24 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/state/domain.go:52:16: struct with 32 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/state/domain.go:89:13: struct with 120 pointer bytes could be 48 /Users/estensen/Developer/erigon-lib/state/domain.go:399:17: struct with 96 pointer bytes could be 64 /Users/estensen/Developer/erigon-lib/state/domain.go:443:14: struct with 32 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/state/domain.go:594:16: struct with 72 pointer bytes could be 48 /Users/estensen/Developer/erigon-lib/state/history.go:48:14: struct with 72 pointer bytes could be 48 /Users/estensen/Developer/erigon-lib/state/history.go:435:20: struct with 48 pointer bytes could be 32 /Users/estensen/Developer/erigon-lib/state/history.go:529:23: struct with 40 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/state/history.go:1150:23: struct of size 344 could be 336 /Users/estensen/Developer/erigon-lib/state/inverted_index.go:46:20: struct with 128 pointer bytes could be 88 /Users/estensen/Developer/erigon-lib/state/inverted_index.go:389:23: struct with 136 pointer bytes could be 88 /Users/estensen/Developer/erigon-lib/state/inverted_index.go:541:24: struct with 184 pointer bytes could be 152 /Users/estensen/Developer/erigon-lib/state/merge.go:69:19: struct of size 72 could be 56 /Users/estensen/Developer/erigon-lib/state/merge.go:143:20: struct of size 48 could be 40 /Users/estensen/Developer/erigon-lib/state/read_indices.go:29:18: struct with 64 pointer bytes could be 48 /Users/estensen/Developer/erigon-lib/state/read_indices.go:211:14: struct of size 72 could be 56 /Users/estensen/Developer/erigon-lib/state/read_indices.go:233:27: struct with 72 pointer bytes could be 56 /Users/estensen/Developer/erigon-lib/state/state_recon.go:61:16: struct with 56 pointer bytes could be 16 /Users/estensen/Developer/erigon-lib/state/state_recon.go:112:19: struct with 136 pointer bytes could be 112 /Users/estensen/Developer/erigon-lib/state/state_recon.go:190:22: struct with 128 pointer bytes could be 112 /Users/estensen/Developer/erigon-lib/types/testdata.go:81:26: struct with 40 pointer bytes could be 8 /Users/estensen/Developer/erigon-lib/types/txn.go:46:21: struct with 400 pointer bytes could be 40 /Users/estensen/Developer/erigon-lib/types/txn.go:82:13: struct with 200 pointer bytes could be 8 /Users/estensen/Developer/erigon-lib/types/txn.go:691:18: struct with 32 pointer bytes could be 8 /Users/estensen/Developer/erigon-lib/txpool/fetch.go:43:12: struct with 136 pointer bytes could be 112 /Users/estensen/Developer/erigon-lib/txpool/pool.go:69:13: struct with 104 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/txpool/pool.go:221:13: struct of size 104 could be 96 /Users/estensen/Developer/erigon-lib/txpool/pool.go:291:13: struct with 336 pointer bytes could be 288 /Users/estensen/Developer/erigon-lib/txpool/pool.go:1789:29: struct with 32 pointer bytes could be 8 /Users/estensen/Developer/erigon-lib/txpool/pool.go:1819:19: struct with 32 pointer bytes could be 24 /Users/estensen/Developer/erigon-lib/txpool/pool.go:1994:18: struct of size 64 could be 56 /Users/estensen/Developer/erigon-lib/txpool/pool.go:2102:14: struct of size 64 could be 56 /Users/estensen/Developer/erigon-lib/txpool/send.go:37:11: struct with 64 pointer bytes could be 48 /Users/estensen/Developer/erigon-lib/txpool/test_util.go:31:17: struct with 72 pointer bytes could be 40 ```
482 lines
12 KiB
Go
482 lines
12 KiB
Go
/*
|
|
Copyright 2022 Erigon contributors
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package bptree
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"unsafe"
|
|
)
|
|
|
|
type Keys []Felt
|
|
|
|
func (keys Keys) Len() int { return len(keys) }
|
|
|
|
func (keys Keys) Less(i, j int) bool { return keys[i] < keys[j] }
|
|
|
|
func (keys Keys) Swap(i, j int) { keys[i], keys[j] = keys[j], keys[i] }
|
|
|
|
func (keys Keys) Contains(key Felt) bool {
|
|
for _, k := range keys {
|
|
if k == key {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (keys Keys) String() string {
|
|
b := strings.Builder{}
|
|
for i, k := range keys {
|
|
fmt.Fprintf(&b, "%v", k)
|
|
if i != len(keys)-1 {
|
|
fmt.Fprintf(&b, " ")
|
|
}
|
|
}
|
|
return b.String()
|
|
}
|
|
|
|
type KeyValues struct {
|
|
keys []*Felt
|
|
values []*Felt
|
|
}
|
|
|
|
func (kv KeyValues) Len() int { return len(kv.keys) }
|
|
|
|
func (kv KeyValues) Less(i, j int) bool { return *kv.keys[i] < *kv.keys[j] }
|
|
|
|
func (kv KeyValues) Swap(i, j int) {
|
|
kv.keys[i], kv.keys[j] = kv.keys[j], kv.keys[i]
|
|
kv.values[i], kv.values[j] = kv.values[j], kv.values[i]
|
|
}
|
|
|
|
func (kv KeyValues) String() string {
|
|
b := strings.Builder{}
|
|
for i, k := range kv.keys {
|
|
v := kv.values[i]
|
|
fmt.Fprintf(&b, "{%v, %v}", *k, *v)
|
|
if i != len(kv.keys)-1 {
|
|
fmt.Fprintf(&b, " ")
|
|
}
|
|
}
|
|
return b.String()
|
|
}
|
|
|
|
type Node23 struct {
|
|
children []*Node23
|
|
keys []*Felt
|
|
values []*Felt
|
|
isLeaf bool
|
|
exposed bool
|
|
updated bool
|
|
}
|
|
|
|
func (n *Node23) String() string {
|
|
s := fmt.Sprintf("{%p isLeaf=%t keys=%v-%v children=[", n, n.isLeaf, deref(n.keys), n.keys)
|
|
for i, child := range n.children {
|
|
s += fmt.Sprintf("%p", child)
|
|
if i != len(n.children)-1 {
|
|
s += " "
|
|
}
|
|
}
|
|
s += "]}"
|
|
return s
|
|
}
|
|
|
|
func makeInternalNode(children []*Node23, keys []*Felt, stats *Stats) *Node23 {
|
|
stats.CreatedCount++
|
|
n := &Node23{isLeaf: false, children: children, keys: keys, values: make([]*Felt, 0), exposed: true, updated: true}
|
|
return n
|
|
}
|
|
|
|
func makeLeafNode(keys, values []*Felt, stats *Stats) *Node23 {
|
|
ensure(len(keys) > 0, "number of keys is zero")
|
|
ensure(len(keys) == len(values), "keys and values have different cardinality")
|
|
stats.CreatedCount++
|
|
n := &Node23{isLeaf: true, children: make([]*Node23, 0), keys: keys, values: values, exposed: true, updated: true}
|
|
return n
|
|
}
|
|
|
|
func makeEmptyLeafNode() *Node23 {
|
|
// At least nil next key is always present
|
|
return makeLeafNode(make([]*Felt, 1), make([]*Felt, 1), &Stats{}) // do not count it into stats
|
|
}
|
|
|
|
func promote(nodes []*Node23, intermediateKeys []*Felt, stats *Stats) *Node23 {
|
|
if len(nodes) > 3 {
|
|
promotedNodes := make([]*Node23, 0)
|
|
promotedKeys := make([]*Felt, 0)
|
|
for len(nodes) > 3 {
|
|
promotedNodes = append(promotedNodes, makeInternalNode(nodes[:2], intermediateKeys[:1], stats))
|
|
nodes = nodes[2:]
|
|
promotedKeys = append(promotedKeys, intermediateKeys[1])
|
|
intermediateKeys = intermediateKeys[2:]
|
|
}
|
|
promotedNodes = append(promotedNodes, makeInternalNode(nodes, intermediateKeys, stats))
|
|
return promote(promotedNodes, promotedKeys, stats)
|
|
}
|
|
promotedRoot := makeInternalNode(nodes, intermediateKeys, stats)
|
|
return promotedRoot
|
|
}
|
|
|
|
func (n *Node23) reset() {
|
|
n.exposed = false
|
|
n.updated = false
|
|
if !n.isLeaf {
|
|
for _, child := range n.children {
|
|
child.reset()
|
|
}
|
|
}
|
|
}
|
|
|
|
func (n *Node23) isValid() (bool, error) {
|
|
ensure(n.exposed || !n.updated, "isValid: node is not exposed but updated")
|
|
if n.isLeaf {
|
|
return n.isValidLeaf()
|
|
}
|
|
return n.isValidInternal()
|
|
}
|
|
|
|
func (n *Node23) isValidLeaf() (bool, error) {
|
|
ensure(n.isLeaf, "isValidLeaf: node is not leaf")
|
|
|
|
/* Any leaf node shall have no children */
|
|
if n.childrenCount() != 0 {
|
|
return false, fmt.Errorf("invalid %d children in %v", n.childrenCount(), n)
|
|
}
|
|
/* Any leaf node can have either 1 or 2 keys (plus next key) */
|
|
return n.keyCount() == 1+1 || n.keyCount() == 2+1, fmt.Errorf("invalid %d keys in %v", n.keyCount(), n)
|
|
}
|
|
|
|
func (n *Node23) isValidInternal() (bool, error) {
|
|
ensure(!n.isLeaf, "isValidInternal: node is leaf")
|
|
|
|
/* Any internal node can have either 1 keys and 2 children or 2 keys and 3 children */
|
|
if n.keyCount() != 1 && n.keyCount() != 2 {
|
|
return false, fmt.Errorf("invalid %d keys in %v", n.keyCount(), n)
|
|
}
|
|
if n.keyCount() == 1 && n.childrenCount() != 2 {
|
|
return false, fmt.Errorf("invalid %d keys %d children in %v", n.keyCount(), n.childrenCount(), n)
|
|
}
|
|
if n.keyCount() == 2 && n.childrenCount() != 3 {
|
|
return false, fmt.Errorf("invalid %d children in %v", n.keyCount(), n)
|
|
}
|
|
subtree := n.walkNodesPostOrder()
|
|
// Check that each internal node has unique keys corresponding to leaf next keys
|
|
for _, key := range n.keys {
|
|
hasNextKey := false
|
|
for _, node := range subtree {
|
|
if !node.isLeaf {
|
|
if node != n && node.hasKey(key) {
|
|
return false, fmt.Errorf("internal key %d not unique", *key)
|
|
}
|
|
continue
|
|
}
|
|
leafNextKey := node.nextKey()
|
|
if leafNextKey != nil && *key == *leafNextKey {
|
|
hasNextKey = true
|
|
}
|
|
}
|
|
if !hasNextKey {
|
|
return false, fmt.Errorf("internal key %d not present in next keys", *key)
|
|
}
|
|
}
|
|
// Check that leaves in subtree are chained together (next key -> first key)
|
|
for i, node := range subtree {
|
|
if !node.isLeaf {
|
|
// Post-order walk => previous and next nodes are contiguous leaves except last
|
|
if i == len(subtree)-1 {
|
|
continue
|
|
}
|
|
previous, next := subtree[i], subtree[i+1]
|
|
if previous.isLeaf && next.isLeaf {
|
|
// Previous node's next key must be equal to next node's first key
|
|
if previous.nextKey() != next.firstKey() {
|
|
return false, fmt.Errorf("nodes %v and %v not chained by next key", previous, next)
|
|
}
|
|
}
|
|
continue
|
|
}
|
|
}
|
|
for i := len(n.children) - 1; i >= 0; i-- {
|
|
child := n.children[i]
|
|
// Check that each child subtree is a 2-3 tree
|
|
childValid, err := child.isValid()
|
|
if !childValid {
|
|
return false, fmt.Errorf("invalid child %v in %v, error: %w", child, n, err)
|
|
}
|
|
}
|
|
return true, nil
|
|
}
|
|
|
|
func (n *Node23) keyCount() int {
|
|
return len(n.keys)
|
|
}
|
|
|
|
func (n *Node23) childrenCount() int {
|
|
return len(n.children)
|
|
}
|
|
|
|
func (n *Node23) valueCount() int {
|
|
return len(n.values)
|
|
}
|
|
|
|
func (n *Node23) firstKey() *Felt {
|
|
ensure(len(n.keys) > 0, "firstKey: node has no key")
|
|
return n.keys[0]
|
|
}
|
|
|
|
func (n *Node23) firstValue() *Felt {
|
|
ensure(len(n.values) > 0, "firstValue: node has no value")
|
|
return n.values[0]
|
|
}
|
|
|
|
func (n *Node23) firstChild() *Node23 {
|
|
ensure(len(n.children) > 0, "firstChild: node has no children")
|
|
return n.children[0]
|
|
}
|
|
|
|
func (n *Node23) firstLeaf() *Node23 {
|
|
if n.isLeaf {
|
|
return n
|
|
}
|
|
firstLeaf := n.firstChild()
|
|
for !firstLeaf.isLeaf {
|
|
firstLeaf = firstLeaf.firstChild()
|
|
}
|
|
ensure(firstLeaf.isLeaf, "firstLeaf: last is not leaf")
|
|
return firstLeaf
|
|
}
|
|
|
|
func (n *Node23) lastChild() *Node23 {
|
|
ensure(len(n.children) > 0, "lastChild: node has no children")
|
|
return n.children[len(n.children)-1]
|
|
}
|
|
|
|
func (n *Node23) lastLeaf() *Node23 {
|
|
if n.isLeaf {
|
|
return n
|
|
}
|
|
lastLeaf := n.lastChild()
|
|
for !lastLeaf.isLeaf {
|
|
lastLeaf = lastLeaf.lastChild()
|
|
}
|
|
ensure(lastLeaf.isLeaf, "lastLeaf: last is not leaf")
|
|
return lastLeaf
|
|
}
|
|
|
|
func (n *Node23) nextKey() *Felt {
|
|
ensure(len(n.keys) > 0, "nextKey: node has no key")
|
|
return n.keys[len(n.keys)-1]
|
|
}
|
|
|
|
func (n *Node23) nextValue() *Felt {
|
|
ensure(len(n.values) > 0, "nextValue: node has no value")
|
|
return n.values[len(n.values)-1]
|
|
}
|
|
|
|
func (n *Node23) rawPointer() uintptr {
|
|
return uintptr(unsafe.Pointer(n))
|
|
}
|
|
|
|
func (n *Node23) setNextKey(nextKey *Felt, stats *Stats) {
|
|
ensure(len(n.keys) > 0, "setNextKey: node has no key")
|
|
n.keys[len(n.keys)-1] = nextKey
|
|
if !n.exposed {
|
|
n.exposed = true
|
|
stats.ExposedCount++
|
|
stats.OpeningHashes += n.howManyHashes()
|
|
}
|
|
n.updated = true
|
|
stats.UpdatedCount++
|
|
}
|
|
|
|
func (n *Node23) canonicalKeys() []Felt {
|
|
if n.isLeaf {
|
|
ensure(len(n.keys) > 0, "canonicalKeys: node has no key")
|
|
return deref(n.keys[:len(n.keys)-1])
|
|
} else {
|
|
return deref(n.keys)
|
|
}
|
|
}
|
|
|
|
func (n *Node23) hasKey(targetKey *Felt) bool {
|
|
var keys []*Felt
|
|
if n.isLeaf {
|
|
ensure(len(n.keys) > 0, "hasKey: node has no key")
|
|
keys = n.keys[:len(n.keys)-1]
|
|
} else {
|
|
keys = n.keys
|
|
}
|
|
for _, key := range keys {
|
|
if *key == *targetKey {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (n *Node23) isEmpty() bool {
|
|
if n.isLeaf {
|
|
// At least next key is always present
|
|
return n.keyCount() == 1
|
|
} else {
|
|
return n.childrenCount() == 0
|
|
}
|
|
}
|
|
|
|
func (n *Node23) height() int {
|
|
if n.isLeaf {
|
|
return 1
|
|
} else {
|
|
ensure(len(n.children) > 0, "height: internal node has zero children")
|
|
return n.children[0].height() + 1
|
|
}
|
|
}
|
|
|
|
func (n *Node23) keysInLevelOrder() []Felt {
|
|
keysByLevel := make([]Felt, 0)
|
|
for i := 0; i < n.height(); i++ {
|
|
keysByLevel = append(keysByLevel, n.keysByLevel(i)...)
|
|
}
|
|
return keysByLevel
|
|
}
|
|
|
|
func (n *Node23) keysByLevel(level int) []Felt {
|
|
if level == 0 {
|
|
return n.canonicalKeys()
|
|
} else {
|
|
levelKeys := make([]Felt, 0)
|
|
for _, child := range n.children {
|
|
childLevelKeys := child.keysByLevel(level - 1)
|
|
levelKeys = append(levelKeys, childLevelKeys...)
|
|
}
|
|
return levelKeys
|
|
}
|
|
}
|
|
|
|
type Walker func(*Node23) interface{}
|
|
|
|
func (n *Node23) walkPostOrder(w Walker) []interface{} {
|
|
items := make([]interface{}, 0)
|
|
if !n.isLeaf {
|
|
for _, child := range n.children {
|
|
childItems := child.walkPostOrder(w)
|
|
items = append(items, childItems...)
|
|
}
|
|
}
|
|
items = append(items, w(n))
|
|
return items
|
|
}
|
|
|
|
func (n *Node23) walkNodesPostOrder() []*Node23 {
|
|
nodeItems := n.walkPostOrder(func(n *Node23) interface{} { return n })
|
|
nodes := make([]*Node23, len(nodeItems))
|
|
for i := range nodeItems {
|
|
nodes[i] = nodeItems[i].(*Node23)
|
|
}
|
|
return nodes
|
|
}
|
|
|
|
func (n *Node23) howManyHashes() uint {
|
|
if n.isLeaf {
|
|
// all leaves except last one: 2 or 3 keys + 1 or 2 values => 3 or 5 data => 2 or 4 hashes
|
|
// last leaf: 1 or 2 keys + 1 or 2 values => 2 or 4 data => 1 or 3 hashes
|
|
switch n.keyCount() {
|
|
case 2:
|
|
nextKey := n.keys[1]
|
|
if nextKey == nil {
|
|
return 1
|
|
} else {
|
|
return 2
|
|
}
|
|
case 3:
|
|
nextKey := n.keys[2]
|
|
if nextKey == nil {
|
|
return 3
|
|
} else {
|
|
return 4
|
|
}
|
|
default:
|
|
ensure(false, fmt.Sprintf("howManyHashes: unexpected keyCount=%d\n", n.keyCount()))
|
|
return 0
|
|
}
|
|
} else {
|
|
// internal node: 2 or 3 children => 1 or 2 hashes
|
|
switch n.childrenCount() {
|
|
case 2:
|
|
return 1
|
|
case 3:
|
|
return 2
|
|
default:
|
|
ensure(false, fmt.Sprintf("howManyHashes: unexpected childrenCount=%d\n", n.childrenCount()))
|
|
return 0
|
|
}
|
|
}
|
|
}
|
|
|
|
func (n *Node23) hashNode() []byte {
|
|
if n.isLeaf {
|
|
return n.hashLeaf()
|
|
} else {
|
|
return n.hashInternal()
|
|
}
|
|
}
|
|
|
|
func (n *Node23) hashLeaf() []byte {
|
|
ensure(n.isLeaf, "hashLeaf: node is not leaf")
|
|
ensure(n.valueCount() == n.keyCount(), "hashLeaf: insufficient number of values")
|
|
switch n.keyCount() {
|
|
case 2:
|
|
k, nextKey, v := *n.keys[0], n.keys[1], *n.values[0]
|
|
h := hash2(k.Binary(), v.Binary())
|
|
if nextKey == nil {
|
|
return h
|
|
} else {
|
|
return hash2(h, (*nextKey).Binary())
|
|
}
|
|
case 3:
|
|
k1, k2, nextKey, v1, v2 := *n.keys[0], *n.keys[1], n.keys[2], *n.values[0], *n.values[1]
|
|
h1 := hash2(k1.Binary(), v1.Binary())
|
|
h2 := hash2(k2.Binary(), v2.Binary())
|
|
h12 := hash2(h1, h2)
|
|
if nextKey == nil {
|
|
return h12
|
|
} else {
|
|
return hash2(h12, (*nextKey).Binary())
|
|
}
|
|
default:
|
|
ensure(false, fmt.Sprintf("hashLeaf: unexpected keyCount=%d\n", n.keyCount()))
|
|
return []byte{}
|
|
}
|
|
}
|
|
|
|
func (n *Node23) hashInternal() []byte {
|
|
ensure(!n.isLeaf, "hashInternal: node is not internal")
|
|
switch n.childrenCount() {
|
|
case 2:
|
|
child1, child2 := n.children[0], n.children[1]
|
|
return hash2(child1.hashNode(), child2.hashNode())
|
|
case 3:
|
|
child1, child2, child3 := n.children[0], n.children[1], n.children[2]
|
|
return hash2(hash2(child1.hashNode(), child2.hashNode()), child3.hashNode())
|
|
default:
|
|
ensure(false, fmt.Sprintf("hashInternal: unexpected childrenCount=%d\n", n.childrenCount()))
|
|
return []byte{}
|
|
}
|
|
}
|