Skip to content

Conversation

@curryxbo
Copy link
Contributor

@curryxbo curryxbo commented Dec 8, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Sidecar retrieval is more tolerant: responses with at least the requested number of sidecars are accepted; fewer sidecars still produce an error.
  • API Changes

    • Blob sidecar endpoint now returns multiple sidecars and includes an enhanced fallback retrieval path for more reliable results.
  • Chores

    • Build/update flow extended to include an additional module; dependency versions updated in that module.

✏️ Tip: You can customize this high-level summary in your review settings.

@curryxbo curryxbo requested a review from a team as a code owner December 8, 2025 06:51
@curryxbo curryxbo requested review from r3aker86 and removed request for a team December 8, 2025 06:51
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

Walkthrough

Replaces strict per-index sidecar validation with a minimum-count check, removes single-index retrieval/verification helpers and hex/KZG logic, and adds GetBlobSidecarsEnhanced which tries the original path then falls back to a time/slot-based direct API request. Tests updated for slice-based results.

Changes

Cohort / File(s) Change Summary
Beacon derivation logic
node/derivation/beacon.go
Relaxed sidecar count check to "at least N"; removed GetBlobSidecar, index-based helpers, hex decoding and KZG/blob-proof verification; added GetBlobSidecarsEnhanced that attempts existing retrieval then falls back to a time-to-slot direct API request.
Tests
node/derivation/beacon_test.go
Replaced calls to GetBlobSidecar(...) with GetBlobSidecarsEnhanced(...); updated test flow, error handling and logging to work with []*BlobSidecar results and enhanced time-based retrieval context.
Build tooling / deps
Makefile, token-price-oracle/go.mod
Added token-price-oracle to update_all_mod in Makefile; updated module dependency version in token-price-oracle/go.mod.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Review public API change from single BlobTxSidecar[]*BlobSidecar and update surface-area impacts.
  • Verify removal of hex/KZG verification for security/regression risk.
  • Inspect fallback path (time-to-slot direct API) for correctness and error handling.

Possibly related PRs

Suggested labels

validator

Suggested reviewers

  • r3aker86
  • FletcherMan

Poem

🐰
I hopped through code and loosened a knot,
Now blobs come in slices—no single-shot,
A fallback trail when the first path is thin,
I nibble bugs, then bounce with a grin.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 title 'Fix GetBlobSidecarsEnhanced' directly references the main function being modified in the changeset and accurately describes the primary change across multiple files.
✨ 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 fixGetBlobSidecar

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between defe539 and cfca6b4.

⛔ Files ignored due to path filters (2)
  • go.work.sum is excluded by !**/*.sum
  • token-price-oracle/go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • Makefile (1 hunks)
  • node/derivation/beacon.go (1 hunks)
  • token-price-oracle/go.mod (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
node/derivation/beacon.go (1)
ops/l2-genesis/eth/types.go (1)
  • Data (123-123)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: Analyze (rust)
  • GitHub Check: Analyze (go)
🔇 Additional comments (3)
Makefile (1)

33-33: LGTM!

The addition of token-price-oracle to the batch update flow is consistent with the existing pattern and ensures its dependencies are updated alongside other modules.

node/derivation/beacon.go (1)

133-138: LGTM!

The updated comment accurately describes the behavior, and the validation logic correctly ensures at least the requested number of sidecars are returned. The changes appropriately address the removal of the index-based filtering function.

token-price-oracle/go.mod (1)

11-11: The dependency version v1.10.14-0.20251119080508-d085f8c79a53 is consistent across all modules and matches the ETHEREUM_TARGET_VERSION defined in the Makefile (line 3). No alignment issues detected.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
node/derivation/beacon.go (1)

250-278: Inconsistent validation in fallback path.

When the fallback path at line 274 returns blobResp.Data, it skips the validation that GetBlobSidecars performs (ensuring at least len(hashes) sidecars are returned). This could return fewer sidecars than needed, causing downstream failures in callers that expect all requested hashes to be present.

Additionally, shadowing err inside the if-block (line 257) loses the original error from GetBlobSidecars, making debugging harder.

 func (cl *L1BeaconClient) GetBlobSidecarsEnhanced(ctx context.Context, ref L1BlockRef, hashes []IndexedBlobHash) ([]*BlobSidecar, error) {
 	// First try using the original GetBlobSidecars method
 	blobSidecars, err := cl.GetBlobSidecars(ctx, ref, hashes)
-	if err != nil || len(blobSidecars) == 0 {
+	if err == nil && len(blobSidecars) >= len(hashes) {
+		return blobSidecars, nil
+	}
+
+	// If failed or insufficient blobs retrieved, try the second method
+	slotFn, slotFnErr := cl.GetTimeToSlotFn(ctx)
+	if slotFnErr != nil {
+		return nil, fmt.Errorf("failed to get timeToSlotFn: %w", slotFnErr)
+	}
 
-		// If failed or no blobs retrieved, try the second method
-		slotFn, err := cl.GetTimeToSlotFn(ctx)
-		if err != nil {
-			return nil, fmt.Errorf("failed to get timeToSlotFn: %w", err)
-		}
+	slot, slotErr := slotFn(ref.Time)
+	if slotErr != nil {
+		return nil, fmt.Errorf("failed to calculate slot: %w", slotErr)
+	}
 
-		slot, err := slotFn(ref.Time)
-		if err != nil {
-			return nil, fmt.Errorf("failed to calculate slot: %w", err)
-		}
+	// Build request URL and use apiReq method directly
+	method := fmt.Sprintf("%s%d", sidecarsMethodPrefix, slot)
+	var blobResp APIGetBlobSidecarsResponse
+	if reqErr := cl.apiReq(ctx, &blobResp, method); reqErr != nil {
+		return nil, fmt.Errorf("failed to request blob sidecars: %w", reqErr)
+	}
 
-		// Build request URL and use apiReq method directly
-		method := fmt.Sprintf("%s%d", sidecarsMethodPrefix, slot)
-		var blobResp APIGetBlobSidecarsResponse
-		if err := cl.apiReq(ctx, &blobResp, method); err != nil {
-			return nil, fmt.Errorf("failed to request blob sidecars: %w", err)
-		}
-
-		return blobResp.Data, nil
+	if len(blobResp.Data) < len(hashes) {
+		return nil, fmt.Errorf("expected at least %v sidecars but got %v", len(hashes), len(blobResp.Data))
 	}
 
-	return blobSidecars, nil
+	return blobResp.Data, nil
 }
🧹 Nitpick comments (1)
node/derivation/beacon_test.go (1)

17-21: Consider adding test skip annotation for clarity.

The test silently returns when BLOB_URL is not set. Consider using t.Skip() to make test output clearer in CI environments.

 func TestGetBlob(t *testing.T) {
 	url := os.Getenv("BLOB_URL")
 	if url == "" {
-		return
+		t.Skip("BLOB_URL environment variable not set, skipping integration test")
 	}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df65943 and 132d3e6.

📒 Files selected for processing (2)
  • node/derivation/beacon.go (1 hunks)
  • node/derivation/beacon_test.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
node/derivation/beacon.go (1)
ops/l2-genesis/eth/types.go (1)
  • Data (123-123)
node/derivation/beacon_test.go (2)
node/derivation/blobs.go (1)
  • BlobSidecar (15-22)
node/derivation/beacon.go (1)
  • L1BlockRef (96-101)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: check
  • GitHub Check: test
  • GitHub Check: check
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: check
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (rust)
🔇 Additional comments (2)
node/derivation/beacon.go (1)

134-139: LGTM! Relaxed validation aligns with Beacon API behavior.

The change from exact equality to >= check is correct since some Beacon nodes return all sidecars for a slot regardless of the indices parameter. The sidecarFromSidecars function properly filters by index and verifies blob hashes downstream.

node/derivation/beacon_test.go (1)

44-51: Test correctly updated for new API.

The test properly uses GetBlobSidecarsEnhanced and handles the slice return type. Note that len(bts) now counts the number of sidecar entries returned, which differs from the previous len(bts.Blobs) semantics, but this is correct for the new API.

Copy link
Contributor

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
node/derivation/beacon.go (1)

201-229: Several issues in the fallback logic.

  1. Original error discarded: When GetBlobSidecars fails, the error is silently discarded. Consider logging or wrapping it for debugging.

  2. Empty hashes triggers unnecessary fallback: If hashes is empty, GetBlobSidecars returns an empty slice (line 106-108), which triggers the fallback to fetch ALL sidecars for the slot unnecessarily.

  3. Fallback lacks validation: GetBlobSidecars validates len(resp.Data) < len(hashes), but the fallback path doesn't perform this check, potentially returning insufficient data.

  4. Variable shadowing: Line 208 redeclares err with :=, shadowing the outer err variable.

 func (cl *L1BeaconClient) GetBlobSidecarsEnhanced(ctx context.Context, ref L1BlockRef, hashes []IndexedBlobHash) ([]*BlobSidecar, error) {
+	if len(hashes) == 0 {
+		return []*BlobSidecar{}, nil
+	}
+
 	// First try using the original GetBlobSidecars method
-	blobSidecars, err := cl.GetBlobSidecars(ctx, ref, hashes)
-	if err != nil || len(blobSidecars) == 0 {
+	blobSidecars, firstErr := cl.GetBlobSidecars(ctx, ref, hashes)
+	if firstErr != nil || len(blobSidecars) == 0 {
 		// If failed or no blobs retrieved, try the second method
 		slotFn, err := cl.GetTimeToSlotFn(ctx)
 		if err != nil {
-			return nil, fmt.Errorf("failed to get timeToSlotFn: %w", err)
+			return nil, fmt.Errorf("failed to get timeToSlotFn (original error: %v): %w", firstErr, err)
 		}
 
 		slot, err := slotFn(ref.Time)
 		if err != nil {
-			return nil, fmt.Errorf("failed to calculate slot: %w", err)
+			return nil, fmt.Errorf("failed to calculate slot (original error: %v): %w", firstErr, err)
 		}
 
 		// Build request URL and use apiReq method directly
 		method := fmt.Sprintf("%s%d", sidecarsMethodPrefix, slot)
 		var blobResp APIGetBlobSidecarsResponse
 		if err := cl.apiReq(ctx, &blobResp, method); err != nil {
-			return nil, fmt.Errorf("failed to request blob sidecars: %w", err)
+			return nil, fmt.Errorf("failed to request blob sidecars (original error: %v): %w", firstErr, err)
+		}
+
+		if len(blobResp.Data) < len(hashes) {
+			return nil, fmt.Errorf("expected at least %v sidecars but got %v", len(hashes), len(blobResp.Data))
 		}
 
 		return blobResp.Data, nil
 	}
 
 	return blobSidecars, nil
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 132d3e6 and defe539.

📒 Files selected for processing (1)
  • node/derivation/beacon.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
node/derivation/beacon.go (1)
ops/l2-genesis/eth/types.go (1)
  • Data (123-123)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: check
  • GitHub Check: test
  • GitHub Check: Analyze (rust)
  • GitHub Check: Analyze (go)

@curryxbo curryxbo merged commit 24abaa7 into main Dec 10, 2025
13 checks passed
@curryxbo curryxbo deleted the fixGetBlobSidecar branch December 10, 2025 03:42
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.

3 participants