Skip to content

Commit accd48f

Browse files
authored
chore: clean up handling of nil batch on startup (#1890)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. NOTE: PR titles should follow semantic commits: https://www.conventionalcommits.org/en/v1.0.0/ --> ## Overview <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. Ex: Closes #<issue number> --> On start up, for a new rollup or restarting an existing rollup, it is common or expected for there to be no txns to process. Currently this triggers an error every time which is unnecessary. Additionally, there are plenty of situations were there are no txns to process and that is ok. This PR changes the error log to an info log. ``` I[2024-10-29|09:27:02.127] Creating and publishing block module=BlockManager height=1 E[2024-10-29|09:27:02.127] error while publishing block module=BlockManager error="failed to get transactions from batch: no batch to process" I[2024-10-29|09:27:03.127] Creating and publishing block module=BlockManager height=1 ``` ``` I[2024-10-29|09:27:16.852] Started node module=main I[2024-10-29|09:27:16.853] Creating and publishing block module=BlockManager height=11 E[2024-10-29|09:27:16.853] error while publishing block module=BlockManager error="failed to get transactions from batch: no batch to process" I[2024-10-29|09:27:17.853] Creating and publishing block module=BlockManager height=11 ``` After ``` I[2024-10-29|09:32:03.615] Creating and publishing block module=BlockManager height=1 I[2024-10-29|09:32:03.615] no batch to process module=BlockManager I[2024-10-29|09:32:04.615] Creating and publishing block module=BlockManager height=1 ``` ``` I[2024-10-29|09:35:09.721] Started node module=main I[2024-10-29|09:35:09.721] Creating and publishing block module=BlockManager height=6 I[2024-10-29|09:35:09.721] no batch to process module=BlockManager I[2024-10-29|09:35:10.722] Creating and publishing block module=BlockManager height=6 ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Enhanced error handling for block publishing when no transactions are available, preventing unnecessary block creation attempts. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent ca746d0 commit accd48f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

block/manager.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,10 +1074,13 @@ func (m *Manager) publishBlock(ctx context.Context) error {
10741074
}
10751075

10761076
txs, timestamp, err := m.getTxsFromBatch()
1077-
if err != nil {
1078-
m.logger.Debug("waiting for transactions to include in block or empty batch", "height", newHeight, "details", err)
1077+
if errors.Is(err, ErrNoBatch) {
1078+
m.logger.Info(err.Error())
10791079
return nil
10801080
}
1081+
if err != nil {
1082+
return fmt.Errorf("failed to get transactions from batch: %w", err)
1083+
}
10811084
// sanity check timestamp for monotonically increasing
10821085
if timestamp.Before(lastHeaderTime) {
10831086
return fmt.Errorf("timestamp is not monotonically increasing: %s < %s", timestamp, m.getLastBlockTime())

0 commit comments

Comments
 (0)