Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions deploy/09_deploy_escrowchallengeauditcollateral.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import "@nomiclabs/hardhat-ethers";
import { deployAndSaveContract } from "../scripts/utils";

const deployFunction: DeployFunction = async function (
hre: HardhatRuntimeEnvironment
) {
const { deployments } = hre;
const roles = await deployments.get("Roles");
await deployAndSaveContract(
"EscrowChallengeAuditCollateral",
[roles.address],
hre
);
};

export default deployFunction;

deployFunction.dependencies = ["Roles"];
deployFunction.tags = ["EscrowChallengeAuditCollateral"];
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions scripts/localnet_docker/devnet.bash
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ EscrowDataTradingFeeAddress=$(npx hardhat getProxyAddress --type localnet --name
EscrowDatacapChunkLandCollateralAddress=$(npx hardhat getProxyAddress --type localnet --name EscrowDatacapChunkLandCollateral)
EscrowDatacapCollateralAddress=$(npx hardhat getProxyAddress --type localnet --name EscrowDatacapCollateral)
EscrowChallengeCommissionAddress=$(npx hardhat getProxyAddress --type localnet --name EscrowChallengeCommission)
EscrowChallengeAuditCollateral=$(npx hardhat getProxyAddress --type localnet --name EscrowChallengeAuditCollateral)

cat >"${BASEDIR}/contract" <<EOF
export RolesAddress=$RolesAddress
Expand All @@ -177,6 +178,7 @@ export EscrowDataTradingFeeAddress=$EscrowDataTradingFeeAddress
export EscrowDatacapChunkLandCollateralAddress=$EscrowDatacapChunkLandCollateralAddress
export EscrowDatacapCollateralAddress=$EscrowDatacapCollateralAddress
export EscrowChallengeCommissionAddress=$EscrowChallengeCommissionAddress
export EscrowChallengeAuditCollateralAddress=$EscrowChallengeAuditCollateral
EOF

PRIVATE_KEY="0x0a3570f105ea5d06c355ea1a7a1fea441e90e44984896779b6c44c2ca5a8e16b"
Expand All @@ -197,6 +199,7 @@ ${BASEDIR}/.foundry/bin/cast send --rpc-url http://127.0.0.1:1234/rpc/v1 --async
${BASEDIR}/.foundry/bin/cast send --rpc-url http://127.0.0.1:1234/rpc/v1 --async --private-key $PRIVATE_KEY $RolesAddress "registerContract(uint8,address)" 14 $EscrowDatacapChunkLandCollateralAddress
${BASEDIR}/.foundry/bin/cast send --rpc-url http://127.0.0.1:1234/rpc/v1 --async --private-key $PRIVATE_KEY $RolesAddress "registerContract(uint8,address)" 15 $EscrowDatacapCollateralAddress
${BASEDIR}/.foundry/bin/cast send --rpc-url http://127.0.0.1:1234/rpc/v1 --async --private-key $PRIVATE_KEY $RolesAddress "registerContract(uint8,address)" 16 $EscrowChallengeCommissionAddress
${BASEDIR}/.foundry/bin/cast send --rpc-url http://127.0.0.1:1234/rpc/v1 --async --private-key $PRIVATE_KEY $RolesAddress "registerContract(uint8,address)" 17 $EscrowChallengeAuditCollateralAddress

echo "filplusAddress:" $(${BASEDIR}/.foundry/bin/cast call --rpc-url http://127.0.0.1:1234/rpc/v1 $RolesAddress "filplus()(address)")
echo "financeAddress:" $(${BASEDIR}/.foundry/bin/cast call --rpc-url http://127.0.0.1:1234/rpc/v1 $RolesAddress "finance()(address)")
Expand All @@ -215,6 +218,7 @@ echo "escrowDataTradingFeeAddress:" $(${BASEDIR}/.foundry/bin/cast call --rpc-ur
echo "escrowDatacapChunkLandCollateralAddress:" $(${BASEDIR}/.foundry/bin/cast call --rpc-url http://127.0.0.1:1234/rpc/v1 $RolesAddress "escrowDatacapChunkLandCollateral()(address)")
echo "escrowChallengeCommissionAddress:" $(${BASEDIR}/.foundry/bin/cast call --rpc-url http://127.0.0.1:1234/rpc/v1 $RolesAddress "escrowChallengeCommission()(address)")
echo "escrowDatacapCollateralAddress:" $(${BASEDIR}/.foundry/bin/cast call --rpc-url http://127.0.0.1:1234/rpc/v1 $RolesAddress "escrowDatacapCollateral()(address)")
echo "escrowChallengeAuditCollateralAddress:" $(${BASEDIR}/.foundry/bin/cast call --rpc-url http://127.0.0.1:1234/rpc/v1 $RolesAddress "escrowChallengeAuditCollateral()(address)")

DATASWAPROLE="0xd4c6f45e959193f4fa6251e76cc3d999512eb8b529a40dac0d5e892efe8ea48e"

Expand All @@ -236,6 +240,7 @@ ${BASEDIR}/.foundry/bin/cast send --rpc-url http://127.0.0.1:1234/rpc/v1 --async
${BASEDIR}/.foundry/bin/cast send --rpc-url http://127.0.0.1:1234/rpc/v1 --async --private-key $PRIVATE_KEY $RolesAddress "grantRole(bytes32,address)" $DATASWAPROLE $EscrowDatacapChunkLandCollateralAddress
${BASEDIR}/.foundry/bin/cast send --rpc-url http://127.0.0.1:1234/rpc/v1 --async --private-key $PRIVATE_KEY $RolesAddress "grantRole(bytes32,address)" $DATASWAPROLE $EscrowDatacapCollateralAddress
${BASEDIR}/.foundry/bin/cast send --rpc-url http://127.0.0.1:1234/rpc/v1 --async --private-key $PRIVATE_KEY $RolesAddress "grantRole(bytes32,address)" $DATASWAPROLE $EscrowChallengeCommissionAddress
${BASEDIR}/.foundry/bin/cast send --rpc-url http://127.0.0.1:1234/rpc/v1 --async --private-key $PRIVATE_KEY $RolesAddress "grantRole(bytes32,address)" $DATASWAPROLE $EscrowChallengeAuditCollateralAddress

echo "roles role:" $(${BASEDIR}/.foundry/bin/cast call --rpc-url http://127.0.0.1:1234/rpc/v1 $RolesAddress "hasRole(bytes32,address)(bool)" $DATASWAPROLE $RolesAddress)
echo "filplus role:" $(${BASEDIR}/.foundry/bin/cast call --rpc-url http://127.0.0.1:1234/rpc/v1 $RolesAddress "hasRole(bytes32,address)(bool)" $DATASWAPROLE $FilplusAddress)
Expand All @@ -255,6 +260,7 @@ echo "escrowDataTradingFee role:" $(${BASEDIR}/.foundry/bin/cast call --rpc-url
echo "escrowDatacapChunkLandCollateral role:" $(${BASEDIR}/.foundry/bin/cast call --rpc-url http://127.0.0.1:1234/rpc/v1 $RolesAddress "hasRole(bytes32,address)(bool)" $DATASWAPROLE $EscrowDatacapChunkLandCollateralAddress)
echo "escrowDatacapCollateral role:" $(${BASEDIR}/.foundry/bin/cast call --rpc-url http://127.0.0.1:1234/rpc/v1 $RolesAddress "hasRole(bytes32,address)(bool)" $DATASWAPROLE $EscrowDatacapCollateralAddress)
echo "escrowChallengeCommission role:" $(${BASEDIR}/.foundry/bin/cast call --rpc-url http://127.0.0.1:1234/rpc/v1 $RolesAddress "hasRole(bytes32,address)(bool)" $DATASWAPROLE $EscrowChallengeCommissionAddress)
echo "escrowChallengeAuditCollateral role:" $(${BASEDIR}/.foundry/bin/cast call --rpc-url http://127.0.0.1:1234/rpc/v1 $RolesAddress "hasRole(bytes32,address)(bool)" $DATASWAPROLE $EscrowChallengeAuditCollateralAddress)


RootAddress=$(lotus msig inspect f080 | grep t0100 | awk '{print $2}')
Expand Down
199 changes: 162 additions & 37 deletions src/v0.8/core/access/Roles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,7 @@ contract Roles is
Ownable2StepUpgradeable,
AccessControlEnumerableUpgradeable
{
IFilplus public filplus;
IFinance public finance;
IFilecoin public filecoin;
ICarstore public carstore;
IStorages public storages;
IMerkleUtils public merkleUtils;

IDatasets public datasets;
IDatasetsProof public datasetsProof;
IDatasetsChallenge public datasetsChallenge;
IDatasetsRequirement public datasetsRequirement;

IMatchings public matchings;
IMatchingsBids public matchingsBids;
IMatchingsTarget public matchingsTarget;

IEscrow public escrowDataTradingFee;
IEscrow public escrowDatacapCollateral;
IEscrow public escrowChallengeCommission;
IEscrow public escrowDatacapChunkLandCollateral;
RolesType.DataswapContracts private dataswapContracts;

/// @notice initialize function to initialize the contract and grant the default admin role to the deployer.
function initialize() public initializer {
Expand Down Expand Up @@ -104,41 +85,57 @@ contract Roles is
address _contract
) public onlyOwner {
if (_type == RolesType.ContractType.Filplus) {
filplus = IFilplus(_contract);
dataswapContracts.filplus = IFilplus(_contract);
} else if (_type == RolesType.ContractType.Finance) {
finance = IFinance(_contract);
dataswapContracts.finance = IFinance(_contract);
} else if (_type == RolesType.ContractType.Filecoin) {
filecoin = IFilecoin(_contract);
dataswapContracts.filecoin = IFilecoin(_contract);
} else if (_type == RolesType.ContractType.Carstore) {
carstore = ICarstore(_contract);
dataswapContracts.carstore = ICarstore(_contract);
} else if (_type == RolesType.ContractType.Storages) {
storages = IStorages(_contract);
dataswapContracts.storages = IStorages(_contract);
} else if (_type == RolesType.ContractType.MerkleUtils) {
merkleUtils = IMerkleUtils(_contract);
dataswapContracts.merkleUtils = IMerkleUtils(_contract);
} else if (_type == RolesType.ContractType.Datasets) {
datasets = IDatasets(_contract);
dataswapContracts.datasets = IDatasets(_contract);
} else if (_type == RolesType.ContractType.DatasetsProof) {
datasetsProof = IDatasetsProof(_contract);
dataswapContracts.datasetsProof = IDatasetsProof(_contract);
} else if (_type == RolesType.ContractType.DatasetsChallenge) {
datasetsChallenge = IDatasetsChallenge(_contract);
dataswapContracts.datasetsChallenge = IDatasetsChallenge(_contract);
} else if (_type == RolesType.ContractType.DatasetsRequirement) {
datasetsRequirement = IDatasetsRequirement(_contract);
dataswapContracts.datasetsRequirement = IDatasetsRequirement(
_contract
);
} else if (_type == RolesType.ContractType.Matchings) {
matchings = IMatchings(_contract);
dataswapContracts.matchings = IMatchings(_contract);
} else if (_type == RolesType.ContractType.MatchingsBids) {
matchingsBids = IMatchingsBids(_contract);
dataswapContracts.matchingsBids = IMatchingsBids(_contract);
} else if (_type == RolesType.ContractType.MatchingsTarget) {
matchingsTarget = IMatchingsTarget(_contract);
dataswapContracts.matchingsTarget = IMatchingsTarget(_contract);
} else if (_type == RolesType.ContractType.EscrowDataTradingFee) {
escrowDataTradingFee = IEscrow(_contract);
dataswapContracts.escrowDataTradingFee = IEscrow(_contract);
} else if (
_type == RolesType.ContractType.EscrowDatacapChunkLandCollateral
) {
escrowDatacapChunkLandCollateral = IEscrow(_contract);
dataswapContracts.escrowDatacapChunkLandCollateral = IEscrow(
_contract
);
} else if (_type == RolesType.ContractType.EscrowDatacapCollateral) {
escrowDatacapCollateral = IEscrow(_contract);
dataswapContracts.escrowDatacapCollateral = IEscrow(_contract);
} else if (_type == RolesType.ContractType.EscrowChallengeCommission) {
escrowChallengeCommission = IEscrow(_contract);
dataswapContracts.escrowChallengeCommission = IEscrow(_contract);
} else if (
_type == RolesType.ContractType.EscrowChallengeAuditCollateral
) {
dataswapContracts.escrowChallengeAuditCollateral = IEscrow(
_contract
);
} else if (
_type == RolesType.ContractType.EscrowDisputeAuditCollateral
) {
dataswapContracts.escrowDisputeAuditCollateral = IEscrow(_contract);
} else if (_type == RolesType.ContractType.EscrowProofAuditCollateral) {
dataswapContracts.escrowProofAuditCollateral = IEscrow(_contract);
} else {
require(false, "Invalid RolesType.ContractType");
}
Expand Down Expand Up @@ -214,4 +211,132 @@ contract Roles is
) internal override(OwnableUpgradeable, Ownable2StepUpgradeable) {
super._transferOwnership(_newOwner);
}

/// @notice Get the Filplus contract.
/// @return Filplus contract address.
function filplus() external view returns (IFilplus) {
return dataswapContracts.filplus;
}

/// @notice Get the Finance contract.
/// @return Finance contract address.
function finance() external view returns (IFinance) {
return dataswapContracts.finance;
}

/// @notice Get the Filecoin contract.
/// @return Filecoin contract address.
function filecoin() external view returns (IFilecoin) {
return dataswapContracts.filecoin;
}

/// @notice Get the Carstore contract.
/// @return Carstore contract address.
function carstore() external view returns (ICarstore) {
return dataswapContracts.carstore;
}

/// @notice Get the Storages contract.
/// @return Storages contract address.
function storages() external view returns (IStorages) {
return dataswapContracts.storages;
}

/// @notice Get the MerkleUtils contract.
/// @return MerkleUtils contract address.
function merkleUtils() external view returns (IMerkleUtils) {
return dataswapContracts.merkleUtils;
}

/// @notice Get the Datasets contract.
/// @return Datasets contract address.
function datasets() external view returns (IDatasets) {
return dataswapContracts.datasets;
}

/// @notice Get the DatasetsProof contract.
/// @return DatasetsProof contract address.
function datasetsProof() external view returns (IDatasetsProof) {
return dataswapContracts.datasetsProof;
}

/// @notice Get the DatasetsChallenge contract.
/// @return DatasetsChallenge contract address.
function datasetsChallenge() external view returns (IDatasetsChallenge) {
return dataswapContracts.datasetsChallenge;
}

/// @notice Get the DatasetsRequirement contract.
/// @return DatasetsRequirement contract address.
function datasetsRequirement()
external
view
returns (IDatasetsRequirement)
{
return dataswapContracts.datasetsRequirement;
}

/// @notice Get the Matchings contract.
/// @return Matchings contract address.
function matchings() external view returns (IMatchings) {
return dataswapContracts.matchings;
}

/// @notice Get the MatchingsBids contract.
/// @return MatchingsBids contract address.
function matchingsBids() external view returns (IMatchingsBids) {
return dataswapContracts.matchingsBids;
}

/// @notice Get the MatchingsTarget contract.
/// @return MatchingsTarget contract address.
function matchingsTarget() external view returns (IMatchingsTarget) {
return dataswapContracts.matchingsTarget;
}

/// @notice Get the EscrowDataTradingFee contract.
/// @return EscrowDataTradingFee contract address.
function escrowDataTradingFee() external view returns (IEscrow) {
return dataswapContracts.escrowDataTradingFee;
}

/// @notice Get the EscrowDatacapChunkLandCollateral contract.
/// @return EscrowDatacapChunkLandCollateral contract address.
function escrowDatacapChunkLandCollateral()
external
view
returns (IEscrow)
{
return dataswapContracts.escrowDatacapChunkLandCollateral;
}

/// @notice Get the EscrowChallengeCommission contract.
/// @return EscrowChallengeCommission contract address.
function escrowChallengeCommission() external view returns (IEscrow) {
return dataswapContracts.escrowChallengeCommission;
}

/// @notice Get the EscrowDatacapCollateral contract.
/// @return EscrowDatacapCollateral contract address.
function escrowDatacapCollateral() external view returns (IEscrow) {
return dataswapContracts.escrowDatacapCollateral;
}

/// @notice Get the EscrowChallengeAuditCollateral contract.
/// @return EscrowChallengeAuditCollateral contract address.
function escrowChallengeAuditCollateral() external view returns (IEscrow) {
return dataswapContracts.escrowChallengeAuditCollateral;
}

/// @notice Get the EscrowDisputeAuditCollateral contract.
/// @return EscrowDisputeAuditCollateral contract address.
function escrowDisputeAuditCollateral() external view returns (IEscrow) {
return dataswapContracts.escrowDisputeAuditCollateral;
}

/// @notice Get the EscrowProofAuditCollateral contract.
/// @return EscrowProofAuditCollateral contract address.
function escrowProofAuditCollateral() external view returns (IEscrow) {
return dataswapContracts.escrowProofAuditCollateral;
}
}
6 changes: 6 additions & 0 deletions src/v0.8/core/finance/Finance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,12 @@ contract Finance is
base = roles.escrowChallengeCommission();
} else if (_type == FinanceType.Type.EscrowDatacapCollateral) {
base = roles.escrowDatacapCollateral();
} else if (_type == FinanceType.Type.EscrowChallengeAuditCollateral) {
base = roles.escrowChallengeAuditCollateral();
} else if (_type == FinanceType.Type.EscrowDisputeAuditCollateral) {
base = roles.escrowDisputeAuditCollateral();
} else if (_type == FinanceType.Type.EscrowProofAuditCollateral) {
base = roles.escrowProofAuditCollateral();
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/v0.8/interfaces/core/IRoles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,16 @@ interface IRoles is IAccessControlEnumerableUpgradeable {
/// @notice Get the EscrowDatacapCollateral contract.
/// @return EscrowDatacapCollateral contract address.
function escrowDatacapCollateral() external view returns (IEscrow);

/// @notice Get the EscrowChallengeAuditCollateral contract.
/// @return EscrowChallengeAuditCollateral contract address.
function escrowChallengeAuditCollateral() external view returns (IEscrow);

/// @notice Get the EscrowDisputeAuditCollateral contract.
/// @return EscrowDisputeAuditCollateral contract address.
function escrowDisputeAuditCollateral() external view returns (IEscrow);

/// @notice Get the EscrowProofAuditCollateral contract.
/// @return EscrowProofAuditCollateral contract address.
function escrowProofAuditCollateral() external view returns (IEscrow);
}
43 changes: 42 additions & 1 deletion src/v0.8/types/RolesType.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.21;
import {IRoles} from "src/v0.8/interfaces/core/IRoles.sol";
import {IEscrow} from "src/v0.8/interfaces/core/IEscrow.sol";
import {IFilplus} from "src/v0.8/interfaces/core/IFilplus.sol";
import {IFinance} from "src/v0.8/interfaces/core/IFinance.sol";
import {IFilecoin} from "src/v0.8/interfaces/core/IFilecoin.sol";
import {ICarstore} from "src/v0.8/interfaces/core/ICarstore.sol";
import {IStorages} from "src/v0.8/interfaces/module/IStorages.sol";
import {IMerkleUtils} from "src/v0.8/interfaces/utils/IMerkleUtils.sol";
import {IDatasets} from "src/v0.8/interfaces/module/IDatasets.sol";
import {IDatasetsProof} from "src/v0.8/interfaces/module/IDatasetsProof.sol";
import {IDatasetsChallenge} from "src/v0.8/interfaces/module/IDatasetsChallenge.sol";
import {IDatasetsRequirement} from "src/v0.8/interfaces/module/IDatasetsRequirement.sol";
import {IMatchings} from "src/v0.8/interfaces/module/IMatchings.sol";
import {IMatchingsBids} from "src/v0.8/interfaces/module/IMatchingsBids.sol";
import {IMatchingsTarget} from "src/v0.8/interfaces/module/IMatchingsTarget.sol";

/// @title RolesType Library
/// @notice This library defines constants for different roles within the system.
Expand Down Expand Up @@ -45,6 +60,32 @@ library RolesType {
EscrowDataTradingFee,
EscrowDatacapChunkLandCollateral,
EscrowDatacapCollateral,
EscrowChallengeCommission
EscrowChallengeCommission,
EscrowChallengeAuditCollateral,
EscrowDisputeAuditCollateral,
EscrowProofAuditCollateral
}

struct DataswapContracts {
IFilplus filplus;
IFinance finance;
IFilecoin filecoin;
ICarstore carstore;
IStorages storages;
IMerkleUtils merkleUtils;
IDatasets datasets;
IDatasetsProof datasetsProof;
IDatasetsChallenge datasetsChallenge;
IDatasetsRequirement datasetsRequirement;
IMatchings matchings;
IMatchingsBids matchingsBids;
IMatchingsTarget matchingsTarget;
IEscrow escrowDataTradingFee;
IEscrow escrowDatacapCollateral;
IEscrow escrowChallengeCommission;
IEscrow escrowDatacapChunkLandCollateral;
IEscrow escrowChallengeAuditCollateral;
IEscrow escrowDisputeAuditCollateral;
IEscrow escrowProofAuditCollateral;
}
}
Loading