Skip to content

Commit f655709

Browse files
authored
Merge pull request #64 from filecoin-project/m4-combined-updates
[M4] combined updates after review
2 parents 05ba9e3 + 79c63ce commit f655709

Some content is hidden

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

76 files changed

+4439
-898
lines changed

.env.example

+17-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
DEPLOYER_PK=""
1+
# Name of the Docker image used by Developer Env. (./lib-dev/dev-env/)
2+
FIL_SOL_DOCKER_IMG="fil-sol-dev-env:latest-amd64"
3+
4+
# Private key for the "master" (F4-type) account on Calibration network
5+
# - this account is used to fund further all necessary accounts (deployers/actors/...)
6+
# - faucet: https://faucet.calibnet.chainsafe-fil.io/send
7+
ETH_PK=""
8+
9+
# Generated dummy F3-type account on Calibration network using Lotus CLI
10+
# - IMPORTANT: do not add real funds !!!
11+
# - note:
12+
# - actor IDs don't have to be same on different networks
13+
# while the F3_ADDR, F3_PK would remain still the same
14+
# - F3_ID is the actor id on the Calibration network
15+
F3_ADDR="t3wybme2dab6l3h4zuuzxxteztmtq7jyh6qgrko3urkvhjfqdr33vsus4x5s2ccpuhhc5xscpx3bcpufsf6vzq"
16+
F3_PK="7b2254797065223a22626c73222c22507269766174654b6579223a22484651356a783635315a2f5470734332763846373148746f52706459684e52316b2f577135793968316a673d227d"
17+
F3_ID="112484"

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ yarn.lock
1919
typechain-types
2020

2121
.openzeppelin/
22-
.env
22+
.env
23+
.vscode
24+
25+
lib-dev/dev-env/.internal
26+
.wip

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
1010
[submodule "lib/forge-std"]
1111
path = lib/forge-std
12-
url = https://github.com/foundry-rs/forge-std
12+
url = https://github.com/foundry-rs/forge-std

Makefile

+24
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
hh_localnet_setup_lock := "localnet-setup-running.lock"
3+
24
################ BUILD ################
35
solc := "./bin/solc"
46

@@ -131,6 +133,26 @@ test_deserialize: build
131133
test_address: build
132134
cd testing && cargo test address -- --nocapture
133135

136+
################ TESTS HARDHAT ################
137+
138+
start_localnet:
139+
./lib-dev/dev-env/1_clean-start-localnet.sh
140+
141+
restart_localnet:
142+
./lib-dev/dev-env/2_restart-localnet.sh
143+
144+
simple_start_localnet:
145+
./lib-dev/dev-env/3_clean-simple-start.sh
146+
147+
kill_localnet:
148+
./lib-dev/dev-env/4_kill-lotus-ps.sh
149+
150+
test_hh_localnet:
151+
./lib-dev/dev-env/5_test-run-localnet.sh
152+
153+
test_hh_calibnet:
154+
export HH_NETWORK=calibnet && npx hardhat test --bail
155+
134156
################ TESTS SECURITY ################
135157

136158
security_account_api:
@@ -205,3 +227,5 @@ install-opencl:
205227
sudo apt-get update
206228
sudo apt-get install ocl-icd-opencl-dev
207229

230+
deps_install: install_solc_linux
231+
yarn install

contracts/v0.8/DataCapAPI.sol

+11-16
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ library DataCapAPI {
7575
return (0, result.deserializeBytesBigInt());
7676
}
7777

78-
CommonTypes.BigInt memory empty_res;
79-
return (exit_code, empty_res);
78+
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
8079
}
8180

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

95-
CommonTypes.BigInt memory empty_res;
96-
return (exit_code, empty_res);
94+
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
9795
}
9896

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

112-
CommonTypes.BigInt memory empty_res;
113-
return (exit_code, empty_res);
110+
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
114111
}
115112

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

181-
CommonTypes.BigInt memory empty_res;
182-
return (exit_code, empty_res);
178+
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
183179
}
184180

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

205-
CommonTypes.BigInt memory empty_res;
206-
return (exit_code, empty_res);
201+
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
207202
}
208203

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

229-
CommonTypes.BigInt memory empty_res;
230-
return (exit_code, empty_res);
224+
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
231225
}
232226

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

246-
CommonTypes.BigInt memory empty_res;
247-
return (exit_code, empty_res);
240+
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
248241
}
249242

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

263-
DataCapTypes.BurnFromReturn memory empty_res;
264-
return (exit_code, empty_res);
256+
return (
257+
exit_code,
258+
DataCapTypes.BurnFromReturn({balance: CommonTypes.BigInt({val: hex"00", neg: false}), allowance: CommonTypes.BigInt({val: hex"00", neg: false})})
259+
);
265260
}
266261
}

contracts/v0.8/MarketAPI.sol

+15-24
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ library MarketAPI {
7979
return (0, result.deserializeBytesBigInt());
8080
}
8181

82-
CommonTypes.BigInt memory empty_res;
83-
return (exit_code, empty_res);
82+
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
8483
}
8584

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

99-
MarketTypes.GetBalanceReturn memory empty_res;
100-
return (exit_code, empty_res);
98+
return (
99+
exit_code,
100+
MarketTypes.GetBalanceReturn({balance: CommonTypes.BigInt({val: hex"00", neg: false}), locked: CommonTypes.BigInt({val: hex"00", neg: false})})
101+
);
101102
}
102103

103104
/// @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.
@@ -118,8 +119,7 @@ library MarketAPI {
118119
return (0, result.deserializeGetDealDataCommitmentReturn());
119120
}
120121

121-
MarketTypes.GetDealDataCommitmentReturn memory empty_res;
122-
return (exit_code, empty_res);
122+
return (exit_code, MarketTypes.GetDealDataCommitmentReturn({data: hex"", size: 0}));
123123
}
124124

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

138-
uint64 empty_res;
139-
return (exit_code, empty_res);
138+
return (exit_code, uint64(0));
140139
}
141140

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

160-
uint64 empty_res;
161-
return (exit_code, empty_res);
159+
return (exit_code, uint64(0));
162160
}
163161

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

177-
CommonTypes.DealLabel memory empty_res;
178-
return (exit_code, empty_res);
175+
return (exit_code, CommonTypes.DealLabel({data: hex"", isString: false}));
179176
}
180177

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

194-
MarketTypes.GetDealTermReturn memory empty_res;
195-
return (exit_code, empty_res);
191+
return (exit_code, MarketTypes.GetDealTermReturn({start: CommonTypes.ChainEpoch.wrap(0), duration: CommonTypes.ChainEpoch.wrap(0)}));
196192
}
197193

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

216-
CommonTypes.BigInt memory empty_res;
217-
return (exit_code, empty_res);
212+
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
218213
}
219214

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

238-
CommonTypes.BigInt memory empty_res;
239-
return (exit_code, empty_res);
233+
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
240234
}
241235

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

260-
CommonTypes.BigInt memory empty_res;
261-
return (exit_code, empty_res);
254+
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
262255
}
263256

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

283-
bool empty_res;
284-
return (exit_code, empty_res);
276+
return (exit_code, false);
285277
}
286278

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

304-
MarketTypes.GetDealActivationReturn memory empty_res;
305-
return (exit_code, empty_res);
296+
return (exit_code, MarketTypes.GetDealActivationReturn({activated: CommonTypes.ChainEpoch.wrap(0), terminated: CommonTypes.ChainEpoch.wrap(0)}));
306297
}
307298

308299
/// @notice Publish a new set of storage deals (not yet included in a sector).

contracts/v0.8/MinerAPI.sol

+8-16
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ library MinerAPI {
5050
return (0, result.deserializeGetOwnerReturn());
5151
}
5252

53-
MinerTypes.GetOwnerReturn memory empty_res;
54-
return (exit_code, empty_res);
53+
return (exit_code, MinerTypes.GetOwnerReturn({owner: CommonTypes.FilAddress({data: hex""}), proposed: CommonTypes.FilAddress({data: hex""})}));
5554
}
5655

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

99-
bool empty_res;
100-
return (exit_code, empty_res);
98+
return (exit_code, false);
10199
}
102100

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

116-
uint64 empty_res;
117-
return (exit_code, empty_res);
114+
return (exit_code, uint64(0));
118115
}
119116

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

139-
CommonTypes.BigInt memory empty_res;
140-
return (exit_code, empty_res);
136+
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
141137
}
142138

143139
/// @notice Returns specified miner's vesting funds
@@ -150,8 +146,7 @@ library MinerAPI {
150146
if (exit_code == 0) {
151147
return (0, result.deserializeGetVestingFundsReturn());
152148
}
153-
MinerTypes.VestingFunds[] memory empty_res;
154-
return (exit_code, empty_res);
149+
return (exit_code, new MinerTypes.VestingFunds[](0));
155150
}
156151

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

301-
CommonTypes.FilAddress memory empty_res;
302-
return (exit_code, empty_res);
296+
return (exit_code, CommonTypes.FilAddress({data: hex""}));
303297
}
304298

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

317-
CommonTypes.FilAddress[] memory empty_res;
318-
return (exit_code, empty_res);
311+
return (exit_code, new CommonTypes.FilAddress[](0));
319312
}
320313

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

342-
CommonTypes.BigInt memory empty_res;
343-
return (exit_code, empty_res);
335+
return (exit_code, CommonTypes.BigInt({val: hex"00", neg: false}));
344336
}
345337
}

0 commit comments

Comments
 (0)