Skip to content

Conversation

@nischitpra
Copy link
Collaborator

@nischitpra nischitpra commented Oct 27, 2025

Summary by CodeRabbit

  • New Features

    • Added environment-controlled option to mark committer as live.
    • New remote service operations to manage committer lifecycle and trigger S3 rightsize.
  • Behavior

    • Automatic one-time S3 committer rightsizing when near the next commit height (visible via logs/metrics).
    • Reorg validation skipped when committer is not live.
  • Bug Fixes

    • Improved block-range error messages now include actual block numbers.
  • Refactor

    • Unified internal service request handling with generalized endpoint usage.

@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2025

Walkthrough

Adds a CommitterIsLive configuration flag; moves insight-service HTTP helpers into internal/libs exposing DisableIndexerMaybeStartCommitter and RightsizeS3Committer; qualifies a call to the new libs function; triggers a one-time S3 committer rightsizing in the poll loop; adds an early return in reorg validator and improves a reorg error message.

Changes

Cohort / File(s) Summary
Configuration Extension
configs/config.go
Added public field CommitterIsLive bool with env tag COMMITTER_IS_LIVE (default: false) to Config struct.
Insight service → libs refactor
internal/libs/insightServiceRequests.go
Package renamed to libs; added public functions DisableIndexerMaybeStartCommitter() and RightsizeS3Committer() and unexported helper makeS3CommitterRequest(endpoint string); generalized request path to /service/chains/{ChainIdStr}/{endpoint}; updated logging and error messages.
Qualified call
internal/backfill/getbackfillboundaries.go
Replaced unqualified call with libs.DisableIndexerMaybeStartCommitter() when startBlock > endBlock.
Committer pooling change
internal/committer/poollatest.go
Added a one-time guard hasRightsized and conditional: when CommitterIsLive is false and latest is within 20 blocks of the next commit, log and call libs.RightsizeS3Committer() once.
Reorg handling
internal/committer/reorg.go
RunReorgValidator now returns early when CommitterIsLive is false; getReorgRange error message updated to include block numbers: "start block is greater than end block (%d >= %d)".

Sequence Diagram(s)

sequenceDiagram
  participant Poll as pollLatest loop
  participant Config as Config (CommitterIsLive)
  participant Libs as internal/libs
  participant Service as Insight Service HTTP

  Note over Poll,Config: periodic pollLatest iteration
  Poll->>Config: read CommitterIsLive
  alt CommitterIsLive == false and within 20 blocks and not rightsized
    Poll->>Libs: RightsizeS3Committer()
    activate Libs
    Libs->>Service: HTTP POST /service/chains/{ChainIdStr}/rightsize-s3-committer
    Service-->>Libs: 2xx / non-2xx
    Libs-->>Poll: result (log)
    deactivate Libs
    Poll-->Poll: set hasRightsized = true
  end
Loading
sequenceDiagram
  participant Backfill as GetBackfillBoundaries
  participant Libs as internal/libs

  Backfill->>Libs: libs.DisableIndexerMaybeStartCommitter()
  Libs-->>Backfill: returns / logs (may start committer)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • Focus areas:
    • internal/libs/insightServiceRequests.go: verify HTTP request construction, endpoint formatting, and logging/error messages.
    • internal/committer/poollatest.go: confirm guard correctness, timing window (20 blocks), and interaction with CommitterIsLive.
    • internal/committer/reorg.go: verify early-return behavior and updated error text.
    • internal/backfill/getbackfillboundaries.go: ensure the qualified call compiles and imports are correct.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "right size s3 committer after it is caught up" directly describes the primary change in the changeset. The raw summary shows that the core feature being added is logic in poollatest.go that triggers a rightsize of the S3 committer when the committer is not live and within 20 blocks of the next commit block. The supporting changes—such as adding the CommitterIsLive configuration field, updating function calls, and reorganizing package structure—all serve to enable this main objective. The title is concise, clear, and specific enough for a teammate to understand the primary purpose when scanning commit history. It avoids vague language and meaningfully conveys the changeset's intent.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch np/is_committer_live

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3cd7742 and b733663.

📒 Files selected for processing (1)
  • internal/committer/reorg.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/committer/reorg.go

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
internal/committer/poollatest.go (1)

78-78: Consider making the 20-block threshold configurable.

The hardcoded threshold of 20 blocks may need adjustment for different chain speeds or operational requirements.

You could add a configuration field:

CommitterRightsizeThreshold int `env:"COMMITTER_RIGHTSIZE_THRESHOLD" envDefault:"20"`

Then use it here:

-if !config.Cfg.CommitterIsLive && latestBlock.Int64()-int64(nextBlockNumber) < 20 {
+if !config.Cfg.CommitterIsLive && latestBlock.Int64()-int64(nextBlockNumber) < int64(config.Cfg.CommitterRightsizeThreshold) {
internal/libs/insightServiceRequests.go (1)

27-84: Consider returning errors for critical operations.

The current fire-and-forget pattern logs errors but doesn't propagate them to callers. For critical operations like DisableIndexerMaybeStartCommitter, the caller might need to know if the request succeeded.

If you want callers to handle failures, consider:

-func makeS3CommitterRequest(endpoint string) {
+func makeS3CommitterRequest(endpoint string) error {
 	serviceURL := config.Cfg.InsightServiceUrl
 	apiKey := config.Cfg.InsightServiceApiKey
 	zeetDeploymentId := config.Cfg.ZeetDeploymentId
 
 	// Prepare request payload
 	requestBody := DeployS3CommitterRequest{
 		ZeetDeploymentId: zeetDeploymentId,
 	}
 
 	jsonData, err := json.Marshal(requestBody)
 	if err != nil {
 		log.Error().Err(err).Msg("Failed to marshal request body")
-		return
+		return fmt.Errorf("failed to marshal request body: %w", err)
 	}
 	// ... similar changes for other error paths
+	return nil
 }

Then update the public functions:

-func DisableIndexerMaybeStartCommitter() {
-	makeS3CommitterRequest("deploy-s3-committer")
+func DisableIndexerMaybeStartCommitter() error {
+	return makeS3CommitterRequest("deploy-s3-committer")
 }

However, if the fire-and-forget pattern is intentional for resilience, the current implementation is acceptable.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c0c492e and 061cc55.

📒 Files selected for processing (5)
  • configs/config.go (1 hunks)
  • internal/backfill/getbackfillboundaries.go (1 hunks)
  • internal/committer/poollatest.go (1 hunks)
  • internal/committer/reorg.go (1 hunks)
  • internal/libs/insightServiceRequests.go (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
internal/committer/poollatest.go (2)
configs/config.go (1)
  • Cfg (84-84)
internal/libs/insightServiceRequests.go (1)
  • RightsizeS3Committer (22-24)
internal/backfill/getbackfillboundaries.go (1)
internal/libs/insightServiceRequests.go (1)
  • DisableIndexerMaybeStartCommitter (18-20)
internal/libs/insightServiceRequests.go (1)
internal/libs/rpcclient.go (1)
  • ChainIdStr (12-12)
🔇 Additional comments (4)
internal/committer/reorg.go (1)

60-60: LGTM! Enhanced error diagnostics.

Including the actual block numbers in the error message significantly improves debuggability.

configs/config.go (1)

63-63: LGTM! Configuration field properly defined.

The new CommitterIsLive flag is correctly structured with appropriate environment variable binding and a sensible default value.

internal/backfill/getbackfillboundaries.go (1)

25-25: LGTM! Correct package reference.

The qualified call to libs.DisableIndexerMaybeStartCommitter() properly reflects the function's relocation to the libs package.

internal/libs/insightServiceRequests.go (1)

1-1: LGTM! Clean API refactoring.

The package relocation to libs and the new public entry points (DisableIndexerMaybeStartCommitter and RightsizeS3Committer) provide a clean, reusable interface with proper separation of concerns.

Also applies to: 18-24

@nischitpra nischitpra merged commit 821798a into main Oct 27, 2025
5 checks passed
@nischitpra nischitpra deleted the np/is_committer_live branch October 27, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants