Skip to content

Commit 1742414

Browse files
author
Abdul Rabbani
committed
Squashed commit of the following:
commit 23bee16 Author: Péter Szilágyi <peterke@gmail.com> Date: Wed Jun 15 15:35:32 2022 +0300 params: release Geth v1.10.19 commit d78d302 Author: Marius van der Wijden <m.vanderwijden@live.de> Date: Wed Jun 15 14:35:53 2022 +0200 node: add info message when JWT secret is loaded (ethereum#25095) Co-authored-by: Felix Lange <fjl@twurst.com> commit d8f9638 Author: Marius van der Wijden <m.vanderwijden@live.de> Date: Wed Jun 15 13:10:38 2022 +0200 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 commit 3060216 Author: rjl493456442 <garyrong0905@gmail.com> Date: Wed Jun 15 18:56:47 2022 +0800 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> commit 3273ad1 Author: lightclient <14004106+lightclient@users.noreply.github.com> Date: Wed Jun 15 09:29:23 2022 +0200 eth: add missing period at end of sentences (ethereum#25058) eth: add missing periods on end of comments commit bc013bc Author: lmittmann <lmittmann@users.noreply.github.com> Date: Tue Jun 14 14:09:48 2022 +0200 all: prefer `new(big.Int)` over `big.NewInt(0)` (ethereum#25087) minor performance improvement: `big.NewInt(0).Xxx` -> `new(big.Int).Xxx` commit 8cfd121 Author: Marius van der Wijden <m.vanderwijden@live.de> Date: Tue Jun 14 14:08:43 2022 +0200 common: improve pretty duration regex (ethereum#25073) * common: improve pretty duration regex * common: improve pretty duration regex commit 6ad620d Author: s7v7nislands <s7v7nislands@gmail.com> Date: Tue Jun 14 19:47:11 2022 +0800 cmd/ethkey: use accounts.TextHash (ethereum#25069) commit 1cf58c7 Author: lightclient <14004106+lightclient@users.noreply.github.com> Date: Tue Jun 14 12:59:05 2022 +0200 readme,eth: remove references to eth.wiki (ethereum#25086) commit f74bb3a Author: Ivan Aracki <aracki.ivan@gmail.com> Date: Tue Jun 14 10:24:29 2022 +0200 cmd/utils: update --ropsten description (ethereum#25078) commit a907d7e Author: Martin Holst Swende <martin@swende.se> Date: Mon Jun 13 16:24:45 2022 +0200 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. commit eb94896 Author: Gustavo Silva <GustavoRSSilva@users.noreply.github.com> Date: Fri Jun 10 16:47:06 2022 +0100 Chore: Minimal gramatical errors (signleton -> singleton) (ethereum#25057) core: fix typos commit 3f5b5ec Author: Luozhu <70309026+LuozhuZhang@users.noreply.github.com> Date: Fri Jun 10 16:57:32 2022 +0800 internal/ethapi: fix typo in comment (ethereum#25056) typo error: keccack256 -> keccak256 commit 594e321 Author: int88 <106391185+int88@users.noreply.github.com> Date: Thu Jun 9 00:40:37 2022 +0800 core/evm: fix error in comment (ethereum#25040) Co-authored-by: Martin Holst Swende <martin@swende.se> commit f503718 Author: henridf <henri@dubfer.com> Date: Wed Jun 8 18:32:07 2022 +0200 core/types: improve LogForStorage and ReceiptForStorage comments (ethereum#25032) Co-authored-by: Felix Lange <fjl@twurst.com> commit 6160296 Author: Rajaram Gaunker <zimbabao@gmail.com> Date: Wed Jun 8 09:31:43 2022 -0700 core/types: remove unused field 'td' in Block (ethereum#25010) commit b60a08d Author: Martin Holst Swende <martin@swende.se> Date: Wed Jun 8 15:36:25 2022 +0200 eth/catalyst: remove unauthenticated 'engine' api (ethereum#24997) Removes engine from any unauthenticated RPC service. commit c4dab8c Merge: 138f0d7 106a162 Author: Péter Szilágyi <peterke@gmail.com> Date: Wed Jun 8 16:34:43 2022 +0300 Merge pull request ethereum#25044 from karalabe/rpc-histograms rpc: swap out timer metrics to histograms commit 106a162 Author: Péter Szilágyi <peterke@gmail.com> Date: Wed Jun 8 16:24:33 2022 +0300 rpc: swap out timer metrics to histograms commit 138f0d7 Author: Håvard Anda Estensen <haavard.ae@gmail.com> Date: Tue Jun 7 17:27:21 2022 +0200 p2p: use errors.Is for error comparison (ethereum#24882) Co-authored-by: Felix Lange <fjl@twurst.com> commit 41e7548 Author: Péter Szilágyi <peterke@gmail.com> Date: Tue Jun 7 13:49:07 2022 +0300 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. commit 450f5da Author: Seungbae.yu <72970043+dbadoy@users.noreply.github.com> Date: Tue Jun 7 19:46:27 2022 +0900 accounts: increase parseURL test coverage (ethereum#25033) accounts/url: add test logic what check null string to parseURL() commit 403624a Author: Martin Holst Swende <martin@swende.se> Date: Tue Jun 7 12:15:22 2022 +0200 p2p/discover: fix panicky test (ethereum#25038) commit 5e8fa1d Author: Marius van der Wijden <m.vanderwijden@live.de> Date: Tue Jun 7 09:06:34 2022 +0200 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 commit 84b3272 Author: lwh <lwhile521@gmail.com> Date: Tue Jun 7 14:38:54 2022 +0800 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> commit d9566e3 Author: Sina Mahmoodi <1591639+s1na@users.noreply.github.com> Date: Tue Jun 7 08:31:19 2022 +0200 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 commit 7e9514b Author: Martin Holst Swende <martin@swende.se> Date: Tue Jun 7 08:11:01 2022 +0200 params: update ropsten terminal total difficulty block (ethereum#25018) commit 6b3e6cb Author: aaronbuchwald <aaron.buchwald56@gmail.com> Date: Tue Jun 7 02:02:04 2022 -0400 trie: move locking into trieDB insert method (ethereum#25030) Move locking into trieDB insert function commit 096daa9 Author: Ikko Ashimine <eltociear@gmail.com> Date: Tue Jun 7 00:55:16 2022 +0900 eth/tracers: fix typo in 4byte_tracer_legacy.js (ethereum#25020) indentifier -> identifier commit 10da980 Author: lightclient <14004106+lightclient@users.noreply.github.com> Date: Mon Jun 6 17:33:05 2022 +0200 eth/api: use `hexutil.Bytes` for account range method (ethereum#25024) eth/api: use hexutil.Bytes for range at methods commit 22defa5 Author: rjl493456442 <garyrong0905@gmail.com> Date: Mon Jun 6 23:14:55 2022 +0800 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> commit c375ee9 Author: Martin Holst Swende <martin@swende.se> Date: Mon Jun 6 17:09:39 2022 +0200 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 (#37) * core/state/snapshot: minor nits * core/state/snapshot: simplify error logic * cmd/geth: go format Co-authored-by: rjl493456442 <garyrong0905@gmail.com> commit d6b5574 Author: Marius van der Wijden <m.vanderwijden@live.de> Date: Mon Jun 6 17:01:59 2022 +0200 tests/fuzzers/bls12381: fix blst deserializing (ethereum#25036) * tests/fuzzers/bls12381: fix blst deserializing * tests/fuzzers/bls12381: fix blst deserializing commit 997f1c4 Author: Paweł Bylica <chfast@gmail.com> Date: Fri Jun 3 10:40:14 2022 +0200 core/vm: optimize jumpdest analysis (ethereum#23500) core/vm: optimize PUSH opcode discrimination commit b453767 Author: s7v7nislands <s7v7nislands@gmail.com> Date: Fri Jun 3 15:25:25 2022 +0800 go.mod: clean up (ethereum#25017) commit 5bc4e8f Author: Jonathan Le Brun <42697488+icyfry@users.noreply.github.com> Date: Thu Jun 2 20:26:44 2022 +0200 go.mod: set go version to 1.17 (ethereum#24926) set go version to 1.17 commit 490c45c Author: Ivan Kuznetsov <me@jeiwan.ru> Date: Fri Jun 3 01:25:12 2022 +0700 consensus/misc: reduce allocations and improve comments in CalcBaseFee (ethereum#24958) * consensus/misc: reduce allocations in CalcBaseFee * consensus/misc: add formulas of CalcBaseFee commit 6f075bf Author: Martin Holst Swende <martin@swende.se> Date: Thu Jun 2 20:21:35 2022 +0200 node: make jwt test less dependent on time (ethereum#25016) commit 2227589 Author: Marius van der Wijden <m.vanderwijden@live.de> Date: Thu Jun 2 13:15:17 2022 +0200 eth/catalyst: return 0x0 on Invalid block on top of pow block (ethereum#25006) commit 3c6d6f7 Author: Marius van der Wijden <m.vanderwijden@live.de> Date: Thu Jun 2 13:13:28 2022 +0200 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 commit d8a2305 Author: Martin Holst Swende <martin@swende.se> Date: Thu Jun 2 11:39:36 2022 +0200 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. commit f9806dc Author: rjl493456442 <garyrong0905@gmail.com> Date: Wed Jun 1 17:03:24 2022 +0800 core: fix canonical hash marker update (ethereum#24996) * core: fix reorg * core: revert change for memory efficiency * core: revert changes commit 8c0c043 Author: Marius van der Wijden <m.vanderwijden@live.de> Date: Tue May 31 11:11:50 2022 +0200 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> commit 03157b6 Author: Boqin Qin(秦 伯钦) <Bobbqqin@gmail.com> Date: Tue May 31 02:35:37 2022 +0800 eth/filters: use buffered channel to avoid goroutine leak (ethereum#24928) commit 2140aab Author: Martin Holst Swende <martin@swende.se> Date: Mon May 30 14:45:27 2022 +0200 contracs/checkpointoracle: fix directives (ethereum#24944) contracts/checkpointoracle: redefine go-generate logic commit 93fe175 Author: Marius van der Wijden <m.vanderwijden@live.de> Date: Mon May 30 13:28:15 2022 +0200 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 commit 8845227 Author: Harry Kalodner <harry.kalodner@gmail.com> Date: Mon May 30 07:00:23 2022 -0400 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> commit a10660b Author: rjl493456442 <garyrong0905@gmail.com> Date: Mon May 30 18:37:42 2022 +0800 cmd/geth: extend traverseRawState command (ethereum#24954) This PR adds node verification into traverseRawState command, so corrupted trie nodes can also be detected. commit 86af788 Author: Marius van der Wijden <m.vanderwijden@live.de> Date: Mon May 30 08:42:06 2022 +0200 core: use less memory during reorgs (ethereum#24616) This PR significantly reduces the memory consumption of a long reorg commit be97427 Author: Marius van der Wijden <m.vanderwijden@live.de> Date: Fri May 27 08:23:55 2022 +0200 params: set emergency ropsten TTD to 100_000_000_000_000_000_000_000 (ethereum#24975) commit 0287e1a Author: Martin Holst Swende <martin@swende.se> Date: Thu May 26 09:26:37 2022 +0200 cmd/abigen: accept combined-json via stdin (ethereum#24960) commit 0559a9a Author: Sina Mahmoodi <1591639+s1na@users.noreply.github.com> Date: Thu May 26 09:22:10 2022 +0200 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. commit d575a2d Author: Felix Lange <fjl@twurst.com> Date: Wed May 25 14:44:52 2022 +0200 params: begin v1.10.19 release cycle
1 parent 8593cfd commit 1742414

File tree

192 files changed

+2121
-1512
lines changed

Some content is hidden

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

192 files changed

+2121
-1512
lines changed

.golangci.yml

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,53 @@ 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+
32+
#- structcheck # lots of false positives
33+
#- errcheck #lot of false positives
34+
# - contextcheck
35+
# - errchkjson # lots of false positives
36+
# - errorlint # this check crashes
37+
# - exhaustive # silly check
38+
# - makezero # false positives
39+
# - nilerr # several intentional
2640

2741
linters-settings:
2842
gofmt:
2943
simplify: true
3044
goconst:
3145
min-len: 3 # minimum length of string constant
3246
min-occurrences: 6 # minimum number of occurrences
47+
gosec:
48+
excludes:
49+
- G404 # Use of weak random number generator - lots of FP
50+
- G107 # Potential http request -- those are intentional
51+
- G306 # G306: Expect WriteFile permissions to be 0600 or less
3352

3453
issues:
3554
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/
55+
- path: crypto/bn256/cloudflare/optate.go
4956
linters:
5057
- deadcode
58+
- staticcheck
59+
- path: internal/build/pgp.go
60+
text: 'SA1019: package golang.org/x/crypto/openpgp is deprecated'
61+
- path: core/vm/contracts.go
62+
text: 'SA1019: package golang.org/x/crypto/ripemd160 is deprecated'
63+
- path: accounts/usbwallet/trezor.go
64+
text: 'SA1019: package github.com/golang/protobuf/proto is deprecated'
65+
- path: accounts/usbwallet/trezor/
66+
text: 'SA1019: package github.com/golang/protobuf/proto is deprecated'
67+
exclude:
68+
- 'SA1019: event.TypeMux is deprecated: use Feed'
69+
- 'SA1019: strings.Title is deprecated'
70+
- 'SA1029: should not use built-in type string as key for value'
71+
- 'G306: Expect WriteFile permissions to be 0600 or less'

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ directory.
5555
| `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. |
5656
| `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. |
5757
| `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`). |
58-
| `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`). |
58+
| `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`). |
5959
| `puppeth` | a CLI wizard that aids in creating a new Ethereum network. |
6060

6161
## Running `geth`
@@ -202,7 +202,7 @@ accessible from the outside.
202202

203203
As a developer, sooner rather than later you'll want to start interacting with `geth` and the
204204
Ethereum network via your own programs and not manually through the console. To aid
205-
this, `geth` has built-in support for a JSON-RPC based APIs ([standard APIs](https://eth.wiki/json-rpc/API)
205+
this, `geth` has built-in support for a JSON-RPC based APIs ([standard APIs](https://ethereum.github.io/execution-apis/api-documentation/)
206206
and [`geth` specific APIs](https://geth.ethereum.org/docs/rpc/server)).
207207
These can be exposed via HTTP, WebSockets and IPC (UNIX sockets on UNIX based
208208
platforms, and named pipes on Windows).
@@ -311,7 +311,7 @@ $ bootnode --genkey=boot.key
311311
$ bootnode --nodekey=boot.key
312312
```
313313

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

accounts/abi/abi.go

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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/bind/backends/simulated.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ 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

7071
events *filters.EventSystem // Event system for filtering log events live
7172

@@ -84,8 +85,8 @@ func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.Genesis
8485
database: database,
8586
blockchain: blockchain,
8687
config: genesis.Config,
87-
events: filters.NewEventSystem(&filterBackend{database, blockchain}, false),
8888
}
89+
backend.events = filters.NewEventSystem(&filterBackend{database, blockchain, backend}, false)
8990
backend.rollback(blockchain.CurrentBlock())
9091
return backend
9192
}
@@ -662,7 +663,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
662663
return fmt.Errorf("invalid transaction nonce: got %d, want %d", tx.Nonce(), nonce)
663664
}
664665
// Include tx in chain
665-
blocks, _ := core.GenerateChain(b.config, block, ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) {
666+
blocks, receipts := core.GenerateChain(b.config, block, ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) {
666667
for _, tx := range b.pendingBlock.Transactions() {
667668
block.AddTxWithChain(b.blockchain, tx)
668669
}
@@ -672,6 +673,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
672673

673674
b.pendingBlock = blocks[0]
674675
b.pendingState, _ = state.New(b.pendingBlock.Root(), stateDB.Database(), nil)
676+
b.pendingReceipts = receipts[0]
675677
return nil
676678
}
677679

@@ -683,7 +685,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.Filter
683685
var filter *filters.Filter
684686
if query.BlockHash != nil {
685687
// Block filter requested, construct a single-shot filter
686-
filter = filters.NewBlockFilter(&filterBackend{b.database, b.blockchain}, *query.BlockHash, query.Addresses, query.Topics)
688+
filter = filters.NewBlockFilter(&filterBackend{b.database, b.blockchain, b}, *query.BlockHash, query.Addresses, query.Topics)
687689
} else {
688690
// Initialize unset filter boundaries to run from genesis to chain head
689691
from := int64(0)
@@ -695,7 +697,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.Filter
695697
to = query.ToBlock.Int64()
696698
}
697699
// Construct the range filter
698-
filter = filters.NewRangeFilter(&filterBackend{b.database, b.blockchain}, from, to, query.Addresses, query.Topics)
700+
filter = filters.NewRangeFilter(&filterBackend{b.database, b.blockchain, b}, from, to, query.Addresses, query.Topics)
699701
}
700702
// Run the filter and return all the logs
701703
logs, err := filter.Logs(ctx)
@@ -816,8 +818,9 @@ func (m callMsg) AccessList() types.AccessList { return m.CallMsg.AccessList }
816818
// filterBackend implements filters.Backend to support filtering for logs without
817819
// taking bloom-bits acceleration structures into account.
818820
type filterBackend struct {
819-
db ethdb.Database
820-
bc *core.BlockChain
821+
db ethdb.Database
822+
bc *core.BlockChain
823+
backend *SimulatedBackend
821824
}
822825

823826
func (fb *filterBackend) ChainDb() ethdb.Database { return fb.db }
@@ -834,6 +837,10 @@ func (fb *filterBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*t
834837
return fb.bc.GetHeaderByHash(hash), nil
835838
}
836839

840+
func (fb *filterBackend) PendingBlockAndReceipts() (*types.Block, types.Receipts) {
841+
return fb.backend.pendingBlock, fb.backend.pendingReceipts
842+
}
843+
837844
func (fb *filterBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
838845
number := rawdb.ReadHeaderNumber(fb.db, hash)
839846
if number == nil {

accounts/abi/bind/backends/simulated_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,7 @@ func TestHeaderByNumber(t *testing.T) {
655655
}
656656
if latestBlockHeader == nil {
657657
t.Errorf("received a nil block header")
658-
}
659-
if latestBlockHeader.Number.Uint64() != uint64(0) {
658+
} else if latestBlockHeader.Number.Uint64() != uint64(0) {
660659
t.Errorf("expected block header number 0, instead got %v", latestBlockHeader.Number.Uint64())
661660
}
662661

accounts/abi/bind/bind.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
9999
// Normalize the method for capital cases and non-anonymous inputs/outputs
100100
normalized := original
101101
normalizedName := methodNormalizer[lang](alias(aliases, original.Name))
102+
102103
// Ensure there is no duplicated identifier
103104
var identifiers = callIdentifiers
104105
if !original.IsConstant() {
@@ -108,6 +109,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
108109
return "", fmt.Errorf("duplicated identifier \"%s\"(normalized \"%s\"), use --alias for renaming", original.Name, normalizedName)
109110
}
110111
identifiers[normalizedName] = true
112+
111113
normalized.Name = normalizedName
112114
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
113115
copy(normalized.Inputs, original.Inputs)
@@ -152,12 +154,22 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
152154
eventIdentifiers[normalizedName] = true
153155
normalized.Name = normalizedName
154156

157+
used := make(map[string]bool)
155158
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
156159
copy(normalized.Inputs, original.Inputs)
157160
for j, input := range normalized.Inputs {
158161
if input.Name == "" {
159162
normalized.Inputs[j].Name = fmt.Sprintf("arg%d", j)
160163
}
164+
// Event is a bit special, we need to define event struct in binding,
165+
// ensure there is no camel-case-style name conflict.
166+
for index := 0; ; index++ {
167+
if !used[capitalise(normalized.Inputs[j].Name)] {
168+
used[capitalise(normalized.Inputs[j].Name)] = true
169+
break
170+
}
171+
normalized.Inputs[j].Name = fmt.Sprintf("%s%d", normalized.Inputs[j].Name, index)
172+
}
161173
if hasStruct(input.Type) {
162174
bindStructType[lang](input.Type, structs)
163175
}
@@ -432,15 +444,22 @@ func bindStructTypeGo(kind abi.Type, structs map[string]*tmplStruct) string {
432444
if s, exist := structs[id]; exist {
433445
return s.Name
434446
}
435-
var fields []*tmplField
447+
var (
448+
names = make(map[string]bool)
449+
fields []*tmplField
450+
)
436451
for i, elem := range kind.TupleElems {
437-
field := bindStructTypeGo(*elem, structs)
438-
fields = append(fields, &tmplField{Type: field, Name: capitalise(kind.TupleRawNames[i]), SolKind: *elem})
452+
name := capitalise(kind.TupleRawNames[i])
453+
name = abi.ResolveNameConflict(name, func(s string) bool { return names[s] })
454+
names[name] = true
455+
fields = append(fields, &tmplField{Type: bindStructTypeGo(*elem, structs), Name: name, SolKind: *elem})
439456
}
440457
name := kind.TupleRawName
441458
if name == "" {
442459
name = fmt.Sprintf("Struct%d", len(structs))
443460
}
461+
name = capitalise(name)
462+
444463
structs[id] = &tmplStruct{
445464
Name: name,
446465
Fields: fields,

0 commit comments

Comments
 (0)