Skip to content

Commit fdede02

Browse files
nandit123gitbook-bot
authored andcommitted
GITBOOK-162: ravish's Jan 25 changes
1 parent 6e37446 commit fdede02

File tree

5 files changed

+221
-200
lines changed

5 files changed

+221
-200
lines changed

SUMMARY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141

4242
## 💾 Filecoin Virtual Machine
4343

44-
* [⬆ Upload, PoDSI, and Deal-Making](filecoin-virtual-machine/section-a.md)
45-
* [👷♂ Attaching RaaS (renew, repair, replication) Worker](filecoin-virtual-machine/section-b.md)
44+
* [⬆ Upload, PoDSI, and Deal-Making via SDK](filecoin-virtual-machine/section-a.md)
45+
* [👷♂ RaaS (renew, repair, replication) Smart Contracts](filecoin-virtual-machine/section-b.md)
4646
* [📖 PoDSI](filecoin-virtual-machine/podsi.md)
4747
* [✅ Deal Verification](filecoin-virtual-machine/deal-verification.md)
4848
* [👮♀ Self Hosted RaaS](filecoin-virtual-machine/self-hosted-raas.md)

filecoin-virtual-machine/deal-verification.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,33 @@ Deals and file inclusion can be verified using the following steps.
88
the successful return of calling `complete` (i.e. the call doesn’t revert) means that the deal’s proof is verified successfully by the smart contract and the mapping of the deals between cid and (miner\_id, deal\_id) are updated in the smart contract 
99
{% endhint %}
1010

11-
* You can call the **complete function** located here: `0x6ec8722e6543fB5976a547434c8644b51e24785b` to verify the successful inclusion of your in the live filecoin deal. Code for this smart contract can be found [here](https://github.com/lighthouse-web3/raas-starter-kit/blob/main/contracts/DealStatus.sol)
12-
* Submit your proof details, specifically: proofSubtree, proofIndex, and verifierData. <mark style="background-color:yellow;">\[Todo: add code here calling dealstatus.complete () contract function here and show actual response commP and that its not reverting in response]</mark>
13-
* What you'll get in return are two things: "commPa" and "sizePa". Think of these as your file's unique fingerprints.
14-
* These fingerprints (pieceCID and pieceSize) might look like regular text. You'll need to change them into a code-like format, known as hex, before you compare.
11+
* You can call the **complete function** located here: \
12+
`0x4015c3E5453d38Df71539C0F7440603C69784d7a` to verify the successful inclusion of your in the live filecoin deal. Code for this smart contract can be found [here](https://github.com/lighthouse-web3/raas-starter-kit/blob/main/contracts/DealStatus.sol)
1513

1614
{% hint style="info" %}
17-
Use the Bearer Authorization token (signed message) for authenticating API requests. Always renew the signed message if it expires or is invalidated.
15+
Lighthouse currently calls this complete function in calibration testnet for all the files submitted through `submitRaaS` function of our deployed contract.
1816
{% endhint %}
1917

18+
* Submit your proof details, specifically: proofSubtree, proofIndex, and verifierData.&#x20;
19+
20+
```javascript
21+
//sample pseudocode for testnet
22+
let response = await axios.get("https://api.lighthouse.storage/api/lighthouse/get_proof", {
23+
params: {
24+
cid: lighthouse_cid,
25+
network: "testnet" // Change the network to mainnet when ready
26+
}
27+
})
28+
const responseBody = response.body.data.dealInfo;
29+
// contractInstance is the address of the contract you deployed or the aggregator-hosted RaaS address above.
30+
const dealStatus = await ethers.getContractAt("DealStatus", contractInstance);
31+
//Call complete function for the file you want to upload to the Filecoin network in the following way.
32+
await dealStatus.complete(transactionId, responseBody.dealId, "t017840", responseBody.proof.inclusionProof, responseBody.proof.verifierData);
33+
```
34+
35+
* Complete function would emit event with two things: "commPa" and "sizePa". Think of these as your file's unique fingerprints.
36+
* These fingerprints (pieceCID and pieceSize) might look like regular text. You'll need to change them into a code-like format, known as hex, before you compare.
37+
2038
#### Step 2: Double-Check Your File's Data:
2139

2240
* This verifier data is like a mixed salad of your file combined with others. The first step confirmed that the salad has the right ingredients.
@@ -25,4 +43,4 @@ Use the Bearer Authorization token (signed message) for authenticating API reque
2543
#### Step 3: Check Live Deal on Explorer:
2644

2745
* You're almost done! You've just ensured your file is part of a bigger bundle handed to a miner.
28-
* Need more peace of mind? Head on over to [FilFox](https://calibration.filfox.info/en/deal/133652). Here, make sure the package's unique tag (the piece cid) aligns with what you've been provided earlier.
46+
* Need more peace of mind? Head on over to [FilFox](https://calibration.filfox.info/en/deal/133652). Here, make sure the `dealId` you received is live 🚀

filecoin-virtual-machine/section-a.md

Lines changed: 85 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1-
# ⬆ Upload, PoDSI, and Deal-Making
1+
# ⬆ Upload, PoDSI, and Deal-Making via SDK
22

3-
In this **Section A**, we will discuss the following
3+
In this **Section A**, we will discuss the following steps
44

5-
1. [Upload via Lighthouse SDK](section-a.md#1-upload-via-lighthouse-sdk)
6-
1. [Upload your first file](section-a.md#step-1-upload-your-first-file-using-lighthouse-sdk)&#x20;
7-
2. [Set deal parameters](section-a.md#step-2-set-deal-parameters)
8-
3. [Understanding PoDSI: Getting the PoDSI for your file](section-a.md#step-3-understanding-podsi-getting-the-podsi-for-your-file)
9-
4. [Get your deal ID from your upload](section-a.md#step-4-get-your-deal-id-from-your-upload)
10-
5. [Download your file using the file’s CID](section-a.md#step-5-download-your-file-using-the-files-cid)
11-
2. [Upload via Lighthouse Smart Contract Interaction](section-a.md#2-upload-via-lighthouse-smart-contract)
12-
1. [Attach Raas Workers (discussed in Section B)](section-b.md)
5+
1. [Upload your first file](section-a.md#step-1-upload-your-first-file-using-lighthouse-sdk)&#x20;
6+
2. [Set deal parameters](section-a.md#step-2-set-deal-parameters)
7+
3. [Understanding PoDSI: Getting the PoDSI for your file](section-a.md#step-3-understanding-podsi-getting-the-podsi-for-your-file)
8+
4. [Get your deal ID from your upload](section-a.md#step-4-get-your-deal-id-from-your-upload)
9+
5. [Download your file using the file’s CID](section-a.md#step-5-download-your-file-using-the-files-cid)
1310

14-
<figure><picture><source srcset="../.gitbook/assets/Group 1707478179.png" media="(prefers-color-scheme: dark)"><img src="../.gitbook/assets/CID deal.png" alt=""></picture><figcaption></figcaption></figure>
1511

16-
## <mark style="color:blue;">1) Upload via Lighthouse SDK</mark>
1712

1813
### Step 1: Upload your first file using Lighthouse SDK
1914

@@ -172,70 +167,87 @@ The response, an example of a PoDSI proof on Calibration, should look something
172167
{% code title="PoDSI response" lineNumbers="true" %}
173168
```json
174169
{
175-
"pieceCID": "baga6ea4seaqgbiszkxkzmaxio5zjucpg2sd4n6abvmcsenah27g4xtjszxtzmia",
176-
"pieceSize": 4194304,
177-
"carFileSize": 4161536,
178-
"proof": {
179-
"pieceCID": "baga6ea4seaqn6s6n3irnz2ewfwlybhpjzrg6i57fzuwletj5sxcv7hz5rauewli",
180-
"id": "19845d2a-4fae-426c-893d-491770c317e8",
181-
"lastUpdate": 1692888301,
182-
"fileProof": {
183-
"verifierData": {
184-
"commPc": "0181e203922020df4bcdda22dce8962d97809de9cc4de477e5cd2cb24d3d95c55f9f3d88284b2d",
185-
"sizePc": "200000"
170+
pieceCID:
171+
'baga6ea4seaqn6s6n3irnz2ewfwlybhpjzrg6i57fzuwletj5sxcv7hz5rauewli',
172+
dealInfo: [
173+
{
174+
dealId: 53078591,
175+
storageProvider: 'f02620',
176+
proof: {
177+
inclusionProof: {
178+
proofIndex: {
179+
index: '1ffc08fd',
180+
path: [
181+
'624c730d13648b9d386948925afbad6980b3a08dd9db7d8d156ffd0d15f1f724',
182+
'6f980e8fd5af43732faf137ff24808dc42f15ec07b5671f9c85c899550d7790a',
183+
'a2f5e3c55a9ff784cc5f39b63846914caf3f0556a65ef6df5847c69df7f30200',
184+
'a46614cbaee2e1c7ed71e43d3f6d8e9ed0ff4e42422f4347fc1ffd0700e24017',
185+
'e919844c2aafbfe63ef9dae0990980c66d3f2548b6b3781445055b9221142901',
186+
'ecbe60a5baf21f07d8f9ae98805149c6e595d7413fc591a86b06e00a0317fc22',
187+
'7455143f0a3424fab9bc576ace3b6fa95bba4ea59e270fc0a1ed06381ddc9e0b',
188+
'356e98673a0f1457e405ebe8bb4564cd6b537fde6e22d75d4b986abf2807be05',
189+
'd29ee6aca59e9b005e74defa05e3edb54e8ecd448b2834635edb3252b516d122',
190+
'77871a87f00a1d260af0050586833a209ce84fce0f783486a2a64a838abebd03',
191+
'6eb665702e7b642b5cc4447b6ad5ca7eedb1de773862ca126ad7cc1a81a7fc16',
192+
'aba5c7451052da6de12715f3f7943a0c65171cd405f296cfdc689f0ae0da950f',
193+
'98d4f4a746d58a5b14be5ec1ed24f99fe25a7caa55769e6abe88f12bdbb79116',
194+
'0c90015fc0e88c578510b0be936618deda2cf6e06f41b4f8d386defc6bf39f16',
195+
'd99887b973573a96e11393645236c17b1f4c7034d723c7a99f709bb4da61162b',
196+
'd0b530dbb0b4f25c5d2f2a28dfee808b53412a02931f18c499f5a254086b1326',
197+
'84c0421ba0685a01bf795a2344064fe424bd52a9d24377b394ff4c4b4568e811',
198+
'65f29e5d98d246c38b388cfc06db1f6b021303c5a289000bdce832a9c3ec421c',
199+
'a2247508285850965b7e334b3127b0c042b1d046dc54402137627cd8799ce13a',
200+
'dafdab6da9364453c26d33726b9fefe343be8f81649ec009aad3faff50617508',
201+
'd941d5e0d6314a995c33ffbd4fbe69118d73d4e5fd2cd31f0f7c86ebdd14e706',
202+
'514c435c3d04d349a5365fbd59ffc713629111785991c1a3c53af22079741a2f',
203+
'ad06853969d37d34ff08e09f56930a4ad19a89def60cbfee7e1d3381c1e71c37',
204+
'39560e7b13a93b07a243fd2720ffa7cb3e1d2e505ab3629e79f46313512cda06',
205+
'ccc3c012f5b05e811a2bbfdd0f6833b84275b47bf229c0052a82484f3c1a5b3d',
206+
'7df29b69773199e8f2b40b77919d048509eed768e2c7297b1f1437034fc3c62c',
207+
'fa668a0a32942239e35c880bc01f031e87d3dd3d5088a325959ef00a2fe4ed00',
208+
'4c4000f3b62fd9999516e7869f3d3e0c7ca983c0749c8b52f702fb1dae87692f',
209+
'ec3b81a302915954112ec8a6d455751469252e0ca21319e7215b43d13c7c311c',
210+
],
186211
},
187-
"inclusionProof": {
188-
"proofIndex": {
189-
"index": "ffe0",
190-
"path": [
191-
"f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb0b",
192-
"3731bb99ac689f66eef5973e4a94da188f4ddcae580724fc6f3fd60dfd488333",
193-
"642a607ef886b004bf2c1978463ae1d4693ac0f410eb2d1b7a47fe205e5e750f",
194-
"57a2381a28652bf47f6bef7aca679be4aede5871ab5cf3eb2c08114488cb8526",
195-
"1f7ac9595510e09ea41c460b176430bb322cd6fb412ec57cb17d989a4310372f",
196-
"fc7e928296e516faade986b28f92d44a4f24b935485223376a799027bc18f833",
197-
"08c47b38ee13bc43f41b915c0eed9911a26086b3ed62401bf9d58b8d19dff624",
198-
"b2e47bfb11facd941f62af5c750f3ea5cc4df517d5c4f16db2b4d77baec1a32f",
199-
"f9226160c8f927bfdcc418cdf203493146008eaefb7d02194d5e548189005108",
200-
"2c1a964bb90b59ebfe0f6da29ad65ae3e417724a8f7c11745a40cac1e5e74011",
201-
"fee378cef16404b199ede0b13e11b624ff9d784fbbed878d83297e795e024f02",
202-
"8e9e2403fa884cf6237f60df25f83ee40dca9ed879eb6f6352d15084f5ad0d3f",
203-
"752d9693fa167524395476e317a98580f00947afb7a30540d625a9291cc12a07",
204-
"7022f60f7ef6adfa17117a52619e30cea82c68075adf1c667786ec506eef2d19",
205-
"d99887b973573a96e11393645236c17b1f4c7034d723c7a99f709bb4da61162b",
206-
"df4bcdda22dce8962d97809de9cc4de477e5cd2cb24d3d95c55f9f3d88284b2d"
207-
]
208-
},
209-
"proofSubtree": {
210-
"index": "0",
211-
"path": [
212-
"83ccb895e53b292546ccda9c45017c247ffa54b406f492605c9148e09aa2f208"
213-
]
214-
}
212+
proofSubtree: {
213+
index: '9e3',
214+
path: [
215+
'1a70519a83a389da68342023f94c0b15bc6f6648bad14e4e27fc2c2d125d3f20',
216+
'a3c0174ed523fe92d9ddde004b2edfed748160d039246b3d74afccb9a0b0c519',
217+
'dc478492b1d8a2b1ccc39814ab5015f24b7e3a0fc942a3d48dabda78e1ab2a3f',
218+
'e3e9663d7b67090385ff0732e29fd20c663e0815c25a11d10da506b248532012',
219+
'dafdab6da9364453c26d33726b9fefe343be8f81649ec009aad3faff50617508',
220+
'a77eff48b3368c4d75808dcbc0caf1d403abdd8954aeb643fed17527b557ce24',
221+
'055300ed6b6526d89f2dcfaf9f59b893bc6cd53c3eaa27876db80830e85b443e',
222+
'38c3e42a3376c26ea82e920e5e5b052f712ad376ef7999e9d8af035c55bcf20f',
223+
'4b5cbc0110eb00a5fc1722a2f7a474b619df9c498bb80622f879b6471345521b',
224+
'db084639887800382d080d44a0fd9818b0344da75a66599e1fc42887ab777035',
225+
'08ca66a143b334d38a8829247688e45548bf26005401ba9e6350267fb6a7b424',
226+
'60414c8e87371715a022a4f5928d898a19ced0133b90fe3b8b32726334a24b18',
227+
'e671e3b30d01a29b2d05632592b36541fa221cb14d9205253896b40b7bcc1700',
228+
'07406022b338845ccc7a8750cb2e927c5f2c671cae07897f5deab2e4f1bf8905',
229+
],
215230
},
216-
"indexRecord": {
217-
"checksum": "4a8e39cfd5af583596f54f95954a991b",
218-
"proofIndex": "df4bcdda22dce8962d97809de9cc4de477e5cd2cb24d3d95c55f9f3d88284b2d",
219-
"proofSubtree": 0,
220-
"size": 2097152
221-
}
222-
}
223-
},
224-
"dealInfo": [
225-
{
226-
"dealUUID": "f064d4d5-7b35-4647-8df7-91fb8fb99f23",
227-
"dealId": 13279,
228-
"storageProvider": "t017840"
231+
},
232+
verifierData: {
233+
commPc:
234+
'0181e203922020df4bcdda22dce8962d97809de9cc4de477e5cd2cb24d3d95c55f9f3d88284b2d',
235+
sizePc: '200000',
236+
},
237+
indexRecord: {
238+
checksum: '2dd9de62dd6433725d537f8c43941a1b',
239+
proofIndex:
240+
'df4bcdda22dce8962d97809de9cc4de477e5cd2cb24d3d95c55f9f3d88284b2d',
241+
proofSubtree: 5307891712,
242+
size: 2097152,
243+
},
229244
},
230-
{
231-
"dealUUID": "ae8f6709-5ca0-4944-abb1-cd04cf05e0c3",
232-
"dealId": null,
233-
"storageProvider": "t017819"
234-
}
245+
aggPieceCID:
246+
'baga6ea4seaqgcyx3xz23psubfg2c6qzhffa4fuchmydcwzamtpaf5ct46l5nola',
247+
aggPieceSize: 34359738368,
248+
aggCarFileSize: 34091302912,
249+
},
235250
],
236-
"previousAggregates": [
237-
"975afcd3-ff3e-4395-a50e-24500ca0bfb7"
238-
]
239251
}
240252
```
241253
{% endcode %}
@@ -307,72 +319,4 @@ saveResponseToFile(response, filePath) {
307319

308320
***
309321

310-
## <mark style="color:blue;">2) Upload via Lighthouse Smart Contract</mark>
311-
312-
In this method, we will pass a cid to Lighthouse Smart Contract deployed on the following address
313-
314-
* **Mainnet:** `0xd928b92E6028463910b2005d118C2edE16C38a2a`
315-
* **Calibration Testnet**: `0x01ccBC72B2f0Ac91B79Ff7D2280d79e25f745960`
316-
317-
The source code for this contract can be found [here](https://github.com/lighthouse-web3/raas-starter-kit/blob/main/contracts/DealStatus.sol)
318-
319-
### Smart Contract Interface
320-
321-
Within the smart contract interface, some important features are critical to the RaaS service. These include:
322-
323-
<table><thead><tr><th width="59">#</th><th width="178">Function Name</th><th width="233">Purpose</th><th width="229">Key Parameters</th><th>Outcome</th></tr></thead><tbody><tr><td>1</td><td><code>submit</code></td><td>Function that submits a new deal request to the oracle and will creates a new deal. By default, there will be no renewals and replications for this deal</td><td><code>_cid</code></td><td><code>Event: SubmitAggregatorRequest</code></td></tr><tr><td>2</td><td><code>submitRaaS</code></td><td>Function that submits a new deal request to the oracle and will creates a new deal. Here user can define deal parameters.</td><td><code>_cid,</code><br><code>_replication_target,</code><br><code>_repair_threshold,</code><br><code>_renew_threshold</code></td><td><code>Event:SubmitAggregatorRequestWithRaaS</code></td></tr><tr><td>3</td><td><code>getAllDeals</code></td><td>Get all deal IDs for a specified cid</td><td><code>_cid</code></td><td><code>Deal[]</code></td></tr><tr><td>4</td><td><code>getActiveDeals</code></td><td>return all the _cid's active dealIds. Critical for replication deals.</td><td><code>_cid</code></td><td><code>Deal[]</code></td></tr><tr><td>5</td><td><code>getExpiringDeals</code></td><td>return all the deals' dealIds if they are expiring within <code>epochs</code>. Critical for renewal and repair jobs.</td><td><code>_cid, epochs</code></td><td><code>Deal[]</code></td></tr></tbody></table>
324-
325-
### Calling SubmitRaaS Function
326-
327-
You can interact with the smart contract by submitting a CID of your choice to the `submit` function. This will create a new deal request that the Lighthouse RaaS Worker will pick up when attached as discussed in [Section B](section-b.md).
328-
329-
{% code lineNumbers="true" %}
330-
```javascript
331-
// contractInstance is the address of the contract you deployed or the aggregator-hosted RaaS address above.
332-
const dealStatus = await ethers.getContractAt("DealStatus", contractInstance);
333-
// Submit the CID of the file you want to upload to the Filecoin network in the following way.
334-
await dealStatus.submitRaaS(ethers.utils.toUtf8Bytes(newJob.cid), 2, 4, 40);
335-
```
336-
{% endcode %}
337-
338-
{% hint style="warning" %}
339-
Upload with the submit function will not start deal-making by default on the Filecoin network. To start deal-making for the cid passed through the submit function, refer to [Section B](section-b.md) of Attaching RaaS (renew, repair, replication) Worker
340-
{% endhint %}
341-
342-
***
343-
344-
## <mark style="color:blue;">3) Why does all this matter?</mark>
345-
346-
We see a bright future in enabling programmable, immutable, decentralized data storage for developers.
347-
348-
Lighthouse SDK is designed to be simple and easy to use. We hope that this will enable developers to easily integrate the Filecoin network as the primary data storage layer for their applications.
349-
350-
More importantly, this enables developers to build novel applications. Imagine a dapp or DAO that can be built to incentivize, analyze and store upload metadata on-chain. There are a couple of examples of this:
351-
352-
* Rewarding $TOKEN based on the upload of a particular file and their CID.
353-
* Being able to track CIDs and deal IDs onchain for verification and airdropping.
354-
* Building more advanced, robust DataDAOs (check out the starter kit [here](https://github.com/filecoin-project/fevm-data-dao-kit)!)
355-
356-
For your consideration, here's some pseudocode of how you could build a simple dapp that rewards users for uploading files to the Filecoin network:
357-
358-
```solidity
359-
function uploadFile(bytes32 fileCID) public {
360-
// Check if the file has already been uploaded
361-
require(!fileExists(fileCID), "File already exists");
362-
363-
// Check if the user's file contains the correct data
364-
// The logic in verifyPoDSI() depends on your specific application
365-
// Check out the various possibilities here https://docs.filecoin.io/smart-contracts/developing-contracts/solidity-libraries/
366-
require(verifyPoDSI(fileCID), "File does not contain the correct data");
367-
368-
// Save the file's CID to prevent against replay attacks
369-
saveFile(fileCID);
370-
371-
// Reward the user for uploading the file
372-
// You can mint them a token or send them some $FIL
373-
// Read more here: https://docs.filecoin.io/smart-contracts/developing-contracts/ethereum-libraries/#example-using-an-erc20-contract
374-
rewardUser(msg.sender);
375-
}
376-
```
377-
378-
***
322+
You can also work with PODSI, and deal making on-chain with help of smart contracts which we will discuss thoroughly in [next section](section-b.md).

0 commit comments

Comments
 (0)