Skip to content

Conversation

@codegen-sh
Copy link
Contributor

@codegen-sh codegen-sh bot commented Dec 21, 2025

Summary

This PR implements partial blocks support for the substreams gui command, mirroring the functionality already available in substreams run. Users can now view partial blockchain blocks in the GUI interface with clear visual identification.

Changes Made

1. Command Flag Integration

  • File: cmd/substreams/gui.go
  • Changes: Added sink.FlagIncludePartialBlocks and sink.FlagPartialBlocksOnly to the GUI command's optional flags
  • Impact: Exposes the --include-partial-blocks and --partial-blocks-only flags for the GUI command

2. Stream Message Routing

  • File: tui2/stream/stream.go
  • Changes:
    • Added *pbsubstreamsrpc.Response_PartialBlockData case to routeNextMessage() function
    • Added *pbsubstreamsrpc.PartialBlockData case to Update() method
  • Impact: Ensures PartialBlockData messages are properly routed and handled in the streaming pipeline

3. Output Page Integration

  • File: tui2/pages/output/output.go
  • Changes:
    • Added partialBlockIndices map[common.BlockContext]uint32 field to track partial block indices
    • Added *pbsubstreamsrpc.PartialBlockData case handler in Update() method
    • Implemented block bound tracking, module management, and payload storage for partial blocks
  • Impact: Partial blocks are processed identically to regular blocks with additional index tracking

4. Visual Display Enhancement

  • File: tui2/pages/output/render.go
  • Changes:
    • Enhanced renderPayload() function to display partial block headers
    • Added conditional rendering: "----------- PARTIAL BLOCK #<num> (idx=<index>) (<id>) ---------------"
    • Added humanize import for formatted block number display
  • Impact: Users can clearly distinguish partial blocks from final blocks in the output

Technical Implementation

Data Flow

  1. Stream receives *pbsubstreamsrpc.Response_PartialBlockData from gRPC
  2. Router extracts PartialBlockData and returns it as a tea.Msg
  3. Stream's Update method handles the message and continues reading
  4. Output page processes PartialBlockData identically to BlockScopedData
  5. Partial index is stored separately for rendering identification
  6. Render cycle displays blocks with partial identification when applicable

Storage Strategy

  • Unified Payload Storage: Both BlockScopedData and PartialBlockData use the same payloads map with common.BlockContext keys
  • Separate Index Tracking: partialBlockIndices map tracks which blocks are partial and their iteration index
  • Visual Differentiation: Conditional header rendering based on partial block index presence

Usage

Users can now run:

# Include both final and partial blocks
substreams gui --include-partial-blocks <package> <module>

# Show only partial blocks  
substreams gui --partial-blocks-only <package> <module>

Partial blocks will be clearly identified in the output with headers like:

----------- PARTIAL BLOCK #1,234,567 (idx=2) (0xabc123...) ---------------

Testing

The implementation follows established patterns in the codebase:

  • PartialBlockData handling mirrors BlockScopedData handling exactly
  • Uses existing data structures and styling conventions
  • Maintains consistency with the original TUI partial block display format

Fixes BLO-795


💻 View my work • 👤 Initiated by Matthieu VachonAbout Codegen
⛔ Remove Codegen from PR🚫 Ban action checks

@codegen-sh
Copy link
Contributor Author

codegen-sh bot commented Dec 21, 2025

🔍 Broken test auto-fixer • Learn more

Check Suite Agent Status Commit Time
GitHub Actions Agent Fix ✅ d94ef13 Dec 21, 16:13:27 UTC
GitHub Actions Agent Fix ✅ 3427aec Dec 21, 17:21:58 UTC
GitHub Actions Agent Fix ✅ 49fc574 Jan 09, 19:46:27 UTC

💻 View my work🛑 Stop🚫 Ban all checks

⚙️ Check suite settings

@codegen-sh
Copy link
Contributor Author

codegen-sh bot commented Dec 21, 2025

Fixed failing check suite on PR #728

I've successfully resolved the compilation errors that were causing the "Build and Test" workflow to fail. The issues were in the tui2/pages/output/output.go file:

🔧 Problems Fixed:

  1. Method call errors: The code was trying to call IsEmpty() and Name() methods directly on *MapModuleOutput, but these methods are only available on *AnyModuleOutput

  2. Type assignment error: The code was trying to assign *MapModuleOutput to a field expecting *AnyModuleOutput

🛠️ Solution Applied:

  • Converted MapModuleOutput to AnyModuleOutput using the ToAny() method before calling IsEmpty() and Name()
  • Fixed the assignment to use the converted anyOutput instead of the raw msg.Output
  • Maintained the same logic flow while ensuring type compatibility

Verification:

  • ✅ Code compiles successfully: go build ./tui2/pages/output
  • ✅ Main substreams command builds: go build ./cmd/substreams
  • ✅ Changes pushed to PR branch: commit 05a3c51

The fix maintains the original functionality for partial blocks support in the GUI while resolving the compilation errors. The GitHub Actions workflow should now pass successfully! 🎉

💻 View my work🛑 Stop🚫 Ban all checks • React 👍 or 👎

Copy link
Contributor

@maoueh maoueh left a comment

Choose a reason for hiding this comment

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

Refactor your approach to partial block handling as there will exist multiple partial block on the same block number. See comment in the review to understand why it can be a problem.

Let's plan your work in such way that we minimize changes to existing structure unless strictly necessary.

I'll review and plan changes for the partial block handling issue... 🔍

💻 View my work🛑 Stop


blocksPerModule map[string][]uint64
payloads map[common.BlockContext]*pbsubstreamsrpc.AnyModuleOutput
partialBlockIndices map[common.BlockContext]uint32 // tracks partial block indices
Copy link
Contributor

Choose a reason for hiding this comment

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

Multiple partial blocks will map to the same block number, this mapping is not going to work properly.

@codegen-sh codegen-sh bot force-pushed the blo-795-support-partials-blocks-in-substreams-gui branch from 05a3c51 to 3427aec Compare December 21, 2025 17:12
@codegen-sh
Copy link
Contributor Author

codegen-sh bot commented Dec 21, 2025

Fixed the failing check suite on PR #728!

Issue Identified

The build was failing due to compilation errors in tui2/pages/output/output.go related to the partial blocks GUI support:

  1. Type mismatch: Code was trying to call IsEmpty() and Name() methods directly on *MapModuleOutput, but these methods only exist on *AnyModuleOutput
  2. Assignment error: Attempting to assign *MapModuleOutput to a field expecting *AnyModuleOutput

Fix Applied

  • Converted MapModuleOutput to AnyModuleOutput using the existing ToAny() method
  • Fixed method calls by calling anyOutput.IsEmpty() and anyOutput.Name() on the converted type
  • Ensured type compatibility for the partialPayloads storage

Changes Made

  • Modified the partial block handling logic in tui2/pages/output/output.go (lines 266-302)
  • The fix maintains all existing functionality while resolving the compilation errors
  • No breaking changes to the partial blocks feature implementation

The fix has been pushed to the PR branch and should resolve the failing "Build and Test" workflow. The partial blocks GUI support should now compile and work correctly! 🎉

Commit: 568c27f

💻 View my work🛑 Stop🚫 Ban all checks • React 👍 or 👎

@maoueh maoueh closed this Dec 26, 2025
@maoueh maoueh deleted the blo-795-support-partials-blocks-in-substreams-gui branch December 26, 2025 19:32
@maoueh maoueh restored the blo-795-support-partials-blocks-in-substreams-gui branch January 5, 2026 19:00
@maoueh maoueh deleted the blo-795-support-partials-blocks-in-substreams-gui branch January 5, 2026 19:00
@maoueh maoueh restored the blo-795-support-partials-blocks-in-substreams-gui branch January 5, 2026 19:03
@maoueh maoueh reopened this Jan 5, 2026
codegen-sh bot and others added 3 commits January 9, 2026 19:35
- Add partial block flags to GUI command initialization
- Update stream message router to handle PartialBlockData
- Add partial block handling to stream Update method
- Implement partial block display in output page with PartialBlockData Update handler
- Add partial block data storage and state management infrastructure
- Update output rendering to display partial blocks with proper identification

This implementation mirrors the existing partial blocks support in 'substreams run'
command, allowing users to view partial blockchain blocks in the GUI interface
with clear visual identification.
…ck number

- Replace partialBlockIndices map with partialPayloads map using composite keys
- Use 'module:blocknum:partialindex' format to uniquely identify each partial block
- Update rendering logic to properly detect and display partial blocks
- Add displayContext to track partial block state during rendering
- Fix data structure issue where multiple partial blocks would overwrite each other

This resolves the issue where BlockContext could not distinguish between
different partial blocks for the same block number.
- Replace deprecated FlagIncludePartialBlocks and FlagPartialBlocksOnly
  with the new FlagPartialBlocks flag to align with v1.17.9 changes
- This matches the implementation used in the run command
- The GUI already handles partial blocks correctly via BlockScopedData
  messages which now contain the IsPartial, PartialIndex, and
  IsLastPartial fields

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codegen-sh codegen-sh bot force-pushed the blo-795-support-partials-blocks-in-substreams-gui branch from 7f8a16a to 49fc574 Compare January 9, 2026 19:38
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