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

Merged
merged 92 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
089a589
eth: fix typo balacne
gzliudan Aug 7, 2024
e561f28
core/types: drop type v4StoredReceiptRLP
gzliudan Jun 25, 2024
6c77d63
core/types: replace core.SetReceiptsData with receipts.DeriveFields
gzliudan Jun 26, 2024
b5fe81f
core/vm: make gas cost reporting to tracers correct (#22702)
holiman Apr 27, 2021
6a3b818
core, params: implement EIP-3529 (#22733)
gzliudan Aug 22, 2024
e18553b
all: implement eip-1559 (#22837)
gzliudan Apr 25, 2024
4e7fd89
core: fix failing tests (#22888)
gzliudan May 28, 2024
684afd0
EIP-1559: miner changes (#22896)
gzliudan Apr 26, 2024
d88d267
core: make txpool free space calculation more accurate (#22933)
gzliudan May 16, 2024
f6a4769
EIP-1559 tx pool support (#22898)
gzliudan May 17, 2024
4f0317c
core: add new eip-1559 tx constraints (#22970)
gzliudan May 17, 2024
bfd1c0c
core, eth, internal, les: RPC methods and fields for EIP 1559 (#22964)
gzliudan May 21, 2024
64f7389
params: print right Eip1559Block for ChainConfig
gzliudan May 22, 2024
5a31888
core, eth, miner: enforce configured mining reward post 1559 too (#22…
gzliudan May 23, 2024
4c096de
all: rename internal 1559 gas fields (#23010)
gzliudan May 24, 2024
ef1dbd0
internal/ethapi: support for eip-1559 txs in clef (#22966)
gzliudan May 24, 2024
18bc355
core, internal: support various eth_call invocations post 1559 (#23027)
gzliudan May 24, 2024
c7d4907
core/vm: evm fix panic (#23047)
gzliudan Sep 19, 2024
1c47afb
core/vm/runtime: add function TestColdAccountAccessCost
gzliudan Oct 18, 2024
3277857
Access list state test format (#22290)
gzliudan May 24, 2024
e93d78c
accounts/abi/bind: add NoSend transact option (#22446)
reds Mar 19, 2021
6b67327
tests: update for London (#22976)
gzliudan May 24, 2024
05c11eb
core: make genesis parse baseFee correctly (#23013)
gzliudan May 24, 2024
1cb1ba7
core: change baseFee into baseFeePerGas in genesis json (#23039)
gzliudan May 24, 2024
dbdca11
accounts/abi/bind: fix bounded contracts and sim backend for 1559 (#2…
gzliudan May 27, 2024
b02922f
core, internal: expose effectiveGasPrice in receipts (#23050)
gzliudan May 28, 2024
c0a63a5
tests: fix eip1559 tx on non-eip1559 network (#23054)
gzliudan May 28, 2024
26fe46c
eth/gasprice: implement feeHistory API (#23033)
gzliudan May 29, 2024
3212ec3
accounts/abi/bind: fix gas price suggestion with pre EIP-1559 clients…
gzliudan May 28, 2024
e94a0a9
ethclient/gethclient: RPC client wrapper for geth-specific API (#22977)
gzliudan May 28, 2024
5d4ad88
internal/ethapi: fix panic in access list creation (#23133)
gzliudan May 28, 2024
012c4cb
ethstats: fix full node interface post 1559 (#23159)
gzliudan May 28, 2024
5766ca4
eth/gasprice, internal/ethapi: minor feehistory fixes (#23178)
gzliudan May 29, 2024
93dd33b
internal/ethapi: fix transaction APIs (#23179)
gzliudan Jun 13, 2024
5b01b23
internal: get pending and queued transaction by address (#22992)
gzliudan May 29, 2024
43a0cdf
core: fix pre-check for account balance under EIP-1559 (#23244)
gzliudan May 28, 2024
7500b0a
Use hexutil.Uint for blockCount parameter and oldestBlock result valu…
gzliudan May 29, 2024
62a70f0
internal/ethapi: fix panic in accesslist creation (#23225)
gzliudan May 28, 2024
206175f
all: remove term whitelist in comments and log messages (#23294)
gzliudan May 29, 2024
655fb58
internal/ethapi: make ext signer sign legacy (#23274)
gzliudan May 29, 2024
d6daac5
core: check if sender is EOA (#23303)
gzliudan Jun 13, 2024
48616d5
internal/ethapi/api: return maxFeePerGas for gasPrice for EIP-1559 tx…
gzliudan May 28, 2024
e4895bf
internal/ethapi: add back missing check for maxfee < maxPriorityFee (…
gzliudan May 29, 2024
d850fc4
core: only check sendernoeoa in non fake mode (#23424)
gzliudan Jun 13, 2024
e0a1ef3
eth/gasprice: feeHistory improvements (#23422)
gzliudan May 30, 2024
e18e611
core: add change counter (#23095)
gzliudan May 30, 2024
17b6231
core/types: copy tx recipient address (#23376)
gzliudan Jun 11, 2024
27071a4
eth/gasprice: avoid modifying TestChainConfig (#23204)
gzliudan May 31, 2024
e5fb0b4
core: remove unused error from TxPool.Pending (#23720)
gzliudan May 30, 2024
a402cbf
core/types: add MarshalBinary, UnmarshalBinary for Receipt (#22806)
gzliudan Jun 12, 2024
eec8da3
accounts/abi/bind: refactor transact method (#23719)
gzliudan May 30, 2024
2d5f9d9
accounts/abi/bind: fix error handling in baseFee query (#23781)
kibgzr Oct 21, 2021
66be9b6
accounts/abi/bin/backends: return basefee in suggestGasPrice's (#23838)
gzliudan May 31, 2024
d2a10ef
accounts/abi/bind/backends: make suggestGasPrice compatible with non-…
MariusVanDerWijden Nov 1, 2021
81dff92
core: more efficient nonce-update in txpool (#22231)
holiman Nov 2, 2021
6feb71e
core: check effective tip in txpool pricelimit validation (#23855)
gzliudan May 31, 2024
bdae200
core: ignore basefee when comparing with pool gasprice in txpool (#24…
gzliudan May 31, 2024
8eaa9e2
core/types: document JSON field name equivalents of DynamicFeeTx (#24…
gzliudan Jun 11, 2024
588847c
internal/ethapi: use same receiver names (#24252)
gzliudan Jun 13, 2024
d1dc9e3
core/statedb: always clear out access list when setting a new one (#2…
gzliudan May 31, 2024
7cb33cc
core/types: improve error for too short transaction / receipt encodin…
gzliudan Jun 12, 2024
c8c43ad
graphql: fee history fields (#24452)
gzliudan Jun 20, 2024
59bc3bf
eth/tracers/logger: remove unnecessary comparisons in accessList.equa…
Apr 21, 2022
dc94ad5
core: fix the order of address in queue (#24908)
zhaochonghe May 19, 2022
77e2ad9
internal/ethapi: add comment explaining return of nil instead of erro…
gzliudan Jun 25, 2024
7237811
core: fix typo in txpool (#25149)
aaronbuchwald Jun 22, 2022
fa83f32
internal/ethapi: error if tx args includes ChainId not match local (#…
gzliudan Jun 13, 2024
9535b3a
ethclient: add FeeHistory support (#25403)
gzliudan May 31, 2024
754c645
eth/gasprice/feehistory: support finalized block (#25442)
gzliudan May 31, 2024
c668279
internal/ethapi: don't estimate gas if no limit provided in eth_creat…
gzliudan Jun 10, 2024
49b54aa
internal/ethapi: rework setDefaults for tx args so fee logic is separ…
gzliudan Jun 13, 2024
e4153f7
internal/ethapi: fix comment typo (#25548)
ucwong Aug 19, 2022
a410f7b
core: preallocate maps in TxPool helper methods (#25737)
dbadoy Sep 12, 2022
66763aa
core: don't cache zero nonce in txNoncer (#25603)
dbadoy Sep 16, 2022
0579784
core: fix datarace in txpool, fixes #25870 and #25869 (#25872)
holiman Sep 26, 2022
8b2e8d9
all: refactor txpool into it's own package in prep for 4844 (#26038)
gzliudan Jun 10, 2024
cda663d
core/types: rename tx files to group them better together (#26044)
karalabe Oct 26, 2022
f64aea4
core/vm: implement EIP-3860: Limit and meter initcode (#23847)
gzliudan Aug 22, 2024
9b20ac7
consensus/misc: move eip1559 into a package (#27828)
gzliudan Jun 11, 2024
2a9d450
core/types: add EffectiveGasPrice in Receipt (#26713)
gzliudan Jun 11, 2024
a294c20
all: fix null effectiveGasPrice
gzliudan Jun 26, 2024
b823688
internal/ethapi: avoid int overflow in GetTransactionReceipt (#26911)
gzliudan Jun 25, 2024
419f81f
eth/gasprice: change feehistory input type from int to uint64 (#26922)
gzliudan Jun 12, 2024
da9d2e2
core/types: fix discrepancy in receipt.EffectiveGasPrice json encodin…
gzliudan Jun 12, 2024
f23e1a6
internal/ethapi: implement eth_getBlockReceipts (#27702)
gzliudan Jun 25, 2024
4340e7b
ethclient: fix forwarding 1559 gas fields (#28462)
gzliudan Jun 12, 2024
0237985
internal/ethapi: ethSendTransaction check baseFee (#27834)
gzliudan Jun 14, 2024
bb55c10
ethclient: apply accessList field in toCallArg (#28832)
colinlyguo Jan 19, 2024
6b8dd86
eth/gasprice: fix percentile validation in eth_feeHistory (#28954)
fjl Feb 8, 2024
bc14c67
internal/ethapi: support unlimited rpc gas cap in eth_createAccessLis…
gzliudan Jun 14, 2024
416e5ac
eth/tracers,internal/ethapi: use correct baseFee when BlockOverrides …
gzliudan Jun 14, 2024
56ed523
common: set Eip1559Block to 23580000 for devnet
gzliudan Oct 31, 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
}
gzliudan marked this conversation as resolved.
Show resolved Hide resolved

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 @@ -384,7 +434,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call XDPoSChain.Cal
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, txContext, statedb, nil, b.config, vm.Config{})
vmenv := vm.NewEVM(evmContext, txContext, 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 @@ -522,9 +572,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 @@ -554,7 +606,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