Skip to content

Commit

Permalink
[Upgrade] Go-Ethereum release v1.10.0 (#1249)
Browse files Browse the repository at this point in the history
* consensus/ethash: implement faster difficulty calculators (#21976)

This PR adds re-written difficulty calculators, which are based on uint256. It also adds a fuzzer + oss-fuzz integration for the new fuzzer. It does differential fuzzing between the new and old calculators.

Note: this PR does not actually enable the new calculators.

* consensus: refactor FinalizeAndAssemble to use Finalize (#21993)

* core, eth, les: implement unclean-shutdown marker (#21893)

This PR implements unclean shutdown marker. Every time geth boots, it adds a timestamp to a list of timestamps in the database. This list is capped at 10. At a clean shutdown, the timestamp is removed again. 
Thus, when geth exits unclean, the marker remains, and at boot up we show the most recent unclean shutdowns to the user, which makes it easier to diagnose root-causes to certain problems. 

Co-authored-by: Nagy Salem <[email protected]>

* abi/bind: fix error-handling in generated wrappers for functions returning structs (#22005)

Fixes the template used when generating code, which in some scenarios would lead to panic instead of returning an error.

* cmd/abigen: clarify abigen alias flag usage (#21875)

* doc: clarify abigen alias flag usage

update the `abigen --alias` flag help info, give an example to make it more clear

related issue: ethereum/go-ethereum#21846

* Update cmd/abigen/main.go

Co-authored-by: ligi <[email protected]>

Co-authored-by: Martin Holst Swende <[email protected]>
Co-authored-by: ligi <[email protected]>

* core, eth: split eth package, implement snap protocol (#21482)

This commit splits the eth package, separating the handling of eth and snap protocols. It also includes the capability to run snap sync (https://github.com/ethereum/devp2p/blob/master/caps/snap.md) , but does not enable it by default. 

Co-authored-by: Marius van der Wijden <[email protected]>
Co-authored-by: Martin Holst Swende <[email protected]>

* cmd/geth: fixed parallelization flaw in account import test (#22002)

* eth/protocols/eth: remove magic numbers in test (#21999)

* eth, core: speed up some tests (#22000)

* les: les/4 minimalistic version (#21909)

* les: allow tx unindexing in les/4 light server mode

* les: minor fixes

* les: more small fixes

* les: add meaningful constants for recentTxIndex handshake field

* cmd/faucet: sort requests by newest first (#22018)

* eth/download/statesync : optimize to avoid a copy in state sync hashing  (#22035)

* eth/download/statesync : state hash sum optimized

* go fmt with blank in imports

* keccak read arg fix

* eth/downloader: fix typo in comment (#22019)

* internal/ethapi: restore net_version RPC method (#22061)

During the snap and eth refactor, the net_version rpc call was falsely deprecated.
This restores the net_version RPC handler as most eth2 nodes and other software
depend on it.

* common,crypto: move fuzzers out of core (#22029)

* common,crypto: move fuzzers out of core

* fuzzers: move vm fuzzer out from core

* fuzzing: rework cover package logic

* fuzzers: lint

* README.md: update Travis badge (#22079)

The legacy dot-org URL was displaying a message about the repository
having migrated to the dot-com service, which now covers open-source
projects as well.

* eth, eth/tracers: include intrinsic gas in calltracer, expose for all tracers (#22038)

* eth/tracers: share tx gas price with js tracer

* eth/tracers: use `go generate`

* eth/tracers: try with another version of go-bindata

* eth/tracers: export txGas

* eth, eth/tracers: pass intrinsic gas to js tracers

eth/tracers: include tx gas in tracers usedGas

eth/tracers: fix prestate tracer's sender balance

eth/tracers: rm unnecessary import

eth/tracers: pass intrinsicGas separately to tracer

eth/tracers: fix tests broken by lack of txdata

eth, eth/tracers: minor fix

* eth/tracers: regenerate assets + unexport test-struct + add testcase

* eth/tracers: simplify tests + make table-driven

Co-authored-by: Guillaume Ballet <[email protected]>
Co-authored-by: Martin Holst Swende <[email protected]>

* tests/fuzzers: fix false positive in bitutil fuzzer (#22076)

* cmd/geth: replace wiki links with new doc pages (#22071)

* eth/filters: replace wiki links with new doc pages (#22070)

* signer: docs - replace wiki links with new doc pages (#22069)

* eth/downloader: remove unnecessary condition (#22052)

* docs: replace wiki links with new doc pages in readme.md (#22065) (#22066)

* core/rawdb, eth/protocols : Method name typo fix (#22026)

* accounts/abi/bind: fix erroneous test (#22053)

closes #22049

* core/state/snapshot: gethring -> gathering typo (#22104)

* cmd/geth: update copyright year (#22099)

* .github: Replace wiki links with new doc pages (#22065) (#22068)

* node: rename startNetworking to openEndpoints (#22105)

* SECURITY.md: link to release page (#22067)

Add links to go-ethereum's GitHub release page.

Co-authored-by: Felix Lange <[email protected]>

* cmd: support v1.1 Twitter API in faucet, fix puppeth

* miner: avoid sleeping in miner (#22108)

This PR removes a logic in the miner, which was originally intended to help temporary testnets based on ethash from "running off into the future". If the difficulty was low, and a few computers started mining several blocks per second, the ethash rules (which demand 1s delay between blocks) would push the blocktimes further and further away.
The solution was to make the miner sleep while this happened.

Nowadays, this problem is solved instead by PoA chains, and it's recommended to let testnets and devnets be based on clique instead. The existing logic is problematic, since it can cause stalls within the miner making it difficult for remote workers to submit work if the channel is blocked on a sleep.

Credits to Saar Tochner for reporting this via the bug bounty

* cmd/geth: usb is off by default (#21984)

* graphql: use a decimal representation for gas limit and gas used (#21883)

This changes the JSON encoding of blocks returned by the API
to have decimal instead of hexadecimal numbers. The spec wants
it this way.

Co-authored-by: Martin Holst Swende <[email protected]>

* cmd/geth: added --mainnet flag (#21932)

* cmd/geth: added --mainnet flag

* cmd/utils: set default genesis if --mainnet is specified

* cmd/utils: addressed comments

* common/compiler: fix parsing of solc output with solidity v.0.8.0 (#22092)

Solidity 0.8.0 changes the way that output is marshalled. This patch allows to parse both
the legacy format used previously and the new format.

See also https://docs.soliditylang.org/en/breaking/080-breaking-changes.html#interface-changes

* eth/downloader: enhanced test cases for downloader queue (#22114)

* cmd/utils, eth/downloader: minor snap nitpicks

* crypto: fix ineffectual assignments (#22124)

* crypto/bls12381: fixed ineffectual assignment

* crypto/signify: fix ineffectual assignment

* graphql: return decimal for `estimateGas` and `cumulativeGas` queries  (#22126)

* estimateGas, cumulativeGas
* linted
* add test for estimateGas

* snapshot, trie: fixed typos, mostly in snapshot pkg (#22133)

* cmd/faucet: fix websocket race regression after switching to gorilla

* eth/protocols/snap: track reverts when peer rejects request (#22016)

* eth/protocols/snap: reschedule missed deliveries

* eth/protocols/snap: clarify log message

* eth/protocols/snap: revert failures async and update runloop

Co-authored-by: Péter Szilágyi <[email protected]>

* eth/protocols/snap: speed up hash checks (#22023)

* eth/protocols/snap: speed up hash checks

* eth/protocols/snap: nit fix

Co-authored-by: Péter Szilágyi <[email protected]>

* cmd/faucet: switch Facebook auth over to mobile site

* les: remove transaction propagation limits (#22125)

* cmd/faucet: fix nonce-gap problem (#22145)

* cmd/faucet: avoid encoding for each client

* cmd/faucet: fix flaw in clearing of txs, avoid sending more than necessary

* cmd/faucet: fix flaw in tx cropping

* cmd/faucet: revert change to not always send tx info

* cmd/faucet: review fixes

* cmd/faucet: revert #22018, fix order in UI

* cmd/faucet: fix lock error

* cmd/faucet: revert json changes

* squashme

* ethclient: better test suite for ethclient package (#22127)

This commit extends the ethclient test suite and increases code coverage of the ethclient
package from ~15% to >55%. These tests act as early smoke tests to signal issues in the
RPC-interface. E.g. if a functionality like eth_chainId or eth_call breaks, the test
will break.

* eth/downloader: fix race condition in tests (#22140)

* downloader: fix race condition in tests

* eth/downloader: fix race condition in tests

* Revert "downloader: fix race condition in tests"

This reverts commit 108033ebc6985de83791d375b6e6647a77d28d5a.

* core: persist bad blocks (#21827)

* core: persist bad blocks

* core, eth, internal: address comments

* core/rawdb: add badblocks to inspector

* core, eth: update

* internal: revert

* core, eth: only save 10 bad blocks

* core/rawdb: address comments

* core/rawdb: fix

* core: address comments

* common/prque: pull in tests and benchmarks from upstream

* eth: improve log message (#22146)

* eth: fixed typos

* eth: fixed log message

* graphql: fix issue with unmarshalling int32 into `Long` type #22153

* eth: return error from eth_chainID during sync before EIP-155 activates (#21686)

This changes the chainID RPC method to return an error when EIP-155 is not yet
active at the current block height. It used to simply return zero in this case, but
that's confusing.

* cmd/utils: avoid making console preloads absolute (#22109)

Resolves etclabscore/core-geth#273

jsre.JSRE already handles establishing preload
file paths relative to the 'assets' path (aka docroot),
where it joins the assets dir and the file path if relative,
or uses the file path only if absolute.

The duplication of this logic by MakeConsolePreloads
caused preloaded files to have paths which contained
duplicate references to the assets dir path.

Date: 2020-12-30 08:25:01-06:00
Signed-off-by: meows <[email protected]>

* go.mod: use github.com/holiman/bloomfilter/v2 (#22044)

* deps: use improved bloom filter implementation

* eth/handler, trie: use 4 keys for syncbloom + minor fixes

* eth/protocols, trie: revert change on syncbloom method signature

* cmd/utils: don't enumerate USB unless --usb is set (#22130)

USB enumeration still occured. Make sure it will only occur if --usb is set.
This also deprecates the 'NoUSB' config file option in favor of a new option 'USB'.

* tests: update the reference tests (#22009)

* graphql: fix spurious error in test (#22164)

This solves an issue in graphql tests:

    graphql_test.go:38: could not create new node: datadir already used by another process

* consensus/ethash: increase seal timeout for tests (#22162)

It seems that the 2 second timeout is not enough for Travis CI:

   --- FAIL: TestTestMode (2.00s)
       ethash_test.go:53: sealing result timeout

* graphql: fix spurious travis failure (#22166)

The tests sometimes failed with certain go versions because
the behavior of http.Server.Shutdown changed over time. A bug
that was fixed in Go 1.15 could cause active connections on unrelated
servers to close unexpectedly. This is fixed by avoiding use of the
same port number in all tests.

* cmd/faucet: update the embedded website asset

* core/state/snapshot: add generation logs to storage too

* les: don't drop sentTo for normal cases (#22048)

* eth/protocols/eth: fix slice resize flaw (#22181)

* les: remove useless protocol defines (#22115)

This PR has two changes in the les protocol:

- the auxRoot is not supported. See ethereum/devp2p#171 for more information
- the empty response will be returned in GetHelperTrieProofsMsg request if the merkle
   proving is failed. note, for backward compatibility, the empty merkle proof as well as
   the request auxiliary data will still be returned in  les2/3 protocol no matter the proving
   is successful or not. the proving failure can happen e.g. request the proving for a
   non-included entry in helper trie (unstable header).

* tests/fuzzers/abi: better test generation (#22158)

* tests/fuzzers/abi: better test generation

* tests/fuzzers/abi: fixed packing issue

* oss-fuzz: enable abi fuzzer

* cmd/geth: dump config for metrics (#22083)

* cmd/geth: dump config

* cmd/geth: dump config

* cmd/geth: properly read config again

* cmd/geth: override metrics if flags are set

* cmd/geth: write metrics regardless if enabled

* cmd/geth: renamed to metricsfromcliargs

* metrics: add default configuration

* core/state/snapshot: write snapshot generator in batch (#22163)

* core/state/snapshot: write snapshot generator in batch

* core: refactor the tests

* core: update tests

* core: update tests

* cmd/geth: graceful shutdown if disk is full (#22103)

Adding warnings of free disk space left and graceful shutdown when there is not enough space left.
This also adds a flag datadir.minfreedisk which can be used to set the trigger for low disk space, and setting it to zero disables the check. 

Co-authored-by: Martin Holst Swende <[email protected]>
Co-authored-by: Felix Lange <[email protected]>

* eth, les: add new config field SyncFromCheckpoint (#22123)

This PR introduces a new config field SyncFromCheckpoint for light client.

In some special scenarios, it's required to start synchronization from some
arbitrary checkpoint or even from the scratch. So this PR offers this
flexibility to users so that the synchronization start point can be configured.

There are two relevant configs: SyncFromCheckpoint and Checkpoint.

- If the SyncFromCheckpoint is true, the light client will try to sync from the
  specified checkpoint.

- If the Checkpoint is not configured, then the light client will sync from the
  scratch(from the latest header if the database is not empty)

Additional notes: these two configs are not visible in the CLI flags but only
accessable in the config file.

Example Usage:

[Eth]
SyncFromCheckpoint = true

[Eth.Checkpoint]
SectionIndex = 100
SectionHead = "0xabc"
CHTRoot = "0xabc"
BloomRoot = "0xabc"

PS. Historical checkpoint can be retrieved from the synced full node or light
client via les_getCheckpoint API.

* oss-fuzz: fix abi fuzzer (#22199)

* go.mod: upgrade golang-lru (#22134)

* downloader: extract findAncestor search functions (#21744)

This is a simple refactoring, extracting common ancestor
negotiation logic to named function

* core: implement background trie prefetcher

Squashed from the following commits:

core/state: lazily init snapshot storage map
core/state: fix flawed meter on storage reads
core/state: make statedb/stateobjects reuse a hasher
core/blockchain, core/state: implement new trie prefetcher
core: make trie prefetcher deliver tries to statedb
core/state: refactor trie_prefetcher, export storage tries
blockchain: re-enable the next-block-prefetcher
state: remove panics in trie prefetcher
core/state/trie_prefetcher: address some review concerns

sq

* core/state: convert prefetcher to concurrent per-trie loader

* eth/filters: fix potential deadlock in filter timeout loop (#22178)

This fixes #22131 and adds a test reproducing the issue.

* event: add ResubscribeErr (#22191)

This adds a way to get the error of the failing subscription
for logging/debugging purposes.

Co-authored-by: Felix Lange <[email protected]>

* trie: fix range prover (#22210)

Fixes a special case when the trie only has a single trie node and the range proof only contains a single element.

* common/mclock: remove dependency on github.com/aristanetworks/goarista (#22211)

It takes three lines of code to get to runtime.nanotime, no need to
pull a dependency for that.

* cmd, geth: CLI help fixes (#22220)

* cmd, geth: Reflect command being optional - closes 22218

* cmd, geth: Set current year to 2021

* cmd, geth: CLI help fixes (#22220)

* cmd, geth: Reflect command being optional - closes 22218

* cmd, geth: Set current year to 2021

* eth/protocols/snap: snap sync testing (#22179)

* eth/protocols/snap: make timeout configurable

* eth/protocols/snap: snap sync testing

* eth/protocols/snap: test to trigger panic

* eth/protocols/snap: fix race condition on timeouts

* eth/protocols/snap: return error on cancelled sync

* squashme: updates + test causing panic + properly serve accounts in order

* eth/protocols/snap: revert failing storage response

* eth/protocols/snap: revert on bad responses (storage, code)

* eth/protocols/snap: fix account handling stall

* eth/protocols/snap: fix remaining revertal-issues

* eth/protocols/snap: timeouthandler for bytecode requests

* eth/protocols/snap: debugging + fix log message

* eth/protocols/snap: fix misspelliings in docs

* eth/protocols/snap: fix race in bytecode handling

* eth/protocols/snap: undo deduplication of storage roots

* synctests: refactor + minify panic testcase

* eth/protocols/snap: minor polishes

* eth: minor polishes to make logs more useful

* eth/protocols/snap: remove excessive logs from the test runs

* eth/protocols/snap: stress tests with concurrency

* eth/protocols/snap: further fixes to test cancel channel handling

* eth/protocols/snap: extend test timeouts on CI

Co-authored-by: Péter Szilágyi <[email protected]>

* go.mod: update dependencies (#22216)

This updates go module dependencies as discussed in #22050.

* graphql: change receipt status to decimal instead of hex (#22187)

This PR fixes the receipt status field to be decimal instead of a hex string,
as called for by the spec.

Co-authored-by: Martin Holst Swende <[email protected]>

* go.mod: upgrade github.com/huin/goupnp (#22227)

This updates the goupnp dependency, fixing huin/goupnp#33

* snapshot: merge loops for better performance (#22160)

* core: reset to genesis when middle block is missing (#22135)

When a sethead/rewind finds that the targeted block is missing, it resets to genesis instead of crashing. Closes #22129

* eth/tracers: move tracing APIs into eth/tracers (#22161)

This moves the tracing RPC API implementation to package eth/tracers.
By doing so, package eth no longer depends on tracing and the duktape JS engine.

The change also enables tracing using the light client. All tracing methods work with the
light client, but it's a lot slower compared to using a full node.

* eth, p2p: reserve half peer slots for snap peers during snap sync (#22171)

* eth, p2p: reserve half peer slots for snap peers during snap sync

* eth: less logging

* eth: rework the eth/snap peer reservation logic

* eth: rework the eth/snap peer reservation logic (again)

* tests/fuzzers/abi: fixed one-off panic with int.Min64 value (#22233)

* tests/fuzzers/abi: fixed one-off panic with int.Min64 value

* tests/fuzzers/abi: fixed one-off panic with int.Min64 value

* internal/ethapi: print tx details when submitting (#22170)

This adds more info about submitted transactions in log messages.

Co-authored-by: Felix Lange <[email protected]>

* core/state: fix panic in state dumping (#22225)

* core: speed up header import (#21967)

This PR implements the following modifications

- Don't shortcut check if block is present, thus avoid disk lookup
- Don't check hash ancestry in early-check (it's still done in parallel checker)
- Don't check time.Now for every single header

Charts and background info can be found here: https://github.com/holiman/headerimport/blob/main/README.md
With these changes, writing 1M headers goes down to from 80s to 62s.

* accounts/scwallet: use go-ethereum crypto instead of go-ecdh (#22212)

* accounts/scwallet: use go-ethereum crypto instead of go-ecdh

github.com/wsddn/go-ecdh is a wrapper package for ECDH functionality
with any elliptic curve.

Since 'generic' ECDH is not required in accounts/scwallet (the curve is
always secp256k1), we can just use the standard library functionality
and our own crypto libraries to perform ECDH and save a dependency.

* Update accounts/scwallet/securechannel.go

Co-authored-by: Guillaume Ballet <[email protected]>

* Use the correct key

Co-authored-by: Guillaume Ballet <[email protected]>

* accounts/scwallet: update documentation (#22242)

* les: switch to new discv5 (#21940)

This PR enables running the new discv5 protocol in both LES client
and server mode. In client mode it mixes discv5 and dnsdisc iterators
(if both are enabled) and filters incoming ENRs for "les" tag and fork ID.
The old p2p/discv5 package and all references to it are removed.

Co-authored-by: Felix Lange <[email protected]>

* rpc: deprecate Client.ShhSubscribe (#22239)

It never worked, whisper uses polling.

Co-authored-by: Felix Lange <[email protected]>

* cmd,core,eth,params,tests: define yolov3 + enable EIP-2565 (#22213)

Removes the yolov2 definition, adds yolov3, including EIP-2565. This PR also disables some of the erroneously generated blockchain and statetests, and adds the new genesis hash + alloc for yolov3. 
This PR disables the CLI switches for yolo, since it's not complete until we merge support for 2930.

* les/utils: UDP rate limiter (#21930)

* les/utils: Limiter

* les/utils: dropped prior weight vs variable cost logic, using fixed weights

* les/utils: always create node selector in addressGroup

* les/utils: renamed request weight to request cost

* les/utils: simplified and improved the DoS penalty mechanism

* les/utils: minor fixes

* les/utils: made selection weight calculation nicer

* les/utils: fixed linter warning

* les/utils: more precise and reliable probabilistic test

* les/utils: fixed linter warning

* cmd/clef: don't check file permissions on windows (#22251)

Fixes #20123

* eth/tracers: fix unigram tracer (#22248)

* eth: check snap satelliteness, delegate drop to eth (#22235)

* eth: check snap satelliteness, delegate drop to eth

* eth: better handle eth/snap satellite relation, merge reg/unreg paths

* cmd/geth, node: allow configuring JSON-RPC on custom path prefix (#22184)

This change allows users to set a custom path prefix on which to mount the http-rpc
or ws-rpc handlers via the new flags --http.rpcprefix and --ws.rpcprefix.

Fixes #21826

Co-authored-by: Felix Lange <[email protected]>

* all: remove unneeded parentheses (#21921)

* remove uneeded convertion type

* remove redundant type in composite literal

* omit explicit type where implicit

* remove unused redundant parenthesis

* remove redundant import alias duktape

* trie : use trie.NewStackTrie instead of new(trie.Trie) (#22246)

The PR makes use of the stacktrie, which is is more lenient on resource consumption, than the regular trie, in cases where we only need it for DeriveSha

* core: reset txpool state on sethead (#22247)

fixes an issue where local transactions that were included in the chain before a SetHead were rejected if resubmitted, since the txpool had not reset the state to the current (older) state.

* fuzzers: added consensys/gurvy library to bn256 differential fuzzer (#21812)

This pr adds consensys' gurvy bn256 variant into the code for differential fuzzing.

* internal/ethapi: comment nitpick (#22270)

* eth: move eth.Config to a common package (#22205)

This moves the eth config definition into a separate package, eth/ethconfig. 
Packages eth and les can now import this common package instead of
importing eth from les, reducing dependencies.

Co-authored-by: Felix Lange <[email protected]>

* internal/ethapi: fix typo in comment (#22271)

* eth: don't wait for snap registration if we're not running snap (#22272)

Prevents a situation where we (not running snap) connects with a peer running snap, and get stalled waiting for snap registration to succeed (which will never happen), which cause a waitgroup wait to halt shutdown

* consensus: remove seal verification from the consensus engine interface (#22274)

* cmd/utils: enable snapshots by default

* metrics: fix cast omission in cpu_syscall.go (#22262)

fixes an regression which caused build failure on certain platforms

* params: just to make snapshots a bit more official

* all: bloom-filter based pruning mechanism (#21724)

* cmd, core, tests: initial state pruner

core: fix db inspector

cmd/geth: add verify-state

cmd/geth: add verification tool

core/rawdb: implement flatdb

cmd, core: fix rebase

core/state: use new contract code layout

core/state/pruner: avoid deleting genesis state

cmd/geth: add helper function

core, cmd: fix extract genesis

core: minor fixes

contracts: remove useless

core/state/snapshot: plugin stacktrie

core: polish

core/state/snapshot: iterate storage concurrently

core/state/snapshot: fix iteration

core: add comments

core/state/snapshot: polish code

core/state: polish

core/state/snapshot: rebase

core/rawdb: add comments

core/rawdb: fix tests

core/rawdb: improve tests

core/state/snapshot: fix concurrent iteration

core/state: run pruning during the recovery

core, trie: implement martin's idea

core, eth: delete flatdb and polish pruner

trie: fix import

core/state/pruner: add log

core/state/pruner: fix issues

core/state/pruner: don't read back

core/state/pruner: fix contract code write

core/state/pruner: check root node presence

cmd, core: polish log

core/state: use HEAD-127 as the target

core/state/snapshot: improve tests

cmd/geth: fix verification tool

cmd/geth: use HEAD as the verification default target

all: replace the bloomfilter with martin's fork

cmd, core: polish code

core, cmd: forcibly delete state root

core/state/pruner: add hash64

core/state/pruner: fix blacklist

core/state: remove blacklist

cmd, core: delete trie clean cache before pruning

cmd, core: fix lint

cmd, core: fix rebase

core/state: fix the special case for clique networks

core/state/snapshot: remove useless code

core/state/pruner: capping the snapshot after pruning

cmd, core, eth: fixes

core/rawdb: update db inspector

cmd/geth: polish code

core/state/pruner: fsync bloom filter

cmd, core: print warning log

core/state/pruner: adjust the parameters for bloom filter

cmd, core: create the bloom filter by size

core: polish

core/state/pruner: sanitize invalid bloomfilter size

cmd: address comments

cmd/geth: address comments

cmd/geth: address comment

core/state/pruner: address comments

core/state/pruner: rename homedir to datadir

cmd, core: address comments

core/state/pruner: address comment

core/state: address comments

core, cmd, tests: address comments

core: address comments

core/state/pruner: release the iterator after each commit

core/state/pruner: improve pruner

cmd, core: adjust bloom paramters

core/state/pruner: fix lint

core/state/pruner: fix tests

core: fix rebase

core/state/pruner: remove atomic rename

core/state/pruner: address comments

all: run go mod tidy

core/state/pruner: avoid false-positive for the middle state roots

core/state/pruner: add checks for middle roots

cmd/geth: replace crit with error

* core/state/pruner: fix lint

* core: drop legacy bloom filter

* core/state/snapshot: improve pruner

* core/state/snapshot: polish concurrent logs to report ETA vs. hashes

* core/state/pruner: add progress report for pruning and compaction too

* core: fix snapshot test API

* core/state: fix some pruning logs

* core/state/pruner: support recovering from bloom flush fail

Co-authored-by: Péter Szilágyi <[email protected]>

* core/state/pruner: fix compaction after pruning

* core/state/pruner: fix compaction range error

* internal/debug: add switch to format logs with json (#22207)

adds a flag --log.json which if enabled makes the client format logs with JSON.

* accounts/abi/bind: fixed unpacking error (#22230)

There was a dormant error with structured inputs that failed unpacking.
This commit fixes the error by switching casting to the better abi.ConvertType function.
It also adds a test for calling a view function that returns a struct

* cmd/utils, eth/ethconfig: unindex txs older than ~1 year

* cmd/devp2p: fix documentation for eth-test (#22298)

* core: fix temp memory blowup caused by defers holding on to state

* les: enable les/4 and add tests (#22321)

* cmd/utils: add workaround for FreeBSD statfs quirk (#22310)

Make geth build on FreeBSD, fixes #22309.

* cmd/geth: fix js unclean shutdown (#22302)

* trie: fix bloom crash on fast sync restart

* rpc: increase the number of subscriptions in storm test (#22316)

* core/state/snapshot: ensure Cap retains a min number of layers

* eth: fix snap sync cancellation

* cmd/devp2p/internal/ethtest: use shared message types (#22315)

This updates the eth protocol test suite to use the message type
definitions of the 'production' protocol implementation in eth/protocols/eth.

* eth/handler, broadcast: optimize tx broadcast mechanism (#22176)

This PR optimizes the broadcast loop. Instead of iterating twice through a given set of transactions to weed out which peers have and which do not have a tx, to send/announce transactions, we do it only once.

* core/state: copy the snap when copying the state (#22340)

* core/state: copy the snap when copying the state

* core/state: deep-copy snap stuff during state Copy

* rlp: handle case of normal EOF in Stream.readFull (#22336)

io.Reader may return n > 0 and io.EOF at the end of the input stream.
readFull did not handle this correctly, looking only at the error. This fixes
it to check for n == len(buf) as well.

* node: always show websocket url in logs (#22307)

* eth: implement eth66 (#22241)

* eth/protocols/eth: split up the eth protocol handlers

* eth/protocols/eth: define eth-66 protocol messages

* eth/protocols/eth: poc implement getblockheaders on eth/66

* eth/protocols/eth: implement remaining eth-66 handlers

* eth/protocols: define handler map for eth 66

* eth/downloader: use protocol constants from eth package

* eth/protocols/eth: add ETH66 capability

* eth/downloader: tests for eth66

* eth/downloader: fix error in tests

* eth/protocols/eth: use eth66 for outgoing requests

* eth/protocols/eth: remove unused error type

* eth/protocols/eth: define protocol length

* eth/protocols/eth: fix pooled tx over eth66

* protocols/eth/handlers: revert behavioural change which caused tests to fail

* eth/downloader: fix failing test

* eth/protocols/eth: add testcases + fix flaw with header requests

* eth/protocols: change comments

* eth/protocols/eth: review fixes + fixed flaw in RequestOneHeader

* eth/protocols: documentation

* eth/protocols/eth: review concerns about types

* p2p/dnsdisc: fix hot-spin when all trees are empty (#22313)

In the random sync algorithm used by the DNS node iterator, we first pick a random
tree and then perform one sync action on that tree. This happens in a loop until any
node is found. If no trees contain any nodes, the iterator will enter a hot loop spinning
at 100% CPU.

The fix is complicated. The iterator now checks if a meaningful sync action can
be performed on any tree. If there is nothing to do, it waits for the next root record
recheck time to arrive and then tries again.

Fixes #22306

* les: renamed lespay to vflux (#22347)

* cmd/utils: disable caching preimages by default

* travis, appveyor, build: bump Go to 1.16

* les: fix balance expiration (#22343)

* les/lespay/server: fix balance expiration and add test

* les: move client balances to a new db

* les: rename lespayDb to lesDb

* tests/fuzzers/les: add fuzzer for les server handler (#22282)

* les: refactored server handler

* tests/fuzzers/les: add fuzzer for les server handler

* tests, les: update les fuzzer

tests: update les fuzzer

tests/fuzzer/les: release resources

tests/fuzzer/les: pre-initialize all resources

* les: refactored server handler and fuzzer

Co-authored-by: rjl493456442 <[email protected]>

* les: clean up server handler (#22357)

* cmd/geth: add db commands stats, compact, put, get, delete (#22014)

This PR introduces:

- db.put to put a value into the database
- db.get to read a value from the database
- db.delete to delete a value from the database
- db.stats to check compaction info from the database
- db.compact to trigger a db compaction

It also moves inspectdb to db.inspect.

* internal/ethapi: reject non-replay-protected txs over RPC (#22339)

This PR prevents users from submitting transactions without EIP-155 enabled. This behaviour can be overridden by specifying the flag --rpc.allow-unprotected-txs=true.

* accounts/abi/bind: fix up Go mod files for Go 1.16

* Dockerfile: bump to Go 1.16 base images

* travis: bump Android NDK version

* travis: bump builders to Bionic

* travis: manually install Android since Travis is stale (#22373)

* cmd/utils: remove deprecated command line flags (#22263)

This removes support for all deprecated flags except --rpc*.

* eth/protocols/snap: lower abortion and resumption logs to debug

* cmd, eth, les: enable serving light clients when non-synced (#22250)

This PR adds a more CLI flag, so that the les-server can serve light clients even the local node is not synced yet.

This functionality is needed in some testing environments(e.g. hive). After launching the les server, no more blocks will be imported so the node is always marked as "non-synced".

* les, light: improve txstatus retrieval (#22349)

Transaction unindexing will be enabled by default as of 1.10, which causes tx status retrieval will be broken without this PR. 

This PR introduces a retry mechanism in TxStatus retrieval.

* all: add support for EIP-2718, EIP-2930 transactions (#21502)

This adds support for EIP-2718 typed transactions as well as EIP-2930
access list transactions (tx type 1). These EIPs are scheduled for the
Berlin fork.

There very few changes to existing APIs in core/types, and several new APIs
to deal with access list transactions. In particular, there are two new
constructor functions for transactions: types.NewTx and types.SignNewTx.
Since the canonical encoding of typed transactions is not RLP-compatible,
Transaction now has new methods for encoding and decoding: MarshalBinary
and UnmarshalBinary.

The existing EIP-155 signer does not support the new transaction types.
All code dealing with transaction signatures should be updated to use the
newer EIP-2930 signer. To make this easier for future updates, we have
added new constructor functions for types.Signer: types.LatestSigner and
types.LatestSignerForChainID. 

This change also adds support for the YoloV3 testnet.

Co-authored-by: Martin Holst Swende <[email protected]>
Co-authored-by: Felix Lange <[email protected]>
Co-authored-by: Ryan Schneider <[email protected]>

* cmd/devp2p: add eth66 test suite (#22363)

Co-authored-by: Martin Holst Swende <[email protected]>

* les: move server pool to les/vflux/client (#22377)

* les: move serverPool to les/vflux/client

* les: add metrics

* les: moved ValueTracker inside ServerPool

* les: protect against node registration before server pool is started

* les/vflux/client: fixed tests

* les: make peer registration safe

* all: define Berlin hard fork spec

* rpc: add separate size limit for websocket (#22385)

This makes the WebSocket message size limit independent of the
limit used for HTTP requests. The new limit for WebSocket messages 
is 15MB.

* accounts/keystore: use github.com/google/uuid (#22217)

This replaces the github.com/pborman/uuid dependency with
github.com/google/uuid because the former is only a wrapper for
the latter (since v1.0.0).

Co-authored-by: Felix Lange <[email protected]>

* core/state: fix eta calculation on pruning (#22386)

* les: UDP pre-negotiation of available server capacity (#22183)

This PR implements the first one of the "lespay" UDP queries which
is already useful in itself: the capacity query. The server pool is making
use of this query by doing a cheap UDP query to determine whether it is
worth starting the more expensive TCP connection process.

* core/rawdb: fix the transaction indexer (#22395)

* cmd/geth: put allowUnsecureTx flag in RPC section (#22412)

* params: update chts (#22418)

* cmd/utils: fix txlookuplimit for archive node (#22419)

* cmd/utils: fix exclusive check for archive node

* cmd/utils: set the txlookuplimit to 0

* core/forkid, params: unset Berlin fork number (#22413)

* les: fix nodiscover option on the client side (#22422)

* cmd: retire whisper flags (#22421)

* cmd: retire whisper flags

* cmd/geth: remove whisper configs

* tests: update to latest tests (#22290)

This updates the consensus tests to commit 31d6630 and
adds support for access list transactions in the test runner.

Co-authored-by: Martin Holst Swende <[email protected]>

* params: release geth 1.10.0 stable

* Update after the tracers factoring and solve some linting

* fix all the linting issues

* fix graphql test

* fix wallet test

* fix cmd package test

* fix internal package test

* fix internal package test

* fix accounts and contracts package test

* fix light package test

* fix some unit tests and changes on the state_prefetcher.go

* fix core unit test

* fix unit test

* faucet: do not replace normal url to mobile version

* faucet: revert change

* eth: added UT for transaction propagation

* internal/eth: fixed merging side effect

* accounts: copy signer

* Added Quorum tag for the UT

* fix: add some fixes and UT (#3)

* faucet: revert change

* eth: added UT for transaction propagation

* internal/eth: fixed merging side effect

* accounts: copy signer

* Added Quorum tag for the UT

* fix: eth/handler.go accept tx for raft consensus

* fix: internal/ethapi add check for accessList if its nil

* add eth66 protocol to consensus

* fix: broadcaster

* revert: logs

* disable flakey facebook test

* fix: eth/api_backend.go use the modified GetReceipts to get the private receipts for PSI

* fix: eth/traces fix the tracer to ignore the tx that the party is not part of

* fix: raft/snapshot remove the trimming of the peer ID

* Accept chainId on permissioning endpoints

* fix: force preimages for making complete dumps
preimages is disabled by default by geth 1.10, but needed for contract extension

* Specify chainId against permision contracts

* Specify chainId with NewWalletTransactor

* Remove chainId from NewWalletTransactor

* Pass chainId through to NewWalletTransactor from config

* fix lint

* fix unit tests

* fix lint

* Upgrade protobuf to 1.5.1

* remove commented code

* added few error checks and some code cleaning

* added few error checks and some code cleaning

* fix conflict merge

* fix linter

* Prevent prune-state from being used when IsQuorum is enabled

Signed-off-by: Antony Denyer <[email protected]>

* Remove date for deprecation notice, made more generic

* fix: miner/worker.go mix-up when resolving conflicts about miner sleeping

Co-authored-by: Martin Holst Swende <[email protected]>
Co-authored-by: Mr-Leshiy <[email protected]>
Co-authored-by: Nagy Salem <[email protected]>
Co-authored-by: Connor Stein <[email protected]>
Co-authored-by: Shiming <[email protected]>
Co-authored-by: ligi <[email protected]>
Co-authored-by: Péter Szilágyi <[email protected]>
Co-authored-by: Marius van der Wijden <[email protected]>
Co-authored-by: Mr-Leshiy <[email protected]>
Co-authored-by: Felföldi Zsolt <[email protected]>
Co-authored-by: ucwong <[email protected]>
Co-authored-by: Timo Tijhof <[email protected]>
Co-authored-by: Sina Mahmoodi <[email protected]>
Co-authored-by: Guillaume Ballet <[email protected]>
Co-authored-by: Suriyaa Sundararuban <[email protected]>
Co-authored-by: jk-jeongkyun <[email protected]>
Co-authored-by: yumiel yoomee1313 <[email protected]>
Co-authored-by: Melvin Junhee Woo <[email protected]>
Co-authored-by: Vie <[email protected]>
Co-authored-by: rene <[email protected]>
Co-authored-by: Felix Lange <[email protected]>
Co-authored-by: Antoine Toulme <[email protected]>
Co-authored-by: gary rong <[email protected]>
Co-authored-by: Chris Ziogas <[email protected]>
Co-authored-by: meowsbits <[email protected]>
Co-authored-by: Dan DeGreef <[email protected]>
Co-authored-by: Alex Mazalov <[email protected]>
Co-authored-by: Łukasz Zimnoch <[email protected]>
Co-authored-by: Alex Prut <[email protected]>
Co-authored-by: isdyaufh8o7cq <[email protected]>
Co-authored-by: Or Neeman <[email protected]>
Co-authored-by: lightclient <[email protected]>
Co-authored-by: Ryan Schneider <[email protected]>
Co-authored-by: achraf <[email protected]>
Co-authored-by: achraf17 <[email protected]>
Co-authored-by: Baptiste Boussemart <[email protected]>
Co-authored-by: Antony Denyer <[email protected]>
Co-authored-by: baptiste-b-pegasys <[email protected]>
Co-authored-by: Antony Denyer <[email protected]>
  • Loading branch information
Show file tree
Hide file tree
Showing 430 changed files with 27,755 additions and 15,807 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ and help.

## Configuration, dependencies, and tests

Please see the [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide)
Please see the [Developers' Guide](https://geth.ethereum.org/docs/developers/devguide)
for more details on configuring your environment, managing project dependencies
and testing procedures.

Expand Down
30 changes: 0 additions & 30 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -1,30 +0,0 @@
---
name: Report a bug
about: Something with go-ethereum is not working as expected
title: ''
labels: 'type:bug'
assignees: ''
---

#### System information

Geth version: `geth version`

OS & Version: Windows/Linux/OSX

Branch, Commit Hash or Release: `git status`

#### Expected behaviour


#### Actual behaviour


#### Steps to reproduce the behaviour


#### Backtrace

````
[backtrace]
````
67 changes: 33 additions & 34 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
allow_failures:
- stage: build
os: osx
go: 1.14.x
go: 1.15.x
env:
- azure-osx
- azure-ios
Expand All @@ -15,8 +15,8 @@ jobs:
# This builder only tests code linters on latest version of Go
- stage: lint
os: linux
dist: xenial
go: 1.15.x
dist: bionic
go: 1.16.x
env:
- lint
git:
Expand All @@ -28,8 +28,8 @@ jobs:
- stage: build
if: type = push
os: linux
dist: xenial
go: 1.15.x
dist: bionic
go: 1.16.x
env:
- ubuntu-ppa
- GO111MODULE=on
Expand All @@ -52,9 +52,9 @@ jobs:
- stage: build
if: type = push
os: linux
dist: xenial
dist: bionic
sudo: required
go: 1.15.x
go: 1.16.x
env:
- azure-linux
- GO111MODULE=on
Expand Down Expand Up @@ -88,10 +88,10 @@ jobs:
- stage: build
if: type = push
os: linux
dist: xenial
dist: bionic
services:
- docker
go: 1.15.x
go: 1.16.x
env:
- azure-linux-mips
- GO111MODULE=on
Expand All @@ -118,37 +118,36 @@ jobs:
- stage: build
if: type = push
os: linux
dist: xenial
dist: bionic
addons:
apt:
packages:
- oracle-java8-installer
- oracle-java8-set-default
language: android
android:
components:
- platform-tools
- tools
- android-15
- android-19
- android-24
- openjdk-8-jdk
env:
- azure-android
- maven-android
- GO111MODULE=on
git:
submodules: false # avoid cloning ethereum/tests
before_install:
- curl https://dl.google.com/go/go1.15.5.linux-amd64.tar.gz | tar -xz
# Install Android and it's dependencies manually, Travis is stale
- export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
- curl https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip -o android.zip
- unzip -q android.zip -d $HOME/sdk && rm android.zip
- mv $HOME/sdk/cmdline-tools $HOME/sdk/latest && mkdir $HOME/sdk/cmdline-tools && mv $HOME/sdk/latest $HOME/sdk/cmdline-tools
- export PATH=$PATH:$HOME/sdk/cmdline-tools/latest/bin
- export ANDROID_HOME=$HOME/sdk

- yes | sdkmanager --licenses >/dev/null
- sdkmanager "platform-tools" "platforms;android-15" "platforms;android-19" "platforms;android-24" "ndk-bundle"

# Install Go to allow building with
- curl https://dl.google.com/go/go1.16.linux-amd64.tar.gz | tar -xz
- export PATH=`pwd`/go/bin:$PATH
- export GOROOT=`pwd`/go
- export GOPATH=$HOME/go
script:
# Build the Android archive and upload it to Maven Central and Azure
- curl https://dl.google.com/android/repository/android-ndk-r19b-linux-x86_64.zip -o android-ndk-r19b.zip
- unzip -q android-ndk-r19b.zip && rm android-ndk-r19b.zip
- mv android-ndk-r19b $ANDROID_HOME/ndk-bundle

- mkdir -p $GOPATH/src/github.com/ethereum
- ln -s `pwd` $GOPATH/src/github.com/ethereum/go-ethereum
- go run build/ci.go aar -signer ANDROID_SIGNING_KEY -signify SIGNIFY_KEY -deploy https://oss.sonatype.org -upload gethstore/builds
Expand All @@ -157,7 +156,7 @@ jobs:
- stage: build
if: type = push
os: osx
go: 1.15.x
go: 1.16.x
env:
- azure-osx
- azure-ios
Expand Down Expand Up @@ -188,8 +187,8 @@ jobs:
- stage: build
os: linux
arch: amd64
dist: xenial
go: 1.15.x
dist: bionic
go: 1.16.x
env:
- GO111MODULE=on
script:
Expand All @@ -199,17 +198,17 @@ jobs:
if: type = pull_request
os: linux
arch: arm64
dist: xenial
go: 1.15.x
dist: bionic
go: 1.16.x
env:
- GO111MODULE=on
script:
- go run build/ci.go test -coverage $TEST_PACKAGES

- stage: build
os: linux
dist: xenial
go: 1.14.x
dist: bionic
go: 1.15.x
env:
- GO111MODULE=on
script:
Expand All @@ -219,8 +218,8 @@ jobs:
- stage: build
if: type = cron
os: linux
dist: xenial
go: 1.15.x
dist: bionic
go: 1.16.x
env:
- azure-purge
- GO111MODULE=on
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build Geth in a stock Go builder container
FROM golang:1.15.6-alpine as builder
FROM golang:1.16-alpine as builder

RUN apk add --no-cache make gcc musl-dev linux-headers git

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.alltools
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build Geth in a stock Go builder container
FROM golang:1.15-alpine as builder
FROM golang:1.16-alpine as builder

RUN apk add --no-cache make gcc musl-dev linux-headers git

Expand Down
10 changes: 4 additions & 6 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,29 @@

## Supported Versions

Please see Releases. We recommend to use the most recent released version.
Please see [Releases](https://github.com/ethereum/go-ethereum/releases). We recommend using the [most recently released version](https://github.com/ethereum/go-ethereum/releases/latest).

## Audit reports

Audit reports are published in the `docs` folder: https://github.com/ethereum/go-ethereum/tree/master/docs/audits


| Scope | Date | Report Link |
| ------- | ------- | ----------- |
| `geth` | 20170425 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2017-04-25_Geth-audit_Truesec.pdf) |
| `clef` | 20180914 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2018-09-14_Clef-audit_NCC.pdf) |



## Reporting a Vulnerability

**Please do not file a public ticket** mentioning the vulnerability.

To find out how to disclose a vulnerability in Ethereum visit [https://bounty.ethereum.org](https://bounty.ethereum.org) or email [email protected].
To find out how to disclose a vulnerability in Ethereum visit [https://bounty.ethereum.org](https://bounty.ethereum.org) or email [email protected]. Please read the [disclosure page](https://github.com/ethereum/go-ethereum/security/advisories?state=published) for more information about publically disclosed security vulnerabilities.

Use the built-in `geth version-check` feature to check whether the software is affected by any known vulnerability. This command will fetch the latest [`vulnerabilities.json`](https://geth.ethereum.org/docs/vulnerabilities/vulnerabilities.json) file which contains known security vulnerabilities concerning `geth`, and cross-check the data against its own version number.

The following key may be used to communicate sensitive information to developers.

Fingerprint: `AE96 ED96 9E47 9B00 84F3 E17F E88D 3334 FA5F 6A0A`


```
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
Expand Down
3 changes: 3 additions & 0 deletions accounts/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const jsondata = `
{ "type" : "function", "name" : "uint64[2]", "inputs" : [ { "name" : "inputs", "type" : "uint64[2]" } ] },
{ "type" : "function", "name" : "uint64[]", "inputs" : [ { "name" : "inputs", "type" : "uint64[]" } ] },
{ "type" : "function", "name" : "int8", "inputs" : [ { "name" : "inputs", "type" : "int8" } ] },
{ "type" : "function", "name" : "bytes32", "inputs" : [ { "name" : "inputs", "type" : "bytes32" } ] },
{ "type" : "function", "name" : "foo", "inputs" : [ { "name" : "inputs", "type" : "uint32" } ] },
{ "type" : "function", "name" : "bar", "inputs" : [ { "name" : "inputs", "type" : "uint32" }, { "name" : "string", "type" : "uint16" } ] },
{ "type" : "function", "name" : "slice", "inputs" : [ { "name" : "inputs", "type" : "uint32[2]" } ] },
Expand All @@ -68,6 +69,7 @@ var (
String, _ = NewType("string", "", nil)
Bool, _ = NewType("bool", "", nil)
Bytes, _ = NewType("bytes", "", nil)
Bytes32, _ = NewType("bytes32", "", nil)
Address, _ = NewType("address", "", nil)
Uint64Arr, _ = NewType("uint64[]", "", nil)
AddressArr, _ = NewType("address[]", "", nil)
Expand Down Expand Up @@ -98,6 +100,7 @@ var methods = map[string]Method{
"uint64[]": NewMethod("uint64[]", "uint64[]", Function, "", false, false, []Argument{{"inputs", Uint64Arr, false}}, nil),
"uint64[2]": NewMethod("uint64[2]", "uint64[2]", Function, "", false, false, []Argument{{"inputs", Uint64Arr2, false}}, nil),
"int8": NewMethod("int8", "int8", Function, "", false, false, []Argument{{"inputs", Int8, false}}, nil),
"bytes32": NewMethod("bytes32", "bytes32", Function, "", false, false, []Argument{{"inputs", Bytes32, false}}, nil),
"foo": NewMethod("foo", "foo", Function, "", false, false, []Argument{{"inputs", Uint32, false}}, nil),
"bar": NewMethod("bar", "bar", Function, "", false, false, []Argument{{"inputs", Uint32, false}, {"string", Uint16, false}}, nil),
"slice": NewMethod("slice", "slice", Function, "", false, false, []Argument{{"inputs", Uint32Arr2, false}}, nil),
Expand Down
23 changes: 15 additions & 8 deletions accounts/abi/bind/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"io"
"io/ioutil"
"math/big"
"reflect"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/external"
Expand Down Expand Up @@ -132,15 +133,16 @@ func NewKeyStoreTransactorWithChainID(keystore *keystore.KeyStore, account accou
if chainID == nil {
return nil, ErrNoChainID
}
var eipo155Signer types.Signer = types.NewEIP155Signer(chainID)
latestSigner := types.LatestSignerForChainID(chainID)
log.Info("NewKeyStoreTransactorWithChainID", "latestSigner", reflect.TypeOf(latestSigner))
return &TransactOpts{
From: account.Address,
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
if address != account.Address {
return nil, ErrNotAuthorized
}
// Quorum
signer := eipo155Signer
signer := latestSigner
if tx.IsPrivate() {
signer = types.QuorumPrivateTxSigner{}
}
Expand All @@ -161,15 +163,15 @@ func NewKeyedTransactorWithChainID(key *ecdsa.PrivateKey, chainID *big.Int) (*Tr
if chainID == nil {
return nil, ErrNoChainID
}
var eipo155Signer types.Signer = types.NewEIP155Signer(chainID)
latestSigner := types.LatestSignerForChainID(chainID)
return &TransactOpts{
From: keyAddr,
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
if address != keyAddr {
return nil, ErrNotAuthorized
}
// Quorum
signer := eipo155Signer
signer := latestSigner
if tx.IsPrivate() {
signer = types.QuorumPrivateTxSigner{}
}
Expand All @@ -192,7 +194,8 @@ func NewClefTransactor(clef *external.ExternalSigner, account accounts.Account)
if address != account.Address {
return nil, ErrNotAuthorized
}
return clef.SignTx(account, transaction, nil) // Clef enforces its own chain id
log.Info("Signing with NewClefTransactor")
return clef.SignTx(account, transaction, transaction.ChainId()) // Clef enforces its own chain id
},
}
}
Expand All @@ -201,14 +204,18 @@ func NewClefTransactor(clef *external.ExternalSigner, account accounts.Account)
//
// NewWalletTransactor is a utility method to easily create a transaction signer
// from a wallet account
func NewWalletTransactor(w accounts.Wallet, account accounts.Account) *TransactOpts {
func NewWalletTransactor(w accounts.Wallet, account accounts.Account, chainId *big.Int) *TransactOpts {
return &TransactOpts{
From: account.Address,
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
Signer: func(address common.Address, transaction *types.Transaction) (*types.Transaction, error) {
if address != account.Address {
return nil, errors.New("not authorized to sign this account")
}
return w.SignTx(account, tx, nil) // homestead signer without chainID is backward compatible
if transaction.ChainId() == nil {
chainId = transaction.ChainId()
}

return w.SignTx(account, transaction, chainId)
},
}
}
Loading

0 comments on commit d258a13

Please sign in to comment.