diff --git a/chain/vm/fvm.go b/chain/vm/fvm.go index 9a342dba4e4..7ae6bf20300 100644 --- a/chain/vm/fvm.go +++ b/chain/vm/fvm.go @@ -9,6 +9,7 @@ import ( "os" "sort" "sync" + "sync/atomic" "time" "github.com/ipfs/go-cid" @@ -419,6 +420,7 @@ func NewDebugFVM(ctx context.Context, opts *VMOpts) (*FVM, error) { func (vm *FVM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet, error) { start := build.Clock.Now() + defer atomic.AddUint64(&StatApplied, 1) vmMsg := cmsg.VMMessage() msgBytes, err := vmMsg.Serialize() if err != nil { @@ -482,6 +484,7 @@ func (vm *FVM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet func (vm *FVM) ApplyImplicitMessage(ctx context.Context, cmsg *types.Message) (*ApplyRet, error) { start := build.Clock.Now() + defer atomic.AddUint64(&StatApplied, 1) cmsg.GasLimit = math.MaxInt64 / 2 vmMsg := cmsg.VMMessage() msgBytes, err := vmMsg.Serialize() diff --git a/chain/vm/vm.go b/chain/vm/vm.go index c04a6c6252a..c5b47fd10aa 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -45,12 +45,6 @@ var ( gasOnActorExec = newGasCharge("OnActorExec", 0, 0) ) -// stat counters -var ( - StatSends uint64 - StatApplied uint64 -) - // ResolveToKeyAddr returns the public key type of address (`BLS`/`SECP256K1`) of an account actor identified by `addr`. func ResolveToKeyAddr(state types.StateTree, cst cbor.IpldStore, addr address.Address) (address.Address, error) { if addr.Protocol() == address.BLS || addr.Protocol() == address.SECP256K1 { diff --git a/chain/vm/vmi.go b/chain/vm/vmi.go index 38de0543c52..01b32d4ad17 100644 --- a/chain/vm/vmi.go +++ b/chain/vm/vmi.go @@ -11,6 +11,12 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) +// stat counters +var ( + StatSends uint64 + StatApplied uint64 +) + type Interface interface { // Applies the given message onto the VM's current state, returning the result of the execution ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet, error)