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

[Upgrade] Go-Ethereum release v1.9.25 #1223

Merged
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
919229d
params: begin v1.9.25 release cycle
fjl Nov 12, 2020
a19b423
crypto/bn256: improve bn256 fuzzer (#21815)
holiman Nov 13, 2020
9ded4e3
crypto/bn256: better comments for u, P and Order (#21836)
MariusVanDerWijden Nov 13, 2020
0703c91
tests/fuzzers: improve the fuzzers (#21829)
holiman Nov 13, 2020
6f4cccf
core/vm, protocol_params: implement eip-2565 modexp repricing (#21607)
holiman Nov 13, 2020
2045a2b
core, all: split vm.Context into BlockContext and TxContext (#21672)
MariusVanDerWijden Nov 13, 2020
cf856ea
accounts/abi: template: set events Raw field in Parse methods (#21807)
nfeignon Nov 13, 2020
92c56eb
common: fix documentation of Address.SetBytes (#21814)
PascalDierich Nov 16, 2020
1ea7537
crypto/bn256: refine comments according to #19577, #21595, and #21836…
SadPencil Nov 17, 2020
844485e
consensus/ethash: fix usage of *reflect.SliceHeader (#21372)
prestonvanloon Nov 17, 2020
d513584
cmd/geth: remove retesteth
holiman Nov 17, 2020
db87223
crypto/secp256k1: add checking z sign in affineFromJacobian (#18419)
hbakhtiyor Nov 17, 2020
6b98580
cmd/geth: improve les test on windows (#21860)
holiman Nov 17, 2020
23524f8
all: disable recording preimage of trie keys (#21402)
rjl493456442 Nov 18, 2020
b9ff57c
metrics: fix the panic for reading empty cpu stats (#21864)
rjl493456442 Nov 18, 2020
2808046
Merge pull request #21861 from holiman/remove_retesteth
karalabe Nov 19, 2020
f1e1d9f
node: support expressive origin rules in ws.origins (#21481)
wbt Nov 19, 2020
6f88d65
trie, rpc, cmd/geth: fix tests on 32-bit and windows + minor rpc fixe…
holiman Nov 19, 2020
ebb9591
crypto/bn256: fix bn256Mul fuzzer to not hang on large input (#21872)
holiman Nov 20, 2020
3ef5277
p2p: avoid spinning loop on out-of-handles (#21878)
holiman Nov 20, 2020
bddf5aa
les/utils: protect against WeightedRandomSelect overflow (#21839)
zsfelfoldi Nov 23, 2020
f6e1aed
github: Add new style of issue-templates
ligi Nov 23, 2020
6104ab6
tests/fuzzers/bls1381: add bls fuzzer (#21796)
holiman Nov 23, 2020
ead8146
Merge pull request #21890 from ligi/issue_templates
karalabe Nov 23, 2020
6b58409
cmd/faucet: improve handling of facebook post url (#21838)
LieutenantRoger Nov 24, 2020
bddd103
les: fix GetProofsV2 bug (#21896)
zsfelfoldi Nov 24, 2020
7e7a3f0
github: Remove vulnerability.md (#21894)
ligi Nov 24, 2020
59b480a
cmd/devp2p/internal/ethtest: add 'large announcement' tests (#21792)
MariusVanDerWijden Nov 24, 2020
29efe1f
core/types: fixed typo (#21897)
MariusVanDerWijden Nov 25, 2020
c92faee
all: simplify nested complexity and if blocks ending with a return st…
alexprut Nov 25, 2020
f59ed35
graphql: always return 400 if errors are present in the response (#21…
atoulme Nov 25, 2020
810f9e0
all: remove redundant conversions and import names (#21903)
alexprut Nov 25, 2020
429e714
p2p/discover: fix deadlock in discv5 message dispatch (#21858)
nisdas Nov 25, 2020
fa572cd
crypto: signing builds with signify/minisign (#21798)
gballet Nov 27, 2020
b71334a
accounts, signer: fix Ledger Live account derivation path (clef) (#21…
svenski123 Nov 29, 2020
566cb4c
accounts/keystore: add missing function doc for SignText (#21914)
pmerkleplant Nov 30, 2020
aba0c23
cmd/geth: make tests run quicker + use less memory and disk (#21919)
holiman Nov 30, 2020
a1ddd9e
cmd/devp2p/internal/ethtest: add transaction tests (#21857)
MariusVanDerWijden Nov 30, 2020
e7db1db
p2p/nodestate: fix deadlock during shutdown of les server (#21927)
holiman Nov 30, 2020
a2795c8
les: fix nodiscover option (#21906)
zsfelfoldi Dec 1, 2020
908c180
params: update CHTs (#21941)
rjl493456442 Dec 2, 2020
e9e86ae
eth: fix error in tracing if reexec is set (#21830)
holiman Dec 2, 2020
0b2f144
go.mod: update github.com/golang/snappy(#21934)
holiman Dec 2, 2020
d7a64dc
cmd/devp2p: add node filter for snap + fix arg error (#21950)
holiman Dec 3, 2020
62cedb3
core/vm/runtime: remove duplicated line (#21956)
ziogaschr Dec 4, 2020
7770e41
core: improve contextual information on core errors (#21869)
holiman Dec 4, 2020
15339cf
cmd/geth: implement vulnerability check (#21859)
holiman Dec 4, 2020
581c028
les: cosmetic rewrite of the arm64 float bug workaround (#21960)
gballet Dec 7, 2020
6a4e730
crypto/secp256k1: add workaround for go mod vendor (#21735)
steveruckdashel Dec 8, 2020
ed0670c
accounts/abi/bind: allow specifying signer on transactOpts (#21356)
MariusVanDerWijden Dec 8, 2020
bd848aa
common: improve printing of Hash and Address (#21834)
lobatt Dec 8, 2020
40b6ccf
core,les: headerchain import in batches (#21471)
holiman Dec 9, 2020
915643a
cmd/geth: add test to verify regexps in version check (#21962)
holiman Dec 9, 2020
f935b1d
crypto/signify, build: fix archive signing with signify (#21977)
fjl Dec 9, 2020
817a3fb
p2p/enode: avoid crashing for invalid IP (#21981)
fjl Dec 9, 2020
9f6bb49
les, light: remove untrusted header retrieval in ODR (#21907)
rjl493456442 Dec 10, 2020
b44f24e
core, trie: speed up some tests with quadratic processing flaw (#21987)
holiman Dec 10, 2020
0045410
les: introduce forkID (#21974)
rjl493456442 Dec 10, 2020
1d1f5fe
build: upgrade to Go 1.15.6 (#21986)
fjl Dec 11, 2020
e787272
params: go-ethereum v1.9.25 stable
fjl Dec 11, 2020
a2e5c23
Merge branch 'master' into upgrade/go-ethereum/v1.9.25-2021629165723
baptiste-b-pegasys Jun 30, 2021
e1c2ee2
fix: merge
baptiste-b-pegasys Jun 30, 2021
f5b4406
fix: review GoQ versions
baptiste-b-pegasys Jun 30, 2021
3d961be
fix: GoQuorum signer
baptiste-b-pegasys Jun 30, 2021
d7e51ed
fix: state processor, missing err formatting
baptiste-b-pegasys Jun 30, 2021
88a5a9a
fix: restore tx GoQ modification
baptiste-b-pegasys Jun 30, 2021
f2f0f6b
fix: work with eip155 & psm tests
baptiste-b-pegasys Jun 30, 2021
358cba8
fix: cmd geth tests
baptiste-b-pegasys Jul 1, 2021
2149d5e
Merge branch 'master' into upgrade/go-ethereum/v1.9.25-2021629165723
baptiste-b-pegasys Jul 1, 2021
56ac367
fix: format (lint)
baptiste-b-pegasys Jul 1, 2021
72b09ad
fix: copy default value, don't erase it
baptiste-b-pegasys Jul 1, 2021
43261ed
Merge branch 'master' into upgrade/go-ethereum/v1.9.25-2021629165723
baptiste-b-pegasys Jul 28, 2021
3f48409
fix: cache config -> trie Config
baptiste-b-pegasys Jul 28, 2021
e2c853e
fix: unit test restored, check another error
baptiste-b-pegasys Jul 28, 2021
fdfb5ef
refactor: remove unused parameters
baptiste-b-pegasys Jul 28, 2021
6f24cf2
fix: configure with default cache config
baptiste-b-pegasys Jul 28, 2021
f82b3ca
Merge branch 'master' into upgrade/go-ethereum/v1.9.25-2021629165723
baptiste-b-pegasys Aug 16, 2021
057f9ca
fix: merge of master
baptiste-b-pegasys Aug 16, 2021
16eb371
Merge branch 'master' into upgrade/go-ethereum/v1.9.25-2021629165723
baptiste-b-pegasys Aug 19, 2021
ceb1f73
Merge branch 'master' into upgrade/go-ethereum/v1.9.25-2021629165723
baptiste-b-pegasys Aug 19, 2021
a1890de
Merge branch 'master' into upgrade/go-ethereum/v1.9.25-2021629165723
baptiste-b-pegasys Aug 25, 2021
09e33d1
Merge branch 'master' into upgrade/go-ethereum/v1.9.25-2021629165723
ricardolyn Aug 30, 2021
f8613cf
Merge branch 'master' into upgrade/go-ethereum/v1.9.25-2021629165723
ricardolyn Aug 31, 2021
8e73b07
go 1.15.6
baptiste-b-pegasys Aug 31, 2021
3e39272
fix: for review
baptiste-b-pegasys Aug 31, 2021
0067960
revert: unnecessary change
baptiste-b-pegasys Aug 31, 2021
f2e60a6
fix: remove comment
baptiste-b-pegasys Aug 31, 2021
7897ab3
fix: review of variable name
baptiste-b-pegasys Aug 31, 2021
ae50ace
fix: use the ChainContext interface
baptiste-b-pegasys Aug 31, 2021
12a2e39
fix: null pointer
baptiste-b-pegasys Aug 31, 2021
341635d
fix: don't check nil pointer
baptiste-b-pegasys Sep 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/ISSUE_TEMPLATE.md → .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Hi there,

Please note that this is an issue tracker reserved for bug reports and feature requests.

For general questions please use [discord](https://discord.gg/nthXNEv) or the Ethereum stack exchange at https://ethereum.stackexchange.com.
---
name: Report a bug
about: Something with go-ethereum is not working as expected
title: ''
labels: 'type:bug'
assignees: ''
---

#### System information

Expand Down
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Request a feature
about: Report a missing feature - e.g. as a step before submitting a PR
title: ''
labels: 'type:feature'
assignees: ''
---

# Rationale

Why should this feature exist?
What are the use-cases?

# Implementation

Do you have ideas regarding the implementation of this feature?
Are you willing to implement this feature?
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: Ask a question
about: Something is unclear
title: ''
labels: 'type:docs'
assignees: ''
---

This should only be used in very rare cases e.g. if you are not 100% sure if something is a bug or asking a question that leads to improving the documentation. For general questions please use [discord](https://discord.gg/nthXNEv) or the Ethereum stack exchange at https://ethereum.stackexchange.com.
26 changes: 13 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ jobs:
script:
# Build for the primary platforms that Trusty can manage
- go run build/ci.go install -dlgo
- go run build/ci.go archive -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
- go run build/ci.go archive -type tar -signer LINUX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds
- go run build/ci.go install -dlgo -arch 386
- go run build/ci.go archive -arch 386 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
- go run build/ci.go archive -arch 386 -type tar -signer LINUX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds

# Switch over GCC to cross compilation (breaks 386, hence why do it here only)
- sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install gcc-arm-linux-gnueabi libc6-dev-armel-cross gcc-arm-linux-gnueabihf libc6-dev-armhf-cross gcc-aarch64-linux-gnu libc6-dev-arm64-cross
- sudo ln -s /usr/include/asm-generic /usr/include/asm

- GOARM=5 go run build/ci.go install -dlgo -arch arm -cc arm-linux-gnueabi-gcc
- GOARM=5 go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
- GOARM=5 go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds
- GOARM=6 go run build/ci.go install -dlgo -arch arm -cc arm-linux-gnueabi-gcc
- GOARM=6 go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
- GOARM=6 go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds
- GOARM=7 go run build/ci.go install -dlgo -arch arm -cc arm-linux-gnueabihf-gcc
- GOARM=7 go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
- GOARM=7 go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds
- go run build/ci.go install -dlgo -arch arm64 -cc aarch64-linux-gnu-gcc
- go run build/ci.go archive -arch arm64 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
- go run build/ci.go archive -arch arm64 -type tar -signer LINUX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds

# This builder does the Linux Azure MIPS xgo uploads
- stage: build
Expand All @@ -100,19 +100,19 @@ jobs:
script:
- go run build/ci.go xgo --alltools -- --targets=linux/mips --ldflags '-extldflags "-static"' -v
- for bin in build/bin/*-linux-mips; do mv -f "${bin}" "${bin/-linux-mips/}"; done
- go run build/ci.go archive -arch mips -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
- go run build/ci.go archive -arch mips -type tar -signer LINUX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds

- go run build/ci.go xgo --alltools -- --targets=linux/mipsle --ldflags '-extldflags "-static"' -v
- for bin in build/bin/*-linux-mipsle; do mv -f "${bin}" "${bin/-linux-mipsle/}"; done
- go run build/ci.go archive -arch mipsle -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
- go run build/ci.go archive -arch mipsle -type tar -signer LINUX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds

- go run build/ci.go xgo --alltools -- --targets=linux/mips64 --ldflags '-extldflags "-static"' -v
- for bin in build/bin/*-linux-mips64; do mv -f "${bin}" "${bin/-linux-mips64/}"; done
- go run build/ci.go archive -arch mips64 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
- go run build/ci.go archive -arch mips64 -type tar -signer LINUX_SIGNING_KEY signify SIGNIFY_KEY -upload gethstore/builds

- go run build/ci.go xgo --alltools -- --targets=linux/mips64le --ldflags '-extldflags "-static"' -v
- for bin in build/bin/*-linux-mips64le; do mv -f "${bin}" "${bin/-linux-mips64le/}"; done
- go run build/ci.go archive -arch mips64le -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
- go run build/ci.go archive -arch mips64le -type tar -signer LINUX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds

# This builder does the Android Maven and Azure uploads
- stage: build
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:

- mkdir -p $GOPATH/src/github.com/ethereum
- ln -s `pwd` $GOPATH/src/github.com/ethereum/go-ethereum
- go run build/ci.go aar -signer ANDROID_SIGNING_KEY -deploy https://oss.sonatype.org -upload gethstore/builds
- go run build/ci.go aar -signer ANDROID_SIGNING_KEY -signify SIGNIFY_KEY -deploy https://oss.sonatype.org -upload gethstore/builds

# This builder does the OSX Azure, iOS CocoaPods and iOS Azure uploads
- stage: build
Expand All @@ -167,7 +167,7 @@ jobs:
submodules: false # avoid cloning ethereum/tests
script:
- go run build/ci.go install -dlgo
- go run build/ci.go archive -type tar -signer OSX_SIGNING_KEY -upload gethstore/builds
- go run build/ci.go archive -type tar -signer OSX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds

# Build the iOS framework and upload it to CocoaPods and Azure
- gem uninstall cocoapods -a -x
Expand All @@ -182,7 +182,7 @@ jobs:

# Workaround for https://github.com/golang/go/issues/23749
- export CGO_CFLAGS_ALLOW='-fmodules|-fblocks|-fobjc-arc'
- go run build/ci.go xcode -signer IOS_SIGNING_KEY -deploy trunk -upload gethstore/builds
- go run build/ci.go xcode -signer IOS_SIGNING_KEY -signify SIGNIFY_KEY -deploy trunk -upload gethstore/builds

# These builders run the tests
- stage: build
Expand Down
118 changes: 110 additions & 8 deletions accounts/abi/bind/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,29 @@ import (
"errors"
"io"
"io/ioutil"
"math/big"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/external"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
)

// ErrNoChainID is returned whenever the user failed to specify a chain id.
var ErrNoChainID = errors.New("no chain id specified")

// ErrNotAuthorized is returned when an account is not properly unlocked.
var ErrNotAuthorized = errors.New("not authorized to sign this account")

// NewTransactor is a utility method to easily create a transaction signer from
// an encrypted json key stream and the associated passphrase.
//
// Deprecated: Use NewTransactorWithChainID instead.
func NewTransactor(keyin io.Reader, passphrase string) (*TransactOpts, error) {
log.Warn("WARNING: NewTransactor has been deprecated in favour of NewTransactorWithChainID")
json, err := ioutil.ReadAll(keyin)
if err != nil {
return nil, err
Expand All @@ -45,14 +56,24 @@ func NewTransactor(keyin io.Reader, passphrase string) (*TransactOpts, error) {
}

// NewKeyStoreTransactor is a utility method to easily create a transaction signer from
// a decrypted key from a keystore.
// an decrypted key from a keystore.
//
// Deprecated: Use NewKeyStoreTransactorWithChainID instead.
func NewKeyStoreTransactor(keystore *keystore.KeyStore, account accounts.Account) (*TransactOpts, error) {
log.Warn("WARNING: NewKeyStoreTransactor has been deprecated in favour of NewTransactorWithChainID")
var Signer types.Signer = types.HomesteadSigner{}
return &TransactOpts{
From: account.Address,
Signer: func(signer types.Signer, address common.Address, tx *types.Transaction) (*types.Transaction, error) {
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
if address != account.Address {
return nil, errors.New("not authorized to sign this account")
return nil, ErrNotAuthorized
}
// Quorum
signer := Signer
if tx.IsPrivate() {
signer = types.QuorumPrivateTxSigner{}
}
// / Quorum
signature, err := keystore.SignHash(account, signer.Hash(tx).Bytes())
if err != nil {
return nil, err
Expand All @@ -64,14 +85,24 @@ func NewKeyStoreTransactor(keystore *keystore.KeyStore, account accounts.Account

// NewKeyedTransactor is a utility method to easily create a transaction signer
// from a single private key.
//
// Deprecated: Use NewKeyedTransactorWithChainID instead.
func NewKeyedTransactor(key *ecdsa.PrivateKey) *TransactOpts {
log.Warn("WARNING: NewKeyedTransactor has been deprecated in favour of NewKeyedTransactorWithChainID")
keyAddr := crypto.PubkeyToAddress(key.PublicKey)
var Signer types.Signer = types.HomesteadSigner{}
return &TransactOpts{
From: keyAddr,
Signer: func(signer types.Signer, address common.Address, tx *types.Transaction) (*types.Transaction, error) {
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
if address != keyAddr {
return nil, errors.New("not authorized to sign this account")
return nil, ErrNotAuthorized
}
// Quorum
signer := Signer
if tx.IsPrivate() {
signer = types.QuorumPrivateTxSigner{}
}
// / Quorum
signature, err := crypto.Sign(signer.Hash(tx).Bytes(), key)
if err != nil {
return nil, err
Expand All @@ -81,14 +112,85 @@ func NewKeyedTransactor(key *ecdsa.PrivateKey) *TransactOpts {
}
}

// NewTransactorWithChainID is a utility method to easily create a transaction signer from
// an encrypted json key stream and the associated passphrase.
func NewTransactorWithChainID(keyin io.Reader, passphrase string, chainID *big.Int) (*TransactOpts, error) {
json, err := ioutil.ReadAll(keyin)
if err != nil {
return nil, err
}
key, err := keystore.DecryptKey(json, passphrase)
if err != nil {
return nil, err
}
return NewKeyedTransactorWithChainID(key.PrivateKey, chainID)
}

// NewKeyStoreTransactorWithChainID is a utility method to easily create a transaction signer from
// an decrypted key from a keystore.
func NewKeyStoreTransactorWithChainID(keystore *keystore.KeyStore, account accounts.Account, chainID *big.Int) (*TransactOpts, error) {
if chainID == nil {
return nil, ErrNoChainID
}
var Signer types.Signer = types.NewEIP155Signer(chainID)
baptiste-b-pegasys marked this conversation as resolved.
Show resolved Hide resolved
return &TransactOpts{
From: account.Address,
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
if address != account.Address {
return nil, ErrNotAuthorized
}
// Quorum
signer := Signer
if tx.IsPrivate() {
signer = types.QuorumPrivateTxSigner{}
}
// / Quorum
signature, err := keystore.SignHash(account, signer.Hash(tx).Bytes())
if err != nil {
return nil, err
}
return tx.WithSignature(signer, signature)
},
}, nil
}

// NewKeyedTransactorWithChainID is a utility method to easily create a transaction signer
// from a single private key.
func NewKeyedTransactorWithChainID(key *ecdsa.PrivateKey, chainID *big.Int) (*TransactOpts, error) {
keyAddr := crypto.PubkeyToAddress(key.PublicKey)
if chainID == nil {
return nil, ErrNoChainID
}
var Signer types.Signer = types.NewEIP155Signer(chainID)
return &TransactOpts{
From: keyAddr,
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
if address != keyAddr {
return nil, ErrNotAuthorized
}
// Quorum
signer := Signer
if tx.IsPrivate() {
signer = types.QuorumPrivateTxSigner{}
}
// / Quorum
signature, err := crypto.Sign(signer.Hash(tx).Bytes(), key)
if err != nil {
return nil, err
}
return tx.WithSignature(signer, signature)
},
}, nil
}

// NewClefTransactor is a utility method to easily create a transaction signer
// with a clef backend.
func NewClefTransactor(clef *external.ExternalSigner, account accounts.Account) *TransactOpts {
return &TransactOpts{
From: account.Address,
Signer: func(signer types.Signer, address common.Address, transaction *types.Transaction) (*types.Transaction, error) {
Signer: func(address common.Address, transaction *types.Transaction) (*types.Transaction, error) {
if address != account.Address {
return nil, errors.New("not authorized to sign this account")
return nil, ErrNotAuthorized
}
return clef.SignTx(account, transaction, nil) // Clef enforces its own chain id
},
Expand All @@ -102,7 +204,7 @@ func NewClefTransactor(clef *external.ExternalSigner, account accounts.Account)
func NewWalletTransactor(w accounts.Wallet, account accounts.Account) *TransactOpts {
return &TransactOpts{
From: account.Address,
Signer: func(signer types.Signer, address common.Address, tx *types.Transaction) (*types.Transaction, error) {
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
if address != account.Address {
return nil, errors.New("not authorized to sign this account")
}
Expand Down
9 changes: 6 additions & 3 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type SimulatedBackend struct {

// NewSimulatedBackendWithDatabase creates a new binding backend based on the given database
// and uses a simulated blockchain for testing purposes.
// A simulated backend always uses chainID 1337.
func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
genesis := core.Genesis{Config: params.AllEthashProtocolChanges, GasLimit: gasLimit, Alloc: alloc}
genesis.MustCommit(database)
Expand Down Expand Up @@ -107,6 +108,7 @@ func NewSimulatedBackendFrom(ethereum *eth.Ethereum) *SimulatedBackend {

// NewSimulatedBackend creates a new binding backend using a simulated blockchain
// for testing purposes.
// A simulated backend always uses chainID 1337.
func NewSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
return NewSimulatedBackendWithDatabase(rawdb.NewMemoryDatabase(), alloc, gasLimit)
}
Expand Down Expand Up @@ -497,7 +499,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
b.pendingState.RevertToSnapshot(snapshot)

if err != nil {
if err == core.ErrIntrinsicGas {
if errors.Is(err, core.ErrIntrinsicGas) {
return true, nil, nil // Special case, raise gas limit
}
return true, nil, err // Bail out
Expand Down Expand Up @@ -560,10 +562,11 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
// Execute the call.
msg := callMsg{call}

evmContext := core.NewEVMContext(msg, block.Header(), b.blockchain, nil)
txContext := core.NewEVMTxContext(msg)
evmContext := core.NewEVMBlockContext(block.Header(), b.blockchain, nil)
// Create a new environment which holds all relevant information
// about the transaction and calling mechanisms.
vmEnv := vm.NewEVM(evmContext, stateDB, privateState, b.config, vm.Config{})
vmEnv := vm.NewEVM(evmContext, txContext, stateDB, privateState, b.config, vm.Config{})
gasPool := new(core.GasPool).AddGas(math.MaxUint64)

return core.NewStateTransition(vmEnv, msg, gasPool).TransitionDb()
Expand Down
12 changes: 6 additions & 6 deletions accounts/abi/bind/backends/simulated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
func TestSimulatedBackend(t *testing.T) {
var gasLimit uint64 = 8000029
key, _ := crypto.GenerateKey() // nolint: gosec
auth := bind.NewKeyedTransactor(key)
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
genAlloc := make(core.GenesisAlloc)
genAlloc[auth.From] = core.GenesisAccount{Balance: big.NewInt(9223372036854775807)}

Expand Down Expand Up @@ -417,7 +417,7 @@ func TestSimulatedBackend_EstimateGas(t *testing.T) {

key, _ := crypto.GenerateKey()
addr := crypto.PubkeyToAddress(key.PublicKey)
opts := bind.NewKeyedTransactor(key)
opts, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))

sim := NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(params.Ether)}}, 10000000)
defer sim.Close()
Expand Down Expand Up @@ -894,7 +894,7 @@ func TestSimulatedBackend_PendingCodeAt(t *testing.T) {
if err != nil {
t.Errorf("could not get code at test addr: %v", err)
}
auth := bind.NewKeyedTransactor(testKey)
auth, _ := bind.NewKeyedTransactorWithChainID(testKey, big.NewInt(1337))
contractAddr, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(abiBin), sim)
if err != nil {
t.Errorf("could not deploy contract: %v tx: %v contract: %v", err, tx, contract)
Expand Down Expand Up @@ -930,7 +930,7 @@ func TestSimulatedBackend_CodeAt(t *testing.T) {
if err != nil {
t.Errorf("could not get code at test addr: %v", err)
}
auth := bind.NewKeyedTransactor(testKey)
auth, _ := bind.NewKeyedTransactorWithChainID(testKey, big.NewInt(1337))
contractAddr, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(abiBin), sim)
if err != nil {
t.Errorf("could not deploy contract: %v tx: %v contract: %v", err, tx, contract)
Expand Down Expand Up @@ -962,7 +962,7 @@ func TestSimulatedBackend_PendingAndCallContract(t *testing.T) {
if err != nil {
t.Errorf("could not get code at test addr: %v", err)
}
contractAuth := bind.NewKeyedTransactor(testKey)
contractAuth, _ := bind.NewKeyedTransactorWithChainID(testKey, big.NewInt(1337))
addr, _, _, err := bind.DeployContract(contractAuth, parsed, common.FromHex(abiBin), sim)
if err != nil {
t.Errorf("could not deploy contract: %v", err)
Expand Down Expand Up @@ -1049,7 +1049,7 @@ func TestSimulatedBackend_CallContractRevert(t *testing.T) {
if err != nil {
t.Errorf("could not get code at test addr: %v", err)
}
contractAuth := bind.NewKeyedTransactor(testKey)
contractAuth, _ := bind.NewKeyedTransactorWithChainID(testKey, big.NewInt(1337))
addr, _, _, err := bind.DeployContract(contractAuth, parsed, common.FromHex(reverterBin), sim)
if err != nil {
t.Errorf("could not deploy contract: %v", err)
Expand Down
Loading