Skip to content

Commit 4b51c2d

Browse files
committed
update shisui dep
Signed-off-by: Chen Kai <[email protected]>
1 parent bf35fd7 commit 4b51c2d

15 files changed

+2556
-110
lines changed

.golangci.yml

+16
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@ issues:
5050
- path: state/trie/encoding.go
5151
linters:
5252
- unused
53+
- path: portalwire/table_util_test.go
54+
linters:
55+
- unused
56+
- path: portalwire/table.go
57+
linters:
58+
- unused
59+
- unparam
60+
- path: portalwire/table_test.go
61+
linters:
62+
- unparam
63+
- path: portalwire/table_reval.go
64+
linters:
65+
- unparam
66+
- path: portalwire/lookup.go
67+
linters:
68+
- unused
5369
- path: state/trie/node_test.go
5470
text: "`randBytes` - `n` always receives `32`"
5571

go.mod

+2-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ replace github.com/protolambda/zrnt v0.32.3 => github.com/optimism-java/zrnt v0.
66

77
require (
88
github.com/VictoriaMetrics/fastcache v1.12.2
9+
github.com/cockroachdb/pebble v1.1.2
910
github.com/ethereum/go-ethereum v1.14.12
1011
github.com/ferranbt/fastssz v0.1.4
1112
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb
@@ -40,7 +41,6 @@ require (
4041
github.com/cockroachdb/errors v1.11.3 // indirect
4142
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect
4243
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
43-
github.com/cockroachdb/pebble v1.1.2 // indirect
4444
github.com/cockroachdb/redact v1.1.5 // indirect
4545
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
4646
github.com/consensys/bavard v0.1.22 // indirect
@@ -55,16 +55,12 @@ require (
5555
github.com/ethereum/c-kzg-4844 v1.0.3 // indirect
5656
github.com/ethereum/go-verkle v0.2.2 // indirect
5757
github.com/fsnotify/fsnotify v1.8.0 // indirect
58-
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
5958
github.com/getsentry/sentry-go v0.29.1 // indirect
6059
github.com/go-ole/go-ole v1.3.0 // indirect
6160
github.com/gofrs/flock v0.12.1 // indirect
6261
github.com/gogo/protobuf v1.3.2 // indirect
63-
github.com/golang-jwt/jwt/v4 v4.5.1 // indirect
6462
github.com/google/uuid v1.6.0 // indirect
6563
github.com/gorilla/websocket v1.5.3 // indirect
66-
github.com/graph-gophers/graphql-go v1.5.0 // indirect
67-
github.com/holiman/billy v0.0.0-20241012173847-7527a2505cb9 // indirect
6864
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
6965
github.com/huin/goupnp v1.3.0 // indirect
7066
github.com/influxdata/influxdb-client-go/v2 v2.14.0 // indirect
@@ -84,7 +80,6 @@ require (
8480
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
8581
github.com/oapi-codegen/runtime v1.1.1 // indirect
8682
github.com/olekukonko/tablewriter v0.0.5 // indirect
87-
github.com/peterh/liner v1.2.2 // indirect
8883
github.com/pion/dtls/v2 v2.2.12 // indirect
8984
github.com/pion/logging v0.2.2 // indirect
9085
github.com/pion/stun v0.6.1 // indirect
@@ -98,7 +93,6 @@ require (
9893
github.com/prometheus/procfs v0.15.1 // indirect
9994
github.com/rivo/uniseg v0.4.7 // indirect
10095
github.com/rogpeppe/go-internal v1.13.1 // indirect
101-
github.com/rs/cors v1.11.1 // indirect
10296
github.com/russross/blackfriday/v2 v2.1.0 // indirect
10397
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
10498
github.com/supranational/blst v0.3.13 // indirect
@@ -114,9 +108,8 @@ require (
114108
golang.org/x/net v0.31.0 // indirect
115109
golang.org/x/sync v0.10.0 // indirect
116110
golang.org/x/sys v0.28.0 // indirect
117-
golang.org/x/time v0.8.0 // indirect
118111
google.golang.org/protobuf v1.35.2 // indirect
119112
rsc.io/tmplfunc v0.0.3 // indirect
120113
)
121114

122-
replace github.com/ethereum/go-ethereum => github.com/optimism-java/shisui v1.14.6-0.20241209061923-db3778434a80
115+
replace github.com/ethereum/go-ethereum => github.com/optimism-java/shisui v1.14.6-0.20241210083122-8a63d44af240

go.sum

+2-29
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r
1414
github.com/bits-and-blooms/bitset v1.17.0 h1:1X2TS7aHz1ELcC0yU1y2stUs/0ig5oMU6STFZGrhvHI=
1515
github.com/bits-and-blooms/bitset v1.17.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
1616
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
17-
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
18-
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
1917
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
2018
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
2119
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
@@ -66,24 +64,17 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
6664
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
6765
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
6866
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
69-
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays=
70-
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
7167
github.com/getsentry/sentry-go v0.29.1 h1:DyZuChN8Hz3ARxGVV8ePaNXh1dQ7d76AiB117xcREwA=
7268
github.com/getsentry/sentry-go v0.29.1/go.mod h1:x3AtIzN01d6SiWkderzaH28Tm0lgkafpJ5Bm3li39O0=
7369
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
7470
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
75-
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
76-
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
77-
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
7871
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
7972
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
8073
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
8174
github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E=
8275
github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0=
8376
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
8477
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
85-
github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo=
86-
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
8778
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
8879
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
8980
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
@@ -97,22 +88,15 @@ github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg
9788
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
9889
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
9990
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
100-
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
10191
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
10292
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
103-
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
104-
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
10593
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
10694
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
10795
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
10896
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
10997
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
110-
github.com/graph-gophers/graphql-go v1.5.0 h1:fDqblo50TEpD0LY7RXk/LFVYEVqo3+tXMNMPSVXA1yc=
111-
github.com/graph-gophers/graphql-go v1.5.0/go.mod h1:YtmJZDLbF1YYNrlNAuiO5zAStUWc3XZT07iGsVqe1Os=
11298
github.com/hashicorp/go-bexpr v0.1.14 h1:uKDeyuOhWhT1r5CiMTjdVY4Aoxdxs6EtwgTGnlosyp4=
11399
github.com/hashicorp/go-bexpr v0.1.14/go.mod h1:gN7hRKB3s7yT+YvTdnhZVLTENejvhlkZ8UE4YVBS+Q8=
114-
github.com/holiman/billy v0.0.0-20241012173847-7527a2505cb9 h1:M8ms5fN6+bAS1KySjDWTXHCQ6aS0Qsm29xdEOm2Meqg=
115-
github.com/holiman/billy v0.0.0-20241012173847-7527a2505cb9/go.mod h1:SCQdl3Vv9DgXmpsGuOn3kjhGgqFoWwB+Y2ITbC52dyc=
116100
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
117101
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
118102
github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw=
@@ -151,7 +135,6 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
151135
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
152136
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
153137
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
154-
github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
155138
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
156139
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
157140
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
@@ -183,15 +166,12 @@ github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9k
183166
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
184167
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
185168
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
186-
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
187-
github.com/optimism-java/shisui v1.14.6-0.20241209061923-db3778434a80 h1:+NwWFTn9pT/rXGg7SMxapxJzTV9Tu396hf3rmKpgfV4=
188-
github.com/optimism-java/shisui v1.14.6-0.20241209061923-db3778434a80/go.mod h1:thV9bgHBOBHDkJJPtsQpaxT5hLsnEFwhYO87I8iE8UU=
169+
github.com/optimism-java/shisui v1.14.6-0.20241210083122-8a63d44af240 h1:HtGAmnakF7bM19xoneFdIAr5Ny6d0y39BzWUt2EhOsw=
170+
github.com/optimism-java/shisui v1.14.6-0.20241210083122-8a63d44af240/go.mod h1:3Cm01IO8CZFmvdgJwICe7iQwuKsPAb5TLjKdVtBGe1Q=
189171
github.com/optimism-java/utp-go v0.0.0-20241110145701-0f0eebf881b3 h1:KfAZ//Sxrqulozmw4QoC8jY3h4I5diWXWPmZ1gptvGY=
190172
github.com/optimism-java/utp-go v0.0.0-20241110145701-0f0eebf881b3/go.mod h1:dJZNMUlyNpjM2VkUEHhmFprLei6gCg3r7U9qj9MmJNQ=
191173
github.com/optimism-java/zrnt v0.32.4-0.20240415084906-d9dbf06b32f7 h1:ZTQWXQ8xblCRUXhZs3h5qrBMSAHe8iNH7BG7a7IVFlI=
192174
github.com/optimism-java/zrnt v0.32.4-0.20240415084906-d9dbf06b32f7/go.mod h1:A0fezkp9Tt3GBLATSPIbuY4ywYESyAuc/FFmPKg8Lqs=
193-
github.com/peterh/liner v1.2.2 h1:aJ4AOodmL+JxOZZEL2u9iJf8omNRpqHc/EbrK+3mAXw=
194-
github.com/peterh/liner v1.2.2/go.mod h1:xFwJyiKIXJZUKItq5dGHZSTBRAuG/CpeNpWLyiNRNwI=
195175
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
196176
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
197177
github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s=
@@ -235,8 +215,6 @@ github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc
235215
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
236216
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
237217
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
238-
github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA=
239-
github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
240218
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
241219
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
242220
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
@@ -276,8 +254,6 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
276254
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
277255
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
278256
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
279-
go.opentelemetry.io/otel v1.6.3/go.mod h1:7BgNga5fNlF/iZjG06hM3yofffp0ofKCDwSXx1GC4dI=
280-
go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs=
281257
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
282258
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
283259
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
@@ -338,7 +314,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
338314
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
339315
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
340316
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
341-
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
342317
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
343318
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
344319
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -369,8 +344,6 @@ golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
369344
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
370345
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
371346
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
372-
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
373-
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
374347
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
375348
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
376349
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=

portalwire/api.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (d *DiscV5API) AddEnr(enr string) (bool, error) {
103103
}
104104

105105
// immediately add the node to the routing table
106-
d.DiscV5.Table().AddInboundNode(n)
106+
d.DiscV5.AddKnownNode(n)
107107
return true, nil
108108
}
109109

@@ -112,7 +112,7 @@ func (d *DiscV5API) GetEnr(nodeId string) (bool, error) {
112112
if err != nil {
113113
return false, err
114114
}
115-
n := d.DiscV5.Table().GetNode(id)
115+
n := d.DiscV5.GetNode(id)
116116
if n == nil {
117117
return false, errors.New("record not in local routing table")
118118
}
@@ -126,12 +126,12 @@ func (d *DiscV5API) DeleteEnr(nodeId string) (bool, error) {
126126
return false, err
127127
}
128128

129-
n := d.DiscV5.Table().GetNode(id)
129+
n := d.DiscV5.GetNode(id)
130130
if n == nil {
131131
return false, errors.New("record not in local routing table")
132132
}
133133

134-
d.DiscV5.Table().DeleteNode(n)
134+
d.DiscV5.DeleteNode(n)
135135
return true, nil
136136
}
137137

@@ -278,7 +278,7 @@ func (p *PortalProtocolAPI) GetEnr(nodeId string) (string, error) {
278278
return p.portalProtocol.localNode.Node().String(), nil
279279
}
280280

281-
n := p.portalProtocol.table.GetNode(id)
281+
n := p.portalProtocol.table.getNode(id)
282282
if n == nil {
283283
return "", errors.New("record not in local routing table")
284284
}
@@ -292,12 +292,12 @@ func (p *PortalProtocolAPI) DeleteEnr(nodeId string) (bool, error) {
292292
return false, err
293293
}
294294

295-
n := p.portalProtocol.table.GetNode(id)
295+
n := p.portalProtocol.table.getNode(id)
296296
if n == nil {
297297
return false, nil
298298
}
299299

300-
p.portalProtocol.table.DeleteNode(n)
300+
p.portalProtocol.table.deleteNode(n)
301301
return true, nil
302302
}
303303

portalwire/common.go

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// Copyright 2019 The go-ethereum Authors
2+
// This file is part of the go-ethereum library.
3+
//
4+
// The go-ethereum library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Lesser General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// The go-ethereum library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Lesser General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Lesser General Public License
15+
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
16+
17+
package portalwire
18+
19+
import (
20+
"crypto/ecdsa"
21+
crand "crypto/rand"
22+
"encoding/binary"
23+
"math/rand"
24+
"net"
25+
"net/netip"
26+
"sync"
27+
"time"
28+
29+
"github.com/ethereum/go-ethereum/common/mclock"
30+
"github.com/ethereum/go-ethereum/log"
31+
"github.com/ethereum/go-ethereum/p2p/enode"
32+
"github.com/ethereum/go-ethereum/p2p/enr"
33+
"github.com/ethereum/go-ethereum/p2p/netutil"
34+
)
35+
36+
// UDPConn is a network connection on which discovery can operate.
37+
type UDPConn interface {
38+
ReadFromUDPAddrPort(b []byte) (n int, addr netip.AddrPort, err error)
39+
WriteToUDPAddrPort(b []byte, addr netip.AddrPort) (n int, err error)
40+
Close() error
41+
LocalAddr() net.Addr
42+
}
43+
44+
// Config holds settings for the discovery listener.
45+
type Config struct {
46+
// These settings are required and configure the UDP listener:
47+
PrivateKey *ecdsa.PrivateKey
48+
49+
// All remaining settings are optional.
50+
51+
// Packet handling configuration:
52+
NetRestrict *netutil.Netlist // list of allowed IP networks
53+
Unhandled chan<- ReadPacket // unhandled packets are sent on this channel
54+
55+
// Node table configuration:
56+
Bootnodes []*enode.Node // list of bootstrap nodes
57+
PingInterval time.Duration // speed of node liveness check
58+
RefreshInterval time.Duration // used in bucket refresh
59+
NoFindnodeLivenessCheck bool // turns off validation of table nodes in FINDNODE handler
60+
61+
// The options below are useful in very specific cases, like in unit tests.
62+
V5ProtocolID *[6]byte
63+
Log log.Logger // if set, log messages go here
64+
ValidSchemes enr.IdentityScheme // allowed identity schemes
65+
Clock mclock.Clock
66+
}
67+
68+
func (cfg Config) withDefaults() Config {
69+
// Node table configuration:
70+
if cfg.PingInterval == 0 {
71+
cfg.PingInterval = 3 * time.Second
72+
}
73+
if cfg.RefreshInterval == 0 {
74+
cfg.RefreshInterval = 30 * time.Minute
75+
}
76+
77+
// Debug/test settings:
78+
if cfg.Log == nil {
79+
cfg.Log = log.Root()
80+
}
81+
if cfg.ValidSchemes == nil {
82+
cfg.ValidSchemes = enode.ValidSchemes
83+
}
84+
if cfg.Clock == nil {
85+
cfg.Clock = mclock.System{}
86+
}
87+
return cfg
88+
}
89+
90+
// ReadPacket is a packet that couldn't be handled. Those packets are sent to the unhandled
91+
// channel if configured.
92+
type ReadPacket struct {
93+
Data []byte
94+
Addr netip.AddrPort
95+
}
96+
97+
type randomSource interface {
98+
Intn(int) int
99+
Int63n(int64) int64
100+
Shuffle(int, func(int, int))
101+
}
102+
103+
// reseedingRandom is a random number generator that tracks when it was last re-seeded.
104+
type reseedingRandom struct {
105+
mu sync.Mutex
106+
cur *rand.Rand
107+
}
108+
109+
func (r *reseedingRandom) seed() {
110+
var b [8]byte
111+
_, _ = crand.Read(b[:])
112+
seed := binary.BigEndian.Uint64(b[:])
113+
new := rand.New(rand.NewSource(int64(seed)))
114+
115+
r.mu.Lock()
116+
r.cur = new
117+
r.mu.Unlock()
118+
}
119+
120+
func (r *reseedingRandom) Intn(n int) int {
121+
r.mu.Lock()
122+
defer r.mu.Unlock()
123+
return r.cur.Intn(n)
124+
}
125+
126+
func (r *reseedingRandom) Int63n(n int64) int64 {
127+
r.mu.Lock()
128+
defer r.mu.Unlock()
129+
return r.cur.Int63n(n)
130+
}
131+
132+
func (r *reseedingRandom) Shuffle(n int, swap func(i, j int)) {
133+
r.mu.Lock()
134+
defer r.mu.Unlock()
135+
r.cur.Shuffle(n, swap)
136+
}

0 commit comments

Comments
 (0)