diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index 7e4666015bec..8f644828cecb 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -100,6 +100,11 @@ var ( slotsGauge = metrics.NewRegisteredGauge("txpool/slots", nil) reheapTimer = metrics.NewRegisteredTimer("txpool/reheap", nil) + + // Metrics related to the astria ordered txs + astriaValidMeter = metrics.GetOrRegisterMeter("astria/txpool/valid", nil) + astriaParsedMeter = metrics.GetOrRegisterMeter("astria/txpool/parsed", nil) + astriaRequestedMeter = metrics.GetOrRegisterMeter("astria/txpool/requested", nil) ) // BlockChain defines the minimal set of methods needed to back a tx pool with @@ -281,6 +286,9 @@ type astriaOrdered struct { } func newAstriaOrdered(valid types.Transactions, parsed types.Transactions, pool *LegacyPool) *astriaOrdered { + astriaParsedMeter.Mark(int64(len(parsed))) + astriaValidMeter.Mark(int64(len(valid))) + return &astriaOrdered{ valid: valid, parsed: parsed, @@ -289,11 +297,13 @@ func newAstriaOrdered(valid types.Transactions, parsed types.Transactions, pool } func (ao *astriaOrdered) clear() { - ao.valid = *&types.Transactions{} - ao.parsed = *&types.Transactions{} + ao.valid = types.Transactions{} + ao.parsed = types.Transactions{} } func (pool *LegacyPool) SetAstriaOrdered(rawTxs [][]byte) { + astriaRequestedMeter.Mark(int64(len(rawTxs))) + valid := []*types.Transaction{} parsed := []*types.Transaction{} for idx, rawTx := range rawTxs { diff --git a/grpc/execution/server.go b/grpc/execution/server.go index b42e797a8415..74c22a3bd1c5 100644 --- a/grpc/execution/server.go +++ b/grpc/execution/server.go @@ -8,6 +8,7 @@ import ( "context" "fmt" "sync" + "time" astriaGrpc "buf.build/gen/go/astria/astria/grpc/go/astria/execution/v1alpha2/executionv1alpha2grpc" astriaPb "buf.build/gen/go/astria/astria/protocolbuffers/go/astria/execution/v1alpha2" @@ -17,6 +18,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/miner" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -37,6 +39,11 @@ type ExecutionServiceServerV1Alpha2 struct { blockExecutionLock sync.Mutex // Lock for the NewPayload method } +var ( + executeBlockTimer = metrics.GetOrRegisterTimer("astria/execution/execute_block_time", nil) + comittmentStateUpdateTimer = metrics.GetOrRegisterTimer("astria/execution/committment_state_update_time", nil) +) + func NewExecutionServiceServerV1Alpha2(eth *eth.Ethereum) *ExecutionServiceServerV1Alpha2 { bc := eth.BlockChain() @@ -96,6 +103,9 @@ func (s *ExecutionServiceServerV1Alpha2) ExecuteBlock(ctx context.Context, req * s.blockExecutionLock.Lock() defer s.blockExecutionLock.Unlock() + // Deliberately called after lock, to more directly measure the time spent executing + executionStart := time.Now() + defer executeBlockTimer.UpdateSince(executionStart) // Validate block being created has valid previous hash prevHeadHash := common.BytesToHash(req.PrevBlockHash) @@ -138,8 +148,8 @@ func (s *ExecutionServiceServerV1Alpha2) ExecuteBlock(ctx context.Context, req * s.eth.TxPool().ClearAstriaOrdered() res := &astriaPb.Block{ - Number: uint32(block.NumberU64()), - Hash: block.Hash().Bytes(), + Number: uint32(block.NumberU64()), + Hash: block.Hash().Bytes(), ParentBlockHash: block.ParentHash().Bytes(), Timestamp: ×tamppb.Timestamp{ Seconds: int64(block.Time()), @@ -178,6 +188,8 @@ func (s *ExecutionServiceServerV1Alpha2) GetCommitmentState(ctx context.Context, // CommitmentState. func (s *ExecutionServiceServerV1Alpha2) UpdateCommitmentState(ctx context.Context, req *astriaPb.UpdateCommitmentStateRequest) (*astriaPb.CommitmentState, error) { log.Info("UpdateCommitmentState called", "request", req) + commitmentUpdateStart := time.Now() + defer comittmentStateUpdateTimer.UpdateSince(commitmentUpdateStart) s.commitementUpdateLock.Lock() defer s.commitementUpdateLock.Unlock()