Skip to content

Commit

Permalink
fix(gas-oracle): fetch base fee of the latest block
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Sep 4, 2023
1 parent 4af3834 commit 368272b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion database/migrate/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func testResetDB(t *testing.T) {
cur, err := Current(pgDB.DB)
assert.NoError(t, err)
// total number of tables.
assert.Equal(t, 11, int(cur))
assert.Equal(t, 12, int(cur))
}

func testMigrate(t *testing.T) {
Expand Down
15 changes: 15 additions & 0 deletions database/migrate/migrations/00012_drop_unique_l1_block_number.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- +goose Up
-- +goose StatementBegin
drop index if exists l1_block_number_uindex;

create index l1_block_number_index
on l1_block (number) where deleted_at IS NULL;
-- +goose StatementEnd

-- +goose Down
-- +goose StatementBegin
drop index if exists l1_block_number_index;

create unique index if not exists l1_block_number_uindex
on l1_block (number) where deleted_at IS NULL;
-- +goose StatementEnd
6 changes: 3 additions & 3 deletions rollup/cmd/gas_oracle/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"scroll-tech/rollup/internal/config"
"scroll-tech/rollup/internal/controller/relayer"
"scroll-tech/rollup/internal/controller/watcher"
butils "scroll-tech/rollup/internal/utils"
)

var app *cli.App
Expand Down Expand Up @@ -92,8 +91,9 @@ func action(ctx *cli.Context) error {
}
// Start l1 watcher process
go utils.LoopWithContext(subCtx, 10*time.Second, func(ctx context.Context) {
number, loopErr := butils.GetLatestConfirmedBlockNumber(ctx, l1client, cfg.L1Config.Confirmations)
if loopErr != nil {
// Fetch the latest block number to decrease the delay when fetching gas prices
number, loopErr := l1client.BlockNumber(ctx)
if err != nil {
log.Error("failed to get block number", "err", loopErr)
return
}
Expand Down

0 comments on commit 368272b

Please sign in to comment.