Skip to content

Commit

Permalink
always have basefee test
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-vball committed Nov 17, 2022
1 parent 9dad7e5 commit 8c7dcb4
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions chain/stmgr/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import (
"errors"
"fmt"

"github.com/filecoin-project/go-state-types/big"

"github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor"
"go.opencensus.io/trace"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/network"

Expand Down Expand Up @@ -125,11 +126,6 @@ func (sm *StateManager) callInternal(ctx context.Context, msg *types.Message, pr
)
}

baseFee := big.Zero()
if checkGas {
baseFee = ts.Blocks()[0].ParentBaseFee
}

buffStore := blockstore.NewTieredBstore(sm.cs.StateBlockstore(), blockstore.NewMemorySync())
vmopt := &vm.VMOpts{
StateBase: stateCid,
Expand All @@ -140,7 +136,7 @@ func (sm *StateManager) callInternal(ctx context.Context, msg *types.Message, pr
Syscalls: sm.Syscalls,
CircSupplyCalc: sm.GetVMCirculatingSupply,
NetworkVersion: nvGetter(ctx, vmHeight),
BaseFee: baseFee,
BaseFee: ts.Blocks()[0].ParentBaseFee,
LookbackState: LookbackStateGetterForTipset(sm, ts),
Tracing: true,
}
Expand Down Expand Up @@ -174,21 +170,21 @@ func (sm *StateManager) callInternal(ctx context.Context, msg *types.Message, pr

msg.Nonce = fromActor.Nonce

var ret *vm.ApplyRet
var gasInfo api.MsgGasCost
if checkGas {
// If the fee cap is set to zero, make gas free.
if msg.GasFeeCap.NilOrZero() {
// Now estimate with a new VM with no base fee.
vmopt.BaseFee = big.Zero()
vmopt.StateBase = stateCid
// If the fee cap is set to zero, make gas free.
if msg.GasFeeCap.NilOrZero() {
// Now estimate with a new VM with no base fee.
vmopt.BaseFee = big.Zero()
vmopt.StateBase = stateCid

vmi, err = sm.newVM(ctx, vmopt)
if err != nil {
return nil, xerrors.Errorf("failed to set up estimation vm: %w", err)
}
vmi, err = sm.newVM(ctx, vmopt)
if err != nil {
return nil, xerrors.Errorf("failed to set up estimation vm: %w", err)
}
}

var ret *vm.ApplyRet
var gasInfo api.MsgGasCost
if checkGas {
fromKey, err := sm.ResolveToKeyAddress(ctx, msg.From, ts)
if err != nil {
return nil, xerrors.Errorf("could not resolve key: %w", err)
Expand Down

0 comments on commit 8c7dcb4

Please sign in to comment.