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

Merge upstream v1.10.9 #59

Merged
merged 146 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
d3f018f
eth: drop eth/65, the last non-reqid protocol version
karalabe Jun 28, 2021
a1f16bc
params: begin v1.10.7 release cycle
fjl Jul 22, 2021
bbfa648
Use `hexutil.Uint` for `blockCount` parameter in `feeHistory` method …
lightclient Jul 27, 2021
5c89ec9
cmd/geth: update vulnerability testdata (#23252)
holiman Jul 27, 2021
b20bc5c
accounts/abi/bind: parse ABI only once, create metadata struct (#22583)
MariusVanDerWijden Jul 27, 2021
3aea432
accounts/abi/bind: set Context in TransactOpts (#23188)
MariusVanDerWijden Jul 27, 2021
2faf796
internal/ethapi: fix panic in accesslist creation (#23225)
MariusVanDerWijden Jul 28, 2021
0730acc
consensus/ethash: less allocation during mining (#23199)
fxfactorial Jul 28, 2021
56e9001
README: fix default sync mode (#23282)
ligi Jul 28, 2021
523866c
all: change blacklist terms
baptiste-b-pegasys Jul 29, 2021
5c13012
accounts/external, internal/ethapi: fixes for London tx signing (#23…
holiman Jul 29, 2021
fb8ea59
tests: update tests/testdata to v9.0.4 (london) (#23279)
MariusVanDerWijden Jul 29, 2021
64a5e12
go.mod: upgrade to goupnp v1.0.2 (#23197)
ucwong Jul 29, 2021
b157bae
go.mod: bump golang.org/x/text to v0.3.6 (#23291)
s1na Jul 29, 2021
8f11d27
p2p/simulations: fix unlikely crash in probabilistic connect (#23200)
Evolution404 Jul 29, 2021
295bc35
signer/core: move API JSON types to separate package (#23275)
holiman Jul 29, 2021
3526f69
all: remove term "whitelist" in comments and log messages (#23294)
baptiste-b-pegasys Jul 29, 2021
860184d
p2p: remove term "whitelist" (#23295)
baptiste-b-pegasys Jul 29, 2021
85afdee
tests: remove whitelist feature (#23297)
baptiste-b-pegasys Jul 29, 2021
95bbd46
node, cmd/clef: remove term "whitelist" (#23296)
baptiste-b-pegasys Aug 2, 2021
82c5085
cre/state: fix outdated statedb Prepare comment (#23320)
aaronbuchwald Aug 3, 2021
4cd6a14
cmd/devp2p: fix ping/pong race in discv4 tests (#23306)
holiman Aug 3, 2021
c38fab9
core: get header from block cache (#23299)
s1na Aug 3, 2021
f311488
internal/ethapi: fix trace log marshalling (#23292)
rjl493456442 Aug 3, 2021
28ba686
core/state: add trie prefetcher tests (#23216)
MariusVanDerWijden Aug 3, 2021
d3e3a46
core/rawdb: fix logs to print block number, not address (#23328)
patrick-ogrady Aug 4, 2021
0658712
core: check if sender is EOA (#23303)
holiman Aug 7, 2021
8a24b56
cmd/evm: implement input txs via rlp in t8n tool (#23138)
holiman Aug 7, 2021
9e59474
core/rawdb: close database in test to avoid goroutine leak (#23287)
charlesxsh Aug 8, 2021
d60cfd2
core: fix london-check to avoid duplication (#23333)
lxex Aug 9, 2021
97bd6cd
internal/ethapi: accept both hex and decimal for blockCount (#23363)
zsfelfoldi Aug 10, 2021
3b38a83
core/state/pruner: fix state bloom sync permission in Windows
karalabe Aug 10, 2021
520f256
Merge pull request #23370 from karalabe/windows-pruning-fix-b
karalabe Aug 10, 2021
6d17546
cmd, core, eth, miner: deprecate miner.gastarget flag (#23213)
rjl493456442 Aug 10, 2021
e4b687c
mobile: remove deprecated code (#23357)
Zachinquarantine Aug 10, 2021
57d9e0a
core/state/snapshot: fix typo in comment (#23219)
zzyalbert Aug 10, 2021
6694831
core/state/snapshot: clarify comment about snapshot repair (#23305)
tylerchambers Aug 10, 2021
39fe7ec
internal/ethapi: return maxFeePerGas for gasPrice for EIP-1559 txs (#…
lightclient Aug 10, 2021
a879c42
internal/ethapi, accounts/abi/bind: cap highest gas limit by account …
lightclient Aug 10, 2021
9d6480c
core/state/snapshot: gofmt
karalabe Aug 10, 2021
5d0ab07
Merge pull request #23371 from karalabe/gofmt
karalabe Aug 10, 2021
9097d0a
travis: transition from docker auto builds to manual pushes
karalabe Aug 10, 2021
0fbc94e
Merge pull request #23373 from karalabe/docker-flip
karalabe Aug 10, 2021
c27bd34
build: fix docker tag to include `v` prefix in version string
karalabe Aug 10, 2021
deff505
Merge pull request #23374 from karalabe/fix-docker-tag
karalabe Aug 10, 2021
278ec71
internal/ethapi: add back missing check for maxfee < maxPriorityFee
holiman Aug 12, 2021
2a451f9
Merge pull request #23384 from holiman/fix_gasfoo
karalabe Aug 12, 2021
f4ad493
params: update CHTs for the 1.10.7 release
karalabe Aug 12, 2021
971df49
Merge pull request #23385 from karalabe/cht-1.10.7
karalabe Aug 12, 2021
12f0ff4
params: release Geth v1.10.7
karalabe Aug 12, 2021
a580f7d
params: begin v1.10.8 release cycle
karalabe Aug 12, 2021
5f98020
core/rawdb: implement sequential reads in freezer_table (#23117)
holiman Aug 13, 2021
fd604be
Merge pull request #23120 from karalabe/drop-eth-65
karalabe Aug 13, 2021
0a68558
accounts/external: handle 0 chainid as not-set for the Clef API (#23394)
karalabe Aug 13, 2021
fb4007b
tests: update, enable legacy tests, remove vm tests (#23350)
holiman Aug 17, 2021
6902485
cmd, metrics: add support for influxdb-v2 (cherry-picking from italoa…
jwasinger Aug 17, 2021
85b9bdd
cmd, core: remove calaveras testnet (#23366)
Zachinquarantine Aug 17, 2021
16ecdd5
cmd/utils: add --nousb to the list of deprecated flags (#23388)
Zachinquarantine Aug 17, 2021
57feabe
eth, internal/ethapi: make RPC block miner field show block sealer co…
chenjia404 Aug 17, 2021
5566e5d
eth/downloader: fix typo in comment (#23413)
chuwt Aug 18, 2021
c368f72
Revert "eth: drop eth/65, the last non-reqid protocol version" (#23426)
karalabe Aug 20, 2021
d02c605
core: only check sendernoeoa in non fake mode (#23424)
MariusVanDerWijden Aug 23, 2021
bb1f7eb
signer/core/apitypes: remove dependency on internal/ethapi (#23362)
fjl Aug 23, 2021
dfeb2f7
go.mod: upgrade golang.org/x/sys for go1.17 support (#23406)
ucwong Aug 23, 2021
f38abc5
eth/gasprice: feeHistory improvements (#23422)
zsfelfoldi Aug 23, 2021
1d99573
core/vm: faster code analysis (#23381)
holiman Aug 24, 2021
2667545
params: release Geth v1.10.8
karalabe Aug 24, 2021
ea4bc2d
params: begin Geth v1.10.9 release cycle
karalabe Aug 24, 2021
79bb930
trie, les: add missing calls to Ticker.Stop (#23415)
chuwt Aug 24, 2021
8dbf261
p2p, p2p/enode: fix data races (#23434)
MariusVanDerWijden Aug 24, 2021
8e0771c
core/bloombits: avoid crash when storing errors of different type (#2…
otherview Aug 24, 2021
5c66bab
tests/testdata: make submodule shallow (#23412)
ligi Aug 24, 2021
0b40977
core/vm: fix typo in comment (#23450)
gballet Aug 24, 2021
a0a4a15
core/types: add benchmarks for rlp encoding/decoding (#23190)
holiman Aug 24, 2021
85126c4
node: add comment about --nousb being deprecated (#23439)
Zachinquarantine Aug 24, 2021
5cee33e
tests/fuzzers: fix go vet warning about ReadByte (#23380)
baptiste-b-pegasys Aug 24, 2021
d705f5a
core: make txpool reject too sudden changes (#23095)
holiman Aug 24, 2021
0db0b27
Revert "Revert "eth: drop eth/65, the last non-reqid protocol version…
karalabe Aug 24, 2021
b69f5ca
cmd/utils: fix typo in variable name (#23451)
bogatyy Aug 24, 2021
a789dcc
metrics: fix compilation for GOOS=js (#23449)
fjl Aug 24, 2021
a5a5237
core, light, tests, trie: add state metrics (#23433)
rjl493456442 Aug 24, 2021
fe2f153
go.mod: update goleveldb (#23417)
ucwong Aug 24, 2021
83ad92c
les: fix data races in tests (#23457)
rjl493456442 Aug 25, 2021
45f3443
build: upgrade to golangci-lint v1.42.0 (#23461)
fjl Aug 25, 2021
efee853
build, .travis.yml: upgrade to Go 1.17 (#23464)
fjl Aug 25, 2021
84c51bc
cmd/evm: add difficulty calculation to t8n tool (#23353)
holiman Aug 25, 2021
3784e15
tests: avoid performance tests during CI runs (#23304)
holiman Aug 25, 2021
d162142
Dockerfile: upgrade to Go 1.17 (#23465)
fjl Aug 25, 2021
887902e
crypto/cloudflare/bn256: fix in-place addition and unmarshalling (#23…
gballet Aug 25, 2021
8a13401
all: add go:build lines (#23468)
fjl Aug 25, 2021
32c576b
rlp: minor optimizations for slice/array encoding (#23467)
fjl Aug 25, 2021
154b525
cmd/devp2p/internal/ethtest: remove WriteTo method (#23379)
baptiste-b-pegasys Aug 25, 2021
7c4cad0
rpc: add BlockNumber.MarshalText (#23324)
zenovich Aug 25, 2021
d584e39
build: stop publishing deb packages for Ubuntu 20.10 Groovy Gorilla (…
fjl Aug 25, 2021
108eec3
node: remove dependency on wallet backend packages (#23019)
s1na Aug 25, 2021
62ad17f
Revert "eth, internal/ethapi: make RPC block miner field show block s…
holiman Aug 26, 2021
ffae204
internal/ethapi: support both input and data for personal_sendTransac…
lightclient Aug 27, 2021
3258211
core/vm: rework jumpdest analysis benchmarks (#23499)
chfast Aug 30, 2021
f85cf72
docs: add links to more audits in SECURITY.md (#23482)
fredriksvantes Aug 31, 2021
31be5d4
core: fix typo in iterator.go (#23502)
eltociear Aug 31, 2021
d019e90
common: fixes format verb (#23495)
AlexanderYastrebov Aug 31, 2021
067084f
core: fix race conditions in txpool (#23474)
MariusVanDerWijden Aug 31, 2021
4d88974
cmd/evm: add tests for evm t8n (#23507)
holiman Sep 2, 2021
de2c44a
trie: add missing copyright header (#23530)
aaronbuchwald Sep 7, 2021
7957530
docs: add post-mortem (#23518)
holiman Sep 7, 2021
ca5bc67
internal/debug: remove deprecated flags (#23368)
Zachinquarantine Sep 7, 2021
9a0df80
cmd/geth, cmd/utils: remove legacy rpc flags (#23358)
Zachinquarantine Sep 7, 2021
794c613
core/rawdb: freezer batch write (#23462)
holiman Sep 7, 2021
6ef3a16
p2p/enode: use unix timestamp as base ENR sequence number (#19903)
karalabe Sep 7, 2021
51ed39c
core: make txPricedList.stales the first field for 64bit alignment (#…
fjl Sep 7, 2021
5c1fc3b
core: 64bit alignment of testBlockChain.gasLimit (#23543)
fjl Sep 7, 2021
90987db
appveyor.yml: add linux/amd64 build job (#23548)
fjl Sep 8, 2021
9e17648
les: duplicate downloader and fetcher to allow progressive refactoring
karalabe Sep 10, 2021
9ada4a2
Merge pull request #23561 from karalabe/temp-split-leseh
karalabe Sep 10, 2021
578bc81
README: add londonBlock to example genesis config (#23565)
verheesj Sep 13, 2021
babe9b9
cmd/evm: transaction validation tool (#23494)
holiman Sep 13, 2021
b8d7c66
core, rpc: disable memory output by default in traces (#23558)
MariusVanDerWijden Sep 13, 2021
84ff152
cmd/devp2p/internal/ethtest: only use eth66 if eth66 is negotiated (#…
MariusVanDerWijden Sep 15, 2021
7ada89d
eth/tracers: abort evm execution when trace is aborted (#23580)
holiman Sep 16, 2021
4013549
core,eth: call frame tracing (#23087)
s1na Sep 17, 2021
1b34283
ethclient, accounts/keystore: fix flaky tests (#23599)
holiman Sep 20, 2021
62e3b83
docs: fix spelling on 2021-08-22 postmortem (#23595)
peteyburgers Sep 20, 2021
e28f713
internal: support optional filter expression for debug.stacks (#23605)
karalabe Sep 20, 2021
9bf495b
internal/debug: make gosimple linter happy
karalabe Sep 20, 2021
86f3625
Merge pull request #23609 from karalabe/regex-fix
karalabe Sep 20, 2021
5b246af
go.mod: fix module file to prevent go from updating it during build
karalabe Sep 20, 2021
b1a5e4a
Merge pull request #23610 from karalabe/gomod-tify
karalabe Sep 20, 2021
d8211c7
console: add note about typing exit to exit (#23602)
thadguidry Sep 21, 2021
b61ef24
consensus/clique: prevent 0 len extradata from panicing (#23538)
MariusVanDerWijden Sep 21, 2021
ca9bce9
rpc: set scheme for ws and ipc conns to the server (#23615)
s1na Sep 21, 2021
57a3fab
accounts/abi: fix resolving single struct argument (#23573)
rjl493456442 Sep 22, 2021
51ececb
rpc: set pong read deadline (#23556)
jmank88 Sep 27, 2021
12674d4
cmd/puppeth: remove shh from Dockerfile (#23634)
Zachinquarantine Sep 27, 2021
ac7baea
eth/tracers: re-write of 4byte tracer using enter/exit (#23622)
s1na Sep 27, 2021
443afc9
core/state: move state account to core/types + abstracted "write acco…
gballet Sep 28, 2021
ab2caae
eth/tracers: implement debug.intermediateRoots (#23594)
holiman Sep 28, 2021
783e97e
core/rawdb: avoid unnecessary receipt processing for log filtering (#…
s1na Sep 28, 2021
92c5d10
accounts/abi/bind: check event signature before parsing (#23230)
yihau Sep 28, 2021
3531ca2
eth/tracers: avoid unsyncronized mutations on trie database (#23632)
holiman Sep 28, 2021
a541fbe
eth/protocols/eth: simplify peer known block/txs caches (#23649)
ferranbt Sep 28, 2021
42bc194
graphql: add storage slots to access list (#23650)
holiman Sep 28, 2021
3a6fe69
eth/protocols/snap, trie: better error-handling (#23657)
holiman Sep 29, 2021
eae3b19
params: release go-ethereum v1.10.9 stable
fjl Sep 29, 2021
7a5ca37
Merge upstream 'v1.10.7' into 32c0e7080ad01b6dd7798d2d333728573999a441
junnmm Feb 1, 2023
4a9b33a
Merge upstream 'v1.10.8' into 7a5ca3719095f073677f8d01c28c0f116d1e2c14
junnmm Feb 1, 2023
ab55698
Merge upstream 'v1.10.9' into 4a9b33acb2dc68a75d73916eb273dd2003f4d687
junnmm Feb 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "tests"]
path = tests/testdata
url = https://github.com/ethereum/tests
shallow = true
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file configures github.com/golangci/golangci-lint.

run:
timeout: 3m
timeout: 5m
tests: true
# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
Expand Down
28 changes: 14 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
allow_failures:
- stage: build
os: osx
go: 1.15.x
go: 1.17.x
env:
- azure-osx
- azure-ios
Expand All @@ -16,7 +16,7 @@ jobs:
- stage: lint
os: linux
dist: bionic
go: 1.16.x
go: 1.17.x
env:
- lint
git:
Expand All @@ -31,7 +31,7 @@ jobs:
os: linux
arch: amd64
dist: bionic
go: 1.16.x
go: 1.17.x
env:
- docker
services:
Expand All @@ -41,14 +41,14 @@ jobs:
before_install:
- export DOCKER_CLI_EXPERIMENTAL=enabled
script:
- go run build/ci.go docker -image -manifest amd64,arm64 -upload karalabe/geth-docker-test
- go run build/ci.go docker -image -manifest amd64,arm64 -upload ethereum/client-go

- stage: build
if: type = push
os: linux
arch: arm64
dist: bionic
go: 1.16.x
go: 1.17.x
env:
- docker
services:
Expand All @@ -58,14 +58,14 @@ jobs:
before_install:
- export DOCKER_CLI_EXPERIMENTAL=enabled
script:
- go run build/ci.go docker -image -manifest amd64,arm64 -upload karalabe/geth-docker-test
- go run build/ci.go docker -image -manifest amd64,arm64 -upload ethereum/client-go

# This builder does the Ubuntu PPA upload
- stage: build
if: type = push
os: linux
dist: bionic
go: 1.16.x
go: 1.17.x
env:
- ubuntu-ppa
- GO111MODULE=on
Expand All @@ -90,7 +90,7 @@ jobs:
os: linux
dist: bionic
sudo: required
go: 1.16.x
go: 1.17.x
env:
- azure-linux
- GO111MODULE=on
Expand Down Expand Up @@ -127,7 +127,7 @@ jobs:
dist: bionic
services:
- docker
go: 1.16.x
go: 1.17.x
env:
- azure-linux-mips
- GO111MODULE=on
Expand Down Expand Up @@ -192,7 +192,7 @@ jobs:
- stage: build
if: type = push
os: osx
go: 1.16.x
go: 1.17.x
env:
- azure-osx
- azure-ios
Expand Down Expand Up @@ -224,7 +224,7 @@ jobs:
os: linux
arch: amd64
dist: bionic
go: 1.16.x
go: 1.17.x
env:
- GO111MODULE=on
script:
Expand All @@ -235,7 +235,7 @@ jobs:
os: linux
arch: arm64
dist: bionic
go: 1.16.x
go: 1.17.x
env:
- GO111MODULE=on
script:
Expand All @@ -244,7 +244,7 @@ jobs:
- stage: build
os: linux
dist: bionic
go: 1.15.x
go: 1.16.x
env:
- GO111MODULE=on
script:
Expand All @@ -255,7 +255,7 @@ jobs:
if: type = cron
os: linux
dist: bionic
go: 1.16.x
go: 1.17.x
env:
- azure-purge
- GO111MODULE=on
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG VERSION=""
ARG BUILDNUM=""

# Build Geth in a stock Go builder container
FROM golang:1.16-alpine as builder
FROM golang:1.17-alpine as builder

RUN apk add --no-cache gcc musl-dev linux-headers git

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.alltools
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG VERSION=""
ARG BUILDNUM=""

# Build Geth in a stock Go builder container
FROM golang:1.16-alpine as builder
FROM golang:1.17-alpine as builder

RUN apk add --no-cache gcc musl-dev linux-headers git

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $ geth console
```

This command will:
* Start `geth` in fast sync mode (default, can be changed with the `--syncmode` flag),
* Start `geth` in snap sync mode (default, can be changed with the `--syncmode` flag),
causing it to download more data in exchange for avoiding processing the entire history
of the KCC network, which is very CPU intensive.
* Start up `geth`'s built-in interactive [JavaScript console](https://geth.ethereum.org/docs/interface/javascript-console),
Expand Down
2 changes: 2 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Audit reports are published in the `docs` folder: https://github.com/ethereum/go
| ------- | ------- | ----------- |
| `geth` | 20170425 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2017-04-25_Geth-audit_Truesec.pdf) |
| `clef` | 20180914 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2018-09-14_Clef-audit_NCC.pdf) |
| `Discv5` | 20191015 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2019-10-15_Discv5_audit_LeastAuthority.pdf) |
| `Discv5` | 20200124 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2020-01-24_DiscV5_audit_Cure53.pdf) |

## Reporting a Vulnerability

Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (arguments Arguments) copyAtomic(v interface{}, marshalledValues interface{
dst := reflect.ValueOf(v).Elem()
src := reflect.ValueOf(marshalledValues)

if dst.Kind() == reflect.Struct && src.Kind() != reflect.Struct {
if dst.Kind() == reflect.Struct {
return set(dst.Field(0), src)
}
return set(dst, src)
Expand Down
6 changes: 6 additions & 0 deletions accounts/abi/bind/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package bind

import (
"context"
"crypto/ecdsa"
"errors"
"io"
Expand Down Expand Up @@ -74,6 +75,7 @@ func NewKeyStoreTransactor(keystore *keystore.KeyStore, account accounts.Account
}
return tx.WithSignature(signer, signature)
},
Context: context.Background(),
}, nil
}

Expand All @@ -97,6 +99,7 @@ func NewKeyedTransactor(key *ecdsa.PrivateKey) *TransactOpts {
}
return tx.WithSignature(signer, signature)
},
Context: context.Background(),
}
}

Expand Down Expand Up @@ -133,6 +136,7 @@ func NewKeyStoreTransactorWithChainID(keystore *keystore.KeyStore, account accou
}
return tx.WithSignature(signer, signature)
},
Context: context.Background(),
}, nil
}

Expand All @@ -156,6 +160,7 @@ func NewKeyedTransactorWithChainID(key *ecdsa.PrivateKey, chainID *big.Int) (*Tr
}
return tx.WithSignature(signer, signature)
},
Context: context.Background(),
}, nil
}

Expand All @@ -170,5 +175,6 @@ func NewClefTransactor(clef *external.ExternalSigner, account accounts.Account)
}
return clef.SignTx(account, transaction, nil) // Clef enforces its own chain id
},
Context: context.Background(),
}
}
19 changes: 15 additions & 4 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,19 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
} else {
hi = b.pendingBlock.GasLimit()
}
// Normalize the max fee per gas the call is willing to spend.
var feeCap *big.Int
if call.GasPrice != nil && (call.GasFeeCap != nil || call.GasTipCap != nil) {
return 0, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
} else if call.GasPrice != nil {
feeCap = call.GasPrice
} else if call.GasFeeCap != nil {
feeCap = call.GasFeeCap
} else {
feeCap = common.Big0
}
// Recap the highest gas allowance with account's balance.
if call.GasPrice != nil && call.GasPrice.BitLen() != 0 {
if feeCap.BitLen() != 0 {
balance := b.pendingState.GetBalance(call.From) // from can't be nil
available := new(big.Int).Set(balance)
if call.Value != nil {
Expand All @@ -498,14 +509,14 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
}
available.Sub(available, call.Value)
}
allowance := new(big.Int).Div(available, call.GasPrice)
allowance := new(big.Int).Div(available, feeCap)
if allowance.IsUint64() && hi > allowance.Uint64() {
transfer := call.Value
if transfer == nil {
transfer = new(big.Int)
}
log.Warn("Gas estimation capped by limited funds", "original", hi, "balance", balance,
"sent", transfer, "gasprice", call.GasPrice, "fundable", allowance)
"sent", transfer, "feecap", feeCap, "fundable", allowance)
hi = allowance.Uint64()
}
}
Expand Down Expand Up @@ -784,7 +795,7 @@ type callMsg struct {

func (m callMsg) From() common.Address { return m.CallMsg.From }
func (m callMsg) Nonce() uint64 { return 0 }
func (m callMsg) CheckNonce() bool { return false }
func (m callMsg) IsFake() bool { return true }
func (m callMsg) To() *common.Address { return m.CallMsg.To }
func (m callMsg) GasPrice() *big.Int { return m.CallMsg.GasPrice }
func (m callMsg) GasFeeCap() *big.Int { return m.CallMsg.GasFeeCap }
Expand Down
23 changes: 23 additions & 0 deletions accounts/abi/bind/backends/simulated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,26 @@ func TestEstimateGasWithPrice(t *testing.T) {
Value: big.NewInt(100000000000),
Data: nil,
}, 21000, errors.New("gas required exceeds allowance (10999)")}, // 10999=(2.2ether-1000wei)/(2e14)

{"EstimateEIP1559WithHighFees", ethereum.CallMsg{
From: addr,
To: &addr,
Gas: 0,
GasFeeCap: big.NewInt(1e14), // maxgascost = 2.1ether
GasTipCap: big.NewInt(1),
Value: big.NewInt(1e17), // the remaining balance for fee is 2.1ether
Data: nil,
}, params.TxGas, nil},

{"EstimateEIP1559WithSuperHighFees", ethereum.CallMsg{
From: addr,
To: &addr,
Gas: 0,
GasFeeCap: big.NewInt(1e14), // maxgascost = 2.1ether
GasTipCap: big.NewInt(1),
Value: big.NewInt(1e17 + 1), // the remaining balance for fee is 2.1ether
Data: nil,
}, params.TxGas, errors.New("gas required exceeds allowance (20999)")}, // 20999=(2.2ether-0.1ether-1wei)/(1e14)
}
for i, c := range cases {
got, err := sim.EstimateGas(context.Background(), c.message)
Expand All @@ -592,6 +612,9 @@ func TestEstimateGasWithPrice(t *testing.T) {
}
continue
}
if c.expectError == nil && err != nil {
t.Fatalf("test %d: didn't expect error, got %v", i, err)
}
if got != c.expect {
t.Fatalf("test %d: gas estimation mismatch, want %d, got %d", i, c.expect, got)
}
Expand Down
31 changes: 31 additions & 0 deletions accounts/abi/bind/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"errors"
"fmt"
"math/big"
"strings"
"sync"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
Expand Down Expand Up @@ -76,6 +78,29 @@ type WatchOpts struct {
Context context.Context // Network context to support cancellation and timeouts (nil = no timeout)
}

// MetaData collects all metadata for a bound contract.
type MetaData struct {
mu sync.Mutex
Sigs map[string]string
Bin string
ABI string
ab *abi.ABI
}

func (m *MetaData) GetAbi() (*abi.ABI, error) {
m.mu.Lock()
defer m.mu.Unlock()
if m.ab != nil {
return m.ab, nil
}
if parsed, err := abi.JSON(strings.NewReader(m.ABI)); err != nil {
return nil, err
} else {
m.ab = &parsed
}
return m.ab, nil
}

// BoundContract is the base wrapper object that reflects a contract on the
// Ethereum network. It contains a collection of methods that are used by the
// higher level contract bindings to operate.
Expand Down Expand Up @@ -406,6 +431,9 @@ func (c *BoundContract) WatchLogs(opts *WatchOpts, name string, query ...[]inter

// UnpackLog unpacks a retrieved log into the provided output structure.
func (c *BoundContract) UnpackLog(out interface{}, event string, log types.Log) error {
if log.Topics[0] != c.abi.Events[event].ID {
return fmt.Errorf("event signature mismatch")
}
if len(log.Data) > 0 {
if err := c.abi.UnpackIntoInterface(out, event, log.Data); err != nil {
return err
Expand All @@ -422,6 +450,9 @@ func (c *BoundContract) UnpackLog(out interface{}, event string, log types.Log)

// UnpackLogIntoMap unpacks a retrieved log into the provided map.
func (c *BoundContract) UnpackLogIntoMap(out map[string]interface{}, event string, log types.Log) error {
if log.Topics[0] != c.abi.Events[event].ID {
return fmt.Errorf("event signature mismatch")
}
if len(log.Data) > 0 {
if err := c.abi.UnpackIntoMap(out, event, log.Data); err != nil {
return err
Expand Down