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 V0.2.12 candidate from maticnetwork:v0.2.12-candidate #7

Merged
merged 128 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
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)
n1charlie Sep 7, 2021
9a0df80
cmd/geth, cmd/utils: remove legacy rpc flags (#23358)
n1charlie 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)
n1charlie 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
06082fe
params: begin v1.10.10 release cycle
fjl Sep 29, 2021
f2491c5
core: fix typo in comment (#23658)
eltociear Sep 29, 2021
07a5bc1
internal/ethapi: support retrieving header RLPs too
karalabe Oct 1, 2021
a47b8cf
Merge pull request #23670 from karalabe/get-header-rlp
karalabe Oct 1, 2021
b522f5e
eth/tracers: fix callTracer fault handling (#23667)
s1na Oct 1, 2021
5240725
internal/ethapi: make header/block rlp retrieval canonical
karalabe Oct 3, 2021
01fdca5
Merge pull request #23677 from karalabe/canon-rlp-fetcher
karalabe Oct 3, 2021
12f971f
core/state: fix typo in comment (#23665)
hsyodyssey Oct 4, 2021
5a0e1d8
eth/filters: fix TestPendingLogsSubscription (#23619)
mirokuratczyk Oct 4, 2021
0dbb3b1
eth/protocols/eth: replace array with counter in txn broadcaster (#23…
ferranbt Oct 4, 2021
307156c
eth/api: add rpc method to obtain which states are accessible (#23646)
holiman Oct 5, 2021
57ff2de
go.mod: upgrade github.com/karalable/usb (#23684)
fjl Oct 5, 2021
4e599ee
core/types: copy tx recipient address (#23376)
aaronbuchwald Oct 6, 2021
edb1937
core: improve shutdown synchronization in BlockChain (#22853)
holiman Oct 7, 2021
48496e0
internal/ethapi: use correct signer when serving old blocks (#23683)
s1na Oct 7, 2021
ec2b43c
cmd/geth: fix typo in error message (#23697)
darcys22 Oct 8, 2021
2fe0c65
build: upgrade -dlgo version to 1.17.2 (#23698)
fjl Oct 8, 2021
28d30b5
eth: close miner on exit (instead of just stopping) (#21992)
holiman Oct 8, 2021
ee120ef
miner: fix data race during shutdown (#23435)
MariusVanDerWijden Oct 8, 2021
1bea4b0
miner/stress: initialize account backends explicitly (#23699)
fjl Oct 9, 2021
a6a0609
internal/jsre: handle null and undefined to prevent crash (#23701)
aditya520 Oct 10, 2021
84bccd0
core/state: fix typos in comments (#23702)
hsyodyssey Oct 10, 2021
bcbd700
eth/gasprice: avoid modifying TestChainConfig (#23204)
aaronbuchwald Oct 10, 2021
8a430fb
cmd/puppeth: add txpool to explorer Dockerfile (#23652)
n1charlie Oct 11, 2021
64da037
cmd/evm: stricter transaction validation (#23694)
holiman Oct 11, 2021
8b6e018
build: increase C thread stack size on linux (#23676)
gballet Oct 11, 2021
53b1420
params: changed CatalystBlock to TerminalTotalDifficulty (#23700)
MariusVanDerWijden Oct 11, 2021
088bc34
les/vflux/server: fix metrics (#22946)
rjl493456442 Oct 11, 2021
cf8a6d6
core: tests for forked blocks retrievable by hash (#23695)
mirokuratczyk Oct 11, 2021
da3da7c
ci: enable race tests as cron job on travis (#23480)
MariusVanDerWijden Oct 11, 2021
6289137
consensus/clique, core: API cleanup (#23100)
holiman Oct 11, 2021
3d11a22
fixed broken web3 methods link in README.md (#23703)
z89 Oct 12, 2021
633e7ef
eth,rpc: allow for flag configured timeouts for eth_call (#23645)
noam-alchemy Oct 12, 2021
f9d683b
go.mod: upgrade goja (#23721)
fjl Oct 13, 2021
e4f570f
core/types: add MarshalBinary, UnmarshalBinary for Receipt (#22806)
i-norden Oct 13, 2021
778ff94
all: fix some go-critic linter warnings (#23709)
quasilyte Oct 13, 2021
79b727b
accounts/abi/bind: refactor transact method (#23719)
MariusVanDerWijden Oct 13, 2021
011fe3e
core: remove unused error from TxPool.Pending (#23720)
jwasinger Oct 13, 2021
08e782c
accounts/abi: add basic support for error types (#23161)
MariusVanDerWijden Oct 14, 2021
f915f68
core/state/snapshot: fix data race in layer flattening (#23628)
rjl493456442 Oct 15, 2021
bb74230
params: release go-ethereum v1.10.10 stable
fjl Oct 15, 2021
0aa8fee
Apply best practices to Dockerfile
Nov 5, 2021
1cd6c84
Vendor protobuf and go extension issue PR (#223)
rajatlko13 Nov 9, 2021
57898e4
Final touches to Dockerfiles
Nov 10, 2021
e58bdfa
Build the new CLI
Nov 10, 2021
8ce3032
Bump Go
Nov 10, 2021
ba25f84
Revert "Build the new CLI"
Nov 10, 2021
2191490
Add chain set head command (#226)
ferranbt Nov 11, 2021
5d0f0b7
Merge pull request #227 from maticnetwork/victor/pos-48-refactor-bor-…
vcastellm Nov 11, 2021
fc58176
Added Prometheus flag on bor-cli
0xsharma Nov 11, 2021
7b6bab4
Release multi-platform with goreleaser
Nov 9, 2021
f3a43f9
Added Prometheus to New CLI: fixes
0xsharma Nov 12, 2021
c23cd5e
minor Clean
0xsharma Nov 12, 2021
a5bcab1
Minor Clean-up
0xsharma Nov 12, 2021
cd6a163
minor cleanup
0xsharma Nov 12, 2021
9ab4781
Merge pull request #228 from maticnetwork/victor/pos-47-improve-bor-b…
vcastellm Nov 12, 2021
358e683
Added Prometheus Flag and Default
0xsharma Nov 12, 2021
3b264e9
Merge branch 'master' into main
0xsharma Nov 12, 2021
baed325
Merge pull request #231 from Shivam691999/main
0xsharma Nov 13, 2021
322e964
added opentelemetry config, flags, and setup (#235)
manav2401 Nov 17, 2021
78ba316
Adapt Dockerfile for development (#237)
vcastellm Nov 17, 2021
87f9b91
added service name in config and flags (#238)
manav2401 Nov 17, 2021
983e32b
merged geth v1.10.10
ssandeep Nov 22, 2021
c55094a
fix: bor receipt #1
jdkanani Nov 22, 2021
9513fbd
Write bor receipts in ancient
ferranbt Nov 22, 2021
ded22da
fix: bor receipt rlp
jdkanani Nov 22, 2021
908cbbf
fix: testcases
jdkanani Nov 22, 2021
5431702
merge conflicts
temaniarpit27 Nov 23, 2021
6f59153
Arpit/reorg fix 2 (#210)
temaniarpit27 Nov 25, 2021
fb79b8d
Merge pull request #242 from maticnetwork/geth-v1.10.10
ssandeep Nov 26, 2021
b1fb79a
Small tweeks to Dockerfiles (#247)
vcastellm Nov 30, 2021
149f47e
Fix ancient receipts
ferranbt Dec 1, 2021
d3010f4
Fix ancestor bor receipts (#249)
ferranbt Dec 1, 2021
08db8bc
bumped version to 0.2.11
ssandeep Dec 1, 2021
cf900a9
Changed syncmode from fast to full
0xsharma Dec 2, 2021
b633382
Merge pull request #250 from maticnetwork/shivam/newCLI-syncmode
0xsharma Dec 3, 2021
a7d97ce
Genesis change fix (#252)
temaniarpit27 Dec 3, 2021
e51394b
add block alloc
temaniarpit27 Dec 3, 2021
753301c
change block alloc
temaniarpit27 Dec 3, 2021
64ba7d6
remove byte array
temaniarpit27 Dec 3, 2021
488ea2b
mainnet upgrade
jdkanani Dec 4, 2021
a276c23
Merge branch 'master' of github.com:maticnetwork/bor into v0.2.12-can…
temaniarpit27 Dec 7, 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
Prev Previous commit
Next Next commit
accounts/abi/bind: refactor transact method (#23719)
This fixes a bug where gas-related fields of the TransactOpts passed
to transaction methods would be modified, skipping gas estimation for
subsequent transactions.

Co-authored-by: Yondon Fu <yondon.fu@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
  • Loading branch information
3 people authored Oct 13, 2021
commit 79b727bc8aa19a70c0735141e60da003d3624472
212 changes: 131 additions & 81 deletions accounts/abi/bind/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,108 +231,158 @@ func (c *BoundContract) Transfer(opts *TransactOpts) (*types.Transaction, error)
return c.transact(opts, &c.address, nil)
}

// transact executes an actual transaction invocation, first deriving any missing
// authorization fields, and then scheduling the transaction for execution.
func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error) {
var err error

// Ensure a valid value field and resolve the account nonce
func (c *BoundContract) createDynamicTx(opts *TransactOpts, contract *common.Address, input []byte, head *types.Header) (*types.Transaction, error) {
// Normalize value
value := opts.Value
if value == nil {
value = new(big.Int)
}
var nonce uint64
if opts.Nonce == nil {
nonce, err = c.transactor.PendingNonceAt(ensureContext(opts.Context), opts.From)
// Estimate TipCap
gasTipCap := opts.GasTipCap
if gasTipCap == nil {
tip, err := c.transactor.SuggestGasTipCap(ensureContext(opts.Context))
if err != nil {
return nil, fmt.Errorf("failed to retrieve account nonce: %v", err)
return nil, err
}
} else {
nonce = opts.Nonce.Uint64()
gasTipCap = tip
}
// Figure out reasonable gas price values
if opts.GasPrice != nil && (opts.GasFeeCap != nil || opts.GasTipCap != nil) {
return nil, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
// Estimate FeeCap
gasFeeCap := opts.GasFeeCap
if gasFeeCap == nil {
gasFeeCap = new(big.Int).Add(
gasTipCap,
new(big.Int).Mul(head.BaseFee, big.NewInt(2)),
)
}
head, err := c.transactor.HeaderByNumber(ensureContext(opts.Context), nil)
if gasFeeCap.Cmp(gasTipCap) < 0 {
return nil, fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", gasFeeCap, gasTipCap)
}
// Estimate GasLimit
gasLimit := opts.GasLimit
if opts.GasLimit == 0 {
var err error
gasLimit, err = c.estimateGasLimit(opts, contract, input, nil, gasTipCap, gasFeeCap, value)
if err != nil {
return nil, err
}
}
// create the transaction
nonce, err := c.getNonce(opts)
if err != nil {
return nil, err
}
if head.BaseFee != nil && opts.GasPrice == nil {
if opts.GasTipCap == nil {
tip, err := c.transactor.SuggestGasTipCap(ensureContext(opts.Context))
if err != nil {
return nil, err
}
opts.GasTipCap = tip
}
if opts.GasFeeCap == nil {
gasFeeCap := new(big.Int).Add(
opts.GasTipCap,
new(big.Int).Mul(head.BaseFee, big.NewInt(2)),
)
opts.GasFeeCap = gasFeeCap
}
if opts.GasFeeCap.Cmp(opts.GasTipCap) < 0 {
return nil, fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", opts.GasFeeCap, opts.GasTipCap)
}
} else {
if opts.GasFeeCap != nil || opts.GasTipCap != nil {
return nil, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet")
}
if opts.GasPrice == nil {
price, err := c.transactor.SuggestGasPrice(ensureContext(opts.Context))
if err != nil {
return nil, err
}
opts.GasPrice = price
baseTx := &types.DynamicFeeTx{
To: contract,
Nonce: nonce,
GasFeeCap: gasFeeCap,
GasTipCap: gasTipCap,
Gas: gasLimit,
Value: value,
Data: input,
}
return types.NewTx(baseTx), nil
}

func (c *BoundContract) createLegacyTx(opts *TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error) {
if opts.GasFeeCap != nil || opts.GasTipCap != nil {
return nil, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet")
}
// Normalize value
value := opts.Value
if value == nil {
value = new(big.Int)
}
// Estimate GasPrice
gasPrice := opts.GasPrice
if gasPrice == nil {
price, err := c.transactor.SuggestGasPrice(ensureContext(opts.Context))
if err != nil {
return nil, err
}
gasPrice = price
}
// Estimate GasLimit
gasLimit := opts.GasLimit
if gasLimit == 0 {
// Gas estimation cannot succeed without code for method invocations
if contract != nil {
if code, err := c.transactor.PendingCodeAt(ensureContext(opts.Context), c.address); err != nil {
return nil, err
} else if len(code) == 0 {
return nil, ErrNoCode
}
}
// If the contract surely has code (or code is not needed), estimate the transaction
msg := ethereum.CallMsg{From: opts.From, To: contract, GasPrice: opts.GasPrice, GasTipCap: opts.GasTipCap, GasFeeCap: opts.GasFeeCap, Value: value, Data: input}
gasLimit, err = c.transactor.EstimateGas(ensureContext(opts.Context), msg)
if opts.GasLimit == 0 {
var err error
gasLimit, err = c.estimateGasLimit(opts, contract, input, gasPrice, nil, nil, value)
if err != nil {
return nil, fmt.Errorf("failed to estimate gas needed: %v", err)
return nil, err
}
}
// Create the transaction, sign it and schedule it for execution
var rawTx *types.Transaction
if opts.GasFeeCap == nil {
baseTx := &types.LegacyTx{
Nonce: nonce,
GasPrice: opts.GasPrice,
Gas: gasLimit,
Value: value,
Data: input,
}
if contract != nil {
baseTx.To = &c.address
// create the transaction
nonce, err := c.getNonce(opts)
if err != nil {
return nil, err
}
baseTx := &types.LegacyTx{
To: contract,
Nonce: nonce,
GasPrice: gasPrice,
Gas: gasLimit,
Value: value,
Data: input,
}
return types.NewTx(baseTx), nil
}

func (c *BoundContract) estimateGasLimit(opts *TransactOpts, contract *common.Address, input []byte, gasPrice, gasTipCap, gasFeeCap, value *big.Int) (uint64, error) {
if contract != nil {
// Gas estimation cannot succeed without code for method invocations.
if code, err := c.transactor.PendingCodeAt(ensureContext(opts.Context), c.address); err != nil {
return 0, err
} else if len(code) == 0 {
return 0, ErrNoCode
}
rawTx = types.NewTx(baseTx)
}
msg := ethereum.CallMsg{
From: opts.From,
To: contract,
GasPrice: gasPrice,
GasTipCap: gasTipCap,
GasFeeCap: gasFeeCap,
Value: value,
Data: input,
}
return c.transactor.EstimateGas(ensureContext(opts.Context), msg)
}

func (c *BoundContract) getNonce(opts *TransactOpts) (uint64, error) {
if opts.Nonce == nil {
return c.transactor.PendingNonceAt(ensureContext(opts.Context), opts.From)
} else {
baseTx := &types.DynamicFeeTx{
Nonce: nonce,
GasFeeCap: opts.GasFeeCap,
GasTipCap: opts.GasTipCap,
Gas: gasLimit,
Value: value,
Data: input,
}
if contract != nil {
baseTx.To = &c.address
return opts.Nonce.Uint64(), nil
}
}

// transact executes an actual transaction invocation, first deriving any missing
// authorization fields, and then scheduling the transaction for execution.
func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error) {
if opts.GasPrice != nil && (opts.GasFeeCap != nil || opts.GasTipCap != nil) {
return nil, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
}
// Create the transaction
var (
rawTx *types.Transaction
err error
)
if opts.GasPrice != nil {
rawTx, err = c.createLegacyTx(opts, contract, input)
} else {
// Only query for basefee if gasPrice not specified
if head, errHead := c.transactor.HeaderByNumber(ensureContext(opts.Context), nil); err != nil {
return nil, errHead
} else if head.BaseFee != nil {
rawTx, err = c.createDynamicTx(opts, contract, input, head)
} else {
// Chain is not London ready -> use legacy transaction
rawTx, err = c.createLegacyTx(opts, contract, input)
}
rawTx = types.NewTx(baseTx)
}
if err != nil {
return nil, err
}
// Sign the transaction and schedule it for execution
if opts.Signer == nil {
return nil, errors.New("no signer to authorize the transaction with")
}
Expand Down
86 changes: 86 additions & 0 deletions accounts/abi/bind/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,49 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"
"github.com/stretchr/testify/assert"
)

func mockSign(addr common.Address, tx *types.Transaction) (*types.Transaction, error) { return tx, nil }

type mockTransactor struct {
baseFee *big.Int
gasTipCap *big.Int
gasPrice *big.Int
suggestGasTipCapCalled bool
suggestGasPriceCalled bool
}

func (mt *mockTransactor) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) {
return &types.Header{BaseFee: mt.baseFee}, nil
}

func (mt *mockTransactor) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error) {
return []byte{1}, nil
}

func (mt *mockTransactor) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) {
return 0, nil
}

func (mt *mockTransactor) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
mt.suggestGasPriceCalled = true
return mt.gasPrice, nil
}

func (mt *mockTransactor) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
mt.suggestGasTipCapCalled = true
return mt.gasTipCap, nil
}

func (mt *mockTransactor) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error) {
return 0, nil
}

func (mt *mockTransactor) SendTransaction(ctx context.Context, tx *types.Transaction) error {
return nil
}

type mockCaller struct {
codeAtBlockNumber *big.Int
callContractBlockNumber *big.Int
Expand Down Expand Up @@ -226,6 +267,51 @@ func TestUnpackIndexedBytesTyLogIntoMap(t *testing.T) {
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
}

func TestTransactGasFee(t *testing.T) {
assert := assert.New(t)

// GasTipCap and GasFeeCap
// When opts.GasTipCap and opts.GasFeeCap are nil
mt := &mockTransactor{baseFee: big.NewInt(100), gasTipCap: big.NewInt(5)}
bc := bind.NewBoundContract(common.Address{}, abi.ABI{}, nil, mt, nil)
opts := &bind.TransactOpts{Signer: mockSign}
tx, err := bc.Transact(opts, "")
assert.Nil(err)
assert.Equal(big.NewInt(5), tx.GasTipCap())
assert.Equal(big.NewInt(205), tx.GasFeeCap())
assert.Nil(opts.GasTipCap)
assert.Nil(opts.GasFeeCap)
assert.True(mt.suggestGasTipCapCalled)

// Second call to Transact should use latest suggested GasTipCap
mt.gasTipCap = big.NewInt(6)
mt.suggestGasTipCapCalled = false
tx, err = bc.Transact(opts, "")
assert.Nil(err)
assert.Equal(big.NewInt(6), tx.GasTipCap())
assert.Equal(big.NewInt(206), tx.GasFeeCap())
assert.True(mt.suggestGasTipCapCalled)

// GasPrice
// When opts.GasPrice is nil
mt = &mockTransactor{gasPrice: big.NewInt(5)}
bc = bind.NewBoundContract(common.Address{}, abi.ABI{}, nil, mt, nil)
opts = &bind.TransactOpts{Signer: mockSign}
tx, err = bc.Transact(opts, "")
assert.Nil(err)
assert.Equal(big.NewInt(5), tx.GasPrice())
assert.Nil(opts.GasPrice)
assert.True(mt.suggestGasPriceCalled)

// Second call to Transact should use latest suggested GasPrice
mt.gasPrice = big.NewInt(6)
mt.suggestGasPriceCalled = false
tx, err = bc.Transact(opts, "")
assert.Nil(err)
assert.Equal(big.NewInt(6), tx.GasPrice())
assert.True(mt.suggestGasPriceCalled)
}

func unpackAndCheck(t *testing.T, bc *bind.BoundContract, expected map[string]interface{}, mockLog types.Log) {
received := make(map[string]interface{})
if err := bc.UnpackLogIntoMap(received, "received", mockLog); err != nil {
Expand Down