@@ -17,58 +17,90 @@ import "./registries/IRegistry.sol";
1717/****************************************************************************
1818 * WARNING: Be carefull when editing this file. *
1919 * *
20- * If you want add new variables for expanded features, add them at the *
21- * end, or (better?) create a Store_v2 that inherits from this Store. *
20+ * If you want to add new variables, add them to the end of the *
21+ * struct `PocoStorage`. *
22+ * Read more about: *
23+ * - Diamond proxy storage https://eips.ethereum.org/EIPS/eip-2535 *
24+ * - Namespaced storage https://eips.ethereum.org/EIPS/eip-7201 *
2225 * *
23- * If in doubt, read about Diamond proxy storage. *
2426 ****************************************************************************/
2527
26- // TODO replace with diamond AppStorage using namespaced storage.
27- // TODO check storage padding.
2828abstract contract Store {
29- // Registries
30- IRegistry internal m_appregistry;
31- IRegistry internal m_datasetregistry;
32- IRegistry internal m_workerpoolregistry;
33-
34- // Escrow
35- IERC20 internal m_baseToken;
36- string internal m_name;
37- string internal m_symbol;
38- uint8 internal m_decimals;
39- uint256 internal m_totalSupply;
40- mapping (address => uint256 ) internal m_balances;
41- mapping (address => uint256 ) internal m_frozens;
42- mapping (address => mapping (address => uint256 )) internal m_allowances;
43-
4429 // Poco - Constants
45- uint256 internal constant CONTRIBUTION_DEADLINE_RATIO = 7 ;
46- uint256 internal constant REVEAL_DEADLINE_RATIO = 2 ;
47- uint256 internal constant FINAL_DEADLINE_RATIO = 10 ;
48- uint256 internal constant WORKERPOOL_STAKE_RATIO = 30 ;
49- uint256 internal constant KITTY_RATIO = 10 ;
50- uint256 internal constant KITTY_MIN = 1000000000 ; // ADJUSTEMENT VARIABLE
51- address internal constant KITTY_ADDRESS = 0x99c2268479b93fDe36232351229815DF80837e23 ; // address(uint256(keccak256(bytes('iExecKitty'))) - 1);
52- uint256 internal constant GROUPMEMBER_PURPOSE = 4 ;
53- bytes32 internal EIP712DOMAIN_SEPARATOR;
30+ uint256 public constant CONTRIBUTION_DEADLINE_RATIO = 7 ;
31+ uint256 public constant REVEAL_DEADLINE_RATIO = 2 ;
32+ uint256 public constant FINAL_DEADLINE_RATIO = 10 ;
33+ uint256 public constant WORKERPOOL_STAKE_RATIO = 30 ;
34+ uint256 public constant KITTY_RATIO = 10 ;
35+ uint256 public constant KITTY_MIN = 1e9 ; // ADJUSTEMENT VARIABLE
36+
37+ // Seized funds of workerpools that do not honor their deals are sent
38+ // out to this kitty address.
39+ // It is determined with address(uint256(keccak256(bytes('iExecKitty'))) - 1).
40+ address public constant KITTY_ADDRESS = 0x99c2268479b93fDe36232351229815DF80837e23 ;
5441
55- // Poco - Storage
56- mapping (bytes32 => address ) internal m_presigned; // per order
57- mapping (bytes32 => uint256 ) internal m_consumed; // per order
58- mapping (bytes32 => IexecLibCore_v5.Deal) internal m_deals; // per deal
59- mapping (bytes32 => IexecLibCore_v5.Task) internal m_tasks; // per task
60- mapping (bytes32 => IexecLibCore_v5.Consensus) internal m_consensus; // per task
61- mapping (bytes32 => mapping (address => IexecLibCore_v5.Contribution)) internal m_contributions; // per task-worker
62- mapping (address => uint256 ) internal m_workerScores; // per worker
42+ // Used with ERC-734 Key Manager identity contract for authorization management.
43+ uint256 public constant GROUPMEMBER_PURPOSE = 4 ;
6344
64- // Poco - Settings
65- address internal m_teebroker;
66- uint256 internal m_callbackgas ;
45+ // keccak256(abi.encode(uint256(keccak256("iexec.poco.storage.PocoStorage")) - 1)) & ~bytes32(uint256(0xff));
46+ bytes32 private constant POCO_STORAGE_LOCATION =
47+ 0x5862653c6982c162832160cf30593645e8487b257e44d77cdd6b51eee2651b00 ;
6748
68- // Categories
69- IexecLibCore_v5.Category[] internal m_categories;
49+ /// @custom:storage-location erc7201:iexec.poco.storage.PocoStorage
50+ struct PocoStorage {
51+ // Registries
52+ IRegistry m_appregistry;
53+ IRegistry m_datasetregistry;
54+ IRegistry m_workerpoolregistry;
55+ // Escrow
56+ IERC20 m_baseToken;
57+ string m_name;
58+ string m_symbol;
59+ uint8 m_decimals;
60+ uint256 m_totalSupply;
61+ // In order to use the protocol, users have to deposit RLC
62+ // and allow PoCo smart contracts to manage them. This state
63+ // variable keeps track of users balances.
64+ mapping (address /* account */ => uint256 /* amount */ ) m_balances;
65+ // When a deal is created, the protocol temporarily locks an amount
66+ // of RLC tokens from the balances of both the requester and the workerpool owners.
67+ // This is to guarantee the payment of different actors later. Frozen funds
68+ // are released when the computation is completed and the result is pushed.
69+ mapping (address /* account */ => uint256 /* amount */ ) m_frozens;
70+ mapping (address /* owner */ => mapping (address /* spender */ => uint256 /* amount */ )) m_allowances;
71+ // EIP-712 domain hash.
72+ // Modified in IexecConfigurationFacet.updateDomainSeparator
73+ bytes32 m_eip712DomainSeparator;
74+ // Mapping an order hash to its owner. Since a smart contract cannot sign orders
75+ // with a private key, it adds an entry to this mapping to provide presigned orders.
76+ mapping (bytes32 /* orderHash */ => address /* owner */ ) m_presigned;
77+ // Each order has a volume (>=1). This tracks how much is consumed from
78+ // the volume of each order. Mapping an order hash to its consumed amount.
79+ mapping (bytes32 /* orderHash */ => uint256 /* consumedAmount */ ) m_consumed;
80+ // a mapping to store PoCo classic deals.
81+ mapping (bytes32 /* dealId */ => IexecLibCore_v5.Deal) m_deals;
82+ mapping (bytes32 /* taskId */ => IexecLibCore_v5.Task) m_tasks;
83+ mapping (bytes32 /* taskId */ => IexecLibCore_v5.Consensus) m_consensus;
84+ mapping (bytes32 /* taskId */ => mapping (address /* worker */ => IexecLibCore_v5.Contribution)) m_contributions;
85+ mapping (address /* worker */ => uint256 /* score */ ) m_workerScores;
86+ // Poco - Settings
87+ // Address of a trusted TEE authority that manages enclave challenges.
88+ // Modified in IexecConfigurationFacet.setTeeBroker
89+ address m_teebroker;
90+ // Max amount of gas to be used with callbacks.
91+ // Modified in IexecConfigurationFacet.setCallbackGas
92+ uint256 m_callbackgas;
93+ // List of defined computation categories.
94+ IexecLibCore_v5.Category[] m_categories;
95+ // Backward compatibility
96+ // Modified in IexecConfigurationFacet.configure
97+ IexecHubInterface m_v3_iexecHub;
98+ mapping (address /* worker */ => bool ) m_v3_scoreImported;
99+ }
70100
71- // Backward compatibility
72- IexecHubInterface internal m_v3_iexecHub;
73- mapping (address => bool ) internal m_v3_scoreImported;
101+ function getPocoStorage () internal pure returns (PocoStorage storage $) {
102+ assembly {
103+ $_slot := POCO_STORAGE_LOCATION
104+ }
105+ }
74106}
0 commit comments