forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: separate state transitions from pure properties
- Loading branch information
1 parent
745dcbc
commit 07ca17e
Showing
3 changed files
with
41 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/contracts-bedrock/test/properties/medusa/Protocol.properties.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.25; | ||
|
||
import { ProtocolHandler } from "./handlers/Protocol.handler.t.sol"; | ||
import { OptimismSuperchainERC20 } from "src/L2/OptimismSuperchainERC20.sol"; | ||
import { EnumerableMap } from "@openzeppelin/contracts/utils/structs/EnumerableMap.sol"; | ||
|
||
contract ProtocolProperties is ProtocolHandler { | ||
using EnumerableMap for EnumerableMap.Bytes32ToUintMap; | ||
// TODO: will need rework after | ||
// - non-atomic bridge | ||
// - `convert` | ||
/// @custom:property-id 24 | ||
/// @custom:property sum of supertoken total supply across all chains is always equal to convert(legacy, super)- | ||
/// convert(super, legacy) | ||
|
||
function property_totalSupplyAcrossChainsEqualsMints() external view returns (bool success) { | ||
// iterate over unique deploy salts aka supertokens that are supposed to be compatible with each other | ||
for (uint256 deploySaltIndex = 0; deploySaltIndex < ghost_totalSupplyAcrossChains.length(); deploySaltIndex++) { | ||
uint256 totalSupply = 0; | ||
(bytes32 currentSalt, uint256 trackedSupply) = ghost_totalSupplyAcrossChains.at(deploySaltIndex); | ||
// and then over all the (mocked) chain ids where that supertoken could be deployed | ||
for (uint256 validChainId = 0; validChainId < MAX_CHAINS; validChainId++) { | ||
address supertoken = MESSENGER.superTokenAddresses(validChainId, currentSalt); | ||
if (supertoken != address(0)) { | ||
totalSupply += OptimismSuperchainERC20(supertoken).totalSupply(); | ||
} | ||
} | ||
if (trackedSupply != totalSupply) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters