all: rename internal 1559 gas fields, add support for graphql (#23010)
* all: rename internal 1559 gas fields, add support for graphql * cmd/evm/testdata, core: use public 1559 gas names on API surfaces
This commit is contained in:
@ -50,8 +50,8 @@ type StateTransition struct {
|
||||
msg Message
|
||||
gas uint64
|
||||
gasPrice *big.Int
|
||||
feeCap *big.Int
|
||||
tip *big.Int
|
||||
gasFeeCap *big.Int
|
||||
gasTipCap *big.Int
|
||||
initialGas uint64
|
||||
value *big.Int
|
||||
data []byte
|
||||
@ -65,8 +65,8 @@ type Message interface {
|
||||
To() *common.Address
|
||||
|
||||
GasPrice() *big.Int
|
||||
FeeCap() *big.Int
|
||||
Tip() *big.Int
|
||||
GasFeeCap() *big.Int
|
||||
GasTipCap() *big.Int
|
||||
Gas() uint64
|
||||
Value() *big.Int
|
||||
|
||||
@ -155,15 +155,15 @@ func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation b
|
||||
// NewStateTransition initialises and returns a new state transition object.
|
||||
func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) *StateTransition {
|
||||
return &StateTransition{
|
||||
gp: gp,
|
||||
evm: evm,
|
||||
msg: msg,
|
||||
gasPrice: msg.GasPrice(),
|
||||
feeCap: msg.FeeCap(),
|
||||
tip: msg.Tip(),
|
||||
value: msg.Value(),
|
||||
data: msg.Data(),
|
||||
state: evm.StateDB,
|
||||
gp: gp,
|
||||
evm: evm,
|
||||
msg: msg,
|
||||
gasPrice: msg.GasPrice(),
|
||||
gasFeeCap: msg.GasFeeCap(),
|
||||
gasTipCap: msg.GasTipCap(),
|
||||
value: msg.Value(),
|
||||
data: msg.Data(),
|
||||
state: evm.StateDB,
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,9 +190,9 @@ func (st *StateTransition) buyGas() error {
|
||||
mgval := new(big.Int).SetUint64(st.msg.Gas())
|
||||
mgval = mgval.Mul(mgval, st.gasPrice)
|
||||
balanceCheck := mgval
|
||||
if st.feeCap != nil {
|
||||
if st.gasFeeCap != nil {
|
||||
balanceCheck = new(big.Int).SetUint64(st.msg.Gas())
|
||||
balanceCheck = balanceCheck.Mul(balanceCheck, st.feeCap)
|
||||
balanceCheck = balanceCheck.Mul(balanceCheck, st.gasFeeCap)
|
||||
}
|
||||
if have, want := st.state.GetBalance(st.msg.From()), balanceCheck; have.Cmp(want) < 0 {
|
||||
return fmt.Errorf("%w: address %v have %v want %v", ErrInsufficientFunds, st.msg.From().Hex(), have, want)
|
||||
@ -219,25 +219,25 @@ func (st *StateTransition) preCheck() error {
|
||||
st.msg.From().Hex(), msgNonce, stNonce)
|
||||
}
|
||||
}
|
||||
// Make sure that transaction feeCap is greater than the baseFee (post london)
|
||||
// Make sure that transaction gasFeeCap is greater than the baseFee (post london)
|
||||
if st.evm.ChainConfig().IsLondon(st.evm.Context.BlockNumber) {
|
||||
if l := st.feeCap.BitLen(); l > 256 {
|
||||
return fmt.Errorf("%w: address %v, feeCap bit length: %d", ErrFeeCapVeryHigh,
|
||||
if l := st.gasFeeCap.BitLen(); l > 256 {
|
||||
return fmt.Errorf("%w: address %v, maxFeePerGas bit length: %d", ErrFeeCapVeryHigh,
|
||||
st.msg.From().Hex(), l)
|
||||
}
|
||||
if l := st.tip.BitLen(); l > 256 {
|
||||
return fmt.Errorf("%w: address %v, tip bit length: %d", ErrTipVeryHigh,
|
||||
if l := st.gasTipCap.BitLen(); l > 256 {
|
||||
return fmt.Errorf("%w: address %v, maxPriorityFeePerGas bit length: %d", ErrTipVeryHigh,
|
||||
st.msg.From().Hex(), l)
|
||||
}
|
||||
if st.feeCap.Cmp(st.tip) < 0 {
|
||||
return fmt.Errorf("%w: address %v, tip: %s, feeCap: %s", ErrTipAboveFeeCap,
|
||||
st.msg.From().Hex(), st.feeCap, st.tip)
|
||||
if st.gasFeeCap.Cmp(st.gasTipCap) < 0 {
|
||||
return fmt.Errorf("%w: address %v, maxPriorityFeePerGas: %s, maxFeePerGas: %s", ErrTipAboveFeeCap,
|
||||
st.msg.From().Hex(), st.gasTipCap, st.gasFeeCap)
|
||||
}
|
||||
// This will panic if baseFee is nil, but basefee presence is verified
|
||||
// as part of header validation.
|
||||
if st.feeCap.Cmp(st.evm.Context.BaseFee) < 0 {
|
||||
return fmt.Errorf("%w: address %v, feeCap: %s baseFee: %s", ErrFeeCapTooLow,
|
||||
st.msg.From().Hex(), st.feeCap, st.evm.Context.BaseFee)
|
||||
if st.gasFeeCap.Cmp(st.evm.Context.BaseFee) < 0 {
|
||||
return fmt.Errorf("%w: address %v, maxFeePerGas: %s baseFee: %s", ErrFeeCapTooLow,
|
||||
st.msg.From().Hex(), st.gasFeeCap, st.evm.Context.BaseFee)
|
||||
}
|
||||
}
|
||||
return st.buyGas()
|
||||
@ -317,7 +317,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
|
||||
}
|
||||
effectiveTip := st.gasPrice
|
||||
if st.evm.ChainConfig().IsLondon(st.evm.Context.BlockNumber) {
|
||||
effectiveTip = cmath.BigMin(st.tip, new(big.Int).Sub(st.feeCap, st.evm.Context.BaseFee))
|
||||
effectiveTip = cmath.BigMin(st.gasTipCap, new(big.Int).Sub(st.gasFeeCap, st.evm.Context.BaseFee))
|
||||
}
|
||||
st.state.AddBalance(st.evm.Context.Coinbase, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), effectiveTip))
|
||||
|
||||
|
Reference in New Issue
Block a user