Skip to content

Commit

Permalink
Merge branch 'm4-combined' of https://github.com/filecoin-project/fil…
Browse files Browse the repository at this point in the history
…ecoin-solidity into m4-combined
  • Loading branch information
wertikalk committed Jun 17, 2024
2 parents 33fc59b + 34cae2c commit 697a0d2
Show file tree
Hide file tree
Showing 76 changed files with 4,364 additions and 897 deletions.
11 changes: 10 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
DEPLOYER_PK=""
FIL_SOL_DOCKER_IMG="fil-sol-dev-env:latest-amd64"

#Master account
ETH_PK=""

#Generated F3 account on Calibnet
#IMPORTANT: do not add real funds !!!
F3_ADDR="t3wybme2dab6l3h4zuuzxxteztmtq7jyh6qgrko3urkvhjfqdr33vsus4x5s2ccpuhhc5xscpx3bcpufsf6vzq"
F3_PK="137412325dfbf9757df5d14c645aacffc4803c12798e0b2cdd154772f5799c47"
F3_ID="111415"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ yarn.lock
typechain-types

.openzeppelin/
.env
.env
.vscode

lib-dev/dev-env/.internal
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
url = https://github.com/foundry-rs/forge-std
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

hh_localnet_setup_lock := "localnet-setup-running.lock"

################ BUILD ################
solc := "./bin/solc"

Expand Down Expand Up @@ -131,6 +133,26 @@ test_deserialize: build
test_address: build
cd testing && cargo test address -- --nocapture

################ TESTS HARDHAT ################

start_localnet:
./lib-dev/dev-env/1_clean-start-localnet.sh

restart_localnet:
./lib-dev/dev-env/2_restart-localnet.sh

simple_start_localnet:
./lib-dev/dev-env/3_clean-simple-start.sh

kill_localnet:
./lib-dev/dev-env/4_kill-lotus-ps.sh

test_hh_localnet:
./lib-dev/dev-env/5_test-run-localnet.sh

test_hh_calibnet:
export HH_NETWORK=calibnet && npx hardhat test

################ TESTS SECURITY ################

security_account_api:
Expand Down Expand Up @@ -205,3 +227,5 @@ install-opencl:
sudo apt-get update
sudo apt-get install ocl-icd-opencl-dev

deps_install: install_solc_linux
yarn install
27 changes: 11 additions & 16 deletions contracts/v0.8/DataCapAPI.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ library DataCapAPI {
return (0, result.deserializeBytesBigInt());
}

CommonTypes.BigInt memory empty_res;
return (exit_code, empty_res);
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
}

/// @notice Return the DataCap token balance for the wallet address.
Expand All @@ -92,8 +91,7 @@ library DataCapAPI {
return (0, result.deserializeBytesBigInt());
}

CommonTypes.BigInt memory empty_res;
return (exit_code, empty_res);
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
}

/// @notice Return the allowance between owner and operator address.
Expand All @@ -109,8 +107,7 @@ library DataCapAPI {
return (0, result.deserializeBytesBigInt());
}

CommonTypes.BigInt memory empty_res;
return (exit_code, empty_res);
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
}

/// @notice Transfers data cap tokens to an address.
Expand Down Expand Up @@ -178,8 +175,7 @@ library DataCapAPI {
return (0, result.deserializeBytesBigInt());
}

CommonTypes.BigInt memory empty_res;
return (exit_code, empty_res);
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
}

/// @notice Decrease the DataCap token allowance that an operator controls of the owner's balance by the requested amount.
Expand All @@ -202,8 +198,7 @@ library DataCapAPI {
return (0, result.deserializeBytesBigInt());
}

CommonTypes.BigInt memory empty_res;
return (exit_code, empty_res);
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
}

/// @notice Revoke the DataCap token allowance from the operator and set the operator's allowance in behave of owner/caller address to 0.
Expand All @@ -226,8 +221,7 @@ library DataCapAPI {
return (0, result.deserializeBytesBigInt());
}

CommonTypes.BigInt memory empty_res;
return (exit_code, empty_res);
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
}

/// @notice Burn an amount of DataCap token from the owner/caller address, decreasing total token supply.
Expand All @@ -243,8 +237,7 @@ library DataCapAPI {
return (0, result.deserializeArrayBigInt());
}

CommonTypes.BigInt memory empty_res;
return (exit_code, empty_res);
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
}

/// @notice Burn an amount of DataCap token from the specified address (owner address), decrease the allowance of operator/caller, and decrease total token supply.
Expand All @@ -260,7 +253,9 @@ library DataCapAPI {
return (0, result.deserializeBurnFromReturn());
}

DataCapTypes.BurnFromReturn memory empty_res;
return (exit_code, empty_res);
return (
exit_code,
DataCapTypes.BurnFromReturn({balance: CommonTypes.BigInt({val: hex"00", neg: false}), allowance: CommonTypes.BigInt({val: hex"00", neg: false})})
);
}
}
39 changes: 15 additions & 24 deletions contracts/v0.8/MarketAPI.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ library MarketAPI {
return (0, result.deserializeBytesBigInt());
}

CommonTypes.BigInt memory empty_res;
return (exit_code, empty_res);
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
}

/// @notice Return the escrow balance and locked amount for an address.
Expand All @@ -96,8 +95,10 @@ library MarketAPI {
return (0, result.deserializeGetBalanceReturn());
}

MarketTypes.GetBalanceReturn memory empty_res;
return (exit_code, empty_res);
return (
exit_code,
MarketTypes.GetBalanceReturn({balance: CommonTypes.BigInt({val: hex"00", neg: false}), locked: CommonTypes.BigInt({val: hex"00", neg: false})})
);
}

/// @notice This will be available after the deal is published (whether or not is is activated) and up until some undefined period after it is terminated.
Expand All @@ -118,8 +119,7 @@ library MarketAPI {
return (0, result.deserializeGetDealDataCommitmentReturn());
}

MarketTypes.GetDealDataCommitmentReturn memory empty_res;
return (exit_code, empty_res);
return (exit_code, MarketTypes.GetDealDataCommitmentReturn({data: hex"", size: 0}));
}

/// @notice Returns the client for the specified deal
Expand All @@ -135,8 +135,7 @@ library MarketAPI {
return (0, result.deserializeUint64());
}

uint64 empty_res;
return (exit_code, empty_res);
return (exit_code, uint64(0));
}

/// @notice Returns the provider for a specified deal
Expand All @@ -157,8 +156,7 @@ library MarketAPI {
return (0, result.deserializeUint64());
}

uint64 empty_res;
return (exit_code, empty_res);
return (exit_code, uint64(0));
}

/// @notice Returns the label of a storage deal
Expand All @@ -174,8 +172,7 @@ library MarketAPI {
return (0, result.deserializeDealLabel());
}

CommonTypes.DealLabel memory empty_res;
return (exit_code, empty_res);
return (exit_code, CommonTypes.DealLabel({data: hex"", isString: false}));
}

/// @notice Returns the start epoch and duration(in epochs) of a deal proposal.
Expand All @@ -191,8 +188,7 @@ library MarketAPI {
return (0, result.deserializeGetDealTermReturn());
}

MarketTypes.GetDealTermReturn memory empty_res;
return (exit_code, empty_res);
return (exit_code, MarketTypes.GetDealTermReturn({start: CommonTypes.ChainEpoch.wrap(0), duration: CommonTypes.ChainEpoch.wrap(0)}));
}

/// @notice Returns the total price that will be paid from the client to the provider for this deal.
Expand All @@ -213,8 +209,7 @@ library MarketAPI {
return (0, result.deserializeBytesBigInt());
}

CommonTypes.BigInt memory empty_res;
return (exit_code, empty_res);
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
}

/// @notice get the client collateral requirement for a deal
Expand All @@ -235,8 +230,7 @@ library MarketAPI {
return (0, result.deserializeBytesBigInt());
}

CommonTypes.BigInt memory empty_res;
return (exit_code, empty_res);
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
}

/// @notice Returns the provider's collateral requirement for a deal
Expand All @@ -257,8 +251,7 @@ library MarketAPI {
return (0, result.deserializeBytesBigInt());
}

CommonTypes.BigInt memory empty_res;
return (exit_code, empty_res);
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
}

/// @notice Returns the verified flag for a deal
Expand All @@ -280,8 +273,7 @@ library MarketAPI {
return (0, result.deserializeBool());
}

bool empty_res;
return (exit_code, empty_res);
return (exit_code, false);
}

/// @notice Fetches activation state for a deal.
Expand All @@ -301,8 +293,7 @@ library MarketAPI {
return (0, result.deserializeGetDealActivationReturn());
}

MarketTypes.GetDealActivationReturn memory empty_res;
return (exit_code, empty_res);
return (exit_code, MarketTypes.GetDealActivationReturn({activated: CommonTypes.ChainEpoch.wrap(0), terminated: CommonTypes.ChainEpoch.wrap(0)}));
}

/// @notice Publish a new set of storage deals (not yet included in a sector).
Expand Down
24 changes: 8 additions & 16 deletions contracts/v0.8/MinerAPI.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ library MinerAPI {
return (0, result.deserializeGetOwnerReturn());
}

MinerTypes.GetOwnerReturn memory empty_res;
return (exit_code, empty_res);
return (exit_code, MinerTypes.GetOwnerReturn({owner: CommonTypes.FilAddress({data: hex""}), proposed: CommonTypes.FilAddress({data: hex""})}));
}

/// @notice Proposes or confirms a change of owner address.
Expand Down Expand Up @@ -96,8 +95,7 @@ library MinerAPI {
return (0, result.deserializeBool());
}

bool empty_res;
return (exit_code, empty_res);
return (exit_code, false);
}

/// @dev For more information about sector sizes, please refer to https://spec.filecoin.io/systems/filecoin_mining/sector/#section-systems.filecoin_mining.sector
Expand All @@ -113,8 +111,7 @@ library MinerAPI {
return (0, result.deserializeUint64());
}

uint64 empty_res;
return (exit_code, empty_res);
return (exit_code, uint64(0));
}

/// @notice This is calculated as actor balance - (vesting funds + pre-commit deposit + initial pledge requirement + fee debt)
Expand All @@ -136,8 +133,7 @@ library MinerAPI {
return (0, result.deserializeBytesBigInt());
}

CommonTypes.BigInt memory empty_res;
return (exit_code, empty_res);
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
}

/// @notice Returns specified miner's vesting funds
Expand All @@ -150,8 +146,7 @@ library MinerAPI {
if (exit_code == 0) {
return (0, result.deserializeGetVestingFundsReturn());
}
MinerTypes.VestingFunds[] memory empty_res;
return (exit_code, empty_res);
return (exit_code, new MinerTypes.VestingFunds[](0));
}

/// @notice Proposes or confirms a change of beneficiary address.
Expand Down Expand Up @@ -298,8 +293,7 @@ library MinerAPI {
return (0, result.deserializeArrayFilAddress());
}

CommonTypes.FilAddress memory empty_res;
return (exit_code, empty_res);
return (exit_code, CommonTypes.FilAddress({data: hex""}));
}

/// @notice Returns miner's multiaddresses
Expand All @@ -314,8 +308,7 @@ library MinerAPI {
return (0, result.deserializeGetMultiaddrsReturn());
}

CommonTypes.FilAddress[] memory empty_res;
return (exit_code, empty_res);
return (exit_code, new CommonTypes.FilAddress[](0));
}

/// @notice Withdraws balance for a specified miner
Expand All @@ -339,7 +332,6 @@ library MinerAPI {
return (0, result.deserializeBytesBigInt());
}

CommonTypes.BigInt memory empty_res;
return (exit_code, empty_res);
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
}
}
Loading

0 comments on commit 697a0d2

Please sign in to comment.