Commit graph

13085 commits

Author SHA1 Message Date
Daniel Liu
eb4240992e
rpc, internal/guide: speed up tests a bit #26193 (#978)
This removes an RPC test which takes > 90s to execute, and updates the
internal/guide tests to use lighter scrypt parameters.

Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-04-24 19:08:57 +08:00
Daniel Liu
a35bc8de19
rpc: support injecting HTTP headers through context #26023 (#977)
This adds a way to specify HTTP headers per request.

Co-authored-by: storyicon <storyicon@foxmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-04-24 19:08:16 +08:00
Daniel Liu
f8eb869b08
rpc: fix connection tracking set in Server #26180 (#976)
rpc: fix connection tracking in Server

When upgrading to mapset/v2 with generics, the set element type used in
rpc.Server had to be changed to *ServerCodec because ServerCodec is not
'comparable'. While the distinction is technically correct, we know all
possible ServerCodec types, and all of them are comparable. So just use
a map instead.

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-04-24 19:07:30 +08:00
Daniel Liu
18c9efa71d
rpc: handle wrong HTTP batch response length #26064 (#975)
Co-authored-by: Jordan Krage <jmank88@gmail.com>
2025-04-24 19:06:19 +08:00
Daniel Liu
02eb1d5375
rpc: improve error codes for internal server errors #25678 (#974)
This changes the error code returned by the RPC server in certain situations:

- handler panic: code -32603
- result marshaling error: code -32603
- attempt to subscribe via HTTP: code -32001

In all of the above cases, the server previously returned the default error
code -32000.

Co-authored-by: Nicholas <nicholas.zhaoyu@gmail.com>
Co-authored-by: Nicholas Zhao <nicholas.zhao@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-04-24 19:03:29 +08:00
Daniel Liu
1d6b09394b
rpc: check that version is 2.0 in request objects #25570 (#973)
The JSON-RPC spec requires the "version" field to be exactly "2.0",
so we should verify that. This change is not backwards-compatible with
sloppy client implementations, but I decided to go ahead with it anyway
because the failure will be caught via the returned error.

Co-authored-by: Seungbae Yu <dbadoy4874@gmail.com>
2025-04-24 19:02:33 +08:00
Daniel Liu
2ce0a220a2
cmd, node, rpc: add ReadHeaderTimeout config option #25338 (#972) 2025-04-24 19:01:11 +08:00
Daniel Liu
94b3ca1eeb
all: remove version field #25096 (#970) 2025-04-24 18:55:15 +08:00
Daniel Liu
4fb622bfd0
all: remove public field from rpc.API #25059 (#969) 2025-04-24 18:53:59 +08:00
Daniel Liu
175ef934ed
rpc: remove mention of shh RPC API #25137 (#968) 2025-04-24 18:41:11 +08:00
Daniel Liu
cfd7e241c6
rpc: fix defer in test #24490 (#967) 2025-04-24 18:40:19 +08:00
Daniel Liu
716e58388f
rpc: fix godoc #24488 (#966)
Co-authored-by: s7v7nislands <s7v7nislands@gmail.com>
Co-authored-by: seven <seven@nodereal.io>
2025-04-24 18:38:38 +08:00
Daniel Liu
007314980f
rpc: set Request.GetBody for client requests #24292 (#965)
When talking to an HTTP2 server, there are situations where it needs to
"rewind" the Request.Body. To allow this, we have to set up the Request.GetBody
function to return a brand new instance of the body.

If not set, we can end up with the following error:

    http2: Transport: cannot retry err [http2: Transport received Server's graceful shutdown GOAWAY] after Request.Body was written; define Request.GetBody to avoid this error

See this commit for more information: cffdcf672a

Co-authored-by: Valentin Trinqué <ValentinTrinque@users.noreply.github.com>
2025-04-24 18:37:08 +08:00
Daniel Liu
d751e88fa5
internal/jsre, node, rpc: fix goroutine leaks in tests #24211 (#964) 2025-04-24 18:36:10 +08:00
Daniel Liu
e7ca47c280
rpc: fix time key collision for logger with json output #24112 (#963)
The "t" key overrides the log message time in JSON output.

Co-authored-by: Roman Mazalov <83914728+gopherxyz@users.noreply.github.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-04-24 18:35:18 +08:00
Daniel Liu
3a618f0fd2
rpc: linear time batch response matching #23856 (#962)
This avoids quadratic time complexity in the lookup of the batch element
corresponding to an RPC response. Unfortunately, the new approach
requires additional memory for the mapping from ID to index.

Fixes #22805

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-04-24 18:34:12 +08:00
Daniel Liu
de88f30b58
rpc/client: fix typo #23834 (#961)
Co-authored-by: chuwt <weitaochu@gmail.com>
2025-04-24 18:32:44 +08:00
Daniel Liu
a997425b03
all: fix warning of DeepEqual on error #23624 (#960) 2025-04-24 18:31:47 +08:00
Daniel Liu
fae15a51b5
rpc: set pong read deadline #23556 (#959) 2025-04-24 18:22:33 +08:00
Daniel Liu
c789f86542
rpc: implement JSON marshaling of BlockNumber #23324 (#958) 2025-04-24 18:20:03 +08:00
Daniel Liu
6225b6dd9f
internal/ethapi: accept both hex and decimal for blockCount #23363 (#957) 2025-04-24 18:19:02 +08:00
Daniel Liu
9f504a6243
rpc: tighter shutdown synchronization in client subscription #22597 (#955)
This fixes a rare issue where the client subscription forwarding loop
would attempt send on the subscription's channel after Unsubscribe has
returned, leading to a panic if the subscription channel was already
closed by the user. Example:

    sub, _ := client.Subscribe(..., channel, ...)
    sub.Unsubscribe()
    close(channel)

The race occurred because Unsubscribe called quitWithServer to tell the
forwarding loop to stop sending on sub.channel, but did not wait for the
loop to actually come down. This is fixed by adding an additional channel
to track the shutdown, on which Unsubscribe now waits.

Fixes #22322

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-04-24 18:17:45 +08:00
Daniel Liu
1f430bcbb1
console: handle eth.coinbase throws #19374 (#953)
* rpc: implement full bi-directional communication #18471

* console: handle eth.coinbase throws #19374

* rpc: remove extra debug log message

* rpc: add go:build lines #23468
2025-04-24 18:11:48 +08:00
Daniel Liu
fb300a43fb
cmd/XDC, cmd/utils: set network flag early (#938)
* cmd/XDC: remove unused function applyValues

* cmd/XDC, cmd/utils: remove function SetupNetwork

* cmd/XDC, cmd/utils: set network flag early
2025-04-24 18:09:59 +08:00
benjamin202410
9656e2d1c4
update devnet reward parameter (#980)
Co-authored-by: liam.lai <liam.lai@us>
2025-04-24 03:03:32 -07:00
Daniel Liu
ab0ce75ede
core: simplify code of trading and lending state (#949) 2025-04-24 18:00:21 +08:00
Daniel Liu
733a1be4dc
common, core: add block age into info logs #17718 (#947) 2025-04-24 17:56:54 +08:00
JukLee0ira
10dd75e82f
node: serve JSON-RPC on custom path prefix #22184 (#952) 2025-04-24 11:34:26 +08:00
Daniel Liu
69323a2dbf
rpc: add HTTPError type for HTTP error responses #22677 (#956)
The new error type is returned by client operations contains details of
the response error code and response body.

Co-authored-by: ryanc414 <ryan@tokencard.io>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-04-22 15:16:48 +08:00
Daniel Liu
1667b1027d
p2p: fix goroutine leaks in unit tests #20666 (#954) 2025-04-22 15:14:21 +08:00
benjamin202410
4f98a8b81c
update devnet config to test reward (#951)
* update devnet config to test reward

* udpate reward

---------

Co-authored-by: liam.lai <liam.lai@us>
2025-04-21 01:46:24 -07:00
JukLee0ira
63b04b4114
eth: some typo mistake (#16802) (#948) 2025-04-21 16:36:20 +08:00
Daniel Liu
e974d96977
core/txpool: accept non-local transaction with zero tip (#950) 2025-04-21 16:11:43 +08:00
Daniel Liu
b9a6c8c32d
cmd, core, eth, trie: add trie read caching layer (#18087) (#946) 2025-04-16 17:27:43 +08:00
Daniel Liu
5759893f2b
trie: quell linter warnings in commiter.go (#21329) (#945) 2025-04-16 17:10:42 +08:00
Daniel Liu
bf893cb73b
trie: reduce allocs in insertPreimage (#21261) (#943)
Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
2025-04-16 17:08:31 +08:00
Daniel Liu
c91a67c4c0
common: enable cancun after 1800 blocks in eip1559 (#942) 2025-04-16 17:07:41 +08:00
wgr523
6a38aa00aa
Reward float upgrade (#940)
* feat: use float type reward

* feat: add test of float reward
2025-04-16 02:03:41 -07:00
benjamin202410
4a8800674d
Merge pull request #941 from gzliudan/rollback-eip1559
all: bump version to v2.6.1-beta
2025-04-13 14:39:43 -07:00
Daniel Liu
66aff99ca0 params: bump version to v2.6.1-beta 2025-04-12 11:38:37 +08:00
Daniel Liu
7aaf724f4f all: update parameters for rollback 2025-04-12 11:38:27 +08:00
Daniel Liu
734abb26dc Revert "core/types: fix wrong hash after EIP-1559 for EncodeIndex in PR #933 (#939)"
This reverts commit 0cc4813e48.
2025-04-12 11:30:50 +08:00
JukLee0ira
b1e08e6642
all: refactor package node #21105 (#923) 2025-04-10 18:52:49 +08:00
Daniel Liu
0cc4813e48
core/types: fix wrong hash after EIP-1559 for EncodeIndex in PR #933 (#939) 2025-04-09 00:05:21 +08:00
Wanwiset Peerapatanapokin
9a00e475b4
Merge pull request #930 from XinFinOrg/add-api-limit
consensus/XDPoS: add limit to high resource demand api
2025-04-08 15:31:50 +04:00
Daniel Liu
5328a637c0 trie: use unified emptyRootHash and emptyCodeHash (#26718) 2025-04-07 16:44:32 +08:00
Daniel Liu
c8b39cabae trie: faster trie node encoding (#24126) 2025-04-07 16:44:32 +08:00
Paweł Bylica
4df7801137 trie: simplify StackTrie implementation (#23950)
Trim the search key from head as it's being pushed deeper into the trie. Previously the search key was never modified but each node kept information how to slice and compare it in keyOffset. Now the keyOffset is not needed as this information is included in the slice of the search key. This way the keyOffset can be removed and key manipulation
simplified.
2025-04-07 16:44:32 +08:00
Paweł Bylica
ad16ad23a5 trie: more tests for stacktrie (#23936) 2025-04-07 16:44:32 +08:00
aaronbuchwald
f25180b7f8 trie: add missing copyright header (#23530)
* Add missing copyright header

* Update stacktrie_test.go

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2025-04-07 16:44:32 +08:00