Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(metrics): add skipped txs metrics for miner #494

Merged
merged 11 commits into from
Aug 31, 2023
17 changes: 17 additions & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/event"
"github.com/scroll-tech/go-ethereum/log"
"github.com/scroll-tech/go-ethereum/metrics"
"github.com/scroll-tech/go-ethereum/params"
"github.com/scroll-tech/go-ethereum/rollup/circuitcapacitychecker"
"github.com/scroll-tech/go-ethereum/trie"
Expand Down Expand Up @@ -81,6 +82,16 @@ const (
staleThreshold = 7
)

var (
// Metrics for the skipped txs
l1TxGasLimitExceededCounter = metrics.NewRegisteredCounter("miner/skipped_txs/l1/gas_limit_exceeded", nil)
l1TxRowConsumptionOverflowCounter = metrics.NewRegisteredCounter("miner/skipped_txs/l1/row_consumption_overflow", nil)
l2TxRowConsumptionOverflowCounter = metrics.NewRegisteredCounter("miner/skipped_txs/l2/row_consumption_overflow", nil)
l1TxCccUnknownErrCounter = metrics.NewRegisteredCounter("miner/skipped_txs/l1/ccc_unknown_err", nil)
l2TxCccUnknownErrCounter = metrics.NewRegisteredCounter("miner/skipped_txs/l2/ccc_unknown_err", nil)
l1TxStrangeErrCounter = metrics.NewRegisteredCounter("miner/skipped_txs/l1/strange_err", nil)
)

// environment is the worker's current environment and holds all of the current state information.
type environment struct {
signer types.Signer
Expand Down Expand Up @@ -1026,6 +1037,7 @@ loop:
w.current.nextL1MsgIndex = queueIndex + 1
txs.Shift()
rawdb.WriteSkippedTransaction(w.eth.ChainDb(), tx, "gas limit exceeded", w.current.header.Number.Uint64(), nil)
l1TxGasLimitExceededCounter.Inc(1)

case errors.Is(err, core.ErrGasLimitReached):
// Pop the current out-of-gas transaction without shifting in the next from the account
Expand Down Expand Up @@ -1086,11 +1098,13 @@ loop:
queueIndex := tx.AsL1MessageTx().QueueIndex
log.Info("Skipping L1 message", "queueIndex", queueIndex, "tx", tx.Hash().String(), "block", w.current.header.Number, "reason", "first tx row consumption overflow")
w.current.nextL1MsgIndex = queueIndex + 1
l1TxRowConsumptionOverflowCounter.Inc(1)
} else {
// Skip L2 transaction and all other transactions from the same sender account
log.Info("Skipping L2 message", "tx", tx.Hash().String(), "block", w.current.header.Number, "reason", "first tx row consumption overflow")
txs.Pop()
w.eth.TxPool().RemoveTx(tx.Hash(), true)
l2TxRowConsumptionOverflowCounter.Inc(1)
}

// Reset ccc so that we can process other transactions for this block
Expand All @@ -1111,6 +1125,7 @@ loop:
w.current.nextL1MsgIndex = queueIndex + 1
// TODO: propagate more info about the error from CCC
rawdb.WriteSkippedTransaction(w.eth.ChainDb(), tx, "unknown circuit capacity checker error", w.current.header.Number.Uint64(), nil)
l1TxCccUnknownErrCounter.Inc(1)

// Normally we would do `txs.Shift()` here.
// However, after `ErrUnknown`, ccc might remain in an
Expand All @@ -1124,6 +1139,7 @@ loop:
log.Info("Skipping L2 message", "tx", tx.Hash().String(), "block", w.current.header.Number, "reason", "unknown row consumption error")
// TODO: propagate more info about the error from CCC
rawdb.WriteSkippedTransaction(w.eth.ChainDb(), tx, "unknown circuit capacity checker error", w.current.header.Number.Uint64(), nil)
l2TxCccUnknownErrCounter.Inc(1)

// Normally we would do `txs.Pop()` here.
// However, after `ErrUnknown`, ccc might remain in an
Expand All @@ -1141,6 +1157,7 @@ loop:
log.Info("Skipping L1 message", "queueIndex", queueIndex, "tx", tx.Hash().String(), "block", w.current.header.Number, "reason", "strange error", "err", err)
w.current.nextL1MsgIndex = queueIndex + 1
rawdb.WriteSkippedTransaction(w.eth.ChainDb(), tx, fmt.Sprintf("strange error: %v", err), w.current.header.Number.Uint64(), nil)
l1TxStrangeErrCounter.Inc(1)
}
txs.Shift()
}
Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
const (
VersionMajor = 4 // Major version component of the current release
VersionMinor = 3 // Minor version component of the current release
VersionPatch = 58 // Patch version component of the current release
VersionPatch = 59 // Patch version component of the current release
VersionMeta = "sepolia" // Version metadata to append to the version string
)

Expand Down
Loading