Skip to content

Conversation

@julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Jun 6, 2025

Superseed #2301

Summary by CodeRabbit

  • New Features

    • Added support for custom signature verification logic on block headers, allowing advanced users to specify how header signatures are verified.
    • Enhanced context handling to provide block header information during transaction execution.
  • Bug Fixes

    • Improved context handling to make block header information available during transaction execution.
  • Chores

    • Updated the initial block version to 11 for improved compatibility with external blockchains.
    • Minor test and code cleanups with no impact on functionality.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 6, 2025

Walkthrough

The changes update block management and header verification mechanisms. The block manager now ignores the lastState argument in block creation and introduces a context key for passing block headers. The SignedHeader struct supports custom signature verification logic. The initial block version is incremented to 11 for compatibility. Minor test code cleanups and loosening of mock argument matching are also included.

Changes

File(s) Change Summary
block/manager.go Ignores lastState in execCreateBlock; adds context key for block headers; updates context usage in execApplyBlock.
types/signed_header.go Adds custom signature verifier support to SignedHeader; updates ValidateBasic logic; removes Validate method.
types/state.go Changes initial block version from 1 to 11 for IBC compatibility.
block/publish_block2_test.go Removes explicit generic type parameters in test helpers; removes trailing blank line in mock method.
block/publish_block_test.go Loosens mock expectation argument matching from specific context to mock.Anything in two tests.

Sequence Diagram(s)

sequenceDiagram
    participant Manager
    participant Context
    participant Executor
    participant SignedHeader

    Manager->>Context: Add block header with HeaderContextKey
    Manager->>Executor: Execute transactions with augmented context
    Executor->>Context: Access block header via HeaderContextKey
    Executor->>SignedHeader: Validate header (may use custom verifier)
    SignedHeader-->>Executor: Return validation result
Loading

Possibly related PRs

  • rollkit/rollkit#1789: Refactors block/manager.go including changes to block/header creation and management, directly related to modifications in this PR.

Suggested reviewers

  • tac0turtle
  • Manav-Aggarwal

Poem

A header hops into context with glee,
While custom verifiers set signatures free.
Block version eleven, a leap in the sun,
Tests cleaned up, their work neatly done.
With every commit, we build and delight—
A rabbit’s code hop, all changes in sight! 🐇

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (1.64.8)

Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2
Failed executing command with error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2


📜 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 37f5859 and 91741bf.

📒 Files selected for processing (1)
  • block/publish_block_test.go (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: rollkit-docker / docker-build (GHCR; ghcr.io/rollkit/rollkit)
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: test / Run E2E System Tests
  • GitHub Check: test / Build All Rollkit Binaries
  • GitHub Check: test / Run EVM Execution Tests
  • GitHub Check: lint / markdown-lint
  • GitHub Check: lint / golangci-lint
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary
🔇 Additional comments (2)
block/publish_block_test.go (2)

313-313: LGTM: Mock expectation correctly loosened for context augmentation.

The change from a specific context to mock.Anything is appropriate given that the context is now augmented with block header information before being passed to ExecuteTxs. This ensures the test remains valid while accommodating the underlying refactor.


383-383: LGTM: Consistent mock expectation adjustment.

Similar to the previous test, this change correctly loosens the mock expectation to accommodate the context augmentation with block header data. The test logic remains intact while properly handling the refactored context passing.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 6, 2025

The latest Buf updates on your PR. Results from workflow CI and Release / buf-check (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped✅ passed✅ passedJun 9, 2025, 10:19 AM

@julienrbrt julienrbrt marked this pull request as ready for review June 9, 2025 10:01
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

🧹 Nitpick comments (1)
types/signed_header.go (1)

126-140: Robust implementation with proper error handling.

The conditional logic correctly uses the custom verifier when available and wraps any errors appropriately. The fallback to default marshaling ensures backward compatibility.

Consider adding documentation about the security implications of custom verifiers to help users implement them safely.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60403ae and 37f5859.

📒 Files selected for processing (4)
  • block/manager.go (2 hunks)
  • block/publish_block2_test.go (2 hunks)
  • types/signed_header.go (4 hunks)
  • types/state.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: rollkit-docker / docker-build (GHCR; ghcr.io/rollkit/rollkit)
  • GitHub Check: test / Run E2E System Tests
  • GitHub Check: test / Run EVM Execution Tests
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: test / Build All Rollkit Binaries
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary
🔇 Additional comments (9)
types/state.go (1)

15-15: LGTM: Version update for CometBFT compatibility.

The block version bump to 11 is well-documented and aligns with CometBFT compatibility requirements for IBC.

block/publish_block2_test.go (2)

73-74: Good cleanup: Leveraging Go's type inference.

Removing the explicit generic type parameters improves code readability since the types can be inferred from the function arguments.


107-108: Good cleanup: Leveraging Go's type inference.

Removing the explicit generic type parameters improves code readability since the types can be inferred from the function arguments.

block/manager.go (3)

821-825: Excellent context key implementation.

The header context key follows Go best practices with an unexported key type and exported variable. This allows safe storage and retrieval of headers in the execution context.


833-833: Good enhancement: Header available during transaction execution.

Storing the header in context before executing transactions allows the execution client to access header information when needed, which aligns well with the PR's objective.


753-753:

Details

✅ Verification successful

Verify that ignoring the lastState parameter is safe.

The function signature now ignores the lastState parameter and uses m.lastState instead. While this may be an intentional design improvement, ensure that all callers expect this behavior and that there are no scenarios where the passed state differs from the manager's internal state.


🏁 Script executed:

#!/bin/bash
# Search for all calls to execCreateBlock to verify they don't rely on different lastState values
ast-grep --pattern 'execCreateBlock($$$)'

Length of output: 43


To ensure we didn’t miss any usages, let’s search across all Go files for calls to execCreateBlock:


🏁 Script executed:

#!/bin/bash
# Grep for all occurrences of execCreateBlock in Go files
rg --color=never --no-heading --with-filename --line-number 'execCreateBlock\(' --include '*.go'

Length of output: 540


To cover all bases, let’s search for any calls to execCreateBlock across the entire Go codebase, falling back to grep if ripgrep finds nothing:


🏁 Script executed:

#!/bin/bash
# Try ripgrep first
if ! rg -n 'execCreateBlock\('; then
  # Fallback to grep for .go files
  grep -R -n 'execCreateBlock(' --include='*.go' .
fi

Length of output: 371


execCreateBlock parameter usage verified

We’ve confirmed that execCreateBlock is only ever called once (in block/manager.go:699), and it always receives m.lastState. Changing the lastState parameter to a blank identifier has no impact on behavior and is safe to keep. No further action needed.

types/signed_header.go (3)

19-19: Good practice: Interface compliance check at top.

Moving the interface compliance assertion to the top of the file improves visibility and follows Go conventions.


21-23: Well-designed signature verification abstraction.

The SignatureVerifier function type provides a clean abstraction for custom signature verification logic while maintaining the same interface contract.


47-54: Good safeguard against verifier overwrites.

The check prevents accidental overwriting of an existing custom verifier, which could lead to unexpected behavior or security issues.

@julienrbrt
Copy link
Member Author

checking the failing tests, as no new calls have been added here.

@codecov
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

Attention: Patch coverage is 36.36364% with 14 lines in your changes missing coverage. Please review.

Project coverage is 65.84%. Comparing base (60403ae) to head (91741bf).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
types/signed_header.go 30.00% 13 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2346      +/-   ##
==========================================
- Coverage   65.91%   65.84%   -0.07%     
==========================================
  Files          66       66              
  Lines        6140     6155      +15     
==========================================
+ Hits         4047     4053       +6     
- Misses       1724     1733       +9     
  Partials      369      369              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tac0turtle tac0turtle added this pull request to the merge queue Jun 9, 2025
Merged via the queue into main with commit 8b2f23a Jun 9, 2025
26 checks passed
@tac0turtle tac0turtle deleted the julien/header-in-ctx branch June 9, 2025 13:55
@github-project-automation github-project-automation bot moved this to Done in Evolve Jun 9, 2025
Manav-Aggarwal pushed a commit that referenced this pull request Jun 10, 2025
Superseed #2301

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added support for custom signature verification logic on block
headers, allowing advanced users to specify how header signatures are
verified.
- Enhanced context handling to provide block header information during
transaction execution.

- **Bug Fixes**
- Improved context handling to make block header information available
during transaction execution.

- **Chores**
- Updated the initial block version to 11 for improved compatibility
with external blockchains.
  - Minor test and code cleanups with no impact on functionality.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Manav-Aggarwal pushed a commit that referenced this pull request Jun 10, 2025
Superseed #2301

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added support for custom signature verification logic on block
headers, allowing advanced users to specify how header signatures are
verified.
- Enhanced context handling to provide block header information during
transaction execution.

- **Bug Fixes**
- Improved context handling to make block header information available
during transaction execution.

- **Chores**
- Updated the initial block version to 11 for improved compatibility
with external blockchains.
  - Minor test and code cleanups with no impact on functionality.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@tac0turtle tac0turtle removed this from Evolve Aug 25, 2025
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