Skip to content

fix(state): display DealIDs from market actor for sectors #13140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sumitvekariya
Copy link

@sumitvekariya sumitvekariya commented May 25, 2025

The 'lotus state sector' command was showing empty DealIDs for sectors that actually contain deals. This occurred because for actors v13+, deal IDs are stored in the market actor's ProviderSectors HAMT, not in the sector's DeprecatedDealIDs field.

This fix:

  • Adds dual DealIDs display showing both deprecated and market sources
  • Retrieves deal IDs from market actor's ProviderSectors HAMT for v13+
  • Maintains backward compatibility with older network versions
  • Provides clear labeling of data sources
  • Handles errors gracefully with informative messages

Resolves issue where sectors containing deals incorrectly showed 'DealIDs: []' instead of the actual deal IDs.

Example output after fix:

DealIDs (deprecated): []
DealIDs (market): [84864966]

Related Issues

#12791

Proposed Changes

  • Enhanced StateSectorCmd in cli/state.go: Added dual DealIDs display functionality
  • New getMarketDealIDs function: Retrieves deal IDs from market actor's ProviderSectors HAMT
  • Network version awareness: Only accesses market actor for network version 13+
  • Improved error handling: Graceful failure with informative error messages
  • Backward compatibility: Maintains support for older network versions using deprecated fields
  • Clear output labeling: Users can distinguish between deprecated and market-sourced deal IDs

Additional Info

  • Tested on live mainnet: Successfully verified with lotus state sector f08403 16357 showing actual deal ID [100951959]
  • No breaking changes: Existing functionality preserved, only enhanced
  • Production ready: Follows lotus coding standards and error handling patterns
  • Minimal code footprint: Only 72 lines added, focused implementation

Technical details:

  • Uses market.Load() to access market actor state
  • Leverages ProviderSectors() HAMT for efficient deal ID lookup
  • Proper actor ID conversion using address.IDFromAddress()
  • Comprehensive error handling for network and API failures

Checklist

Before you mark the PR ready for review, please make sure that:

The 'lotus state sector' command was showing empty DealIDs for sectors
that actually contain deals. This occurred because for actors v13+,
deal IDs are stored in the market actor's ProviderSectors HAMT, not
in the sector's DeprecatedDealIDs field.

This fix:
- Adds dual DealIDs display showing both deprecated and market sources
- Retrieves deal IDs from market actor's ProviderSectors HAMT for v13+
- Maintains backward compatibility with older network versions
- Provides clear labeling of data sources
- Handles errors gracefully with informative messages

Resolves issue where sectors containing deals incorrectly showed
'DealIDs: []' instead of the actual deal IDs.

Example output after fix:
DealIDs (deprecated): []
DealIDs (market): [84864966]
@Copilot Copilot AI review requested due to automatic review settings May 25, 2025 11:52
@github-project-automation github-project-automation bot moved this to 📌 Triage in FilOz May 25, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where the "lotus state sector" command failed to display deal IDs for sectors with deals by adding dual DealIDs display functionality. Key changes include:

  • Dual display of deal IDs from both the deprecated field and the market actor's ProviderSectors HAMT (for actors v13+).
  • New function getMarketDealIDs for retrieving deal IDs from the market actor.
  • Improved error handling and clear output labelling.

Improve code readability and maintainability by refactoring the
getMarketDealIDs function into three focused helper functions:

- getMinerActorID: Handles miner address to actor ID conversion
- loadMarketState: Manages market actor state loading
- extractSectorDealIDs: Extracts deal IDs from ProviderSectors HAMT

Each function now has a single responsibility, making the code
easier to understand, test, and maintain.
Copy link
Member

@rvagg rvagg left a comment

Choose a reason for hiding this comment

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

looks pretty good, I think this will be appreciated by some folks who have lost this direct insight

@github-project-automation github-project-automation bot moved this from 📌 Triage to ⌨️ In Progress in FilOz May 26, 2025
Copy link
Member

@rvagg rvagg left a comment

Choose a reason for hiding this comment

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

looks good to me, without having tried it out though

@github-project-automation github-project-automation bot moved this from ⌨️ In Progress to ✔️ Approved by reviewer in FilOz May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✔️ Approved by reviewer
Development

Successfully merging this pull request may close these issues.

2 participants