Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 23bee16
Author: Péter Szilágyi <[email protected]>
Date:   Wed Jun 15 15:35:32 2022 +0300

    params: release Geth v1.10.19

commit d78d302
Author: Marius van der Wijden <[email protected]>
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 <[email protected]>

commit d8f9638
Author: Marius van der Wijden <[email protected]>
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 <[email protected]>
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 <[email protected]>
    Co-authored-by: Martin Holst Swende <[email protected]>

commit 3273ad1
Author: lightclient <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Date:   Tue Jun 14 19:47:11 2022 +0800

    cmd/ethkey: use accounts.TextHash (ethereum#25069)

commit 1cf58c7
Author: lightclient <[email protected]>
Date:   Tue Jun 14 12:59:05 2022 +0200

    readme,eth: remove references to eth.wiki (ethereum#25086)

commit f74bb3a
Author: Ivan Aracki <[email protected]>
Date:   Tue Jun 14 10:24:29 2022 +0200

    cmd/utils: update --ropsten description (ethereum#25078)

commit a907d7e
Author: Martin Holst Swende <[email protected]>
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 <[email protected]>
Date:   Fri Jun 10 16:47:06 2022 +0100

    Chore:  Minimal gramatical errors (signleton -> singleton) (ethereum#25057)

    core: fix typos

commit 3f5b5ec
Author: Luozhu <[email protected]>
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 <[email protected]>
Date:   Thu Jun 9 00:40:37 2022 +0800

    core/evm: fix error in comment (ethereum#25040)

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

commit f503718
Author: henridf <[email protected]>
Date:   Wed Jun 8 18:32:07 2022 +0200

    core/types: improve LogForStorage and ReceiptForStorage comments (ethereum#25032)

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

commit 6160296
Author: Rajaram Gaunker <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Date:   Wed Jun 8 16:24:33 2022 +0300

    rpc: swap out timer metrics to histograms

commit 138f0d7
Author: Håvard Anda Estensen <[email protected]>
Date:   Tue Jun 7 17:27:21 2022 +0200

    p2p: use errors.Is for error comparison (ethereum#24882)

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

commit 41e7548
Author: Péter Szilágyi <[email protected]>
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 <[email protected]>
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 <[email protected]>
Date:   Tue Jun 7 12:15:22 2022 +0200

    p2p/discover: fix panicky test (ethereum#25038)

commit 5e8fa1d
Author: Marius van der Wijden <[email protected]>
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 <[email protected]>
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 <[email protected]>

commit d9566e3
Author: Sina Mahmoodi <[email protected]>
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 <[email protected]>
Date:   Tue Jun 7 08:11:01 2022 +0200

    params: update ropsten terminal total difficulty block (ethereum#25018)

commit 6b3e6cb
Author: aaronbuchwald <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>

commit c375ee9
Author: Martin Holst Swende <[email protected]>
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 <[email protected]>

commit d6b5574
Author: Marius van der Wijden <[email protected]>
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 <[email protected]>
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 <[email protected]>
Date:   Fri Jun 3 15:25:25 2022 +0800

    go.mod: clean up (ethereum#25017)

commit 5bc4e8f
Author: Jonathan Le Brun <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>

    * eth/catalys: go format

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

commit 03157b6
Author: Boqin Qin(秦 伯钦) <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>

commit a10660b
Author: rjl493456442 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Date:   Thu May 26 09:26:37 2022 +0200

    cmd/abigen: accept combined-json via stdin (ethereum#24960)

commit 0559a9a
Author: Sina Mahmoodi <[email protected]>
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 <[email protected]>
Date:   Wed May 25 14:44:52 2022 +0200

    params: begin v1.10.19 release cycle
  • Loading branch information
abdulrabbani00 committed Jun 15, 2022
1 parent 8593cfd commit 1742414
Show file tree
Hide file tree
Showing 192 changed files with 2,121 additions and 1,512 deletions.
51 changes: 36 additions & 15 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,53 @@ linters:
- govet
- ineffassign
- misspell
# - staticcheck
- unconvert
# - unused
- varcheck
- typecheck
- unused
- staticcheck
- bidichk
- durationcheck
- exportloopref
- gosec

#- structcheck # lots of false positives
#- errcheck #lot of false positives
# - contextcheck
# - errchkjson # lots of false positives
# - errorlint # this check crashes
# - exhaustive # silly check
# - makezero # false positives
# - nilerr # several intentional

linters-settings:
gofmt:
simplify: true
goconst:
min-len: 3 # minimum length of string constant
min-occurrences: 6 # minimum number of occurrences
gosec:
excludes:
- G404 # Use of weak random number generator - lots of FP
- G107 # Potential http request -- those are intentional
- G306 # G306: Expect WriteFile permissions to be 0600 or less

issues:
exclude-rules:
- path: crypto/blake2b/
linters:
- deadcode
- path: crypto/bn256/cloudflare
linters:
- deadcode
- path: p2p/discv5/
linters:
- deadcode
- path: core/vm/instructions_test.go
linters:
- goconst
- path: cmd/faucet/
- path: crypto/bn256/cloudflare/optate.go
linters:
- deadcode
- staticcheck
- path: internal/build/pgp.go
text: 'SA1019: package golang.org/x/crypto/openpgp is deprecated'
- path: core/vm/contracts.go
text: 'SA1019: package golang.org/x/crypto/ripemd160 is deprecated'
- path: accounts/usbwallet/trezor.go
text: 'SA1019: package github.com/golang/protobuf/proto is deprecated'
- path: accounts/usbwallet/trezor/
text: 'SA1019: package github.com/golang/protobuf/proto is deprecated'
exclude:
- 'SA1019: event.TypeMux is deprecated: use Feed'
- 'SA1019: strings.Title is deprecated'
- 'SA1029: should not use built-in type string as key for value'
- 'G306: Expect WriteFile permissions to be 0600 or less'
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ directory.
| `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. |
| `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. |
| `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`). |
| `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`). |
| `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`). |
| `puppeth` | a CLI wizard that aids in creating a new Ethereum network. |

## Running `geth`
Expand Down Expand Up @@ -202,7 +202,7 @@ accessible from the outside.

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

With the bootnode online, it will display an [`enode` URL](https://eth.wiki/en/fundamentals/enode-url-format)
With the bootnode online, it will display an [`enode` URL](https://ethereum.org/en/developers/docs/networking-layer/network-addresses/#enode)
that other nodes can use to connect to it and exchange peer information. Make sure to
replace the displayed IP address information (most probably `[::]`) with your externally
accessible IP to get the actual `enode` URL.
Expand Down
23 changes: 4 additions & 19 deletions accounts/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
case "constructor":
abi.Constructor = NewMethod("", "", Constructor, field.StateMutability, field.Constant, field.Payable, field.Inputs, nil)
case "function":
name := overloadedName(field.Name, func(s string) bool { _, ok := abi.Methods[s]; return ok })
name := ResolveNameConflict(field.Name, func(s string) bool { _, ok := abi.Methods[s]; return ok })
abi.Methods[name] = NewMethod(name, field.Name, Function, field.StateMutability, field.Constant, field.Payable, field.Inputs, field.Outputs)
case "fallback":
// New introduced function type in v0.6.0, check more detail
Expand All @@ -184,9 +184,11 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
}
abi.Receive = NewMethod("", "", Receive, field.StateMutability, field.Constant, field.Payable, nil, nil)
case "event":
name := overloadedName(field.Name, func(s string) bool { _, ok := abi.Events[s]; return ok })
name := ResolveNameConflict(field.Name, func(s string) bool { _, ok := abi.Events[s]; return ok })
abi.Events[name] = NewEvent(name, field.Name, field.Anonymous, field.Inputs)
case "error":
// Errors cannot be overloaded or overridden but are inherited,
// no need to resolve the name conflict here.
abi.Errors[field.Name] = NewError(field.Name, field.Inputs)
default:
return fmt.Errorf("abi: could not recognize type %v of field %v", field.Type, field.Name)
Expand Down Expand Up @@ -251,20 +253,3 @@ func UnpackRevert(data []byte) (string, error) {
}
return unpacked[0].(string), nil
}

// overloadedName returns the next available name for a given thing.
// Needed since solidity allows for overloading.
//
// e.g. if the abi contains Methods send, send1
// overloadedName would return send2 for input send.
//
// overloadedName works for methods, events and errors.
func overloadedName(rawName string, isAvail func(string) bool) string {
name := rawName
ok := isAvail(name)
for idx := 0; ok; idx++ {
name = fmt.Sprintf("%s%d", rawName, idx)
ok = isAvail(name)
}
return name
}
4 changes: 1 addition & 3 deletions accounts/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1038,9 +1038,7 @@ func TestABI_EventById(t *testing.T) {
}
if event == nil {
t.Errorf("We should find a event for topic %s, test #%d", topicID.Hex(), testnum)
}

if event.ID != topicID {
} else if event.ID != topicID {
t.Errorf("Event id %s does not match topic %s, test #%d", event.ID.Hex(), topicID.Hex(), testnum)
}

Expand Down
25 changes: 16 additions & 9 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ type SimulatedBackend struct {
database ethdb.Database // In memory database to store our testing data
blockchain *core.BlockChain // Ethereum blockchain to handle the consensus

mu sync.Mutex
pendingBlock *types.Block // Currently pending block that will be imported on request
pendingState *state.StateDB // Currently pending state that will be the active on request
mu sync.Mutex
pendingBlock *types.Block // Currently pending block that will be imported on request
pendingState *state.StateDB // Currently pending state that will be the active on request
pendingReceipts types.Receipts // Currently receipts for the pending block

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

Expand All @@ -84,8 +85,8 @@ func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.Genesis
database: database,
blockchain: blockchain,
config: genesis.Config,
events: filters.NewEventSystem(&filterBackend{database, blockchain}, false),
}
backend.events = filters.NewEventSystem(&filterBackend{database, blockchain, backend}, false)
backend.rollback(blockchain.CurrentBlock())
return backend
}
Expand Down Expand Up @@ -662,7 +663,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
return fmt.Errorf("invalid transaction nonce: got %d, want %d", tx.Nonce(), nonce)
}
// Include tx in chain
blocks, _ := core.GenerateChain(b.config, block, ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) {
blocks, receipts := core.GenerateChain(b.config, block, ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) {
for _, tx := range b.pendingBlock.Transactions() {
block.AddTxWithChain(b.blockchain, tx)
}
Expand All @@ -672,6 +673,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa

b.pendingBlock = blocks[0]
b.pendingState, _ = state.New(b.pendingBlock.Root(), stateDB.Database(), nil)
b.pendingReceipts = receipts[0]
return nil
}

Expand All @@ -683,7 +685,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.Filter
var filter *filters.Filter
if query.BlockHash != nil {
// Block filter requested, construct a single-shot filter
filter = filters.NewBlockFilter(&filterBackend{b.database, b.blockchain}, *query.BlockHash, query.Addresses, query.Topics)
filter = filters.NewBlockFilter(&filterBackend{b.database, b.blockchain, b}, *query.BlockHash, query.Addresses, query.Topics)
} else {
// Initialize unset filter boundaries to run from genesis to chain head
from := int64(0)
Expand All @@ -695,7 +697,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.Filter
to = query.ToBlock.Int64()
}
// Construct the range filter
filter = filters.NewRangeFilter(&filterBackend{b.database, b.blockchain}, from, to, query.Addresses, query.Topics)
filter = filters.NewRangeFilter(&filterBackend{b.database, b.blockchain, b}, from, to, query.Addresses, query.Topics)
}
// Run the filter and return all the logs
logs, err := filter.Logs(ctx)
Expand Down Expand Up @@ -816,8 +818,9 @@ func (m callMsg) AccessList() types.AccessList { return m.CallMsg.AccessList }
// filterBackend implements filters.Backend to support filtering for logs without
// taking bloom-bits acceleration structures into account.
type filterBackend struct {
db ethdb.Database
bc *core.BlockChain
db ethdb.Database
bc *core.BlockChain
backend *SimulatedBackend
}

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

func (fb *filterBackend) PendingBlockAndReceipts() (*types.Block, types.Receipts) {
return fb.backend.pendingBlock, fb.backend.pendingReceipts
}

func (fb *filterBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
number := rawdb.ReadHeaderNumber(fb.db, hash)
if number == nil {
Expand Down
3 changes: 1 addition & 2 deletions accounts/abi/bind/backends/simulated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,7 @@ func TestHeaderByNumber(t *testing.T) {
}
if latestBlockHeader == nil {
t.Errorf("received a nil block header")
}
if latestBlockHeader.Number.Uint64() != uint64(0) {
} else if latestBlockHeader.Number.Uint64() != uint64(0) {
t.Errorf("expected block header number 0, instead got %v", latestBlockHeader.Number.Uint64())
}

Expand Down
25 changes: 22 additions & 3 deletions accounts/abi/bind/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
// Normalize the method for capital cases and non-anonymous inputs/outputs
normalized := original
normalizedName := methodNormalizer[lang](alias(aliases, original.Name))

// Ensure there is no duplicated identifier
var identifiers = callIdentifiers
if !original.IsConstant() {
Expand All @@ -108,6 +109,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
return "", fmt.Errorf("duplicated identifier \"%s\"(normalized \"%s\"), use --alias for renaming", original.Name, normalizedName)
}
identifiers[normalizedName] = true

normalized.Name = normalizedName
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
copy(normalized.Inputs, original.Inputs)
Expand Down Expand Up @@ -152,12 +154,22 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
eventIdentifiers[normalizedName] = true
normalized.Name = normalizedName

used := make(map[string]bool)
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
copy(normalized.Inputs, original.Inputs)
for j, input := range normalized.Inputs {
if input.Name == "" {
normalized.Inputs[j].Name = fmt.Sprintf("arg%d", j)
}
// Event is a bit special, we need to define event struct in binding,
// ensure there is no camel-case-style name conflict.
for index := 0; ; index++ {
if !used[capitalise(normalized.Inputs[j].Name)] {
used[capitalise(normalized.Inputs[j].Name)] = true
break
}
normalized.Inputs[j].Name = fmt.Sprintf("%s%d", normalized.Inputs[j].Name, index)
}
if hasStruct(input.Type) {
bindStructType[lang](input.Type, structs)
}
Expand Down Expand Up @@ -432,15 +444,22 @@ func bindStructTypeGo(kind abi.Type, structs map[string]*tmplStruct) string {
if s, exist := structs[id]; exist {
return s.Name
}
var fields []*tmplField
var (
names = make(map[string]bool)
fields []*tmplField
)
for i, elem := range kind.TupleElems {
field := bindStructTypeGo(*elem, structs)
fields = append(fields, &tmplField{Type: field, Name: capitalise(kind.TupleRawNames[i]), SolKind: *elem})
name := capitalise(kind.TupleRawNames[i])
name = abi.ResolveNameConflict(name, func(s string) bool { return names[s] })
names[name] = true
fields = append(fields, &tmplField{Type: bindStructTypeGo(*elem, structs), Name: name, SolKind: *elem})
}
name := kind.TupleRawName
if name == "" {
name = fmt.Sprintf("Struct%d", len(structs))
}
name = capitalise(name)

structs[id] = &tmplStruct{
Name: name,
Fields: fields,
Expand Down
Loading

0 comments on commit 1742414

Please sign in to comment.