Commit Graph

1686 Commits

Author SHA1 Message Date
Delweng
a404195c7b
eth/tracers: fix the issue prestate missing existing contract state (#25996)
The prestate tracer did not report accounts that existed at a given address prior to a contract being created at that address.

Signed-off-by: Delweng <delweng@gmail.com>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2022-10-21 11:48:53 +02:00
Delweng
c776a98c83
eth/tracers: fix the issue of panic in prestate with diffmode (#25957)
In some cases, inner contract creation may not be successful, and an inner contract was not created. This PR fixes a crash that could occur when doing tracing in such situations.
2022-10-12 12:50:01 +02:00
lmittmann
5b1a04b9c7
eth/filters, ethclient/gethclient: add fullTx option to pending tx filter (#25186)
This PR adds a way to subscribe to the _full_ pending transactions, as opposed to just being notified about hashes. 

In use cases where client subscribes to newPendingTransactions and gets txhashes only to then request the actual transaction, the caller can now shortcut that flow and obtain the transactions directly. 


Co-authored-by: Felix Lange <fjl@twurst.com>
2022-10-12 11:54:52 +02:00
Jens W
010f47f76a
eth/protocols/eth: fix typo in log message (#25969) 2022-10-12 11:15:19 +02:00
Martin Holst Swende
5a02b2d6d0
all: fix spelling mistakes (#25961) 2022-10-11 09:37:00 +02:00
Ryan Schneider
df2b3cd2bd
eth/filters: fix for eth_getLogs failing with finalized- and safe tag (#25922)
Prior to this change, f.begin (and possibly end) stay negative, leading to strange results later in the code. With this change, filters using "safe" and "finalized" block produce results consistent w/ the overall behavior of this RPC method.

Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-10-06 14:43:55 +02:00
Martin Holst Swende
067bac3f24
core, ethclient/gethclient: improve flaky tests (#25918)
* ethclient/gethclient: improve time-sensitive flaky test

* eth/catalyst: fix (?) flaky test

* core: stop blockchains in tests after use

* core: fix dangling blockchain instances

* core: rm whitespace

* eth/gasprice, eth/tracers, consensus/clique: stop dangling blockchains in tests

* all: address review concerns

* core: goimports

* eth/catalyst: fix another time-sensitive test

* consensus/clique: add snapshot test run function

* core: rename stop() to stopWithoutSaving()

Co-authored-by: Felix Lange <fjl@twurst.com>
2022-10-06 13:39:20 +02:00
rjl493456442
e50aeac4d0
eth/traces: add state limit (#25812)
This PR introduces a new mechanism in chain tracer for preventing creating too many trace states.

The workflow of chain tracer can be divided into several parts:

- state creator generates trace state in a thread
- state tracer retrieves the trace state and applies the tracing on top in another thread
- state collector gathers all result from state tracer and stream to users

It's basically a producer-consumer model here, while if we imagine that the state producer generates states too fast, then it will lead to accumulate lots of unused states in memory. Even worse, in path-based state scheme it will only keep the latest 128 states in memory, and the newly generated state will invalidate the oldest one by marking it as stale.

The solution for fixing it is to limit the speed of state generation. If there are over 128 states un-consumed in memory, then the creation will be paused until the states are be consumed properly.
2022-10-06 10:48:04 +02:00
Delweng
5d52a35931
eth/tracers: add diffMode to prestateTracer (#25422)
Backwards compatibility warning: The result will from now on omit empty fields instead
of including a zero value (e.g. no more `balance: '0x'`).

The prestateTracer will now take an option `diffMode: bool`. In this mode
the tracer will output the pre state and post data for the modified parts of state.
Read-only accesses will be completely omitted. Creations (be it account or slot)
will be signified by omission in the `pre` list and inclusion in `post`. Whereas
deletion (be it account or slot) will be signified by inclusion in `pre` and omission
in `post` list.

Signed-off-by: Delweng <delweng@gmail.com>
2022-10-05 19:05:43 -05:00
Péter Szilágyi
4f7a425aa8
Merge pull request #25924 from holiman/comments_fix
all: fix docstrings
2022-10-04 13:30:00 +03:00
Martin Holst Swende
ee301c750b
all: fix docstrings 2022-10-04 09:18:02 +02:00
rjl493456442
1913b50111
eth, miner: add timeout for building sealing block (#25407)
* eth, miner: add timeout for building sealing block

* eth, cmd, miner: add newpayloadtimeout flag

* eth, miner, cmd: address comments

* eth, miner: minor fixes

Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-10-03 14:10:00 +02:00
Martin Holst Swende
f61b50b1e8
eth/protocols/snap: serve snap requests when possible (#25644)
This PR makes it so that the snap server responds to trie heal requests when possible, even if the snapshot does not exist. The idea being that it might prolong the lifetime of a state root, so we don't have to pivot quite as often.
2022-10-03 13:37:17 +02:00
Sina Mahmoodi
ff1f49245d
eth/tracers: remove revertReasonTracer, add revert reason to callTracer (#25508)
* eth/tracers: add revertReason to callTracer

* update callframe gen json

* add revertal to calltrace test
2022-09-29 11:36:07 +02:00
Delweng
85aafcfb2b
eth/tracers: fix a bug in prestateTracer (#25884) 2022-09-28 17:52:39 +02:00
Martin Holst Swende
456b187892
trie, eth/protocols/snap: less tiny db-writes during trie-healing (#25681)
This PR prevent making tiny writes during state healing, by only performing the batch-write if the accumulated data is large enough to be meaningful.
2022-09-28 08:08:18 +02:00
Martin Holst Swende
80cc34ac3c
eth/downloader: make flakey test less flakey (#25879) 2022-09-27 15:49:52 +02:00
zhiqiangxu
13e6985929
eth: return state error via GetEVM (#25876)
* make vmError more useful

* fix for review

* Update api.go

* revert calling site

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2022-09-27 13:16:54 +02:00
rjl493456442
bff84a99fe
cmd, core, eth, les, light: track deleted nodes (#25757)
* cmd, core, eth, les, light: track deleted nodes

* trie: add docs

* trie: address comments

* cmd, core, eth, les, light, trie: trie id

* trie: add tests

* trie, core: updates

* trie: fix imports

* trie: add utility print-method for nodeset

* trie: import err

* trie: fix go vet warnings

Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-09-27 10:01:02 +02:00
Sina Mahmoodi
fc3e6d0162
eth/tracers: use gencodec for native tracers (#25637)
The call tracer and prestate tracer store data JSON-encoded in memory. In order to support alternative encodings (specifically RLP), it's better to keep data a native format during tracing. This PR does marshalling at the end, using gencodec.

OBS! 
This PR changes the call tracer result slightly:

-  Order of type and value fields are changed (should not matter). 
-  Output fields are completely omitted when they're empty (no more output: "0x"). Previously, this was only _sometimes_ omitted (e.g. when call ended in a non-revert error) and otherwise 0x when the output was actually empty.
2022-09-26 18:35:44 +02:00
zhiqiangxu
b32d20324e
eth/downloader, les/downloader: fix subtle flaw in queue delivery (#25861)
* fix queue.deliver

* les/downloader: fix queue.deliver

Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-09-26 12:33:21 +02:00
Sina Mahmoodi
4dc212d4f1
eth/tracers: pad memory slice on OOB case (#25213)
* eth/tracers: pad memory slice on oob case

* eth/tracers/js: fix testfailure due to err msg capitalization

Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-09-26 09:56:45 +02:00
Zachinquarantine
9b35f3f5b1
tests, les, eth: remove mentions of deprecated Morden testnet (#23570)
* remove morden

* Update commons.go

* Update handler.go

* empty commit to make appveyor happy
2022-09-23 19:33:15 +02:00
Martin Holst Swende
fb500d12d5
eth/protocols/snap: make log messages more clear that sync is ongoing (#25837)
* eth/protocols/snap: make log messages more clear that sync is ongoing

* Update sync.go

Co-authored-by: Felix Lange <fjl@twurst.com>
2022-09-23 11:11:41 +03:00
Martin Holst Swende
400ab0d94f
eth/catalyst: make tests run faster (#25818) 2022-09-21 15:12:45 +02:00
Martin Holst Swende
6eb8f3225e
eth/catalyst: add locking around newpayload (#25816)
Sometimes we get stuck on db compaction, and the CL re-issues the "same" command to us multiple times. Each request get stuck on the same place, in the middle of the handler.

This changes makes it so we do not reprocess the same payload, but instead detects it early.
2022-09-21 13:48:09 +02:00
makcandrov
5d11d38f4d
eth/tracers: fix trace config for TraceCall (#25821)
Co-authored-by:  AtomicAzzaz  <AtomicAzzaz@users.noreply.github.com>
Co-authored-by:  ewile <ewile@users.noreply.github.com>
2022-09-21 09:55:48 +02:00
Péter Szilágyi
d728ba97d8
eth: fix a rare datarace on CHT challenge reply / shutdown 2022-09-20 14:14:24 +03:00
Felix Lange
b628d72766
build: upgrade to go 1.19 (#25726)
This changes the CI / release builds to use the latest Go version. It also
upgrades golangci-lint to a newer version compatible with Go 1.19.

In Go 1.19, godoc has gained official support for links and lists. The
syntax for code blocks in doc comments has changed and now requires a
leading tab character. gofmt adapts comments to the new syntax
automatically, so there are a lot of comment re-formatting changes in this
PR. We need to apply the new format in order to pass the CI lint stage with
Go 1.19.

With the linter upgrade, I have decided to disable 'gosec' - it produces
too many false-positive warnings. The 'deadcode' and 'varcheck' linters
have also been removed because golangci-lint warns about them being
unmaintained. 'unused' provides similar coverage and we already have it
enabled, so we don't lose much with this change.
2022-09-10 13:25:40 +02:00
Péter Szilágyi
de8d5fa042
eth/protocols/snap: throttle trie heal requests when peers DoS us (#25666)
* eth/protocols/snap: throttle trie heal requests when peers DoS us

* eth/protocols/snap: lower heal throttle log to debug

Co-authored-by: Martin Holst Swende <martin@swende.se>

* eth/protocols/snap: fix comment

Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-09-09 11:42:57 +03:00
rjl493456442
6a575eda6f
eth/tracer: fix broken test (#25715) 2022-09-08 08:06:06 +02:00
rjl493456442
b1f6dccfba
eth, les: rework chain tracer (#25143)
This PR simplifies the logic of chain tracer and also adds the unit tests.

The most important change has been made in this PR is the state management. Whenever a tracing state is acquired there is a corresponding release function be returned as well. It must be called once the state is used up, otherwise resource leaking can happen.

And also the logic of state management has been simplified a lot. Specifically, the state provider(eth backend, les backend) should ensure the state is available and referenced. State customers can use the state according to their own needs, or build other states based on the given state. But once the release function is called, there is no guarantee of the availability of the state.


Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2022-09-07 20:25:58 +02:00
rjl493456442
dea1fb3cfc
all: cleanup tests (#25641)
Follow-up to PR #25523 to cleanup all relevant tests.
2022-09-07 20:21:59 +02:00
Felix Lange
731885809c
eth/tracers/js: improve integer types in log object (#25668)
All fields related to gas must be represented as uint64. Depth is
internally tracked as int, so it makes sense to also store it as int.
2022-09-05 14:06:16 +02:00
Martin Holst Swende
7f2890a9be
eth/fetcher: throttle peers which deliver many invalid transactions (#25573)
Co-authored-by: Felix Lange <fjl@twurst.com>
2022-09-02 17:28:33 +02:00
Sina Mahmoodi
d6a12bc7b8
eth/tracers/js: fill in log.refund field (#25661)
For some reason, an accessor method for this field exists in JS, but
the value was never actually assigned.
2022-09-02 17:08:25 +02:00
Péter Szilágyi
511bf8f188
Merge pull request #25651 from holiman/fix_snapqueue
eth/protocols/snap: fix problems due to idle-but-busy peers
2022-09-01 12:38:34 +03:00
Marius van der Wijden
95a2c221d4
eth/catalyst: prevent division by zero (#25654)
eth/catalyst: prevent diff by zero
2022-08-31 21:29:39 +03:00
Martin Holst Swende
dafa40e7a7
eth/protocols/snap: fix problems due to idle-but-busy peers 2022-08-31 17:58:18 +02:00
Martin Holst Swende
362256ebff
eth/catalyst: adjust eta for themerge (#25601)
* eth/catalyst: adjust eta for themerge

* squash

* squash

* eth/catalyst: address review concerns
2022-08-31 13:28:35 +03:00
rjl493456442
d10c280309
all: move genesis initialization to blockchain (#25523)
* all: move genesis initialization to blockchain

* core: add one more check

* core: fix tests
2022-08-30 18:22:28 +02:00
Péter Szilágyi
81bd998353
core, eth/downloader: handle spurious junk bodies from racey rollbacks (#25578)
* eth/downloader: handle junkbodies/receipts in the beacon sync

* core: check for header presence when checking for blocks
2022-08-23 14:02:51 +03:00
Péter Szilágyi
395f3d4bf6
eth/catalyst: warn less frequently if no beacon client is available (#25569)
* eth/catalyst: warn less frequently if no beacon client is available

* eth/catalyst: tweak warning frequency a bit

* eth/catalyst: some more tweaks

* Update api.go

Co-authored-by: Felix Lange <fjl@twurst.com>
2022-08-22 11:27:39 +03:00
Péter Szilágyi
02418c2fa9
Revert "eth/fetcher: don't spend too much time on transaction inclusion" (#25567)
Revert "eth/fetcher: don't spend too much time on transaction inclusion (#25524)"

This reverts commit 0ce494b60c.
2022-08-22 10:14:56 +03:00
Martin Holst Swende
0ce494b60c
eth/fetcher: don't spend too much time on transaction inclusion (#25524)
* eth/fetcher: introduce some lag in tx fetching

* eth/fetcher: change conditions a bit

* eth/fetcher: use per-batch quota check

* eth/fetcher: fix some comments

* eth/fetcher: address review concerns

* eth/fetcher: fix panic + add warn log

* eth/fetcher: fix log

* eth/fetcher: fix log

* cmd/devp2p/internal/ethtest: fix ignorign tx announcements from prev. tests

* cmd/devp2p/internal/ethtest: fix TestLargeTxRequest

This increases the number of tx relay messages the test waits for. Since
go-ethereum now processes incoming txs in smaller batches, the
announcement messages it sends are also smaller.

Co-authored-by: Felix Lange <fjl@twurst.com>
2022-08-19 16:59:36 +03:00
Sina Mahmoodi
36874b63a1
eth/filters: add global block logs cache (#25459)
This adds a cache for block logs which is shared by all filters. The cache
size of is configurable using the `--cache.blocklogs` flag.

Co-authored-by: Felix Lange <fjl@twurst.com>
2022-08-19 11:14:59 +02:00
Justin Traglia
656dc8cc00
eth, les: unlock downloader peerSet if there's an error (#25546)
Unlock peerSet if there's an error in the downloader
2022-08-19 09:02:47 +03:00
Justin Traglia
2c5648d891
all: fix some typos (#25551)
* Fix some typos

* Fix some mistakes

* Revert 4byte.json

* Fix an incorrect fix

* Change files to fails
2022-08-19 09:00:21 +03:00
rjl493456442
a41ea8a97c
all: cleanup the APIs for initializing genesis (#25473)
* all: polish tests

* core: apply feedback from Guillaume

* core: fix comment
2022-08-09 12:44:39 +03:00
Sina Mahmoodi
86de2e516e
eth/tracers: add onlyTopCall option to callTracer (#25430)
This PR allows users to pass in a config object directly to the tracers. Previously only the struct logger was configurable.

It also adds an option to the call tracer which if enabled makes it ignore any subcall and collect only information about the top-level call. See #25419 for discussion.

The tracers will silently ignore if they are passed a config they don't care about.
2022-08-09 11:04:57 +02:00
aaronbuchwald
759d795c56
eth: formatted error nit (#25499) 2022-08-09 11:23:41 +03:00
int88
e93442c6cf
eth/downloader: fix log errors of queue_test.go (#25494) 2022-08-08 16:07:54 +03:00
Guillaume Ballet
f67e54c92f
core: use TryGetAccount to read what TryUpdateAccount has written (#25458)
* core: use TryGetAccount to read where TryUpdateAccount has been used to write

* Gary's review feedback

* implement Gary's suggestion

* fix bug + rename NewSecure into NewStateTrie

* trie: add backwards-compatibility aliases for SecureTrie

* Update database.go

* make the linter happy

Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2022-08-04 16:13:18 +02:00
rjl493456442
8b53b92eb4
core, trie: rework trie committer (#25320)
* all: rework trie and trie committer

* all: get rid of internal cache in trie

* all: fixes

* trie: polish

* core, trie: address comments

* trie: fix imports

* core/state: address comments

* core/state/snapshot: polish

* trie: remove unused code

* trie: update tests

* trie: don't set db as nil

* trie: address comments

* trie: unskip test
2022-08-04 11:03:20 +03:00
lightclient
a0b88ce869
eth/gasprice/feehistory: support finalized block (#25442) 2022-08-01 19:13:30 +02:00
Sina Mahmoodi
1b34ed2ed6
eth: fix typo in catalyst api (#25460)
eth: fix typo
2022-08-01 17:33:39 +03:00
Péter Szilágyi
6fd06ab075
cmd, core, eth, les, params: add merge-passed chain config (#24538)
* cmd, core, eth, les, params: add merge-passed chain config

* eth/catalyst, params: add various warning on malfunctioning beacons

* eth/catalyst: fix warning for beacons without transition exchanges
2022-08-01 15:13:25 +03:00
Rithwik Babu
fea569f90a
eth: fix typo in comment (#25327) 2022-07-29 18:29:01 +02:00
Marius van der Wijden
377c7d799f
eth/catalyst: return 0x0 if latestvalid is pow block (#25423)
* eth/catalyst: return 0x0 if latestvalid is pow block

* eth/catalyst: return 0x0 if latestvalid is pow block

* eth/catalyst: fix header retrieval, fix sign check

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2022-07-28 16:16:15 +03:00
Marius van der Wijden
f3549814a9
eth/catalyst: return syncing not accepted (#25414)
* eth/catalyst: return syncing not accepted

* eth/catalyst: fix test
2022-07-28 16:01:35 +03:00
Péter Szilágyi
ad7106dfc4
eth/catalyst: fix NewPayload warn log when dropping due to snap sync 2022-07-28 08:46:13 +03:00
rjl493456442
9d76a9b94f
core, trie, eth, cmd: rework preimage store (#25287)
* core, trie, eth, cmd: rework preimage store

* trie: address comment
2022-07-27 20:37:04 +02:00
Marius van der Wijden
c6dcd018d2
core: eth: rpc: implement safe rpc block (#25165)
* core: eth: rpc: implement safe rpc block

* core: fix setHead, panics
2022-07-25 18:42:05 +03:00
Péter Szilágyi
f3af3fd8df
eth: support bubbling up bad blocks from sync to the engine API (#25190)
* eth: support bubbling up bad blocks from sync to the engine API

* eth/catalyst: fix typo

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>

* eth/catalyst: fix typo

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>

* Update eth/catalyst/api.go

* eth/catalyst: when forgetting bad hashes, also forget descendants

* eth/catalyst: minor bad block tweaks for resilience

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-07-25 16:51:04 +03:00
Péter Szilágyi
eb2b8cb4fd
eth/tracers/js: fix capitalization in tests 2022-07-25 16:49:16 +03:00
Delweng
b196ad1c16
all: add whitespace linter (#25312)
* golangci: typo

Signed-off-by: Delweng <delweng@gmail.com>

* golangci: add whietspace

Signed-off-by: Delweng <delweng@gmail.com>

* *: rm whitesapce using golangci-lint

Signed-off-by: Delweng <delweng@gmail.com>

* cmd/puppeth: revert accidental resurrection

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2022-07-25 13:14:03 +03:00
Seungbae.yu
d2247d9f5d
eth, internal, light: fix error string capitalization (#25364) 2022-07-25 12:53:44 +03:00
Marius van der Wijden
b2be5f956f
eth/catalyst: better warning for ttd not configured (#25394) 2022-07-25 12:06:22 +03:00
Marius van der Wijden
3b2a6b34d9
cmd/geth: eth/catalyst: enable authrpc by default (#25152)
* cmd/geth: eth/catalyst: enable authrpc by default

* eth/catalyst: rename catalyst -> Engine API in logs

* eth/catalyst: don't panic
2022-07-23 09:56:02 +02:00
rjl493456442
1657e43931
core, les, eth: port snap sync changes (#24898)
core, eth, les, trie: rework snap sync
2022-07-15 14:55:51 +03:00
Péter Szilágyi
b53d38246e
Merge pull request #25096 from lightclient/remove-version-field
all: remove version field
2022-07-14 12:13:59 +03:00
Philip Fan
3e759e28d7
eth/tracers: add initial revertReasonTracer tracer (#25265)
Adds a native tracer that returns that in case of failure returns the error message or the revert reason of a transaction.

Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-07-12 10:10:12 +02:00
Seungbae.yu
44893be0d6
core, eth: pre-allocate map in storage copy (#25279) 2022-07-12 10:08:45 +03:00
Seungbae.yu
2697e44d81
all: change format 0x%x to %#x (#25221) 2022-07-04 11:03:32 +03:00
Péter Szilágyi
de1cecb22e
eth/catalyst: disallow importing blocks via newPayload during snap sync (#25210)
* eth/catalyst: disallow importing blocks via newPayload during snap sync

* eth/catalyst: make tests pass by using full sync only

* eth/catalysts: make the import delay a bit cleaner

* eth/catalyst: fix typo

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
2022-07-01 14:38:26 +03:00
lightclient@protonmail.com
0c6f81f888
all: remove version field from rpc.API 2022-06-27 12:39:46 +02:00
lightclient
119f955686
all: remove public field from rpc.API (#25059)
all: remove public field from rpc.API
2022-06-27 13:33:13 +03:00
int88
e620fa3980
eth: fix typo (#25161) 2022-06-24 15:28:01 +03:00
Sina Mahmoodi
6135c688b8
eth/tracers: optimize goja buffer conversion (#25156)
This changes the []byte <-> Uint8Array conversion to use an
ArrayBuffer, avoiding inefficient copying of the slice data in Goja.

Co-authored-by: Felix Lange <fjl@twurst.com>
2022-06-23 18:11:47 +02:00
rjl493456442
7c7cd410d1
eth, miner: retrieve mining state from live database (#25139)
* miner: retrieve mining state from live database

* eth/catalyst: ignore stale fcu events from cl
2022-06-22 14:59:55 +03:00
lightclient
10dc5dce08
all: remove concept of public/private API definitions (#25053)
* internal/ethapi: rename PublicEthereumAPI to EthereumAPI

* eth: rename PublicEthereumAPI to EthereumAPI

* internal/ethapi: rename PublicTxPoolAPI to TxPoolAPI

* internal/ethapi: rename PublicAccountAPI to EthereumAccountAPI

* internal/ethapi: rename PrivateAccountAPI to PersonalAccountAPI

* internal/ethapi: rename PublicBlockChainAPI to BlockChainAPI

* internal/ethapi: rename PublicTransactionPoolAPI to TransactionAPI

* internal/ethapi: rename PublicDebugAPI to DebugAPI

* internal/ethapi: move PrivateDebugAPI methods to DebugAPI

* internal/ethapi: rename PublicNetAPI to NetAPI

* les: rename PrivateLightServerAPI to LightServerAPI

* les: rename PrivateLightAPI to LightAPI

* les: rename PrivateDebugAPI to DebugAPI

* les: rename PublicDownloaderAPI to DownloaderAPI

* eth,les: rename PublicFilterAPI to FilterAPI

* eth: rename PublicMinerAPI to MinerAPI

* eth: rename PublicDownloaderAPI to DownloaderAPI

* eth: move PrivateMinerAPI methods to MinerAPI

* eth: rename PrivateAdminAPI to AdminAPI

* eth: rename PublicDebugAPI to DebugAPI

* eth: move PrivateDebugAPI methods to DebugAPI

* node: rename publicAdminAPI to adminAPI

* node: move privateAdminAPI methods to adminAPI

* node: rename publicWeb3API to web3API

* eth,internal/ethapi: sync comments with previous renamings
2022-06-21 12:05:43 +03:00
Marius van der Wijden
d8f963811d
cmd, params: implement Gray Glacier hard-fork (EIP-5133) (#25088)
* cmd/geth, params: implement Gray Glacier (EIP-5133)

* cmd/evm: add gray glacier tests

* params: nitpicks

* params: fixes
2022-06-15 14:10:38 +03:00
rjl493456442
30602163d5
eth: introduce eth67 protocol (#24093)
The new protocol version removes support for GetNodeData.
See https://eips.ethereum.org/EIPS/eip-4938 for more information.

Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-06-15 12:56:47 +02:00
lightclient
3273ad1a58
eth: add missing period at end of sentences (#25058)
eth: add missing periods on end of comments
2022-06-15 09:29:23 +02:00
lightclient
1cf58c7b81
readme,eth: remove references to eth.wiki (#25086) 2022-06-14 12:59:05 +02:00
Martin Holst Swende
a907d7e81a
all: more linters (#24783)
This enables the following linters

- typecheck
- unused
- staticcheck
- bidichk
- durationcheck
- exportloopref
- gosec

WIth a few exceptions.

- We use a deprecated protobuf in trezor. I didn't want to mess with that, since I cannot meaningfully test any changes there.
- The deprecated TypeMux is used in a few places still, so the warning for it is silenced for now.
- Using string type in context.WithValue is apparently wrong, one should use a custom type, to prevent collisions between different places in the hierarchy of callers. That should be fixed at some point, but may require some attention.
- The warnings for using weak random generator are squashed, since we use a lot of random without need for cryptographic guarantees.
2022-06-13 16:24:45 +02:00
Martin Holst Swende
b60a08d2fd
eth/catalyst: remove unauthenticated 'engine' api (#24997)
Removes engine from any unauthenticated RPC service.
2022-06-08 15:36:25 +02:00
Péter Szilágyi
41e75480df
eth, les, params: log chain config a bit saner (#24904)
Previously on Geth startup we just logged the chain config is a semi-json-y format. Whilst that worked while we had a handful of hard-forks defined, currently it's kind of unwieldy. 

This PR converts that original data dump and converts it into a user friendly - alas multiline - log output.
2022-06-07 12:49:07 +02:00
Sina Mahmoodi
d9566e39bd
eth/filters: fix getLogs for pending block (#24949)
* eth/filters: fix pending for getLogs

* add pending method to test backend

* fix block range validation
2022-06-07 08:31:19 +02:00
Ikko Ashimine
096daa9a7d
eth/tracers: fix typo in 4byte_tracer_legacy.js (#25020)
indentifier -> identifier
2022-06-06 17:55:16 +02:00
lightclient
10da98072c
eth/api: use hexutil.Bytes for account range method (#25024)
eth/api: use hexutil.Bytes for range at methods
2022-06-06 17:33:05 +02:00
rjl493456442
22defa5af7
all: introduce trie owner notion (#24750)
* cmd, core/state, light, trie, eth: add trie owner notion

* all: refactor

* tests: fix goimports

* core/state/snapshot: fix ineffasigns

Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-06-06 17:14:55 +02:00
Marius van der Wijden
2227589f9b
eth/catalyst: return 0x0 on Invalid block on top of pow block (#25006) 2022-06-02 13:15:17 +02:00
Martin Holst Swende
d8a2305565
eth/tracers: add support for block overrides in debug_traceCall (#24871)
This PR adds support for block overrides when doing debug_traceCall.

- Previously, debug_traceCall against pending erroneously used a common.Hash{} stateroot when looking up the state, meaning that a totally empty state was used -- so it always failed,
- With this change, we reject executing debug_traceCall against pending.
- And we add ability to override all evm-visible header fields.
2022-06-02 11:39:36 +02:00
Marius van der Wijden
8c0c0434c9
core/beacon: prevent invalid logsBloom length panic (#24946)
* core/beacon: prevent invalid logsBloom length panic

* core/beacon: prevent negative baseFeePerGas

* Update core/beacon/types.go

Co-authored-by: Martin Holst Swende <martin@swende.se>

* eth/catalys: go format

Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-05-31 11:11:50 +02:00
Boqin Qin(秦 伯钦)
03157b6efa
eth/filters: use buffered channel to avoid goroutine leak (#24928) 2022-05-30 20:35:37 +02:00
Marius van der Wijden
93fe17559b
eth/catalyst: fix edge case in NewPayload (#24955)
Fixes an issue where we would accept a NewPayload where the grandparent is already post ttd, and the parent still has a Difficulty
2022-05-30 13:28:15 +02:00
Felix Lange
9244d5cd61
all: update license headers and AUTHORS from git history (#24947) 2022-05-24 20:39:40 +02:00
Sina Mahmoodi
ba47d800b1
eth/tracers/js: drop duktape engine (#24934)
#23773 added a JS tracer which uses Goja as its engine. In this PR I remove the previous tracer which used duktape as well as remove the dependencies.

This PR also comes with 2 fixes in the Goja tracer and one small behavioural change:

    I had handled errors in the native Go functions by panicing. My oversight was that Goja only handles panics with a Goja.Value as argument. The difference is panic(goja.Value) allows JS to catch the exception whereas Interrupt(error) doesn't.
    There was a race in how I handled Stop.
    Because of 1. some of the methods that simply return nil on error (like memory.slice) now throw an exception.
2022-05-23 22:26:10 +02:00
Péter Szilágyi
34bda5eae3
core, eth, les, rpc: polish catalyst errors, add context 2022-05-20 12:15:54 +03:00
Marius van der Wijden
4a4d531052
eth/catalyst: update implementation to spec (#24802)
* eth/catalyst: return invalid payload attributes error

* eth/catalyst: implement LVH as specified, add tests

* eth/catalyst: return current block hash not header hash

* eth/catalyst: fix test

* eth/catalyst: bring error codes in line with spec
2022-05-20 11:12:12 +03:00
Eduard S
310f751639
eth/tracers/js: add memory.length method (#24887) 2022-05-19 14:35:30 +02:00
Sina Mahmoodi
bf693228a3
eth/tracers/js: goja tracer (#23773)
This adds a JS tracer runtime environment based on the Goja VM. The new
runtime replaces the duktape runtime, which will be removed soon.

Goja is implemented in Go and is faster for cases where the Go <-> JS
transition overhead dominates overall performance. It is faster because
duktape is written in C, and the transition cost includes the cost of using
cgo. Another reason for using Goja is that go-duktape is not maintained
anymore.

We expect the performace of JS tracing to be at least as good or better with
this change.
2022-05-18 16:34:18 +02:00
Marius van der Wijden
cc9fb8e21d
eth/catalyst, miner: build the execution payload async (#24866)
* eth/catalyst: build the execution payload async

* miner: added comment, added test case

* eth/catalyst: miner: move async block production to miner

* eth/catalyst, miner: support generate seal block async

* miner: rework GetSealingBlockAsync to use a passed channel

* miner: apply rjl's diff

* eth/catalyst: nitpicks

Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2022-05-18 17:33:37 +03:00
Marius van der Wijden
e6fa102eb0
core, eth, internal, rpc: implement final block (#24282)
* eth: core: implement finalized block

* eth/catalyst: fix final block

* eth/catalyst: update finalized head gauge

* internal/jsre/deps: updated web3.js to allow for finalized block

* eth/catalyst: make sure only one thread can call fcu

* eth/catalyst: nitpicks

* eth/catalyst: use plain mutex

* eth: nitpicks
2022-05-18 17:30:42 +03:00
Håvard Anda Estensen
4b309c7006
all: replace non-trivial uses of package ioutil with os (#24886)
Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-05-17 14:27:04 +02:00
Marius van der Wijden
381c66caf0
eth/catalyst: set the correct LatestValidHash (#24855)
* eth/catalyst: set the correct LatestValidHash

* eth/catalyst: core: return LVH during reorg, rework invalid teminal block

* eth/catalyst: nitpicks
2022-05-17 12:32:55 +03:00
rjl493456442
39fb82bcfb
eth: fix flaky test, don't attach empty slots/proofs (#24885)
* eth/protocols/snap: don't include empty snapshot slot slice

This PR fixes the snapshot storage serving handler. In snap protocol
the response is capped by the response size. Server can cutdown the
response if the accumulated byte size exceeds the local hard limit.

It means we can meet a special scenario that there is no storage slot
included for a requested account, but we attach the proof for this
account by mistake.

So in the prover side, when it meets a empty storage response but with
a valid proof proves there are some more slots left in the trie, then
requestor will reject this response and disconnect with server.

In this PR, if there is no storage slot served for the requested account,
then no proof should be attached as well.

* eth/protocols/snap: loosen restrictions for flaky tests

* eth/catalyst: fix flaky test in catalyst
2022-05-17 11:19:51 +03:00
Håvard Anda Estensen
07508ac0e9
all: replace uses of ioutil with io and os (#24869) 2022-05-16 11:59:35 +02:00
Martin Holst Swende
646503208e
eth/protocols/snap: sort trienode heal requests by path (#24779)
* sort snap trienode heal requests

* eth/protocols/snap: remove debug code

* eth/protocols/snap: simplify sort, generate pathsets later

* eth/protocols/snap: review concern

* eth/protocols/snap: renamings

* eth/protocols/snap: add comments in Merge

* eth/protocols/snap: remove variable 'last' in Merge

* eth/protocols/snap: fix lint flaws in test

Co-authored-by: Felix Lange <fjl@twurst.com>
2022-05-10 17:37:24 +03:00
s7v7nislands
7caa2d8163
all: replace strings.Replace with string.ReplaceAll (#24835) 2022-05-09 13:13:23 +03:00
Marius van der Wijden
86d5477079
core/state/snapshot: fix race condition (#24685)
Fixes three race conditions found through fuzzing by David Theodore
2022-05-06 17:20:41 +02:00
Martin Holst Swende
7175f82495
eth/fetcher: avoid hang in tests (partial fix for #23331) (#23351)
* eth/fetcher: fix test to avoid hanging. Partial fix for #23331

* eth/filters: avoid dangling goroutines

* eth/fetcher: revert closing of proceed
2022-05-06 15:23:43 +02:00
Mateusz Morusiewicz
cef1a86df2
miner: discard interrupted blocks (#24638)
During mining, when a new head arrives and interrupts the block building, the block being built should not be commited (but discarded). Committing the interrupted block introduces unnecessary delay, and possibly causes miner to mine on the previous head, which could result in higher uncle rate.
2022-05-06 11:19:30 +02:00
EXEC
256aae0bfa
eth/filters: remove explicit continue label in filterLogs (#24795)
The loop label can be removed because this 'continue' statement
is not in a nested loop.
2022-05-05 17:58:43 +02:00
s7v7nislands
1c90d97c1e
eth/protocols/eth: fix godoc comments (#24810)
Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-05-05 17:35:36 +02:00
rjl493456442
7f6f01d46f
core: recover state when beacon sets canonical head if it's missing (#24613)
* core: recover the state in SetChainHead if the head state is missing

* core: disable test logging

* core: address comment from martin

* core: improve log level in case state is recovered

* core, eth, les, light: rename SetChainHead to SetCanonical
2022-05-05 10:36:26 +03:00
Péter Szilágyi
ecae8e4f65
cmd, eth: fix required blocks regression 2022-05-04 19:55:17 +03:00
EXEC
d6b77f661c
eth/filters: fix code comment (#24799) 2022-05-04 15:32:51 +02:00
hero5512
f94e23ca66
eth/filters: remove unused struct fields (#24782) 2022-04-29 10:07:52 +02:00
s7v7nislands
7ab15490e9
all: use 'embed' instead of go-bindata (#24744) 2022-04-25 11:15:14 +02:00
Emmanuel T Odeke
a8bb49b8ea
eth/tracers/logger: remove unnecessary comparisons in accessList.equal (#24663)
This change removes extraneous/unnecessary checks for equality
when comparing 2 accessList values A and B. Given that we validate that
their lengths of A and B are equal, if so and if every element in A is
in B, reflexively every element in B is already in A. If that weren't
the case and an element g existed in A but not in B, that would mean
that there is an extra element and hence a mathematical contradiction.

Fixes #24658
2022-04-22 01:30:15 +02:00
Ikko Ashimine
40cfe71002
eth/downloader: fix typo in downloader.go (#24704)
synchornization -> synchronization
2022-04-20 16:17:29 +02:00
rjl493456442
f0328f241b
eth/downloader: resolve local header by hash for beacon sync (#24691)
* eth/downlaoder: resolve local header by hash for beacon sync

* eth/downloader: fix error message

* eth/downloader: cap the reverse header resolving

* eth/downloader: re-enable tests

* eth/downloader: add warning logs
2022-04-14 09:49:23 +03:00
Péter Szilágyi
86216189a5
eth/downloader: remove stale beacon headers as backfilling progresses (#24670)
* eth/downloader: remove stale beacon headers as backfilling progresses

* eth/downloader: remove leftover from a previous design

* eth/downloader: do partial beacon cleanups if chain is large

* eth/downloader: linter != heart
2022-04-13 20:31:08 +03:00
Sina Mahmoodi
9c82c646e4
eth/tracers: make txhash blockhash accessible to native tracers (#24679) 2022-04-12 21:09:27 +02:00
ucwong
d4d288e3f1
build: add imports for go generate tools (#24682)
This adds a tools.go file to import all command packages used for
go:generate. Doing so makes it possible to execute go-based code
generators using 'go run', locking in the tool version using go.mod.

Co-authored-by: Felix Lange <fjl@twurst.com>
2022-04-12 20:24:02 +02:00
Marius van der Wijden
c40943a167
cmd: set DefaultGasLimit to 30M (#24680)
* cmd: set DefaultGasLimit to 30M, rem deprec. Flag

* cmd: revert flag deprecation
2022-04-12 08:48:03 +03:00
Eng Zer Jun
8d066f1f42
all: use T.TempDir to create temporary test directories (#24633)
This commit replaces ioutil.TempDir with t.TempDir in tests. The
directory created by t.TempDir is automatically removed when the test
and all its subtests complete.

Prior to this commit, temporary directory created using ioutil.TempDir
had to be removed manually by calling os.RemoveAll, which is omitted in
some tests. The error handling boilerplate e.g.

	defer func() {
		if err := os.RemoveAll(dir); err != nil {
			t.Fatal(err)
		}
	}

is also tedious, but t.TempDir handles this for us nicely.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-04-08 15:44:55 +02:00
Péter Szilágyi
111a1b73cf
Merge pull request #24652 from karalabe/block-fetcher-timeouts
eth/fetcher: if peers never respond, drop them
2022-04-06 10:43:18 +03:00
Sina Mahmoodi
fb3a081c7e
eth/tracers: refactor traceTx to separate out struct logging (#24326)
* eth/tracers: refactor traceTx to separate out struct logging

review fix

Update eth/tracers/api.go

Co-authored-by: Martin Holst Swende <martin@swende.se>

Mv ExecutionResult type to logger package

review fix

impl GetResult for StructLogger

make formatLogs private

confused exit and end..

account for intrinsicGas in structlogger, fix TraceCall test

Add Stop method to logger

Simplify traceTx

Fix test

rm logger from blockchain test

account for refund in structLogger

* use tx hooks in struct logger

* minor

* avoid executionResult in struct logger

* revert blockchain test changes
2022-04-06 09:34:18 +02:00
Péter Szilágyi
7e2bbb9cbb
eth/fetcher: if peers never respond, drop them 2022-04-06 10:18:57 +03:00
rjl493456442
28ec26094b
eth/downloader: retrieve pivot header from local chain if necessary (#24610)
* eth/downloader: retrieve pivot header from local chain if necessary

* eth/downloader: improve readability

* eth/downloader: update fix

* eth/downloader: add beacon sync tests

* eth/downloader: remove duplicated code
2022-04-04 10:10:16 +03:00
Martin Holst Swende
1e973a96b4
eth: clarify the error string on getlogs failure (#24617)
This PR makes the errors we spit out a bit more clear about what block is problematic.
2022-03-31 21:16:03 +02:00
Sina Mahmoodi
3fd16af5a9
core,eth: implement tx-level hooks for tracers (#24510)
* core,eth: add empty tx logger hooks

* core,eth: add initial and remaining gas to tx hooks

* store tx gasLimit in js tracer

* use gasLimit to compute intrinsic cost for js tracer

* re-use rules in transitiondb

* rm logs

* rm logs

* Mv some fields from Start to TxStart

* simplify sender lookup in prestate tracer

* mv env to TxStart

* Revert "mv env to TxStart"

This reverts commit 656939634b9aff19f55a1cd167345faf8b1ec310.

* Revert "simplify sender lookup in prestate tracer"

This reverts commit ab65bce48007cab99e68232e7aac2fe008338d50.

* Revert "Mv some fields from Start to TxStart"

This reverts commit aa50d3d9b2559addc80df966111ef5fb5d0c1b6b.

* fix intrinsic gas for prestate tracer

* add comments

* refactor

* fix test case

* simplify consumedGas calc in prestate tracer
2022-03-31 11:51:44 +02:00
Nic Jansma
127dc5982e
eth: change snapshot extension registration failure to warning instead of error (#24475)
* core: Change Snapshot extension registration failed to Debug

* Update eth/handler.go

Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-03-30 10:28:27 +02:00
Martin Holst Swende
67c070c379
eth/tracers/logger: use omitempty to reduce log bloat (#24547)
Makes the evm json output less verbose: omitting output of `memory` and `returndata` in case they are empty.
2022-03-29 22:36:55 +02:00
Marius van der Wijden
de6a113f84
eth/catalyst: only apply block if we actually have the state (#24598)
* eth/catalyst: only apply block if we actually have the state

* add header to payload queue

* Update cmd/geth/dbcmd.go

Co-authored-by: Martin Holst Swende <martin@swende.se>

Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-03-29 18:26:18 +02:00
Marius van der Wijden
535f25d65f
eth/catalyst: fix log message (#24574) 2022-03-23 21:00:26 +01:00
Martin Holst Swende
f252154599
eth/downloader: fix flakey test (#24576) 2022-03-23 20:57:53 +01:00
rjl493456442
e0e8bf31c5
eth/downloader: ignore zero size header batch for importing (#24569)
* eth/downloader: ignore zero size header batch for importing

* core, light: reject empty header batch for importing
2022-03-22 18:58:05 +01:00
Péter Szilágyi
51de2bc9dc
eth/downloader: terminate beacon sync early when linked to local chain (#24550)
* eth/downloader: terminate beacon sync early when linked to local chain

* eth/downloader: fix backfiller resume on early beacon termination
2022-03-21 10:43:54 +02:00
Marius van der Wijden
4f4622bc8b
core: eth: implement Kiln-v2 spec (#24506)
* core/beacon: eth/catalyst: updated engine api to new version

* core: implement exchangeTransitionConfig

* core/beacon: prevRandao instead of Random

* eth/catalyst: Fix ExchangeTransitionConfig, add test

* eth/catalyst: stop external miners on TTD reached

* node: implement --authrpc.vhosts flag

* core: allow for config override on non-mainnet networks

* eth/catalyst: fix peters comments

* eth/catalyst: make stop remote sealer more explicit

* eth/catalyst: add log output

* cmd/utils: rename authrpc.host to authrpc.addr

* eth/catalyst: disable the disabling of the miner

* eth: core: remove notion of terminal pow block

* eth: les: more of peters nitpicks
2022-03-17 17:20:03 +02:00
Péter Szilágyi
6b8718c374
eth/downloader: fix off-by-one error in test causing 50% fails 2022-03-16 08:57:00 +02:00
Ryan Schneider
dbfd397262
cmd/geth: rename --whitelist to --eth.requiredblocks (#24505)
* cmd, eth: Rename whitelist argument to peer.requiredblocks

* eth/ethconfig: document PeerRequiredBlocks better

* cmd/utils: rename new flag to --eth.requiredblocks

Co-authored-by: Felix Lange <fjl@twurst.com>
2022-03-15 12:20:03 +01:00
Guifel
85042b7090
eth/tracers: use hex encoding for debug_traceBlock argument (#24517) 2022-03-15 10:27:30 +01:00
Péter Szilágyi
8f66ea3786
eth/downloader: implement beacon sync (#23982)
* eth/downloader: implement beacon sync

* eth/downloader: fix a crash if the beacon chain is reduced in length

* eth/downloader: fix beacon sync start/stop thrashing data race

* eth/downloader: use a non-nil pivot even in degenerate sync requests

* eth/downloader: don't touch internal state on beacon Head retrieval

* eth/downloader: fix spelling mistakes

* eth/downloader: fix some typos

* eth: integrate legacy/beacon sync switchover and UX

* eth: handle UX wise being stuck on post-merge TTD

* core, eth: integrate the beacon client with the beacon sync

* eth/catalyst: make some warning messages nicer

* eth/downloader: remove Ethereum 1&2 notions in favor of merge

* core/beacon, eth: clean up engine API returns a bit

* eth/downloader: add skeleton extension tests

* eth/catalyst: keep non-kiln spec, handle mining on ttd

* eth/downloader: add beacon header retrieval tests

* eth: fixed spelling, commented failing tests out

* eth/downloader: review fixes

* eth/downloader: drop peers failing to deliver beacon headers

* core/rawdb: track beacon sync data in db inspect

* eth: fix review concerns

* internal/web3ext: nit

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
2022-03-11 14:14:45 +02:00
Péter Szilágyi
1b58e42802
Merge pull request #24529 from holiman/fix_inf
eth/protocols/snap: avoid estimating infinite percentage
2022-03-11 10:40:55 +02:00
沉风
7d3ecca451
eth/protocols/snap: a little typo Merkel -> Merkle (#24530) 2022-03-11 10:32:08 +02:00
Sina Mahmoodi
57cec89253
graphql: fee history fields (#24452)
This PR adds the `NextBaseFeePerGas` to `Block` and `EffectiveTip` to `Transaction` to make it easier for clients to compute fee history themselves via graphql queries.
2022-03-10 13:59:22 +01:00