Skip to content

Commit

Permalink
Merge branch 'zkevm' into zjg/optimise-coinbase
Browse files Browse the repository at this point in the history
  • Loading branch information
zjg555543 authored Aug 28, 2024
2 parents 92ddc0e + 26ea489 commit c2e776a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
6 changes: 3 additions & 3 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,17 +560,17 @@ var (
DataStreamWriteTimeout = cli.DurationFlag{
Name: "zkevm.data-stream-writeTimeout",
Usage: "Define the TCP write timeout when sending data to a datastream client",
Value: 5 * time.Second,
Value: 20 * time.Second,
}
DataStreamInactivityTimeout = cli.DurationFlag{
Name: "zkevm.data-stream-inactivity-timeout",
Usage: "Define the inactivity timeout when interacting with a data stream server",
Value: 10 * time.Second,
Value: 10 * time.Minute,
}
DataStreamInactivityCheckInterval = cli.DurationFlag{
Name: "zkevm.data-stream-inactivity-check-interval",
Usage: "Define the inactivity check interval timeout when interacting with a data stream server",
Value: 2 * time.Second,
Value: 5 * time.Minute,
}
Limbo = cli.BoolFlag{
Name: "zkevm.limbo",
Expand Down
11 changes: 9 additions & 2 deletions zk/stages/stage_sequence_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func SpawnSequencingStage(

log.Info(fmt.Sprintf("[%s] Starting batch %d...", logPrefix, batchState.batchNumber))

var allConditionsOK bool
for blockNumber := executionAt + 1; runLoopBlocks; blockNumber++ {
log.Info(fmt.Sprintf("[%s] Starting block %d (forkid %v)...", logPrefix, blockNumber, batchState.forkId))
logTicker.Reset(10 * time.Second)
Expand Down Expand Up @@ -224,12 +225,18 @@ func SpawnSequencingStage(
return err
}
} else if !batchState.isL1Recovery() {
batchState.blockState.transactionsForInclusion, err = getNextPoolTransactions(ctx, cfg, executionAt, batchState.forkId, batchState.yieldedTransactions)
batchState.blockState.transactionsForInclusion, allConditionsOK, err = getNextPoolTransactions(ctx, cfg, executionAt, batchState.forkId, batchState.yieldedTransactions)
if err != nil {
return err
}

if len(batchState.blockState.transactionsForInclusion) == 0 {
time.Sleep(batchContext.cfg.zk.SequencerTimeoutOnEmptyTxPool)
if allConditionsOK {
time.Sleep(batchContext.cfg.zk.SequencerTimeoutOnEmptyTxPool)
} else {
time.Sleep(batchContext.cfg.zk.SequencerTimeoutOnEmptyTxPool / 5) // we do not need to sleep too long for txpool not ready
}

} else {
log.Trace(fmt.Sprintf("[%s] Yielded transactions from the pool", logPrefix), "txCount", len(batchState.blockState.transactionsForInclusion))
}
Expand Down
9 changes: 5 additions & 4 deletions zk/stages/stage_sequence_execute_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@ import (
"github.com/ledgerwatch/log/v3"
)

func getNextPoolTransactions(ctx context.Context, cfg SequenceBlockCfg, executionAt, forkId uint64, alreadyYielded mapset.Set[[32]byte]) ([]types.Transaction, error) {
func getNextPoolTransactions(ctx context.Context, cfg SequenceBlockCfg, executionAt, forkId uint64, alreadyYielded mapset.Set[[32]byte]) ([]types.Transaction, bool, error) {
cfg.txPool.LockFlusher()
defer cfg.txPool.UnlockFlusher()

var transactions []types.Transaction
var allConditionsOk bool
var err error

gasLimit := utils.GetBlockGasLimitForFork(forkId)

if err := cfg.txPoolDb.View(ctx, func(poolTx kv.Tx) error {
slots := types2.TxsRlp{}
if _, _, err = cfg.txPool.YieldBest(cfg.yieldSize, &slots, poolTx, executionAt, gasLimit, alreadyYielded); err != nil {
if allConditionsOk, _, err = cfg.txPool.YieldBest(cfg.yieldSize, &slots, poolTx, executionAt, gasLimit, alreadyYielded); err != nil {
return err
}
yieldedTxs, err := extractTransactionsFromSlot(&slots)
Expand All @@ -42,10 +43,10 @@ func getNextPoolTransactions(ctx context.Context, cfg SequenceBlockCfg, executio
transactions = append(transactions, yieldedTxs...)
return nil
}); err != nil {
return nil, err
return nil, allConditionsOk, err
}

return transactions, err
return transactions, allConditionsOk, err
}

func getLimboTransaction(ctx context.Context, cfg SequenceBlockCfg, txHash *common.Hash) ([]types.Transaction, error) {
Expand Down

0 comments on commit c2e776a

Please sign in to comment.