diff --git a/packages/contracts-bedrock/medusa.json b/packages/contracts-bedrock/medusa.json index cb4737956fea..1e76338ea28f 100644 --- a/packages/contracts-bedrock/medusa.json +++ b/packages/contracts-bedrock/medusa.json @@ -55,7 +55,10 @@ ] }, "targetFunctionSignatures": [], - "excludeFunctionSignatures": [] + "excludeFunctionSignatures": [ + "ProtocolProperties.test_ERC20external_transferToZeroAddress()", + "ProtocolProperties.test_ERC20external_transferFromToZeroAddress(uint256)" + ] }, "chainConfig": { "codeSizeCheckDisabled": true, diff --git a/packages/contracts-bedrock/test/properties/helpers/Actors.t.sol b/packages/contracts-bedrock/test/properties/helpers/Actors.t.sol index 5843bfd243cd..3a7400667518 100644 --- a/packages/contracts-bedrock/test/properties/helpers/Actors.t.sol +++ b/packages/contracts-bedrock/test/properties/helpers/Actors.t.sol @@ -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 diff --git a/packages/contracts-bedrock/test/properties/medusa/handlers/Protocol.handler.t.sol b/packages/contracts-bedrock/test/properties/medusa/handlers/Protocol.handler.t.sol index f2069dda66d3..d773d1ef90d3 100644 --- a/packages/contracts-bedrock/test/properties/medusa/handlers/Protocol.handler.t.sol +++ b/packages/contracts-bedrock/test/properties/medusa/handlers/Protocol.handler.t.sol @@ -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 @@ -82,22 +84,27 @@ 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 @@ -105,20 +112,22 @@ contract ProtocolHandler is TestBase, StdUtils, Actors { { 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