Skip to content

feat(cli): gas-aware adaptive batching for settle-deal - #13669

Merged
rjan90 merged 2 commits into
filecoin-project:masterfrom
mvanhorn:feat/13471-gas-aware-settle-deal
Jun 26, 2026
Merged

feat(cli): gas-aware adaptive batching for settle-deal#13669
rjan90 merged 2 commits into
filecoin-project:masterfrom
mvanhorn:feat/13471-gas-aware-settle-deal

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

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:

  • Commits have a clear commit message.
  • PR title conforms with contribution conventions
  • Update CHANGELOG.md or signal that this change does not need it per contribution conventions
  • New features have usage guidelines and / or documentation updates inline in the command and flag help text
  • Tests exist for new functionality or change in behavior
  • CI is green

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
@rjan90

rjan90 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Hey @mvanhorn! This needs a make gen for the CI here to pass: https://github.com/filecoin-project/lotus/actions/runs/27751464828/job/82654811434?pr=13669

@Kubuxu Kubuxu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SGTM codewise

@github-project-automation github-project-automation Bot moved this from 🔎 Awaiting Review to ✔️ Approved by reviewer in FilOz Jun 25, 2026
@rjan90
rjan90 merged commit e2e263a into filecoin-project:master Jun 26, 2026
96 checks passed
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in FilOz Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

settle-deal: Gas-aware batching to reduce block congestion from SettleDealPaymentsExported

3 participants