Skip to content

Commit 3da440b

Browse files
fqlxfjls1naholimanMariusVanDerWijden
authored
update eth v1.10.26 (#3)
* params: begin v1.10.19 release cycle * cmd/geth: exit when freezer has legacy receipts (ethereum#24943) In ethereum#24028 we flagged a warning when finding legacy receipts in the freezer. This PR nudges users a bit more strongly by preventing geth from starting in this case until receipts have been migrated. It also adds a flag --ignore-legacy-receipts which when present allows geth to start normally. * cmd/abigen: accept combined-json via stdin (ethereum#24960) * params: set emergency ropsten TTD to 100_000_000_000_000_000_000_000 (ethereum#24975) * core: use less memory during reorgs (ethereum#24616) This PR significantly reduces the memory consumption of a long reorg * cmd/geth: extend traverseRawState command (ethereum#24954) This PR adds node verification into traverseRawState command, so corrupted trie nodes can also be detected. * consensus/clique: fix race condition (ethereum#24957) * consensus/clique: remove race condition * consensus/clique: fix one more signer data race Co-authored-by: Gary Rong <garyrong0905@gmail.com> * eth/catalyst: fix edge case in NewPayload (ethereum#24955) Fixes an issue where we would accept a NewPayload where the grandparent is already post ttd, and the parent still has a Difficulty * contracs/checkpointoracle: fix directives (ethereum#24944) contracts/checkpointoracle: redefine go-generate logic * eth/filters: use buffered channel to avoid goroutine leak (ethereum#24928) * core/beacon: prevent invalid logsBloom length panic (ethereum#24946) * core/beacon: prevent invalid logsBloom length panic * core/beacon: prevent negative baseFeePerGas * Update core/beacon/types.go Co-authored-by: Martin Holst Swende <martin@swende.se> * eth/catalys: go format Co-authored-by: Martin Holst Swende <martin@swende.se> * core: fix canonical hash marker update (ethereum#24996) * core: fix reorg * core: revert change for memory efficiency * core: revert changes * eth/tracers: add support for block overrides in debug_traceCall (ethereum#24871) This PR adds support for block overrides when doing debug_traceCall. - Previously, debug_traceCall against pending erroneously used a common.Hash{} stateroot when looking up the state, meaning that a totally empty state was used -- so it always failed, - With this change, we reject executing debug_traceCall against pending. - And we add ability to override all evm-visible header fields. * tests/fuzzers/bls12381: Add BLST to fuzzing support (ethereum#24249) * tests/fuzzers/bls12381: added blst library * go.mod: added blst dependency * tests/fuzzers/bls12381: stuff * tests/fuzzers/bls12381: added blst to pairing fuzzer * eth/catalyst: return 0x0 on Invalid block on top of pow block (ethereum#25006) * node: make jwt test less dependent on time (ethereum#25016) * consensus/misc: reduce allocations and improve comments in CalcBaseFee (ethereum#24958) * consensus/misc: reduce allocations in CalcBaseFee * consensus/misc: add formulas of CalcBaseFee * go.mod: set go version to 1.17 (ethereum#24926) set go version to 1.17 * go.mod: clean up (ethereum#25017) * core/vm: optimize jumpdest analysis (ethereum#23500) core/vm: optimize PUSH opcode discrimination * tests/fuzzers/bls12381: fix blst deserializing (ethereum#25036) * tests/fuzzers/bls12381: fix blst deserializing * tests/fuzzers/bls12381: fix blst deserializing * cmd/geth, core/state/snapshot: rework journal loading, implement account-check (ethereum#24765) * cmd/geth, core/state/snapshot: rework journal loading, implement account-check * core/state/snapshot, cmd/geth: polish code (ethereum#37) * core/state/snapshot: minor nits * core/state/snapshot: simplify error logic * cmd/geth: go format Co-authored-by: rjl493456442 <garyrong0905@gmail.com> * all: introduce trie owner notion (ethereum#24750) * cmd, core/state, light, trie, eth: add trie owner notion * all: refactor * tests: fix goimports * core/state/snapshot: fix ineffasigns Co-authored-by: Martin Holst Swende <martin@swende.se> * eth/api: use `hexutil.Bytes` for account range method (ethereum#25024) eth/api: use hexutil.Bytes for range at methods * eth/tracers: fix typo in 4byte_tracer_legacy.js (ethereum#25020) indentifier -> identifier * trie: move locking into trieDB insert method (ethereum#25030) Move locking into trieDB insert function * params: update ropsten terminal total difficulty block (ethereum#25018) * eth/filters: fix getLogs for pending block (ethereum#24949) * eth/filters: fix pending for getLogs * add pending method to test backend * fix block range validation * accounts/abi/bind: fix duplicate field names in the generated go struct (ethereum#24924) * accounts/abi/bind: fix duplicate field names in the generated go struct ethereum#24627 * accounts, cmd/abigen: resolve name conflicts * ci lint, accounts/abi: remove unused function overloadedArgName Co-authored-by: Gary Rong <garyrong0905@gmail.com> * tests/fuzzers/bls12381: fix blst pairing (ethereum#25037) * tests/fuzzers/bls12381: fix blst pairing * tests/fuzzers/bls12381: only build on gofuzz * tests/fuzzers/bls12381: remove unused code * tests/fuzzers/bls12381: remove unused code * p2p/discover: fix panicky test (ethereum#25038) * accounts: increase parseURL test coverage (ethereum#25033) accounts/url: add test logic what check null string to parseURL() * eth, les, params: log chain config a bit saner (ethereum#24904) Previously on Geth startup we just logged the chain config is a semi-json-y format. Whilst that worked while we had a handful of hard-forks defined, currently it's kind of unwieldy. This PR converts that original data dump and converts it into a user friendly - alas multiline - log output. * p2p: use errors.Is for error comparison (ethereum#24882) Co-authored-by: Felix Lange <fjl@twurst.com> * rpc: swap out timer metrics to histograms * eth/catalyst: remove unauthenticated 'engine' api (ethereum#24997) Removes engine from any unauthenticated RPC service. * core/types: remove unused field 'td' in Block (ethereum#25010) * core/types: improve LogForStorage and ReceiptForStorage comments (ethereum#25032) Co-authored-by: Felix Lange <fjl@twurst.com> * core/evm: fix error in comment (ethereum#25040) Co-authored-by: Martin Holst Swende <martin@swende.se> * internal/ethapi: fix typo in comment (ethereum#25056) typo error: keccack256 -> keccak256 * Chore: Minimal gramatical errors (signleton -> singleton) (ethereum#25057) core: fix typos * all: more linters (ethereum#24783) This enables the following linters - typecheck - unused - staticcheck - bidichk - durationcheck - exportloopref - gosec WIth a few exceptions. - We use a deprecated protobuf in trezor. I didn't want to mess with that, since I cannot meaningfully test any changes there. - The deprecated TypeMux is used in a few places still, so the warning for it is silenced for now. - Using string type in context.WithValue is apparently wrong, one should use a custom type, to prevent collisions between different places in the hierarchy of callers. That should be fixed at some point, but may require some attention. - The warnings for using weak random generator are squashed, since we use a lot of random without need for cryptographic guarantees. * cmd/utils: update --ropsten description (ethereum#25078) * readme,eth: remove references to eth.wiki (ethereum#25086) * cmd/ethkey: use accounts.TextHash (ethereum#25069) * common: improve pretty duration regex (ethereum#25073) * common: improve pretty duration regex * common: improve pretty duration regex * all: prefer `new(big.Int)` over `big.NewInt(0)` (ethereum#25087) minor performance improvement: `big.NewInt(0).Xxx` -> `new(big.Int).Xxx` * eth: add missing period at end of sentences (ethereum#25058) eth: add missing periods on end of comments * eth: introduce eth67 protocol (ethereum#24093) The new protocol version removes support for GetNodeData. See https://eips.ethereum.org/EIPS/eip-4938 for more information. Co-authored-by: Felix Lange <fjl@twurst.com> Co-authored-by: Martin Holst Swende <martin@swende.se> * cmd, params: implement Gray Glacier hard-fork (EIP-5133) (ethereum#25088) * cmd/geth, params: implement Gray Glacier (EIP-5133) * cmd/evm: add gray glacier tests * params: nitpicks * params: fixes * node: add info message when JWT secret is loaded (ethereum#25095) Co-authored-by: Felix Lange <fjl@twurst.com> * params: release Geth v1.10.19 * params: begin v1.10.20 release cycle * internal/ethapi: add comment explaining return of nil instead of error (ethereum#25097) Co-authored-by: Felix Lange <fjl@twurst.com> * tests/fuzzers/rlp: avoid very large input (ethereum#25109) The oss-fuzz engine crashes due to stack overflow decoding a large nested structure into a interface{}. This PR limits the size of the input data, so should avoid such crashes. * node: make jwt tests less time-dependent (ethereum#25120) * cmd/faucet: more verbose message about private posts (ethereum#25129) * cmd/faucet: Add error message for private posts Fixes ethereum#22631 * grammar * internal/ethapi: remove SignAndSendTransaction (ethereum#25111) * cmd/faucet: add sepolia network support (ethereum#25128) cmd/faucet: Add Sepolia network support to faucet * trie: fix size accounting in cleaner (ethereum#25007) Decrease children size instead of dirties size when marking dirties as cleaned up in trie cleaner * all: remove concept of public/private API definitions (ethereum#25053) * internal/ethapi: rename PublicEthereumAPI to EthereumAPI * eth: rename PublicEthereumAPI to EthereumAPI * internal/ethapi: rename PublicTxPoolAPI to TxPoolAPI * internal/ethapi: rename PublicAccountAPI to EthereumAccountAPI * internal/ethapi: rename PrivateAccountAPI to PersonalAccountAPI * internal/ethapi: rename PublicBlockChainAPI to BlockChainAPI * internal/ethapi: rename PublicTransactionPoolAPI to TransactionAPI * internal/ethapi: rename PublicDebugAPI to DebugAPI * internal/ethapi: move PrivateDebugAPI methods to DebugAPI * internal/ethapi: rename PublicNetAPI to NetAPI * les: rename PrivateLightServerAPI to LightServerAPI * les: rename PrivateLightAPI to LightAPI * les: rename PrivateDebugAPI to DebugAPI * les: rename PublicDownloaderAPI to DownloaderAPI * eth,les: rename PublicFilterAPI to FilterAPI * eth: rename PublicMinerAPI to MinerAPI * eth: rename PublicDownloaderAPI to DownloaderAPI * eth: move PrivateMinerAPI methods to MinerAPI * eth: rename PrivateAdminAPI to AdminAPI * eth: rename PublicDebugAPI to DebugAPI * eth: move PrivateDebugAPI methods to DebugAPI * node: rename publicAdminAPI to adminAPI * node: move privateAdminAPI methods to adminAPI * node: rename publicWeb3API to web3API * eth,internal/ethapi: sync comments with previous renamings * cmd/geth: drop geth js command (ethereum#25000) * cmd/geth: drop js command * cmd: simplify ipc path determination for attach * Add deprecation warning for js * rm testdata for exec * fix account unlock test cases * Update cmd/geth/consolecmd.go Co-authored-by: Martin Holst Swende <martin@swende.se> * fix Co-authored-by: Martin Holst Swende <martin@swende.se> * README,rpc: remove mention of "shh" RPC API (ethereum#25137) * eth, miner: retrieve mining state from live database (ethereum#25139) * miner: retrieve mining state from live database * eth/catalyst: ignore stale fcu events from cl * core: fix typo in txpool (ethereum#25149) Fix typo in txPool truncateQueue comment * go.mod: upgrade to latest goleveldb (ethereum#25067) Co-authored-by: Felix Lange <fjl@twurst.com> * eth/tracers: optimize goja buffer conversion (ethereum#25156) This changes the []byte <-> Uint8Array conversion to use an ArrayBuffer, avoiding inefficient copying of the slice data in Goja. Co-authored-by: Felix Lange <fjl@twurst.com> * eth: fix typo (ethereum#25161) * internal/ethapi: always return chain id (ethereum#25166) The error was introduced in PR ethereum#21686, but there is no good reason to enforce sync in this method, and it causes issues with EL/CL integration. * internal/ethapi: add note about eth_chainId compatibility with EIP-695 (ethereum#25168) Co-authored-by: Felix Lange <fjl@twurst.com> * all: remove `public` field from `rpc.API` (ethereum#25059) all: remove public field from rpc.API * all: remove version field from rpc.API * cmd: migrate to urfave/cli/v2 (ethereum#24751) This change updates our urfave/cli dependency to the v2 branch of the library. There are some Go API changes in cli v2: - Flag values can now be accessed using the methods ctx.Bool, ctx.Int, ctx.String, ... regardless of whether the flag is 'local' or 'global'. - v2 has built-in support for flag categories. Our home-grown category system is removed and the categories of flags are assigned as part of the flag definition. For users, there is only one observable difference with cli v2: flags must now strictly appear before regular arguments. For example, the following command is now invalid: geth account import mykey.json --password file.txt Instead, the command must be invoked as follows: geth account import --password file.txt mykey.json * params: set TTD for sepolia testnet (ethereum#25179) * cmd/geth, p2p: add support for custom discovery UDP port (ethereum#24979) This adds a new flag to set the discovery port to be different from the TCP listener port. Co-authored-by: Felix Lange <fjl@twurst.com> * fix: linter warning (ethereum#25192) * core/rawdb: fix typo in comment (ethereum#25191) * core/rawdb: simplify TestDiskSeek to use memorydb (ethereum#25182) * cmd/utils: fix applying bootstrap nodes from config file (ethereum#25174) * internal/ethapi: return chain id for EIP-155 legacy txs (ethereum#25155) * common: increase StorageSize test coverage (ethereum#25188) * consensus/beacon: check that only the latest pow block is valid ttd block (ethereum#25187) * consensus/beacon: check that only the latest pow block is valid ttd block * consensus/beacon: move verification to async function * consensus/beacon: fix verifyTerminalPoWBlock, add test cases * consensus/beacon: cosmetic changes * consensus/beacon: apply karalabe's fixes * build: fix auto-completion scripts and include them in .deb package (ethereum#25195) Co-authored-by: Felix Lange <fjl@twurst.com> * build: upgrade to golangci-lint v1.46.2 (ethereum#25202) This upgrade is required to fix lint issues with urfave/cli/v2, which uses generics when built with Go 1.18 * build/deb: fix auto-completion install paths (ethereum#25204) * params: go-ethereum v1.10.20 stable * params: begin v1.10.21 release cycle * common/prque: fix typo * eth/catalyst: disallow importing blocks via newPayload during snap sync (ethereum#25210) * eth/catalyst: disallow importing blocks via newPayload during snap sync * eth/catalyst: make tests pass by using full sync only * eth/catalysts: make the import delay a bit cleaner * eth/catalyst: fix typo Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de> Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de> * Replace fmt.Errorf with errors.New in abi argument (ethereum#25181) Replace unnecessary fmt.Errorf with errors.New in accounts/abi/argument.go * all: change format `0x%x` to `%#x` (ethereum#25221) * consensus/beacon: copy td value so we can modify it (ethereum#25230) * consensus/beacon: copy td value so we can modify it * consensus/beacon: copy td value so we can modify it * core: allow external code to set the block validator for malicious tests (ethereum#25119) * core: don't validate state * core: allow external validator * core: revert * core: comments * Update blockchain_reader.go * core: move SetValidator to blockchain.go * core: rename method * core: apply ttd override to uninitialized db (ethereum#25136) * core: apply ttd override to genesis block * core: apply overrides properly * signer/core/apitypes: support primitive types int96/uint96 (ethereum#25105) I have a EIP712 typehash using uint96, but it's currently not supported by go-ethereum. This change fixes it. * cmd/geth, cmd/devp2p: fix some cli parsing issues (ethereum#25234) * cmd/geth: add some missing argument count checks * internal/flags: skip cmds with no action func in MigrateGlobalFlags * internal/flags: add Merge * cmd/devp2p: re-add listener config flags in discv4 commands * core: allow external processor (ethereum#25233) * consensus/beacon: verify timestamp is greater than parent timestamp (ethereum#25236) * go.mod: updated logfmt dependency (ethereum#25231) This fixes an issue in abigen tests with go 1.17. * internal/ethapi: add basefee to block overrides (ethereum#25219) * build: upgrade -dlgo version to Go 1.18.3 * trie: fix typo in comment (ethereum#25241) paralallel -> parallel * core/types: fix typo in comment (ethereum#25249) * internal/ethapi: fix chain ID check to return all non-zero IDs (ethereum#25244) * rpc: add graceful shutdown timeout for HTTP server (ethereum#25258) This change ensures the HTTP server will always terminate within at most 5s, even when all connections are busy and do not become idle. Co-authored-by: Felix Lange <fjl@twurst.com> * p2p/discover: fix typos in comments (ethereum#25272) * core, eth: pre-allocate map in storage copy (ethereum#25279) * eth/tracers: add initial revertReasonTracer tracer (ethereum#25265) Adds a native tracer that returns that in case of failure returns the error message or the revert reason of a transaction. Co-authored-by: Martin Holst Swende <martin@swende.se> * params: enable DNS discovery on Sepolia too * internal/build: add a timestamp to the tar archive folder * build: upgrade -dlgo version to Go 1.18.4 * accounts/abi: fix typo in comment (ethereum#25271) * accounts/abi/bind/backends: return hash of new blocks (ethereum#25163) Co-authored-by: Jens <jmw.1906@gmx.de> * internal/ethapi: error if tx args includes chain id that doesn't match local (ethereum#25157) * internal/ethapi: error if tx args includes chain id that doesn't match local * internal/ethapi: simplify code a bit Co-authored-by: Péter Szilágyi <peterke@gmail.com> * core: remove lock in BlockChain.ExportN (ethereum#25254) * Remove locking in (*BlockChain).ExportN Since ExportN is read-only, it shouldn't need the lock. (?) * Add hash check to detect reorgs during export. * fix check order * Update blockchain.go * Update blockchain.go Co-authored-by: rjl493456442 <garyrong0905@gmail.com> * core: prevent negative fee during RPC calls (ethereum#25214) During RPC calls such as eth_call and eth_estimateGas, st.evm.Config.NoBaseFee is set which allows the gas price to be below the base fee. This results the tip being negative, and balance being subtracted from the coinbase instead of added to it, which results in a potentially negative coinbase balance interestingly. This can't happen during normal chain processing as outside of RPC calls the gas price is required to be at least the base fee, as NoBaseFee is false. This change prevents this behavior by disabling fee payment when the fee is not set. Co-authored-by: lightclient@protonmail.com <lightclient@protonmail.com> Co-authored-by: Felix Lange <fjl@twurst.com> * core, les, eth: port snap sync changes (ethereum#24898) core, eth, les, trie: rework snap sync * tests: only activate merge on london rules (ethereum#25239) * trie: fix 'gosimple' lint issue (ethereum#25309) * p2p/discover: apply netrestrict in discv5 response handler (ethereum#25304) * cmd/geth: remove redundant 0x in dbGet/dbDelete (ethereum#25315) * accounts/abi: substitude arg%d to the range keyword (ethereum#25307) * accounts/abi: substitude arg%d to the range keyword * support more keywords * review feedback * params: Add Shanghai and Cancun blocks (ethereum#25305) * params: Add Shangai and Cancun blocks * fix copy/paste error Co-authored-by: Martin Holst Swende <martin@swende.se> * fix typo in Shanghai name Co-authored-by: Martin Holst Swende <martin@swende.se> * params: change Merge config to print simpler message This fixes ethereum#25366 * cmd/puppeth: remove support for exporting non-Geth genesis configurations (ethereum#25329) * cmd/puppeth: remove support for exporting non-Geth genesis configurations * remove unused function * params: set goerli TTD to 10_790_000 (ethereum#25324) * signer/core: add canonical TypedData hashing methods (ethereum#25283) * deps: update goleveldb * params: set sepolia mergeNetsplitBlock to 1735371 (ethereum#25372) * cmd/geth: eth/catalyst: enable authrpc by default (ethereum#25152) * cmd/geth: eth/catalyst: enable authrpc by default * eth/catalyst: rename catalyst -> Engine API in logs * eth/catalyst: don't panic * eth/catalyst: better warning for ttd not configured (ethereum#25394) * cmd: use flags.Merge for grouping flags (ethereum#25392) * consensus/beacon: fix typo in comment (ethereum#25391) * p2p/netutil: minor code cosmetic Signed-off-by: Abirdcfly <fp544037857@gmail.com> * eth, internal, light: fix error string capitalization (ethereum#25364) * light: fix differTries err message in tests (ethereum#25358) * all: add whitespace linter (ethereum#25312) * golangci: typo Signed-off-by: Delweng <delweng@gmail.com> * golangci: add whietspace Signed-off-by: Delweng <delweng@gmail.com> * *: rm whitesapce using golangci-lint Signed-off-by: Delweng <delweng@gmail.com> * cmd/puppeth: revert accidental resurrection Co-authored-by: Péter Szilágyi <peterke@gmail.com> * eth/tracers/js: fix capitalization in tests * eth: support bubbling up bad blocks from sync to the engine API (ethereum#25190) * eth: support bubbling up bad blocks from sync to the engine API * eth/catalyst: fix typo Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de> * eth/catalyst: fix typo Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de> * Update eth/catalyst/api.go * eth/catalyst: when forgetting bad hashes, also forget descendants * eth/catalyst: minor bad block tweaks for resilience Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de> Co-authored-by: Martin Holst Swende <martin@swende.se> * core: eth: rpc: implement safe rpc block (ethereum#25165) * core: eth: rpc: implement safe rpc block * core: fix setHead, panics * go.mod: downgrade leveldb (ethereum#25413) * params: go-ethereum v1.10.21 stable * params: begin v1.10.22 release cycle * core, trie, eth, cmd: rework preimage store (ethereum#25287) * core, trie, eth, cmd: rework preimage store * trie: address comment * eth/catalyst: fix NewPayload warn log when dropping due to snap sync * node: set JWT expiry to 60 seconds (ethereum#25416) * node: set JWT expiry to 60 seconds * node: rename var * eth/catalyst: return syncing not accepted (ethereum#25414) * eth/catalyst: return syncing not accepted * eth/catalyst: fix test * eth/catalyst: return 0x0 if latestvalid is pow block (ethereum#25423) * eth/catalyst: return 0x0 if latestvalid is pow block * eth/catalyst: return 0x0 if latestvalid is pow block * eth/catalyst: fix header retrieval, fix sign check Co-authored-by: Péter Szilágyi <peterke@gmail.com> * ethereum, ethclient: add FeeHistory support (ethereum#25403) Co-authored-by: Felix Lange <fjl@twurst.com> * all: use AbsTime.Add instead of conversion (ethereum#25417) * cm/puppeth: fix crash when of ethstats specifier doesn't contain `:` (ethereum#25405) Signed-off-by: Delweng <delweng@gmail.com> * eth: fix typo in comment (ethereum#25327) * common/compiler: json unmarshalling error checks (ethereum#25449) complier/solidity:add json.Unmarshal err check * cmd, core, eth, les, params: add merge-passed chain config (ethereum#24538) * cmd, core, eth, les, params: add merge-passed chain config * eth/catalyst, params: add various warning on malfunctioning beacons * eth/catalyst: fix warning for beacons without transition exchanges * eth: fix typo in catalyst api (ethereum#25460) eth: fix typo * build: upgrade -dlgo version to Go 1.18.5 * eth/gasprice/feehistory: support finalized block (ethereum#25442) * consensus/ethash: remove temp files created during DAG generation (ethereum#25381) This makes it remove not only the actual DAG file, but also the temporary file which the DAG data is written to while generating. * cmd/devp2p/internal/ethtest: update tests for eth/67 (ethereum#25306) * node, rpc: add ReadHeaderTimeout config option (ethereum#25338) This change makes http.Server.ReadHeaderTimeout configurable separately from ReadTimeout for RPC servers. The default is set to the same as ReadTimeout, which in order to cause no change in existing deployments. * core/types: fix typo in comment (ethereum#25359) * core: preallocate batch size in bloomIndexer (ethereum#25289) This change reduces allocations when committing bloombits indexes by creating the database batch with a larger initial size. * internal/ethapi: don't estimate gas if no limit provided in eth_createAccessList (ethereum#25467) Because the goal of eth_createAccessList is providing the caller with the largest-possible access list, it's generally not important that the gas limit used by the tracer will match the usage of the call exactly. Avoiding the gas estimation step is a performance improvement. As long as the call does not branch based on gas limit, the returned access list will be accurate. * graphql: embed *Resolver instead of backend interface (ethereum#25468) This creates some infrastructure to share resources between graphql API objects. * node: remove noop path.Join (ethereum#25475) Signed-off-by: Delweng <delweng@gmail.com> * core, trie: rework trie committer (ethereum#25320) * all: rework trie and trie committer * all: get rid of internal cache in trie * all: fixes * trie: polish * core, trie: address comments * trie: fix imports * core/state: address comments * core/state/snapshot: polish * trie: remove unused code * trie: update tests * trie: don't set db as nil * trie: address comments * trie: unskip test * core: use TryGetAccount to read what TryUpdateAccount has written (ethereum#25458) * core: use TryGetAccount to read where TryUpdateAccount has been used to write * Gary's review feedback * implement Gary's suggestion * fix bug + rename NewSecure into NewStateTrie * trie: add backwards-compatibility aliases for SecureTrie * Update database.go * make the linter happy Co-authored-by: Felix Lange <fjl@twurst.com> Co-authored-by: rjl493456442 <garyrong0905@gmail.com> * cmd, core, ethdb, node: move chain freezer one folder deeper (ethereum#25487) * cmd, core, ethdb, node: create chain freezer in a sub folder * core/rawdb: remove unused code * core, ethdb, node: add AncientDatadir API back * cmd, core: extend freezer info dump for sub-ancient-store * core/rawdb: rework freezer inspector * core/rawdb: address comments from Peter * core/rawdb: fix build issue * eth/downloader: fix log errors of queue_test.go (ethereum#25494) * core: fix uncle creation in TestFastVsFullChains (ethereum#25476) Co-authored-by: Felix Lange <fjl@twurst.com> * eth: formatted error nit (ethereum#25499) * eth/tracers: add onlyTopCall option to callTracer (ethereum#25430) This PR allows users to pass in a config object directly to the tracers. Previously only the struct logger was configurable. It also adds an option to the call tracer which if enabled makes it ignore any subcall and collect only information about the top-level call. See ethereum#25419 for discussion. The tracers will silently ignore if they are passed a config they don't care about. * all: cleanup the APIs for initializing genesis (ethereum#25473) * all: polish tests * core: apply feedback from Guillaume * core: fix comment * core: remove unused bc ChainContext in applyTransaction * signer/rules: register clef api properly when rules are used (ethereum#25455) signer/rules: register clef api properly when rules are used, fixes ethereum#25298 * build: add static linking support (ethereum#25492) This adds support for building statically-linked executables using ci.go. Static linking is enabled by default in Docker builds, making it possible to use the geth executable in any Docker image, regardless of the Linux distribution the Dockerfile is based on. Co-authored-by: Felix Lange <fjl@twurst.com> * accounts/abi: display name in "method/event not found" error (ethereum#25512) * internal/ethapi: rework setDefaults for tx args so fee logic is separate (ethereum#25197) Co-authored-by: bobpkr <bob.p@krustuniverse.com> * core/genesis: remove calaverasAllocData (ethereum#25516) core/genesis: calaverasAllocData no longer used * params: set ttdpassed on goerli (ethereum#25519) * params: set mainnet terminal total difficulty for the merge (ethereum#25528) * params: set mainnet ttd to 58_750_000_000_000_000_000_000 * params: set mainnet ttd to 58_750_000_000_000_000_000_000 * core, trie: flush preimages to db on blockchain close (ethereum#25533) * core, trie: flush preimages to db on database close Co-authored-by: rjl493456442 <garyrong0905@gmail.com> * rename Close to CommitPreimages for clarity * core, trie: nitpick fixes Co-authored-by: rjl493456442 <garyrong0905@gmail.com> Co-authored-by: Péter Szilágyi <peterke@gmail.com> * core/state, trie, light: add a TryDeleteAccount method (ethereum#25531) * core/state, trie, light: Add a DeleteAccount method * review feedback * Update database.go * pr triage feedback Co-authored-by: rjl493456442 <garyrong0905@gmail.com> * core: make tx journal check and open atomic (ethereum#25530) * core: reduce system call about `os` * avoid deprecated method * cmd. core: save preimages on genesis creation (ethereum#25538) force preimage dump for genesis * rlp/rlpgen: fix error handling when target type not found (ethereum#25547) typ will be nil when lookupStructType returns an error. cfg.Type should be used instead. * trie: improve node rlp decoding performance (ethereum#25357) This avoids copying the input []byte while decoding trie nodes. In most cases, particularly when the input slice is provided by the underlying database, this optimization is safe to use. For cases where the origin of the input slice is unclear, the copying version is retained. The new code performs better even when the input must be copied, because it is now only copied once in decodeNode. * all: fix some typos (ethereum#25551) * Fix some typos * Fix some mistakes * Revert 4byte.json * Fix an incorrect fix * Change files to fails * internal/ethapi: fix comment typo (ethereum#25548) * accounts/abi/bind/backends: typo fix (ethereum#25549) * eth, les: unlock downloader peerSet if there's an error (ethereum#25546) Unlock peerSet if there's an error in the downloader * cmd/geth: parse uint64 value with ParseUint instead of Atoi (ethereum#25545) Parse uint64 value with ParseUint instead of Atoi * consensus/beacon: check ttd reached on pos blocks (ethereum#25552) * consensus/beacon: check ttd reached on pos blocks * consensus/beacon: check ttd reached on pos blocks * consensus/beacon: check ttd reached on pos blocks * eth/filters: add global block logs cache (ethereum#25459) This adds a cache for block logs which is shared by all filters. The cache size of is configurable using the `--cache.blocklogs` flag. Co-authored-by: Felix Lange <fjl@twurst.com> * accounts/abi: fix set function (ethereum#25477) * accounts/abi: fix set function * don't break things * update test * internal/ethapi: fix build regression (ethereum#25555) * eth/fetcher: don't spend too much time on transaction inclusion (ethereum#25524) * eth/fetcher: introduce some lag in tx fetching * eth/fetcher: change conditions a bit * eth/fetcher: use per-batch quota check * eth/fetcher: fix some comments * eth/fetcher: address review concerns * eth/fetcher: fix panic + add warn log * eth/fetcher: fix log * eth/fetcher: fix log * cmd/devp2p/internal/ethtest: fix ignorign tx announcements from prev. tests * cmd/devp2p/internal/ethtest: fix TestLargeTxRequest This increases the number of tx relay messages the test waits for. Since go-ethereum now processes incoming txs in smaller batches, the announcement messages it sends are also smaller. Co-authored-by: Felix Lange <fjl@twurst.com> * Revert "eth/fetcher: don't spend too much time on transaction inclusion" (ethereum#25567) Revert "eth/fetcher: don't spend too much time on transaction inclusion (ethereum#25524)" This reverts commit 0ce494b. * eth/catalyst: warn less frequently if no beacon client is available (ethereum#25569) * eth/catalyst: warn less frequently if no beacon client is available * eth/catalyst: tweak warning frequency a bit * eth/catalyst: some more tweaks * Update api.go Co-authored-by: Felix Lange <fjl@twurst.com> * params: release go-ethereum v1.10.22 * params: begin v1.10.23 release cycle * core, eth/downloader: handle spurious junk bodies from racey rollbacks (ethereum#25578) * eth/downloader: handle junkbodies/receipts in the beacon sync * core: check for header presence when checking for blocks * core/state, trie: fix trie flush order for proper pruning * consensus/beacon: don't ignore errors * params: release Geth v1.10.23 * graphql: return correct logs for tx (ethereum#25612) * graphql: fix tx logs * minor * Use optimized search for selecting tx logs * graphql: fixes missing tx logs (ethereum#25745) * graphql: fix tx logs * graphql: refactor test service setup * graphql: add test for tx logs * Release Geth v1.10.24 * params: set TerminalTotalDifficultyPassed to true (ethereum#25769) * params: set TerminalTotalDifficultyPassed to true * Update params/config.go Co-authored-by: Martin Holst Swende <martin@swende.se> * params: release Geth v1.10.25 * eth/protocols/snap: fix problems due to idle-but-busy peers (ethereum#25651) * eth/protocols/snap: throttle trie heal requests when peers DoS us (ethereum#25666) * eth/protocols/snap: throttle trie heal requests when peers DoS us * eth/protocols/snap: lower heal throttle log to debug Co-authored-by: Martin Holst Swende <martin@swende.se> * eth/protocols/snap: fix comment Co-authored-by: Martin Holst Swende <martin@swende.se> * trie: check childrens' existence concurrently for snap heal (ethereum#25694) * eth: fix a rare datarace on CHT challenge reply / shutdown (ethereum#25831) * eth/filters: change filter block to be by-ref (ethereum#26054) This PR changes the block field in the filter to be a pointer, to disambiguate between empty hash and no hash * rpc: handle wrong HTTP batch response length (ethereum#26064) * params: release geth v1.10.26 stable Signed-off-by: Abirdcfly <fp544037857@gmail.com> Signed-off-by: Delweng <delweng@gmail.com> Co-authored-by: Felix Lange <fjl@twurst.com> Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com> Co-authored-by: Martin Holst Swende <martin@swende.se> Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de> Co-authored-by: rjl493456442 <garyrong0905@gmail.com> Co-authored-by: Harry Kalodner <harry.kalodner@gmail.com> Co-authored-by: Boqin Qin(秦 伯钦) <Bobbqqin@gmail.com> Co-authored-by: Ivan Kuznetsov <me@jeiwan.ru> Co-authored-by: Jonathan Le Brun <42697488+icyfry@users.noreply.github.com> Co-authored-by: s7v7nislands <s7v7nislands@gmail.com> Co-authored-by: Paweł Bylica <chfast@gmail.com> Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com> Co-authored-by: Ikko Ashimine <eltociear@gmail.com> Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com> Co-authored-by: lwh <lwhile521@gmail.com> Co-authored-by: Seungbae.yu <72970043+dbadoy@users.noreply.github.com> Co-authored-by: Péter Szilágyi <peterke@gmail.com> Co-authored-by: Håvard Anda Estensen <haavard.ae@gmail.com> Co-authored-by: Rajaram Gaunker <zimbabao@gmail.com> Co-authored-by: henridf <henri@dubfer.com> Co-authored-by: int88 <106391185+int88@users.noreply.github.com> Co-authored-by: Luozhu <70309026+LuozhuZhang@users.noreply.github.com> Co-authored-by: Gustavo Silva <GustavoRSSilva@users.noreply.github.com> Co-authored-by: Ivan Aracki <aracki.ivan@gmail.com> Co-authored-by: lmittmann <lmittmann@users.noreply.github.com> Co-authored-by: Kosuke Taniguchi <73885532+TaniguchiKosuke@users.noreply.github.com> Co-authored-by: Zachinquarantine <Zachinquarantine@protonmail.com> Co-authored-by: ucwong <ucwong@126.com> Co-authored-by: lightclient@protonmail.com <lightclient@protonmail.com> Co-authored-by: willian.eth <willian@ufpa.br> Co-authored-by: zeim839 <50573884+zeim839@users.noreply.github.com> Co-authored-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Co-authored-by: Ruohui Wang <nomaru@outlook.com> Co-authored-by: Andre Patta <andre_luis@outlook.com> Co-authored-by: スパイク <1311798+spkjp@users.noreply.github.com> Co-authored-by: Marius Kjærstad <mkjaerstad@protonmail.com> Co-authored-by: Brion <4777457+cifer76@users.noreply.github.com> Co-authored-by: Philip Fan <fanwengang@hotmail.com> Co-authored-by: Jens W <8270201+DragonDev1906@users.noreply.github.com> Co-authored-by: Jens <jmw.1906@gmx.de> Co-authored-by: henridf <henridf@gmail.com> Co-authored-by: Lee Bousfield <ljbousfield@gmail.com> Co-authored-by: Ha ĐANG <dvietha@gmail.com> Co-authored-by: jwasinger <j-wasinger@hotmail.com> Co-authored-by: Nikhil Suri <nikhilsuri@comcast.net> Co-authored-by: Abirdcfly <fp544037857@gmail.com> Co-authored-by: Eval EXEC <execvy@gmail.com> Co-authored-by: Delweng <delweng@gmail.com> Co-authored-by: Rithwik Babu <rithwikbabu2020@gmail.com> Co-authored-by: Henry <101552941+henry-0@users.noreply.github.com> Co-authored-by: Manoj Kumar <mnjkmr398@gmail.com> Co-authored-by: Tristan-Wilson <87238672+Tristan-Wilson@users.noreply.github.com> Co-authored-by: yong <33920876+yzhaoyu@users.noreply.github.com> Co-authored-by: Seungbae Yu <dbadoy4874@gmail.com> Co-authored-by: ycyraum <ycyraum@fastmail.com> Co-authored-by: 0xe3b0c4 <110295932+0xe3b0c4@users.noreply.github.com> Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org> Co-authored-by: bobpkr <bob.p@krustuniverse.com> Co-authored-by: Justin Traglia <95511699+jtraglia@users.noreply.github.com> Co-authored-by: zhiqiangxu <652732310@qq.com> Co-authored-by: Jordan Krage <jmank88@gmail.com>
1 parent 2693bc8 commit 3da440b

File tree

489 files changed

+10832
-8760
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

489 files changed

+10832
-8760
lines changed

.golangci.yml

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,55 @@ linters:
1919
- govet
2020
- ineffassign
2121
- misspell
22-
# - staticcheck
2322
- unconvert
24-
# - unused
2523
- varcheck
24+
- typecheck
25+
- unused
26+
- staticcheck
27+
- bidichk
28+
- durationcheck
29+
- exportloopref
30+
- gosec
31+
- whitespace
32+
33+
# - structcheck # lots of false positives
34+
# - errcheck #lot of false positives
35+
# - contextcheck
36+
# - errchkjson # lots of false positives
37+
# - errorlint # this check crashes
38+
# - exhaustive # silly check
39+
# - makezero # false positives
40+
# - nilerr # several intentional
2641

2742
linters-settings:
2843
gofmt:
2944
simplify: true
3045
goconst:
3146
min-len: 3 # minimum length of string constant
3247
min-occurrences: 6 # minimum number of occurrences
48+
gosec:
49+
excludes:
50+
- G404 # Use of weak random number generator - lots of FP
51+
- G107 # Potential http request -- those are intentional
52+
- G306 # G306: Expect WriteFile permissions to be 0600 or less
3353

3454
issues:
3555
exclude-rules:
36-
- path: crypto/blake2b/
37-
linters:
38-
- deadcode
39-
- path: crypto/bn256/cloudflare
40-
linters:
41-
- deadcode
42-
- path: p2p/discv5/
43-
linters:
44-
- deadcode
45-
- path: core/vm/instructions_test.go
46-
linters:
47-
- goconst
48-
- path: cmd/faucet/
56+
- path: crypto/bn256/cloudflare/optate.go
4957
linters:
5058
- deadcode
59+
- staticcheck
60+
- path: internal/build/pgp.go
61+
text: 'SA1019: package golang.org/x/crypto/openpgp is deprecated'
62+
- path: core/vm/contracts.go
63+
text: 'SA1019: package golang.org/x/crypto/ripemd160 is deprecated'
64+
- path: accounts/usbwallet/trezor.go
65+
text: 'SA1019: package github.com/golang/protobuf/proto is deprecated'
66+
- path: accounts/usbwallet/trezor/
67+
text: 'SA1019: package github.com/golang/protobuf/proto is deprecated'
68+
exclude:
69+
- 'SA1019: event.TypeMux is deprecated: use Feed'
70+
- 'SA1019: strings.Title is deprecated'
71+
- 'SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.'
72+
- 'SA1029: should not use built-in type string as key for value'
73+
- 'G306: Expect WriteFile permissions to be 0600 or less'

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ COPY go.sum /go-ethereum/
1414
RUN cd /go-ethereum && go mod download
1515

1616
ADD . /go-ethereum
17-
RUN cd /go-ethereum && go run build/ci.go install ./cmd/geth
17+
RUN cd /go-ethereum && go run build/ci.go install -static ./cmd/geth
1818

1919
# Pull Geth into a second stage deploy alpine container
2020
FROM alpine:latest

Dockerfile.alltools

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ COPY go.sum /go-ethereum/
1414
RUN cd /go-ethereum && go mod download
1515

1616
ADD . /go-ethereum
17-
RUN cd /go-ethereum && go run build/ci.go install
17+
RUN cd /go-ethereum && go run build/ci.go install -static
1818

1919
# Pull all binaries into a second stage deploy alpine container
2020
FROM alpine:latest

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ directory.
4242
| `abigen` | Source code generator to convert Ethereum contract definitions into easy to use, compile-time type-safe Go packages. It operates on plain [Ethereum contract ABIs](https://docs.soliditylang.org/en/develop/abi-spec.html) with expanded functionality if the contract bytecode is also available. However, it also accepts Solidity source files, making development much more streamlined. Please see our [Native DApps](https://geth.ethereum.org/docs/dapp/native-bindings) page for details. |
4343
| `bootnode` | Stripped down version of our Ethereum client implementation that only takes part in the network node discovery protocol, but does not run any of the higher level application protocols. It can be used as a lightweight bootstrap node to aid in finding peers in private networks. |
4444
| `evm` | Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode. Its purpose is to allow isolated, fine-grained debugging of EVM opcodes (e.g. `evm --code 60ff60ff --debug run`). |
45-
| `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://eth.wiki/en/fundamentals/rlp)) dumps (data encoding used by the Ethereum protocol both network as well as consensus wise) to user-friendlier hierarchical representation (e.g. `rlpdump --hex CE0183FFFFFFC4C304050583616263`). |
45+
| `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp)) dumps (data encoding used by the Ethereum protocol both network as well as consensus wise) to user-friendlier hierarchical representation (e.g. `rlpdump --hex CE0183FFFFFFC4C304050583616263`). |
4646
| `puppeth` | a CLI wizard that aids in creating a new Ethereum network. |
4747

4848
## Running `geth`
@@ -188,7 +188,7 @@ accessible from the outside.
188188

189189
As a developer, sooner rather than later you'll want to start interacting with `geth` and the
190190
Ethereum network via your own programs and not manually through the console. To aid
191-
this, `geth` has built-in support for a JSON-RPC based APIs ([standard APIs](https://eth.wiki/json-rpc/API)
191+
this, `geth` has built-in support for a JSON-RPC based APIs ([standard APIs](https://ethereum.github.io/execution-apis/api-documentation/)
192192
and [`geth` specific APIs](https://geth.ethereum.org/docs/rpc/server)).
193193
These can be exposed via HTTP, WebSockets and IPC (UNIX sockets on UNIX based
194194
platforms, and named pipes on Windows).
@@ -211,7 +211,7 @@ HTTP based JSON-RPC API options:
211211
* `--ws.api` API's offered over the WS-RPC interface (default: `eth,net,web3`)
212212
* `--ws.origins` Origins from which to accept websockets requests
213213
* `--ipcdisable` Disable the IPC-RPC server
214-
* `--ipcapi` API's offered over the IPC-RPC interface (default: `admin,debug,eth,miner,net,personal,shh,txpool,web3`)
214+
* `--ipcapi` API's offered over the IPC-RPC interface (default: `admin,debug,eth,miner,net,personal,txpool,web3`)
215215
* `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it)
216216

217217
You'll need to use your own programming environments' capabilities (libraries, tools, etc) to
@@ -297,7 +297,7 @@ $ bootnode --genkey=boot.key
297297
$ bootnode --nodekey=boot.key
298298
```
299299

300-
With the bootnode online, it will display an [`enode` URL](https://eth.wiki/en/fundamentals/enode-url-format)
300+
With the bootnode online, it will display an [`enode` URL](https://ethereum.org/en/developers/docs/networking-layer/network-addresses/#enode)
301301
that other nodes can use to connect to it and exchange peer information. Make sure to
302302
replace the displayed IP address information (most probably `[::]`) with your externally
303303
accessible IP to get the actual `enode` URL.

accounts/abi/abi.go

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (abi ABI) getArguments(name string, data []byte) (Arguments, error) {
9595
args = event.Inputs
9696
}
9797
if args == nil {
98-
return nil, errors.New("abi: could not locate named method or event")
98+
return nil, fmt.Errorf("abi: could not locate named method or event: %s", name)
9999
}
100100
return args, nil
101101
}
@@ -164,7 +164,7 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
164164
case "constructor":
165165
abi.Constructor = NewMethod("", "", Constructor, field.StateMutability, field.Constant, field.Payable, field.Inputs, nil)
166166
case "function":
167-
name := overloadedName(field.Name, func(s string) bool { _, ok := abi.Methods[s]; return ok })
167+
name := ResolveNameConflict(field.Name, func(s string) bool { _, ok := abi.Methods[s]; return ok })
168168
abi.Methods[name] = NewMethod(name, field.Name, Function, field.StateMutability, field.Constant, field.Payable, field.Inputs, field.Outputs)
169169
case "fallback":
170170
// New introduced function type in v0.6.0, check more detail
@@ -184,9 +184,11 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
184184
}
185185
abi.Receive = NewMethod("", "", Receive, field.StateMutability, field.Constant, field.Payable, nil, nil)
186186
case "event":
187-
name := overloadedName(field.Name, func(s string) bool { _, ok := abi.Events[s]; return ok })
187+
name := ResolveNameConflict(field.Name, func(s string) bool { _, ok := abi.Events[s]; return ok })
188188
abi.Events[name] = NewEvent(name, field.Name, field.Anonymous, field.Inputs)
189189
case "error":
190+
// Errors cannot be overloaded or overridden but are inherited,
191+
// no need to resolve the name conflict here.
190192
abi.Errors[field.Name] = NewError(field.Name, field.Inputs)
191193
default:
192194
return fmt.Errorf("abi: could not recognize type %v of field %v", field.Type, field.Name)
@@ -251,20 +253,3 @@ func UnpackRevert(data []byte) (string, error) {
251253
}
252254
return unpacked[0].(string), nil
253255
}
254-
255-
// overloadedName returns the next available name for a given thing.
256-
// Needed since solidity allows for overloading.
257-
//
258-
// e.g. if the abi contains Methods send, send1
259-
// overloadedName would return send2 for input send.
260-
//
261-
// overloadedName works for methods, events and errors.
262-
func overloadedName(rawName string, isAvail func(string) bool) string {
263-
name := rawName
264-
ok := isAvail(name)
265-
for idx := 0; ok; idx++ {
266-
name = fmt.Sprintf("%s%d", rawName, idx)
267-
ok = isAvail(name)
268-
}
269-
return name
270-
}

accounts/abi/abi_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,9 +1038,7 @@ func TestABI_EventById(t *testing.T) {
10381038
}
10391039
if event == nil {
10401040
t.Errorf("We should find a event for topic %s, test #%d", topicID.Hex(), testnum)
1041-
}
1042-
1043-
if event.ID != topicID {
1041+
} else if event.ID != topicID {
10441042
t.Errorf("Event id %s does not match topic %s, test #%d", event.ID.Hex(), topicID.Hex(), testnum)
10451043
}
10461044

accounts/abi/argument.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package abi
1818

1919
import (
2020
"encoding/json"
21+
"errors"
2122
"fmt"
2223
"reflect"
2324
"strings"
@@ -79,7 +80,7 @@ func (arguments Arguments) isTuple() bool {
7980
func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
8081
if len(data) == 0 {
8182
if len(arguments.NonIndexed()) != 0 {
82-
return nil, fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
83+
return nil, errors.New("abi: attempting to unmarshall an empty string while arguments are expected")
8384
}
8485
return make([]interface{}, 0), nil
8586
}
@@ -90,11 +91,11 @@ func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
9091
func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte) error {
9192
// Make sure map is not nil
9293
if v == nil {
93-
return fmt.Errorf("abi: cannot unpack into a nil map")
94+
return errors.New("abi: cannot unpack into a nil map")
9495
}
9596
if len(data) == 0 {
9697
if len(arguments.NonIndexed()) != 0 {
97-
return fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
98+
return errors.New("abi: attempting to unmarshall an empty string while arguments are expected")
9899
}
99100
return nil // Nothing to unmarshal, return
100101
}
@@ -116,7 +117,7 @@ func (arguments Arguments) Copy(v interface{}, values []interface{}) error {
116117
}
117118
if len(values) == 0 {
118119
if len(arguments.NonIndexed()) != 0 {
119-
return fmt.Errorf("abi: attempting to copy no values while arguments are expected")
120+
return errors.New("abi: attempting to copy no values while arguments are expected")
120121
}
121122
return nil // Nothing to copy, return
122123
}

accounts/abi/bind/backends/simulated.go

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ type SimulatedBackend struct {
6363
database ethdb.Database // In memory database to store our testing data
6464
blockchain *core.BlockChain // Ethereum blockchain to handle the consensus
6565

66-
mu sync.Mutex
67-
pendingBlock *types.Block // Currently pending block that will be imported on request
68-
pendingState *state.StateDB // Currently pending state that will be the active on request
66+
mu sync.Mutex
67+
pendingBlock *types.Block // Currently pending block that will be imported on request
68+
pendingState *state.StateDB // Currently pending state that will be the active on request
69+
pendingReceipts types.Receipts // Currently receipts for the pending block
6970

70-
events *filters.EventSystem // Event system for filtering log events live
71+
events *filters.EventSystem // for filtering log events live
72+
filterSystem *filters.FilterSystem // for filtering database logs
7173

7274
config *params.ChainConfig
7375
}
@@ -84,8 +86,12 @@ func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.Genesis
8486
database: database,
8587
blockchain: blockchain,
8688
config: genesis.Config,
87-
events: filters.NewEventSystem(&filterBackend{database, blockchain}, false),
8889
}
90+
91+
filterBackend := &filterBackend{database, blockchain, backend}
92+
backend.filterSystem = filters.NewFilterSystem(filterBackend, filters.Config{})
93+
backend.events = filters.NewEventSystem(backend.filterSystem, false)
94+
8995
backend.rollback(blockchain.CurrentBlock())
9096
return backend
9197
}
@@ -105,16 +111,20 @@ func (b *SimulatedBackend) Close() error {
105111

106112
// Commit imports all the pending transactions as a single block and starts a
107113
// fresh new state.
108-
func (b *SimulatedBackend) Commit() {
114+
func (b *SimulatedBackend) Commit() common.Hash {
109115
b.mu.Lock()
110116
defer b.mu.Unlock()
111117

112118
if _, err := b.blockchain.InsertChain([]*types.Block{b.pendingBlock}); err != nil {
113119
panic(err) // This cannot happen unless the simulator is wrong, fail in that case
114120
}
121+
blockHash := b.pendingBlock.Hash()
122+
115123
// Using the last inserted block here makes it possible to build on a side
116124
// chain after a fork.
117125
b.rollback(b.pendingBlock)
126+
127+
return blockHash
118128
}
119129

120130
// Rollback aborts all pending transactions, reverting to the last committed state.
@@ -604,7 +614,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
604614
// User specified the legacy gas field, convert to 1559 gas typing
605615
call.GasFeeCap, call.GasTipCap = call.GasPrice, call.GasPrice
606616
} else {
607-
// User specified 1559 gas feilds (or none), use those
617+
// User specified 1559 gas fields (or none), use those
608618
if call.GasFeeCap == nil {
609619
call.GasFeeCap = new(big.Int)
610620
}
@@ -662,7 +672,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
662672
return fmt.Errorf("invalid transaction nonce: got %d, want %d", tx.Nonce(), nonce)
663673
}
664674
// Include tx in chain
665-
blocks, _ := core.GenerateChain(b.config, block, ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) {
675+
blocks, receipts := core.GenerateChain(b.config, block, ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) {
666676
for _, tx := range b.pendingBlock.Transactions() {
667677
block.AddTxWithChain(b.blockchain, tx)
668678
}
@@ -672,6 +682,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
672682

673683
b.pendingBlock = blocks[0]
674684
b.pendingState, _ = state.New(b.pendingBlock.Root(), stateDB.Database(), nil)
685+
b.pendingReceipts = receipts[0]
675686
return nil
676687
}
677688

@@ -683,7 +694,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.Filter
683694
var filter *filters.Filter
684695
if query.BlockHash != nil {
685696
// Block filter requested, construct a single-shot filter
686-
filter = filters.NewBlockFilter(&filterBackend{b.database, b.blockchain}, *query.BlockHash, query.Addresses, query.Topics)
697+
filter = b.filterSystem.NewBlockFilter(*query.BlockHash, query.Addresses, query.Topics)
687698
} else {
688699
// Initialize unset filter boundaries to run from genesis to chain head
689700
from := int64(0)
@@ -695,7 +706,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.Filter
695706
to = query.ToBlock.Int64()
696707
}
697708
// Construct the range filter
698-
filter = filters.NewRangeFilter(&filterBackend{b.database, b.blockchain}, from, to, query.Addresses, query.Topics)
709+
filter = b.filterSystem.NewRangeFilter(from, to, query.Addresses, query.Topics)
699710
}
700711
// Run the filter and return all the logs
701712
logs, err := filter.Logs(ctx)
@@ -816,11 +827,13 @@ func (m callMsg) AccessList() types.AccessList { return m.CallMsg.AccessList }
816827
// filterBackend implements filters.Backend to support filtering for logs without
817828
// taking bloom-bits acceleration structures into account.
818829
type filterBackend struct {
819-
db ethdb.Database
820-
bc *core.BlockChain
830+
db ethdb.Database
831+
bc *core.BlockChain
832+
backend *SimulatedBackend
821833
}
822834

823-
func (fb *filterBackend) ChainDb() ethdb.Database { return fb.db }
835+
func (fb *filterBackend) ChainDb() ethdb.Database { return fb.db }
836+
824837
func (fb *filterBackend) EventMux() *event.TypeMux { panic("not supported") }
825838

826839
func (fb *filterBackend) HeaderByNumber(ctx context.Context, block rpc.BlockNumber) (*types.Header, error) {
@@ -834,6 +847,10 @@ func (fb *filterBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*t
834847
return fb.bc.GetHeaderByHash(hash), nil
835848
}
836849

850+
func (fb *filterBackend) PendingBlockAndReceipts() (*types.Block, types.Receipts) {
851+
return fb.backend.pendingBlock, fb.backend.pendingReceipts
852+
}
853+
837854
func (fb *filterBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
838855
number := rawdb.ReadHeaderNumber(fb.db, hash)
839856
if number == nil {
@@ -842,19 +859,8 @@ func (fb *filterBackend) GetReceipts(ctx context.Context, hash common.Hash) (typ
842859
return rawdb.ReadReceipts(fb.db, hash, *number, fb.bc.Config()), nil
843860
}
844861

845-
func (fb *filterBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error) {
846-
number := rawdb.ReadHeaderNumber(fb.db, hash)
847-
if number == nil {
848-
return nil, nil
849-
}
850-
receipts := rawdb.ReadReceipts(fb.db, hash, *number, fb.bc.Config())
851-
if receipts == nil {
852-
return nil, nil
853-
}
854-
logs := make([][]*types.Log, len(receipts))
855-
for i, receipt := range receipts {
856-
logs[i] = receipt.Logs
857-
}
862+
func (fb *filterBackend) GetLogs(ctx context.Context, hash common.Hash, number uint64) ([][]*types.Log, error) {
863+
logs := rawdb.ReadLogs(fb.db, hash, number, fb.bc.Config())
858864
return logs, nil
859865
}
860866

0 commit comments

Comments
 (0)