Skip to content

Commit

Permalink
Cahnge getLastGer implementation (#1556)
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniRamirezM authored Jan 18, 2023
1 parent a99fb62 commit 5e3ad6c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
8 changes: 1 addition & 7 deletions sequencer/closingsignalsmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ func (c *closingSignalsManager) checkGERUpdate() {
for {
time.Sleep(c.cfg.ClosingSignalsManagerWaitForL1OperationsInSec.Duration * time.Second)

lastL2BlockHeader, err := c.dbManager.GetLastL2BlockHeader(c.ctx, nil)
if err != nil {
log.Errorf("error getting last L2 block: %v", err)
continue
}

ger, _, err := c.dbManager.GetLatestGer(c.ctx, lastL2BlockHeader.Number.Uint64(), c.cfg.GERFinalityNumberOfBlocks)
ger, _, err := c.dbManager.GetLatestGer(c.ctx, c.cfg.GERFinalityNumberOfBlocks)
if err != nil {
log.Errorf("error checking GER update: %v", err)
continue
Expand Down
10 changes: 9 additions & 1 deletion sequencer/dbmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,15 @@ func (d *dbManager) GetLastNBatches(ctx context.Context, numBatches uint) ([]*st
}

// GetLatestGer gets the latest global exit root
func (d *dbManager) GetLatestGer(ctx context.Context, blockNumber uint64, gerFinalityNumberOfBlocks uint64) (state.GlobalExitRoot, time.Time, error) {
func (d *dbManager) GetLatestGer(ctx context.Context, gerFinalityNumberOfBlocks uint64) (state.GlobalExitRoot, time.Time, error) {
lastL2BlockHeader, err := d.GetLastL2BlockHeader(ctx, nil)
if err != nil {
log.Errorf("error getting last L2 block: %v", err)

}

blockNumber := lastL2BlockHeader.Number.Uint64()

maxBlockNumber := uint64(0)
if gerFinalityNumberOfBlocks <= blockNumber {
maxBlockNumber = blockNumber - gerFinalityNumberOfBlocks
Expand Down
2 changes: 1 addition & 1 deletion sequencer/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type dbManagerInterface interface {
GetLastClosedBatch(ctx context.Context) (*state.Batch, error)
IsBatchClosed(ctx context.Context, batchNum uint64) (bool, error)
MarkReorgedTxsAsPending(ctx context.Context)
GetLatestGer(ctx context.Context, blockNumber uint64, gerFinalityNumberOfBlocks uint64) (state.GlobalExitRoot, time.Time, error)
GetLatestGer(ctx context.Context, gerFinalityNumberOfBlocks uint64) (state.GlobalExitRoot, time.Time, error)
ProcessForcedBatch(forcedBatchNum uint64, request state.ProcessRequest) (*state.ProcessBatchResponse, error)
GetForcedBatchesSince(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) ([]*state.ForcedBatch, error)
GetLastL2BlockHeader(ctx context.Context, dbTx pgx.Tx) (*types.Header, error)
Expand Down
18 changes: 9 additions & 9 deletions sequencer/mock_db_manager.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5e3ad6c

Please sign in to comment.