Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into release/v0.5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
omritoptix committed Aug 29, 2023
2 parents 897ad27 + 40e74dc commit 28a7e1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
12 changes: 7 additions & 5 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ func (m *Manager) SubmitLoop(ctx context.Context) {
//Context canceled
case <-ctx.Done():
return
//TODO: add the case of batch size (should be signaled from the the block production)
// case <- requiredByNumOfBlocks
case <-ticker.C:
// SyncTarget is the height of the last block in the last batch as seen by this node.
syncTarget := atomic.LoadUint64(&m.syncTarget)
Expand All @@ -302,13 +304,13 @@ func (m *Manager) SubmitLoop(ctx context.Context) {
}

// Submit batch if we've reached the batch size and there isn't another batch currently in submission process.
if m.batchInProcess.Load() == false {
m.batchInProcess.Store(true)
go m.submitNextBatch(ctx)
if m.batchInProcess.Load() == true {
m.logger.Debug("Batch submission already in process, skipping submission")
continue
}

//TODO: add the case of batch size (should be signaled from the the block production)
// case <- requiredByNumOfBlocks
m.batchInProcess.Store(true)
m.submitNextBatch(ctx)
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions settlement/dymension/dymension.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ func (d *HubClient) Stop() error {
// PostBatch posts a batch to the Dymension Hub. it tries to post the batch until it is accepted by the settlement layer.
// it emits success and failure events to the event bus accordingly.
func (d *HubClient) PostBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) {

msgUpdateState, err := d.convertBatchToMsgUpdateState(batch, daClient, daResult)
if err != nil {
panic(err)
Expand Down Expand Up @@ -236,7 +235,6 @@ func (d *HubClient) PostBatch(batch *types.Batch, daClient da.Client, daResult *
map[string][]string{settlement.EventTypeKey: {settlement.EventSettlementHealthStatus}})
// Sleep to allow context cancellation to take effect before retrying

//TODO(mtsitrin): I think it should panic here, if it fails after retries. same as in DA submission
time.Sleep(100 * time.Millisecond)
continue
}
Expand All @@ -245,6 +243,7 @@ func (d *HubClient) PostBatch(batch *types.Batch, daClient da.Client, daResult *
// Batch was submitted successfully. Wait for it to be accepted by the settlement layer.
ticker := time.NewTicker(d.batchAcceptanceTimeout)
defer ticker.Stop()

select {
case <-d.ctx.Done():
return
Expand Down Expand Up @@ -516,7 +515,7 @@ func (d *HubClient) waitForBatchInclusion(batchStartHeight uint64) (*settlement.
return nil
}
return settlement.ErrBatchNotFound
}, retry.Context(d.ctx), retry.LastErrorOnly(true), retry.Delay(d.batchRetryDelay), retry.Attempts(d.batchRetryAttempts))
}, retry.Context(d.ctx), retry.LastErrorOnly(true),
retry.Delay(d.batchRetryDelay), retry.Attempts(d.batchRetryAttempts), retry.MaxDelay(batchRetryMaxDelay))
return resultRetriveBatch, err

}

0 comments on commit 28a7e1c

Please sign in to comment.