Most places that used this method were cutting off the 1st byte.
Refactor this idea to a common place.
* better naming: MarshalPubkey matches existing UnmarshalPubkey
* "Std" suffix for the ANSI standard encoding without cut off
* docs
Problem:
QuerySeeds will poke 150 random entries in the whole node DB and ignore hitting "field" entries.
In a bootstrap scenario it might hit hundreds of :lastping :lastpong entries,
and very few true "node record" entries.
After running for 15 minutes I've got totalEntryCount=1508 nodeRecordCount=114 entries.
There's a 1/16 chance of hitting a "node record" entry.
It means finding just about 10 nodes of 114 total on average from 150 attempts.
Solution:
Split "node record" entries to a separate table such that QuerySeeds doesn't do idle cycle hits.
UpdateFindFails/UpdateLastPingReceived/UpdateLastPongReceived events
are causing bursty DB commits (100 per minute).
This optimization throttles the disk writes to happen at most once in a few seconds,
because this info doesn't need to be persisted immediately.
This helps on HDD drives.
Encode and hash logic was duplicated in multiple places.
* Move encoding to p2p/discover/v4wire
* Move hashing to p2p/enode/idscheme
* Change newRandomLookup to create a proper random key on a curve.
If --nat extip:1.2.3.4 option is specified, the port mapping logic
(AddMapping/DeleteMapping) does nothing.
This optimization avoids running a goroutine for doing nothing.
Extract private key setup from the global config setup to make it reusable.
Return errors instead of panicing.
* NodeKey() method is removed - it is unused.
* use "log" for struct fields
* use "logger" for function parameters and local vars
This is a compromise between:
1) using logger := log.New() to avoid aliasing (log := log.New())
2) and keeping it short when logging e.g.: srv.log.Info(...)
* migrated consensus and chain config files for bsc support
* migrated more files from bsc
* fixed consensus crashing
* updated erigon lib for parlia snapshot prefix
* added staticpeers for bsc
* [+] added system contracts
[*] fixed bug with loading snapshot
[+] enabled gas bailout
[+] added fix to prevent syncing more than 1000 headers (for testing only)
[*] fixed bug with crashing sender recover sometimes
* migrated system contract calls
* [*] fixed bug with returning mutable balance object
[+] migrated lightclient contracts from bsc
[*] fixed parlia consensus config param
* [*] fixed tendermint deps
* [+] added some logs
* [+] enabled bsc forks
[*] fixed syscalls from coinbase
[*] more logging
* Fix call sys contract gas calculation
* [*] fixed executing system transactions
* [*] enabled receipt hash, gas and bloom filter checks
* [-] removed some logging scripts
[*] set header checkpoint to 10 million blocks (for testing forks)
* [*] fixed bug with commiting dirty inter block state state after system transaction execution
[-] removed some extra logs and comments
* [+] added chapel and rialto testnet support
* [*] fixed chapel allocs
* [-] removed 6 mil block limit for headers sync
* Fix hardforks on chapel and other testnets
* [*] fixed header sync issue after merge
* [*] tiny code cleanup
* [-] removed some comments
* [*] increased mdbx map size to 4 TB
* [*] increased max chaindata size to 6 tb
* [*] bring more compatibility with origin erigon and some code cleanup
* [+] added support of validator mode for BSC chain
* [*] enable private key load for bsc, rialto and chapel chains
* [*] fixed running BSC validator node
* Fix the branch list
* [*] tiny fixes for linter
* [*] formatted imports for core and parlia packages
* [*] fixed import rules in other files
* Revert "[*] formatted imports for core and parlia packages"
This reverts commit c764b58b34fedc2b14d69458583ba0dad114f227.
* [*] changed import rules in more packages
* [*] fixed type mismatch in hack command
* [*] fixed crash on new epoch, enabled bootstrap flags
* [*] fixed linter errors
* [*] fixed missing err check for syscalls
* [*] now BSC implementation is fully compatible with erigon original sources
* Revert "Add chain config and CLI changes for Binance Smart Chain support (#3131)"
This reverts commit 3d048b7f1a.
* Revert "Add Parlia consensus engine for Binance Smart Chain support (#3086)"
This reverts commit ee99f17fbe.
* [*] fixed several issues after merge
* [*] fixed integration compilation
* Revert "Fix the branch list"
This reverts commit 8150ca57e5f2707a84a9f6a1c5b809b7cc84547b.
* [-] removed receipt repair migration
* [*] fixed parlia fork numbers output
* [*] bring more devel compatibility, fixed bsc address list for access list calculation
* [*] fixed bug with commiting state transition for bad blocks in BSC
* [*] fixed bsc changes apply for integration command and updated config print for parlia
* [*] fixed bug with applying bsc forks for chapel and rialto testnet chains
[*] let's use finalize and assemble for mining to let consensus know for what it's finalizing block
* Fix compilation errors in hack.go
* Fix lint
* reset changes in erigon-snapshots to devel
* Remove unrelated changes
* Fix embed
* Remove more unrelated changes
* Remove more unrelated changes
* Restore clique and aura miner config
* Refactor interfaces not to use slice pointers
* Refactor parlia functions to return tx and receipt instead of dealing with slices
* Fix for header panic
* Fix lint, restore system contract addresses
* Remove more unrelated changes, unify GatherForks
Co-authored-by: Dmitry Ivanov <convexman18@gmail.com>
Co-authored-by: j75689 <j75689@gmail.com>
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* Prevent frequent commits to the node DB in sentries
* Commit when btree goes over limit
* iterator for SeedQuery
* Fixing test
* Fix tests
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
* implemented crash reporting for all goroutine panics that aren't handled explicitly
* implemented crash reporting for all goroutine panics that aren't handled explicitly
* changed node defaults back to originals after testing
* implemented panic handling for all goroutines that don't explicitly handle them, outputting the stack trace to a file in crashreports
* handling panics on all goroutines gracefully
* updated missing call
* error assignment
* implemented suggestions
* path.Join added
* implemented Evgeny's suggestions
* changed path.Join to filepath.Join for cross-platform
* added err check
* updated RecoverStackTrace to LogPanic
* updated closures
* removed call of common.Go to some goroutines
* updated scope capture
* removed testing files
* reverted back to original method, I feel like its less intrusive
* update filename for clarity
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.
# Conflicts:
# les/client.go
# les/clientpool.go
# les/clientpool_test.go
# les/enr_entry.go
# les/server.go
# les/vflux/client/serverpool.go
# les/vflux/client/serverpool_test.go
# les/vflux/server/balance.go
# les/vflux/server/balance_test.go
# les/vflux/server/prioritypool.go
# les/vflux/server/prioritypool_test.go
# p2p/nodestate/nodestate.go
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
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
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 <fjl@twurst.com>
# Conflicts:
# cmd/bootnode/main.go
# cmd/faucet/faucet.go
# cmd/utils/flags.go
# les/client.go
# les/commons.go
# les/enr_entry.go
# les/server.go
# les/serverpool.go
# les/serverpool_test.go
# mobile/discover.go
# mobile/params.go
# p2p/discv5/database.go
# p2p/discv5/metrics.go
# p2p/discv5/net.go
# p2p/discv5/net_test.go
# p2p/discv5/node.go
# p2p/discv5/node_test.go
# p2p/discv5/sim_test.go
# p2p/discv5/table.go
# p2p/discv5/table_test.go
# p2p/discv5/ticket.go
# p2p/discv5/topic.go
# p2p/discv5/topic_test.go
# p2p/discv5/udp.go
# p2p/server.go
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'.
# Conflicts:
# cmd/geth/accountcmd_test.go
# cmd/geth/consolecmd_test.go
# cmd/geth/dao_test.go
# cmd/geth/genesis_test.go
# cmd/geth/les_test.go
The database panicked for invalid IPs. This is usually no problem
because all code paths leading to node DB access verify the IP, but it's
dangerous because improper validation can turn this panic into a DoS
vulnerability. The quick fix here is to just turn database accesses
using invalid IP into a noop. This isn't great, but I'm planning to
remove the node DB for discv5 long-term, so it should be fine to have
this quick fix for half a year.
Fixes#21849
This fixes a deadlock that could occur when a response packet arrived
after a call had already received enough responses and was about to
signal completion to the dispatch loop.
Co-authored-by: Felix Lange <fjl@twurst.com>
Changes:
Simplify nested complexity
If an if blocks ends with a return statement then remove the else nesting.
Most of the changes has also been reported in golint https://goreportcard.com/report/github.com/ethereum/go-ethereum#golint
# Conflicts:
# cmd/utils/flags.go
# console/bridge.go
# crypto/bls12381/g2.go
# les/benchmark.go
# les/lespay/server/balance.go
# les/lespay/server/balance_tracker.go
# les/lespay/server/prioritypool.go
# les/odr_requests.go
# les/serverpool.go
# les/serverpool_test.go
# p2p/nodestate/nodestate_test.go
# trie/committer.go
- Remove the ws:// prefix from the status endpoint since
the ws:// is already included in the stack.WSEndpoint().
- Don't register the services again in the node start.
Registration is already done in the initialization stage.
- Expose admin namespace via websocket.
This namespace is necessary for connecting the peers via websocket.
- Offer logging relevant options for exec adapter.
It's really painful to mix all log output in the single console. So
this PR offers two additional options for exec adapter in this case
testers can config the log output(e.g. file output) and log level
for each p2p node.
This adds a few tiny fixes for les and the p2p simulation framework:
LES Parts
- Keep the LES-SERVER connection even it's non-synced
We had this idea to reject the connections in LES protocol if the les-server itself is
not synced. However, in LES protocol we will also receive the connection from another
les-server. In this case even the local node is not synced yet, we should keep the tcp
connection for other protocols(e.g. eth protocol).
- Don't count "invalid message" for non-existing GetBlockHeadersMsg request
In the eth syncing mechanism (full sync, fast sync, light sync), it will try to fetch
some non-existent blocks or headers(to ensure we indeed download all the missing chain).
In this case, it's possible that the les-server will receive the request for
non-existent headers. So don't count it as the "invalid message" for scheduling
dropping.
- Copy the announce object in the closure
Before the les-server pushes the latest headers to all connected clients, it will create
a closure and queue it in the underlying request scheduler. In some scenarios it's
problematic. E.g, in private networks, the block can be mined very fast. So before the
first closure is executed, we may already update the latest_announce object. So actually
the "announce" object we want to send is replaced.
The downsize is the client will receive two announces with the same td and then drop the
server.
P2P Simulation Framework
- Don't double register the protocol services in p2p-simulation "Start".
The protocols upon the devp2p are registered in the "New node stage". So don't reigster
them again when starting a node in the p2p simulation framework
- Add one more new config field "ExternalSigner", in order to use clef service in the
framework.
# Conflicts:
# les/server_handler.go
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* change_set_dup
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* working version
* aa
* aa
* aa
* aa
* aa
* aa
* aa
* aa
* aa
* aa
* aa
* aa
* aa
* aa
* aa
* squash
* squash
* fix
* fix
* fix
* fix
* fix
* fix
* fix
* fix
* fix
* fix
* fix
* history_early_stop
* history_early_stop
* vmConfig with ReadOnly false
* auto_increment
* auto_increment
* rebase master
Co-authored-by: Alexey Akhunov <akhounov@gmail.com>
This change implements the Discovery v5.1 wire protocol and
also adds an interactive test suite for this protocol.
# Conflicts:
# cmd/devp2p/discv5cmd.go
# p2p/discover/v5_encoding.go
# p2p/discover/v5_encoding_test.go
# p2p/discover/v5_udp.go
# p2p/discover/v5_udp_test.go
# p2p/discover/v5wire/session.go
* peer: return localAddr instead of name to prevent spam
We currently use the name (which can be freely set by the peer) in several log messages.
This enables malicious actors to write spam into your geth log.
This commit returns the localAddr instead of the freely settable name.
* p2p: reduce usage of peer.Name in warn messages
* eth, p2p: use truncated names
* Update peer.go
Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: Felix Lange <fjl@twurst.com>
For some reason, using the shared hash causes a cryptographic incompatibility
when using Go 1.15. I noticed this during the development of Discovery v5.1
when I added test vector verification.
The go library commit that broke this is golang/go@97240d5, but the
way we used HKDF is slightly dodgy anyway and it's not a regression.
* Added back fdlimit to increase number of file descriptors
* Fixing a test file that fails on Mac with too few file descriptors available
* Trying to fix ci
* Trying to fix ci
* Trying to fix ci 3
* Fixing ci
This change moves the RLPx protocol implementation into a separate package,
p2p/rlpx. The new package can be used to establish RLPx connections for
protocol testing purposes.
Co-authored-by: Felix Lange <fjl@twurst.com>
# Conflicts:
# p2p/rlpx/rlpx.go
# p2p/rlpx/rlpx_test.go
# p2p/server_test.go
This change improves discovery behavior in small networks. Very small
networks would often fail to bootstrap because all member nodes were
dropping table content due to findnode failure. The check is now changed
to avoid dropping nodes on findnode failure when their bucket is almost
empty. It also relaxes the liveness check requirement for FINDNODE/v4
response nodes, returning unverified nodes as results when there aren't
any verified nodes yet.
The "findnode failed" log now reports whether the node was dropped
instead of the number of results. The value of the "results" was
always zero by definition.
Co-authored-by: Felix Lange <fjl@twurst.com>
# Conflicts:
# p2p/discover/v4_udp.go
This adds a lock around requests because some routers can't handle
concurrent requests. Requests are also rate-limited.
The Map function request a new mapping exactly when the map timeout
occurs instead of 5 minutes earlier. This should prevent duplicate mappings.
This PR significantly changes the APIs for instantiating Ethereum nodes in
a Go program. The new APIs are not backwards-compatible, but we feel that
this is made up for by the much simpler way of registering services on
node.Node. You can find more information and rationale in the design
document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775.
There is also a new feature in Node's Go API: it is now possible to
register arbitrary handlers on the user-facing HTTP server. In geth, this
facility is used to enable GraphQL.
There is a single minor change relevant for geth users in this PR: The
GraphQL API is no longer available separately from the JSON-RPC HTTP
server. If you want GraphQL, you need to enable it using the
./geth --http --graphql flag combination.
The --graphql.port and --graphql.addr flags are no longer available.
# Conflicts:
# cmd/faucet/faucet.go
# cmd/geth/chaincmd.go
# cmd/geth/config.go
# cmd/geth/consolecmd.go
# cmd/geth/main.go
# cmd/utils/flags.go
# cmd/wnode/main.go
# core/rawdb/freezer.go
# eth/api_backend.go
# eth/backend.go
# ethclient/ethclient_test.go
# ethstats/ethstats.go
# graphql/service.go
# internal/ethapi/backend.go
# les/api_backend.go
# les/api_test.go
# les/checkpointoracle/oracle.go
# les/client.go
# les/commons.go
# les/server.go
# miner/stresstest/stress_clique.go
# miner/stresstest/stress_ethash.go
# mobile/geth.go
# node/api.go
# node/node.go
# node/node_example_test.go
# node/node_test.go
# node/rpcstack.go
# node/rpcstack_test.go
# node/service.go
# node/service_test.go
# node/utils_test.go
# p2p/simulations/examples/ping-pong.go
# p2p/testing/peerpool.go
# p2p/testing/protocolsession.go
# p2p/testing/protocoltester.go
# whisper/mailserver/server_test.go
# whisper/whisperv6/api_test.go
# whisper/whisperv6/filter_test.go
# whisper/whisperv6/whisper.go
# whisper/whisperv6/whisper_test.go
* make lmdb default db
* switch nodes db to lmdb
* log errors in nodedb
* fix miss typing
* fix default test target in makefile
* report error of .Get method
* add debug info
* run tests with debug
* run tests with debug
* remove default db from TEST_DB env
* cleanup
* wait for goroutines finish
* wait for goroutines finish before close db
* wait for goroutines finish before close db
* wait for goroutines finish before close db
* wait for goroutines finish before close db
This moves all v4 protocol definitions to a new package, p2p/discover/v4wire.
The new package will be used for low-level protocol tests.
# Conflicts:
# p2p/discover/v4_lookup_test.go
# p2p/discover/v4_udp.go
# p2p/discover/v4_udp_test.go
This PR reimplements the light client server pool. It is also a first step
to move certain logic into a new lespay package. This package will contain
the implementation of the lespay token sale functions, the token buying and
selling logic and other components related to peer selection/prioritization
and service quality evaluation. Over the long term this package will be
reusable for incentivizing future protocols.
Since the LES peer logic is now based on enode.Iterator, it can now use
DNS-based fallback discovery to find servers.
This document describes the function of the new components:
https://gist.github.com/zsfelfoldi/3c7ace895234b7b345ab4f71dab102d4
# Conflicts:
# cmd/utils/flags.go
# core/forkid/forkid.go
# les/client.go
# les/client_handler.go
# les/commons.go
# les/distributor.go
# les/enr_entry.go
# les/fetcher.go
# les/lespay/client/valuetracker.go
# les/metrics.go
# les/peer.go
# les/protocol.go
# les/retrieve.go
# les/server.go
# les/serverpool.go
# les/test_helper.go
# les/utils/expiredvalue.go
# les/utils/weighted_select.go
# les/utils/weighted_select_test.go
# params/bootnodes.go
* resetIH from scratch if needed
* lmdb
* add AbstractKV to loader, added new Object accessor around AbstractKV
* add lmdb cli flag
* add requirement of k!=nil on error in docs
* add Size method for compatibility
* read after put tests
* fix multiput nils
* simplify loops
* increase mmap size
* better error messages
* better error messages
* fix tests
* better error messages
* cleanup
* avoid bolt usage in test
* move hardcoded bucket name to dbutils
* register more buckets
* register more buckets
* fix test
* p2p: add low port check in dialer
We already have a check like this for UDP ports, add a similar one in
the dialer. This prevents dials to port zero and it's also an extra
layer of protection against spamming HTTP servers.
* p2p/discover: use errLowPort in v4 code
* p2p: change port check
* p2p: add comment
* p2p/simulations/adapters: ensure assigned port is in all node records
It is possible to specify enode URLs using domain name since
commit b90cdbaa79, but the code comment still said that only
IP addresses are allowed.
Co-authored-by: admin@komgo.io <KomgoRocks2018!>
This adds two new methods to UDPv5, AllNodes and LocalNode.
AllNodes returns all the nodes stored in the local table; this is
useful for the purposes of metrics collection and also debugging any
potential issues with other discovery v5 implementations.
LocalNode returns the local node object. The reason for exposing this
is so that users can modify and set/delete new key-value entries in
the local record.
* core: initial version of state snapshots
* core/state: lazy sorting, snapshot invalidation
* core/state/snapshot: extract and split cap method, cover corners
* snapshot: iteration and buffering optimizations
* core/state/snapshot: unlink snapshots from blocks, quad->linear cleanup
* 123
* core/rawdb, core/state/snapshot: runtime snapshot generation
* core/state/snapshot: fix difflayer origin-initalization after flatten
* add "to merge"
* core/state/snapshot: implement snapshot layer iteration
* core/state/snapshot: node behavioural difference on bloom content
* core: journal the snapshot inside leveldb, not a flat file
* core/state/snapshot: bloom, metrics and prefetcher fixes
* core/state/snapshot: move iterator out into its own files
* core/state/snapshot: implement iterator priority for fast direct data lookup
* core/state/snapshot: full featured account iteration
* core/state/snapshot: faster account iteration, CLI integration
* core: fix broken tests due to API changes + linter
* core/state: fix an account resurrection issue
* core/tests: test for destroy+recreate contract with storage
* squashme
* core/state/snapshot, tests: sync snap gen + snaps in consensus tests
* core/state: extend snapshotter to handle account resurrections
* core/state: fix account root hash update point
* core/state: fix resurrection state clearing and access
* core/state/snapshot: handle deleted accounts in fast iterator
* core: more blockchain tests
* core/state/snapshot: fix various iteration issues due to destruct set
* core: fix two snapshot iterator flaws, decollide snap storage prefix
* core/state/snapshot/iterator: fix two disk iterator flaws
* core/rawdb: change SnapshotStoragePrefix to avoid prefix collision with preimagePrefix
* params: begin v1.9.13 release cycle
* cmd/checkpoint-admin: add some documentation (#20697)
* go.mod: update duktape to fix sprintf warnings (#20777)
This revision of go-duktype fixes the following warning
```
duk_logging.c: In function ‘duk__logger_prototype_log_shared’:
duk_logging.c:184:64: warning: ‘Z’ directive writing 1 byte into a region of size between 0 and 9 [-Wformat-overflow=]
184 | sprintf((char *) date_buf, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ",
| ^
In file included from /usr/include/stdio.h:867,
from duk_logging.c:5:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:36:10: note: ‘__builtin___sprintf_chk’ output between 25 and 85 bytes into a destination of size 32
36 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37 | __bos (__s), __fmt, __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
* core/rawdb: fix freezer table test error check
Fixes: Condition is always 'false' because 'err' is always 'nil'
* core/rawdb: improve table database (#20703)
This PR fixes issues in TableDatabase.
TableDatabase is a wrapper of underlying ethdb.Database with an additional prefix.
The prefix is applied to all entries it maintains. However when we try to retrieve entries
from it we don't handle the key properly. In theory the prefix should be truncated and
only user key is returned. But we don't do it in some cases, e.g. the iterator and batch
replayer created from it. So this PR is the fix to these issues.
* eth: when triggering a sync, check the head header TD, not block
* internal/web3ext: fix clique console apis to work on missing arguments
* rpc: dont log an error if user configures --rpcapi=rpc... (#20776)
This just prevents a false negative ERROR warning when, for some unknown
reason, a user attempts to turn on the module rpc even though it's already going
to be on.
* node, cmd/clef: report actual port used for http rpc (#20789)
* internal/ethapi: don't set sender-balance to maxuint, fixes#16999 (#20783)
Prior to this change, eth_call changed the balance of the sender account in the
EVM environment to 2^256 wei to cover the gas cost of the call execution.
We've had this behavior for a long time even though it's super confusing.
This commit sets the default call gasprice to zero instead of updating the balance,
which is better because it makes eth_call semantics less surprising. Removing
the built-in balance assignment also makes balance overrides work as expected.
* metrics: disable CPU stats (gosigar) on iOS
* cmd/devp2p: tweak DNS TTLs (#20801)
* cmd/devp2p: tweak DNS TTLs
* cmd/devp2p: bump treeNodeTTL to four weeks
* cmd/devp2p: lower route53 change limit again (#20819)
* cmd/devp2p: be very correct about route53 change splitting (#20820)
Turns out the way RDATA limits work is documented after all,
I just didn't search right. The trick to make it work is to
count UPSERTs twice.
This also adds an additional check to ensure TTL changes are
applied on existing records.
* graphql, node, rpc: fix typos in comments (#20824)
* eth: improve shutdown synchronization (#20695)
* eth: improve shutdown synchronization
Most goroutines started by eth.Ethereum didn't have any shutdown sync at
all, which lead to weird error messages when quitting the client.
This change improves the clean shutdown path by stopping all internal
components in dependency order and waiting for them to actually be
stopped before shutdown is considered done. In particular, we now stop
everything related to peers before stopping 'resident' parts such as
core.BlockChain.
* eth: rewrite sync controller
* eth: remove sync start debug message
* eth: notify chainSyncer about new peers after handshake
* eth: move downloader.Cancel call into chainSyncer
* eth: make post-sync block broadcast synchronous
* eth: add comments
* core: change blockchain stop message
* eth: change closeBloomHandler channel type
* eth/filters: fix typo on unindexedLogs function's comment (#20827)
* core: bump txpool tx max size to 128KB
* snapshotter/tests: verify snapdb post-state against trie (#20812)
* core/state/snapshot: basic trie-to-hash implementation
* tests: validate snapshot after test
* core/state/snapshot: fix review concerns
* cmd, consensus: add option to disable mmap for DAG caches/datasets (#20484)
* cmd, consensus: add option to disable mmap for DAG caches/datasets
* consensus: add benchmarks for mmap with/with lock
* cmd/clef: add newaccount command (#20782)
* cmd/clef: add newaccount command
* cmd/clef: document clef_New, update API versioning
* Update cmd/clef/intapi_changelog.md
Co-Authored-By: ligi <ligi@ligi.de>
* Update signer/core/uiapi.go
Co-Authored-By: ligi <ligi@ligi.de>
Co-authored-by: ligi <ligi@ligi.de>
* eth: add debug_accountRange API (#19645)
This new API allows reading accounts and their content by address range.
Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Felix Lange <fjl@twurst.com>
* travis: allow cocoapods deploy to fail (#20833)
* metrics: improve TestTimerFunc (#20818)
The test failed due to what appears to be fluctuations in time.Sleep, which is
not the actual method under test. This change modifies it so we compare the
metered Max to the actual time instead of the desired time.
* README: update private network genesis spec with istanbul (#20841)
* add istanbul and muirGlacier to genesis states in README
* remove muirGlacier, relocate istanbul
* cmd/evm: Rework execution stats (#20792)
- Dump stats also for --bench flag.
- From memory stats only show number and size of allocations. This is what `test -bench` shows. I doubt others like number of GC runs are any useful, but can be added if requested.
- Now the mem stats are for single execution in case of --bench.
* cmd/devp2p, cmd/wnode, whisper: add missing calls to Timer.Stop (#20843)
* p2p/server: add UDP port mapping goroutine to wait group (#20846)
* accounts/abi faster unpacking of int256 (#20850)
* p2p/discv5: add missing Timer.Stop calls (#20853)
* miner/worker: add missing timer.Stop call (#20857)
* cmd/geth: fix bad genesis test (#20860)
* eth/filters: add missing Ticker.Stop call (#20862)
* eth/fetcher: add missing timer.Stop calls (#20861)
* event: add missing timer.Stop call in TestFeed (#20868)
* metrics: add missing calls to Ticker.Stop in tests (#20866)
* ethstats: add missing Ticker.Stop call (#20867)
* p2p/discv5, p2p/testing: add missing Timer.Stop calls in tests (#20869)
* core: add missing Timer.Stop call in TestLogReorgs (#20870)
* rpc: add missing timer.Stop calls in websocket tests (#20863)
* crypto/ecies: improve concatKDF (#20836)
This removes a bunch of weird code around the counter overflow check in
concatKDF and makes it actually work for different hash output sizes.
The overflow check worked as follows: concatKDF applies the hash function N
times, where N is roundup(kdLen, hashsize) / hashsize. N should not
overflow 32 bits because that would lead to a repetition in the KDF output.
A couple issues with the overflow check:
- It used the hash.BlockSize, which is wrong because the
block size is about the input of the hash function. Luckily, all standard
hash functions have a block size that's greater than the output size, so
concatKDF didn't crash, it just generated too much key material.
- The check used big.Int to compare against 2^32-1.
- The calculation could still overflow before reaching the check.
The new code in concatKDF doesn't check for overflow. Instead, there is a
new check on ECIESParams which ensures that params.KeyLen is < 512. This
removes any possibility of overflow.
There are a couple of miscellaneous improvements bundled in with this
change:
- The key buffer is pre-allocated instead of appending the hash output
to an initially empty slice.
- The code that uses concatKDF to derive keys is now shared between Encrypt
and Decrypt.
- There was a redundant invocation of IsOnCurve in Decrypt. This is now removed
because elliptic.Unmarshal already checks whether the input is a valid curve
point since Go 1.5.
Co-authored-by: Felix Lange <fjl@twurst.com>
* rpc: metrics for JSON-RPC method calls (#20847)
This adds a couple of metrics for tracking the timing
and frequency of method calls:
- rpc/requests gauge counts all requests
- rpc/success gauge counts requests which return err == nil
- rpc/failure gauge counts requests which return err != nil
- rpc/duration/all timer tracks timing of all requests
- rpc/duration/<method>/<success/failure> tracks per-method timing
* mobile: use bind.NewKeyedTransactor instead of duplicating (#20888)
It's better to reuse the existing code to create a keyed transactor
than to rewrite the logic again.
* internal/ethapi: add CallArgs.ToMessage method (#20854)
ToMessage is used to convert between ethapi.CallArgs and types.Message.
It reduces the length of the DoCall method by about half by abstracting out
the conversion between the CallArgs and the Message. This should improve the
code's maintainability and reusability.
* eth, les: fix flaky tests (#20897)
* les: fix flaky test
* eth: fix flaky test
* cmd/geth: enable metrics for geth import command (#20738)
* cmd/geth: enable metrics for geth import command
* cmd/geth: enable metrics-flags for import command
* core/vm: use a callcontext struct (#20761)
* core/vm: use a callcontext struct
* core/vm: fix tests
* core/vm/runtime: benchmark
* core/vm: make intpool push inlineable, unexpose callcontext
* docs/audits: add discv5 protocol audits from LA and C53 (#20898)
* .github: change gitter reference to discord link in issue template (#20896)
* couple of fixes to docs in clef (#20900)
* p2p/discover: add initial discovery v5 implementation (#20750)This adds an implementation of the current discovery v5 spec.There is full integration with cmd/devp2p and enode.Iterator in thisversion. In theory we could enable the new protocol as a replacement ofdiscovery v4 at any time. In practice, there will likely be a few morechanges to the spec and implementation before this can happen.
* build: upgrade to golangci-lint 1.24.0 (#20901)
* accounts/scwallet: remove unnecessary uses of fmt.Sprintf
* cmd/puppeth: remove unnecessary uses of fmt.Sprintf
* p2p/discv5: remove unnecessary use of fmt.Sprintf
* whisper/mailserver: remove unnecessary uses of fmt.Sprintf
* core: goimports -w tx_pool_test.go
* eth/downloader: goimports -w downloader_test.go
* build: upgrade to golangci-lint 1.24.0
* accounts/abi/bind: Refactored topics (#20851)
* accounts/abi/bind: refactored topics
* accounts/abi/bind: use store function to remove code duplication
* accounts/abi/bind: removed unused type defs
* accounts/abi/bind: error on tuples in topics
* Cosmetic changes to restart travis build
Co-authored-by: Guillaume Ballet <gballet@gmail.com>
* node: allow websocket and HTTP on the same port (#20810)
This change makes it possible to run geth with JSON-RPC over HTTP and
WebSocket on the same TCP port. The default port for WebSocket
is still 8546.
geth --rpc --rpcport 8545 --ws --wsport 8545
This also removes a lot of deprecated API surface from package rpc.
The rpc package is now purely about serving JSON-RPC and no longer
provides a way to start an HTTP server.
* crypto: improve error messages in LoadECDSA (#20718)
This improves error messages when the file is too short or too long.
Also rewrite the test for SaveECDSA because LoadECDSA has its own
test now.
Co-authored-by: Felix Lange <fjl@twurst.com>
* changed date of rpcstack.go since new file (#20904)
* accounts/abi/bind: fixed erroneous filtering of negative ints (#20865)
* accounts/abi/bind: fixed erroneous packing of negative ints
* accounts/abi/bind: added test cases for negative ints in topics
* accounts/abi/bind: fixed genIntType for go 1.12
* accounts/abi: minor nitpick
* cmd: deprecate --testnet, use named networks instead (#20852)
* cmd/utils: make goerli the default testnet
* cmd/geth: explicitly rename testnet to ropsten
* core: explicitly rename testnet to ropsten
* params: explicitly rename testnet to ropsten
* cmd: explicitly rename testnet to ropsten
* miner: explicitly rename testnet to ropsten
* mobile: allow for returning the goerli spec
* tests: explicitly rename testnet to ropsten
* docs: update readme to reflect changes to the default testnet
* mobile: allow for configuring goerli and rinkeby nodes
* cmd/geth: revert --testnet back to ropsten and mark as legacy
* cmd/util: mark --testnet flag as deprecated
* docs: update readme to properly reflect the 3 testnets
* cmd/utils: add an explicit deprecation warning on startup
* cmd/utils: swap goerli and ropsten in usage
* cmd/geth: swap goerli and ropsten in usage
* cmd/geth: if running a known preset, log it for convenience
* docs: improve readme on usage of ropsten's testnet datadir
* cmd/utils: check if legacy `testnet` datadir exists for ropsten
* cmd/geth: check for legacy testnet path in console command
* cmd/geth: use switch statement for complex conditions in main
* cmd/geth: move known preset log statement to the very top
* cmd/utils: create new ropsten configurations in the ropsten datadir
* cmd/utils: makedatadir should check for existing testnet dir
* cmd/geth: add legacy testnet flag to the copy db command
* cmd/geth: add legacy testnet flag to the inspect command
* les, les/lespay/client: add service value statistics and API (#20837)
This PR adds service value measurement statistics to the light client. It
also adds a private API that makes these statistics accessible. A follow-up
PR will add the new server pool which uses these statistics to select
servers with good performance.
This document describes the function of the new components:
https://gist.github.com/zsfelfoldi/3c7ace895234b7b345ab4f71dab102d4
Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
* README: update min go version to 1.13 (#20911)
* travis, appveyor, build, Dockerfile: bump Go to 1.14.2 (#20913)
* travis, appveyor, build, Dockerfile: bump Go to 1.14.2
* travis, appveyor: force GO111MODULE=on for every build
* core/rawdb: fix data race between Retrieve and Close (#20919)
* core/rawdb: fixed data race between retrieve and close
closes https://github.com/ethereum/go-ethereum/issues/20420
* core/rawdb: use non-atomic load while holding mutex
* all: simplify and fix database iteration with prefix/start (#20808)
* core/state/snapshot: start fixing disk iterator seek
* ethdb, rawdb, leveldb, memorydb: implement iterators with prefix and start
* les, core/state/snapshot: iterator fixes
* all: remove two iterator methods
* all: rename Iteratee.NewIteratorWith -> NewIterator
* ethdb: fix review concerns
* params: update CHTs for the 1.9.13 release
* params: release Geth v1.9.13
* added some missing files
* post-rebase fixups
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: gary rong <garyrong0905@gmail.com>
Co-authored-by: Alex Willmer <alex@moreati.org.uk>
Co-authored-by: meowsbits <45600330+meowsbits@users.noreply.github.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: rene <41963722+renaynay@users.noreply.github.com>
Co-authored-by: Ha ĐANG <dvietha@gmail.com>
Co-authored-by: Hanjiang Yu <42531996+de1acr0ix@users.noreply.github.com>
Co-authored-by: ligi <ligi@ligi.de>
Co-authored-by: Wenbiao Zheng <delweng@gmail.com>
Co-authored-by: Adam Schmideg <adamschmideg@users.noreply.github.com>
Co-authored-by: Jeff Wentworth <jeff@curvegrid.com>
Co-authored-by: Paweł Bylica <chfast@gmail.com>
Co-authored-by: ucwong <ucwong@126.com>
Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: Luke Champine <luke.champine@gmail.com>
Co-authored-by: Boqin Qin <Bobbqqin@gmail.com>
Co-authored-by: William Morriss <wjmelements@gmail.com>
Co-authored-by: Guillaume Ballet <gballet@gmail.com>
Co-authored-by: Raw Pong Ghmoa <58883403+q9f@users.noreply.github.com>
Co-authored-by: Felföldi Zsolt <zsfelfoldi@gmail.com>
* Add revive and phoenix
* store enode address to file, then read it from tester
* store enode address to file, then read it from tester
* rebase master
* fix miss-type
* dbg p2p-sub-protocol, add self-destruct test case
* re-create blockFetcher
* exit syncer loop and start new one
* rebase to master
* use core.GenerateChain
* root miss-match
* introduce reduceComplexity flag
* fix transfer to 0 account
* cleanup
* test-case for intermediate cache
* clean
* clean
* clean
* fix handler panic
Co-authored-by: Alexey Akhunov <akhounov@gmail.com>
Co-authored-by: alex.sharov <alex.sharov@lazada.com>
This adds additional logic to re-resolve the root name of a tree when a
couple of leaf requests have failed. We need this change to avoid
getting into a failure state where leaf requests keep failing for half
an hour when the tree has been updated.
* p2p: new dial scheduler
This change replaces the peer-to-peer dial scheduler with a new and
improved implementation. The new code is better than the previous
implementation in two key aspects:
- The time between discovery of a node and dialing that node is
significantly lower in the new version. The old dialState kept
a buffer of nodes and launched a task to refill it whenever the buffer
became empty. This worked well with the discovery interface we used to
have, but doesn't really work with the new iterator-based discovery
API.
- Selection of static dial candidates (created by Server.AddPeer or
through static-nodes.json) performs much better for large amounts of
static peers. Connections to static nodes are now limited like dynanic
dials and can no longer overstep MaxPeers or the dial ratio.
* p2p/simulations/adapters: adapt to new NodeDialer interface
* p2p: re-add check for self in checkDial
* p2p: remove peersetCh
* p2p: allow static dials when discovery is disabled
* p2p: add test for dialScheduler.removeStatic
* p2p: remove blank line
* p2p: fix documentation of maxDialPeers
* p2p: change "ok" to "added" in static node log
* p2p: improve dialTask docs
Also increase log level for "Can't resolve node"
* p2p: ensure dial resolver is truly nil without discovery
* p2p: add "looking for peers" log message
* p2p: clean up Server.run comments
* p2p: fix maxDialedConns for maxpeers < dialRatio
Always allocate at least one dial slot unless dialing is disabled using
NoDial or MaxPeers == 0. Most importantly, this fixes MaxPeers == 1 to
dedicate the sole slot to dialing instead of listening.
* p2p: fix RemovePeer to disconnect the peer again
Also make RemovePeer synchronous and add a test.
* p2p: remove "Connection set up" log message
* p2p: clean up connection logging
We previously logged outgoing connection failures up to three times.
- in SetupConn() as "Setting up connection failed addr=..."
- in setupConn() with an error-specific message and "id=... addr=..."
- in dial() as "Dial error task=..."
This commit ensures a single log message is emitted per failure and adds
"id=... addr=... conn=..." everywhere (id= omitted when the ID isn't
known yet).
Also avoid printing a log message when a static dial fails but can't be
resolved because discv4 is disabled. The light client hit this case all
the time, increasing the message count to four lines per failed
connection.
* p2p: document that RemovePeer blocks