FVM: record message applied metrics

This commit is contained in:
Aayush 2022-07-18 10:50:58 -04:00
parent e950421e87
commit 279b1f4317
3 changed files with 9 additions and 6 deletions

View File

@ -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()

View File

@ -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 {

View File

@ -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)