Skip to content

Commit

Permalink
[R4R]-[estimataGas]fix: fix estimateGas
Browse files Browse the repository at this point in the history
  • Loading branch information
Tri-stone committed Mar 10, 2024
1 parent 303c724 commit 5034449
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
17 changes: 8 additions & 9 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ func NewStateTransition(evm *vm.EVM, msg *Message, gp *GasPool) *StateTransition
}
}

// to returns the recipient of the message.
func (st *StateTransition) to() common.Address {
if st.msg == nil || st.msg.To == nil /* contract creation */ {
return common.Address{}
}
return *st.msg.To
}

// CalculateL1Cost calculates the L1 cost for a transaction without modifying the state.
func (st *StateTransition) CalculateL1Cost() (*big.Int, error) {
var l1Cost *big.Int
Expand All @@ -300,14 +308,6 @@ func (st *StateTransition) CalculateL1Cost() (*big.Int, error) {
return l1Cost, nil
}

// to returns the recipient of the message.
func (st *StateTransition) to() common.Address {
if st.msg == nil || st.msg.To == nil /* contract creation */ {
return common.Address{}
}
return *st.msg.To
}

func (st *StateTransition) buyGas() (*big.Int, error) {
if err := st.applyMetaTransaction(); err != nil {
return nil, err
Expand All @@ -324,7 +324,6 @@ func (st *StateTransition) buyGas() (*big.Int, error) {
if l1Cost != nil && (st.msg.RunMode == GasEstimationMode || st.msg.RunMode == GasEstimationWithSkipCheckBalanceMode) {
mgval = mgval.Add(mgval, l1Cost)
}

balanceCheck := new(big.Int).Set(mgval)
if st.msg.GasFeeCap != nil {
balanceCheck.SetUint64(st.msg.GasLimit)
Expand Down
3 changes: 0 additions & 3 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1157,9 +1157,6 @@ func DoCall(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash
return nil, err
}

log.Info("Args after ToMessage", "GasPrice", msg.GasPrice,
"GasFeeCap", msg.GasFeeCap, "GasTipCap", msg.GasTipCap)

evm, vmError, err := b.GetEVM(ctx, msg, state, header, &vm.Config{NoBaseFee: true})
if err != nil {
return nil, err
Expand Down

0 comments on commit 5034449

Please sign in to comment.