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

implement EIP-1559 #527

Open
wants to merge 91 commits into
base: dev-upgrade
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
8dcbf2d
eth: fix typo balacne
gzliudan Aug 7, 2024
c592f61
core/types: drop type v4StoredReceiptRLP
gzliudan Jun 25, 2024
c66120e
core/types: replace core.SetReceiptsData with receipts.DeriveFields
gzliudan Jun 26, 2024
8938ff6
core/vm: make gas cost reporting to tracers correct (#22702)
holiman Apr 27, 2021
f923a31
core, params: implement EIP-3529 (#22733)
gzliudan Aug 22, 2024
4ef140e
all: implement eip-1559 (#22837)
gzliudan Apr 25, 2024
8b3951c
core: fix failing tests (#22888)
gzliudan May 28, 2024
5a04cb9
EIP-1559: miner changes (#22896)
gzliudan Apr 26, 2024
b18a68a
core: make txpool free space calculation more accurate (#22933)
gzliudan May 16, 2024
3304e7d
EIP-1559 tx pool support (#22898)
gzliudan May 17, 2024
7924cef
core: add new eip-1559 tx constraints (#22970)
gzliudan May 17, 2024
1979e04
core, eth, internal, les: RPC methods and fields for EIP 1559 (#22964)
gzliudan May 21, 2024
d0742af
params: print right Eip1559Block for ChainConfig
gzliudan May 22, 2024
90792ce
core, eth, miner: enforce configured mining reward post 1559 too (#22…
gzliudan May 23, 2024
07f3004
all: rename internal 1559 gas fields (#23010)
gzliudan May 24, 2024
844bcba
internal/ethapi: support for eip-1559 txs in clef (#22966)
gzliudan May 24, 2024
add10f0
core, internal: support various eth_call invocations post 1559 (#23027)
gzliudan May 24, 2024
ac8942e
eth/ethconfig: bump the RPC gas cap to 50M, since 1559 exceeds 25 (#2…
gzliudan May 24, 2024
16ec35f
core/vm: evm fix panic (#23047)
gzliudan Sep 19, 2024
1b5527a
Access list state test format (#22290)
gzliudan May 24, 2024
6e7cb9d
accounts/abi/bind: add NoSend transact option (#22446)
reds Mar 19, 2021
88daa96
tests: update for London (#22976)
gzliudan May 24, 2024
901d864
core: make genesis parse baseFee correctly (#23013)
gzliudan May 24, 2024
12d1c94
core: change baseFee into baseFeePerGas in genesis json (#23039)
gzliudan May 24, 2024
4f8bdcc
accounts/abi/bind: fix bounded contracts and sim backend for 1559 (#2…
gzliudan May 27, 2024
80620bb
core, internal: expose effectiveGasPrice in receipts (#23050)
gzliudan May 28, 2024
1227634
tests: fix eip1559 tx on non-eip1559 network (#23054)
gzliudan May 28, 2024
50eb5c6
eth/gasprice: implement feeHistory API (#23033)
gzliudan May 29, 2024
08d4042
accounts/abi/bind: fix gas price suggestion with pre EIP-1559 clients…
gzliudan May 28, 2024
958a2e0
ethclient/gethclient: RPC client wrapper for geth-specific API (#22977)
gzliudan May 28, 2024
7862328
internal/ethapi: fix panic in access list creation (#23133)
gzliudan May 28, 2024
35e4a6f
ethstats: fix full node interface post 1559 (#23159)
gzliudan May 28, 2024
cecef1b
eth/gasprice, internal/ethapi: minor feehistory fixes (#23178)
gzliudan May 29, 2024
436d523
internal/ethapi: fix transaction APIs (#23179)
gzliudan Jun 13, 2024
a03edec
internal: get pending and queued transaction by address (#22992)
gzliudan May 29, 2024
8def266
core: fix pre-check for account balance under EIP-1559 (#23244)
gzliudan May 28, 2024
8598a31
Use hexutil.Uint for blockCount parameter and oldestBlock result valu…
gzliudan May 29, 2024
2a36604
internal/ethapi: fix panic in accesslist creation (#23225)
gzliudan May 28, 2024
50c50fa
all: remove term whitelist in comments and log messages (#23294)
gzliudan May 29, 2024
de55f28
internal/ethapi: make ext signer sign legacy (#23274)
gzliudan May 29, 2024
bd15cfc
core: check if sender is EOA (#23303)
gzliudan Jun 13, 2024
8d006aa
internal/ethapi/api: return maxFeePerGas for gasPrice for EIP-1559 tx…
gzliudan May 28, 2024
d8e9549
internal/ethapi: add back missing check for maxfee < maxPriorityFee (…
gzliudan May 29, 2024
35fe3c2
core: only check sendernoeoa in non fake mode (#23424)
gzliudan Jun 13, 2024
c612ce2
eth/gasprice: feeHistory improvements (#23422)
gzliudan May 30, 2024
82c7e2c
core: add change counter (#23095)
gzliudan May 30, 2024
3767632
core/types: copy tx recipient address (#23376)
gzliudan Jun 11, 2024
e6df473
eth/gasprice: avoid modifying TestChainConfig (#23204)
gzliudan May 31, 2024
9300204
core: remove unused error from TxPool.Pending (#23720)
gzliudan May 30, 2024
8e0ac8c
core/types: add MarshalBinary, UnmarshalBinary for Receipt (#22806)
gzliudan Jun 12, 2024
4d99965
accounts/abi/bind: refactor transact method (#23719)
gzliudan May 30, 2024
fa155c8
accounts/abi/bind: fix error handling in baseFee query (#23781)
kibgzr Oct 21, 2021
fc2e7a7
accounts/abi/bin/backends: return basefee in suggestGasPrice's (#23838)
gzliudan May 31, 2024
029a39d
accounts/abi/bind/backends: make suggestGasPrice compatible with non-…
MariusVanDerWijden Nov 1, 2021
a15ccc5
core: more efficient nonce-update in txpool (#22231)
holiman Nov 2, 2021
70d55d0
core: check effective tip in txpool pricelimit validation (#23855)
gzliudan May 31, 2024
fbada38
core: ignore basefee when comparing with pool gasprice in txpool (#24…
gzliudan May 31, 2024
9e6c217
core/types: document JSON field name equivalents of DynamicFeeTx (#24…
gzliudan Jun 11, 2024
2ef0995
internal/ethapi: use same receiver names (#24252)
gzliudan Jun 13, 2024
6ec033f
core/statedb: always clear out access list when setting a new one (#2…
gzliudan May 31, 2024
bccfd99
core/types: improve error for too short transaction / receipt encodin…
gzliudan Jun 12, 2024
9f11e28
graphql: fee history fields (#24452)
gzliudan Jun 20, 2024
4b30ee5
eth/tracers/logger: remove unnecessary comparisons in accessList.equa…
Apr 21, 2022
b70950b
core: fix the order of address in queue (#24908)
zhaochonghe May 19, 2022
2a3f479
internal/ethapi: add comment explaining return of nil instead of erro…
gzliudan Jun 25, 2024
6bdc463
core: fix typo in txpool (#25149)
aaronbuchwald Jun 22, 2022
aa938d1
internal/ethapi: error if tx args includes ChainId not match local (#…
gzliudan Jun 13, 2024
5ad2413
ethclient: add FeeHistory support (#25403)
gzliudan May 31, 2024
e4eb9bd
eth/gasprice/feehistory: support finalized block (#25442)
gzliudan May 31, 2024
132df36
internal/ethapi: don't estimate gas if no limit provided in eth_creat…
gzliudan Jun 10, 2024
df76769
internal/ethapi: rework setDefaults for tx args so fee logic is separ…
gzliudan Jun 13, 2024
6352e3b
internal/ethapi: fix comment typo (#25548)
ucwong Aug 19, 2022
f89e41a
core: preallocate maps in TxPool helper methods (#25737)
dbadoy Sep 12, 2022
21d8ff9
core: don't cache zero nonce in txNoncer (#25603)
dbadoy Sep 16, 2022
339ff64
core: fix datarace in txpool, fixes #25870 and #25869 (#25872)
holiman Sep 26, 2022
3a64e77
all: refactor txpool into it's own package in prep for 4844 (#26038)
gzliudan Jun 10, 2024
7f6da65
core/types: rename tx files to group them better together (#26044)
karalabe Oct 26, 2022
11c004e
core/vm: implement EIP-3860: Limit and meter initcode (#23847)
gzliudan Aug 22, 2024
318ec25
consensus/misc: move eip1559 into a package (#27828)
gzliudan Jun 11, 2024
4452720
core/types: add EffectiveGasPrice in Receipt (#26713)
gzliudan Jun 11, 2024
4984977
all: fix null effectiveGasPrice
gzliudan Jun 26, 2024
4ccea79
internal/ethapi: avoid int overflow in GetTransactionReceipt (#26911)
gzliudan Jun 25, 2024
38d0827
eth/gasprice: change feehistory input type from int to uint64 (#26922)
gzliudan Jun 12, 2024
b39144a
core/types: fix discrepancy in receipt.EffectiveGasPrice json encodin…
gzliudan Jun 12, 2024
8f15474
internal/ethapi: implement eth_getBlockReceipts (#27702)
gzliudan Jun 25, 2024
ac1be09
ethclient: fix forwarding 1559 gas fields (#28462)
gzliudan Jun 12, 2024
6ff5d55
internal/ethapi: ethSendTransaction check baseFee (#27834)
gzliudan Jun 14, 2024
2087076
ethclient: apply accessList field in toCallArg (#28832)
colinlyguo Jan 19, 2024
f04e7c8
eth/gasprice: fix percentile validation in eth_feeHistory (#28954)
fjl Feb 8, 2024
9ac22de
internal/ethapi: support unlimited rpc gas cap in eth_createAccessLis…
gzliudan Jun 14, 2024
1510158
eth/tracers,internal/ethapi: use correct baseFee when BlockOverrides …
gzliudan Jun 14, 2024
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
22 changes: 18 additions & 4 deletions accounts/abi/bind/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ var (
// have any code associated with it (i.e. suicided).
ErrNoCode = errors.New("no contract code at given address")

// This error is raised when attempting to perform a pending state action
// ErrNoPendingState is raised when attempting to perform a pending state action
// on a backend that doesn't implement PendingContractCaller.
ErrNoPendingState = errors.New("backend does not support pending state")

// This error is returned by WaitDeployed if contract creation leaves an
// empty contract behind.
// ErrNoCodeAfterDeploy is returned by WaitDeployed if contract creation leaves
// an empty contract behind.
ErrNoCodeAfterDeploy = errors.New("no contract code after deployment")
)

Expand All @@ -47,7 +47,8 @@ type ContractCaller interface {
// CodeAt returns the code of the given account. This is needed to differentiate
// between contract internal errors and the local chain being out of sync.
CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
// ContractCall executes an Ethereum contract call with the specified data as the

// CallContract executes an Ethereum contract call with the specified data as the
// input.
CallContract(ctx context.Context, call XDPoSChain.CallMsg, blockNumber *big.Int) ([]byte, error)
}
Expand All @@ -58,6 +59,7 @@ type ContractCaller interface {
type PendingContractCaller interface {
// PendingCodeAt returns the code of the given account in the pending state.
PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error)

// PendingCallContract executes an Ethereum contract call against the pending state.
PendingCallContract(ctx context.Context, call XDPoSChain.CallMsg) ([]byte, error)
}
Expand All @@ -67,19 +69,31 @@ type PendingContractCaller interface {
// used when the user does not provide some needed values, but rather leaves it up
// to the transactor to decide.
type ContractTransactor interface {
// HeaderByNumber returns a block header from the current canonical chain. If
// number is nil, the latest known header is returned.
HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

// PendingCodeAt returns the code of the given account in the pending state.
PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)

// PendingNonceAt retrieves the current pending nonce associated with an account.
PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)

// SuggestGasPrice retrieves the currently suggested gas price to allow a timely
// execution of a transaction.
SuggestGasPrice(ctx context.Context) (*big.Int, error)

// SuggestGasTipCap retrieves the currently suggested 1559 priority fee to allow
// a timely execution of a transaction.
SuggestGasTipCap(ctx context.Context) (*big.Int, error)

// EstimateGas tries to estimate the gas needed to execute a specific
// transaction based on the current pending state of the backend blockchain.
// There is no guarantee that this is the true gas limit requirement as other
// transactions may be added or removed by miners, but it should provide a basis
// for setting a reasonable default.
EstimateGas(ctx context.Context, call XDPoSChain.CallMsg) (gas uint64, err error)

// SendTransaction injects the transaction into the pending pool for execution.
SendTransaction(ctx context.Context, tx *types.Transaction) error
}
Expand Down
70 changes: 63 additions & 7 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,19 @@ func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash common
return receipt, nil
}

// HeaderByNumber returns a block header from the current canonical chain. If number is
// nil, the latest known header is returned.
func (b *SimulatedBackend) HeaderByNumber(ctx context.Context, block *big.Int) (*types.Header, error) {
b.mu.Lock()
defer b.mu.Unlock()

if block == nil || block.Cmp(b.pendingBlock.Number()) == 0 {
return b.blockchain.CurrentHeader(), nil
}

return b.blockchain.GetHeaderByNumber(uint64(block.Int64())), nil
}

// PendingCodeAt returns the code associated with an account in the pending state.
func (b *SimulatedBackend) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error) {
b.mu.Lock()
Expand Down Expand Up @@ -300,8 +313,17 @@ func (b *SimulatedBackend) PendingNonceAt(ctx context.Context, account common.Ad
}

// SuggestGasPrice implements ContractTransactor.SuggestGasPrice. Since the simulated
// chain doens't have miners, we just return a gas price of 1 for any call.
// chain doesn't have miners, we just return a gas price of 1 for any call.
func (b *SimulatedBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
if b.pendingBlock.Header().BaseFee != nil {
return b.pendingBlock.Header().BaseFee, nil
}
return big.NewInt(1), nil
}

// SuggestGasTipCap implements ContractTransactor.SuggestGasTipCap. Since the simulated
// chain doesn't have miners, we just return a gas tip of 1 for any call.
func (b *SimulatedBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
return big.NewInt(1), nil
}

Expand Down Expand Up @@ -358,10 +380,38 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call XDPoSChain.Call
// callContract implements common code between normal and pending contract calls.
// state is modified during execution, make sure to copy it if necessary.
func (b *SimulatedBackend) callContract(ctx context.Context, call XDPoSChain.CallMsg, block *types.Block, statedb *state.StateDB) (ret []byte, usedGas uint64, failed bool, err error) {
// Ensure message is initialized properly.
if call.GasPrice == nil {
call.GasPrice = big.NewInt(1)
// Gas prices post 1559 need to be initialized
if call.GasPrice != nil && (call.GasFeeCap != nil || call.GasTipCap != nil) {
return nil, 0, false, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
}
head := b.blockchain.CurrentHeader()
if !b.blockchain.Config().IsEIP1559(head.Number) {
// If there's no basefee, then it must be a non-1559 execution
if call.GasPrice == nil {
call.GasPrice = new(big.Int)
}
call.GasFeeCap, call.GasTipCap = call.GasPrice, call.GasPrice
} else {
// A basefee is provided, necessitating 1559-type execution
if call.GasPrice != nil {
// 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
if call.GasFeeCap == nil {
call.GasFeeCap = new(big.Int)
}
if call.GasTipCap == nil {
call.GasTipCap = new(big.Int)
}
// Backfill the legacy gasPrice for EVM execution, unless we're all zeroes
call.GasPrice = new(big.Int)
if call.GasFeeCap.BitLen() > 0 || call.GasTipCap.BitLen() > 0 {
call.GasPrice = math.BigMin(new(big.Int).Add(call.GasTipCap, head.BaseFee), call.GasFeeCap)
}
}
}
// Ensure message is initialized properly.
if call.Gas == 0 {
call.Gas = 50000000
}
Expand All @@ -382,7 +432,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call XDPoSChain.Cal
evmContext := core.NewEVMContext(msg, 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, nil, b.config, vm.Config{})
vmenv := vm.NewEVM(evmContext, statedb, nil, b.config, vm.Config{NoBaseFee: true})
gaspool := new(core.GasPool).AddGas(math.MaxUint64)
owner := common.Address{}
ret, usedGas, failed, err, _ = core.NewStateTransition(vmenv, msg, gaspool).TransitionDb(owner)
Expand Down Expand Up @@ -520,9 +570,11 @@ 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 }
func (m callMsg) GasTipCap() *big.Int { return m.CallMsg.GasTipCap }
func (m callMsg) Gas() uint64 { return m.CallMsg.Gas }
func (m callMsg) Value() *big.Int { return m.CallMsg.Value }
func (m callMsg) Data() []byte { return m.CallMsg.Data }
Expand Down Expand Up @@ -552,7 +604,11 @@ func (fb *filterBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*t
}

func (fb *filterBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
return core.GetBlockReceipts(fb.db, hash, core.GetBlockNumber(fb.db, hash)), nil
number := rawdb.ReadHeaderNumber(fb.db, hash)
if number == nil {
return nil, nil
}
return rawdb.ReadReceipts(fb.db, hash, *number, fb.bc.Config()), nil
}

func (fb *filterBackend) GetBody(ctx context.Context, hash common.Hash, number rpc.BlockNumber) (*types.Body, error) {
Expand Down
Loading