Skip to content

Commit

Permalink
apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rachit77 committed Dec 2, 2024
1 parent 7ca135e commit 88e3082
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
8 changes: 4 additions & 4 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ func TestClient_GetStatus(t *testing.T) {
name: "successfully got status",
result: `{"result":{"version":"v1.0.0","uptime":"123","key_count":2,"backfill_progress":5}}`,
status: &types.DACStatus{
Uptime: "123",
Version: "v1.0.0",
KeyCount: 2,
BackfillProgress: 5,
Uptime: "123",
Version: "v1.0.0",
KeyCount: 2,
LastSynchronizedBlock: 5,
},
},
{
Expand Down
6 changes: 5 additions & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ func (db *pgDB) StoreMissingBatchKeys(ctx context.Context, bks []types.BatchKey)
query, args := buildBatchKeysInsertQuery(bks)

if _, err := db.pg.ExecContext(ctx, query, args...); err != nil {
return fmt.Errorf("failed to store misisng batches: %w", err)
batchNumbers := make([]string, len(bks))
for i, bk := range bks {
batchNumbers[i] = fmt.Sprintf("%d", bk.Number)
}
return fmt.Errorf("failed to store missing batches (BatchKey.Number: %s): %w", strings.Join(batchNumbers, ", "), err)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions db/migrations/0006.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ALTER TABLE data_node.offchain_data
ADD COLUMN IF NOT EXISTS batch_num BIGINT NOT NULL DEFAULT 0;

-- Rename the 'missing_batches' table to 'unresolved_batches'
ALTER TABLE data_node.missing_batches RENAME TO unresolved_batches;
ALTER TABLE data_node.missing_batches RENAME TO data_node.unresolved_batches;

-- Create an index for the 'batch_num' column for better performance
CREATE INDEX IF NOT EXISTS idx_batch_num ON data_node.offchain_data(batch_num);
Expand All @@ -17,7 +17,7 @@ UPDATE data_node.sync_tasks SET block = 0 WHERE task = 'L1';
ALTER TABLE data_node.offchain_data DROP COLUMN batch_num;

-- Rename the 'unresolved_batches' table back to 'missing_batches'
ALTER TABLE data_node.unresolved_batches RENAME TO missing_batches;
ALTER TABLE data_node.unresolved_batches RENAME TO data_node.missing_batches;

-- Drop the index created on 'batch_num'
DROP INDEX IF EXISTS idx_batch_num;
10 changes: 5 additions & 5 deletions services/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ func (s *Endpoints) GetStatus() (interface{}, rpc.Error) {
log.Errorf("failed to get the key count from the offchain_data table: %v", err)
}

backfillProgress, err := s.db.GetLastProcessedBlock(ctx, string(synchronizer.L1SyncTask))
lastSynchronizedBlock, err := s.db.GetLastProcessedBlock(ctx, string(synchronizer.L1SyncTask))
if err != nil {
log.Errorf("failed to get last block processed by the synchronizer: %v", err)
}

return types.DACStatus{
Version: dataavailability.Version,
Uptime: uptime,
KeyCount: rowCount,
BackfillProgress: backfillProgress,
Version: dataavailability.Version,
Uptime: uptime,
KeyCount: rowCount,
LastSynchronizedBlock: lastSynchronizedBlock,
}, nil
}
2 changes: 1 addition & 1 deletion services/status/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestEndpoints_GetStatus(t *testing.T) {
require.NotEmpty(t, dacStatus.Uptime)
require.Equal(t, "v0.1.0", dacStatus.Version)
require.Equal(t, tt.countOffchainData, dacStatus.KeyCount)
require.Equal(t, tt.getLastProcessedBlock, dacStatus.BackfillProgress)
require.Equal(t, tt.getLastProcessedBlock, dacStatus.LastSynchronizedBlock)
}
})
}
Expand Down
8 changes: 4 additions & 4 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ const (

// DACStatus contains DAC status info
type DACStatus struct {
Uptime string `json:"uptime"`
Version string `json:"version"`
KeyCount uint64 `json:"key_count"`
BackfillProgress uint64 `json:"backfill_progress"`
Uptime string `json:"uptime"`
Version string `json:"version"`
KeyCount uint64 `json:"key_count"`
LastSynchronizedBlock uint64 `json:"last_synchronized_block"`
}

// BatchKey is the pairing of batch number and data hash of a batch
Expand Down

0 comments on commit 88e3082

Please sign in to comment.