feat(cli): gas-aware adaptive batching for settle-deal - #13669
Merged
rjan90 merged 2 commits intoJun 26, 2026
Conversation
The 'lotus-miner actor settle-deal' command batched deals into SettleDealPaymentsExported messages using only the fixed --max-deals chunk size, so a single message could consume a large fraction of block gas capacity. Estimate gas per prospective message and, when a batch would exceed a fraction of the block gas limit (tunable via the new --max-gas-fraction flag, default 1/4), recursively split it in half until each message fits, mirroring the adaptive-splitting pattern in SectorsCompactPartitionsCmd. Small batches are unchanged. A single deal whose own estimate exceeds the ceiling is still sent with a warning rather than looping. The batching/splitting logic is extracted into a pure, unit-tested helper. Refs filecoin-project#13471
Contributor
|
Hey @mvanhorn! This needs a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Refs #13471
Today the settle-deal command groups deals into settlement messages purely by count, using the fixed max-deals threshold. When a miner has many expiring deals, one of those messages can claim a large share of a block's gas, which is exactly the congestion the issue asks us to avoid. The fix makes batching aware of the gas each prospective message would actually cost, so no single settlement message hogs the block.
Proposed Changes
The command now estimates the gas of each prospective settlement message before sending it. If a batch would cost more than a configurable fraction of the block gas limit, the batch is split in half and re-estimated until every message fits comfortably under that ceiling. This mirrors the adaptive-splitting approach the miner already uses when compacting partitions, so the behavior should feel familiar to maintainers and operators alike.
Operators who want to tune how aggressively batches are split can use the new max-gas-fraction flag, which defaults to a quarter of the block gas limit. Small jobs are unaffected: when every batch already fits, the messages sent are identical to before, and the existing confirmation, dry-run, and wait-for-message behavior is untouched. Before sending, the command now reports how many messages will go out and how many deals each one carries.
Two edge cases get explicit handling. A single deal whose estimate is over the soft ceiling cannot be split any further, so it is still sent, with a warning. A single deal whose estimate genuinely exceeds the block gas limit cannot be mined at all, so rather than quietly emitting an unsendable message the command stops with a clear error naming the deal.
Additional Info
The splitting logic lives in a small pure helper so it can be unit-tested without a live node. The added tests cover the happy path where nothing splits, a batch that splits recursively without dropping or duplicating any deal, a single deal that stays over the ceiling without looping forever, and the estimator-error path. A changelog entry is included under New Features in the unreleased section.
Checklist
Before you mark the PR ready for review, please make sure that: