Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jonastheis committed Dec 12, 2024
1 parent b05954d commit ce8f785
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 54 deletions.
1 change: 1 addition & 0 deletions rollup/da_syncer/batch_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@ func (bq *BatchQueue) deleteBatch(batch da.Entry) {
func (bq *BatchQueue) Reset(height uint64) {
bq.batches.Clear()
bq.batchesMap.Clear()
bq.lastFinalizedBatchIndex = 0
bq.DAQueue.Reset(height)
}
6 changes: 5 additions & 1 deletion rollup/da_syncer/blob_client/block_native_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ func (c *BlockNativeClient) GetBlobByVersionedHashAndBlockNumber(ctx context.Con
if err != nil {
return nil, fmt.Errorf("failed to join path, err: %w", err)
}
resp, err := http.Get(path)
req, err := http.NewRequestWithContext(ctx, "GET", path, nil)
if err != nil {
return nil, fmt.Errorf("cannot create request, err: %w", err)
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, fmt.Errorf("cannot do request, err: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion rollup/da_syncer/da/commitV1.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewCommitBatchDAWithBlob(ctx context.Context, db ethdb.Database,
// compute blob versioned hash and compare with one from tx
c, err := kzg4844.BlobToCommitment(blob)
if err != nil {
return nil, fmt.Errorf("failed to create blob commitment")
return nil, fmt.Errorf("failed to create blob commitment: %w", err)
}
blobVersionedHash := common.Hash(kzg4844.CalcBlobHashV1(sha256.New(), &c))
if blobVersionedHash != versionedHash {
Expand Down
6 changes: 6 additions & 0 deletions rollup/da_syncer/da_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ func NewDAQueue(l1height uint64, dataSourceFactory *DataSourceFactory) *DAQueue

func (dq *DAQueue) NextDA(ctx context.Context) (da.Entry, error) {
for len(dq.da) == 0 {
select {
case <-ctx.Done():
return nil, ctx.Err()
default:
}

err := dq.getNextData(ctx)
if err != nil {
return nil, err
Expand Down
4 changes: 4 additions & 0 deletions rollup/da_syncer/da_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ func (s *DASyncer) SyncOneBlock(block *da.PartialBlock) error {
}

parentBlock := s.blockchain.GetBlockByNumber(currentBlock.Number().Uint64())
if parentBlock == nil {
return fmt.Errorf("parent block not found at height %d", currentBlock.Number().Uint64())
}

if _, err := s.blockchain.BuildAndWriteBlock(parentBlock, block.PartialHeader.ToHeader(), block.Transactions); err != nil {
return fmt.Errorf("failed building and writing block, number: %d, error: %v", block.PartialHeader.Number, err)
}
Expand Down
52 changes: 0 additions & 52 deletions rollup/da_syncer/modes.go

This file was deleted.

0 comments on commit ce8f785

Please sign in to comment.