Skip to content

Commit

Permalink
Merge branch 'develop' into fix/better-invalid-opcode-trace
Browse files Browse the repository at this point in the history
  • Loading branch information
Thegaram authored Aug 31, 2023
2 parents cc3e5b7 + 24d8567 commit 04d724e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
14 changes: 10 additions & 4 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,18 @@ func (c *bigModExp) RequiredGas(input []byte) uint64 {

func (c *bigModExp) Run(input []byte) ([]byte, error) {
var (
baseLen = new(big.Int).SetBytes(getData(input, 0, 32)).Uint64()
expLen = new(big.Int).SetBytes(getData(input, 32, 32)).Uint64()
modLen = new(big.Int).SetBytes(getData(input, 64, 32)).Uint64()
baseLenBigInt = new(big.Int).SetBytes(getData(input, 0, 32))
expLenBigInt = new(big.Int).SetBytes(getData(input, 32, 32))
modLenBigInt = new(big.Int).SetBytes(getData(input, 64, 32))
)
var (
baseLen = baseLenBigInt.Uint64()
expLen = expLenBigInt.Uint64()
modLen = modLenBigInt.Uint64()
)
// Check that all inputs are `u256` (32 - bytes) or less, revert otherwise
if baseLen > 32 || expLen > 32 || modLen > 32 {
var lenLimit = new(big.Int).SetInt64(32)
if baseLenBigInt.Cmp(lenLimit) > 0 || expLenBigInt.Cmp(lenLimit) > 0 || modLenBigInt.Cmp(lenLimit) > 0 {
return nil, errModexpUnsupportedInput
}
if len(input) > 96 {
Expand Down
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 = 60 // Patch version component of the current release
VersionMeta = "sepolia" // Version metadata to append to the version string
)

Expand Down

0 comments on commit 04d724e

Please sign in to comment.