diff --git a/.agents/context/architecture.md b/.agents/context/architecture.md index b1c3b2f2e..99a05a790 100644 --- a/.agents/context/architecture.md +++ b/.agents/context/architecture.md @@ -7,7 +7,7 @@ - Protocol logic: `contracts/facets/*Facet.sol` - External API declarations: `contracts/interfaces/` - `contracts/IexecInterfaceToken.sol` aggregates them into the single interface downstream tools compile against -- Shared helpers: `contracts/abstract/` (`FacetBase`, `IexecPocoCommon`, `SignatureVerifier`, …) +- Shared helpers: `contracts/abstract/` for inherited bases (`FacetBase`) and `contracts/libs/` for stateless helper libraries (`CommonLib`, `EscrowLib`, `PocoStorageLib`, …) - Storage lives in one struct accessed through `contracts/libs/PocoStorageLib.sol`, shared by every facet: **never reorder or remove an existing variable, only append**. `npm run check-storage-layout` is the CI gate. - Adding or removing a facet means editing two hand-maintained lists: `utils/proxy-tools.ts#getAllLocalFacetFunctions` (selector-to-name map used by upgrades) and the facet groups in `scripts/tools/sol-to-uml.mjs`. diff --git a/.solcover.js b/.solcover.js index 4d2eefc89..a06cea406 100644 --- a/.solcover.js +++ b/.solcover.js @@ -7,7 +7,7 @@ module.exports = { solcOptimizerDetails: { yul: true, yulDetails: { - optimizerSteps: '', + optimizerSteps: 'u', }, }, mocha: { diff --git a/abis/contracts/facets/IexecEscrowTokenFacet.json b/abis/contracts/facets/IexecEscrowTokenFacet.json index 94c219396..5adf3d767 100644 --- a/abis/contracts/facets/IexecEscrowTokenFacet.json +++ b/abis/contracts/facets/IexecEscrowTokenFacet.json @@ -45,75 +45,6 @@ "name": "Approval", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Lock", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "ref", - "type": "bytes32" - } - ], - "name": "Reward", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "ref", - "type": "bytes32" - } - ], - "name": "Seize", - "type": "event" - }, { "anonymous": false, "inputs": [ @@ -139,25 +70,6 @@ "name": "Transfer", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Unlock", - "type": "event" - }, { "stateMutability": "payable", "type": "fallback" diff --git a/abis/contracts/facets/IexecPoco1Facet.json b/abis/contracts/facets/IexecPoco1Facet.json index 04119f496..e72e4b473 100644 --- a/abis/contracts/facets/IexecPoco1Facet.json +++ b/abis/contracts/facets/IexecPoco1Facet.json @@ -10,31 +10,6 @@ "name": "IncompatibleDatasetOrder", "type": "error" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, { "anonymous": false, "inputs": [ @@ -116,31 +91,6 @@ "name": "OrdersMatched", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "ref", - "type": "bytes32" - } - ], - "name": "Reward", - "type": "event" - }, { "anonymous": false, "inputs": [ @@ -160,31 +110,6 @@ "name": "SchedulerNotice", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "ref", - "type": "bytes32" - } - ], - "name": "Seize", - "type": "event" - }, { "anonymous": false, "inputs": [ @@ -210,25 +135,6 @@ "name": "Transfer", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Unlock", - "type": "event" - }, { "inputs": [ { diff --git a/abis/contracts/facets/IexecPoco2Facet.json b/abis/contracts/facets/IexecPoco2Facet.json index c5dd7eb13..e379af17d 100644 --- a/abis/contracts/facets/IexecPoco2Facet.json +++ b/abis/contracts/facets/IexecPoco2Facet.json @@ -23,31 +23,6 @@ "name": "AccurateContribution", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, { "anonymous": false, "inputs": [ diff --git a/abis/contracts/facets/IexecPocoBoostFacet.json b/abis/contracts/facets/IexecPocoBoostFacet.json index f4e8ddc06..753f46048 100644 --- a/abis/contracts/facets/IexecPocoBoostFacet.json +++ b/abis/contracts/facets/IexecPocoBoostFacet.json @@ -15,31 +15,6 @@ "name": "SafeCastOverflowedUintDowncast", "type": "error" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, { "anonymous": false, "inputs": [ diff --git a/abis/contracts/interfaces/IexecEscrowToken.json b/abis/contracts/interfaces/IexecEscrowToken.json index 9796f8cf1..be1a4f1dd 100644 --- a/abis/contracts/interfaces/IexecEscrowToken.json +++ b/abis/contracts/interfaces/IexecEscrowToken.json @@ -20,144 +20,6 @@ "name": "UnsupportedOperation", "type": "error" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Lock", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "ref", - "type": "bytes32" - } - ], - "name": "Reward", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "ref", - "type": "bytes32" - } - ], - "name": "Seize", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Unlock", - "type": "event" - }, { "stateMutability": "payable", "type": "fallback" diff --git a/abis/contracts/abstract/IexecEscrow.json b/abis/contracts/libs/EscrowLib.json similarity index 63% rename from abis/contracts/abstract/IexecEscrow.json rename to abis/contracts/libs/EscrowLib.json index 0c2a6141e..cea6073dc 100644 --- a/abis/contracts/abstract/IexecEscrow.json +++ b/abis/contracts/libs/EscrowLib.json @@ -1,29 +1,4 @@ [ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, { "anonymous": false, "inputs": [ @@ -93,31 +68,6 @@ "name": "Seize", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, { "anonymous": false, "inputs": [ diff --git a/abis/contracts/libs/StakedRlcLib.json b/abis/contracts/libs/StakedRlcLib.json new file mode 100644 index 000000000..fe1bdc880 --- /dev/null +++ b/abis/contracts/libs/StakedRlcLib.json @@ -0,0 +1,52 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + } +] diff --git a/abis/human-readable-abis/contracts/facets/IexecEscrowTokenFacet.sol/IexecEscrowTokenFacet.json b/abis/human-readable-abis/contracts/facets/IexecEscrowTokenFacet.sol/IexecEscrowTokenFacet.json index 31b0d5cc0..f267d464f 100644 --- a/abis/human-readable-abis/contracts/facets/IexecEscrowTokenFacet.sol/IexecEscrowTokenFacet.json +++ b/abis/human-readable-abis/contracts/facets/IexecEscrowTokenFacet.sol/IexecEscrowTokenFacet.json @@ -3,11 +3,7 @@ "error OperationFailed()", "error UnsupportedOperation(bytes4)", "event Approval(address indexed,address indexed,uint256)", - "event Lock(address,uint256)", - "event Reward(address,uint256,bytes32)", - "event Seize(address,uint256,bytes32)", "event Transfer(address indexed,address indexed,uint256)", - "event Unlock(address,uint256)", "function approve(address,uint256) returns (bool)", "function approveAndCall(address,uint256,bytes) returns (bool)", "function decreaseAllowance(address,uint256) returns (bool)", diff --git a/abis/human-readable-abis/contracts/facets/IexecPoco1Facet.sol/IexecPoco1Facet.json b/abis/human-readable-abis/contracts/facets/IexecPoco1Facet.sol/IexecPoco1Facet.json index 4cd2ca141..0ac7214c8 100644 --- a/abis/human-readable-abis/contracts/facets/IexecPoco1Facet.sol/IexecPoco1Facet.json +++ b/abis/human-readable-abis/contracts/facets/IexecPoco1Facet.sol/IexecPoco1Facet.json @@ -1,14 +1,10 @@ [ "error IncompatibleDatasetOrder(string)", - "event Approval(address indexed,address indexed,uint256)", "event DealSponsored(bytes32,address)", "event Lock(address,uint256)", "event OrdersMatched(bytes32,bytes32,bytes32,bytes32,bytes32,uint256)", - "event Reward(address,uint256,bytes32)", "event SchedulerNotice(address indexed,bytes32)", - "event Seize(address,uint256,bytes32)", "event Transfer(address indexed,address indexed,uint256)", - "event Unlock(address,uint256)", "function assertDatasetDealCompatibility(tuple(address,uint256,uint256,bytes32,address,address,address,bytes32,bytes),bytes32) view", "function matchOrders(tuple(address,uint256,uint256,bytes32,address,address,address,bytes32,bytes),tuple(address,uint256,uint256,bytes32,address,address,address,bytes32,bytes),tuple(address,uint256,uint256,bytes32,uint256,uint256,address,address,address,bytes32,bytes),tuple(address,uint256,address,uint256,address,uint256,address,uint256,bytes32,uint256,uint256,address,address,string,bytes32,bytes)) returns (bytes32)", "function sponsorMatchOrders(tuple(address,uint256,uint256,bytes32,address,address,address,bytes32,bytes),tuple(address,uint256,uint256,bytes32,address,address,address,bytes32,bytes),tuple(address,uint256,uint256,bytes32,uint256,uint256,address,address,address,bytes32,bytes),tuple(address,uint256,address,uint256,address,uint256,address,uint256,bytes32,uint256,uint256,address,address,string,bytes32,bytes)) returns (bytes32)", diff --git a/abis/human-readable-abis/contracts/facets/IexecPoco2Facet.sol/IexecPoco2Facet.json b/abis/human-readable-abis/contracts/facets/IexecPoco2Facet.sol/IexecPoco2Facet.json index 00476c8a4..19ef5ebb3 100644 --- a/abis/human-readable-abis/contracts/facets/IexecPoco2Facet.sol/IexecPoco2Facet.json +++ b/abis/human-readable-abis/contracts/facets/IexecPoco2Facet.sol/IexecPoco2Facet.json @@ -1,7 +1,6 @@ [ "error MathOverflowedMulDiv()", "event AccurateContribution(address indexed,bytes32 indexed)", - "event Approval(address indexed,address indexed,uint256)", "event FaultyContribution(address indexed,bytes32 indexed)", "event Lock(address,uint256)", "event Reward(address,uint256,bytes32)", diff --git a/abis/human-readable-abis/contracts/facets/IexecPocoBoostFacet.sol/IexecPocoBoostFacet.json b/abis/human-readable-abis/contracts/facets/IexecPocoBoostFacet.sol/IexecPocoBoostFacet.json index c6025282e..a9b60c326 100644 --- a/abis/human-readable-abis/contracts/facets/IexecPocoBoostFacet.sol/IexecPocoBoostFacet.json +++ b/abis/human-readable-abis/contracts/facets/IexecPocoBoostFacet.sol/IexecPocoBoostFacet.json @@ -1,6 +1,5 @@ [ "error SafeCastOverflowedUintDowncast(uint8,uint256)", - "event Approval(address indexed,address indexed,uint256)", "event DealSponsoredBoost(bytes32,address)", "event Lock(address,uint256)", "event OrdersMatched(bytes32,bytes32,bytes32,bytes32,bytes32,uint256)", diff --git a/abis/human-readable-abis/contracts/interfaces/IexecEscrowToken.sol/IexecEscrowToken.json b/abis/human-readable-abis/contracts/interfaces/IexecEscrowToken.sol/IexecEscrowToken.json index b1d2b9e51..f3fe78992 100644 --- a/abis/human-readable-abis/contracts/interfaces/IexecEscrowToken.sol/IexecEscrowToken.json +++ b/abis/human-readable-abis/contracts/interfaces/IexecEscrowToken.sol/IexecEscrowToken.json @@ -2,12 +2,6 @@ "error CallerIsNotTheRequester()", "error OperationFailed()", "error UnsupportedOperation(bytes4)", - "event Approval(address indexed,address indexed,uint256)", - "event Lock(address,uint256)", - "event Reward(address,uint256,bytes32)", - "event Seize(address,uint256,bytes32)", - "event Transfer(address indexed,address indexed,uint256)", - "event Unlock(address,uint256)", "function approve(address,uint256) returns (bool)", "function approveAndCall(address,uint256,bytes) returns (bool)", "function decreaseAllowance(address,uint256) returns (bool)", diff --git a/abis/human-readable-abis/contracts/abstract/IexecEscrow.sol/IexecEscrow.json b/abis/human-readable-abis/contracts/libs/EscrowLib.sol/EscrowLib.json similarity index 56% rename from abis/human-readable-abis/contracts/abstract/IexecEscrow.sol/IexecEscrow.json rename to abis/human-readable-abis/contracts/libs/EscrowLib.sol/EscrowLib.json index ca70d06c7..e70f2078f 100644 --- a/abis/human-readable-abis/contracts/abstract/IexecEscrow.sol/IexecEscrow.json +++ b/abis/human-readable-abis/contracts/libs/EscrowLib.sol/EscrowLib.json @@ -1,8 +1,6 @@ [ - "event Approval(address indexed,address indexed,uint256)", "event Lock(address,uint256)", "event Reward(address,uint256,bytes32)", "event Seize(address,uint256,bytes32)", - "event Transfer(address indexed,address indexed,uint256)", "event Unlock(address,uint256)" ] diff --git a/abis/human-readable-abis/contracts/libs/StakedRlcLib.sol/StakedRlcLib.json b/abis/human-readable-abis/contracts/libs/StakedRlcLib.sol/StakedRlcLib.json new file mode 100644 index 000000000..c145a777d --- /dev/null +++ b/abis/human-readable-abis/contracts/libs/StakedRlcLib.sol/StakedRlcLib.json @@ -0,0 +1,4 @@ +[ + "event Approval(address indexed,address indexed,uint256)", + "event Transfer(address indexed,address indexed,uint256)" +] diff --git a/abis/human-readable-abis/contracts/tools/testing/IexecEscrowTestContract.sol/IexecEscrowTestContract.json b/abis/human-readable-abis/contracts/tools/testing/IexecEscrowTestContract.sol/IexecEscrowTestContract.json index a52f7811a..8ba4f7fbf 100644 --- a/abis/human-readable-abis/contracts/tools/testing/IexecEscrowTestContract.sol/IexecEscrowTestContract.json +++ b/abis/human-readable-abis/contracts/tools/testing/IexecEscrowTestContract.sol/IexecEscrowTestContract.json @@ -1,5 +1,4 @@ [ - "event Approval(address indexed,address indexed,uint256)", "event Lock(address,uint256)", "event Reward(address,uint256,bytes32)", "event Seize(address,uint256,bytes32)", diff --git a/abis/human-readable-abis/contracts/tools/testing/IexecPocoBoostCompositeFacet.sol/IexecPocoBoostCompositeFacet.json b/abis/human-readable-abis/contracts/tools/testing/IexecPocoBoostCompositeFacet.sol/IexecPocoBoostCompositeFacet.json index 7570d62e0..c05089d16 100644 --- a/abis/human-readable-abis/contracts/tools/testing/IexecPocoBoostCompositeFacet.sol/IexecPocoBoostCompositeFacet.json +++ b/abis/human-readable-abis/contracts/tools/testing/IexecPocoBoostCompositeFacet.sol/IexecPocoBoostCompositeFacet.json @@ -1,6 +1,5 @@ [ "error SafeCastOverflowedUintDowncast(uint8,uint256)", - "event Approval(address indexed,address indexed,uint256)", "event DealSponsoredBoost(bytes32,address)", "event Lock(address,uint256)", "event OrdersMatched(bytes32,bytes32,bytes32,bytes32,bytes32,uint256)", diff --git a/abis/human-readable-abis/contracts/tools/testing/slither/Slither.sol/Slither.json b/abis/human-readable-abis/contracts/tools/testing/slither/Slither.sol/Slither.json index a96ed7baf..64a34952a 100644 --- a/abis/human-readable-abis/contracts/tools/testing/slither/Slither.sol/Slither.json +++ b/abis/human-readable-abis/contracts/tools/testing/slither/Slither.sol/Slither.json @@ -2,7 +2,6 @@ "error IncompatibleDatasetOrder(string)", "error MathOverflowedMulDiv()", "event AccurateContribution(address indexed,bytes32 indexed)", - "event Approval(address indexed,address indexed,uint256)", "event DealSponsored(bytes32,address)", "event FaultyContribution(address indexed,bytes32 indexed)", "event Lock(address,uint256)", diff --git a/abis/human-readable-abis/contracts/tools/testing/slither/SlitherBoost.sol/SlitherBoost.json b/abis/human-readable-abis/contracts/tools/testing/slither/SlitherBoost.sol/SlitherBoost.json index b5161b0f3..02b2f7a96 100644 --- a/abis/human-readable-abis/contracts/tools/testing/slither/SlitherBoost.sol/SlitherBoost.json +++ b/abis/human-readable-abis/contracts/tools/testing/slither/SlitherBoost.sol/SlitherBoost.json @@ -1,6 +1,5 @@ [ "error SafeCastOverflowedUintDowncast(uint8,uint256)", - "event Approval(address indexed,address indexed,uint256)", "event DealSponsoredBoost(bytes32,address)", "event Lock(address,uint256)", "event OrdersMatched(bytes32,bytes32,bytes32,bytes32,bytes32,uint256)", diff --git a/contracts/IexecInterfaceToken.sol b/contracts/IexecInterfaceToken.sol index 2d0803981..5d0a70ce5 100644 --- a/contracts/IexecInterfaceToken.sol +++ b/contracts/IexecInterfaceToken.sol @@ -7,6 +7,7 @@ import {IexecAccessorsABILegacy} from "./interfaces/IexecAccessorsABILegacy.sol" import {IexecCategoryManager} from "./interfaces/IexecCategoryManager.sol"; import {IexecConfiguration} from "./interfaces/IexecConfiguration.sol"; import {IexecConfigurationExtra} from "./interfaces/IexecConfigurationExtra.sol"; +import {IexecEscrowEvents} from "./interfaces/IexecEscrowEvents.sol"; import {IexecEscrowToken} from "./interfaces/IexecEscrowToken.sol"; import {IexecOrderManagement} from "./interfaces/IexecOrderManagement.sol"; import {IexecPoco1} from "./interfaces/IexecPoco1.sol"; @@ -34,6 +35,7 @@ interface IexecInterfaceToken is IexecCategoryManager, IexecConfiguration, IexecConfigurationExtra, + IexecEscrowEvents, IexecEscrowToken, IexecOrderManagement, IexecPoco1, diff --git a/contracts/abstract/FacetBase.sol b/contracts/abstract/FacetBase.sol index cc3b877e5..2cd15a438 100644 --- a/contracts/abstract/FacetBase.sol +++ b/contracts/abstract/FacetBase.sol @@ -13,6 +13,10 @@ import {IERC5313} from "@openzeppelin/contracts/interfaces/IERC5313.sol"; * @dev Every facet must inherit from this contract. */ abstract contract FacetBase { + // TODO move these constants to a ConstantsLib library and reference them as + // ConstantsLib. in the next PR. + // CommonLib redeclares GROUPMEMBER_PURPOSE temporarily. + // Poco - Constants uint256 internal constant CONTRIBUTION_DEADLINE_RATIO = 7; uint256 internal constant REVEAL_DEADLINE_RATIO = 2; diff --git a/contracts/abstract/IexecPocoCommon.sol b/contracts/abstract/IexecPocoCommon.sol deleted file mode 100644 index ca596aade..000000000 --- a/contracts/abstract/IexecPocoCommon.sol +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-FileCopyrightText: 2024-2025 IEXEC BLOCKCHAIN TECH -// SPDX-License-Identifier: Apache-2.0 - -pragma solidity ^0.8.0; - -import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; -import {PocoStorageLib} from "../libs/PocoStorageLib.sol"; -import {IexecLibOrders_v5} from "../libs/IexecLibOrders_v5.sol"; -import {FacetBase} from "./FacetBase.sol"; - -// TODO convert to library -abstract contract IexecPocoCommon is FacetBase { - using Math for uint256; - using IexecLibOrders_v5 for IexecLibOrders_v5.AppOrder; - using IexecLibOrders_v5 for IexecLibOrders_v5.DatasetOrder; - using IexecLibOrders_v5 for IexecLibOrders_v5.WorkerpoolOrder; - using IexecLibOrders_v5 for IexecLibOrders_v5.RequestOrder; - - /** - * @notice Internal function to compute the deal volume considering the minimum - * remaining volume across all provided orders. This ensures that the deal volume - * does not exceed the available volume of any individual order. - * - * @param appOrderVolume The volume of the app order. - * @param appOrderTypedDataHash The typed data hash of the app order. - * @param hasDataset Indicates if there is a dataset order. - * @param datasetOrderVolume The volume of the dataset order. - * @param datasetOrderTypedDataHash The typed data hash of the dataset order. - * @param workerpoolOrderVolume The volume of the workerpool order. - * @param workerpoolOrderTypedDataHash The typed data hash of the workerpool order. - * @param requestOrderVolume The volume of the request order. - * @param requestOrderTypedDataHash The typed data hash of the request order. - * @return The minimum volume available across all orders. - */ - function _computeDealVolume( - uint256 appOrderVolume, - bytes32 appOrderTypedDataHash, - bool hasDataset, - uint256 datasetOrderVolume, - bytes32 datasetOrderTypedDataHash, - uint256 workerpoolOrderVolume, - bytes32 workerpoolOrderTypedDataHash, - uint256 requestOrderVolume, - bytes32 requestOrderTypedDataHash - ) internal view returns (uint256) { - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - return - (appOrderVolume - $.m_consumed[appOrderTypedDataHash]) - .min( - hasDataset - ? datasetOrderVolume - $.m_consumed[datasetOrderTypedDataHash] - : type(uint256).max - ) - .min(workerpoolOrderVolume - $.m_consumed[workerpoolOrderTypedDataHash]) - .min(requestOrderVolume - $.m_consumed[requestOrderTypedDataHash]); - } -} diff --git a/contracts/facets/IexecEscrowTokenFacet.sol b/contracts/facets/IexecEscrowTokenFacet.sol index cbc21929a..2944e8dea 100644 --- a/contracts/facets/IexecEscrowTokenFacet.sol +++ b/contracts/facets/IexecEscrowTokenFacet.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import {FacetBase} from "../abstract/FacetBase.sol"; -import {IexecEscrow} from "../abstract/IexecEscrow.sol"; +import {StakedRlcLib} from "../libs/StakedRlcLib.sol"; import {IexecEscrowToken} from "../interfaces/IexecEscrowToken.sol"; import {IexecTokenSpender} from "../interfaces/IexecTokenSpender.sol"; import {IexecPoco1} from "../interfaces/IexecPoco1.sol"; @@ -23,7 +23,8 @@ import {PocoStorageLib} from "../libs/PocoStorageLib.sol"; * RLC, and the ERC-20 methods move it between accounts. The balance moves of the * escrow itself (lock, unlock, reward, seize) run over the same ledger. */ -contract IexecEscrowTokenFacet is IexecEscrowToken, IexecTokenSpender, IexecEscrow { +// TODO rename to IexecEscrowFacet +contract IexecEscrowTokenFacet is IexecEscrowToken, IexecTokenSpender, FacetBase { /*************************************************************************** * Deposit and withdraw functions * ***************************************************************************/ @@ -37,13 +38,13 @@ contract IexecEscrowTokenFacet is IexecEscrowToken, IexecTokenSpender, IexecEscr function deposit(uint256 amount) external override returns (bool) { _deposit(_msgSender(), amount); - _mint(_msgSender(), amount); + StakedRlcLib.mint(_msgSender(), amount); return true; } function depositFor(uint256 amount, address target) external override returns (bool) { _deposit(_msgSender(), amount); - _mint(target, amount); + StakedRlcLib.mint(target, amount); return true; } @@ -54,19 +55,19 @@ contract IexecEscrowTokenFacet is IexecEscrowToken, IexecTokenSpender, IexecEscr require(amounts.length == targets.length, "invalid-array-length"); for (uint i = 0; i < amounts.length; ++i) { _deposit(_msgSender(), amounts[i]); - _mint(targets[i], amounts[i]); + StakedRlcLib.mint(targets[i], amounts[i]); } return true; } function withdraw(uint256 amount) external override returns (bool) { - _burn(_msgSender(), amount); + StakedRlcLib.burn(_msgSender(), amount); _withdraw(_msgSender(), amount); return true; } function withdrawTo(uint256 amount, address target) external override returns (bool) { - _burn(_msgSender(), amount); + StakedRlcLib.burn(_msgSender(), amount); _withdraw(target, amount); return true; } @@ -74,7 +75,7 @@ contract IexecEscrowTokenFacet is IexecEscrowToken, IexecTokenSpender, IexecEscr function recover() external override onlyOwner returns (uint256) { PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); uint256 delta = $.m_baseToken.balanceOf(address(this)) - $.m_totalSupply; - _mint(owner(), delta); + StakedRlcLib.mint(owner(), delta); return delta; } @@ -140,7 +141,7 @@ contract IexecEscrowTokenFacet is IexecEscrowToken, IexecTokenSpender, IexecEscr PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); require(token == address($.m_baseToken), "wrong-token"); _deposit(sender, amount); - _mint(sender, amount); + StakedRlcLib.mint(sender, amount); if (data.length > 0) { _executeOperation(sender, data); } @@ -216,12 +217,12 @@ contract IexecEscrowTokenFacet is IexecEscrowToken, IexecTokenSpender, IexecEscr ***************************************************************************/ function transfer(address recipient, uint256 amount) external override returns (bool) { - _transfer(_msgSender(), recipient, amount); + StakedRlcLib.transfer(_msgSender(), recipient, amount); return true; } function approve(address spender, uint256 value) external override returns (bool) { - _approve(_msgSender(), spender, value); + StakedRlcLib.approve(_msgSender(), spender, value); return true; } @@ -230,7 +231,7 @@ contract IexecEscrowTokenFacet is IexecEscrowToken, IexecTokenSpender, IexecEscr uint256 value, bytes calldata extraData ) external override returns (bool) { - _approve(_msgSender(), spender, value); + StakedRlcLib.approve(_msgSender(), spender, value); require( IexecTokenSpender(spender).receiveApproval( _msgSender(), @@ -249,8 +250,8 @@ contract IexecEscrowTokenFacet is IexecEscrowToken, IexecTokenSpender, IexecEscr uint256 amount ) external override returns (bool) { PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - _transfer(sender, recipient, amount); - _approve(sender, _msgSender(), $.m_allowances[sender][_msgSender()] - amount); + StakedRlcLib.transfer(sender, recipient, amount); + StakedRlcLib.approve(sender, _msgSender(), $.m_allowances[sender][_msgSender()] - amount); return true; } @@ -259,7 +260,11 @@ contract IexecEscrowTokenFacet is IexecEscrowToken, IexecTokenSpender, IexecEscr uint256 addedValue ) external override returns (bool) { PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - _approve(_msgSender(), spender, $.m_allowances[_msgSender()][spender] + addedValue); + StakedRlcLib.approve( + _msgSender(), + spender, + $.m_allowances[_msgSender()][spender] + addedValue + ); return true; } @@ -268,31 +273,11 @@ contract IexecEscrowTokenFacet is IexecEscrowToken, IexecTokenSpender, IexecEscr uint256 subtractedValue ) external override returns (bool) { PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - _approve(_msgSender(), spender, $.m_allowances[_msgSender()][spender] - subtractedValue); + StakedRlcLib.approve( + _msgSender(), + spender, + $.m_allowances[_msgSender()][spender] - subtractedValue + ); return true; } - - function _mint(address account, uint256 amount) internal { - require(account != address(0), "ERC20: mint to the zero address"); - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - $.m_totalSupply = $.m_totalSupply + amount; - $.m_balances[account] = $.m_balances[account] + amount; - emit Transfer(address(0), account, amount); - } - - function _burn(address account, uint256 amount) internal { - require(account != address(0), "ERC20: burn from the zero address"); - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - $.m_totalSupply = $.m_totalSupply - amount; - $.m_balances[account] = $.m_balances[account] - amount; - emit Transfer(account, address(0), amount); - } - - function _approve(address owner, address spender, uint256 amount) internal { - require(owner != address(0), "ERC20: approve from the zero address"); - require(spender != address(0), "ERC20: approve to the zero address"); - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - $.m_allowances[owner][spender] = amount; - emit Approval(owner, spender, amount); - } } diff --git a/contracts/facets/IexecOrderManagementFacet.sol b/contracts/facets/IexecOrderManagementFacet.sol index aac00b7da..d1249f3dc 100644 --- a/contracts/facets/IexecOrderManagementFacet.sol +++ b/contracts/facets/IexecOrderManagementFacet.sol @@ -4,12 +4,13 @@ pragma solidity ^0.8.0; import {IERC5313} from "@openzeppelin/contracts/interfaces/IERC5313.sol"; -import {SignatureVerifier} from "../abstract/SignatureVerifier.sol"; +import {FacetBase} from "../abstract/FacetBase.sol"; +import {CommonLib} from "../libs/CommonLib.sol"; import {IexecOrderManagement} from "../interfaces/IexecOrderManagement.sol"; import {PocoStorageLib} from "../libs/PocoStorageLib.sol"; import {IexecLibOrders_v5} from "../libs/IexecLibOrders_v5.sol"; -contract IexecOrderManagementFacet is IexecOrderManagement, SignatureVerifier { +contract IexecOrderManagementFacet is IexecOrderManagement, FacetBase { using IexecLibOrders_v5 for IexecLibOrders_v5.AppOrder; using IexecLibOrders_v5 for IexecLibOrders_v5.DatasetOrder; using IexecLibOrders_v5 for IexecLibOrders_v5.WorkerpoolOrder; @@ -29,15 +30,15 @@ contract IexecOrderManagementFacet is IexecOrderManagement, SignatureVerifier { address owner = IERC5313(_apporderoperation.order.app).owner(); require( owner == _msgSender() || - _verifySignature( + CommonLib.verifySignature( owner, - _toTypedDataHash(_apporderoperation.hash()), + CommonLib.toTypedDataHash(_apporderoperation.hash()), _apporderoperation.sign ), "invalid-sender-or-signature" ); - bytes32 apporderHash = _toTypedDataHash(_apporderoperation.order.hash()); + bytes32 apporderHash = CommonLib.toTypedDataHash(_apporderoperation.order.hash()); if (_apporderoperation.operation == IexecLibOrders_v5.OrderOperationEnum.SIGN) { $.m_presigned[apporderHash] = owner; emit SignedAppOrder(apporderHash); @@ -54,15 +55,15 @@ contract IexecOrderManagementFacet is IexecOrderManagement, SignatureVerifier { address owner = IERC5313(_datasetorderoperation.order.dataset).owner(); require( owner == _msgSender() || - _verifySignature( + CommonLib.verifySignature( owner, - _toTypedDataHash(_datasetorderoperation.hash()), + CommonLib.toTypedDataHash(_datasetorderoperation.hash()), _datasetorderoperation.sign ), "invalid-sender-or-signature" ); - bytes32 datasetorderHash = _toTypedDataHash(_datasetorderoperation.order.hash()); + bytes32 datasetorderHash = CommonLib.toTypedDataHash(_datasetorderoperation.order.hash()); if (_datasetorderoperation.operation == IexecLibOrders_v5.OrderOperationEnum.SIGN) { $.m_presigned[datasetorderHash] = owner; emit SignedDatasetOrder(datasetorderHash); @@ -79,15 +80,17 @@ contract IexecOrderManagementFacet is IexecOrderManagement, SignatureVerifier { address owner = IERC5313(_workerpoolorderoperation.order.workerpool).owner(); require( owner == _msgSender() || - _verifySignature( + CommonLib.verifySignature( owner, - _toTypedDataHash(_workerpoolorderoperation.hash()), + CommonLib.toTypedDataHash(_workerpoolorderoperation.hash()), _workerpoolorderoperation.sign ), "invalid-sender-or-signature" ); - bytes32 workerpoolorderHash = _toTypedDataHash(_workerpoolorderoperation.order.hash()); + bytes32 workerpoolorderHash = CommonLib.toTypedDataHash( + _workerpoolorderoperation.order.hash() + ); if (_workerpoolorderoperation.operation == IexecLibOrders_v5.OrderOperationEnum.SIGN) { $.m_presigned[workerpoolorderHash] = owner; emit SignedWorkerpoolOrder(workerpoolorderHash); @@ -106,15 +109,15 @@ contract IexecOrderManagementFacet is IexecOrderManagement, SignatureVerifier { address owner = _requestorderoperation.order.requester; require( owner == _msgSender() || - _verifySignature( + CommonLib.verifySignature( owner, - _toTypedDataHash(_requestorderoperation.hash()), + CommonLib.toTypedDataHash(_requestorderoperation.hash()), _requestorderoperation.sign ), "invalid-sender-or-signature" ); - bytes32 requestorderHash = _toTypedDataHash(_requestorderoperation.order.hash()); + bytes32 requestorderHash = CommonLib.toTypedDataHash(_requestorderoperation.order.hash()); if (_requestorderoperation.operation == IexecLibOrders_v5.OrderOperationEnum.SIGN) { $.m_presigned[requestorderHash] = owner; emit SignedRequestOrder(requestorderHash); diff --git a/contracts/facets/IexecPoco1Facet.sol b/contracts/facets/IexecPoco1Facet.sol index fc49c5244..03e4d9566 100644 --- a/contracts/facets/IexecPoco1Facet.sol +++ b/contracts/facets/IexecPoco1Facet.sol @@ -11,9 +11,9 @@ import {IWorkerpool} from "../registries/workerpools/IWorkerpool.v8.sol"; import {PocoStorageLib} from "../libs/PocoStorageLib.sol"; import {IexecPoco1} from "../interfaces/IexecPoco1.sol"; import {IexecPoco1Errors} from "../interfaces/IexecPoco1Errors.sol"; -import {IexecEscrow} from "../abstract/IexecEscrow.sol"; -import {IexecPocoCommon} from "../abstract/IexecPocoCommon.sol"; -import {SignatureVerifier} from "../abstract/SignatureVerifier.sol"; +import {FacetBase} from "../abstract/FacetBase.sol"; +import {EscrowLib} from "../libs/EscrowLib.sol"; +import {CommonLib} from "../libs/CommonLib.sol"; struct Matching { bytes32 apporderHash; @@ -26,13 +26,7 @@ struct Matching { bool hasDataset; } -contract IexecPoco1Facet is - IexecPoco1, - IexecPoco1Errors, - IexecEscrow, - SignatureVerifier, - IexecPocoCommon -{ +contract IexecPoco1Facet is IexecPoco1, IexecPoco1Errors, FacetBase { using Math for uint256; using IexecLibOrders_v5 for IexecLibOrders_v5.AppOrder; using IexecLibOrders_v5 for IexecLibOrders_v5.DatasetOrder; @@ -47,14 +41,14 @@ contract IexecPoco1Facet is bytes32 _hash, bytes calldata _signature ) external view override returns (bool) { - return _verifySignature(_identity, _hash, _signature); + return CommonLib.verifySignature(_identity, _hash, _signature); } function verifyPresignature( address _identity, bytes32 _hash ) external view override returns (bool) { - return _verifyPresignature(_identity, _hash); + return CommonLib.verifyPresignature(_identity, _hash); } function verifyPresignatureOrSignature( @@ -62,7 +56,7 @@ contract IexecPoco1Facet is bytes32 _hash, bytes calldata _signature ) external view override returns (bool) { - return _verifySignatureOrPresignature(_identity, _hash, _signature); + return CommonLib.verifySignatureOrPresignature(_identity, _hash, _signature); } /** @@ -85,7 +79,7 @@ contract IexecPoco1Facet is bytes32 dealId ) external view override { PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - bytes32 datasetOrderHash = _toTypedDataHash(datasetOrder.hash()); + bytes32 datasetOrderHash = CommonLib.toTypedDataHash(datasetOrder.hash()); // Check if dataset order is not revoked or fully consumed. // Note: This should be the first check because it is the most important // and the most likely to occur (users revoking their dataset orders). @@ -94,7 +88,13 @@ contract IexecPoco1Facet is } // Check dataset order signature (including presign and ERC-1271). address datasetOwner = IERC5313(datasetOrder.dataset).owner(); - if (!_verifySignatureOrPresignature(datasetOwner, datasetOrderHash, datasetOrder.sign)) { + if ( + !CommonLib.verifySignatureOrPresignature( + datasetOwner, + datasetOrderHash, + datasetOrder.sign + ) + ) { revert IncompatibleDatasetOrder("Invalid dataset order signature"); } // The deal should exist. @@ -107,12 +107,14 @@ contract IexecPoco1Facet is revert IncompatibleDatasetOrder("Deal already has a dataset"); } // The deal's app should be allowed by order restriction. - if (!_isAccountAuthorizedByRestriction(datasetOrder.apprestrict, deal.app.pointer)) { + if ( + !CommonLib.isAccountAuthorizedByRestriction(datasetOrder.apprestrict, deal.app.pointer) + ) { revert IncompatibleDatasetOrder("App restriction not satisfied"); } // The deal's workerpool should be allowed by order restriction. if ( - !_isAccountAuthorizedByRestriction( + !CommonLib.isAccountAuthorizedByRestriction( datasetOrder.workerpoolrestrict, deal.workerpool.pointer ) @@ -120,7 +122,12 @@ contract IexecPoco1Facet is revert IncompatibleDatasetOrder("Workerpool restriction not satisfied"); } // The deal's requester should be allowed by order restriction. - if (!_isAccountAuthorizedByRestriction(datasetOrder.requesterrestrict, deal.requester)) { + if ( + !CommonLib.isAccountAuthorizedByRestriction( + datasetOrder.requesterrestrict, + deal.requester + ) + ) { revert IncompatibleDatasetOrder("Requester restriction not satisfied"); } // The deal's tag should include all activated tag bits of the dataset order. @@ -253,58 +260,64 @@ contract IexecPoco1Facet is require(_requestorder.app == _apporder.app, "iExecV5-matchOrders-0x10"); require(_requestorder.dataset == _datasetorder.dataset, "iExecV5-matchOrders-0x11"); require( - _isAccountAuthorizedByRestriction( + CommonLib.isAccountAuthorizedByRestriction( _requestorder.workerpool, _workerpoolorder.workerpool ), "iExecV5-matchOrders-0x12" ); // requestorder.workerpool is a restriction require( - _isAccountAuthorizedByRestriction(_apporder.datasetrestrict, _datasetorder.dataset), + CommonLib.isAccountAuthorizedByRestriction( + _apporder.datasetrestrict, + _datasetorder.dataset + ), "iExecV5-matchOrders-0x13" ); require( - _isAccountAuthorizedByRestriction( + CommonLib.isAccountAuthorizedByRestriction( _apporder.workerpoolrestrict, _workerpoolorder.workerpool ), "iExecV5-matchOrders-0x14" ); require( - _isAccountAuthorizedByRestriction(_apporder.requesterrestrict, _requestorder.requester), + CommonLib.isAccountAuthorizedByRestriction( + _apporder.requesterrestrict, + _requestorder.requester + ), "iExecV5-matchOrders-0x15" ); require( - _isAccountAuthorizedByRestriction(_datasetorder.apprestrict, _apporder.app), + CommonLib.isAccountAuthorizedByRestriction(_datasetorder.apprestrict, _apporder.app), "iExecV5-matchOrders-0x16" ); require( - _isAccountAuthorizedByRestriction( + CommonLib.isAccountAuthorizedByRestriction( _datasetorder.workerpoolrestrict, _workerpoolorder.workerpool ), "iExecV5-matchOrders-0x17" ); require( - _isAccountAuthorizedByRestriction( + CommonLib.isAccountAuthorizedByRestriction( _datasetorder.requesterrestrict, _requestorder.requester ), "iExecV5-matchOrders-0x18" ); require( - _isAccountAuthorizedByRestriction(_workerpoolorder.apprestrict, _apporder.app), + CommonLib.isAccountAuthorizedByRestriction(_workerpoolorder.apprestrict, _apporder.app), "iExecV5-matchOrders-0x19" ); require( - _isAccountAuthorizedByRestriction( + CommonLib.isAccountAuthorizedByRestriction( _workerpoolorder.datasetrestrict, _datasetorder.dataset ), "iExecV5-matchOrders-0x1a" ); require( - _isAccountAuthorizedByRestriction( + CommonLib.isAccountAuthorizedByRestriction( _workerpoolorder.requesterrestrict, _requestorder.requester ), @@ -319,19 +332,19 @@ contract IexecPoco1Facet is ids.hasDataset = _datasetorder.dataset != address(0); // app - ids.apporderHash = _toTypedDataHash(_apporder.hash()); + ids.apporderHash = CommonLib.toTypedDataHash(_apporder.hash()); ids.appOwner = IERC5313(_apporder.app).owner(); require($.m_appregistry.isRegistered(_apporder.app), "iExecV5-matchOrders-0x20"); require( - _verifySignatureOrPresignature(ids.appOwner, ids.apporderHash, _apporder.sign), + CommonLib.verifySignatureOrPresignature(ids.appOwner, ids.apporderHash, _apporder.sign), "iExecV5-matchOrders-0x21" ); // dataset if (ids.hasDataset) { // only check if dataset is enabled - ids.datasetorderHash = _toTypedDataHash(_datasetorder.hash()); + ids.datasetorderHash = CommonLib.toTypedDataHash(_datasetorder.hash()); ids.datasetOwner = IERC5313(_datasetorder.dataset).owner(); require( @@ -339,7 +352,7 @@ contract IexecPoco1Facet is "iExecV5-matchOrders-0x30" ); require( - _verifySignatureOrPresignature( + CommonLib.verifySignatureOrPresignature( ids.datasetOwner, ids.datasetorderHash, _datasetorder.sign @@ -349,7 +362,7 @@ contract IexecPoco1Facet is } // workerpool - ids.workerpoolorderHash = _toTypedDataHash(_workerpoolorder.hash()); + ids.workerpoolorderHash = CommonLib.toTypedDataHash(_workerpoolorder.hash()); ids.workerpoolOwner = IERC5313(_workerpoolorder.workerpool).owner(); require( @@ -357,7 +370,7 @@ contract IexecPoco1Facet is "iExecV5-matchOrders-0x40" ); require( - _verifySignatureOrPresignature( + CommonLib.verifySignatureOrPresignature( ids.workerpoolOwner, ids.workerpoolorderHash, _workerpoolorder.sign @@ -366,9 +379,9 @@ contract IexecPoco1Facet is ); // request - ids.requestorderHash = _toTypedDataHash(_requestorder.hash()); + ids.requestorderHash = CommonLib.toTypedDataHash(_requestorder.hash()); require( - _verifySignatureOrPresignature( + CommonLib.verifySignatureOrPresignature( _requestorder.requester, ids.requestorderHash, _requestorder.sign @@ -379,7 +392,7 @@ contract IexecPoco1Facet is /** * Check availability */ - uint256 volume = _computeDealVolume( + uint256 volume = CommonLib.computeDealVolume( _apporder.volume, ids.apporderHash, ids.hasDataset, @@ -443,9 +456,12 @@ contract IexecPoco1Facet is /** * Lock */ - lock(_sponsor, (deal.app.price + deal.dataset.price + deal.workerpool.price) * volume); + EscrowLib.lock( + _sponsor, + (deal.app.price + deal.dataset.price + deal.workerpool.price) * volume + ); //slither-disable-next-line divide-before-multiply - lock( + EscrowLib.lock( deal.workerpool.owner, ((deal.workerpool.price * WORKERPOOL_STAKE_RATIO) / 100) * volume // ORDER IS IMPORTANT HERE! ); diff --git a/contracts/facets/IexecPoco2Facet.sol b/contracts/facets/IexecPoco2Facet.sol index 9028615e9..6071f99c3 100644 --- a/contracts/facets/IexecPoco2Facet.sol +++ b/contracts/facets/IexecPoco2Facet.sol @@ -9,10 +9,11 @@ import {IOracleConsumer} from "../external/interfaces/IOracleConsumer.sol"; import {IexecLibCore_v5} from "../libs/IexecLibCore_v5.sol"; import {IexecLibOrders_v5} from "../libs/IexecLibOrders_v5.sol"; import {IexecPoco2} from "../interfaces/IexecPoco2.sol"; -import {IexecEscrow} from "../abstract/IexecEscrow.sol"; -import {SignatureVerifier} from "../abstract/SignatureVerifier.sol"; +import {FacetBase} from "../abstract/FacetBase.sol"; +import {EscrowLib} from "../libs/EscrowLib.sol"; +import {CommonLib} from "../libs/CommonLib.sol"; -contract IexecPoco2Facet is IexecPoco2, IexecEscrow, SignatureVerifier { +contract IexecPoco2Facet is IexecPoco2, FacetBase { modifier onlyScheduler(bytes32 _taskId) { PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); require(_msgSender() == $.m_deals[$.m_tasks[_taskId].dealid].workerpool.owner); @@ -30,17 +31,17 @@ contract IexecPoco2Facet is IexecPoco2, IexecEscrow, SignatureVerifier { uint256 poolstake = (deal.workerpool.price * WORKERPOOL_STAKE_RATIO) / 100; // Seize the payer of the task - seize(deal.sponsor, taskPrice, _taskid); + EscrowLib.seize(deal.sponsor, taskPrice, _taskid); // dapp reward if (deal.app.price > 0) { - reward(deal.app.owner, deal.app.price, _taskid); + EscrowLib.reward(deal.app.owner, deal.app.price, _taskid); } // data reward if (deal.dataset.price > 0 && deal.dataset.pointer != address(0)) { - reward(deal.dataset.owner, deal.dataset.price, _taskid); + EscrowLib.reward(deal.dataset.owner, deal.dataset.price, _taskid); } // unlock pool stake - unlock(deal.workerpool.owner, poolstake); + EscrowLib.unlock(deal.workerpool.owner, poolstake); // pool reward performed by consensus manager // Retrieve part of the kitty @@ -48,8 +49,8 @@ contract IexecPoco2Facet is IexecPoco2, IexecEscrow, SignatureVerifier { if (kitty > 0) { // Get a fraction of the kitty where KITTY_MIN <= fraction <= kitty kitty = Math.min(Math.max((kitty * KITTY_RATIO) / 100, KITTY_MIN), kitty); - seize(KITTY_ADDRESS, kitty, _taskid); - reward(deal.workerpool.owner, kitty, _taskid); + EscrowLib.seize(KITTY_ADDRESS, kitty, _taskid); + EscrowLib.reward(deal.workerpool.owner, kitty, _taskid); } } @@ -60,10 +61,10 @@ contract IexecPoco2Facet is IexecPoco2, IexecEscrow, SignatureVerifier { uint256 taskPrice = deal.app.price + deal.dataset.price + deal.workerpool.price; uint256 poolstake = (deal.workerpool.price * WORKERPOOL_STAKE_RATIO) / 100; - unlock(deal.sponsor, taskPrice); // Refund the payer of the task - seize(deal.workerpool.owner, poolstake, _taskid); + EscrowLib.unlock(deal.sponsor, taskPrice); // Refund the payer of the task + EscrowLib.seize(deal.workerpool.owner, poolstake, _taskid); // Reward kitty and lock value on it. - rewardAndLock(KITTY_ADDRESS, poolstake, _taskid); // → Kitty / Burn + EscrowLib.rewardAndLock(KITTY_ADDRESS, poolstake, _taskid); // → Kitty / Burn } /*************************************************************************** @@ -119,7 +120,7 @@ contract IexecPoco2Facet is IexecPoco2, IexecEscrow, SignatureVerifier { // Check that the worker + taskid + enclave combo is authorized to contribute (scheduler signature) require( - _verifySignatureOfEthSignedMessage( + CommonLib.verifySignatureOfEthSignedMessage( (_enclaveChallenge != address(0) && $.m_teebroker != address(0)) ? $.m_teebroker : deal.workerpool.owner, @@ -131,7 +132,7 @@ contract IexecPoco2Facet is IexecPoco2, IexecEscrow, SignatureVerifier { // Check enclave signature require( _enclaveChallenge == address(0) || - _verifySignatureOfEthSignedMessage( + CommonLib.verifySignatureOfEthSignedMessage( _enclaveChallenge, abi.encodePacked(_resultHash, _resultSeal), _enclaveSign @@ -146,7 +147,7 @@ contract IexecPoco2Facet is IexecPoco2, IexecEscrow, SignatureVerifier { task.contributors.push(_msgSender()); // Lock contribution. - lock(_msgSender(), deal.workerStake); + EscrowLib.lock(_msgSender(), deal.workerStake); emit TaskContribute(_taskid, _msgSender(), _resultHash); @@ -206,7 +207,7 @@ contract IexecPoco2Facet is IexecPoco2, IexecEscrow, SignatureVerifier { // Check that the worker + taskid + enclave combo is authorized to contribute (scheduler signature) require( - _verifySignatureOfEthSignedMessage( + CommonLib.verifySignatureOfEthSignedMessage( (_enclaveChallenge != address(0) && $.m_teebroker != address(0)) ? $.m_teebroker : deal.workerpool.owner, @@ -218,7 +219,7 @@ contract IexecPoco2Facet is IexecPoco2, IexecEscrow, SignatureVerifier { // Check enclave signature require( _enclaveChallenge == address(0) || - _verifySignatureOfEthSignedMessage( + CommonLib.verifySignatureOfEthSignedMessage( _enclaveChallenge, abi.encodePacked(resultHash, resultSeal), _enclaveSign @@ -359,7 +360,7 @@ contract IexecPoco2Facet is IexecPoco2, IexecEscrow, SignatureVerifier { for (uint256 i = 0; i < task.contributors.length; ++i) { address worker = task.contributors[i]; // Unlock contribution - unlock(worker, $.m_deals[task.dealid].workerStake); + EscrowLib.unlock(worker, $.m_deals[task.dealid].workerStake); } emit TaskClaimed(_taskid); @@ -447,9 +448,9 @@ contract IexecPoco2Facet is IexecPoco2, IexecEscrow, SignatureVerifier { totalReward = totalReward - workerReward; // Unlock contribution - unlock(worker, deal.workerStake); + EscrowLib.unlock(worker, deal.workerStake); // Reward for contribution - reward(worker, workerReward, _taskid); + EscrowLib.reward(worker, workerReward, _taskid); // Only reward if replication happened if (task.contributors.length > 1) { @@ -466,7 +467,7 @@ contract IexecPoco2Facet is IexecPoco2, IexecEscrow, SignatureVerifier { else { // No Reward // Seize contribution - seize(worker, deal.workerStake, _taskid); + EscrowLib.seize(worker, deal.workerStake, _taskid); // Always punish bad contributors { @@ -483,7 +484,7 @@ contract IexecPoco2Facet is IexecPoco2, IexecEscrow, SignatureVerifier { } // totalReward now contains the scheduler share // Reward for scheduling. - reward(deal.workerpool.owner, totalReward, _taskid); + EscrowLib.reward(deal.workerpool.owner, totalReward, _taskid); } /* @@ -498,9 +499,9 @@ contract IexecPoco2Facet is IexecPoco2, IexecEscrow, SignatureVerifier { uint256 workerReward = (deal.workerpool.price * (100 - deal.schedulerRewardRatio)) / 100; uint256 schedulerReward = deal.workerpool.price - workerReward; // Reward for contribution. - reward(_msgSender(), workerReward, _taskid); + EscrowLib.reward(_msgSender(), workerReward, _taskid); // Reward for scheduling. - reward(deal.workerpool.owner, schedulerReward, _taskid); + EscrowLib.reward(deal.workerpool.owner, schedulerReward, _taskid); } /** diff --git a/contracts/facets/IexecPocoAccessorsFacet.sol b/contracts/facets/IexecPocoAccessorsFacet.sol index 1a8a5b40e..f4c0bc5fc 100644 --- a/contracts/facets/IexecPocoAccessorsFacet.sol +++ b/contracts/facets/IexecPocoAccessorsFacet.sol @@ -11,13 +11,13 @@ import {IApp} from "../registries/apps/IApp.v8.sol"; import {IWorkerpool} from "../registries/workerpools/IWorkerpool.v8.sol"; import {IexecPocoAccessors} from "../interfaces/IexecPocoAccessors.sol"; import {IRegistry} from "../registries/IRegistry.sol"; -import {IexecPocoCommon} from "../abstract/IexecPocoCommon.sol"; -import {SignatureVerifier} from "../abstract/SignatureVerifier.sol"; +import {FacetBase} from "../abstract/FacetBase.sol"; +import {CommonLib} from "../libs/CommonLib.sol"; /** * @title Getters contract for PoCo facets. */ -contract IexecPocoAccessorsFacet is IexecPocoAccessors, SignatureVerifier, IexecPocoCommon { +contract IexecPocoAccessorsFacet is IexecPocoAccessors, FacetBase { using IexecLibOrders_v5 for IexecLibOrders_v5.AppOrder; using IexecLibOrders_v5 for IexecLibOrders_v5.DatasetOrder; using IexecLibOrders_v5 for IexecLibOrders_v5.WorkerpoolOrder; @@ -60,16 +60,16 @@ contract IexecPocoAccessorsFacet is IexecPocoAccessors, SignatureVerifier, Iexec IexecLibOrders_v5.RequestOrder calldata requestOrder ) external view override returns (uint256) { return - _computeDealVolume( + CommonLib.computeDealVolume( appOrder.volume, - _toTypedDataHash(appOrder.hash()), + CommonLib.toTypedDataHash(appOrder.hash()), datasetOrder.dataset != address(0), datasetOrder.volume, - _toTypedDataHash(datasetOrder.hash()), + CommonLib.toTypedDataHash(datasetOrder.hash()), workerpoolOrder.volume, - _toTypedDataHash(workerpoolOrder.hash()), + CommonLib.toTypedDataHash(workerpoolOrder.hash()), requestOrder.volume, - _toTypedDataHash(requestOrder.hash()) + CommonLib.toTypedDataHash(requestOrder.hash()) ); } diff --git a/contracts/facets/IexecPocoBoostFacet.sol b/contracts/facets/IexecPocoBoostFacet.sol index e7b5d5b10..e43fa35be 100644 --- a/contracts/facets/IexecPocoBoostFacet.sol +++ b/contracts/facets/IexecPocoBoostFacet.sol @@ -14,10 +14,10 @@ import {IexecLibCore_v5} from "../libs/IexecLibCore_v5.sol"; import {IexecLibOrders_v5} from "../libs/IexecLibOrders_v5.sol"; import {IWorkerpool} from "../registries/workerpools/IWorkerpool.v8.sol"; import {IexecPocoBoost} from "../interfaces/IexecPocoBoost.sol"; -import {IexecEscrow} from "../abstract/IexecEscrow.sol"; -import {IexecPocoCommon} from "../abstract/IexecPocoCommon.sol"; +import {FacetBase} from "../abstract/FacetBase.sol"; +import {EscrowLib} from "../libs/EscrowLib.sol"; import {PocoStorageLib} from "../libs/PocoStorageLib.sol"; -import {SignatureVerifier} from "../abstract/SignatureVerifier.sol"; +import {CommonLib} from "../libs/CommonLib.sol"; // // Not deployed yet! @@ -27,7 +27,7 @@ import {SignatureVerifier} from "../abstract/SignatureVerifier.sol"; * @title PoCo Boost to reduce latency and increase throughput of deals. * @notice Works for deals with requested trust = 0. */ -contract IexecPocoBoostFacet is IexecPocoBoost, IexecEscrow, SignatureVerifier, IexecPocoCommon { +contract IexecPocoBoostFacet is IexecPocoBoost, FacetBase { using ECDSA for bytes32; using MessageHashUtils for bytes32; using Math for uint256; @@ -161,52 +161,55 @@ contract IexecPocoBoostFacet is IexecPocoBoost, IexecEscrow, SignatureVerifier, // Check all possible restrictions. address workerpool = workerpoolOrder.workerpool; require( - _isAccountAuthorizedByRestriction(requestOrder.workerpool, workerpool), + CommonLib.isAccountAuthorizedByRestriction(requestOrder.workerpool, workerpool), "PocoBoost: Workerpool restricted by request order" ); require( - _isAccountAuthorizedByRestriction(appOrder.datasetrestrict, dataset), + CommonLib.isAccountAuthorizedByRestriction(appOrder.datasetrestrict, dataset), "PocoBoost: Dataset restricted by app order" ); require( - _isAccountAuthorizedByRestriction(appOrder.workerpoolrestrict, workerpool), + CommonLib.isAccountAuthorizedByRestriction(appOrder.workerpoolrestrict, workerpool), "PocoBoost: Workerpool restricted by app order" ); address requester = requestOrder.requester; require( - _isAccountAuthorizedByRestriction(appOrder.requesterrestrict, requester), + CommonLib.isAccountAuthorizedByRestriction(appOrder.requesterrestrict, requester), "PocoBoost: Requester restricted by app order" ); require( - _isAccountAuthorizedByRestriction(datasetOrder.apprestrict, app), + CommonLib.isAccountAuthorizedByRestriction(datasetOrder.apprestrict, app), "PocoBoost: App restricted by dataset order" ); require( - _isAccountAuthorizedByRestriction(datasetOrder.workerpoolrestrict, workerpool), + CommonLib.isAccountAuthorizedByRestriction(datasetOrder.workerpoolrestrict, workerpool), "PocoBoost: Workerpool restricted by dataset order" ); require( - _isAccountAuthorizedByRestriction(datasetOrder.requesterrestrict, requester), + CommonLib.isAccountAuthorizedByRestriction(datasetOrder.requesterrestrict, requester), "PocoBoost: Requester restricted by dataset order" ); require( - _isAccountAuthorizedByRestriction(workerpoolOrder.apprestrict, app), + CommonLib.isAccountAuthorizedByRestriction(workerpoolOrder.apprestrict, app), "PocoBoost: App restricted by workerpool order" ); require( - _isAccountAuthorizedByRestriction(workerpoolOrder.datasetrestrict, dataset), + CommonLib.isAccountAuthorizedByRestriction(workerpoolOrder.datasetrestrict, dataset), "PocoBoost: Dataset restricted by workerpool order" ); require( - _isAccountAuthorizedByRestriction(workerpoolOrder.requesterrestrict, requester), + CommonLib.isAccountAuthorizedByRestriction( + workerpoolOrder.requesterrestrict, + requester + ), "PocoBoost: Requester restricted by workerpool order" ); // Check ownership, registration, and signatures for app and dataset. require($.m_appregistry.isRegistered(app), "PocoBoost: App not registered"); address appOwner = IERC5313(app).owner(); - bytes32 appOrderTypedDataHash = _toTypedDataHash(appOrder.hash()); + bytes32 appOrderTypedDataHash = CommonLib.toTypedDataHash(appOrder.hash()); require( - _verifySignatureOrPresignature(appOwner, appOrderTypedDataHash, appOrder.sign), + CommonLib.verifySignatureOrPresignature(appOwner, appOrderTypedDataHash, appOrder.sign), "PocoBoost: Invalid app order signature" ); bool hasDataset = dataset != address(0); @@ -215,9 +218,9 @@ contract IexecPocoBoostFacet is IexecPocoBoost, IexecEscrow, SignatureVerifier, if (hasDataset) { require($.m_datasetregistry.isRegistered(dataset), "PocoBoost: Dataset not registered"); datasetOwner = IERC5313(dataset).owner(); - datasetOrderTypedDataHash = _toTypedDataHash(datasetOrder.hash()); + datasetOrderTypedDataHash = CommonLib.toTypedDataHash(datasetOrder.hash()); require( - _verifySignatureOrPresignature( + CommonLib.verifySignatureOrPresignature( datasetOwner, datasetOrderTypedDataHash, datasetOrder.sign @@ -231,18 +234,22 @@ contract IexecPocoBoostFacet is IexecPocoBoost, IexecEscrow, SignatureVerifier, "PocoBoost: Workerpool not registered" ); address workerpoolOwner = IERC5313(workerpool).owner(); - bytes32 workerpoolOrderTypedDataHash = _toTypedDataHash(workerpoolOrder.hash()); + bytes32 workerpoolOrderTypedDataHash = CommonLib.toTypedDataHash(workerpoolOrder.hash()); require( - _verifySignatureOrPresignature( + CommonLib.verifySignatureOrPresignature( workerpoolOwner, workerpoolOrderTypedDataHash, workerpoolOrder.sign ), "PocoBoost: Invalid workerpool order signature" ); - bytes32 requestOrderTypedDataHash = _toTypedDataHash(requestOrder.hash()); + bytes32 requestOrderTypedDataHash = CommonLib.toTypedDataHash(requestOrder.hash()); require( - _verifySignatureOrPresignature(requester, requestOrderTypedDataHash, requestOrder.sign), + CommonLib.verifySignatureOrPresignature( + requester, + requestOrderTypedDataHash, + requestOrder.sign + ), "PocoBoost: Invalid request order signature" ); @@ -268,7 +275,7 @@ contract IexecPocoBoostFacet is IexecPocoBoost, IexecEscrow, SignatureVerifier, * - but trying to use as little gas as possible * - Overflows: Solidity 0.8 has built in overflow checking */ - uint256 volume = _computeDealVolume( + uint256 volume = CommonLib.computeDealVolume( appOrder.volume, appOrderTypedDataHash, hasDataset, @@ -328,12 +335,15 @@ contract IexecPocoBoostFacet is IexecPocoBoost, IexecEscrow, SignatureVerifier, $.m_consumed[workerpoolOrderTypedDataHash] = workerpoolOrderConsumed + volume; $.m_consumed[requestOrderTypedDataHash] = requestOrderConsumed + volume; // Lock deal price from sponsor balance. - lock(sponsor, (appPrice + datasetPrice + workerpoolPrice) * volume); + EscrowLib.lock(sponsor, (appPrice + datasetPrice + workerpoolPrice) * volume); // Lock deal stake from scheduler balance. // Order is important here. First get percentage by task then // multiply by volume. //slither-disable-next-line divide-before-multiply - lock(workerpoolOwner, ((workerpoolPrice * WORKERPOOL_STAKE_RATIO) / 100) * volume); + EscrowLib.lock( + workerpoolOwner, + ((workerpoolPrice * WORKERPOOL_STAKE_RATIO) / 100) * volume + ); // Notify workerpool. emit SchedulerNoticeBoost( workerpool, @@ -394,7 +404,7 @@ contract IexecPocoBoostFacet is IexecPocoBoost, IexecEscrow, SignatureVerifier, address workerpoolOwner = deal.workerpoolOwner; // Check scheduler or TEE broker signature require( - _verifySignatureOfEthSignedMessage( + CommonLib.verifySignatureOfEthSignedMessage( enclaveChallenge != address(0) && $.m_teebroker != address(0) ? $.m_teebroker : workerpoolOwner, @@ -407,7 +417,7 @@ contract IexecPocoBoostFacet is IexecPocoBoost, IexecEscrow, SignatureVerifier, // Check enclave signature require( enclaveChallenge == address(0) || - _verifySignatureOfEthSignedMessage( + CommonLib.verifySignatureOfEthSignedMessage( enclaveChallenge, abi.encodePacked( msg.sender, @@ -434,21 +444,21 @@ contract IexecPocoBoostFacet is IexecPocoBoost, IexecEscrow, SignatureVerifier, uint96 workerPoolPrice = deal.workerpoolPrice; // Seize requester - seize(deal.requester, appPrice + datasetPrice + workerPoolPrice, taskId); + EscrowLib.seize(deal.requester, appPrice + datasetPrice + workerPoolPrice, taskId); uint96 workerReward = deal.workerReward; // Reward worker - reward(msg.sender, workerReward, taskId); + EscrowLib.reward(msg.sender, workerReward, taskId); // Reward app developer if (appPrice > 0) { - reward(deal.appOwner, appPrice, taskId); + EscrowLib.reward(deal.appOwner, appPrice, taskId); } // Reward dataset provider if (datasetPrice > 0) { - reward(deal.datasetOwner, datasetPrice, taskId); + EscrowLib.reward(deal.datasetOwner, datasetPrice, taskId); } // Unlock scheduler stake - unlock(workerpoolOwner, (workerPoolPrice * WORKERPOOL_STAKE_RATIO) / 100); + EscrowLib.unlock(workerpoolOwner, (workerPoolPrice * WORKERPOOL_STAKE_RATIO) / 100); // Reward scheduler uint256 kitty = $.m_frozens[KITTY_ADDRESS]; if (kitty > 0) { @@ -457,9 +467,9 @@ contract IexecPocoBoostFacet is IexecPocoBoost, IexecEscrow, SignatureVerifier, // @dev As long as `KITTY_RATIO = 10`, we can introduce this small kitty / KITTY_RATIO // optimization for `kitty * KITTY_RATIO / 100` ).min(kitty); // 3. but no more than available - seize(KITTY_ADDRESS, kitty, taskId); + EscrowLib.seize(KITTY_ADDRESS, kitty, taskId); } - reward( + EscrowLib.reward( workerpoolOwner, workerPoolPrice - // reward with workerReward + // sheduler base reward @@ -507,11 +517,11 @@ contract IexecPocoBoostFacet is IexecPocoBoost, IexecEscrow, SignatureVerifier, uint96 workerPoolPrice = deal.workerpoolPrice; uint256 workerpoolTaskStake = (workerPoolPrice * WORKERPOOL_STAKE_RATIO) / 100; // Refund the payer of the task by unlocking the locked funds. - unlock(deal.sponsor, deal.appPrice + deal.datasetPrice + workerPoolPrice); + EscrowLib.unlock(deal.sponsor, deal.appPrice + deal.datasetPrice + workerPoolPrice); // Seize task stake from workerpool. - seize(deal.workerpoolOwner, workerpoolTaskStake, taskId); + EscrowLib.seize(deal.workerpoolOwner, workerpoolTaskStake, taskId); // Reward kitty and lock the rewarded amount. - rewardAndLock(KITTY_ADDRESS, workerpoolTaskStake, taskId); + EscrowLib.rewardAndLock(KITTY_ADDRESS, workerpoolTaskStake, taskId); emit TaskClaimed(taskId); } diff --git a/contracts/interfaces/IexecEscrowToken.sol b/contracts/interfaces/IexecEscrowToken.sol index 5d0334198..a25b49ed8 100644 --- a/contracts/interfaces/IexecEscrowToken.sol +++ b/contracts/interfaces/IexecEscrowToken.sol @@ -3,9 +3,7 @@ pragma solidity ^0.8.0; -import {IexecEscrowEvents} from "./IexecEscrowEvents.sol"; - -interface IexecEscrowToken is IexecEscrowEvents { +interface IexecEscrowToken { error UnsupportedOperation(bytes4 selector); error OperationFailed(); error CallerIsNotTheRequester(); diff --git a/contracts/abstract/SignatureVerifier.sol b/contracts/libs/CommonLib.sol similarity index 65% rename from contracts/abstract/SignatureVerifier.sol rename to contracts/libs/CommonLib.sol index b7d9e2211..d394735e0 100644 --- a/contracts/abstract/SignatureVerifier.sol +++ b/contracts/libs/CommonLib.sol @@ -6,19 +6,26 @@ pragma solidity ^0.8.0; import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; -import {FacetBase} from "./FacetBase.sol"; +import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {IERC734} from "../external/interfaces/IERC734.sol"; -import {PocoStorageLib} from "../libs/PocoStorageLib.sol"; +import {PocoStorageLib} from "./PocoStorageLib.sol"; -// TODO convert to library -abstract contract SignatureVerifier is FacetBase { +/** + * @title Helpers shared by the PoCo facets (signature verification, address + * restriction checks, deal volume computation, ...) + */ +library CommonLib { using ECDSA for bytes32; + using Math for uint256; + + // Used with ERC-734 Key Manager identity contract for authorization management. + uint256 private constant GROUPMEMBER_PURPOSE = 4; /** * Hash a Typed Data using the configured domain. * @param structHash The original structure hash. */ - function _toTypedDataHash(bytes32 structHash) internal view returns (bytes32) { + function toTypedDataHash(bytes32 structHash) internal view returns (bytes32) { PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); return MessageHashUtils.toTypedDataHash($.m_eip712DomainSeparator, structHash); } @@ -29,13 +36,13 @@ abstract contract SignatureVerifier is FacetBase { * @param message The original message that was signed. * @param signature The signature to be verified. */ - function _verifySignatureOfEthSignedMessage( + function verifySignatureOfEthSignedMessage( address account, bytes memory message, bytes calldata signature ) internal view returns (bool) { return - _verifySignature( + verifySignature( account, MessageHashUtils.toEthSignedMessageHash(keccak256(message)), signature @@ -54,7 +61,7 @@ abstract contract SignatureVerifier is FacetBase { * @param messageHash The message hash that was signed. * @param signature The signature to be verified. */ - function _verifySignature( + function verifySignature( address account, bytes32 messageHash, bytes calldata signature @@ -88,10 +95,7 @@ abstract contract SignatureVerifier is FacetBase { * @param account The expected presigner account. * @param messageHash The message hash that was presigned. */ - function _verifyPresignature( - address account, - bytes32 messageHash - ) internal view returns (bool) { + function verifyPresignature(address account, bytes32 messageHash) internal view returns (bool) { PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); return account != address(0) && account == $.m_presigned[messageHash]; } @@ -102,14 +106,14 @@ abstract contract SignatureVerifier is FacetBase { * @param messageHash The message hash that was signed or presigned. * @param signature The signature to be verified. Not required for a presignature. */ - function _verifySignatureOrPresignature( + function verifySignatureOrPresignature( address account, bytes32 messageHash, bytes calldata signature ) internal view returns (bool) { return - _verifyPresignature(account, messageHash) || - _verifySignature(account, messageHash, signature); + verifyPresignature(account, messageHash) || + verifySignature(account, messageHash, signature); } /** @@ -129,7 +133,7 @@ abstract contract SignatureVerifier is FacetBase { * that might whitelist a given address in a group. * @param account An address to be checked. */ - function _isAccountAuthorizedByRestriction( + function isAccountAuthorizedByRestriction( address restriction, address account ) internal view returns (bool) { @@ -151,4 +155,43 @@ abstract contract SignatureVerifier is FacetBase { } return false; } + + /** + * @notice Compute the deal volume considering the minimum remaining volume + * across all provided orders. This ensures that the deal volume does not + * exceed the available volume of any individual order. + * + * @param appOrderVolume The volume of the app order. + * @param appOrderTypedDataHash The typed data hash of the app order. + * @param hasDataset Indicates if there is a dataset order. + * @param datasetOrderVolume The volume of the dataset order. + * @param datasetOrderTypedDataHash The typed data hash of the dataset order. + * @param workerpoolOrderVolume The volume of the workerpool order. + * @param workerpoolOrderTypedDataHash The typed data hash of the workerpool order. + * @param requestOrderVolume The volume of the request order. + * @param requestOrderTypedDataHash The typed data hash of the request order. + * @return The minimum volume available across all orders. + */ + function computeDealVolume( + uint256 appOrderVolume, + bytes32 appOrderTypedDataHash, + bool hasDataset, + uint256 datasetOrderVolume, + bytes32 datasetOrderTypedDataHash, + uint256 workerpoolOrderVolume, + bytes32 workerpoolOrderTypedDataHash, + uint256 requestOrderVolume, + bytes32 requestOrderTypedDataHash + ) internal view returns (uint256) { + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + return + (appOrderVolume - $.m_consumed[appOrderTypedDataHash]) + .min( + hasDataset + ? datasetOrderVolume - $.m_consumed[datasetOrderTypedDataHash] + : type(uint256).max + ) + .min(workerpoolOrderVolume - $.m_consumed[workerpoolOrderTypedDataHash]) + .min(requestOrderVolume - $.m_consumed[requestOrderTypedDataHash]); + } } diff --git a/contracts/abstract/IexecEscrow.sol b/contracts/libs/EscrowLib.sol similarity index 57% rename from contracts/abstract/IexecEscrow.sol rename to contracts/libs/EscrowLib.sol index 3a51fadaf..f7d2edf22 100644 --- a/contracts/abstract/IexecEscrow.sol +++ b/contracts/libs/EscrowLib.sol @@ -2,16 +2,22 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; -import {PocoStorageLib} from "../libs/PocoStorageLib.sol"; -import {IexecEscrowEvents} from "../interfaces/IexecEscrowEvents.sol"; -import {FacetBase} from "./FacetBase.sol"; - -// TODO convert to library +import {PocoStorageLib} from "./PocoStorageLib.sol"; +import {StakedRlcLib} from "./StakedRlcLib.sol"; /** * @title Manage (lock/unlock/reward/seize) user funds. + * @notice The escrow layers on top of the sRLC ledger: it owns `m_frozens` and + * defers every balance move to {StakedRlcLib}. + * @dev The events are declared here rather than taken from {IexecEscrowEvents} + * because solc 0.8.21 cannot compile `emit Other.Event(...)`. */ -abstract contract IexecEscrow is FacetBase, IexecEscrowEvents { +library EscrowLib { + event Reward(address owner, uint256 amount, bytes32 ref); + event Seize(address owner, uint256 amount, bytes32 ref); + event Lock(address owner, uint256 amount); + event Unlock(address owner, uint256 amount); + /** * Lock some value of an account. * @param account The account where the value should be locked. @@ -19,7 +25,7 @@ abstract contract IexecEscrow is FacetBase, IexecEscrowEvents { */ function lock(address account, uint256 value) internal { PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - _transfer(account, address(this), value); + StakedRlcLib.transfer(account, address(this), value); $.m_frozens[account] += value; emit Lock(account, value); } @@ -31,7 +37,7 @@ abstract contract IexecEscrow is FacetBase, IexecEscrowEvents { */ function unlock(address account, uint256 value) internal { PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - _transfer(address(this), account, value); + StakedRlcLib.transfer(address(this), account, value); $.m_frozens[account] -= value; emit Unlock(account, value); } @@ -43,7 +49,7 @@ abstract contract IexecEscrow is FacetBase, IexecEscrowEvents { * @param ref A reference of the reward context. */ function reward(address account, uint256 value, bytes32 ref) internal { - _transfer(address(this), account, value); + StakedRlcLib.transfer(address(this), account, value); emit Reward(account, value, ref); } @@ -74,32 +80,4 @@ abstract contract IexecEscrow is FacetBase, IexecEscrowEvents { emit Reward(account, value, ref); emit Lock(account, value); } - - /** - * Transfer value from a spender account to a receiver account. - * @notice - * This is the single implementation of an sRLC balance move. It backs both - * the escrow operations declared below (lock, unlock, reward) and the ERC-20 - * entry points of {IexecEscrowTokenFacet}. - * A self-transfer is a no-op on the balances and is not rejected. - * - * @param from The address of the spender account. - * @param to The address of the receiver account. - * @param value The value to transfer. - */ - function _transfer(address from, address to, uint256 value) internal { - require(from != address(0), "IexecEscrow: Transfer from empty address"); - require(to != address(0), "IexecEscrow: Transfer to empty address"); - PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); - uint256 fromBalance = $.m_balances[from]; - require(value <= fromBalance, "IexecEscrow: Transfer amount exceeds balance"); - // This block is guaranteed to not underflow because we check the from balance - // and guaranteed to not overflow because the total supply is capped and there - // is no minting involved. - unchecked { - $.m_balances[from] = fromBalance - value; - $.m_balances[to] += value; - } - emit Transfer(from, to, value); - } } diff --git a/contracts/libs/IexecLibCore_v5.sol b/contracts/libs/IexecLibCore_v5.sol index aca6f5f40..d77746fac 100644 --- a/contracts/libs/IexecLibCore_v5.sol +++ b/contracts/libs/IexecLibCore_v5.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.0; +// TODO rename to CoreLib library IexecLibCore_v5 { /** * Tools diff --git a/contracts/libs/IexecLibOrders_v5.sol b/contracts/libs/IexecLibOrders_v5.sol index a5ba8b13f..587e93089 100644 --- a/contracts/libs/IexecLibOrders_v5.sol +++ b/contracts/libs/IexecLibOrders_v5.sol @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; +// TODO rename to OrdersLib library IexecLibOrders_v5 { // bytes32 public constant EIP712DOMAIN_TYPEHASH = keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'); // bytes32 public constant APPORDER_TYPEHASH = keccak256('AppOrder(address app,uint256 appprice,uint256 volume,bytes32 tag,address datasetrestrict,address workerpoolrestrict,address requesterrestrict,bytes32 salt)'); diff --git a/contracts/libs/StakedRlcLib.sol b/contracts/libs/StakedRlcLib.sol new file mode 100644 index 000000000..fcbe1e41a --- /dev/null +++ b/contracts/libs/StakedRlcLib.sol @@ -0,0 +1,87 @@ +// SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH +// SPDX-License-Identifier: Apache-2.0 + +pragma solidity ^0.8.0; + +import {PocoStorageLib} from "./PocoStorageLib.sol"; + +/** + * @title The sRLC ledger. + * @notice sRLC ("Staked RLC") is the internal token of the PoCo protocol. It is + * not a standalone contract: its total supply, balances and allowances live in + * the PoCo storage. This library is the single owner of every write to them. + * @dev The events are declared here rather than taken from {IexecEscrowEvents} + * because solc 0.8.21 cannot compile `emit Other.Event(...)`. + */ +library StakedRlcLib { + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval(address indexed owner, address indexed spender, uint256 value); + + /** + * Transfer value from a spender account to a receiver account. + * @notice + * This is the single implementation of an sRLC balance move. It backs both + * the escrow operations of {EscrowLib} and the ERC-20 entry points of + * {IexecEscrowTokenFacet}. + * A self-transfer is a no-op on the balances and is not rejected. + * + * @param from The address of the spender account. + * @param to The address of the receiver account. + * @param value The value to transfer. + */ + function transfer(address from, address to, uint256 value) internal { + require(from != address(0), "ERC20: Transfer from empty address"); + require(to != address(0), "ERC20: Transfer to empty address"); + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + uint256 fromBalance = $.m_balances[from]; + require(value <= fromBalance, "ERC20: Transfer amount exceeds balance"); + // This block is guaranteed to not underflow because we check the from balance + // and guaranteed to not overflow because the total supply is capped and there + // is no minting involved. + unchecked { + $.m_balances[from] = fromBalance - value; + $.m_balances[to] += value; + } + emit Transfer(from, to, value); + } + + /** + * Create sRLC and credit it to an account. + * @param account The account to credit. + * @param amount The amount to create. + */ + function mint(address account, uint256 amount) internal { + require(account != address(0), "ERC20: mint to the zero address"); + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + $.m_totalSupply = $.m_totalSupply + amount; + $.m_balances[account] = $.m_balances[account] + amount; + emit Transfer(address(0), account, amount); + } + + /** + * Destroy sRLC held by an account. + * @param account The account to debit. + * @param amount The amount to destroy. + */ + function burn(address account, uint256 amount) internal { + require(account != address(0), "ERC20: burn from the zero address"); + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + $.m_totalSupply = $.m_totalSupply - amount; + $.m_balances[account] = $.m_balances[account] - amount; + emit Transfer(account, address(0), amount); + } + + /** + * Set the allowance of a spender over an owner's sRLC. + * @param owner The account granting the allowance. + * @param spender The account receiving the allowance. + * @param amount The allowed amount. + */ + function approve(address owner, address spender, uint256 amount) internal { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage(); + $.m_allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } +} diff --git a/contracts/tools/testing/IexecEscrowTestContract.sol b/contracts/tools/testing/IexecEscrowTestContract.sol index 4d20a5a34..0fe184fba 100644 --- a/contracts/tools/testing/IexecEscrowTestContract.sol +++ b/contracts/tools/testing/IexecEscrowTestContract.sol @@ -3,28 +3,28 @@ pragma solidity ^0.8.0; -import {IexecEscrow} from "../../abstract/IexecEscrow.sol"; +import {EscrowLib} from "../../libs/EscrowLib.sol"; import {PocoStorageLib} from "../../libs/PocoStorageLib.sol"; /** * @notice a wrapper contract to make internal functions of - * IexecEscrow testable. + * EscrowLib testable. */ -contract IexecEscrowTestContract is IexecEscrow { +contract IexecEscrowTestContract { function lock_(address account, uint256 value) external { - lock(account, value); + EscrowLib.lock(account, value); } function unlock_(address account, uint256 value) external { - unlock(account, value); + EscrowLib.unlock(account, value); } function reward_(address account, uint256 value, bytes32 ref) external { - reward(account, value, ref); + EscrowLib.reward(account, value, ref); } function seize_(address account, uint256 value, bytes32 ref) external { - seize(account, value, ref); + EscrowLib.seize(account, value, ref); } // Helper functions used in unit tests. diff --git a/docs/solidity/index.md b/docs/solidity/index.md index 6734cf1c7..7cbd1227b 100644 --- a/docs/solidity/index.md +++ b/docs/solidity/index.md @@ -12,8 +12,6 @@ Changing the name or the path would cause a breaking change in the SDK._ _Every facet must inherit from this contract._ -## IexecEscrow - ## IexecCategoryManagerFacet ### createCategory @@ -795,6 +793,38 @@ function broadcastWorkerpoolOrder(struct IexecLibOrders_v5.WorkerpoolOrder _work function broadcastRequestOrder(struct IexecLibOrders_v5.RequestOrder _requestorder) external ``` +## EscrowLib + +The escrow layers on top of the sRLC ledger: it owns `m_frozens` and +defers every balance move to {StakedRlcLib}. + +_The events are declared here rather than taken from {IexecEscrowEvents} +because solc 0.8.21 cannot compile `emit Other.Event(...)`._ + +### Reward + +```solidity +event Reward(address owner, uint256 amount, bytes32 ref) +``` + +### Seize + +```solidity +event Seize(address owner, uint256 amount, bytes32 ref) +``` + +### Lock + +```solidity +event Lock(address owner, uint256 amount) +``` + +### Unlock + +```solidity +event Unlock(address owner, uint256 amount) +``` + ## IexecLibCore_v5 ### Account @@ -1260,6 +1290,27 @@ struct PocoStorage { } ``` +## StakedRlcLib + +sRLC ("Staked RLC") is the internal token of the PoCo protocol. It is +not a standalone contract: its total supply, balances and allowances live in +the PoCo storage. This library is the single owner of every write to them. + +_The events are declared here rather than taken from {IexecEscrowEvents} +because solc 0.8.21 cannot compile `emit Other.Event(...)`._ + +### Transfer + +```solidity +event Transfer(address from, address to, uint256 value) +``` + +### Approval + +```solidity +event Approval(address owner, address spender, uint256 value) +``` + ## IRegistry ### isRegistered diff --git a/docs/uml/class-uml-IexecEscrows.svg b/docs/uml/class-uml-IexecEscrows.svg index e96b334d3..25eb235b6 100644 --- a/docs/uml/class-uml-IexecEscrows.svg +++ b/docs/uml/class-uml-IexecEscrows.svg @@ -4,708 +4,716 @@ - - + + UmlClassDiagram - + 3 - -<<Abstract>> -FacetBase -contracts/abstract/FacetBase.sol - -Internal: -   CONTRIBUTION_DEADLINE_RATIO: uint256 -   REVEAL_DEADLINE_RATIO: uint256 -   FINAL_DEADLINE_RATIO: uint256 -   WORKERPOOL_STAKE_RATIO: uint256 -   KITTY_RATIO: uint256 -   KITTY_MIN: uint256 -   KITTY_ADDRESS: address -   GROUPMEMBER_PURPOSE: uint256 - -Internal: -    owner(): address -    _msgSender(): address -Public: -    <<modifier>> onlyOwner() - - + +<<Abstract>> +FacetBase +contracts/abstract/FacetBase.sol + +Internal: +   CONTRIBUTION_DEADLINE_RATIO: uint256 +   REVEAL_DEADLINE_RATIO: uint256 +   FINAL_DEADLINE_RATIO: uint256 +   WORKERPOOL_STAKE_RATIO: uint256 +   KITTY_RATIO: uint256 +   KITTY_MIN: uint256 +   KITTY_ADDRESS: address +   GROUPMEMBER_PURPOSE: uint256 + +Internal: +    owner(): address +    _msgSender(): address +Public: +    <<modifier>> onlyOwner() + + -4 - -<<Abstract>> -IexecEscrow -contracts/abstract/IexecEscrow.sol - -Internal: -    lock(account: address, value: uint256) -    unlock(account: address, value: uint256) -    reward(account: address, value: uint256, ref: bytes32) -    seize(account: address, value: uint256, ref: bytes32) -    rewardAndLock(account: address, value: uint256, ref: bytes32) -    _transfer(from: address, to: address, value: uint256) - - +8 + +IexecEscrowTokenFacet +contracts/facets/IexecEscrowTokenFacet.sol + +Internal: +    _executeOperation(sender: address, data: bytes) +    _validateMatchOrders(sender: address, data: bytes) +    _deposit(from: address, amount: uint256) +    _withdraw(to: address, amount: uint256) +External: +    <<payable>> null() +    <<payable>> null() +    deposit(amount: uint256): bool +    depositFor(amount: uint256, target: address): bool +    depositForArray(amounts: uint256[], targets: address[]): bool +    withdraw(amount: uint256): bool +    withdrawTo(amount: uint256, target: address): bool +    recover(): uint256 <<onlyOwner>> +    receiveApproval(sender: address, amount: uint256, token: address, data: bytes): bool +    transfer(recipient: address, amount: uint256): bool +    approve(spender: address, value: uint256): bool +    approveAndCall(spender: address, value: uint256, extraData: bytes): bool +    transferFrom(sender: address, recipient: address, amount: uint256): bool +    increaseAllowance(spender: address, addedValue: uint256): bool +    decreaseAllowance(spender: address, subtractedValue: uint256): bool + + + +8->3 + + + + + +23 + +<<Interface>> +IexecEscrowToken +contracts/interfaces/IexecEscrowToken.sol + +External: +     null() +     null() +     deposit(uint256): bool +     depositFor(uint256, address): bool +     depositForArray(uint256[], address[]): bool +     withdraw(uint256): bool +     withdrawTo(uint256, address): bool +     recover(): uint256 +     transfer(address, uint256): bool +     approve(address, uint256): bool +     transferFrom(address, address, uint256): bool +     increaseAllowance(address, uint256): bool +     decreaseAllowance(address, uint256): bool +     approveAndCall(address, uint256, bytes): bool + + -4->3 - - +8->23 + + - - -25 - -<<Interface>> -IexecEscrowEvents -contracts/interfaces/IexecEscrowEvents.sol - -Public: -    <<event>> Transfer(from: address, to: address, value: uint256) -    <<event>> Approval(owner: address, spender: address, value: uint256) -    <<event>> Reward(owner: address, amount: uint256, ref: bytes32) -    <<event>> Seize(owner: address, amount: uint256, ref: bytes32) -    <<event>> Lock(owner: address, amount: uint256) -    <<event>> Unlock(owner: address, amount: uint256) - - + + +26 + +<<Interface>> +IexecPoco1 +contracts/interfaces/IexecPoco1.sol + +External: +     verifySignature(address, bytes32, bytes): bool +     verifyPresignature(address, bytes32): bool +     verifyPresignatureOrSignature(address, bytes32, bytes): bool +     assertDatasetDealCompatibility(datasetOrder: IexecLibOrders_v5.DatasetOrder, dealId: bytes32) +     matchOrders(IexecLibOrders_v5.AppOrder, IexecLibOrders_v5.DatasetOrder, IexecLibOrders_v5.WorkerpoolOrder, IexecLibOrders_v5.RequestOrder): bytes32 +     sponsorMatchOrders(IexecLibOrders_v5.AppOrder, IexecLibOrders_v5.DatasetOrder, IexecLibOrders_v5.WorkerpoolOrder, IexecLibOrders_v5.RequestOrder): bytes32 +Public: +    <<event>> SchedulerNotice(workerpool: address, dealid: bytes32) +    <<event>> OrdersMatched(dealid: bytes32, appHash: bytes32, datasetHash: bytes32, workerpoolHash: bytes32, requestHash: bytes32, volume: uint256) +    <<event>> DealSponsored(dealId: bytes32, sponsor: address) + + + +8->26 + + + + + +33 + +<<Interface>> +IexecTokenSpender +contracts/interfaces/IexecTokenSpender.sol + +External: +     receiveApproval(address, uint256, address, bytes): bool + + -4->25 - - +8->33 + + + + + +50 + +<<Library>> +IexecLibOrders_v5 +contracts/libs/IexecLibOrders_v5.sol + +Public: +   EIP712DOMAIN_TYPEHASH: bytes32 +   APPORDER_TYPEHASH: bytes32 +   DATASETORDER_TYPEHASH: bytes32 +   WORKERPOOLORDER_TYPEHASH: bytes32 +   REQUESTORDER_TYPEHASH: bytes32 +   APPORDEROPERATION_TYPEHASH: bytes32 +   DATASETORDEROPERATION_TYPEHASH: bytes32 +   WORKERPOOLORDEROPERATION_TYPEHASH: bytes32 +   REQUESTORDEROPERATION_TYPEHASH: bytes32 + +Public: +    hash(_domain: EIP712Domain): (domainhash: bytes32) +    hash(_apporder: AppOrder): (apphash: bytes32) +    hash(_datasetorder: DatasetOrder): (datasethash: bytes32) +    hash(_workerpoolorder: WorkerpoolOrder): (workerpoolhash: bytes32) +    hash(_requestorder: RequestOrder): (requesthash: bytes32) +    hash(_apporderoperation: AppOrderOperation): bytes32 +    hash(_datasetorderoperation: DatasetOrderOperation): bytes32 +    hash(_workerpoolorderoperation: WorkerpoolOrderOperation): bytes32 +    hash(_requestorderoperation: RequestOrderOperation): bytes32 + + + +8->50 + + + + + +61 + +<<Library>> +PocoStorageLib +contracts/libs/PocoStorageLib.sol + +Private: +   POCO_STORAGE_LOCATION: bytes32 + +Internal: +    getPocoStorage(): ($: PocoStorage) + + + +8->61 + + 62 - -<<Library>> -PocoStorageLib -contracts/libs/PocoStorageLib.sol - -Private: -   POCO_STORAGE_LOCATION: bytes32 - -Internal: -    getPocoStorage(): ($: PocoStorage) - - - -4->62 - - + +<<Struct>> +PocoStorage +contracts/libs/PocoStorageLib.sol + +m_appregistry: IRegistry +m_datasetregistry: IRegistry +m_workerpoolregistry: IRegistry +m_baseToken: IERC20 +m_name: string +m_symbol: string +m_decimals: uint8 +m_totalSupply: uint256 +m_balances: mapping(address=>uint256) +m_frozens: mapping(address=>uint256) +m_allowances: mapping(address=>mapping(address=>uint256)) +m_eip712DomainSeparator: bytes32 +m_presigned: mapping(bytes32=>address) +m_consumed: mapping(bytes32=>uint256) +m_deals: mapping(bytes32=>IexecLibCore_v5.Deal) +m_tasks: mapping(bytes32=>IexecLibCore_v5.Task) +m_consensus: mapping(bytes32=>IexecLibCore_v5.Consensus) +m_contributions: mapping(bytes32=>mapping(address=>IexecLibCore_v5.Contribution)) +m_workerScores: mapping(address=>uint256) +m_teebroker: address +m_callbackgas: uint256 +m_categories: IexecLibCore_v5.Category[] +m_v3_iexecHub: IexecHubV3Interface +m_v3_scoreImported: mapping(address=>bool) +m_dealsBoost: mapping(bytes32=>IexecLibCore_v5.DealBoost) + + + +8->62 + + 63 - -<<Struct>> -PocoStorage -contracts/libs/PocoStorageLib.sol - -m_appregistry: IRegistry -m_datasetregistry: IRegistry -m_workerpoolregistry: IRegistry -m_baseToken: IERC20 -m_name: string -m_symbol: string -m_decimals: uint8 -m_totalSupply: uint256 -m_balances: mapping(address=>uint256) -m_frozens: mapping(address=>uint256) -m_allowances: mapping(address=>mapping(address=>uint256)) -m_eip712DomainSeparator: bytes32 -m_presigned: mapping(bytes32=>address) -m_consumed: mapping(bytes32=>uint256) -m_deals: mapping(bytes32=>IexecLibCore_v5.Deal) -m_tasks: mapping(bytes32=>IexecLibCore_v5.Task) -m_consensus: mapping(bytes32=>IexecLibCore_v5.Consensus) -m_contributions: mapping(bytes32=>mapping(address=>IexecLibCore_v5.Contribution)) -m_workerScores: mapping(address=>uint256) -m_teebroker: address -m_callbackgas: uint256 -m_categories: IexecLibCore_v5.Category[] -m_v3_iexecHub: IexecHubV3Interface -m_v3_scoreImported: mapping(address=>bool) -m_dealsBoost: mapping(bytes32=>IexecLibCore_v5.DealBoost) - - + +<<Library>> +StakedRlcLib +contracts/libs/StakedRlcLib.sol + +Internal: +    transfer(from: address, to: address, value: uint256) +    mint(account: address, amount: uint256) +    burn(account: address, amount: uint256) +    approve(owner: address, spender: address, amount: uint256) +Public: +    <<event>> Transfer(from: address, to: address, value: uint256) +    <<event>> Approval(owner: address, spender: address, value: uint256) + + -4->63 - - - - - -11 - -IexecEscrowTokenFacet -contracts/facets/IexecEscrowTokenFacet.sol - -Internal: -    _executeOperation(sender: address, data: bytes) -    _validateMatchOrders(sender: address, data: bytes) -    _deposit(from: address, amount: uint256) -    _withdraw(to: address, amount: uint256) -    _mint(account: address, amount: uint256) -    _burn(account: address, amount: uint256) -    _approve(owner: address, spender: address, amount: uint256) -External: -    <<payable>> null() -    <<payable>> null() -    deposit(amount: uint256): bool -    depositFor(amount: uint256, target: address): bool -    depositForArray(amounts: uint256[], targets: address[]): bool -    withdraw(amount: uint256): bool -    withdrawTo(amount: uint256, target: address): bool -    recover(): uint256 <<onlyOwner>> -    receiveApproval(sender: address, amount: uint256, token: address, data: bytes): bool -    transfer(recipient: address, amount: uint256): bool -    approve(spender: address, value: uint256): bool -    approveAndCall(spender: address, value: uint256, extraData: bytes): bool -    transferFrom(sender: address, recipient: address, amount: uint256): bool -    increaseAllowance(spender: address, addedValue: uint256): bool -    decreaseAllowance(spender: address, subtractedValue: uint256): bool - - - -11->4 - - - - - -26 - -<<Interface>> -IexecEscrowToken -contracts/interfaces/IexecEscrowToken.sol - -External: -     null() -     null() -     deposit(uint256): bool -     depositFor(uint256, address): bool -     depositForArray(uint256[], address[]): bool -     withdraw(uint256): bool -     withdrawTo(uint256, address): bool -     recover(): uint256 -     transfer(address, uint256): bool -     approve(address, uint256): bool -     transferFrom(address, address, uint256): bool -     increaseAllowance(address, uint256): bool -     decreaseAllowance(address, uint256): bool -     approveAndCall(address, uint256, bytes): bool - - - -11->26 - - - - - -29 - -<<Interface>> -IexecPoco1 -contracts/interfaces/IexecPoco1.sol - -External: -     verifySignature(address, bytes32, bytes): bool -     verifyPresignature(address, bytes32): bool -     verifyPresignatureOrSignature(address, bytes32, bytes): bool -     assertDatasetDealCompatibility(datasetOrder: IexecLibOrders_v5.DatasetOrder, dealId: bytes32) -     matchOrders(IexecLibOrders_v5.AppOrder, IexecLibOrders_v5.DatasetOrder, IexecLibOrders_v5.WorkerpoolOrder, IexecLibOrders_v5.RequestOrder): bytes32 -     sponsorMatchOrders(IexecLibOrders_v5.AppOrder, IexecLibOrders_v5.DatasetOrder, IexecLibOrders_v5.WorkerpoolOrder, IexecLibOrders_v5.RequestOrder): bytes32 -Public: -    <<event>> SchedulerNotice(workerpool: address, dealid: bytes32) -    <<event>> OrdersMatched(dealid: bytes32, appHash: bytes32, datasetHash: bytes32, workerpoolHash: bytes32, requestHash: bytes32, volume: uint256) -    <<event>> DealSponsored(dealId: bytes32, sponsor: address) - - - -11->29 - - - - - -36 - -<<Interface>> -IexecTokenSpender -contracts/interfaces/IexecTokenSpender.sol - -External: -     receiveApproval(address, uint256, address, bytes): bool - - - -11->36 - - +8->63 + + - - -51 - -<<Library>> -IexecLibOrders_v5 -contracts/libs/IexecLibOrders_v5.sol - -Public: -   EIP712DOMAIN_TYPEHASH: bytes32 -   APPORDER_TYPEHASH: bytes32 -   DATASETORDER_TYPEHASH: bytes32 -   WORKERPOOLORDER_TYPEHASH: bytes32 -   REQUESTORDER_TYPEHASH: bytes32 -   APPORDEROPERATION_TYPEHASH: bytes32 -   DATASETORDEROPERATION_TYPEHASH: bytes32 -   WORKERPOOLORDEROPERATION_TYPEHASH: bytes32 -   REQUESTORDEROPERATION_TYPEHASH: bytes32 - -Public: -    hash(_domain: EIP712Domain): (domainhash: bytes32) -    hash(_apporder: AppOrder): (apphash: bytes32) -    hash(_datasetorder: DatasetOrder): (datasethash: bytes32) -    hash(_workerpoolorder: WorkerpoolOrder): (workerpoolhash: bytes32) -    hash(_requestorder: RequestOrder): (requesthash: bytes32) -    hash(_apporderoperation: AppOrderOperation): bytes32 -    hash(_datasetorderoperation: DatasetOrderOperation): bytes32 -    hash(_workerpoolorderoperation: WorkerpoolOrderOperation): bytes32 -    hash(_requestorderoperation: RequestOrderOperation): bytes32 - - - -11->51 - - - - - -11->62 - - - - + + +24 + +<<Interface>> +IexecHubV3Interface +contracts/interfaces/IexecHubV3Interface.sol + +External: +     viewScore(worker: address): uint256 + + -11->63 - - - - - -26->25 - - +26->50 + + - - -27 - -<<Interface>> -IexecHubV3Interface -contracts/interfaces/IexecHubV3Interface.sol - -External: -     viewScore(worker: address): uint256 - - - -29->51 - - + + +53 + +<<Struct>> +AppOrder +contracts/libs/IexecLibOrders_v5.sol + +app: address +appprice: uint256 +volume: uint256 +tag: bytes32 +datasetrestrict: address +workerpoolrestrict: address +requesterrestrict: address +salt: bytes32 +sign: bytes + + + +26->53 + + 54 - -<<Struct>> -AppOrder -contracts/libs/IexecLibOrders_v5.sol - -app: address -appprice: uint256 -volume: uint256 -tag: bytes32 -datasetrestrict: address -workerpoolrestrict: address -requesterrestrict: address -salt: bytes32 -sign: bytes - - - -29->54 - - + +<<Struct>> +DatasetOrder +contracts/libs/IexecLibOrders_v5.sol + +dataset: address +datasetprice: uint256 +volume: uint256 +tag: bytes32 +apprestrict: address +workerpoolrestrict: address +requesterrestrict: address +salt: bytes32 +sign: bytes + + + +26->54 + + 55 - -<<Struct>> -DatasetOrder -contracts/libs/IexecLibOrders_v5.sol - -dataset: address -datasetprice: uint256 -volume: uint256 -tag: bytes32 -apprestrict: address -workerpoolrestrict: address -requesterrestrict: address -salt: bytes32 -sign: bytes - - - -29->55 - - + +<<Struct>> +WorkerpoolOrder +contracts/libs/IexecLibOrders_v5.sol + +workerpool: address +workerpoolprice: uint256 +volume: uint256 +tag: bytes32 +category: uint256 +trust: uint256 +apprestrict: address +datasetrestrict: address +requesterrestrict: address +salt: bytes32 +sign: bytes + + + +26->55 + + 56 - -<<Struct>> -WorkerpoolOrder -contracts/libs/IexecLibOrders_v5.sol - -workerpool: address -workerpoolprice: uint256 -volume: uint256 -tag: bytes32 -category: uint256 -trust: uint256 -apprestrict: address -datasetrestrict: address -requesterrestrict: address -salt: bytes32 -sign: bytes - - + +<<Struct>> +RequestOrder +contracts/libs/IexecLibOrders_v5.sol + +app: address +appmaxprice: uint256 +dataset: address +datasetmaxprice: uint256 +workerpool: address +workerpoolmaxprice: uint256 +requester: address +volume: uint256 +tag: bytes32 +category: uint256 +trust: uint256 +beneficiary: address +callback: address +params: string +salt: bytes32 +sign: bytes + + + +26->56 + + + + + +35 + +<<Library>> +EscrowLib +contracts/libs/EscrowLib.sol + +Internal: +    lock(account: address, value: uint256) +    unlock(account: address, value: uint256) +    reward(account: address, value: uint256, ref: bytes32) +    seize(account: address, value: uint256, ref: bytes32) +    rewardAndLock(account: address, value: uint256, ref: bytes32) +Public: +    <<event>> Reward(owner: address, amount: uint256, ref: bytes32) +    <<event>> Seize(owner: address, amount: uint256, ref: bytes32) +    <<event>> Lock(owner: address, amount: uint256) +    <<event>> Unlock(owner: address, amount: uint256) + + + +35->61 + + + + + +35->62 + + + + -29->56 - - +35->63 + + - - -57 - -<<Struct>> -RequestOrder -contracts/libs/IexecLibOrders_v5.sol - -app: address -appmaxprice: uint256 -dataset: address -datasetmaxprice: uint256 -workerpool: address -workerpoolmaxprice: uint256 -requester: address -volume: uint256 -tag: bytes32 -category: uint256 -trust: uint256 -beneficiary: address -callback: address -params: string -salt: bytes32 -sign: bytes - - - -29->57 - - + + +36 + +<<Library>> +IexecLibCore_v5 +contracts/libs/IexecLibCore_v5.sol - - -37 - -<<Library>> -IexecLibCore_v5 -contracts/libs/IexecLibCore_v5.sol + + +52 + +<<Struct>> +EIP712Domain +contracts/libs/IexecLibOrders_v5.sol + +name: string +version: string +chainId: uint256 +verifyingContract: address + + + +50->52 + + - - -53 - -<<Struct>> -EIP712Domain -contracts/libs/IexecLibOrders_v5.sol - -name: string -version: string -chainId: uint256 -verifyingContract: address - - + -51->53 - - +50->53 + + - + -51->54 - - +50->54 + + - + -51->55 - - +50->55 + + - + -51->56 - - +50->56 + + - + + +57 + +<<Struct>> +AppOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: AppOrder +operation: OrderOperationEnum +sign: bytes + + -51->57 - - +50->57 + + 58 - -<<Struct>> -AppOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: AppOrder -operation: OrderOperationEnum -sign: bytes - - + +<<Struct>> +DatasetOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: DatasetOrder +operation: OrderOperationEnum +sign: bytes + + -51->58 - - +50->58 + + 59 - -<<Struct>> -DatasetOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: DatasetOrder -operation: OrderOperationEnum -sign: bytes - - + +<<Struct>> +WorkerpoolOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: WorkerpoolOrder +operation: OrderOperationEnum +sign: bytes + + -51->59 - - +50->59 + + 60 - -<<Struct>> -WorkerpoolOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: WorkerpoolOrder -operation: OrderOperationEnum -sign: bytes - - + +<<Struct>> +RequestOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: RequestOrder +operation: OrderOperationEnum +sign: bytes + + -51->60 - - +50->60 + + - - -61 - -<<Struct>> -RequestOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: RequestOrder -operation: OrderOperationEnum -sign: bytes - - - -51->61 - - + + +51 + +<<Enum>> +OrderOperationEnum +contracts/libs/IexecLibOrders_v5.sol + +SIGN: 0 +CLOSE: 1 + + + +51->50 + + - - -52 - -<<Enum>> -OrderOperationEnum -contracts/libs/IexecLibOrders_v5.sol - -SIGN: 0 -CLOSE: 1 - - + -52->51 - - +52->50 + + - + -53->51 - - +53->50 + + - + -54->51 - - +54->50 + + - + -55->51 - - +55->50 + + - + -56->51 - - +56->50 + + - + +57->50 + + + + + 57->51 - - + + - + + +57->53 + + + + -58->51 - - +58->50 + + - - -58->52 - - + + +58->51 + + - + 58->54 - - + + - + -59->51 - - +59->50 + + - - -59->52 - - + + +59->51 + + - + 59->55 - - + + - + -60->51 - - +60->50 + + - - -60->52 - - + + +60->51 + + - + 60->56 - - + + - - -61->51 - - + + +61->62 + + - - -61->52 - - + + +62->24 + + - - -61->57 - - + + +62->36 + + - + + +62->61 + + + + + +64 + +<<Interface>> +IRegistry +contracts/registries/IRegistry.sol + +External: +     isRegistered(_entry: address): bool + + -62->63 - - +62->64 + + - + -63->27 - - - - - -63->37 - - +63->61 + + - + 63->62 - - - - - -64 - -<<Interface>> -IRegistry -contracts/registries/IRegistry.sol - -External: -     isRegistered(_entry: address): bool - - - -63->64 - - + + diff --git a/docs/uml/class-uml-IexecPocoBoostFacet.svg b/docs/uml/class-uml-IexecPocoBoostFacet.svg index 55a6dcefd..e5cf871b5 100644 --- a/docs/uml/class-uml-IexecPocoBoostFacet.svg +++ b/docs/uml/class-uml-IexecPocoBoostFacet.svg @@ -4,890 +4,864 @@ - - + + UmlClassDiagram - + 3 - -<<Abstract>> -FacetBase -contracts/abstract/FacetBase.sol - -Internal: -   CONTRIBUTION_DEADLINE_RATIO: uint256 -   REVEAL_DEADLINE_RATIO: uint256 -   FINAL_DEADLINE_RATIO: uint256 -   WORKERPOOL_STAKE_RATIO: uint256 -   KITTY_RATIO: uint256 -   KITTY_MIN: uint256 -   KITTY_ADDRESS: address -   GROUPMEMBER_PURPOSE: uint256 - -Internal: -    owner(): address -    _msgSender(): address -Public: -    <<modifier>> onlyOwner() - - - -4 - -<<Abstract>> -IexecEscrow -contracts/abstract/IexecEscrow.sol - -Internal: -    lock(account: address, value: uint256) -    unlock(account: address, value: uint256) -    reward(account: address, value: uint256, ref: bytes32) -    seize(account: address, value: uint256, ref: bytes32) -    rewardAndLock(account: address, value: uint256, ref: bytes32) -    _transfer(from: address, to: address, value: uint256) - - - -4->3 - - - - - -25 - -<<Interface>> -IexecEscrowEvents -contracts/interfaces/IexecEscrowEvents.sol - -Public: -    <<event>> Transfer(from: address, to: address, value: uint256) -    <<event>> Approval(owner: address, spender: address, value: uint256) -    <<event>> Reward(owner: address, amount: uint256, ref: bytes32) -    <<event>> Seize(owner: address, amount: uint256, ref: bytes32) -    <<event>> Lock(owner: address, amount: uint256) -    <<event>> Unlock(owner: address, amount: uint256) - - - -4->25 - - - - - -62 - -<<Library>> -PocoStorageLib -contracts/libs/PocoStorageLib.sol - -Private: -   POCO_STORAGE_LOCATION: bytes32 - -Internal: -    getPocoStorage(): ($: PocoStorage) - - - -4->62 - - - - - -63 - -<<Struct>> -PocoStorage -contracts/libs/PocoStorageLib.sol - -m_appregistry: IRegistry -m_datasetregistry: IRegistry -m_workerpoolregistry: IRegistry -m_baseToken: IERC20 -m_name: string -m_symbol: string -m_decimals: uint8 -m_totalSupply: uint256 -m_balances: mapping(address=>uint256) -m_frozens: mapping(address=>uint256) -m_allowances: mapping(address=>mapping(address=>uint256)) -m_eip712DomainSeparator: bytes32 -m_presigned: mapping(bytes32=>address) -m_consumed: mapping(bytes32=>uint256) -m_deals: mapping(bytes32=>IexecLibCore_v5.Deal) -m_tasks: mapping(bytes32=>IexecLibCore_v5.Task) -m_consensus: mapping(bytes32=>IexecLibCore_v5.Consensus) -m_contributions: mapping(bytes32=>mapping(address=>IexecLibCore_v5.Contribution)) -m_workerScores: mapping(address=>uint256) -m_teebroker: address -m_callbackgas: uint256 -m_categories: IexecLibCore_v5.Category[] -m_v3_iexecHub: IexecHubV3Interface -m_v3_scoreImported: mapping(address=>bool) -m_dealsBoost: mapping(bytes32=>IexecLibCore_v5.DealBoost) - - - -4->63 - - + +<<Abstract>> +FacetBase +contracts/abstract/FacetBase.sol + +Internal: +   CONTRIBUTION_DEADLINE_RATIO: uint256 +   REVEAL_DEADLINE_RATIO: uint256 +   FINAL_DEADLINE_RATIO: uint256 +   WORKERPOOL_STAKE_RATIO: uint256 +   KITTY_RATIO: uint256 +   KITTY_MIN: uint256 +   KITTY_ADDRESS: address +   GROUPMEMBER_PURPOSE: uint256 + +Internal: +    owner(): address +    _msgSender(): address +Public: +    <<modifier>> onlyOwner() - + + +68 + +<<Interface>> +IOracleConsumer +contracts/external/interfaces/IOracleConsumer.sol + +External: +     receiveResult(taskId: bytes32, resultsCallback: bytes) + + -5 - -<<Abstract>> -IexecPocoCommon -contracts/abstract/IexecPocoCommon.sol - -Internal: -    _computeDealVolume(appOrderVolume: uint256, appOrderTypedDataHash: bytes32, hasDataset: bool, datasetOrderVolume: uint256, datasetOrderTypedDataHash: bytes32, workerpoolOrderVolume: uint256, workerpoolOrderTypedDataHash: bytes32, requestOrderVolume: uint256, requestOrderTypedDataHash: bytes32): uint256 - - - -5->3 - - - - - -51 - -<<Library>> -IexecLibOrders_v5 -contracts/libs/IexecLibOrders_v5.sol - -Public: -   EIP712DOMAIN_TYPEHASH: bytes32 -   APPORDER_TYPEHASH: bytes32 -   DATASETORDER_TYPEHASH: bytes32 -   WORKERPOOLORDER_TYPEHASH: bytes32 -   REQUESTORDER_TYPEHASH: bytes32 -   APPORDEROPERATION_TYPEHASH: bytes32 -   DATASETORDEROPERATION_TYPEHASH: bytes32 -   WORKERPOOLORDEROPERATION_TYPEHASH: bytes32 -   REQUESTORDEROPERATION_TYPEHASH: bytes32 - -Public: -    hash(_domain: EIP712Domain): (domainhash: bytes32) -    hash(_apporder: AppOrder): (apphash: bytes32) -    hash(_datasetorder: DatasetOrder): (datasethash: bytes32) -    hash(_workerpoolorder: WorkerpoolOrder): (workerpoolhash: bytes32) -    hash(_requestorder: RequestOrder): (requesthash: bytes32) -    hash(_apporderoperation: AppOrderOperation): bytes32 -    hash(_datasetorderoperation: DatasetOrderOperation): bytes32 -    hash(_workerpoolorderoperation: WorkerpoolOrderOperation): bytes32 -    hash(_requestorderoperation: RequestOrderOperation): bytes32 - - - -5->51 - - - - - -5->62 - - - - - -5->63 - - - - - -6 - -<<Abstract>> -SignatureVerifier -contracts/abstract/SignatureVerifier.sol - -Internal: -    _toTypedDataHash(structHash: bytes32): bytes32 -    _verifySignatureOfEthSignedMessage(account: address, message: bytes, signature: bytes): bool -    _verifySignature(account: address, messageHash: bytes32, signature: bytes): bool -    _verifyPresignature(account: address, messageHash: bytes32): bool -    _verifySignatureOrPresignature(account: address, messageHash: bytes32, signature: bytes): bool -    _isAccountAuthorizedByRestriction(restriction: address, account: address): bool - - - -6->3 - - - - - -6->62 - - +15 + +IexecPocoBoostFacet +contracts/facets/IexecPocoBoostFacet.sol + +Private: +    _matchOrdersBoost(appOrder: IexecLibOrders_v5.AppOrder, datasetOrder: IexecLibOrders_v5.DatasetOrder, workerpoolOrder: IexecLibOrders_v5.WorkerpoolOrder, requestOrder: IexecLibOrders_v5.RequestOrder, sponsor: address): bytes32 +    requireTaskExistsAndUnset(taskStatus: IexecLibCore_v5.TaskStatusEnum, taskIndex: uint256, botSize: uint16) +External: +    matchOrdersBoost(appOrder: IexecLibOrders_v5.AppOrder, datasetOrder: IexecLibOrders_v5.DatasetOrder, workerpoolOrder: IexecLibOrders_v5.WorkerpoolOrder, requestOrder: IexecLibOrders_v5.RequestOrder): bytes32 +    sponsorMatchOrdersBoost(appOrder: IexecLibOrders_v5.AppOrder, datasetOrder: IexecLibOrders_v5.DatasetOrder, workerpoolOrder: IexecLibOrders_v5.WorkerpoolOrder, requestOrder: IexecLibOrders_v5.RequestOrder): bytes32 +    pushResultBoost(dealId: bytes32, index: uint256, results: bytes, resultsCallback: bytes, authorizationSign: bytes, enclaveChallenge: address, enclaveSign: bytes) +    claimBoost(dealId: bytes32, index: uint256) + + + +15->3 + + - - -6->63 - - + + +15->68 + + - + -68 - -<<Interface>> -IOracleConsumer -contracts/external/interfaces/IOracleConsumer.sol - -External: -     receiveResult(taskId: bytes32, resultsCallback: bytes) - - - -18 - -IexecPocoBoostFacet -contracts/facets/IexecPocoBoostFacet.sol - -Private: -    _matchOrdersBoost(appOrder: IexecLibOrders_v5.AppOrder, datasetOrder: IexecLibOrders_v5.DatasetOrder, workerpoolOrder: IexecLibOrders_v5.WorkerpoolOrder, requestOrder: IexecLibOrders_v5.RequestOrder, sponsor: address): bytes32 -    requireTaskExistsAndUnset(taskStatus: IexecLibCore_v5.TaskStatusEnum, taskIndex: uint256, botSize: uint16) -External: -    matchOrdersBoost(appOrder: IexecLibOrders_v5.AppOrder, datasetOrder: IexecLibOrders_v5.DatasetOrder, workerpoolOrder: IexecLibOrders_v5.WorkerpoolOrder, requestOrder: IexecLibOrders_v5.RequestOrder): bytes32 -    sponsorMatchOrdersBoost(appOrder: IexecLibOrders_v5.AppOrder, datasetOrder: IexecLibOrders_v5.DatasetOrder, workerpoolOrder: IexecLibOrders_v5.WorkerpoolOrder, requestOrder: IexecLibOrders_v5.RequestOrder): bytes32 -    pushResultBoost(dealId: bytes32, index: uint256, results: bytes, resultsCallback: bytes, authorizationSign: bytes, enclaveChallenge: address, enclaveSign: bytes) -    claimBoost(dealId: bytes32, index: uint256) - - - -18->4 - - +30 + +<<Interface>> +IexecPocoBoost +contracts/interfaces/IexecPocoBoost.sol + +External: +     matchOrdersBoost(appOrder: IexecLibOrders_v5.AppOrder, datasetOrder: IexecLibOrders_v5.DatasetOrder, workerpoolOrder: IexecLibOrders_v5.WorkerpoolOrder, requestOrder: IexecLibOrders_v5.RequestOrder): bytes32 +     sponsorMatchOrdersBoost(appOrder: IexecLibOrders_v5.AppOrder, datasetOrder: IexecLibOrders_v5.DatasetOrder, workerpoolOrder: IexecLibOrders_v5.WorkerpoolOrder, requestOrder: IexecLibOrders_v5.RequestOrder): bytes32 +     pushResultBoost(dealId: bytes32, index: uint256, results: bytes, resultsCallback: bytes, authorizationSign: bytes, enclaveChallenge: address, enclaveSign: bytes) +     claimBoost(dealId: bytes32, index: uint256) +Public: +    <<event>> SchedulerNoticeBoost(workerpool: address, dealId: bytes32, app: address, dataset: address, category: uint256, tag: bytes32, params: string, beneficiary: address) +    <<event>> OrdersMatched(dealid: bytes32, appHash: bytes32, datasetHash: bytes32, workerpoolHash: bytes32, requestHash: bytes32, volume: uint256) +    <<event>> ResultPushedBoost(dealId: bytes32, index: uint256, results: bytes) +    <<event>> TaskClaimed(taskid: bytes32) +    <<event>> DealSponsoredBoost(dealId: bytes32, sponsor: address) + + + +15->30 + + - - -18->5 - - + + +34 + +<<Library>> +CommonLib +contracts/libs/CommonLib.sol + +Private: +   GROUPMEMBER_PURPOSE: uint256 + +Internal: +    toTypedDataHash(structHash: bytes32): bytes32 +    verifySignatureOfEthSignedMessage(account: address, message: bytes, signature: bytes): bool +    verifySignature(account: address, messageHash: bytes32, signature: bytes): bool +    verifyPresignature(account: address, messageHash: bytes32): bool +    verifySignatureOrPresignature(account: address, messageHash: bytes32, signature: bytes): bool +    isAccountAuthorizedByRestriction(restriction: address, account: address): bool +    computeDealVolume(appOrderVolume: uint256, appOrderTypedDataHash: bytes32, hasDataset: bool, datasetOrderVolume: uint256, datasetOrderTypedDataHash: bytes32, workerpoolOrderVolume: uint256, workerpoolOrderTypedDataHash: bytes32, requestOrderVolume: uint256, requestOrderTypedDataHash: bytes32): uint256 + + + +15->34 + + - + + +35 + +<<Library>> +EscrowLib +contracts/libs/EscrowLib.sol + +Internal: +    lock(account: address, value: uint256) +    unlock(account: address, value: uint256) +    reward(account: address, value: uint256, ref: bytes32) +    seize(account: address, value: uint256, ref: bytes32) +    rewardAndLock(account: address, value: uint256, ref: bytes32) +Public: +    <<event>> Reward(owner: address, amount: uint256, ref: bytes32) +    <<event>> Seize(owner: address, amount: uint256, ref: bytes32) +    <<event>> Lock(owner: address, amount: uint256) +    <<event>> Unlock(owner: address, amount: uint256) + + -18->6 - - +15->35 + + - - -18->68 - - + + +36 + +<<Library>> +IexecLibCore_v5 +contracts/libs/IexecLibCore_v5.sol - + + +15->36 + + + + -33 - -<<Interface>> -IexecPocoBoost -contracts/interfaces/IexecPocoBoost.sol - -External: -     matchOrdersBoost(appOrder: IexecLibOrders_v5.AppOrder, datasetOrder: IexecLibOrders_v5.DatasetOrder, workerpoolOrder: IexecLibOrders_v5.WorkerpoolOrder, requestOrder: IexecLibOrders_v5.RequestOrder): bytes32 -     sponsorMatchOrdersBoost(appOrder: IexecLibOrders_v5.AppOrder, datasetOrder: IexecLibOrders_v5.DatasetOrder, workerpoolOrder: IexecLibOrders_v5.WorkerpoolOrder, requestOrder: IexecLibOrders_v5.RequestOrder): bytes32 -     pushResultBoost(dealId: bytes32, index: uint256, results: bytes, resultsCallback: bytes, authorizationSign: bytes, enclaveChallenge: address, enclaveSign: bytes) -     claimBoost(dealId: bytes32, index: uint256) -Public: -    <<event>> SchedulerNoticeBoost(workerpool: address, dealId: bytes32, app: address, dataset: address, category: uint256, tag: bytes32, params: string, beneficiary: address) -    <<event>> OrdersMatched(dealid: bytes32, appHash: bytes32, datasetHash: bytes32, workerpoolHash: bytes32, requestHash: bytes32, volume: uint256) -    <<event>> ResultPushedBoost(dealId: bytes32, index: uint256, results: bytes) -    <<event>> TaskClaimed(taskid: bytes32) -    <<event>> DealSponsoredBoost(dealId: bytes32, sponsor: address) - - +44 + +<<Struct>> +DealBoost +contracts/libs/IexecLibCore_v5.sol + +appOwner: address +appPrice: uint96 +datasetOwner: address +datasetPrice: uint96 +workerpoolOwner: address +workerpoolPrice: uint96 +requester: address +workerReward: uint96 +callback: address +deadline: uint40 +botFirst: uint16 +botSize: uint16 +shortTag: bytes3 +sponsor: address + + -18->33 - - - - - -37 - -<<Library>> -IexecLibCore_v5 -contracts/libs/IexecLibCore_v5.sol - - - -18->37 - - +15->44 + + - + 45 - -<<Struct>> -DealBoost -contracts/libs/IexecLibCore_v5.sol - -appOwner: address -appPrice: uint96 -datasetOwner: address -datasetPrice: uint96 -workerpoolOwner: address -workerpoolPrice: uint96 -requester: address -workerReward: uint96 -callback: address -deadline: uint40 -botFirst: uint16 -botSize: uint16 -shortTag: bytes3 -sponsor: address - - - -18->45 - - + +<<Enum>> +TaskStatusEnum +contracts/libs/IexecLibCore_v5.sol + +UNSET: 0 +ACTIVE: 1 +REVEALING: 2 +COMPLETED: 3 +FAILED: 4 + + + +15->45 + + - + 46 - -<<Enum>> -TaskStatusEnum -contracts/libs/IexecLibCore_v5.sol - -UNSET: 0 -ACTIVE: 1 -REVEALING: 2 -COMPLETED: 3 -FAILED: 4 - - - -18->46 - - + +<<Struct>> +Task +contracts/libs/IexecLibCore_v5.sol + +status: TaskStatusEnum +dealid: bytes32 +idx: uint256 +timeref: uint256 +contributionDeadline: uint256 +revealDeadline: uint256 +finalDeadline: uint256 +consensusValue: bytes32 +revealCounter: uint256 +winnerCounter: uint256 +contributors: address[] +resultDigest: bytes32 +results: bytes +resultsTimestamp: uint256 +resultsCallback: bytes + + + +15->46 + + - - -47 - -<<Struct>> -Task -contracts/libs/IexecLibCore_v5.sol - -status: TaskStatusEnum -dealid: bytes32 -idx: uint256 -timeref: uint256 -contributionDeadline: uint256 -revealDeadline: uint256 -finalDeadline: uint256 -consensusValue: bytes32 -revealCounter: uint256 -winnerCounter: uint256 -contributors: address[] -resultDigest: bytes32 -results: bytes -resultsTimestamp: uint256 -resultsCallback: bytes - - - -18->47 - - + + +50 + +<<Library>> +IexecLibOrders_v5 +contracts/libs/IexecLibOrders_v5.sol + +Public: +   EIP712DOMAIN_TYPEHASH: bytes32 +   APPORDER_TYPEHASH: bytes32 +   DATASETORDER_TYPEHASH: bytes32 +   WORKERPOOLORDER_TYPEHASH: bytes32 +   REQUESTORDER_TYPEHASH: bytes32 +   APPORDEROPERATION_TYPEHASH: bytes32 +   DATASETORDEROPERATION_TYPEHASH: bytes32 +   WORKERPOOLORDEROPERATION_TYPEHASH: bytes32 +   REQUESTORDEROPERATION_TYPEHASH: bytes32 + +Public: +    hash(_domain: EIP712Domain): (domainhash: bytes32) +    hash(_apporder: AppOrder): (apphash: bytes32) +    hash(_datasetorder: DatasetOrder): (datasethash: bytes32) +    hash(_workerpoolorder: WorkerpoolOrder): (workerpoolhash: bytes32) +    hash(_requestorder: RequestOrder): (requesthash: bytes32) +    hash(_apporderoperation: AppOrderOperation): bytes32 +    hash(_datasetorderoperation: DatasetOrderOperation): bytes32 +    hash(_workerpoolorderoperation: WorkerpoolOrderOperation): bytes32 +    hash(_requestorderoperation: RequestOrderOperation): bytes32 + + + +15->50 + + - - -18->51 - - + + +53 + +<<Struct>> +AppOrder +contracts/libs/IexecLibOrders_v5.sol + +app: address +appprice: uint256 +volume: uint256 +tag: bytes32 +datasetrestrict: address +workerpoolrestrict: address +requesterrestrict: address +salt: bytes32 +sign: bytes + + + +15->53 + + - + 54 - -<<Struct>> -AppOrder -contracts/libs/IexecLibOrders_v5.sol - -app: address -appprice: uint256 -volume: uint256 -tag: bytes32 -datasetrestrict: address -workerpoolrestrict: address -requesterrestrict: address -salt: bytes32 -sign: bytes - - - -18->54 - - + +<<Struct>> +DatasetOrder +contracts/libs/IexecLibOrders_v5.sol + +dataset: address +datasetprice: uint256 +volume: uint256 +tag: bytes32 +apprestrict: address +workerpoolrestrict: address +requesterrestrict: address +salt: bytes32 +sign: bytes + + + +15->54 + + - + 55 - -<<Struct>> -DatasetOrder -contracts/libs/IexecLibOrders_v5.sol - -dataset: address -datasetprice: uint256 -volume: uint256 -tag: bytes32 -apprestrict: address -workerpoolrestrict: address -requesterrestrict: address -salt: bytes32 -sign: bytes - - - -18->55 - - + +<<Struct>> +WorkerpoolOrder +contracts/libs/IexecLibOrders_v5.sol + +workerpool: address +workerpoolprice: uint256 +volume: uint256 +tag: bytes32 +category: uint256 +trust: uint256 +apprestrict: address +datasetrestrict: address +requesterrestrict: address +salt: bytes32 +sign: bytes + + + +15->55 + + - + 56 - -<<Struct>> -WorkerpoolOrder -contracts/libs/IexecLibOrders_v5.sol - -workerpool: address -workerpoolprice: uint256 -volume: uint256 -tag: bytes32 -category: uint256 -trust: uint256 -apprestrict: address -datasetrestrict: address -requesterrestrict: address -salt: bytes32 -sign: bytes - - + +<<Struct>> +RequestOrder +contracts/libs/IexecLibOrders_v5.sol + +app: address +appmaxprice: uint256 +dataset: address +datasetmaxprice: uint256 +workerpool: address +workerpoolmaxprice: uint256 +requester: address +volume: uint256 +tag: bytes32 +category: uint256 +trust: uint256 +beneficiary: address +callback: address +params: string +salt: bytes32 +sign: bytes + + + +15->56 + + + + + +61 + +<<Library>> +PocoStorageLib +contracts/libs/PocoStorageLib.sol + +Private: +   POCO_STORAGE_LOCATION: bytes32 + +Internal: +    getPocoStorage(): ($: PocoStorage) + + + +15->61 + + + + + +62 + +<<Struct>> +PocoStorage +contracts/libs/PocoStorageLib.sol + +m_appregistry: IRegistry +m_datasetregistry: IRegistry +m_workerpoolregistry: IRegistry +m_baseToken: IERC20 +m_name: string +m_symbol: string +m_decimals: uint8 +m_totalSupply: uint256 +m_balances: mapping(address=>uint256) +m_frozens: mapping(address=>uint256) +m_allowances: mapping(address=>mapping(address=>uint256)) +m_eip712DomainSeparator: bytes32 +m_presigned: mapping(bytes32=>address) +m_consumed: mapping(bytes32=>uint256) +m_deals: mapping(bytes32=>IexecLibCore_v5.Deal) +m_tasks: mapping(bytes32=>IexecLibCore_v5.Task) +m_consensus: mapping(bytes32=>IexecLibCore_v5.Consensus) +m_contributions: mapping(bytes32=>mapping(address=>IexecLibCore_v5.Contribution)) +m_workerScores: mapping(address=>uint256) +m_teebroker: address +m_callbackgas: uint256 +m_categories: IexecLibCore_v5.Category[] +m_v3_iexecHub: IexecHubV3Interface +m_v3_scoreImported: mapping(address=>bool) +m_dealsBoost: mapping(bytes32=>IexecLibCore_v5.DealBoost) + + + +15->62 + + + + + +79 + +<<Interface>> +IWorkerpool +contracts/registries/workerpools/IWorkerpool.v8.sol + +External: +     owner(): address +     m_workerpoolDescription(): string +     m_schedulerRewardRatioPolicy(): uint256 +     m_workerStakeRatioPolicy(): uint256 + + + +15->79 + + + + + +24 + +<<Interface>> +IexecHubV3Interface +contracts/interfaces/IexecHubV3Interface.sol + +External: +     viewScore(worker: address): uint256 + + + +30->50 + + + + -18->56 - - +30->53 + + - - -57 - -<<Struct>> -RequestOrder -contracts/libs/IexecLibOrders_v5.sol - -app: address -appmaxprice: uint256 -dataset: address -datasetmaxprice: uint256 -workerpool: address -workerpoolmaxprice: uint256 -requester: address -volume: uint256 -tag: bytes32 -category: uint256 -trust: uint256 -beneficiary: address -callback: address -params: string -salt: bytes32 -sign: bytes - - + -18->57 - - +30->54 + + - + -18->62 - - +30->55 + + - + -18->63 - - +30->56 + + - - -79 - -<<Interface>> -IWorkerpool -contracts/registries/workerpools/IWorkerpool.v8.sol - -External: -     owner(): address -     m_workerpoolDescription(): string -     m_schedulerRewardRatioPolicy(): uint256 -     m_workerStakeRatioPolicy(): uint256 - - - -18->79 - - + + +34->61 + + - - -27 - -<<Interface>> -IexecHubV3Interface -contracts/interfaces/IexecHubV3Interface.sol - -External: -     viewScore(worker: address): uint256 - - - -33->51 - - + + +34->62 + + - - -33->54 - - + + +35->61 + + - - -33->55 - - + + +35->62 + + - - -33->56 - - + + +63 + +<<Library>> +StakedRlcLib +contracts/libs/StakedRlcLib.sol + +Internal: +    transfer(from: address, to: address, value: uint256) +    mint(account: address, amount: uint256) +    burn(account: address, amount: uint256) +    approve(owner: address, spender: address, amount: uint256) +Public: +    <<event>> Transfer(from: address, to: address, value: uint256) +    <<event>> Approval(owner: address, spender: address, value: uint256) + + + +35->63 + + - - -33->57 - - + + +44->36 + + - - -45->37 - - + + +45->36 + + - - -46->37 - - + + +46->36 + + - - -47->37 - - + + +46->45 + + - - -47->46 - - + + +52 + +<<Struct>> +EIP712Domain +contracts/libs/IexecLibOrders_v5.sol + +name: string +version: string +chainId: uint256 +verifyingContract: address + + + +50->52 + + - - -53 - -<<Struct>> -EIP712Domain -contracts/libs/IexecLibOrders_v5.sol - -name: string -version: string -chainId: uint256 -verifyingContract: address - - - -51->53 - - + + +50->53 + + - - -51->54 - - + + +50->54 + + - - -51->55 - - + + +50->55 + + - - -51->56 - - + + +50->56 + + - - -51->57 - - + + +57 + +<<Struct>> +AppOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: AppOrder +operation: OrderOperationEnum +sign: bytes + + + +50->57 + + - + 58 - -<<Struct>> -AppOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: AppOrder -operation: OrderOperationEnum -sign: bytes - - - -51->58 - - + +<<Struct>> +DatasetOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: DatasetOrder +operation: OrderOperationEnum +sign: bytes + + + +50->58 + + - + 59 - -<<Struct>> -DatasetOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: DatasetOrder -operation: OrderOperationEnum -sign: bytes - - - -51->59 - - + +<<Struct>> +WorkerpoolOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: WorkerpoolOrder +operation: OrderOperationEnum +sign: bytes + + + +50->59 + + - + 60 - -<<Struct>> -WorkerpoolOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: WorkerpoolOrder -operation: OrderOperationEnum -sign: bytes - - - -51->60 - - + +<<Struct>> +RequestOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: RequestOrder +operation: OrderOperationEnum +sign: bytes + + + +50->60 + + - - -61 - -<<Struct>> -RequestOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: RequestOrder -operation: OrderOperationEnum -sign: bytes - - - -51->61 - - + + +51 + +<<Enum>> +OrderOperationEnum +contracts/libs/IexecLibOrders_v5.sol + +SIGN: 0 +CLOSE: 1 + + + +51->50 + + - - -52 - -<<Enum>> -OrderOperationEnum -contracts/libs/IexecLibOrders_v5.sol - -SIGN: 0 -CLOSE: 1 - - - -52->51 - - + + +52->50 + + - - -53->51 - - + + +53->50 + + - - -54->51 - - + + +54->50 + + - - -55->51 - - + + +55->50 + + - - -56->51 - - + + +56->50 + + + + + +57->50 + + - + 57->51 - - + + + + + +57->53 + + + + + +58->50 + + - + 58->51 - - - - - -58->52 - - + + - + 58->54 - - + + + + + +59->50 + + - + 59->51 - - - - - -59->52 - - + + - + 59->55 - - + + + + + +60->50 + + - + 60->51 - - - - - -60->52 - - + + - + 60->56 - - - - - -61->51 - - + + - - -61->52 - - + + +61->62 + + - + -61->57 - - - - - -62->63 - - - - - -63->27 - - - - - -63->37 - - +62->24 + + - - -63->62 - - + + +62->36 + + + + + +62->61 + + - + 64 - -<<Interface>> -IRegistry -contracts/registries/IRegistry.sol - -External: -     isRegistered(_entry: address): bool - - - -63->64 - - + +<<Interface>> +IRegistry +contracts/registries/IRegistry.sol + +External: +     isRegistered(_entry: address): bool + + + +62->64 + + + + + +63->61 + + + + + +63->62 + + diff --git a/docs/uml/class-uml-IexecPocoFacets.svg b/docs/uml/class-uml-IexecPocoFacets.svg index 2b01ae3df..bca055427 100644 --- a/docs/uml/class-uml-IexecPocoFacets.svg +++ b/docs/uml/class-uml-IexecPocoFacets.svg @@ -4,1106 +4,1086 @@ - - + + UmlClassDiagram - + 3 - -<<Abstract>> -FacetBase -contracts/abstract/FacetBase.sol - -Internal: -   CONTRIBUTION_DEADLINE_RATIO: uint256 -   REVEAL_DEADLINE_RATIO: uint256 -   FINAL_DEADLINE_RATIO: uint256 -   WORKERPOOL_STAKE_RATIO: uint256 -   KITTY_RATIO: uint256 -   KITTY_MIN: uint256 -   KITTY_ADDRESS: address -   GROUPMEMBER_PURPOSE: uint256 - -Internal: -    owner(): address -    _msgSender(): address -Public: -    <<modifier>> onlyOwner() - - + +<<Abstract>> +FacetBase +contracts/abstract/FacetBase.sol + +Internal: +   CONTRIBUTION_DEADLINE_RATIO: uint256 +   REVEAL_DEADLINE_RATIO: uint256 +   FINAL_DEADLINE_RATIO: uint256 +   WORKERPOOL_STAKE_RATIO: uint256 +   KITTY_RATIO: uint256 +   KITTY_MIN: uint256 +   KITTY_ADDRESS: address +   GROUPMEMBER_PURPOSE: uint256 + +Internal: +    owner(): address +    _msgSender(): address +Public: +    <<modifier>> onlyOwner() + + -4 - -<<Abstract>> -IexecEscrow -contracts/abstract/IexecEscrow.sol - -Internal: -    lock(account: address, value: uint256) -    unlock(account: address, value: uint256) -    reward(account: address, value: uint256, ref: bytes32) -    seize(account: address, value: uint256, ref: bytes32) -    rewardAndLock(account: address, value: uint256, ref: bytes32) -    _transfer(from: address, to: address, value: uint256) - - - -4->3 - - +10 + +<<Struct>> +Matching +contracts/facets/IexecPoco1Facet.sol + +apporderHash: bytes32 +appOwner: address +datasetorderHash: bytes32 +datasetOwner: address +workerpoolorderHash: bytes32 +workerpoolOwner: address +requestorderHash: bytes32 +hasDataset: bool + + + +11 + +IexecPoco1Facet +contracts/facets/IexecPoco1Facet.sol + +Private: +    _matchOrders(_apporder: IexecLibOrders_v5.AppOrder, _datasetorder: IexecLibOrders_v5.DatasetOrder, _workerpoolorder: IexecLibOrders_v5.WorkerpoolOrder, _requestorder: IexecLibOrders_v5.RequestOrder, _sponsor: address): bytes32 +    _ignoreTeeFramework(tag: bytes32): bytes32 +External: +    verifySignature(_identity: address, _hash: bytes32, _signature: bytes): bool +    verifyPresignature(_identity: address, _hash: bytes32): bool +    verifyPresignatureOrSignature(_identity: address, _hash: bytes32, _signature: bytes): bool +    assertDatasetDealCompatibility(datasetOrder: IexecLibOrders_v5.DatasetOrder, dealId: bytes32) +    matchOrders(_apporder: IexecLibOrders_v5.AppOrder, _datasetorder: IexecLibOrders_v5.DatasetOrder, _workerpoolorder: IexecLibOrders_v5.WorkerpoolOrder, _requestorder: IexecLibOrders_v5.RequestOrder): bytes32 +    sponsorMatchOrders(_apporder: IexecLibOrders_v5.AppOrder, _datasetorder: IexecLibOrders_v5.DatasetOrder, _workerpoolorder: IexecLibOrders_v5.WorkerpoolOrder, _requestorder: IexecLibOrders_v5.RequestOrder): bytes32 + + + +11->3 + + - - -25 - -<<Interface>> -IexecEscrowEvents -contracts/interfaces/IexecEscrowEvents.sol - -Public: -    <<event>> Transfer(from: address, to: address, value: uint256) -    <<event>> Approval(owner: address, spender: address, value: uint256) -    <<event>> Reward(owner: address, amount: uint256, ref: bytes32) -    <<event>> Seize(owner: address, amount: uint256, ref: bytes32) -    <<event>> Lock(owner: address, amount: uint256) -    <<event>> Unlock(owner: address, amount: uint256) - - - -4->25 - - + + +11->10 + + - - -62 - -<<Library>> -PocoStorageLib -contracts/libs/PocoStorageLib.sol - -Private: -   POCO_STORAGE_LOCATION: bytes32 - -Internal: -    getPocoStorage(): ($: PocoStorage) - - - -4->62 - - + + +26 + +<<Interface>> +IexecPoco1 +contracts/interfaces/IexecPoco1.sol + +External: +     verifySignature(address, bytes32, bytes): bool +     verifyPresignature(address, bytes32): bool +     verifyPresignatureOrSignature(address, bytes32, bytes): bool +     assertDatasetDealCompatibility(datasetOrder: IexecLibOrders_v5.DatasetOrder, dealId: bytes32) +     matchOrders(IexecLibOrders_v5.AppOrder, IexecLibOrders_v5.DatasetOrder, IexecLibOrders_v5.WorkerpoolOrder, IexecLibOrders_v5.RequestOrder): bytes32 +     sponsorMatchOrders(IexecLibOrders_v5.AppOrder, IexecLibOrders_v5.DatasetOrder, IexecLibOrders_v5.WorkerpoolOrder, IexecLibOrders_v5.RequestOrder): bytes32 +Public: +    <<event>> SchedulerNotice(workerpool: address, dealid: bytes32) +    <<event>> OrdersMatched(dealid: bytes32, appHash: bytes32, datasetHash: bytes32, workerpoolHash: bytes32, requestHash: bytes32, volume: uint256) +    <<event>> DealSponsored(dealId: bytes32, sponsor: address) + + + +11->26 + + - - -63 - -<<Struct>> -PocoStorage -contracts/libs/PocoStorageLib.sol - -m_appregistry: IRegistry -m_datasetregistry: IRegistry -m_workerpoolregistry: IRegistry -m_baseToken: IERC20 -m_name: string -m_symbol: string -m_decimals: uint8 -m_totalSupply: uint256 -m_balances: mapping(address=>uint256) -m_frozens: mapping(address=>uint256) -m_allowances: mapping(address=>mapping(address=>uint256)) -m_eip712DomainSeparator: bytes32 -m_presigned: mapping(bytes32=>address) -m_consumed: mapping(bytes32=>uint256) -m_deals: mapping(bytes32=>IexecLibCore_v5.Deal) -m_tasks: mapping(bytes32=>IexecLibCore_v5.Task) -m_consensus: mapping(bytes32=>IexecLibCore_v5.Consensus) -m_contributions: mapping(bytes32=>mapping(address=>IexecLibCore_v5.Contribution)) -m_workerScores: mapping(address=>uint256) -m_teebroker: address -m_callbackgas: uint256 -m_categories: IexecLibCore_v5.Category[] -m_v3_iexecHub: IexecHubV3Interface -m_v3_scoreImported: mapping(address=>bool) -m_dealsBoost: mapping(bytes32=>IexecLibCore_v5.DealBoost) - - - -4->63 - - + + +27 + +<<Interface>> +IexecPoco1Errors +contracts/interfaces/IexecPoco1Errors.sol - - -5 - -<<Abstract>> -IexecPocoCommon -contracts/abstract/IexecPocoCommon.sol - -Internal: -    _computeDealVolume(appOrderVolume: uint256, appOrderTypedDataHash: bytes32, hasDataset: bool, datasetOrderVolume: uint256, datasetOrderTypedDataHash: bytes32, workerpoolOrderVolume: uint256, workerpoolOrderTypedDataHash: bytes32, requestOrderVolume: uint256, requestOrderTypedDataHash: bytes32): uint256 - - - -5->3 - - + + +11->27 + + - - -51 - -<<Library>> -IexecLibOrders_v5 -contracts/libs/IexecLibOrders_v5.sol - -Public: -   EIP712DOMAIN_TYPEHASH: bytes32 -   APPORDER_TYPEHASH: bytes32 -   DATASETORDER_TYPEHASH: bytes32 -   WORKERPOOLORDER_TYPEHASH: bytes32 -   REQUESTORDER_TYPEHASH: bytes32 -   APPORDEROPERATION_TYPEHASH: bytes32 -   DATASETORDEROPERATION_TYPEHASH: bytes32 -   WORKERPOOLORDEROPERATION_TYPEHASH: bytes32 -   REQUESTORDEROPERATION_TYPEHASH: bytes32 - -Public: -    hash(_domain: EIP712Domain): (domainhash: bytes32) -    hash(_apporder: AppOrder): (apphash: bytes32) -    hash(_datasetorder: DatasetOrder): (datasethash: bytes32) -    hash(_workerpoolorder: WorkerpoolOrder): (workerpoolhash: bytes32) -    hash(_requestorder: RequestOrder): (requesthash: bytes32) -    hash(_apporderoperation: AppOrderOperation): bytes32 -    hash(_datasetorderoperation: DatasetOrderOperation): bytes32 -    hash(_workerpoolorderoperation: WorkerpoolOrderOperation): bytes32 -    hash(_requestorderoperation: RequestOrderOperation): bytes32 - - - -5->51 - - + + +34 + +<<Library>> +CommonLib +contracts/libs/CommonLib.sol + +Private: +   GROUPMEMBER_PURPOSE: uint256 + +Internal: +    toTypedDataHash(structHash: bytes32): bytes32 +    verifySignatureOfEthSignedMessage(account: address, message: bytes, signature: bytes): bool +    verifySignature(account: address, messageHash: bytes32, signature: bytes): bool +    verifyPresignature(account: address, messageHash: bytes32): bool +    verifySignatureOrPresignature(account: address, messageHash: bytes32, signature: bytes): bool +    isAccountAuthorizedByRestriction(restriction: address, account: address): bool +    computeDealVolume(appOrderVolume: uint256, appOrderTypedDataHash: bytes32, hasDataset: bool, datasetOrderVolume: uint256, datasetOrderTypedDataHash: bytes32, workerpoolOrderVolume: uint256, workerpoolOrderTypedDataHash: bytes32, requestOrderVolume: uint256, requestOrderTypedDataHash: bytes32): uint256 + + + +11->34 + + - - -5->62 - - + + +35 + +<<Library>> +EscrowLib +contracts/libs/EscrowLib.sol + +Internal: +    lock(account: address, value: uint256) +    unlock(account: address, value: uint256) +    reward(account: address, value: uint256, ref: bytes32) +    seize(account: address, value: uint256, ref: bytes32) +    rewardAndLock(account: address, value: uint256, ref: bytes32) +Public: +    <<event>> Reward(owner: address, amount: uint256, ref: bytes32) +    <<event>> Seize(owner: address, amount: uint256, ref: bytes32) +    <<event>> Lock(owner: address, amount: uint256) +    <<event>> Unlock(owner: address, amount: uint256) + + + +11->35 + + - - -5->63 - - + + +36 + +<<Library>> +IexecLibCore_v5 +contracts/libs/IexecLibCore_v5.sol - - -6 - -<<Abstract>> -SignatureVerifier -contracts/abstract/SignatureVerifier.sol - -Internal: -    _toTypedDataHash(structHash: bytes32): bytes32 -    _verifySignatureOfEthSignedMessage(account: address, message: bytes, signature: bytes): bool -    _verifySignature(account: address, messageHash: bytes32, signature: bytes): bool -    _verifyPresignature(account: address, messageHash: bytes32): bool -    _verifySignatureOrPresignature(account: address, messageHash: bytes32, signature: bytes): bool -    _isAccountAuthorizedByRestriction(restriction: address, account: address): bool - - + -6->3 - - +11->36 + + - + + +43 + +<<Struct>> +Deal +contracts/libs/IexecLibCore_v5.sol + +app: Resource +dataset: Resource +workerpool: Resource +trust: uint256 +category: uint256 +tag: bytes32 +requester: address +beneficiary: address +callback: address +params: string +startTime: uint256 +botFirst: uint256 +botSize: uint256 +workerStake: uint256 +schedulerRewardRatio: uint256 +sponsor: address + + -6->62 - - - - - -6->63 - - +11->43 + + - - -13 - -<<Struct>> -Matching -contracts/facets/IexecPoco1Facet.sol - -apporderHash: bytes32 -appOwner: address -datasetorderHash: bytes32 -datasetOwner: address -workerpoolorderHash: bytes32 -workerpoolOwner: address -requestorderHash: bytes32 -hasDataset: bool - - - -14 - -IexecPoco1Facet -contracts/facets/IexecPoco1Facet.sol - -Private: -    _matchOrders(_apporder: IexecLibOrders_v5.AppOrder, _datasetorder: IexecLibOrders_v5.DatasetOrder, _workerpoolorder: IexecLibOrders_v5.WorkerpoolOrder, _requestorder: IexecLibOrders_v5.RequestOrder, _sponsor: address): bytes32 -    _ignoreTeeFramework(tag: bytes32): bytes32 -External: -    verifySignature(_identity: address, _hash: bytes32, _signature: bytes): bool -    verifyPresignature(_identity: address, _hash: bytes32): bool -    verifyPresignatureOrSignature(_identity: address, _hash: bytes32, _signature: bytes): bool -    assertDatasetDealCompatibility(datasetOrder: IexecLibOrders_v5.DatasetOrder, dealId: bytes32) -    matchOrders(_apporder: IexecLibOrders_v5.AppOrder, _datasetorder: IexecLibOrders_v5.DatasetOrder, _workerpoolorder: IexecLibOrders_v5.WorkerpoolOrder, _requestorder: IexecLibOrders_v5.RequestOrder): bytes32 -    sponsorMatchOrders(_apporder: IexecLibOrders_v5.AppOrder, _datasetorder: IexecLibOrders_v5.DatasetOrder, _workerpoolorder: IexecLibOrders_v5.WorkerpoolOrder, _requestorder: IexecLibOrders_v5.RequestOrder): bytes32 - - - -14->4 - - - - - -14->5 - - + + +50 + +<<Library>> +IexecLibOrders_v5 +contracts/libs/IexecLibOrders_v5.sol + +Public: +   EIP712DOMAIN_TYPEHASH: bytes32 +   APPORDER_TYPEHASH: bytes32 +   DATASETORDER_TYPEHASH: bytes32 +   WORKERPOOLORDER_TYPEHASH: bytes32 +   REQUESTORDER_TYPEHASH: bytes32 +   APPORDEROPERATION_TYPEHASH: bytes32 +   DATASETORDEROPERATION_TYPEHASH: bytes32 +   WORKERPOOLORDEROPERATION_TYPEHASH: bytes32 +   REQUESTORDEROPERATION_TYPEHASH: bytes32 + +Public: +    hash(_domain: EIP712Domain): (domainhash: bytes32) +    hash(_apporder: AppOrder): (apphash: bytes32) +    hash(_datasetorder: DatasetOrder): (datasethash: bytes32) +    hash(_workerpoolorder: WorkerpoolOrder): (workerpoolhash: bytes32) +    hash(_requestorder: RequestOrder): (requesthash: bytes32) +    hash(_apporderoperation: AppOrderOperation): bytes32 +    hash(_datasetorderoperation: DatasetOrderOperation): bytes32 +    hash(_workerpoolorderoperation: WorkerpoolOrderOperation): bytes32 +    hash(_requestorderoperation: RequestOrderOperation): bytes32 + + + +11->50 + + - - -14->6 - - + + +53 + +<<Struct>> +AppOrder +contracts/libs/IexecLibOrders_v5.sol + +app: address +appprice: uint256 +volume: uint256 +tag: bytes32 +datasetrestrict: address +workerpoolrestrict: address +requesterrestrict: address +salt: bytes32 +sign: bytes + + + +11->53 + + - - -14->13 - - + + +54 + +<<Struct>> +DatasetOrder +contracts/libs/IexecLibOrders_v5.sol + +dataset: address +datasetprice: uint256 +volume: uint256 +tag: bytes32 +apprestrict: address +workerpoolrestrict: address +requesterrestrict: address +salt: bytes32 +sign: bytes + + + +11->54 + + - - -29 - -<<Interface>> -IexecPoco1 -contracts/interfaces/IexecPoco1.sol - -External: -     verifySignature(address, bytes32, bytes): bool -     verifyPresignature(address, bytes32): bool -     verifyPresignatureOrSignature(address, bytes32, bytes): bool -     assertDatasetDealCompatibility(datasetOrder: IexecLibOrders_v5.DatasetOrder, dealId: bytes32) -     matchOrders(IexecLibOrders_v5.AppOrder, IexecLibOrders_v5.DatasetOrder, IexecLibOrders_v5.WorkerpoolOrder, IexecLibOrders_v5.RequestOrder): bytes32 -     sponsorMatchOrders(IexecLibOrders_v5.AppOrder, IexecLibOrders_v5.DatasetOrder, IexecLibOrders_v5.WorkerpoolOrder, IexecLibOrders_v5.RequestOrder): bytes32 -Public: -    <<event>> SchedulerNotice(workerpool: address, dealid: bytes32) -    <<event>> OrdersMatched(dealid: bytes32, appHash: bytes32, datasetHash: bytes32, workerpoolHash: bytes32, requestHash: bytes32, volume: uint256) -    <<event>> DealSponsored(dealId: bytes32, sponsor: address) - - + + +55 + +<<Struct>> +WorkerpoolOrder +contracts/libs/IexecLibOrders_v5.sol + +workerpool: address +workerpoolprice: uint256 +volume: uint256 +tag: bytes32 +category: uint256 +trust: uint256 +apprestrict: address +datasetrestrict: address +requesterrestrict: address +salt: bytes32 +sign: bytes + + -14->29 - - +11->55 + + - - -30 - -<<Interface>> -IexecPoco1Errors -contracts/interfaces/IexecPoco1Errors.sol - - + + +56 + +<<Struct>> +RequestOrder +contracts/libs/IexecLibOrders_v5.sol + +app: address +appmaxprice: uint256 +dataset: address +datasetmaxprice: uint256 +workerpool: address +workerpoolmaxprice: uint256 +requester: address +volume: uint256 +tag: bytes32 +category: uint256 +trust: uint256 +beneficiary: address +callback: address +params: string +salt: bytes32 +sign: bytes + + -14->30 - - +11->56 + + - - -37 - -<<Library>> -IexecLibCore_v5 -contracts/libs/IexecLibCore_v5.sol + + +61 + +<<Library>> +PocoStorageLib +contracts/libs/PocoStorageLib.sol + +Private: +   POCO_STORAGE_LOCATION: bytes32 + +Internal: +    getPocoStorage(): ($: PocoStorage) + + + +11->61 + + - - -14->37 - - + + +62 + +<<Struct>> +PocoStorage +contracts/libs/PocoStorageLib.sol + +m_appregistry: IRegistry +m_datasetregistry: IRegistry +m_workerpoolregistry: IRegistry +m_baseToken: IERC20 +m_name: string +m_symbol: string +m_decimals: uint8 +m_totalSupply: uint256 +m_balances: mapping(address=>uint256) +m_frozens: mapping(address=>uint256) +m_allowances: mapping(address=>mapping(address=>uint256)) +m_eip712DomainSeparator: bytes32 +m_presigned: mapping(bytes32=>address) +m_consumed: mapping(bytes32=>uint256) +m_deals: mapping(bytes32=>IexecLibCore_v5.Deal) +m_tasks: mapping(bytes32=>IexecLibCore_v5.Task) +m_consensus: mapping(bytes32=>IexecLibCore_v5.Consensus) +m_contributions: mapping(bytes32=>mapping(address=>IexecLibCore_v5.Contribution)) +m_workerScores: mapping(address=>uint256) +m_teebroker: address +m_callbackgas: uint256 +m_categories: IexecLibCore_v5.Category[] +m_v3_iexecHub: IexecHubV3Interface +m_v3_scoreImported: mapping(address=>bool) +m_dealsBoost: mapping(bytes32=>IexecLibCore_v5.DealBoost) + + + +11->62 + + - - -44 - -<<Struct>> -Deal -contracts/libs/IexecLibCore_v5.sol - -app: Resource -dataset: Resource -workerpool: Resource -trust: uint256 -category: uint256 -tag: bytes32 -requester: address -beneficiary: address -callback: address -params: string -startTime: uint256 -botFirst: uint256 -botSize: uint256 -workerStake: uint256 -schedulerRewardRatio: uint256 -sponsor: address - - - -14->44 - - + + +79 + +<<Interface>> +IWorkerpool +contracts/registries/workerpools/IWorkerpool.v8.sol + +External: +     owner(): address +     m_workerpoolDescription(): string +     m_schedulerRewardRatioPolicy(): uint256 +     m_workerStakeRatioPolicy(): uint256 + + + +11->79 + + - + + +12 + +IexecPoco2Facet +contracts/facets/IexecPoco2Facet.sol + +Internal: +    successWork(_dealid: bytes32, _taskid: bytes32) +    failedWork(_dealid: bytes32, _taskid: bytes32) +    checkConsensus(_taskid: bytes32, _consensus: bytes32) +    distributeRewards(_taskid: bytes32) +    distributeRewardsFast(_taskid: bytes32) +    executeCallback(_taskid: bytes32, _resultsCallback: bytes) +External: +    contribute(_taskid: bytes32, _resultHash: bytes32, _resultSeal: bytes32, _enclaveChallenge: address, _enclaveSign: bytes, _authorizationSign: bytes) +    contributeAndFinalize(_taskid: bytes32, _resultDigest: bytes32, _results: bytes, _resultsCallback: bytes, _enclaveChallenge: address, _enclaveSign: bytes, _authorizationSign: bytes) +    reveal(_taskid: bytes32, _resultDigest: bytes32) +    reopen(_taskid: bytes32) <<onlyScheduler>> +    finalize(_taskid: bytes32, _results: bytes, _resultsCallback: bytes) <<onlyScheduler>> +    initializeArray(_dealid: bytes32[], _idx: uint256[]): bool +    claimArray(_taskid: bytes32[]): bool +    initializeAndClaimArray(_dealid: bytes32[], _idx: uint256[]): bool +Public: +    <<modifier>> onlyScheduler(_taskId: bytes32) +    initialize(_dealid: bytes32, idx: uint256): bytes32 +    claim(_taskid: bytes32) + + + +12->3 + + + + + +28 + +<<Interface>> +IexecPoco2 +contracts/interfaces/IexecPoco2.sol + +External: +     initialize(dealId: bytes32, index: uint256): bytes32 +     claim(taskId: bytes32) +     contribute(taskId: bytes32, resultHash: bytes32, resultSeal: bytes32, enclaveChallenge: address, enclaveSign: bytes, authorizationSign: bytes) +     contributeAndFinalize(taskId: bytes32, resultDigest: bytes32, results: bytes, resultsCallback: bytes, enclaveChallenge: address, enclaveSign: bytes, authorizationSign: bytes) +     reveal(taskId: bytes32, resultDigest: bytes32) +     reopen(taskId: bytes32) +     finalize(taskId: bytes32, results: bytes, resultsCallback: bytes) +     initializeArray(dealIds: bytes32[], indexes: uint256[]): bool +     claimArray(taskIds: bytes32[]): bool +     initializeAndClaimArray(dealIds: bytes32[], indexes: uint256[]): bool +Public: +    <<event>> AccurateContribution(worker: address, taskid: bytes32) +    <<event>> FaultyContribution(worker: address, taskid: bytes32) +    <<event>> TaskInitialize(taskid: bytes32, workerpool: address) +    <<event>> TaskContribute(taskid: bytes32, worker: address, hash: bytes32) +    <<event>> TaskConsensus(taskid: bytes32, consensus: bytes32) +    <<event>> TaskReveal(taskid: bytes32, worker: address, digest: bytes32) +    <<event>> TaskReopen(taskid: bytes32) +    <<event>> TaskFinalize(taskid: bytes32, results: bytes) +    <<event>> TaskClaimed(taskid: bytes32) + + -14->51 - - +12->28 + + - - -54 - -<<Struct>> -AppOrder -contracts/libs/IexecLibOrders_v5.sol - -app: address -appprice: uint256 -volume: uint256 -tag: bytes32 -datasetrestrict: address -workerpoolrestrict: address -requesterrestrict: address -salt: bytes32 -sign: bytes - - + + +12->34 + + + + -14->54 - - +12->35 + + - - -55 - -<<Struct>> -DatasetOrder -contracts/libs/IexecLibOrders_v5.sol - -dataset: address -datasetprice: uint256 -volume: uint256 -tag: bytes32 -apprestrict: address -workerpoolrestrict: address -requesterrestrict: address -salt: bytes32 -sign: bytes - - - -14->55 - - + + +12->36 + + - - -56 - -<<Struct>> -WorkerpoolOrder -contracts/libs/IexecLibOrders_v5.sol - -workerpool: address -workerpoolprice: uint256 -volume: uint256 -tag: bytes32 -category: uint256 -trust: uint256 -apprestrict: address -datasetrestrict: address -requesterrestrict: address -salt: bytes32 -sign: bytes - - + + +12->43 + + + + + +46 + +<<Struct>> +Task +contracts/libs/IexecLibCore_v5.sol + +status: TaskStatusEnum +dealid: bytes32 +idx: uint256 +timeref: uint256 +contributionDeadline: uint256 +revealDeadline: uint256 +finalDeadline: uint256 +consensusValue: bytes32 +revealCounter: uint256 +winnerCounter: uint256 +contributors: address[] +resultDigest: bytes32 +results: bytes +resultsTimestamp: uint256 +resultsCallback: bytes + + -14->56 - - +12->46 + + - - -57 - -<<Struct>> -RequestOrder -contracts/libs/IexecLibOrders_v5.sol - -app: address -appmaxprice: uint256 -dataset: address -datasetmaxprice: uint256 -workerpool: address -workerpoolmaxprice: uint256 -requester: address -volume: uint256 -tag: bytes32 -category: uint256 -trust: uint256 -beneficiary: address -callback: address -params: string -salt: bytes32 -sign: bytes - - + + +47 + +<<Struct>> +Consensus +contracts/libs/IexecLibCore_v5.sol + +group: mapping(bytes32=>uint256) +total: uint256 + + + +12->47 + + + + + +49 + +<<Struct>> +Contribution +contracts/libs/IexecLibCore_v5.sol + +status: ContributionStatusEnum +resultHash: bytes32 +resultSeal: bytes32 +enclaveChallenge: address +weight: uint256 + + -14->57 - - +12->49 + + - + -14->62 - - +12->61 + + - + -14->63 - - +12->62 + + - - -79 - -<<Interface>> -IWorkerpool -contracts/registries/workerpools/IWorkerpool.v8.sol - -External: -     owner(): address -     m_workerpoolDescription(): string -     m_schedulerRewardRatioPolicy(): uint256 -     m_workerStakeRatioPolicy(): uint256 - - - -14->79 - - + + +24 + +<<Interface>> +IexecHubV3Interface +contracts/interfaces/IexecHubV3Interface.sol + +External: +     viewScore(worker: address): uint256 + + + +26->50 + + - - -15 - -IexecPoco2Facet -contracts/facets/IexecPoco2Facet.sol - -Internal: -    successWork(_dealid: bytes32, _taskid: bytes32) -    failedWork(_dealid: bytes32, _taskid: bytes32) -    checkConsensus(_taskid: bytes32, _consensus: bytes32) -    distributeRewards(_taskid: bytes32) -    distributeRewardsFast(_taskid: bytes32) -    executeCallback(_taskid: bytes32, _resultsCallback: bytes) -External: -    contribute(_taskid: bytes32, _resultHash: bytes32, _resultSeal: bytes32, _enclaveChallenge: address, _enclaveSign: bytes, _authorizationSign: bytes) -    contributeAndFinalize(_taskid: bytes32, _resultDigest: bytes32, _results: bytes, _resultsCallback: bytes, _enclaveChallenge: address, _enclaveSign: bytes, _authorizationSign: bytes) -    reveal(_taskid: bytes32, _resultDigest: bytes32) -    reopen(_taskid: bytes32) <<onlyScheduler>> -    finalize(_taskid: bytes32, _results: bytes, _resultsCallback: bytes) <<onlyScheduler>> -    initializeArray(_dealid: bytes32[], _idx: uint256[]): bool -    claimArray(_taskid: bytes32[]): bool -    initializeAndClaimArray(_dealid: bytes32[], _idx: uint256[]): bool -Public: -    <<modifier>> onlyScheduler(_taskId: bytes32) -    initialize(_dealid: bytes32, idx: uint256): bytes32 -    claim(_taskid: bytes32) - - + + +26->53 + + + + -15->4 - - +26->54 + + - - -15->6 - - + + +26->55 + + - - -31 - -<<Interface>> -IexecPoco2 -contracts/interfaces/IexecPoco2.sol - -External: -     initialize(dealId: bytes32, index: uint256): bytes32 -     claim(taskId: bytes32) -     contribute(taskId: bytes32, resultHash: bytes32, resultSeal: bytes32, enclaveChallenge: address, enclaveSign: bytes, authorizationSign: bytes) -     contributeAndFinalize(taskId: bytes32, resultDigest: bytes32, results: bytes, resultsCallback: bytes, enclaveChallenge: address, enclaveSign: bytes, authorizationSign: bytes) -     reveal(taskId: bytes32, resultDigest: bytes32) -     reopen(taskId: bytes32) -     finalize(taskId: bytes32, results: bytes, resultsCallback: bytes) -     initializeArray(dealIds: bytes32[], indexes: uint256[]): bool -     claimArray(taskIds: bytes32[]): bool -     initializeAndClaimArray(dealIds: bytes32[], indexes: uint256[]): bool -Public: -    <<event>> AccurateContribution(worker: address, taskid: bytes32) -    <<event>> FaultyContribution(worker: address, taskid: bytes32) -    <<event>> TaskInitialize(taskid: bytes32, workerpool: address) -    <<event>> TaskContribute(taskid: bytes32, worker: address, hash: bytes32) -    <<event>> TaskConsensus(taskid: bytes32, consensus: bytes32) -    <<event>> TaskReveal(taskid: bytes32, worker: address, digest: bytes32) -    <<event>> TaskReopen(taskid: bytes32) -    <<event>> TaskFinalize(taskid: bytes32, results: bytes) -    <<event>> TaskClaimed(taskid: bytes32) - - - -15->31 - - + + +26->56 + + - + -15->37 - - +34->61 + + - + -15->44 - - +34->62 + + - - -47 - -<<Struct>> -Task -contracts/libs/IexecLibCore_v5.sol - -status: TaskStatusEnum -dealid: bytes32 -idx: uint256 -timeref: uint256 -contributionDeadline: uint256 -revealDeadline: uint256 -finalDeadline: uint256 -consensusValue: bytes32 -revealCounter: uint256 -winnerCounter: uint256 -contributors: address[] -resultDigest: bytes32 -results: bytes -resultsTimestamp: uint256 -resultsCallback: bytes - - + -15->47 - - +35->61 + + - - -48 - -<<Struct>> -Consensus -contracts/libs/IexecLibCore_v5.sol - -group: mapping(bytes32=>uint256) -total: uint256 - - - -15->48 - - - - - -50 - -<<Struct>> -Contribution -contracts/libs/IexecLibCore_v5.sol - -status: ContributionStatusEnum -resultHash: bytes32 -resultSeal: bytes32 -enclaveChallenge: address -weight: uint256 - - + -15->50 - - - - - -15->62 - - +35->62 + + - - -15->63 - - - - - -27 - -<<Interface>> -IexecHubV3Interface -contracts/interfaces/IexecHubV3Interface.sol - -External: -     viewScore(worker: address): uint256 - - - -29->51 - - + + +63 + +<<Library>> +StakedRlcLib +contracts/libs/StakedRlcLib.sol + +Internal: +    transfer(from: address, to: address, value: uint256) +    mint(account: address, amount: uint256) +    burn(account: address, amount: uint256) +    approve(owner: address, spender: address, amount: uint256) +Public: +    <<event>> Transfer(from: address, to: address, value: uint256) +    <<event>> Approval(owner: address, spender: address, value: uint256) + + + +35->63 + + - + + +42 + +<<Struct>> +Resource +contracts/libs/IexecLibCore_v5.sol + +pointer: address +owner: address +price: uint256 + + -29->54 - - +42->36 + + - - -29->55 - - - - + -29->56 - - +43->36 + + - - -29->57 - - + + +43->42 + + - + -43 - -<<Struct>> -Resource -contracts/libs/IexecLibCore_v5.sol - -pointer: address -owner: address -price: uint256 - - - -43->37 - - +45 + +<<Enum>> +TaskStatusEnum +contracts/libs/IexecLibCore_v5.sol + +UNSET: 0 +ACTIVE: 1 +REVEALING: 2 +COMPLETED: 3 +FAILED: 4 + + + +45->36 + + - - -44->37 - - + + +46->36 + + - - -44->43 - - + + +46->45 + + - - -46 - -<<Enum>> -TaskStatusEnum -contracts/libs/IexecLibCore_v5.sol - -UNSET: 0 -ACTIVE: 1 -REVEALING: 2 -COMPLETED: 3 -FAILED: 4 - - + -46->37 - - - - - -47->37 - - - - - -47->46 - - +47->36 + + - - -48->37 - - + + +48 + +<<Enum>> +ContributionStatusEnum +contracts/libs/IexecLibCore_v5.sol + +UNSET: 0 +CONTRIBUTED: 1 +PROVED: 2 +REJECTED: 3 + + + +48->36 + + - - -49 - -<<Enum>> -ContributionStatusEnum -contracts/libs/IexecLibCore_v5.sol - -UNSET: 0 -CONTRIBUTED: 1 -PROVED: 2 -REJECTED: 3 - - + -49->37 - - +49->36 + + - - -50->37 - - + + +49->48 + + - - -50->49 - - + + +52 + +<<Struct>> +EIP712Domain +contracts/libs/IexecLibOrders_v5.sol + +name: string +version: string +chainId: uint256 +verifyingContract: address + + + +50->52 + + - - -53 - -<<Struct>> -EIP712Domain -contracts/libs/IexecLibOrders_v5.sol - -name: string -version: string -chainId: uint256 -verifyingContract: address - - - -51->53 - - + + +50->53 + + - - -51->54 - - + + +50->54 + + - - -51->55 - - + + +50->55 + + - - -51->56 - - + + +50->56 + + - - -51->57 - - + + +57 + +<<Struct>> +AppOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: AppOrder +operation: OrderOperationEnum +sign: bytes + + + +50->57 + + - + 58 - -<<Struct>> -AppOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: AppOrder -operation: OrderOperationEnum -sign: bytes - - - -51->58 - - + +<<Struct>> +DatasetOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: DatasetOrder +operation: OrderOperationEnum +sign: bytes + + + +50->58 + + - + 59 - -<<Struct>> -DatasetOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: DatasetOrder -operation: OrderOperationEnum -sign: bytes - - - -51->59 - - + +<<Struct>> +WorkerpoolOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: WorkerpoolOrder +operation: OrderOperationEnum +sign: bytes + + + +50->59 + + - + 60 - -<<Struct>> -WorkerpoolOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: WorkerpoolOrder -operation: OrderOperationEnum -sign: bytes - - - -51->60 - - + +<<Struct>> +RequestOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: RequestOrder +operation: OrderOperationEnum +sign: bytes + + + +50->60 + + - - -61 - -<<Struct>> -RequestOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: RequestOrder -operation: OrderOperationEnum -sign: bytes - - - -51->61 - - + + +51 + +<<Enum>> +OrderOperationEnum +contracts/libs/IexecLibOrders_v5.sol + +SIGN: 0 +CLOSE: 1 + + + +51->50 + + - - -52 - -<<Enum>> -OrderOperationEnum -contracts/libs/IexecLibOrders_v5.sol - -SIGN: 0 -CLOSE: 1 - - - -52->51 - - + + +52->50 + + - - -53->51 - - + + +53->50 + + - - -54->51 - - + + +54->50 + + - - -55->51 - - + + +55->50 + + - - -56->51 - - + + +56->50 + + + + + +57->50 + + - + 57->51 - - + + + + + +57->53 + + + + + +58->50 + + - + 58->51 - - - - - -58->52 - - + + - + 58->54 - - + + + + + +59->50 + + - + 59->51 - - - - - -59->52 - - + + - + 59->55 - - + + + + + +60->50 + + - + 60->51 - - - - - -60->52 - - + + - + 60->56 - - + + - - -61->51 - - + + +61->62 + + - + -61->52 - - +62->24 + + - + -61->57 - - +62->36 + + - - -62->63 - - - - - -63->27 - - - - - -63->37 - - - - - -63->62 - - + + +62->61 + + - + 64 - -<<Interface>> -IRegistry -contracts/registries/IRegistry.sol - -External: -     isRegistered(_entry: address): bool - - - -63->64 - - + +<<Interface>> +IRegistry +contracts/registries/IRegistry.sol + +External: +     isRegistered(_entry: address): bool + + + +62->64 + + + + + +63->61 + + + + + +63->62 + + diff --git a/docs/uml/class-uml-dir-facets.svg b/docs/uml/class-uml-dir-facets.svg index 0809a3dd8..7518ea546 100644 --- a/docs/uml/class-uml-dir-facets.svg +++ b/docs/uml/class-uml-dir-facets.svg @@ -66,34 +66,31 @@ 4 - -IexecEscrowTokenFacet -contracts/facets/IexecEscrowTokenFacet.sol - -Internal: -    _executeOperation(sender: address, data: bytes) -    _validateMatchOrders(sender: address, data: bytes) -    _deposit(from: address, amount: uint256) -    _withdraw(to: address, amount: uint256) -    _mint(account: address, amount: uint256) -    _burn(account: address, amount: uint256) -    _approve(owner: address, spender: address, amount: uint256) -External: -    <<payable>> null() -    <<payable>> null() -    deposit(amount: uint256): bool -    depositFor(amount: uint256, target: address): bool -    depositForArray(amounts: uint256[], targets: address[]): bool -    withdraw(amount: uint256): bool -    withdrawTo(amount: uint256, target: address): bool -    recover(): uint256 <<onlyOwner>> -    receiveApproval(sender: address, amount: uint256, token: address, data: bytes): bool -    transfer(recipient: address, amount: uint256): bool -    approve(spender: address, value: uint256): bool -    approveAndCall(spender: address, value: uint256, extraData: bytes): bool -    transferFrom(sender: address, recipient: address, amount: uint256): bool -    increaseAllowance(spender: address, addedValue: uint256): bool -    decreaseAllowance(spender: address, subtractedValue: uint256): bool + +IexecEscrowTokenFacet +contracts/facets/IexecEscrowTokenFacet.sol + +Internal: +    _executeOperation(sender: address, data: bytes) +    _validateMatchOrders(sender: address, data: bytes) +    _deposit(from: address, amount: uint256) +    _withdraw(to: address, amount: uint256) +External: +    <<payable>> null() +    <<payable>> null() +    deposit(amount: uint256): bool +    depositFor(amount: uint256, target: address): bool +    depositForArray(amounts: uint256[], targets: address[]): bool +    withdraw(amount: uint256): bool +    withdrawTo(amount: uint256, target: address): bool +    recover(): uint256 <<onlyOwner>> +    receiveApproval(sender: address, amount: uint256, token: address, data: bytes): bool +    transfer(recipient: address, amount: uint256): bool +    approve(spender: address, value: uint256): bool +    approveAndCall(spender: address, value: uint256, extraData: bytes): bool +    transferFrom(sender: address, recipient: address, amount: uint256): bool +    increaseAllowance(spender: address, addedValue: uint256): bool +    decreaseAllowance(spender: address, subtractedValue: uint256): bool diff --git a/docs/uml/class-uml-dir-libs.svg b/docs/uml/class-uml-dir-libs.svg index 0875f7d38..7215ddc1d 100644 --- a/docs/uml/class-uml-dir-libs.svg +++ b/docs/uml/class-uml-dir-libs.svg @@ -4,725 +4,824 @@ - - + + UmlClassDiagram - + 0 - -<<Library>> -IexecLibCore_v5 -contracts/libs/IexecLibCore_v5.sol + +<<Library>> +CommonLib +contracts/libs/CommonLib.sol + +Private: +   GROUPMEMBER_PURPOSE: uint256 + +Internal: +    toTypedDataHash(structHash: bytes32): bytes32 +    verifySignatureOfEthSignedMessage(account: address, message: bytes, signature: bytes): bool +    verifySignature(account: address, messageHash: bytes32, signature: bytes): bool +    verifyPresignature(account: address, messageHash: bytes32): bool +    verifySignatureOrPresignature(account: address, messageHash: bytes32, signature: bytes): bool +    isAccountAuthorizedByRestriction(restriction: address, account: address): bool +    computeDealVolume(appOrderVolume: uint256, appOrderTypedDataHash: bytes32, hasDataset: bool, datasetOrderVolume: uint256, datasetOrderTypedDataHash: bytes32, workerpoolOrderVolume: uint256, workerpoolOrderTypedDataHash: bytes32, requestOrderVolume: uint256, requestOrderTypedDataHash: bytes32): uint256 + + + +27 + +<<Library>> +PocoStorageLib +contracts/libs/PocoStorageLib.sol + +Private: +   POCO_STORAGE_LOCATION: bytes32 + +Internal: +    getPocoStorage(): ($: PocoStorage) + + + +0->27 + + + + + +28 + +<<Struct>> +PocoStorage +contracts/libs/PocoStorageLib.sol + +m_appregistry: IRegistry +m_datasetregistry: IRegistry +m_workerpoolregistry: IRegistry +m_baseToken: IERC20 +m_name: string +m_symbol: string +m_decimals: uint8 +m_totalSupply: uint256 +m_balances: mapping(address=>uint256) +m_frozens: mapping(address=>uint256) +m_allowances: mapping(address=>mapping(address=>uint256)) +m_eip712DomainSeparator: bytes32 +m_presigned: mapping(bytes32=>address) +m_consumed: mapping(bytes32=>uint256) +m_deals: mapping(bytes32=>IexecLibCore_v5.Deal) +m_tasks: mapping(bytes32=>IexecLibCore_v5.Task) +m_consensus: mapping(bytes32=>IexecLibCore_v5.Consensus) +m_contributions: mapping(bytes32=>mapping(address=>IexecLibCore_v5.Contribution)) +m_workerScores: mapping(address=>uint256) +m_teebroker: address +m_callbackgas: uint256 +m_categories: IexecLibCore_v5.Category[] +m_v3_iexecHub: IexecHubV3Interface +m_v3_scoreImported: mapping(address=>bool) +m_dealsBoost: mapping(bytes32=>IexecLibCore_v5.DealBoost) + + + +0->28 + + 1 - -<<Struct>> -Account -contracts/libs/IexecLibCore_v5.sol - -stake: uint256 -locked: uint256 - - + +<<Library>> +EscrowLib +contracts/libs/EscrowLib.sol + +Internal: +    lock(account: address, value: uint256) +    unlock(account: address, value: uint256) +    reward(account: address, value: uint256, ref: bytes32) +    seize(account: address, value: uint256, ref: bytes32) +    rewardAndLock(account: address, value: uint256, ref: bytes32) +Public: +    <<event>> Reward(owner: address, amount: uint256, ref: bytes32) +    <<event>> Seize(owner: address, amount: uint256, ref: bytes32) +    <<event>> Lock(owner: address, amount: uint256) +    <<event>> Unlock(owner: address, amount: uint256) + + -1->0 - - +1->27 + + + + + +1->28 + + + + + +29 + +<<Library>> +StakedRlcLib +contracts/libs/StakedRlcLib.sol + +Internal: +    transfer(from: address, to: address, value: uint256) +    mint(account: address, amount: uint256) +    burn(account: address, amount: uint256) +    approve(owner: address, spender: address, amount: uint256) +Public: +    <<event>> Transfer(from: address, to: address, value: uint256) +    <<event>> Approval(owner: address, spender: address, value: uint256) + + + +1->29 + + 2 - -<<Struct>> -Category -contracts/libs/IexecLibCore_v5.sol - -name: string -description: string -workClockTimeRef: uint256 - - - -2->0 - - + +<<Library>> +IexecLibCore_v5 +contracts/libs/IexecLibCore_v5.sol 3 - -<<Struct>> -DatasetInfo -contracts/libs/IexecLibCore_v5.sol - -owner: address -m_datasetName: string -m_datasetMultiaddr: bytes -m_datasetChecksum: bytes32 - - - -3->0 - - + +<<Struct>> +Account +contracts/libs/IexecLibCore_v5.sol + +stake: uint256 +locked: uint256 + + + +3->2 + + 4 - -<<Struct>> -AppInfo -contracts/libs/IexecLibCore_v5.sol - -owner: address -m_appName: string -m_appType: string -m_appMultiaddr: bytes -m_appChecksum: bytes32 -m_appMREnclave: bytes - - - -4->0 - - + +<<Struct>> +Category +contracts/libs/IexecLibCore_v5.sol + +name: string +description: string +workClockTimeRef: uint256 + + + +4->2 + + 5 - -<<Struct>> -WorkerpoolInfo -contracts/libs/IexecLibCore_v5.sol - -owner: address -m_workerpoolDescription: string -m_workerStakeRatioPolicy: uint256 -m_schedulerRewardRatioPolicy: uint256 - - - -5->0 - - + +<<Struct>> +DatasetInfo +contracts/libs/IexecLibCore_v5.sol + +owner: address +m_datasetName: string +m_datasetMultiaddr: bytes +m_datasetChecksum: bytes32 + + + +5->2 + + 6 - -<<Struct>> -Resource -contracts/libs/IexecLibCore_v5.sol - -pointer: address -owner: address -price: uint256 - - - -6->0 - - + +<<Struct>> +AppInfo +contracts/libs/IexecLibCore_v5.sol + +owner: address +m_appName: string +m_appType: string +m_appMultiaddr: bytes +m_appChecksum: bytes32 +m_appMREnclave: bytes + + + +6->2 + + 7 - -<<Struct>> -Deal -contracts/libs/IexecLibCore_v5.sol - -app: Resource -dataset: Resource -workerpool: Resource -trust: uint256 -category: uint256 -tag: bytes32 -requester: address -beneficiary: address -callback: address -params: string -startTime: uint256 -botFirst: uint256 -botSize: uint256 -workerStake: uint256 -schedulerRewardRatio: uint256 -sponsor: address - - - -7->0 - - - - - -7->6 - - + +<<Struct>> +WorkerpoolInfo +contracts/libs/IexecLibCore_v5.sol + +owner: address +m_workerpoolDescription: string +m_workerStakeRatioPolicy: uint256 +m_schedulerRewardRatioPolicy: uint256 + + + +7->2 + + 8 - -<<Struct>> -DealBoost -contracts/libs/IexecLibCore_v5.sol - -appOwner: address -appPrice: uint96 -datasetOwner: address -datasetPrice: uint96 -workerpoolOwner: address -workerpoolPrice: uint96 -requester: address -workerReward: uint96 -callback: address -deadline: uint40 -botFirst: uint16 -botSize: uint16 -shortTag: bytes3 -sponsor: address - - - -8->0 - - + +<<Struct>> +Resource +contracts/libs/IexecLibCore_v5.sol + +pointer: address +owner: address +price: uint256 + + + +8->2 + + 9 - -<<Enum>> -TaskStatusEnum -contracts/libs/IexecLibCore_v5.sol - -UNSET: 0 -ACTIVE: 1 -REVEALING: 2 -COMPLETED: 3 -FAILED: 4 - - - -9->0 - - + +<<Struct>> +Deal +contracts/libs/IexecLibCore_v5.sol + +app: Resource +dataset: Resource +workerpool: Resource +trust: uint256 +category: uint256 +tag: bytes32 +requester: address +beneficiary: address +callback: address +params: string +startTime: uint256 +botFirst: uint256 +botSize: uint256 +workerStake: uint256 +schedulerRewardRatio: uint256 +sponsor: address + + + +9->2 + + + + + +9->8 + + 10 - -<<Struct>> -Task -contracts/libs/IexecLibCore_v5.sol - -status: TaskStatusEnum -dealid: bytes32 -idx: uint256 -timeref: uint256 -contributionDeadline: uint256 -revealDeadline: uint256 -finalDeadline: uint256 -consensusValue: bytes32 -revealCounter: uint256 -winnerCounter: uint256 -contributors: address[] -resultDigest: bytes32 -results: bytes -resultsTimestamp: uint256 -resultsCallback: bytes - - - -10->0 - - - - + +<<Struct>> +DealBoost +contracts/libs/IexecLibCore_v5.sol + +appOwner: address +appPrice: uint96 +datasetOwner: address +datasetPrice: uint96 +workerpoolOwner: address +workerpoolPrice: uint96 +requester: address +workerReward: uint96 +callback: address +deadline: uint40 +botFirst: uint16 +botSize: uint16 +shortTag: bytes3 +sponsor: address + + -10->9 - - +10->2 + + 11 - -<<Struct>> -Consensus -contracts/libs/IexecLibCore_v5.sol - -group: mapping(bytes32=>uint256) -total: uint256 - - - -11->0 - - + +<<Enum>> +TaskStatusEnum +contracts/libs/IexecLibCore_v5.sol + +UNSET: 0 +ACTIVE: 1 +REVEALING: 2 +COMPLETED: 3 +FAILED: 4 + + + +11->2 + + 12 - -<<Enum>> -ContributionStatusEnum -contracts/libs/IexecLibCore_v5.sol - -UNSET: 0 -CONTRIBUTED: 1 -PROVED: 2 -REJECTED: 3 - - - -12->0 - - + +<<Struct>> +Task +contracts/libs/IexecLibCore_v5.sol + +status: TaskStatusEnum +dealid: bytes32 +idx: uint256 +timeref: uint256 +contributionDeadline: uint256 +revealDeadline: uint256 +finalDeadline: uint256 +consensusValue: bytes32 +revealCounter: uint256 +winnerCounter: uint256 +contributors: address[] +resultDigest: bytes32 +results: bytes +resultsTimestamp: uint256 +resultsCallback: bytes + + + +12->2 + + + + + +12->11 + + 13 - -<<Struct>> -Contribution -contracts/libs/IexecLibCore_v5.sol - -status: ContributionStatusEnum -resultHash: bytes32 -resultSeal: bytes32 -enclaveChallenge: address -weight: uint256 - - - -13->0 - - - - - -13->12 - - + +<<Struct>> +Consensus +contracts/libs/IexecLibCore_v5.sol + +group: mapping(bytes32=>uint256) +total: uint256 + + + +13->2 + + 14 - -<<Library>> -IexecLibOrders_v5 -contracts/libs/IexecLibOrders_v5.sol - -Public: -   EIP712DOMAIN_TYPEHASH: bytes32 -   APPORDER_TYPEHASH: bytes32 -   DATASETORDER_TYPEHASH: bytes32 -   WORKERPOOLORDER_TYPEHASH: bytes32 -   REQUESTORDER_TYPEHASH: bytes32 -   APPORDEROPERATION_TYPEHASH: bytes32 -   DATASETORDEROPERATION_TYPEHASH: bytes32 -   WORKERPOOLORDEROPERATION_TYPEHASH: bytes32 -   REQUESTORDEROPERATION_TYPEHASH: bytes32 - -Public: -    hash(_domain: EIP712Domain): (domainhash: bytes32) -    hash(_apporder: AppOrder): (apphash: bytes32) -    hash(_datasetorder: DatasetOrder): (datasethash: bytes32) -    hash(_workerpoolorder: WorkerpoolOrder): (workerpoolhash: bytes32) -    hash(_requestorder: RequestOrder): (requesthash: bytes32) -    hash(_apporderoperation: AppOrderOperation): bytes32 -    hash(_datasetorderoperation: DatasetOrderOperation): bytes32 -    hash(_workerpoolorderoperation: WorkerpoolOrderOperation): bytes32 -    hash(_requestorderoperation: RequestOrderOperation): bytes32 + +<<Enum>> +ContributionStatusEnum +contracts/libs/IexecLibCore_v5.sol + +UNSET: 0 +CONTRIBUTED: 1 +PROVED: 2 +REJECTED: 3 + + + +14->2 + + + + + +15 + +<<Struct>> +Contribution +contracts/libs/IexecLibCore_v5.sol + +status: ContributionStatusEnum +resultHash: bytes32 +resultSeal: bytes32 +enclaveChallenge: address +weight: uint256 + + + +15->2 + + + + + +15->14 + + 16 - -<<Struct>> -EIP712Domain -contracts/libs/IexecLibOrders_v5.sol - -name: string -version: string -chainId: uint256 -verifyingContract: address - - - -14->16 - - - - - -17 - -<<Struct>> -AppOrder -contracts/libs/IexecLibOrders_v5.sol - -app: address -appprice: uint256 -volume: uint256 -tag: bytes32 -datasetrestrict: address -workerpoolrestrict: address -requesterrestrict: address -salt: bytes32 -sign: bytes - - - -14->17 - - + +<<Library>> +IexecLibOrders_v5 +contracts/libs/IexecLibOrders_v5.sol + +Public: +   EIP712DOMAIN_TYPEHASH: bytes32 +   APPORDER_TYPEHASH: bytes32 +   DATASETORDER_TYPEHASH: bytes32 +   WORKERPOOLORDER_TYPEHASH: bytes32 +   REQUESTORDER_TYPEHASH: bytes32 +   APPORDEROPERATION_TYPEHASH: bytes32 +   DATASETORDEROPERATION_TYPEHASH: bytes32 +   WORKERPOOLORDEROPERATION_TYPEHASH: bytes32 +   REQUESTORDEROPERATION_TYPEHASH: bytes32 + +Public: +    hash(_domain: EIP712Domain): (domainhash: bytes32) +    hash(_apporder: AppOrder): (apphash: bytes32) +    hash(_datasetorder: DatasetOrder): (datasethash: bytes32) +    hash(_workerpoolorder: WorkerpoolOrder): (workerpoolhash: bytes32) +    hash(_requestorder: RequestOrder): (requesthash: bytes32) +    hash(_apporderoperation: AppOrderOperation): bytes32 +    hash(_datasetorderoperation: DatasetOrderOperation): bytes32 +    hash(_workerpoolorderoperation: WorkerpoolOrderOperation): bytes32 +    hash(_requestorderoperation: RequestOrderOperation): bytes32 18 - -<<Struct>> -DatasetOrder -contracts/libs/IexecLibOrders_v5.sol - -dataset: address -datasetprice: uint256 -volume: uint256 -tag: bytes32 -apprestrict: address -workerpoolrestrict: address -requesterrestrict: address -salt: bytes32 -sign: bytes - - - -14->18 - - + +<<Struct>> +EIP712Domain +contracts/libs/IexecLibOrders_v5.sol + +name: string +version: string +chainId: uint256 +verifyingContract: address + + + +16->18 + + 19 - -<<Struct>> -WorkerpoolOrder -contracts/libs/IexecLibOrders_v5.sol - -workerpool: address -workerpoolprice: uint256 -volume: uint256 -tag: bytes32 -category: uint256 -trust: uint256 -apprestrict: address -datasetrestrict: address -requesterrestrict: address -salt: bytes32 -sign: bytes - - - -14->19 - - + +<<Struct>> +AppOrder +contracts/libs/IexecLibOrders_v5.sol + +app: address +appprice: uint256 +volume: uint256 +tag: bytes32 +datasetrestrict: address +workerpoolrestrict: address +requesterrestrict: address +salt: bytes32 +sign: bytes + + + +16->19 + + 20 - -<<Struct>> -RequestOrder -contracts/libs/IexecLibOrders_v5.sol - -app: address -appmaxprice: uint256 -dataset: address -datasetmaxprice: uint256 -workerpool: address -workerpoolmaxprice: uint256 -requester: address -volume: uint256 -tag: bytes32 -category: uint256 -trust: uint256 -beneficiary: address -callback: address -params: string -salt: bytes32 -sign: bytes - - - -14->20 - - + +<<Struct>> +DatasetOrder +contracts/libs/IexecLibOrders_v5.sol + +dataset: address +datasetprice: uint256 +volume: uint256 +tag: bytes32 +apprestrict: address +workerpoolrestrict: address +requesterrestrict: address +salt: bytes32 +sign: bytes + + + +16->20 + + 21 - -<<Struct>> -AppOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: AppOrder -operation: OrderOperationEnum -sign: bytes - - - -14->21 - - + +<<Struct>> +WorkerpoolOrder +contracts/libs/IexecLibOrders_v5.sol + +workerpool: address +workerpoolprice: uint256 +volume: uint256 +tag: bytes32 +category: uint256 +trust: uint256 +apprestrict: address +datasetrestrict: address +requesterrestrict: address +salt: bytes32 +sign: bytes + + + +16->21 + + 22 - -<<Struct>> -DatasetOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: DatasetOrder -operation: OrderOperationEnum -sign: bytes - - - -14->22 - - + +<<Struct>> +RequestOrder +contracts/libs/IexecLibOrders_v5.sol + +app: address +appmaxprice: uint256 +dataset: address +datasetmaxprice: uint256 +workerpool: address +workerpoolmaxprice: uint256 +requester: address +volume: uint256 +tag: bytes32 +category: uint256 +trust: uint256 +beneficiary: address +callback: address +params: string +salt: bytes32 +sign: bytes + + + +16->22 + + 23 - -<<Struct>> -WorkerpoolOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: WorkerpoolOrder -operation: OrderOperationEnum -sign: bytes - - - -14->23 - - + +<<Struct>> +AppOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: AppOrder +operation: OrderOperationEnum +sign: bytes + + + +16->23 + + 24 - -<<Struct>> -RequestOrderOperation -contracts/libs/IexecLibOrders_v5.sol - -order: RequestOrder -operation: OrderOperationEnum -sign: bytes - - - -14->24 - - - - - -15 - -<<Enum>> -OrderOperationEnum -contracts/libs/IexecLibOrders_v5.sol - -SIGN: 0 -CLOSE: 1 - - - -15->14 - - - - - -16->14 - - - - - -17->14 - - + +<<Struct>> +DatasetOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: DatasetOrder +operation: OrderOperationEnum +sign: bytes + + + +16->24 + + - - -18->14 - - + + +25 + +<<Struct>> +WorkerpoolOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: WorkerpoolOrder +operation: OrderOperationEnum +sign: bytes + + + +16->25 + + - - -19->14 - - + + +26 + +<<Struct>> +RequestOrderOperation +contracts/libs/IexecLibOrders_v5.sol + +order: RequestOrder +operation: OrderOperationEnum +sign: bytes + + + +16->26 + + - + + +17 + +<<Enum>> +OrderOperationEnum +contracts/libs/IexecLibOrders_v5.sol + +SIGN: 0 +CLOSE: 1 + + -20->14 - - +17->16 + + - + -21->14 - - - - - -21->15 - - - - - -21->17 - - +18->16 + + - + -22->14 - - +19->16 + + - - -22->15 - - + + +20->16 + + - - -22->18 - - + + +21->16 + + - - -23->14 - - + + +22->16 + + - - -23->15 - - + + +23->16 + + + + + +23->17 + + - + 23->19 - - + + - - -24->14 - - + + +24->16 + + - - -24->15 - - + + +24->17 + + - + 24->20 - - - - - -25 - -<<Library>> -PocoStorageLib -contracts/libs/PocoStorageLib.sol - -Private: -   POCO_STORAGE_LOCATION: bytes32 - -Internal: -    getPocoStorage(): ($: PocoStorage) + + - - -26 - -<<Struct>> -PocoStorage -contracts/libs/PocoStorageLib.sol - -m_appregistry: IRegistry -m_datasetregistry: IRegistry -m_workerpoolregistry: IRegistry -m_baseToken: IERC20 -m_name: string -m_symbol: string -m_decimals: uint8 -m_totalSupply: uint256 -m_balances: mapping(address=>uint256) -m_frozens: mapping(address=>uint256) -m_allowances: mapping(address=>mapping(address=>uint256)) -m_eip712DomainSeparator: bytes32 -m_presigned: mapping(bytes32=>address) -m_consumed: mapping(bytes32=>uint256) -m_deals: mapping(bytes32=>IexecLibCore_v5.Deal) -m_tasks: mapping(bytes32=>IexecLibCore_v5.Task) -m_consensus: mapping(bytes32=>IexecLibCore_v5.Consensus) -m_contributions: mapping(bytes32=>mapping(address=>IexecLibCore_v5.Contribution)) -m_workerScores: mapping(address=>uint256) -m_teebroker: address -m_callbackgas: uint256 -m_categories: IexecLibCore_v5.Category[] -m_v3_iexecHub: IexecHubV3Interface -m_v3_scoreImported: mapping(address=>bool) -m_dealsBoost: mapping(bytes32=>IexecLibCore_v5.DealBoost) - - - -25->26 - - + + +25->16 + + - + -26->0 - - +25->17 + + - - -26->25 - - + + +25->21 + + + + + +26->16 + + + + + +26->17 + + + + + +26->22 + + + + + +27->28 + + + + + +28->2 + + + + + +28->27 + + + + + +29->27 + + + + + +29->28 + + diff --git a/hardhat.config.ts b/hardhat.config.ts index da827a4ec..5ad7052ca 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -166,12 +166,11 @@ const config: HardhatUserConfig = { outputDir: 'docs/solidity', templates: 'docs/solidity/templates', exclude: [ - 'abstract/IexecPocoCommon.sol', // contains only internal/private - 'abstract/SignatureVerifier.sol', // contains only internal/private 'external/', 'facets/IexecAccessorsABILegacyFacet.sol', // not relevant // TODO: put all events and soldoc inside interfaces and use them instead of contracts. 'interfaces/', // interesting for events but too much doc duplication if enabled + 'libs/CommonLib.sol', // contains only internal/private 'tools/', 'Diamond.sol', // not relevant ], diff --git a/scripts/tools/sol-to-uml.mjs b/scripts/tools/sol-to-uml.mjs index bbf1fe69f..0b7820954 100644 --- a/scripts/tools/sol-to-uml.mjs +++ b/scripts/tools/sol-to-uml.mjs @@ -13,7 +13,7 @@ await generateClassDiagramOfDirectory('registries'); await generateClassDiagramOfContracts(['IexecPoco1Facet', 'IexecPoco2Facet'], 'IexecPocoFacets'); -await generateClassDiagramOfContracts(['IexecEscrowTokenFacet', 'IexecEscrow'], 'IexecEscrows'); +await generateClassDiagramOfContracts(['IexecEscrowTokenFacet', 'EscrowLib'], 'IexecEscrows'); await generateClassDiagramOfContracts(['IexecPocoBoostFacet'], 'IexecPocoBoostFacet'); diff --git a/test/byContract/IexecERC20/IexecERC20.test.ts b/test/byContract/IexecERC20/IexecERC20.test.ts index 26bfcd606..6b015f438 100644 --- a/test/byContract/IexecERC20/IexecERC20.test.ts +++ b/test/byContract/IexecERC20/IexecERC20.test.ts @@ -87,17 +87,17 @@ describe('ERC20', async () => { it('Should not transfer from the zero address', async () => { await expect( iexecPoco.connect(zeroAddressSigner).transfer(recipient.address, value), - ).to.be.revertedWith('IexecEscrow: Transfer from empty address'); + ).to.be.revertedWith('ERC20: Transfer from empty address'); }); it('Should not transfer to the zero address', async () => { await expect(iexecPocoAsHolder.transfer(ZeroAddress, value)).to.be.revertedWith( - 'IexecEscrow: Transfer to empty address', + 'ERC20: Transfer to empty address', ); }); it('Should not transfer when sender balance is too low', async () => { await expect( iexecPocoAsHolder.transfer(recipient.address, value + 1n), - ).to.be.revertedWith('IexecEscrow: Transfer amount exceeds balance'); + ).to.be.revertedWith('ERC20: Transfer amount exceeds balance'); }); }); @@ -191,17 +191,17 @@ describe('ERC20', async () => { it('Should not transferFrom when owner is the zero address', async () => { await expect( iexecPocoAsSpender.transferFrom(ZeroAddress, spender.address, value), - ).to.be.revertedWith('IexecEscrow: Transfer from empty address'); + ).to.be.revertedWith('ERC20: Transfer from empty address'); }); it('Should not transferFrom to the zero address', async () => { await expect( iexecPocoAsSpender.transferFrom(holder.address, ZeroAddress, value), - ).to.be.revertedWith('IexecEscrow: Transfer to empty address'); + ).to.be.revertedWith('ERC20: Transfer to empty address'); }); it('Should not transferFrom when owner balance is too low', async () => { await expect( iexecPocoAsSpender.transferFrom(holder.address, spender.address, value + 1n), - ).to.be.revertedWith('IexecEscrow: Transfer amount exceeds balance'); + ).to.be.revertedWith('ERC20: Transfer amount exceeds balance'); }); it('Should not transferFrom when spender allowance is too low', async () => { await iexecPocoAsHolder.approve(spender.address, value - 1n).then((tx) => tx.wait()); diff --git a/test/byContract/IexecEscrow/IexecEscrowToken-receiveApproval.test.ts b/test/byContract/IexecEscrow/IexecEscrowToken-receiveApproval.test.ts index c48eb1aa3..92c520dce 100644 --- a/test/byContract/IexecEscrow/IexecEscrowToken-receiveApproval.test.ts +++ b/test/byContract/IexecEscrow/IexecEscrowToken-receiveApproval.test.ts @@ -338,7 +338,7 @@ describe('IexecEscrowToken-receiveApproval', () => { insufficientAmount, await matchOrdersCalldata(orders), ), - ).to.be.revertedWith('IexecEscrow: Transfer amount exceeds balance'); + ).to.be.revertedWith('ERC20: Transfer amount exceeds balance'); }); it('Should revert with unsupported operation error for unknown function selector', async () => { diff --git a/test/byContract/IexecPoco/IexecPoco1.test.ts b/test/byContract/IexecPoco/IexecPoco1.test.ts index 83a2690da..6cb07c235 100644 --- a/test/byContract/IexecPoco/IexecPoco1.test.ts +++ b/test/byContract/IexecPoco/IexecPoco1.test.ts @@ -999,7 +999,7 @@ describe('IexecPoco1', () => { expect(await iexecPoco.balanceOf(scheduler.address)).to.equal(schedulerStake); await signOrders(iexecWrapper.getDomain(), orders, ordersActors); await expect(iexecPocoAsRequester.matchOrders(...orders.toArray())).to.be.revertedWith( - 'IexecEscrow: Transfer amount exceeds balance', + 'ERC20: Transfer amount exceeds balance', ); }); @@ -1016,7 +1016,7 @@ describe('IexecPoco1', () => { expect(await iexecPoco.balanceOf(scheduler.address)).to.be.lessThan(schedulerStake); await signOrders(iexecWrapper.getDomain(), orders, ordersActors); await expect(iexecPocoAsRequester.matchOrders(...orders.toArray())).to.be.revertedWith( - 'IexecEscrow: Transfer amount exceeds balance', + 'ERC20: Transfer amount exceeds balance', ); }); }); @@ -1099,7 +1099,7 @@ describe('IexecPoco1', () => { await signOrders(iexecWrapper.getDomain(), orders, ordersActors); await expect( iexecPocoAsSponsor.sponsorMatchOrders(...orders.toArray()), - ).to.be.revertedWith('IexecEscrow: Transfer amount exceeds balance'); + ).to.be.revertedWith('ERC20: Transfer amount exceeds balance'); }); }); diff --git a/test/byContract/IexecPoco/IexecPoco2-contribute.test.ts b/test/byContract/IexecPoco/IexecPoco2-contribute.test.ts index b9e5600d4..a8931ed6a 100644 --- a/test/byContract/IexecPoco/IexecPoco2-contribute.test.ts +++ b/test/byContract/IexecPoco/IexecPoco2-contribute.test.ts @@ -519,7 +519,7 @@ describe('IexecPoco2#contribute', () => { scheduler, ), ), - ).to.be.revertedWith('IexecEscrow: Transfer amount exceeds balance'); + ).to.be.revertedWith('ERC20: Transfer amount exceeds balance'); }); }); }); diff --git a/test/byContract/IexecPocoBoost/IexecEscrow.test.ts b/test/byContract/IexecPocoBoost/IexecEscrow.test.ts index 7a38a6888..06aba2bf7 100644 --- a/test/byContract/IexecPocoBoost/IexecEscrow.test.ts +++ b/test/byContract/IexecPocoBoost/IexecEscrow.test.ts @@ -53,14 +53,14 @@ describe('IexecEscrow', function () { it('Should not lock funds for empty address', async function () { await expect(iexecEscrow.lock_(ZeroAddress, amount)).to.be.revertedWith( - 'IexecEscrow: Transfer from empty address', + 'ERC20: Transfer from empty address', ); }); it('Should not lock funds when insufficient balance', async function () { await expect( iexecEscrow.lock_(account.address, accountBalance + 1n), - ).to.be.revertedWith('IexecEscrow: Transfer amount exceeds balance'); + ).to.be.revertedWith('ERC20: Transfer amount exceeds balance'); }); }); @@ -86,13 +86,13 @@ describe('IexecEscrow', function () { it('Should not unlock funds for empty address', async function () { await expect(iexecEscrow.unlock_(ZeroAddress, amount)).to.be.revertedWith( - 'IexecEscrow: Transfer to empty address', + 'ERC20: Transfer to empty address', ); }); it('Should not unlock funds when insufficient balance', async function () { await expect(iexecEscrow.unlock_(account.address, amount)).to.be.revertedWith( - 'IexecEscrow: Transfer amount exceeds balance', + 'ERC20: Transfer amount exceeds balance', ); }); }); @@ -117,13 +117,13 @@ describe('IexecEscrow', function () { it('Should not reward empty address', async function () { await expect(iexecEscrow.reward_(ZeroAddress, amount, HashZero)).to.be.revertedWith( - 'IexecEscrow: Transfer to empty address', + 'ERC20: Transfer to empty address', ); }); it('Should not reward when insufficient balance', async function () { await expect(iexecEscrow.reward_(account.address, amount, HashZero)).to.be.revertedWith( - 'IexecEscrow: Transfer amount exceeds balance', + 'ERC20: Transfer amount exceeds balance', ); }); }); diff --git a/test/byContract/IexecPocoBoost/IexecPocoBoost.test.ts b/test/byContract/IexecPocoBoost/IexecPocoBoost.test.ts index 6d798850a..05c2a1ec9 100644 --- a/test/byContract/IexecPocoBoost/IexecPocoBoost.test.ts +++ b/test/byContract/IexecPocoBoost/IexecPocoBoost.test.ts @@ -1277,7 +1277,7 @@ describe('IexecPocoBoost', function () { await signOrders(domain, orders, ordersActors); await expect( iexecPocoBoostInstance.matchOrdersBoost(...orders.toArray()), - ).to.be.revertedWith('IexecEscrow: Transfer amount exceeds balance'); + ).to.be.revertedWith('ERC20: Transfer amount exceeds balance'); }); it('Should fail when scheduler has insufficient balance', async () => { @@ -1308,7 +1308,7 @@ describe('IexecPocoBoost', function () { await signOrders(domain, orders, ordersActors); await expect( iexecPocoBoostInstance.matchOrdersBoost(...orders.toArray()), - ).to.be.revertedWith('IexecEscrow: Transfer amount exceeds balance'); + ).to.be.revertedWith('ERC20: Transfer amount exceeds balance'); }); it('Should fail when sponsor has insufficient balance', async () => { const dealPrice = (appPrice + datasetPrice + workerpoolPrice) * volume; @@ -1327,7 +1327,7 @@ describe('IexecPocoBoost', function () { iexecPocoBoostInstance .connect(sponsor) .sponsorMatchOrdersBoost(...orders.toArray()), - ).to.be.revertedWith('IexecEscrow: Transfer amount exceeds balance'); + ).to.be.revertedWith('ERC20: Transfer amount exceeds balance'); }); });