Skip to content

Commit 7c758c9

Browse files
committed
Merge branch 'feature/diamond' into fix/fix-uprade-helper-script
2 parents 08d616d + 3b43823 commit 7c758c9

File tree

87 files changed

+886
-651
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+886
-651
lines changed

.prettierignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
artifacts/
3+
audit/
4+
build/
5+
cache/
6+
coverage/
7+
coverage.json
8+
deployments/
9+
node_modules/
10+
typechain/

.solcover.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121
'tools/testing/ERC1271Mock.sol',
2222
'tools/testing/TestClient.sol',
2323
'tools/testing/TestReceiver.sol',
24-
'modules/facets/SignatureVerifier.sol',
24+
'facets/SignatureVerifier.sol',
2525
],
2626
istanbulFolder: BASE_FOLDER,
2727
};

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
## vNEXT
44

55
- Migrate proxy to Diamond pattern (ERC-2535):
6+
- Restore compatibility with iExec SDK. (#240)
7+
- Target latest EVM version (#239)
8+
- Adapt contracts file tree (#238)
9+
- Use namespaced storage (#236, #237)
610
- Fix script folder (#235)
711
- Format all solidity files (#233)
812
- Rename ERC1538 architure to diamond Proxy architecture(#226, #229, #230, #234)

contracts/IexecInterfaceNative.sol

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,24 @@
44
pragma solidity ^0.6.0;
55
pragma experimental ABIEncoderV2;
66

7-
import "./modules/interfaces/IOwnable.sol";
8-
import "./modules/interfaces/IexecAccessors.sol";
9-
import "./modules/interfaces/IexecCategoryManager.sol";
10-
import "./modules/interfaces/IexecERC20.sol";
11-
import "./modules/interfaces/IexecEscrowNative.sol";
12-
import "./modules/interfaces/IexecConfiguration.sol";
13-
import "./modules/interfaces/IexecOrderManagement.sol";
14-
import "./modules/interfaces/IexecPoco1.sol";
15-
import "./modules/interfaces/IexecPoco2.sol";
16-
import "./modules/interfaces/IexecRelay.sol";
17-
import "./modules/interfaces/IexecTokenSpender.sol";
7+
import "./interfaces/IOwnable.sol";
8+
import "./interfaces/IexecAccessors.sol";
9+
import "./interfaces/IexecCategoryManager.sol";
10+
import "./interfaces/IexecERC20.sol";
11+
import "./interfaces/IexecEscrowNative.sol";
12+
import "./interfaces/IexecConfiguration.sol";
13+
import "./interfaces/IexecOrderManagement.sol";
14+
import "./interfaces/IexecPoco1.sol";
15+
import "./interfaces/IexecPoco2.sol";
16+
import "./interfaces/IexecRelay.sol";
17+
import "./interfaces/IexecTokenSpender.sol";
1818

19+
/**
20+
* A global interface that aggregates all the interfaces needed to interact with
21+
* the PoCo contracts in native mode.
22+
* @dev Referenced in the SDK with the current path `contracts/IexecInterfaceNative.sol`.
23+
* Changing the name or the path would cause a breaking change in the SDK.
24+
*/
1925
interface IexecInterfaceNative is
2026
IOwnable,
2127
IexecAccessors,

contracts/IexecInterfaceNativeABILegacy.sol

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
pragma solidity ^0.6.0;
55
pragma experimental ABIEncoderV2;
66

7-
import "./modules/interfaces/IOwnable.sol";
8-
import "./modules/interfaces/IexecAccessors.sol";
9-
import "./modules/interfaces/IexecAccessorsABILegacy.sol";
10-
import "./modules/interfaces/IexecCategoryManager.sol";
11-
import "./modules/interfaces/IexecERC20.sol";
12-
import "./modules/interfaces/IexecEscrowNative.sol";
13-
import "./modules/interfaces/IexecConfiguration.sol";
14-
import "./modules/interfaces/IexecOrderManagement.sol";
15-
import "./modules/interfaces/IexecPoco1.sol";
16-
import "./modules/interfaces/IexecPoco2.sol";
17-
import "./modules/interfaces/IexecRelay.sol";
18-
import "./modules/interfaces/IexecTokenSpender.sol";
7+
import "./interfaces/IOwnable.sol";
8+
import "./interfaces/IexecAccessors.sol";
9+
import "./interfaces/IexecAccessorsABILegacy.sol";
10+
import "./interfaces/IexecCategoryManager.sol";
11+
import "./interfaces/IexecERC20.sol";
12+
import "./interfaces/IexecEscrowNative.sol";
13+
import "./interfaces/IexecConfiguration.sol";
14+
import "./interfaces/IexecOrderManagement.sol";
15+
import "./interfaces/IexecPoco1.sol";
16+
import "./interfaces/IexecPoco2.sol";
17+
import "./interfaces/IexecRelay.sol";
18+
import "./interfaces/IexecTokenSpender.sol";
1919

20+
/**
21+
* TODO: Remove this interface in the future when IexecInterfaceTokenABILegacy is removed.
22+
*/
2023
interface IexecInterfaceNativeABILegacy is
2124
IOwnable,
2225
IexecAccessors,

contracts/IexecInterfaceToken.sol

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,25 @@
44
pragma solidity ^0.6.0;
55
pragma experimental ABIEncoderV2;
66

7-
import "./modules/interfaces/IOwnable.sol";
8-
import "./modules/interfaces/IexecAccessors.sol";
9-
import "./modules/interfaces/IexecCategoryManager.sol";
10-
import "./modules/interfaces/IexecERC20.sol";
11-
import "./modules/interfaces/IexecEscrowToken.sol";
12-
import "./modules/interfaces/IexecEscrowTokenSwap.sol";
13-
import "./modules/interfaces/IexecConfiguration.sol";
14-
import "./modules/interfaces/IexecOrderManagement.sol";
15-
import "./modules/interfaces/IexecPoco1.sol";
16-
import "./modules/interfaces/IexecPoco2.sol";
17-
import "./modules/interfaces/IexecRelay.sol";
18-
import "./modules/interfaces/IexecTokenSpender.sol";
7+
import "./interfaces/IOwnable.sol";
8+
import "./interfaces/IexecAccessors.sol";
9+
import "./interfaces/IexecCategoryManager.sol";
10+
import "./interfaces/IexecERC20.sol";
11+
import "./interfaces/IexecEscrowToken.sol";
12+
import "./interfaces/IexecEscrowTokenSwap.sol";
13+
import "./interfaces/IexecConfiguration.sol";
14+
import "./interfaces/IexecOrderManagement.sol";
15+
import "./interfaces/IexecPoco1.sol";
16+
import "./interfaces/IexecPoco2.sol";
17+
import "./interfaces/IexecRelay.sol";
18+
import "./interfaces/IexecTokenSpender.sol";
1919

20+
/**
21+
* A global interface that aggregates all the interfaces needed to interact with
22+
* the PoCo contracts in token mode.
23+
* @dev Referenced in the SDK with the current path `contracts/IexecInterfaceToken.sol`.
24+
* Changing the name or the path would cause a breaking change in the SDK.
25+
*/
2026
interface IexecInterfaceToken is
2127
IOwnable,
2228
IexecAccessors,

contracts/IexecInterfaceTokenABILegacy.sol

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,25 @@
44
pragma solidity ^0.6.0;
55
pragma experimental ABIEncoderV2;
66

7-
import "./modules/interfaces/IOwnable.sol";
8-
import "./modules/interfaces/IexecAccessors.sol";
9-
import "./modules/interfaces/IexecAccessorsABILegacy.sol";
10-
import "./modules/interfaces/IexecCategoryManager.sol";
11-
import "./modules/interfaces/IexecERC20.sol";
12-
import "./modules/interfaces/IexecEscrowToken.sol";
13-
import "./modules/interfaces/IexecEscrowTokenSwap.sol";
14-
import "./modules/interfaces/IexecConfiguration.sol";
15-
import "./modules/interfaces/IexecOrderManagement.sol";
16-
import "./modules/interfaces/IexecPoco1.sol";
17-
import "./modules/interfaces/IexecPoco2.sol";
18-
import "./modules/interfaces/IexecRelay.sol";
19-
import "./modules/interfaces/IexecTokenSpender.sol";
7+
import "./interfaces/IOwnable.sol";
8+
import "./interfaces/IexecAccessors.sol";
9+
import "./interfaces/IexecAccessorsABILegacy.sol";
10+
import "./interfaces/IexecCategoryManager.sol";
11+
import "./interfaces/IexecERC20.sol";
12+
import "./interfaces/IexecEscrowToken.sol";
13+
import "./interfaces/IexecEscrowTokenSwap.sol";
14+
import "./interfaces/IexecConfiguration.sol";
15+
import "./interfaces/IexecOrderManagement.sol";
16+
import "./interfaces/IexecPoco1.sol";
17+
import "./interfaces/IexecPoco2.sol";
18+
import "./interfaces/IexecRelay.sol";
19+
import "./interfaces/IexecTokenSpender.sol";
2020

21+
/**
22+
* TODO: Remove this interface in the future.
23+
* Currently Used in the middleware:
24+
* https://github.com/iExecBlockchainComputing/iexec-commons-poco/blob/819cd008/generateContractWrappers#L7
25+
*/
2126
interface IexecInterfaceTokenABILegacy is
2227
IOwnable,
2328
IexecAccessors,

contracts/Store.sol

Lines changed: 77 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
2828
abstract 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

Comments
 (0)