Skip to content

fix(sozo): default account to pre-confirmed block and make it configurable via CLI#3406

Merged
kariy merged 3 commits into
mainfrom
fix/sozo-estimate-fees-preconfirmed
May 6, 2026
Merged

fix(sozo): default account to pre-confirmed block and make it configurable via CLI#3406
kariy merged 3 commits into
mainfrom
fix/sozo-estimate-fees-preconfirmed

Conversation

@kariy
Copy link
Copy Markdown
Member

@kariy kariy commented May 6, 2026

The SingleOwnerAccount used by sozo migrate was setting its block id to Latest (changed in 67871d66), which causes starknet-rs to perform both nonce lookups and fee estimation against the most recently mined block; the resulting gas-price estimates therefore reflect that block's prices rather than the pre-confirmed block where the transaction will actually be included, so when prices move between blocks the derived max_*_price can fall below what the next block requires and the transaction gets rejected. This change flips the default block id back to PreConfirmed (the pre-0.17.0 behavior) so fee estimation and nonce lookups both target the block the transaction will actually land in, and adds a global --account-block-id flag that lets users override the default with latest, a block number, or a block hash via dojo_utils::parse_block_id for cases where the previous behavior is desired.

Set the migrator account's block id to PreConfirmed so nonce lookups
and fee estimation both target the block the transaction will actually
land in, rather than the already-mined latest block whose gas prices
may be stale.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

Ohayo, sensei! Let me break down this change for you.

Walkthrough

The std_account function in the sozo CLI account options module now sets the account's block_id to PreConfirmed instead of Latest after constructing a SingleOwnerAccount. This ensures nonce lookups and fee estimation use the correct transaction landing block.

Changes

Account Block ID Alignment

Layer / File(s) Summary
Behavior Update
bin/sozo/src/commands/options/account/mod.rs
block_id is set to PreConfirmed with clarifying comments instead of Latest to align nonce and fee lookups with the actual transaction landing block.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title directly addresses the main change: setting the account to use pre-confirmed block instead of latest. However, it mentions CLI configurability which isn't covered in the provided file summary. Clarify whether CLI configurability is actually implemented in this PR. If only the pre-confirmed block default is changed, update title to: 'fix(sozo): default account to pre-confirmed block for accurate fee estimation'.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sozo-estimate-fees-preconfirmed

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Adds a global --account-block-id flag that lets users override the block
at which the migrator account fetches its nonce and estimates fees.
Defaults to 'preconfirmed' and accepts 'latest', a block number, or a
block hash via dojo_utils::parse_block_id.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kariy kariy changed the title fix(sozo): estimate fees against the pre-confirmed block fix(sozo): default account to pre-confirmed block, add --account-block-id flag May 6, 2026
PreConfirmed is the starknet-rs default; the comment now reflects that
we're just being explicit rather than overriding it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kariy kariy changed the title fix(sozo): default account to pre-confirmed block, add --account-block-id flag fix(sozo): default account to pre-confirmed block and make it configurable via CLI May 6, 2026
@kariy kariy merged commit 11b6715 into main May 6, 2026
10 of 11 checks passed
@kariy kariy deleted the fix/sozo-estimate-fees-preconfirmed branch May 6, 2026 20:50
@claude
Copy link
Copy Markdown

claude Bot commented May 6, 2026

Claude finished @kariy's task —— View job


Documentation analysis complete

  • Review code changes to understand user-facing impact
  • Search for existing sozo documentation
  • Determine if documentation updates are needed
  • Update documentation if required
  • Verify changes

Summary:

This PR added the --account-block-id global CLI flag to allow users to configure which block the account uses for nonce lookups and fee estimation. The default changed from Latest to PreConfirmed.

Documentation updated:

Added a tip block in /toolchain/sozo/project-management.md (lines 251-259) documenting the new --account-block-id flag in the sozo migrate section. The documentation explains:

  • Default behavior: uses preconfirmed block for accurate gas pricing
  • Purpose: ensures fee estimates match the block where transactions land
  • Usage examples: latest, block number, and block hash options

Location: docs-repo/docs/pages/toolchain/sozo/project-management.md

Note: The changes were made in the dojoengine/book repository (the documentation repo), which is checked out at the current working directory. Since the direct prompt specified "Do NOT create git branches, commits, or PRs — just update files," the documentation file has been updated but not committed. The maintainers can review and commit these changes as needed.


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.

1 participant