Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev eth v1.10.22 #64

Merged
merged 108 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
bd544f3
common/prque: fix typo
dbadoy Jun 30, 2022
d698ffa
eth/catalyst: disallow importing blocks via newPayload during snap sy…
karalabe Jul 1, 2022
8a8b11d
Replace fmt.Errorf with errors.New in abi argument (#25181)
aaronbuchwald Jul 4, 2022
0230cbd
all: change format `0x%x` to `%#x` (#25221)
dbadoy Jul 4, 2022
df15f70
consensus/beacon: copy td value so we can modify it (#25230)
MariusVanDerWijden Jul 4, 2022
ebf7092
core: allow external code to set the block validator for malicious te…
MariusVanDerWijden Jul 4, 2022
e521830
core: apply ttd override to uninitialized db (#25136)
MariusVanDerWijden Jul 4, 2022
27e6c30
signer/core/apitypes: support primitive types int96/uint96 (#25105)
spkjp Jul 4, 2022
1f4d550
cmd/geth, cmd/devp2p: fix some cli parsing issues (#25234)
fjl Jul 4, 2022
19f5f7c
core: allow external processor (#25233)
MariusVanDerWijden Jul 5, 2022
bc9a43a
consensus/beacon: verify timestamp is greater than parent timestamp (…
MariusVanDerWijden Jul 5, 2022
1e50ef5
internal/ethapi: add basefee to block overrides (#25219)
s1na Jul 5, 2022
a09c789
trie: fix typo in comment (#25241)
aaronbuchwald Jul 6, 2022
5d5e466
core/types: fix typo in comment (#25249)
dbadoy Jul 6, 2022
09f65bc
internal/ethapi: fix chain ID check to return all non-zero IDs (#25244)
lightclient Jul 7, 2022
56c5351
rpc: add graceful shutdown timeout for HTTP server (#25258)
windycrypto Jul 8, 2022
0d36230
p2p/discover: fix typos in comments (#25272)
dbadoy Jul 10, 2022
3460fa5
core, eth: pre-allocate map in storage copy (#25279)
dbadoy Jul 12, 2022
5630511
eth/tracers: add initial revertReasonTracer tracer (#25265)
fanbsb Jul 12, 2022
b471d42
params: enable DNS discovery on Sepolia too
karalabe Jul 12, 2022
668072e
internal/build: add a timestamp to the tar archive folder
karalabe Jul 12, 2022
b222b5d
accounts/abi: fix typo in comment (#25271)
eltociear Jul 14, 2022
73c2cae
accounts/abi/bind/backends: return hash of new blocks (#25163)
DragonDev1906 Jul 14, 2022
b90c634
Merge pull request #25096 from lightclient/remove-version-field
cp-wjhan Sep 25, 2023
734c819
internal/ethapi: error if tx args includes chain id that doesn't matc…
lightclient Jul 14, 2022
ad4485c
core: prevent negative fee during RPC calls (#25214)
PlasmaPower Jul 15, 2022
2c22e12
core, les, eth: port snap sync changes (#24898)
rjl493456442 Jul 15, 2022
c18797a
trie: fixed make lint error
cp-wjhan Sep 25, 2023
9e1cd09
tests: only activate merge on london rules (#25239)
MariusVanDerWijden Jul 15, 2022
0a31c0d
trie: fix 'gosimple' lint issue (#25309)
fjl Jul 15, 2022
fa0c972
p2p/discover: apply netrestrict in discv5 response handler (#25304)
hadv Jul 15, 2022
2f0dcff
cmd/geth: remove redundant 0x in dbGet/dbDelete (#25315)
gballet Jul 18, 2022
727d8cd
accounts/abi: substitude arg%d to the range keyword (#25307)
gballet Jul 19, 2022
f6bf601
params: Add Shanghai and Cancun blocks (#25305)
gballet Jul 19, 2022
54efc87
params: change Merge config to print simpler message
n1charlie Jul 21, 2022
3eff1c8
cmd/puppeth: remove support for exporting non-Geth genesis configurat…
jwasinger Jul 22, 2022
9ffa552
params: set goerli TTD to 10_790_000 (#25324)
MariusVanDerWijden Jul 22, 2022
30c0ace
signer/core: add canonical TypedData hashing methods (#25283)
nik-suri Jul 22, 2022
77d627f
deps: update goleveldb
cp-wjhan Sep 25, 2023
95a8cda
params: set sepolia mergeNetsplitBlock to 1735371 (#25372)
MariusVanDerWijden Jul 23, 2022
a195693
cmd/geth: eth/catalyst: enable authrpc by default (#25152)
MariusVanDerWijden Jul 23, 2022
058d284
eth/catalyst: better warning for ttd not configured (#25394)
MariusVanDerWijden Jul 25, 2022
c4d77a7
cmd: use flags.Merge for grouping flags (#25392)
rjl493456442 Jul 25, 2022
6abe049
consensus/beacon: fix typo in comment (#25391)
gballet Jul 25, 2022
b2fff71
p2p/netutil: minor code cosmetic
Abirdcfly Jul 25, 2022
99567e3
eth, internal, light: fix error string capitalization (#25364)
dbadoy Jul 25, 2022
3a48e2f
light: fix differTries err message in tests (#25358)
eval-exec Jul 25, 2022
67fad3e
eth/catalyst: fixed make lint error
cp-wjhan Sep 25, 2023
478d099
all: add whitespace linter (#25312)
jsvisa Jul 25, 2022
f78e870
eth/tracers/js: fix capitalization in tests
karalabe Jul 25, 2022
8111ed1
eth: support bubbling up bad blocks from sync to the engine API (#25190)
karalabe Jul 25, 2022
72e1f5f
core: eth: rpc: implement safe rpc block (#25165)
MariusVanDerWijden Jul 25, 2022
37d44b6
go.mod: downgrade leveldb (#25413)
cp-wjhan Sep 25, 2023
a5d9c2f
wemix/scripts: add authrpc option
cp-wjhan Oct 5, 2023
f896a96
core, trie, eth, cmd: rework preimage store (#25287)
rjl493456442 Jul 27, 2022
7385c06
eth/catalyst: fix NewPayload warn log when dropping due to snap sync
karalabe Jul 28, 2022
65cb8df
node: set JWT expiry to 60 seconds (#25416)
MariusVanDerWijden Jul 28, 2022
702cb08
eth/catalyst: return syncing not accepted (#25414)
MariusVanDerWijden Jul 28, 2022
c2342e3
eth/catalyst: return 0x0 if latestvalid is pow block (#25423)
MariusVanDerWijden Jul 28, 2022
72c71ea
ethereum, ethclient: add FeeHistory support (#25403)
lightclient Jul 29, 2022
12c7774
all: use AbsTime.Add instead of conversion (#25417)
dbadoy Jul 29, 2022
9304051
cm/puppeth: fix crash when of ethstats specifier doesn't contain `:` …
jsvisa Jul 29, 2022
ffc23b0
eth: fix typo in comment (#25327)
rithwikbabu Jul 29, 2022
cd679b3
common/compiler: json unmarshalling error checks (#25449)
henry-0 Aug 1, 2022
61345a4
cmd, core, eth, les, params: add merge-passed chain config (#24538)
karalabe Aug 1, 2022
dba9ebc
eth: fix typo in catalyst api (#25460)
s1na Aug 1, 2022
df53219
eth/gasprice/feehistory: support finalized block (#25442)
lightclient Aug 1, 2022
e949d35
consensus/ethash: remove temp files created during DAG generation (#2…
manoj398 Aug 2, 2022
bef7de8
cmd/devp2p/internal/ethtest: update tests for eth/67 (#25306)
fjl Aug 2, 2022
ad018cc
node, rpc: add ReadHeaderTimeout config option (#25338)
Tristan-Wilson Aug 3, 2022
f4bc85e
core/types: fix typo in comment (#25359)
yzhaoyu Aug 3, 2022
499eecf
core: preallocate batch size in bloomIndexer (#25289)
dbadoy Aug 3, 2022
659b796
internal/ethapi: don't estimate gas if no limit provided in eth_creat…
lightclient Aug 3, 2022
46eddb2
graphql: embed *Resolver instead of backend interface (#25468)
fjl Aug 3, 2022
4e94d67
node: remove noop path.Join (#25475)
jsvisa Aug 4, 2022
ab66245
core, trie: rework trie committer (#25320)
rjl493456442 Aug 4, 2022
e7e8e27
core: use TryGetAccount to read what TryUpdateAccount has written (#2…
gballet Aug 4, 2022
09b627b
cmd, core, ethdb, node: move chain freezer one folder deeper (#25487)
rjl493456442 Aug 8, 2022
dd4914c
core/state/snapshot, ethdb/rocksdb: Fixed RocksDB Iterator error.
cp-wjhan Oct 19, 2023
ef96ba5
eth/downloader: fix log errors of queue_test.go (#25494)
int88 Aug 8, 2022
2df96d2
core: fix uncle creation in TestFastVsFullChains (#25476)
int88 Aug 8, 2022
3b749d7
eth: formatted error nit (#25499)
aaronbuchwald Aug 9, 2022
8172979
eth/tracers: add onlyTopCall option to callTracer (#25430)
s1na Aug 9, 2022
5ed07cc
all: cleanup the APIs for initializing genesis (#25473)
rjl493456442 Aug 9, 2022
e1f17a8
core: remove unused bc ChainContext in applyTransaction
Aug 10, 2022
847c7ff
signer/rules: register clef api properly when rules are used (#25455)
holiman Aug 10, 2022
1f60924
build: add static linking support (#25492)
0xe3b0c4 Aug 10, 2022
41513f3
accounts/abi: display name in "method/event not found" error (#25512)
darioush Aug 11, 2022
6c11e5a
internal/ethapi: rework setDefaults for tx args so fee logic is separ…
lightclient Aug 11, 2022
f23b62c
core/genesis: remove calaverasAllocData (#25516)
Aug 12, 2022
441ecd0
params: set ttdpassed on goerli (#25519)
holiman Aug 15, 2022
cc35e1e
params: set mainnet terminal total difficulty for the merge (#25528)
MariusVanDerWijden Aug 16, 2022
47bb911
core, trie: flush preimages to db on blockchain close (#25533)
gballet Aug 17, 2022
5d9295e
core/state, trie, light: add a TryDeleteAccount method (#25531)
gballet Aug 17, 2022
b96eeb3
core: make tx journal check and open atomic (#25530)
dbadoy Aug 17, 2022
5255691
cmd. core: save preimages on genesis creation (#25538)
gballet Aug 18, 2022
b8e0f39
rlp/rlpgen: fix error handling when target type not found (#25547)
jtraglia Aug 18, 2022
28d241b
trie: improve node rlp decoding performance (#25357)
rjl493456442 Aug 18, 2022
0e5d9fd
all: fix some typos (#25551)
jtraglia Aug 19, 2022
2f7cab6
internal/ethapi: fix comment typo (#25548)
ucwong Aug 19, 2022
2f45095
accounts/abi/bind/backends: typo fix (#25549)
ucwong Aug 19, 2022
17188a0
eth, les: unlock downloader peerSet if there's an error (#25546)
jtraglia Aug 19, 2022
797a104
cmd/geth: parse uint64 value with ParseUint instead of Atoi (#25545)
jtraglia Aug 19, 2022
93bfed8
consensus/beacon: check ttd reached on pos blocks (#25552)
MariusVanDerWijden Aug 19, 2022
dad79e6
eth/filters: add global block logs cache (#25459)
s1na Aug 19, 2022
e753ea4
accounts/abi: fix set function (#25477)
zhiqiangxu Aug 19, 2022
9703bda
internal/ethapi: fix build regression (#25555)
fjl Aug 19, 2022
ccc9a0a
eth/catalyst: warn less frequently if no beacon client is available (…
karalabe Aug 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 12 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ linters:
- durationcheck
- exportloopref
# - gosec
- whitespace

#- 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
# - 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:
Expand All @@ -48,9 +49,9 @@ linters-settings:
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
- 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:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ COPY go.sum /go-ethereum/
RUN cd /go-ethereum && go mod download

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

# Pull Geth into a second stage deploy alpine container
FROM alpine:latest
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.alltools
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ COPY go.sum /go-ethereum/
RUN cd /go-ethereum && go mod download

ADD . /go-ethereum
RUN cd /go-ethereum && go run build/ci.go install
RUN cd /go-ethereum && go run build/ci.go install -static

# Pull all binaries into a second stage deploy alpine container
FROM alpine:latest
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (abi ABI) getArguments(name string, data []byte) (Arguments, error) {
args = event.Inputs
}
if args == nil {
return nil, errors.New("abi: could not locate named method or event")
return nil, fmt.Errorf("abi: could not locate named method or event: %s", name)
}
return args, nil
}
Expand Down
9 changes: 5 additions & 4 deletions accounts/abi/argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package abi

import (
"encoding/json"
"errors"
"fmt"
"reflect"
"strings"
Expand Down Expand Up @@ -79,7 +80,7 @@ func (arguments Arguments) isTuple() bool {
func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
if len(data) == 0 {
if len(arguments.NonIndexed()) != 0 {
return nil, fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
return nil, errors.New("abi: attempting to unmarshall an empty string while arguments are expected")
}
return make([]interface{}, 0), nil
}
Expand All @@ -90,11 +91,11 @@ func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte) error {
// Make sure map is not nil
if v == nil {
return fmt.Errorf("abi: cannot unpack into a nil map")
return errors.New("abi: cannot unpack into a nil map")
}
if len(data) == 0 {
if len(arguments.NonIndexed()) != 0 {
return fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
return errors.New("abi: attempting to unmarshall an empty string while arguments are expected")
}
return nil // Nothing to unmarshal, return
}
Expand All @@ -116,7 +117,7 @@ func (arguments Arguments) Copy(v interface{}, values []interface{}) error {
}
if len(values) == 0 {
if len(arguments.NonIndexed()) != 0 {
return fmt.Errorf("abi: attempting to copy no values while arguments are expected")
return errors.New("abi: attempting to copy no values while arguments are expected")
}
return nil // Nothing to copy, return
}
Expand Down
39 changes: 19 additions & 20 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ type SimulatedBackend struct {
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
events *filters.EventSystem // for filtering log events live
filterSystem *filters.FilterSystem // for filtering database logs

config *params.ChainConfig
}
Expand All @@ -86,7 +87,11 @@ func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.Genesis
blockchain: blockchain,
config: genesis.Config,
}
backend.events = filters.NewEventSystem(&filterBackend{database, blockchain, backend}, false)

filterBackend := &filterBackend{database, blockchain, backend}
backend.filterSystem = filters.NewFilterSystem(filterBackend, filters.Config{})
backend.events = filters.NewEventSystem(backend.filterSystem, false)

backend.rollback(blockchain.CurrentBlock())
return backend
}
Expand All @@ -106,16 +111,20 @@ func (b *SimulatedBackend) Close() error {

// Commit imports all the pending transactions as a single block and starts a
// fresh new state.
func (b *SimulatedBackend) Commit() {
func (b *SimulatedBackend) Commit() common.Hash {
b.mu.Lock()
defer b.mu.Unlock()

if _, err := b.blockchain.InsertChain([]*types.Block{b.pendingBlock}); err != nil {
panic(err) // This cannot happen unless the simulator is wrong, fail in that case
}
blockHash := b.pendingBlock.Hash()

// Using the last inserted block here makes it possible to build on a side
// chain after a fork.
b.rollback(b.pendingBlock)

return blockHash
}

// Rollback aborts all pending transactions, reverting to the last committed state.
Expand Down Expand Up @@ -605,7 +614,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
// User specified the legacy gas field, convert to 1559 gas typing
call.GasFeeCap, call.GasTipCap = call.GasPrice, call.GasPrice
} else {
// User specified 1559 gas feilds (or none), use those
// User specified 1559 gas fields (or none), use those
if call.GasFeeCap == nil {
call.GasFeeCap = new(big.Int)
}
Expand Down Expand Up @@ -685,7 +694,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, b}, *query.BlockHash, query.Addresses, query.Topics)
filter = b.filterSystem.NewBlockFilter(*query.BlockHash, query.Addresses, query.Topics)
} else {
// Initialize unset filter boundaries to run from genesis to chain head
from := int64(0)
Expand All @@ -697,7 +706,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, b}, from, to, query.Addresses, query.Topics)
filter = b.filterSystem.NewRangeFilter(from, to, query.Addresses, query.Topics)
}
// Run the filter and return all the logs
logs, err := filter.Logs(ctx)
Expand Down Expand Up @@ -826,7 +835,8 @@ type filterBackend struct {
backend *SimulatedBackend
}

func (fb *filterBackend) ChainDb() ethdb.Database { return fb.db }
func (fb *filterBackend) ChainDb() ethdb.Database { return fb.db }

func (fb *filterBackend) EventMux() *event.TypeMux { panic("not supported") }

func (fb *filterBackend) HeaderByNumber(ctx context.Context, block rpc.BlockNumber) (*types.Header, error) {
Expand All @@ -852,19 +862,8 @@ func (fb *filterBackend) GetReceipts(ctx context.Context, hash common.Hash) (typ
return rawdb.ReadReceipts(fb.db, hash, *number, fb.bc.Config()), nil
}

func (fb *filterBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error) {
number := rawdb.ReadHeaderNumber(fb.db, hash)
if number == nil {
return nil, nil
}
receipts := rawdb.ReadReceipts(fb.db, hash, *number, fb.bc.Config())
if receipts == nil {
return nil, nil
}
logs := make([][]*types.Log, len(receipts))
for i, receipt := range receipts {
logs[i] = receipt.Logs
}
func (fb *filterBackend) GetLogs(ctx context.Context, hash common.Hash, number uint64) ([][]*types.Log, error) {
logs := rawdb.ReadLogs(fb.db, hash, number, fb.bc.Config())
return logs, nil
}

Expand Down
39 changes: 39 additions & 0 deletions accounts/abi/bind/backends/simulated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1338,3 +1338,42 @@ func TestForkResendTx(t *testing.T) {
t.Errorf("TX included in wrong block: %d", h)
}
}

func TestCommitReturnValue(t *testing.T) {
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
sim := simTestBackend(testAddr)
defer sim.Close()

startBlockHeight := sim.blockchain.CurrentBlock().NumberU64()

// Test if Commit returns the correct block hash
h1 := sim.Commit()
if h1 != sim.blockchain.CurrentBlock().Hash() {
t.Error("Commit did not return the hash of the last block.")
}

// Create a block in the original chain (containing a transaction to force different block hashes)
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
_tx := types.NewTransaction(0, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
tx, _ := types.SignTx(_tx, types.HomesteadSigner{}, testKey)
sim.SendTransaction(context.Background(), tx)
h2 := sim.Commit()

// Create another block in the original chain
sim.Commit()

// Fork at the first bock
if err := sim.Fork(context.Background(), h1); err != nil {
t.Errorf("forking: %v", err)
}

// Test if Commit returns the correct block hash after the reorg
h2fork := sim.Commit()
if h2 == h2fork {
t.Error("The block in the fork and the original block are the same block!")
}
if sim.blockchain.GetHeader(h2fork, startBlockHeight+2) == nil {
t.Error("Could not retrieve the just created block (side-chain)")
}
}
1 change: 0 additions & 1 deletion accounts/abi/bind/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func (mc *mockPendingCaller) PendingCallContract(ctx context.Context, call ether
}

func TestPassingBlockNumber(t *testing.T) {

mc := &mockPendingCaller{
mockCaller: &mockCaller{
codeAtBytes: []byte{1, 2, 3},
Expand Down
41 changes: 39 additions & 2 deletions accounts/abi/bind/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,43 @@ const (
LangObjC
)

func isKeyWord(arg string) bool {
switch arg {
case "break":
case "case":
case "chan":
case "const":
case "continue":
case "default":
case "defer":
case "else":
case "fallthrough":
case "for":
case "func":
case "go":
case "goto":
case "if":
case "import":
case "interface":
case "iota":
case "map":
case "make":
case "new":
case "package":
case "range":
case "return":
case "select":
case "struct":
case "switch":
case "type":
case "var":
default:
return false
}

return true
}

// Bind generates a Go wrapper around a contract ABI. This wrapper isn't meant
// to be used as is in client code, but rather as an intermediate struct which
// enforces compile time type safety and naming convention opposed to having to
Expand Down Expand Up @@ -114,7 +151,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
copy(normalized.Inputs, original.Inputs)
for j, input := range normalized.Inputs {
if input.Name == "" {
if input.Name == "" || isKeyWord(input.Name) {
normalized.Inputs[j].Name = fmt.Sprintf("arg%d", j)
}
if hasStruct(input.Type) {
Expand Down Expand Up @@ -158,7 +195,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
copy(normalized.Inputs, original.Inputs)
for j, input := range normalized.Inputs {
if input.Name == "" {
if input.Name == "" || isKeyWord(input.Name) {
normalized.Inputs[j].Name = fmt.Sprintf("arg%d", j)
}
// Event is a bit special, we need to define event struct in binding,
Expand Down
39 changes: 38 additions & 1 deletion accounts/abi/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1971,7 +1971,7 @@ var bindTests = []struct {
}
}
`,
bytecode: []string{`0x608060405234801561001057600080fd5b5061042b806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063c2bb515f1461003b578063cce7b04814610059575b600080fd5b610043610075565b60405161005091906101af565b60405180910390f35b610073600480360381019061006e91906103ac565b6100b5565b005b61007d6100b8565b604051806040016040528060405180602001604052806000815250815260200160405180602001604052806000815250815250905090565b50565b604051806040016040528060608152602001606081525090565b600081519050919050565b600082825260208201905092915050565b60005b8381101561010c5780820151818401526020810190506100f1565b8381111561011b576000848401525b50505050565b6000601f19601f8301169050919050565b600061013d826100d2565b61014781856100dd565b93506101578185602086016100ee565b61016081610121565b840191505092915050565b600060408301600083015184820360008601526101888282610132565b915050602083015184820360208601526101a28282610132565b9150508091505092915050565b600060208201905081810360008301526101c9818461016b565b905092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61022282610121565b810181811067ffffffffffffffff82111715610241576102406101ea565b5b80604052505050565b60006102546101d1565b90506102608282610219565b919050565b600080fd5b600080fd5b600080fd5b600067ffffffffffffffff82111561028f5761028e6101ea565b5b61029882610121565b9050602081019050919050565b82818337600083830152505050565b60006102c76102c284610274565b61024a565b9050828152602081018484840111156102e3576102e261026f565b5b6102ee8482856102a5565b509392505050565b600082601f83011261030b5761030a61026a565b5b813561031b8482602086016102b4565b91505092915050565b60006040828403121561033a576103396101e5565b5b610344604061024a565b9050600082013567ffffffffffffffff81111561036457610363610265565b5b610370848285016102f6565b600083015250602082013567ffffffffffffffff81111561039457610393610265565b5b6103a0848285016102f6565b60208301525092915050565b6000602082840312156103c2576103c16101db565b5b600082013567ffffffffffffffff8111156103e0576103df6101e0565b5b6103ec84828501610324565b9150509291505056fea264697066735822122033bca1606af9b6aeba1673f98c52003cec19338539fb44b86690ce82c51483b564736f6c634300080e0033`},
bytecode: []string{"0x608060405234801561001057600080fd5b5061042b806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063c2bb515f1461003b578063cce7b04814610059575b600080fd5b610043610075565b60405161005091906101af565b60405180910390f35b610073600480360381019061006e91906103ac565b6100b5565b005b61007d6100b8565b604051806040016040528060405180602001604052806000815250815260200160405180602001604052806000815250815250905090565b50565b604051806040016040528060608152602001606081525090565b600081519050919050565b600082825260208201905092915050565b60005b8381101561010c5780820151818401526020810190506100f1565b8381111561011b576000848401525b50505050565b6000601f19601f8301169050919050565b600061013d826100d2565b61014781856100dd565b93506101578185602086016100ee565b61016081610121565b840191505092915050565b600060408301600083015184820360008601526101888282610132565b915050602083015184820360208601526101a28282610132565b9150508091505092915050565b600060208201905081810360008301526101c9818461016b565b905092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61022282610121565b810181811067ffffffffffffffff82111715610241576102406101ea565b5b80604052505050565b60006102546101d1565b90506102608282610219565b919050565b600080fd5b600080fd5b600080fd5b600067ffffffffffffffff82111561028f5761028e6101ea565b5b61029882610121565b9050602081019050919050565b82818337600083830152505050565b60006102c76102c284610274565b61024a565b9050828152602081018484840111156102e3576102e261026f565b5b6102ee8482856102a5565b509392505050565b600082601f83011261030b5761030a61026a565b5b813561031b8482602086016102b4565b91505092915050565b60006040828403121561033a576103396101e5565b5b610344604061024a565b9050600082013567ffffffffffffffff81111561036457610363610265565b5b610370848285016102f6565b600083015250602082013567ffffffffffffffff81111561039457610393610265565b5b6103a0848285016102f6565b60208301525092915050565b6000602082840312156103c2576103c16101db565b5b600082013567ffffffffffffffff8111156103e0576103df6101e0565b5b6103ec84828501610324565b9150509291505056fea264697066735822122033bca1606af9b6aeba1673f98c52003cec19338539fb44b86690ce82c51483b564736f6c634300080e0033"},
abi: []string{`[ { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "int256", "name": "msg", "type": "int256" }, { "indexed": false, "internalType": "int256", "name": "_msg", "type": "int256" } ], "name": "log", "type": "event" }, { "inputs": [ { "components": [ { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "bytes", "name": "_data", "type": "bytes" } ], "internalType": "struct oracle.request", "name": "req", "type": "tuple" } ], "name": "addRequest", "outputs": [], "stateMutability": "pure", "type": "function" }, { "inputs": [], "name": "getRequest", "outputs": [ { "components": [ { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "bytes", "name": "_data", "type": "bytes" } ], "internalType": "struct oracle.request", "name": "", "type": "tuple" } ], "stateMutability": "pure", "type": "function" } ]`},
imports: `
"math/big"
Expand Down Expand Up @@ -2002,6 +2002,43 @@ var bindTests = []struct {
}
`,
},
{
name: "RangeKeyword",
contract: `
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;
contract keywordcontract {
function functionWithKeywordParameter(range uint256) public pure {}
}
`,
bytecode: []string{"0x608060405234801561001057600080fd5b5060dc8061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063527a119f14602d575b600080fd5b60436004803603810190603f9190605b565b6045565b005b50565b6000813590506055816092565b92915050565b600060208284031215606e57606d608d565b5b6000607a848285016048565b91505092915050565b6000819050919050565b600080fd5b6099816083565b811460a357600080fd5b5056fea2646970667358221220d4f4525e2615516394055d369fb17df41c359e5e962734f27fd683ea81fd9db164736f6c63430008070033"},
abi: []string{`[{"inputs":[{"internalType":"uint256","name":"range","type":"uint256"}],"name":"functionWithKeywordParameter","outputs":[],"stateMutability":"pure","type":"function"}]`},
imports: `
"math/big"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth/ethconfig"
`,
tester: `
var (
key, _ = crypto.GenerateKey()
user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
sim = backends.NewSimulatedBackend(core.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.GasCeil)
)
_, tx, _, err := DeployRangeKeyword(user, sim)
if err != nil {
t.Fatalf("error deploying contract: %v", err)
}
sim.Commit()

if _, err = bind.WaitDeployed(nil, sim, tx); err != nil {
t.Errorf("error deploying the contract: %v", err)
}
`,
},
}

// Tests that packages generated by the binder can be successfully compiled and
Expand Down
1 change: 0 additions & 1 deletion accounts/abi/error_handling.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func typeCheck(t Type, value reflect.Value) error {
} else {
return nil
}

}

// typeErr returns a formatted type casting error.
Expand Down
1 change: 0 additions & 1 deletion accounts/abi/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ func TestEventMultiValueWithArrayUnpack(t *testing.T) {
}

func TestEventTupleUnpack(t *testing.T) {

type EventTransfer struct {
Value *big.Int
}
Expand Down
Loading