Skip to content

fix: fuzz test, increase fuzz runs #6

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

Merged
merged 3 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ out = "out"
libs = ["lib"]
odyssey = true

[profile.default.fuzz]
runs = 1000

[profile.ci.fuzz]
runs = 100000

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
5 changes: 1 addition & 4 deletions src/libraries/ModeDecoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ library ModeDecoder {
// Mode layout adhering to ERC-7579
// 1 byte | 1 byte | 4 bytes | 4 bytes | 22 bytes
// CALL_TYPE | EXEC_TYPE | UNUSED | MODE_SELECTOR | MODE_PAYLOAD

Copy link
Collaborator

Choose a reason for hiding this comment

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

why remove the mask?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that we want the function to revert if the EXACT mode is not specified. So the only mode we support rn is batched calls. In the old code if the call type is batched calls but the unused bytes are dirtied it would just set it to be a batched call but I think thats actually incorrect behaviour. it should have to be the exact mode

// Only need to check the first 2 bytes, and the last 4 bytes of the first 10 bytes (the CALL_TYPE, EXECUTION_TYPE, and MODE_SELECTOR)
bytes32 constant MASK_UNUSED = 0xffff00000000ffffffff00000000000000000000000000000000000000000000;
bytes32 constant BATCHED_CALL = 0x0100000000000000000000000000000000000000000000000000000000000000;

// Supported modes:
// 0x01 | 0x00 | unused | 0x00000000 | unused
// - A batched call that reverts on failure, specifying mode selector 0x00000000 means no other data is present
function isBatchedCall(bytes32 mode) internal pure returns (bool) {
return (mode & MASK_UNUSED) == BATCHED_CALL;
return mode == BATCHED_CALL;
}
}
3 changes: 2 additions & 1 deletion test/MinimalDelegation.execute.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ contract MinimalDelegationExecuteTest is TokenHandler, DelegationHandler {
}

function test_execute_fuzz_reverts(bytes32 mode) public {
vm.startPrank(address(minimalDelegation));
if (mode != BATCHED_CALL) {
vm.expectRevert(IERC7821.UnsupportedExecutionMode.selector);
minimalDelegation.execute(mode, "");
}
minimalDelegation.execute(mode, abi.encode(CallBuilder.init()));
}

function test_execute_auth_reverts() public {
Expand Down
Loading