Skip to content

test: add comprehensive MultiSigSigner tests (ithacaxyz#382)#36

Merged
Dargon789 merged 5 commits into
Dargon789:legionfrom
ithacaxyz:main
Mar 14, 2026
Merged

test: add comprehensive MultiSigSigner tests (ithacaxyz#382)#36
Dargon789 merged 5 commits into
Dargon789:legionfrom
ithacaxyz:main

Conversation

@Dargon789

Copy link
Copy Markdown
Owner

No description provided.

legion2002 and others added 5 commits September 25, 2025 18:14
* chore: add test script without upgrade tests, because they are slow

* chore: remove husky because running tests before every commit is slow, sometimes you want to merge commits without contracts building, and forge fmt doesn't work because the files are not added to staging

* chore: add Benchmark updates to CI

* fix: CI

* chore: update package.json

* fix: ci

* chore: update gas snapshots

* chore: add formatting to CI

* chore: use standardized commit logic in version bump CI
* feat: add multicall to simulator

* chore: add gas test

* chore: review fixes

* chore: fmt contracts and update gas snapshots

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @Dargon789, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@snyk-io

snyk-io Bot commented Mar 14, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the project's testing infrastructure and introduces advanced simulation features. It includes a new, extensive test suite for the MultiSigSigner contract, ensuring its core functionalities are thoroughly validated. Furthermore, it integrates Multicall3 into the Simulator contract, providing more sophisticated tools for gas estimation and intent execution analysis, which is crucial for optimizing transaction costs and improving user operation reliability. A new set of upgrade tests has also been added to verify seamless contract upgrades and state preservation. These changes collectively aim to improve the robustness, maintainability, and development experience of the project.

Highlights

  • Comprehensive MultiSigSigner Tests: Introduced an extensive test suite for the MultiSigSigner contract, covering initialization, owner management, threshold validation, and various signature verification scenarios, including fuzz tests.
  • Advanced Simulation Features: Integrated Multicall3 into the Simulator contract, adding new functions for more robust gas estimation and intent execution analysis, including iterative combined gas simulation and V1 log simulation.
  • Contract Upgrade Testing: Implemented a dedicated UpgradeTests suite to ensure seamless contract upgrades, verifying state preservation (keys, balances, nonces) and post-upgrade functionality across different key types and spending limits.
  • Configuration and Dependency Refactoring: Updated .env.example with new configuration variables for upgrade tests and deployment, while streamlining existing entries. Project dependencies and scripts were also refactored, removing husky and gas snapshot generation.
Changelog
  • .env.example
    • Removed default PRIVATE_KEY value.
    • Removed RPC_42161, RPC_8453, and local development RPC entries.
    • Removed VERIFICATION_KEY_* entries.
    • Added UPGRADE_TEST_RPC_URL, UPGRADE_TEST_OLD_PROXY, and UPGRADE_TEST_OLD_VERSION for upgrade testing.
    • Added GAS_SIGNER_MNEMONIC for funding scripts.
  • .husky/pre-commit
    • Removed the pre-commit hook script.
  • gas-snapshots/.gas-snapshot-main
    • Removed the gas snapshot file.
  • package-lock.json
    • Updated project version from 0.5.5 to 0.5.7.
    • Removed husky dependency and its related node_modules entry.
  • package.json
    • Updated project version from 0.5.5 to 0.5.7.
    • Removed snapshot:main, diff:main, and prepare scripts.
    • Removed husky from devDependencies.
    • Added tests script for forge test --no-match-contract UpgradeTests.
  • snapshots/BenchmarkTest.json
    • Updated gas values for various IthacaAccount and batch100_IthacaAccount test cases.
  • src/Escrow.sol
    • Adjusted line breaks for readability in SettlementInvalid error and isSettled assignment.
  • src/GuardedExecutor.sol
    • Added curly braces to if statements for UnauthorizedCall and SpendPeriod calculations.
    • Adjusted line breaks for readability in _getGuardedExecutorKeyStorage and canExecutePackedInfos function signature.
  • src/IthacaAccount.sol
    • Adjusted line breaks for readability in isValidSignature and getKeys function signatures.
    • Adjusted line breaks for readability in $.keyStorage[keyHash].set and LibBit.and conditions.
  • src/LayerZeroSettler.sol
    • Adjusted line breaks for readability in _getPeerOrRevert and _lzReceive function signatures.
  • src/Orchestrator.sol
    • Adjusted line breaks for readability in the call instruction within selfCallSuccess assignment.
  • src/SimpleFunder.sol
    • Adjusted line breaks for readability in the fund function signature.
  • src/Simulator.sol
    • Imported IMulticall3 interface.
    • Added _callMulticall3 internal function to perform calls to Multicall3 and parse gas usage.
    • Added _bubbleUpMulticall3Error internal function to bubble up errors from Multicall3 results.
    • Added simulateMulticall3CombinedGas public function for iterative combined gas simulation.
    • Added simulateMulticall3V1Logs public function for V1 log simulation with verification runs.
  • src/interfaces/IFunder.sol
    • Adjusted line breaks for readability in the fund function signature.
  • src/interfaces/IMulticall3.sol
    • Added new interface for Multicall3 contract, including Call, Call3, Call3Value, and Result structs, and aggregate and aggregate3 functions.
  • src/interfaces/IOrchestrator.sol
    • Removed an empty line in the execute function documentation.
  • src/libraries/LibNonce.sol
    • Adjusted line breaks for readability in the invalidate function signature.
  • src/vendor/layerzero/interfaces/IOAppCore.sol
    • Adjusted import statement formatting for ILayerZeroEndpointV2.
  • src/vendor/layerzero/mocks/EndpointV2Mock.sol
    • Adjusted import statement formatting for ISendLib, Packet, and ILayerZeroReceiver.
    • Added curly braces to if statements for LZ_LzTokenUnavailable and LZ_PathNotInitializable reverts.
    • Adjusted line breaks for readability in ILayerZeroReceiver(_receiver).lzReceive and _oapp delegate checks.
  • src/vendor/layerzero/oapp/OAppReceiver.sol
    • Adjusted line breaks for readability in _isValidMessage and nextNonce function signatures.
  • src/vendor/layerzero/oapp/OAppSender.sol
    • Adjusted line breaks for readability in the endpoint.send call.
  • test/Account.t.sol
    • Added testContextKeyHash function to test context key hash functionality.
  • test/Base.t.sol
    • Added contextKeyHash state variable.
    • Added targetFunctionContextKeyHash function to set contextKeyHash.
  • test/Benchmark.t.sol
    • Adjusted formatting for _ALCHEMY_MODULAR_ACCOUNT_IMPL_ADDR constant.
    • Removed an empty line in PaymentMode enum.
    • Adjusted line breaks for readability in IStakeManager.depositTo and stdstore.target calls.
    • Adjusted line breaks for readability in IKernelFactory.createAccount call.
    • Adjusted line breaks for readability in d.d.setCanExecute and d.d.setSpendLimit calls.
  • test/GuardedExecutor.t.sol
    • Adjusted line breaks for readability in d.d.setSpendLimit calls.
    • Adjusted line breaks for readability in if condition for anotherTransfer call.
    • Adjusted line breaks for readability in _testSpendWithPassKeyViaOrchestrator function signature.
  • test/LayerZeroSettler.t.sol
    • Adjusted line breaks for readability in testFuzz_send_differentSettlementIds and settlerA.executeSend calls.
  • test/MultiSigSigner.t.sol
    • Added new test contract MultiSigSignerTest with comprehensive tests for MultiSigSigner contract.
    • Tests cover duplicate owner signatures, initConfig, addOwner, removeOwner, setThreshold, and signature validation under various conditions.
    • Includes fuzz tests for initConfig and SignatureValidation.
  • test/Orchestrator.t.sol
    • Adjusted line breaks for readability in abi.encodeWithSignature call for approve.
  • test/SimpleFunder.t.sol
    • Adjusted line breaks for readability in keccak256(abi.encode(...)) call.
  • test/SimulateExecute.t.sol
    • Imported IMulticall3 interface.
    • Added multicall3 mock contract.
    • Added gMulticall3 and preCalls to _SimulateExecuteTemps struct.
    • Added testSimulateMulticall3V1Logs, testSimulateMulticall3NoRevertUnderfundedReverts, testSimulateMulticall3WithEOAKey, testSimulateMulticall3WithPassKey, testSimulateMulticall3EmptyPreCalls, testSimulateMulticall3MultiplePreCalls, and testSimulateVsActualGas functions to test new Simulator functionalities.
    • Added MockMulticall3 contract for testing purposes.
  • test/UpgradeTests.t.sol
    • Added new test contract UpgradeTests for comprehensive contract upgrade testing.
    • Tests cover state preservation (keys, balances, nonces), post-upgrade functionality (P256 super admins, new key authorization, spend limits), and complex spending state preservation.
    • Uses environment variables for UPGRADE_TEST_RPC_URL, UPGRADE_TEST_OLD_PROXY, and UPGRADE_TEST_OLD_VERSION.
  • test/utils/TestPlus.sol
    • Adjusted line breaks for readability in _truncateBytes function signature.
  • test/utils/interfaces/ISafe.sol
    • Adjusted line breaks for readability in executeUserOp function signature.
  • test/utils/mocks/MockAccount.sol
    • Imported LibTStack.
    • Added setContextKeyHash function using LibTStack.
  • test/utils/mocks/MockCallChecker.sol
    • Adjusted line breaks for readability in the check function return condition.
  • test/utils/mocks/MockERC4337Account.sol
    • Adjusted line breaks for readability in _domainNameAndVersion function signature.
  • test/utils/mocks/SendLibMock.sol
    • Adjusted import statement formatting for various LayerZero interfaces.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/ci.yaml
    • .github/workflows/version-check.yaml
Activity
  • No human activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a significant number of tests, including comprehensive tests for MultiSigSigner, upgrade scenarios, and multicall simulations, which greatly enhances the project's test coverage and robustness. Additionally, it includes numerous formatting improvements across the codebase for better readability. My review identified a bug in Simulator.sol where gas consumption was being misreported in a specific failure scenario.

Comment thread src/Simulator.sol
for (uint256 i = 0; i < results.length - 1; i++) {
// If any call failed, we return gasUsed = 0, multicall3Gas, and the error data from that call
if (!results[i].success) {
return (0, 0, results[i].returnData);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

In the case of a pre-call failure within _callMulticall3, the function returns 0 for multicall3Gas. However, multicall3Gas has already been calculated and represents the gas spent on the aggregate3 call itself. Returning 0 is misleading and loses important gas accounting information. The function should return the actual multicall3Gas value even when a pre-call fails. The comment on line 180 also suggests that multicall3Gas should be returned.

                    return (0, multicall3Gas, results[i].returnData);

@Dargon789

Copy link
Copy Markdown
Owner Author

@Mergifyio refresh

@mergify

mergify Bot commented Mar 14, 2026

Copy link
Copy Markdown

refresh

✅ Pull request refreshed

@Dargon789 Dargon789 merged commit 767e973 into Dargon789:legion Mar 14, 2026
18 of 21 checks passed
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.

Sequence diagram for merkle-based signature verification in IthacaAccount Sequence diagram for wrapped and Merkle signature validation

4 participants