Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invariant tests #68

Open
spengrah opened this issue Oct 25, 2024 · 1 comment
Open

invariant tests #68

spengrah opened this issue Oct 25, 2024 · 1 comment

Comments

@spengrah
Copy link
Member

spengrah commented Oct 25, 2024

Running list of HSG invariants:

  • the safe threshold should always be equal to lesser of the correct threshold and the current number of safe owners
  • HSG should always be the guard of the safe (except when removing itself)
  • HSG should always be enabled as a module of the safe (except when removing itself)
  • There should never be more than 1 module enabled on the safe
  • No multisig transactions can be executed when the number of static signers is less than the min threshold
  • No multisig transactions can be executed when the number of static signers is less than the "enforced threshold"
  • No multisig transactions can be executed when the number of valid signers is less than the "enforced threshold"
  • Modules should never be able to change any values in Safe storage
  • The safe can never change its own number of static signers
  • The safe can never change its own threshold

Notes:

  • the "enforced threshold" is the min number of valid signers that approve a transaction. It can differ from the safe threshold when one or more of the static signers are not valid.
@spengrah spengrah added this to HSG v2 Oct 17, 2024
@spengrah spengrah converted this from a draft issue Oct 25, 2024
@spengrah
Copy link
Member Author

Useful foundry tool for verifying that no state has been changed for a given contract

function testNoStorageChanges() public {
    // Start recording storage accesses
    vm.record();

    // Perform the operation you're testing
    contract.someFunction();

    // Get the storage accesses
    (bytes32[] memory reads, bytes32[] memory writes) = vm.accesses(address(contract));

    // Assert that no storage writes occurred
    assertEq(writes.length, 0, "Storage was modified unexpectedly");
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

1 participant