Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

feat(metrics): collect txmgr metrics #725

Merged
merged 13 commits into from
Apr 17, 2024
5 changes: 5 additions & 0 deletions internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"strconv"
"time"

opMetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
txmgrMetrics "github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/metrics/prometheus"
Expand Down Expand Up @@ -42,6 +44,9 @@ var (
ProverSubmissionErrorCounter = metrics.NewRegisteredCounter("prover/proof/submission/error", nil)
ProverSgxProofGeneratedCounter = metrics.NewRegisteredCounter("prover/proof/sgx/generated", nil)
ProverSubmissionRevertedCounter = metrics.NewRegisteredCounter("prover/proof/submission/reverted", nil)

// TxManager Metrics
TxMgrMetrics = txmgrMetrics.MakeTxMetrics("client", opMetrics.With(opMetrics.NewRegistry()))
)

// Serve starts the metrics server on the given address, will be closed when the given
Expand Down
13 changes: 11 additions & 2 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/ethereum-optimism/optimism/op-challenger/sender"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
txmgrMetrics "github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -107,7 +106,7 @@ func (p *Proposer) InitFromConfig(ctx context.Context, cfg *Config) (err error)
txmgr, err := txmgr.NewSimpleTxManager(
"proposer",
log.Root(),
new(txmgrMetrics.NoopTxMetrics),
&metrics.TxMgrMetrics,
*cfg.TxmgrConfigs,
)
if err != nil {
Expand Down Expand Up @@ -231,6 +230,11 @@ func (p *Proposer) fetchPoolContent(filterPoolContent bool) ([]types.Transaction
}
// If the pool content is empty and the checkPoolContent flag is not set, return an empty list.
if !filterPoolContent && len(txLists) == 0 {
log.Info(
"Pool content is empty, proposing an empty block",
"lastProposedAt", p.lastProposedAt,
"minProposingInternal", p.MinProposingInternal,
)
txLists = append(txLists, types.Transactions{})
}

Expand Down Expand Up @@ -294,6 +298,11 @@ func (p *Proposer) ProposeOp(ctx context.Context) error {
return err
}

// If the pool content is empty, return.
if len(txLists) == 0 {
return nil
}

// Propose all L2 transactions lists.
for i, txs := range txLists {
if i >= int(p.MaxProposedTxListsPerEpoch) {
Expand Down
4 changes: 2 additions & 2 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/cenkalti/backoff/v4"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
Expand All @@ -21,6 +20,7 @@ import (

"github.com/taikoxyz/taiko-client/bindings"
"github.com/taikoxyz/taiko-client/bindings/encoding"
"github.com/taikoxyz/taiko-client/internal/metrics"
"github.com/taikoxyz/taiko-client/internal/version"
eventIterator "github.com/taikoxyz/taiko-client/pkg/chain_iterator/event_iterator"
"github.com/taikoxyz/taiko-client/pkg/rpc"
Expand Down Expand Up @@ -148,7 +148,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) {
if p.txmgr, err = txmgr.NewSimpleTxManager(
"prover",
log.Root(),
new(metrics.NoopTxMetrics),
&metrics.TxMgrMetrics,
*cfg.TxmgrConfigs,
); err != nil {
return err
Expand Down
Loading