Skip to content

Commit

Permalink
fix: disable ToB properties we are not using and guide the fuzzer a b…
Browse files Browse the repository at this point in the history
…it more
  • Loading branch information
0xteddybear committed Aug 23, 2024
1 parent 50f6e2e commit 1cbdfab
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
5 changes: 4 additions & 1 deletion packages/contracts-bedrock/medusa.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@
]
},
"targetFunctionSignatures": [],
"excludeFunctionSignatures": []
"excludeFunctionSignatures": [
"ProtocolProperties.test_ERC20external_transferToZeroAddress()",
"ProtocolProperties.test_ERC20external_transferFromToZeroAddress(uint256)"
]
},
"chainConfig": {
"codeSizeCheckDisabled": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ contract Actors is StdUtils {
/// usually called with msg.sender as a parameter, to track the actors
/// already provided by the fuzzer
modifier withActor(address who) {
addActor(who);
_currentActor = who;
_;
}

function addActor(address who) internal {
if (!_isActor[who]) {
_isActor[who] = true;
_actors.push(who);
}
_currentActor = who;
_;
}

/// @notice get the currently configured actor, should equal msg.sender
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ contract ProtocolHandler is TestBase, StdUtils, Actors {
_deploySupertoken(remoteTokens[remoteTokenIndex], WORDS[0], WORDS[0], DECIMALS[0], supertokenChainId);
}
}
// integrate with all ToB properties using address(this) as the sender
addActor(address(this));
}

/// @notice the deploy params are _indexes_ to pick from a pre-defined array of options and limit
Expand Down Expand Up @@ -82,43 +84,50 @@ contract ProtocolHandler is TestBase, StdUtils, Actors {
ghost_totalSupplyAcrossChains.set(MESSENGER.superTokenInitDeploySalts(addr), currentValue + amount);
}

/// @notice The ToB properties don't preclude the need for this since they
/// always use address(this) as the caller, which won't get any balance
/// until it's transferred to it somehow
function handler_SupERC20Transfer(
uint256 tokenIndex,
address recipient,
uint256 toIndex,
uint256 amount
)
external
withActor(msg.sender)
{
vm.prank(currentActor());
OptimismSuperchainERC20(allSuperTokens[bound(tokenIndex, 0, allSuperTokens.length)]).transfer(recipient, amount);
OptimismSuperchainERC20(allSuperTokens[bound(tokenIndex, 0, allSuperTokens.length)]).transfer(
getActorByRawIndex(toIndex), amount
);
}

function handler_SupERC20TransferFrom(
uint256 tokenIndex,
address from,
address to,
uint256 fromIndex,
uint256 toIndex,
uint256 amount
)
external
withActor(msg.sender)
{
vm.prank(currentActor());
OptimismSuperchainERC20(allSuperTokens[bound(tokenIndex, 0, allSuperTokens.length)]).transferFrom(
from, to, amount
getActorByRawIndex(fromIndex), getActorByRawIndex(toIndex), amount
);
}

function handler_SupERC20Approve(
uint256 tokenIndex,
address spender,
uint256 spenderIndex,
uint256 amount
)
external
withActor(msg.sender)
{
vm.prank(currentActor());
OptimismSuperchainERC20(allSuperTokens[bound(tokenIndex, 0, allSuperTokens.length)]).transfer(spender, amount);
OptimismSuperchainERC20(allSuperTokens[bound(tokenIndex, 0, allSuperTokens.length)]).approve(
getActorByRawIndex(spenderIndex), amount
);
}

/// @notice deploy a remote token, that supertokens will be a representation of. They are never called, so there
Expand Down

0 comments on commit 1cbdfab

Please sign in to comment.