Skip to content

fix(utils/invoker): add split for big multicalls - #3284

Merged
glihm merged 2 commits into
mainfrom
fix/multicall-split
Jul 21, 2025
Merged

fix(utils/invoker): add split for big multicalls#3284
glihm merged 2 commits into
mainfrom
fix/multicall-split

Conversation

@glihm

@glihm glihm commented Jul 18, 2025

Copy link
Copy Markdown
Contributor

This PR adds a split to multicalls to ensure the user can control the maximum number of calls in a multi call.

Due to reduction of the network resources for a single transaction, when too much models are registered in the same transaction, this latter can fail.

By adding a max_calls parameter, the user can adjust the number of calls in a multi call to avoid such issue.

By default, there is no limit if the max_calls is not supplied, and Sozo will attempt to send only one transaction per migration step.

Summary by CodeRabbit

  • New Features

    • Added support for limiting the maximum number of calls in a single transaction via a new option.
    • Users can now specify the maximum number of calls per transaction through configuration and command-line arguments.
  • Bug Fixes

    • Improved handling and display of multiple transaction results, ensuring each result is shown individually.
  • Documentation

    • Updated configuration examples with new seed values and keystore paths.
    • Refreshed manifest files with updated contract addresses and seed values.

@coderabbitai

coderabbitai Bot commented Jul 18, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Ohayo sensei! This update introduces support for splitting multicall transactions into multiple chunks based on a new max_calls parameter. The transaction handling logic across several commands is updated to process and print multiple transaction results. The configuration and manifest files are also updated with new addresses, seeds, and keystore paths.

Changes

Files/Paths Change Summary
bin/sozo/src/commands/auth.rs, bin/sozo/src/commands/execute.rs, crates/sozo/ops/src/migrate/mod.rs Updated to handle and print multiple transaction results from invoker.multicall().await? instead of one.
bin/sozo/src/commands/options/transaction.rs, crates/dojo/utils/src/tx/mod.rs Added max_calls field to transaction options/configs and integrated it into transaction actions and config.
crates/dojo/utils/src/tx/invoker.rs Refactored multicall to split calls into chunks by max_calls, returning a vector of transaction results.
examples/simple/dojo_sepolia.toml, examples/simple/manifest_sepolia.json Updated seed, keystore path, and contract addresses in configuration and manifest files.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI_Command
    participant Invoker
    participant Blockchain

    User->>CLI_Command: Run command with multicall
    CLI_Command->>Invoker: multicall(max_calls)
    Invoker->>Invoker: Split calls into chunks (if max_calls)
    loop For each chunk
        Invoker->>Blockchain: Send transaction
        Blockchain-->>Invoker: TransactionResult
    end
    Invoker-->>CLI_Command: Vec<TransactionResult>
    CLI_Command->>CLI_Command: Iterate and print each TransactionResult
Loading

Possibly related PRs

Suggested labels

contributor

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/multicall-split

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
examples/simple/dojo_sepolia.toml (1)

10-10: Avoid hard-coding a user-specific keystore path

Committing ~/.snaccounts/dev-sepolia.key may break other environments. Consider reading the path from an env-var, e.g.:

-keystore_path = "~/.snaccounts/dev-sepolia.key"
+keystore_path = "${SNACCOUNT_KEYSTORE:-~/.snaccounts/dev-sepolia.key}"

Keeps defaults while remaining portable.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8964db9 and 904d800.

📒 Files selected for processing (8)
  • bin/sozo/src/commands/auth.rs (3 hunks)
  • bin/sozo/src/commands/execute.rs (1 hunks)
  • bin/sozo/src/commands/options/transaction.rs (4 hunks)
  • crates/dojo/utils/src/tx/invoker.rs (1 hunks)
  • crates/dojo/utils/src/tx/mod.rs (1 hunks)
  • crates/sozo/ops/src/migrate/mod.rs (1 hunks)
  • examples/simple/dojo_sepolia.toml (1 hunks)
  • examples/simple/manifest_sepolia.json (4 hunks)
🧰 Additional context used
🧠 Learnings (6)
bin/sozo/src/commands/auth.rs (2)
Learnt from: glihm
PR: dojoengine/dojo#2650
File: bin/sozo/src/commands/migrate.rs:64-65
Timestamp: 2024-11-07T13:57:57.616Z
Learning: In the codebase, the use of `into()` and `try_into()` for converting `TransactionOptions` is intentional. Conversions that may fail use `try_into()`, while those that cannot fail use `into()`. This approach is appropriate and should be preserved.

Examples:
- `try_into()` is used in `bin/sozo/src/commands/migrate.rs` and `bin/sozo/src/commands/execute.rs` where conversions can fail.
- `into()` is used in `bin/sozo/src/commands/register.rs` and `bin/sozo/src/commands/auth.rs` where conversions are infallible.
Learnt from: glihm
PR: dojoengine/dojo#2650
File: crates/dojo/utils/src/tx/mod.rs:201-272
Timestamp: 2024-11-07T14:43:23.530Z
Learning: In `crates/dojo/utils/src/tx/mod.rs`, fee token configurations are verified when the `fee_config` is built, making additional validations in the `send_with_cfg` methods redundant.
bin/sozo/src/commands/execute.rs (1)
Learnt from: glihm
PR: dojoengine/dojo#2650
File: bin/sozo/src/commands/migrate.rs:64-65
Timestamp: 2024-11-07T13:57:57.616Z
Learning: In the codebase, the use of `into()` and `try_into()` for converting `TransactionOptions` is intentional. Conversions that may fail use `try_into()`, while those that cannot fail use `into()`. This approach is appropriate and should be preserved.

Examples:
- `try_into()` is used in `bin/sozo/src/commands/migrate.rs` and `bin/sozo/src/commands/execute.rs` where conversions can fail.
- `into()` is used in `bin/sozo/src/commands/register.rs` and `bin/sozo/src/commands/auth.rs` where conversions are infallible.
crates/dojo/utils/src/tx/mod.rs (2)
Learnt from: glihm
PR: dojoengine/dojo#2650
File: crates/dojo/utils/src/tx/mod.rs:201-272
Timestamp: 2024-11-07T14:43:23.530Z
Learning: In `crates/dojo/utils/src/tx/mod.rs`, fee token configurations are verified when the `fee_config` is built, making additional validations in the `send_with_cfg` methods redundant.
Learnt from: glihm
PR: dojoengine/dojo#2650
File: crates/dojo/utils/src/tx/mod.rs:0-0
Timestamp: 2024-11-07T13:57:19.152Z
Learning: In the `send_with_cfg` method for `ExecutionV1` in `crates/dojo/utils/src/tx/mod.rs`, `FeeConfig::Strk` parameters are intentionally ignored for V1 execution, and this is expected behavior.
crates/sozo/ops/src/migrate/mod.rs (2)
Learnt from: glihm
PR: dojoengine/dojo#2650
File: bin/sozo/src/commands/migrate.rs:64-65
Timestamp: 2024-11-07T13:57:57.616Z
Learning: In the codebase, the use of `into()` and `try_into()` for converting `TransactionOptions` is intentional. Conversions that may fail use `try_into()`, while those that cannot fail use `into()`. This approach is appropriate and should be preserved.

Examples:
- `try_into()` is used in `bin/sozo/src/commands/migrate.rs` and `bin/sozo/src/commands/execute.rs` where conversions can fail.
- `into()` is used in `bin/sozo/src/commands/register.rs` and `bin/sozo/src/commands/auth.rs` where conversions are infallible.
Learnt from: glihm
PR: dojoengine/dojo#2650
File: crates/dojo/utils/src/tx/mod.rs:201-272
Timestamp: 2024-11-07T14:43:23.530Z
Learning: In `crates/dojo/utils/src/tx/mod.rs`, fee token configurations are verified when the `fee_config` is built, making additional validations in the `send_with_cfg` methods redundant.
crates/dojo/utils/src/tx/invoker.rs (1)
Learnt from: glihm
PR: dojoengine/dojo#2650
File: crates/dojo/utils/src/tx/mod.rs:201-272
Timestamp: 2024-11-07T14:43:23.530Z
Learning: In `crates/dojo/utils/src/tx/mod.rs`, fee token configurations are verified when the `fee_config` is built, making additional validations in the `send_with_cfg` methods redundant.
bin/sozo/src/commands/options/transaction.rs (3)
Learnt from: glihm
PR: dojoengine/dojo#2650
File: bin/sozo/src/commands/migrate.rs:64-65
Timestamp: 2024-11-07T13:57:57.616Z
Learning: In the codebase, the use of `into()` and `try_into()` for converting `TransactionOptions` is intentional. Conversions that may fail use `try_into()`, while those that cannot fail use `into()`. This approach is appropriate and should be preserved.

Examples:
- `try_into()` is used in `bin/sozo/src/commands/migrate.rs` and `bin/sozo/src/commands/execute.rs` where conversions can fail.
- `into()` is used in `bin/sozo/src/commands/register.rs` and `bin/sozo/src/commands/auth.rs` where conversions are infallible.
Learnt from: glihm
PR: dojoengine/dojo#2650
File: crates/dojo/utils/src/tx/mod.rs:201-272
Timestamp: 2024-11-07T14:43:23.530Z
Learning: In `crates/dojo/utils/src/tx/mod.rs`, fee token configurations are verified when the `fee_config` is built, making additional validations in the `send_with_cfg` methods redundant.
Learnt from: glihm
PR: dojoengine/dojo#2650
File: crates/dojo/utils/src/tx/mod.rs:0-0
Timestamp: 2024-11-07T13:57:19.152Z
Learning: In the `send_with_cfg` method for `ExecutionV1` in `crates/dojo/utils/src/tx/mod.rs`, `FeeConfig::Strk` parameters are intentionally ignored for V1 execution, and this is expected behavior.
🔇 Additional comments (20)
bin/sozo/src/commands/auth.rs (3)

377-380: LGTM! Consistent multicall result handling.

Ohayo sensei! The update correctly handles the new Vec<TransactionResult> return type from multicall by iterating over each result for printing. This approach aligns with the multicall splitting functionality.


597-600: LGTM! Consistent pattern maintained.

The same clean pattern is used here for handling multiple transaction results from the owners permission updates.


641-644: LGTM! Pattern consistency confirmed.

All three multicall usage points in this file follow the same correct pattern for handling multiple transaction results.

bin/sozo/src/commands/execute.rs (2)

169-172: LGTM! Proper multicall result handling.

Ohayo sensei! The execute command correctly handles the new multicall behavior by iterating over multiple transaction results for display.


176-178: LGTM! Walnut debugger integration updated correctly.

The debugger integration properly handles multiple transaction results by iterating through each one individually, maintaining the debugging capability for split transactions.

crates/dojo/utils/src/tx/mod.rs (2)

43-46: LGTM! Well-documented configuration addition.

Ohayo sensei! The max_calls field is properly added with clear documentation explaining its purpose for preventing migration issues with too many resources. The optional type maintains backward compatibility.


51-57: LGTM! Consistent TxnAction update.

The TxnAction::Send variant correctly includes the new max_calls parameter, maintaining consistency with the TxnConfig structure.

crates/sozo/ops/src/migrate/mod.rs (1)

572-591: LGTM! Proper handling of multicall splitting with thoughtful comments.

Ohayo sensei! The implementation correctly adapts to handle multiple transaction results from the split multicall functionality. Taking the block number from the first transaction is a reasonable approach since the transactions should be in the same or consecutive blocks. The TODO comment shows good awareness of potential edge cases with transaction receipts.

crates/dojo/utils/src/tx/invoker.rs (3)

78-87: LGTM! Clear method documentation and proper empty case handling.

Ohayo sensei! The updated method signature and documentation clearly explain the new multicall splitting behavior. The empty calls case correctly returns a vector with a single Noop result, maintaining consistency with the new return type.


91-131: LGTM! Robust chunking implementation with excellent tracing.

The chunking logic is well-implemented with proper error handling, comprehensive tracing for debugging, and maintains the existing wait/receipt behavior for each chunk. The approach ensures transaction reliability while providing flexibility for large multicalls.


132-155: LGTM! Backward compatibility maintained with proper fallback.

The fallback path for when max_calls is not set preserves the original multicall behavior while adapting to the new return type. This ensures existing code continues to work seamlessly.

bin/sozo/src/commands/options/transaction.rs (4)

39-43: Ohayo sensei! LGTM on the new max_calls field!

The field declaration follows the established patterns perfectly - proper Option type, clear documentation, and consistent clap attributes. The help text clearly explains the default behavior when not specified.


63-63: Proper integration into TxnAction::Send, sensei!

The max_calls field is correctly passed only to the Send variant, which makes logical sense since call limiting is only relevant when actually executing transactions, not during estimation or simulation.


78-78: Clean TryFrom implementation, sensei!

The max_calls field is properly included in the TxnConfig conversion, following the same direct mapping pattern as other fields.


97-97: Solid test coverage for the new field, sensei!

The test properly verifies that max_calls values are correctly preserved through the TransactionOptions to TxnConfig conversion, providing good confidence in the implementation.

Also applies to: 105-105

examples/simple/manifest_sepolia.json (4)

4-5: Ohayo sensei! Verify new world address & seed are propagated

The updated address and seed look fine, but please double-check that:

  1. examples/simple/dojo_sepolia.toml and any CI scripts use the same values.
  2. Down-stream tooling (deployment, tests) isn’t still pointing at the old world contract.

A quick rg search in the repo can confirm no stale references remain.


1492-1493: Contract address change recorded – consistency check recommended

Nice catch on the new ns-c1 address. Make sure any hard-coded allow-lists, docs, or front-end configs reference 0x6a2a…32d now.


1750-1751: Updated ns-c2 address – verify against class-hash

The address now ends with …060. Confirm it actually hosts the class-hash 0x1e48…02d; a mismatched deploy will brick migrations.


1926-1927: Duplicate class-hash / new address combo – just an FYI

ns2-c1 keeps the same class-hash as ns-c1, only the address moved. All good on my end.

examples/simple/dojo_sepolia.toml (1)

4-4: Seed aligned with manifest – looks good

simple-a matches the manifest; no issues spotted.

@glihm
glihm merged commit ff0b704 into main Jul 21, 2025
10 checks passed
@glihm
glihm deleted the fix/multicall-split branch July 21, 2025 14:57
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