From b179b7b8e7c9cac7ac21da385dbedc9f24ce3755 Mon Sep 17 00:00:00 2001 From: Abirdcfly Date: Mon, 15 Apr 2024 14:34:31 +0800 Subject: [PATCH 1/5] all: remove duplicate word in comments (#29531) This change removes some duplicate words in in comments --- cmd/utils/flags.go | 2 +- core/state/statedb_test.go | 2 +- core/vm/contracts.go | 4 ++-- crypto/signature_test.go | 2 +- eth/ethconfig/config.go | 2 +- p2p/simulations/events.go | 2 +- triedb/pathdb/errors.go | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 7d78c7b31f..1265864e44 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -661,7 +661,7 @@ var ( } HTTPPathPrefixFlag = &cli.StringFlag{ Name: "http.rpcprefix", - Usage: "HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths.", + Usage: "HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths.", Value: "", Category: flags.APICategory, } diff --git a/core/state/statedb_test.go b/core/state/statedb_test.go index bc8c634479..edde6e8254 100644 --- a/core/state/statedb_test.go +++ b/core/state/statedb_test.go @@ -1178,7 +1178,7 @@ func TestDeleteStorage(t *testing.T) { t.Fatal("delete should have empty hashes") } if len(n.Blob) != 0 { - t.Fatal("delete should have have empty blobs") + t.Fatal("delete should have empty blobs") } a = append(a, fmt.Sprintf("%x", path)) }) diff --git a/core/vm/contracts.go b/core/vm/contracts.go index bef8575bb5..140d0e087d 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -1008,7 +1008,7 @@ func (c *bls12381MapG1) RequiredGas(input []byte) uint64 { func (c *bls12381MapG1) Run(input []byte) ([]byte, error) { // Implements EIP-2537 Map_To_G1 precompile. - // > Field-to-curve call expects `64` bytes an an input that is interpreted as a an element of the base field. + // > Field-to-curve call expects an `64` bytes input that is interpreted as an element of the base field. // > Output of this call is `128` bytes and is G1 point following respective encoding rules. if len(input) != 64 { return nil, errBLS12381InvalidInputLength @@ -1043,7 +1043,7 @@ func (c *bls12381MapG2) RequiredGas(input []byte) uint64 { func (c *bls12381MapG2) Run(input []byte) ([]byte, error) { // Implements EIP-2537 Map_FP2_TO_G2 precompile logic. - // > Field-to-curve call expects `128` bytes an an input that is interpreted as a an element of the quadratic extension field. + // > Field-to-curve call expects an `128` bytes input that is interpreted as an element of the quadratic extension field. // > Output of this call is `256` bytes and is G2 point following respective encoding rules. if len(input) != 128 { return nil, errBLS12381InvalidInputLength diff --git a/crypto/signature_test.go b/crypto/signature_test.go index aecff76bfb..74d683b507 100644 --- a/crypto/signature_test.go +++ b/crypto/signature_test.go @@ -71,7 +71,7 @@ func TestVerifySignature(t *testing.T) { wrongkey := common.CopyBytes(testpubkey) wrongkey[10]++ if VerifySignature(wrongkey, testmsg, sig) { - t.Errorf("signature valid with with wrong public key") + t.Errorf("signature valid with wrong public key") } } diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index fef7f29f4e..91f2c8d330 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -83,7 +83,7 @@ type Config struct { SyncMode downloader.SyncMode // This can be set to list of enrtree:// URLs which will be queried for - // for nodes to connect to. + // nodes to connect to. EthDiscoveryURLs []string SnapDiscoveryURLs []string diff --git a/p2p/simulations/events.go b/p2p/simulations/events.go index d0d03794ed..1131185fb9 100644 --- a/p2p/simulations/events.go +++ b/p2p/simulations/events.go @@ -30,7 +30,7 @@ const ( EventTypeNode EventType = "node" // EventTypeConn is the type of event emitted when a connection is - // is either established or dropped between two nodes + // either established or dropped between two nodes EventTypeConn EventType = "conn" // EventTypeMsg is the type of event emitted when a p2p message it diff --git a/triedb/pathdb/errors.go b/triedb/pathdb/errors.go index bbf2c9e37c..498bc9ec81 100644 --- a/triedb/pathdb/errors.go +++ b/triedb/pathdb/errors.go @@ -28,7 +28,7 @@ var ( errDatabaseWaitSync = errors.New("waiting for sync") // errSnapshotStale is returned from data accessors if the underlying layer - // layer had been invalidated due to the chain progressing forward far enough + // had been invalidated due to the chain progressing forward far enough // to not maintain the layer's original state. errSnapshotStale = errors.New("layer stale") From 3705acd1a97b2cc9bbb092b326a9d8cfbc42037a Mon Sep 17 00:00:00 2001 From: yudrywet <166895665+yudrywet@users.noreply.github.com> Date: Mon, 15 Apr 2024 14:40:42 +0800 Subject: [PATCH 2/5] cmd/utils: fix typo in comment (#29528) --- cmd/utils/history_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/utils/history_test.go b/cmd/utils/history_test.go index 1d8e48344a..b6703c59ed 100644 --- a/cmd/utils/history_test.go +++ b/cmd/utils/history_test.go @@ -83,7 +83,7 @@ func TestHistoryImportAndExport(t *testing.T) { t.Fatalf("unable to initialize chain: %v", err) } if _, err := chain.InsertChain(blocks); err != nil { - t.Fatalf("error insterting chain: %v", err) + t.Fatalf("error inserting chain: %v", err) } // Make temp directory for era files. From 84b12df09e0a67e99a3943f26ccf1b6e6c19a85a Mon Sep 17 00:00:00 2001 From: Martin HS Date: Mon, 15 Apr 2024 14:54:51 +0200 Subject: [PATCH 3/5] core/rawdb: add sanity-limit to header accessor (#29534) --- core/rawdb/accessors_chain.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index e61559993c..5a4af5bb87 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -316,8 +316,8 @@ func ReadHeaderRange(db ethdb.Reader, number uint64, count uint64) []rlp.RawValu if count == 0 { return rlpHeaders } - // read remaining from ancients - data, err := db.AncientRange(ChainFreezerHeaderTable, i+1-count, count, 0) + // read remaining from ancients, cap at 2M + data, err := db.AncientRange(ChainFreezerHeaderTable, i+1-count, count, 2*1024*1024) if err != nil { log.Error("Failed to read headers from freezer", "err", err) return rlpHeaders From 67422e2a565784edaeade7d3bb747dc13f6863cf Mon Sep 17 00:00:00 2001 From: Seungbae Yu Date: Mon, 15 Apr 2024 21:58:17 +0900 Subject: [PATCH 4/5] p2p/nat: fix typos in comments (#29536) --- p2p/nat/natpmp.go | 2 +- p2p/nat/natupnp.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/p2p/nat/natpmp.go b/p2p/nat/natpmp.go index ea2d897829..94ef1f4b68 100644 --- a/p2p/nat/natpmp.go +++ b/p2p/nat/natpmp.go @@ -26,7 +26,7 @@ import ( natpmp "github.com/jackpal/go-nat-pmp" ) -// natPMPClient adapts the NAT-PMP protocol implementation so it conforms to +// pmp adapts the NAT-PMP protocol implementation so it conforms to // the common interface. type pmp struct { gw net.IP diff --git a/p2p/nat/natupnp.go b/p2p/nat/natupnp.go index c90c4f3de8..f1bb955892 100644 --- a/p2p/nat/natupnp.go +++ b/p2p/nat/natupnp.go @@ -205,8 +205,8 @@ func discoverUPnP() Interface { return nil } -// finds devices matching the given target and calls matcher for all -// advertised services of each device. The first non-nil service found +// discover finds devices matching the given target and calls matcher for +// all advertised services of each device. The first non-nil service found // is sent into out. If no service matched, nil is sent. func discover(out chan<- *upnp, target string, matcher func(goupnp.ServiceClient) *upnp) { devs, err := goupnp.DiscoverDevices(target) From ef5ac3fb7ae5bf41a465cc32845631f01ff823ef Mon Sep 17 00:00:00 2001 From: Martin HS Date: Mon, 15 Apr 2024 17:35:35 +0200 Subject: [PATCH 5/5] eth/filters: enforce topic-limit early on filter criterias (#29535) This PR adds a limit of 1000 to the "inner" topics in a filter-criteria --- eth/filters/api.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/eth/filters/api.go b/eth/filters/api.go index 59103ac03c..56a9de1b21 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -43,6 +43,9 @@ var ( // The maximum number of topic criteria allowed, vm.LOG4 - vm.LOG0 const maxTopics = 4 +// The maximum number of allowed topics within a topic criteria +const maxSubTopics = 1000 + // filter is a helper struct that holds meta information over the filter type // and associated subscription in the event system. type filter struct { @@ -539,6 +542,9 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error { return errors.New("invalid addresses in query") } } + if len(raw.Topics) > maxTopics { + return errExceedMaxTopics + } // topics is an array consisting of strings and/or arrays of strings. // JSON null values are converted to common.Hash{} and ignored by the filter manager. @@ -559,6 +565,9 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error { case []interface{}: // or case e.g. [null, "topic0", "topic1"] + if len(topic) > maxSubTopics { + return errExceedMaxTopics + } for _, rawTopic := range topic { if rawTopic == nil { // null component, match all