Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Save IexecLibOrders_v5 in config file (#242)
- Migrate proxy to Diamond pattern (ERC-2535):
- Use lib as storage. (#243)
- Restore compatibility with iExec SDK. (#240)
- Target latest EVM version (#239)
- Adapt contracts file tree (#238)
Expand Down
20 changes: 18 additions & 2 deletions contracts/facets/FacetBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pragma solidity ^0.6.0;

import "../Store.sol";
import "../libs/PocoStorageLib.sol";
import "../interfaces/IOwnable.sol";

// Functions that were declared in ERC1538Store are re-declared here.
Expand All @@ -13,7 +13,23 @@ import "../interfaces/IOwnable.sol";
* @title Base contract of all Facet contracts.
* @dev Every facet must inherit from this contract.
*/
abstract contract FacetBase is Store {
abstract contract FacetBase {
// Poco - Constants
uint256 public constant CONTRIBUTION_DEADLINE_RATIO = 7;
uint256 public constant REVEAL_DEADLINE_RATIO = 2;
uint256 public constant FINAL_DEADLINE_RATIO = 10;
uint256 public constant WORKERPOOL_STAKE_RATIO = 30;
uint256 public constant KITTY_RATIO = 10;
uint256 public constant KITTY_MIN = 1e9; // ADJUSTEMENT VARIABLE

// Seized funds of workerpools that do not honor their deals are sent
// out to this kitty address.
// It is determined with address(uint256(keccak256(bytes('iExecKitty'))) - 1).
address public constant KITTY_ADDRESS = 0x99c2268479b93fDe36232351229815DF80837e23;

// Used with ERC-734 Key Manager identity contract for authorization management.
uint256 public constant GROUPMEMBER_PURPOSE = 4;

modifier onlyOwner() {
require(_msgSender() == owner(), "Ownable: caller is not the owner");
_;
Expand Down
20 changes: 18 additions & 2 deletions contracts/facets/FacetBase.v8.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
pragma solidity ^0.8.0;

import {IERC5313} from "@openzeppelin/contracts-v5/interfaces/IERC5313.sol";
import {Store} from "../Store.v8.sol";
import {PocoStorageLib} from "../libs/PocoStorageLib.v8.sol";

// Functions that were declared in ERC1538Store are re-declared here.
// TODO use LibDiamond.contractOwner() when migrating all contracts to v8.
Expand All @@ -13,7 +13,23 @@ import {Store} from "../Store.v8.sol";
* @title Base contract of all Facet contracts.
* @dev Every facet must inherit from this contract.
*/
abstract contract FacetBase is Store {
abstract contract FacetBase {
// Poco - Constants
uint256 public constant CONTRIBUTION_DEADLINE_RATIO = 7;
uint256 public constant REVEAL_DEADLINE_RATIO = 2;
uint256 public constant FINAL_DEADLINE_RATIO = 10;
uint256 public constant WORKERPOOL_STAKE_RATIO = 30;
uint256 public constant KITTY_RATIO = 10;
uint256 public constant KITTY_MIN = 1e9; // ADJUSTEMENT VARIABLE

// Seized funds of workerpools that do not honor their deals are sent
// out to this kitty address.
// It is determined with address(uint256(keccak256(bytes('iExecKitty'))) - 1).
address public constant KITTY_ADDRESS = 0x99c2268479b93fDe36232351229815DF80837e23;

// Used with ERC-734 Key Manager identity contract for authorization management.
uint256 public constant GROUPMEMBER_PURPOSE = 4;

modifier onlyOwner() {
require(_msgSender() == owner(), "Ownable: caller is not the owner");
_;
Expand Down
15 changes: 8 additions & 7 deletions contracts/facets/IexecAccessorsABILegacyFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pragma experimental ABIEncoderV2;

import "./FacetBase.sol";
import "../interfaces/IexecAccessorsABILegacy.sol";
import {PocoStorageLib} from "../libs/PocoStorageLib.sol";

contract IexecAccessorsABILegacyFacet is IexecAccessorsABILegacy, FacetBase {
function viewDealABILegacy_pt1(
Expand All @@ -16,7 +17,7 @@ contract IexecAccessorsABILegacyFacet is IexecAccessorsABILegacy, FacetBase {
override
returns (address, address, uint256, address, address, uint256, address, address, uint256)
{
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
IexecLibCore_v5.Deal memory deal = $.m_deals[_id];
return (
deal.app.pointer,
Expand All @@ -34,15 +35,15 @@ contract IexecAccessorsABILegacyFacet is IexecAccessorsABILegacy, FacetBase {
function viewDealABILegacy_pt2(
bytes32 _id
) external view override returns (uint256, bytes32, address, address, address, string memory) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
IexecLibCore_v5.Deal memory deal = $.m_deals[_id];
return (deal.trust, deal.tag, deal.requester, deal.beneficiary, deal.callback, deal.params);
}

function viewConfigABILegacy(
bytes32 _id
) external view override returns (uint256, uint256, uint256, uint256, uint256, uint256) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
IexecLibCore_v5.Deal memory deal = $.m_deals[_id];
return (
deal.category,
Expand All @@ -57,7 +58,7 @@ contract IexecAccessorsABILegacyFacet is IexecAccessorsABILegacy, FacetBase {
function viewAccountABILegacy(
address account
) external view override returns (uint256, uint256) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return ($.m_balances[account], $.m_frozens[account]);
}

Expand All @@ -83,7 +84,7 @@ contract IexecAccessorsABILegacyFacet is IexecAccessorsABILegacy, FacetBase {
)
{
/// @dev Using $.m_tasks causes "Stack too deep" error.
IexecLibCore_v5.Task memory task = getPocoStorage().m_tasks[_taskid];
IexecLibCore_v5.Task memory task = PocoStorageLib.getPocoStorage().m_tasks[_taskid];
return (
task.status,
task.dealid,
Expand All @@ -109,7 +110,7 @@ contract IexecAccessorsABILegacyFacet is IexecAccessorsABILegacy, FacetBase {
override
returns (IexecLibCore_v5.ContributionStatusEnum, bytes32, bytes32, address)
{
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
IexecLibCore_v5.Contribution memory contribution = $.m_contributions[_taskid][_worker];
return (
contribution.status,
Expand All @@ -122,7 +123,7 @@ contract IexecAccessorsABILegacyFacet is IexecAccessorsABILegacy, FacetBase {
function viewCategoryABILegacy(
uint256 _catid
) external view override returns (string memory, string memory, uint256) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
IexecLibCore_v5.Category memory category = $.m_categories[_catid];
return (category.name, category.description, category.workClockTimeRef);
}
Expand Down
49 changes: 25 additions & 24 deletions contracts/facets/IexecAccessorsFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,94 +6,95 @@ pragma experimental ABIEncoderV2;

import "./FacetBase.sol";
import "../interfaces/IexecAccessors.sol";
import {PocoStorageLib} from "../libs/PocoStorageLib.sol";

contract IexecAccessorsFacet is IexecAccessors, FacetBase {
function name() external view override returns (string memory) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_name;
}

function symbol() external view override returns (string memory) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_symbol;
}

function decimals() external view override returns (uint8) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_decimals;
}

function totalSupply() external view override returns (uint256) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_totalSupply;
}

function balanceOf(address account) external view override returns (uint256) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_balances[account];
}

function frozenOf(address account) external view override returns (uint256) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_frozens[account];
}

function allowance(address account, address spender) external view override returns (uint256) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_allowances[account][spender];
}

function viewAccount(
address account
) external view override returns (IexecLibCore_v5.Account memory) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return IexecLibCore_v5.Account($.m_balances[account], $.m_frozens[account]);
}

function token() external view override returns (address) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return address($.m_baseToken);
}

function viewDeal(
bytes32 _id
) external view override returns (IexecLibCore_v5.Deal memory deal) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_deals[_id];
}

function viewConsumed(bytes32 _id) external view override returns (uint256 consumed) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_consumed[_id];
}

function viewPresigned(bytes32 _id) external view override returns (address signer) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_presigned[_id];
}

function viewTask(
bytes32 _taskid
) external view override returns (IexecLibCore_v5.Task memory) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_tasks[_taskid];
}

function viewContribution(
bytes32 _taskid,
address _worker
) external view override returns (IexecLibCore_v5.Contribution memory) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_contributions[_taskid][_worker];
}

function viewScore(address _worker) external view override returns (uint256) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_workerScores[_worker];
}

function resultFor(bytes32 id) external view override returns (bytes memory) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
IexecLibCore_v5.Task storage task = $.m_tasks[id];
require(task.status == IexecLibCore_v5.TaskStatusEnum.COMPLETED, "task-pending");
return task.resultsCallback; // Expansion - result separation
Expand All @@ -102,37 +103,37 @@ contract IexecAccessorsFacet is IexecAccessors, FacetBase {
function viewCategory(
uint256 _catid
) external view override returns (IexecLibCore_v5.Category memory category) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_categories[_catid];
}

function countCategory() external view override returns (uint256 count) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_categories.length;
}

function appregistry() external view override returns (IRegistry) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_appregistry;
}

function datasetregistry() external view override returns (IRegistry) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_datasetregistry;
}

function workerpoolregistry() external view override returns (IRegistry) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_workerpoolregistry;
}

function teebroker() external view override returns (address) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_teebroker;
}

function callbackgas() external view override returns (uint256) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_callbackgas;
}

Expand Down Expand Up @@ -169,7 +170,7 @@ contract IexecAccessorsFacet is IexecAccessors, FacetBase {
}

function eip712domain_separator() external view override returns (bytes32) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
return $.m_eip712DomainSeparator;
}
}
3 changes: 2 additions & 1 deletion contracts/facets/IexecCategoryManagerFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;

import "./FacetBase.sol";
import {PocoStorageLib} from "../libs/PocoStorageLib.sol";
import "../interfaces/IexecCategoryManager.sol";

contract IexecCategoryManagerFacet is IexecCategoryManager, FacetBase {
Expand All @@ -16,7 +17,7 @@ contract IexecCategoryManagerFacet is IexecCategoryManager, FacetBase {
string calldata description,
uint256 workClockTimeRef
) external override onlyOwner returns (uint256) {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
$.m_categories.push(IexecLibCore_v5.Category(name, description, workClockTimeRef));

uint256 catid = $.m_categories.length - 1;
Expand Down
3 changes: 2 additions & 1 deletion contracts/facets/IexecConfigurationExtraFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ pragma experimental ABIEncoderV2;

import "./FacetBase.sol";
import "../interfaces/IexecConfigurationExtra.sol";
import {PocoStorageLib} from "../libs/PocoStorageLib.sol";

contract IexecConfigurationExtraFacet is IexecConfigurationExtra, FacetBase {
function changeRegistries(
address _appregistryAddress,
address _datasetregistryAddress,
address _workerpoolregistryAddress
) external override onlyOwner {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
$.m_appregistry = IRegistry(_appregistryAddress);
$.m_datasetregistry = IRegistry(_datasetregistryAddress);
$.m_workerpoolregistry = IRegistry(_workerpoolregistryAddress);
Expand Down
12 changes: 6 additions & 6 deletions contracts/facets/IexecConfigurationFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import "./FacetBase.sol";
import "../interfaces/IexecConfiguration.sol";
import {PocoStorageLib} from "../libs/PocoStorageLib.sol";

contract IexecConfigurationFacet is IexecConfiguration, FacetBase {
using SafeMathExtended for uint256;
Expand All @@ -24,10 +25,9 @@ contract IexecConfigurationFacet is IexecConfiguration, FacetBase {
address _workerpoolregistryAddress,
address _v3_iexecHubAddress
) external override onlyOwner {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
require($.m_eip712DomainSeparator == bytes32(0), "already-configured");
$.m_eip712DomainSeparator = _domain().hash();

$.m_baseToken = IERC20(_token);
$.m_name = _name;
$.m_symbol = _symbol;
Expand All @@ -44,13 +44,13 @@ contract IexecConfigurationFacet is IexecConfiguration, FacetBase {
}

function updateDomainSeparator() external override {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
require($.m_eip712DomainSeparator != bytes32(0), "not-configured");
$.m_eip712DomainSeparator = _domain().hash();
}

function importScore(address _worker) external override {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
require(!$.m_v3_scoreImported[_worker], "score-already-imported");
$.m_workerScores[_worker] = $.m_workerScores[_worker].max(
$.m_v3_iexecHub.viewScore(_worker)
Expand All @@ -59,12 +59,12 @@ contract IexecConfigurationFacet is IexecConfiguration, FacetBase {
}

function setTeeBroker(address _teebroker) external override onlyOwner {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
$.m_teebroker = _teebroker;
}

function setCallbackGas(uint256 _callbackgas) external override onlyOwner {
PocoStorage storage $ = getPocoStorage();
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
$.m_callbackgas = _callbackgas;
}

Expand Down
Loading