Skip to content

Commit

Permalink
Refactor sequencer state interfaces (#2002)
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniRamirezM authored Apr 12, 2023
1 parent c32f2d4 commit ebdbe04
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
4 changes: 2 additions & 2 deletions sequencer/dbmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
type dbManager struct {
cfg DBManagerCfg
txPool txPool
state dbManagerStateInterface
state stateInterface
worker workerInterface
txsStore TxsStore
l2ReorgCh chan L2ReorgEvent
Expand All @@ -43,7 +43,7 @@ type ClosingBatchParameters struct {
Txs []types.Transaction
}

func newDBManager(ctx context.Context, config DBManagerCfg, txPool txPool, state dbManagerStateInterface, worker *Worker, closingSignalCh ClosingSignalCh, txsStore TxsStore, batchConstraints batchConstraints) *dbManager {
func newDBManager(ctx context.Context, config DBManagerCfg, txPool txPool, state stateInterface, worker *Worker, closingSignalCh ClosingSignalCh, txsStore TxsStore, batchConstraints batchConstraints) *dbManager {
numberOfReorgs, err := state.CountReorgs(ctx, nil)
if err != nil {
log.Error("failed to get number of reorgs: %v", err)
Expand Down
30 changes: 0 additions & 30 deletions sequencer/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,36 +119,6 @@ type dbManagerInterface interface {
FlushMerkleTree(ctx context.Context) error
}

type dbManagerStateInterface interface {
BeginStateTransaction(ctx context.Context) (pgx.Tx, error)
OpenBatch(ctx context.Context, processingContext state.ProcessingContext, dbTx pgx.Tx) error
GetLastVirtualBatchNum(ctx context.Context, dbTx pgx.Tx) (uint64, error)
GetLastNBatches(ctx context.Context, numBatches uint, dbTx pgx.Tx) ([]*state.Batch, error)
StoreTransaction(ctx context.Context, batchNumber uint64, processedTx *state.ProcessTransactionResponse, coinbase common.Address, timestamp uint64, dbTx pgx.Tx) error
CloseBatch(ctx context.Context, receipt state.ProcessingReceipt, dbTx pgx.Tx) error
IsBatchClosed(ctx context.Context, batchNum uint64, dbTx pgx.Tx) (bool, error)
GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, err error)
GetLastClosedBatch(ctx context.Context, dbTx pgx.Tx) (*state.Batch, error)
GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
GetLastBatch(ctx context.Context, dbTx pgx.Tx) (*state.Batch, error)
GetLatestGlobalExitRoot(ctx context.Context, maxBlockNumber uint64, dbTx pgx.Tx) (state.GlobalExitRoot, time.Time, error)
GetLastStateRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error)
GetLastL2BlockHeader(ctx context.Context, dbTx pgx.Tx) (*types.Header, error)
GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*state.Block, error)
ExecuteBatch(ctx context.Context, batch state.Batch, updateMerkleTree bool, dbTx pgx.Tx) (*pb.ProcessBatchResponse, error)
GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
UpdateBatchL2Data(ctx context.Context, batchNumber uint64, batchL2Data []byte, dbTx pgx.Tx) error
GetForcedBatch(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (*state.ForcedBatch, error)
ProcessSequencerBatch(ctx context.Context, batchNumber uint64, batchL2Data []byte, caller metrics.CallerLabel, dbTx pgx.Tx) (*state.ProcessBatchResponse, error)
GetForcedBatchesSince(ctx context.Context, forcedBatchNumber, maxBlockNumber uint64, dbTx pgx.Tx) ([]*state.ForcedBatch, error)
GetLastTrustedForcedBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
GetBalanceByStateRoot(ctx context.Context, address common.Address, root common.Hash) (*big.Int, error)
GetLatestVirtualBatchTimestamp(ctx context.Context, dbTx pgx.Tx) (time.Time, error)
CountReorgs(ctx context.Context, dbTx pgx.Tx) (uint64, error)
GetLatestGer(ctx context.Context, maxBlockNumber uint64) (state.GlobalExitRoot, time.Time, error)
FlushMerkleTree(ctx context.Context) error
}

type ethTxManager interface {
Add(ctx context.Context, owner, id string, from common.Address, to *common.Address, value *big.Int, data []byte, dbTx pgx.Tx) error
Result(ctx context.Context, owner, id string, dbTx pgx.Tx) (ethtxmanager.MonitoredTxResult, error)
Expand Down

0 comments on commit ebdbe04

Please sign in to comment.