@@ -11,144 +11,100 @@ import {IexecLibCore_v5} from "./libs/IexecLibCore_v5.sol";
1111/****************************************************************************
1212 * WARNING: Be carefull when editing this file. *
1313 * *
14- * If you want add new variables for expanded features, add them at the *
15- * end, or (better?) create a Store_v2 that inherits from this Store. *
14+ * If you want to add new variables, add them to the end of the *
15+ * struct `PocoStorage`. *
16+ * Read more about: *
17+ * - Diamond proxy storage https://eips.ethereum.org/EIPS/eip-2535 *
18+ * - Namespaced storage https://eips.ethereum.org/EIPS/eip-7201 *
1619 * *
17- * If in doubt, read about Diamond proxy storage. *
1820 ****************************************************************************/
1921
20- /// @dev registries
21- interface IRegistry is IERC721Enumerable {
22- function isRegistered (address _entry ) external view returns (bool );
23- }
24-
25- /// @dev Poco store
26- /**
27- * @title Central storage of all modules contracts. It follows the Diamond
28- * pattern aka ERC-2535.
29- * @dev note the new added state variable "m_dealsBoost" that holds a new type
30- * of deals for the PoCo Boost workflow.
31- */
32- // TODO replace with diamond AppStorage using namespaced storage.
33- // TODO check storage padding.
3422abstract contract Store {
35- // Registries
36- //slither-disable-next-line constable-states
37- IRegistry internal m_appregistry;
38- //slither-disable-next-line constable-states
39- IRegistry internal m_datasetregistry;
40- //slither-disable-next-line constable-states
41- IRegistry internal m_workerpoolregistry;
42-
43- // Escrow
44- //slither-disable-next-line constable-states
45- IERC20 internal m_baseToken;
46- //slither-disable-next-line constable-states
47- string internal m_name;
48- //slither-disable-next-line constable-states
49- string internal m_symbol;
50- //slither-disable-next-line constable-states
51- uint8 internal m_decimals;
52- //slither-disable-next-line constable-states
53- uint256 internal m_totalSupply;
54-
55- /**
56- * @dev In order to use the protocol, users have to deposit RLC
57- * and allow PoCo smart contracts to manage them. This state
58- * variable keeps track of users balances.
59- */
60- mapping (address => uint256 ) internal m_balances;
61-
62- /**
63- * @dev When a deal is created, the protocol temporarily locks an amount
64- * of RLC tokens from the balances of both the requester and the workerpool owners.
65- * This is to guarantee the payment of different actors later. Frozen funds
66- * are released when the computation is completed and the result is pushed.
67- */
68- mapping (address => uint256 ) internal m_frozens;
69-
70- mapping (address => mapping (address => uint256 )) internal m_allowances;
71-
7223 // Poco - Constants
73- uint256 internal constant CONTRIBUTION_DEADLINE_RATIO = 7 ;
74- uint256 internal constant REVEAL_DEADLINE_RATIO = 2 ;
75- uint256 internal constant FINAL_DEADLINE_RATIO = 10 ;
76- uint256 internal constant WORKERPOOL_STAKE_RATIO = 30 ;
77- uint256 internal constant KITTY_RATIO = 10 ;
78- uint256 internal constant KITTY_MIN = 1e9 ; // ADJUSTEMENT VARIABLE
79-
80- /**
81- * @dev Seized funds of workerpools that do not honor their deals are sent
82- * out to this kitty address.
83- * It is determined with address(uint256(keccak256(bytes('iExecKitty'))) - 1).
84- */
85- address internal constant KITTY_ADDRESS = 0x99c2268479b93fDe36232351229815DF80837e23 ;
86-
87- /**
88- * @dev Used with ERC-734 Key Manager identity contract for authorization management.
89- */
90- uint256 internal constant GROUPMEMBER_PURPOSE = 4 ;
91-
92- /**
93- * @dev EIP-712 domain hash.
94- */
95- // Modified in IexecConfigurationFacet.updateDomainSeparator
96- //slither-disable-next-line constable-states
97- bytes32 internal EIP712DOMAIN_SEPARATOR;
98-
99- // Poco - Storage
100-
101- /**
102- * @dev Mapping an order hash to its owner. Since a smart contract cannot sign orders
103- * with a private key, it adds an entry to this mapping to provide presigned orders.
104- */
105- mapping (bytes32 => address ) internal m_presigned;
106-
107- /**
108- * @dev Each order has a volume (>=1). This tracks how much is consumed from
109- * the volume of each order. Mapping an order hash to its consumed amount.
110- */
111- mapping (bytes32 => uint256 ) internal m_consumed;
112-
113- /**
114- * @dev a mapping to store PoCo classic deals.
115- */
116- mapping (bytes32 => IexecLibCore_v5.Deal) internal m_deals;
117-
118- mapping (bytes32 => IexecLibCore_v5.Task) internal m_tasks; // per task
119- mapping (bytes32 => IexecLibCore_v5.Consensus) internal m_consensus; // per task
120- mapping (bytes32 => mapping (address => IexecLibCore_v5.Contribution)) internal m_contributions; // per task-worker
121- mapping (address => uint256 ) internal m_workerScores; // per worker
122-
123- // Poco - Settings
124-
125- /**
126- * @dev Address of a trusted TEE authority that manages enclave challenges.
127- */
128- // Modified in IexecConfigurationFacet.setTeeBroker
129- //slither-disable-next-line constable-states
130- address internal m_teebroker;
131-
132- /**
133- * @dev Max amount of gas to be used with callbacks.
134- */
135- // Modified in IexecConfigurationFacet.setCallbackGas
136- //slither-disable-next-line constable-states
137- uint256 internal m_callbackgas;
138-
139- /**
140- * @dev List of defined computation categories.
141- */
142- IexecLibCore_v5.Category[] internal m_categories;
143-
144- // Backward compatibility
145- // Modified in IexecConfigurationFacet.configure
146- //slither-disable-next-line constable-states
147- address internal m_v3_iexecHub; // IexecHubInterface
148- mapping (address => bool ) internal m_v3_scoreImported;
24+ uint256 public constant CONTRIBUTION_DEADLINE_RATIO = 7 ;
25+ uint256 public constant REVEAL_DEADLINE_RATIO = 2 ;
26+ uint256 public constant FINAL_DEADLINE_RATIO = 10 ;
27+ uint256 public constant WORKERPOOL_STAKE_RATIO = 30 ;
28+ uint256 public constant KITTY_RATIO = 10 ;
29+ uint256 public constant KITTY_MIN = 1e9 ; // ADJUSTEMENT VARIABLE
30+
31+ // Seized funds of workerpools that do not honor their deals are sent
32+ // out to this kitty address.
33+ // It is determined with address(uint256(keccak256(bytes('iExecKitty'))) - 1).
34+ address public constant KITTY_ADDRESS = 0x99c2268479b93fDe36232351229815DF80837e23 ;
35+
36+ // Used with ERC-734 Key Manager identity contract for authorization management.
37+ uint256 public constant GROUPMEMBER_PURPOSE = 4 ;
38+
39+ // keccak256(abi.encode(uint256(keccak256("iexec.poco.storage.PocoStorage")) - 1)) & ~bytes32(uint256(0xff));
40+ bytes32 private constant POCO_STORAGE_LOCATION =
41+ 0x5862653c6982c162832160cf30593645e8487b257e44d77cdd6b51eee2651b00 ;
42+
43+ /// @custom:storage-location erc7201:iexec.poco.storage.PocoStorage
44+ struct PocoStorage {
45+ // Registries
46+ IRegistry m_appregistry;
47+ IRegistry m_datasetregistry;
48+ IRegistry m_workerpoolregistry;
49+ // Escrow
50+ IERC20 m_baseToken;
51+ string m_name;
52+ string m_symbol;
53+ uint8 m_decimals;
54+ uint256 m_totalSupply;
55+ // In order to use the protocol, users have to deposit RLC
56+ // and allow PoCo smart contracts to manage them. This state
57+ // variable keeps track of users balances.
58+ mapping (address => uint256 ) m_balances;
59+ // When a deal is created, the protocol temporarily locks an amount
60+ // of RLC tokens from the balances of both the requester and the workerpool owners.
61+ // This is to guarantee the payment of different actors later. Frozen funds
62+ // are released when the computation is completed and the result is pushed.
63+ mapping (address => uint256 ) m_frozens;
64+ mapping (address => mapping (address => uint256 )) m_allowances;
65+ // EIP-712 domain hash.
66+ // Modified in IexecConfigurationFacet.updateDomainSeparator
67+ bytes32 EIP712DOMAIN_SEPARATOR; // TODO rename
68+ // Poco - Storage
69+
70+ // Mapping an order hash to its owner. Since a smart contract cannot sign orders
71+ // with a private key, it adds an entry to this mapping to provide presigned orders.
72+ mapping (bytes32 => address ) m_presigned;
73+ // Each order has a volume (>=1). This tracks how much is consumed from
74+ // the volume of each order. Mapping an order hash to its consumed amount.
75+ mapping (bytes32 => uint256 ) m_consumed;
76+ // a mapping to store PoCo classic deals.
77+ mapping (bytes32 => IexecLibCore_v5.Deal) m_deals;
78+ mapping (bytes32 => IexecLibCore_v5.Task) m_tasks; // per task
79+ mapping (bytes32 => IexecLibCore_v5.Consensus) m_consensus; // per task
80+ mapping (bytes32 => mapping (address => IexecLibCore_v5.Contribution)) m_contributions; // per task-worker
81+ mapping (address => uint256 ) m_workerScores; // per worker
82+ // Poco - Settings
83+ // Address of a trusted TEE authority that manages enclave challenges.
84+ // Modified in IexecConfigurationFacet.setTeeBroker
85+ address m_teebroker;
86+ // Max amount of gas to be used with callbacks.
87+ // Modified in IexecConfigurationFacet.setCallbackGas
88+ uint256 m_callbackgas;
89+ // List of defined computation categories.
90+ IexecLibCore_v5.Category[] m_categories;
91+ // Backward compatibility
92+ // Modified in IexecConfigurationFacet.configure
93+ address m_v3_iexecHub; // IexecHubInterface
94+ mapping (address => bool ) m_v3_scoreImported;
95+ // /!\ New storage variables not present in v6 store.
96+ // A mapping to store PoCo Boost deals.
97+ mapping (bytes32 => IexecLibCore_v5.DealBoost) m_dealsBoost;
98+ }
99+
100+ function getPocoStorage () internal pure returns (PocoStorage storage $) {
101+ assembly ("memory-safe" ) {
102+ $.slot := POCO_STORAGE_LOCATION
103+ }
104+ }
105+ }
149106
150- /**
151- * @dev A mapping to store PoCo Boost deals.
152- */
153- mapping (bytes32 => IexecLibCore_v5.DealBoost) internal m_dealsBoost;
107+ // Use in registries.
108+ interface IRegistry is IERC721Enumerable {
109+ function isRegistered (address _entry ) external view returns (bool );
154110}
0 commit comments