From ab8b769e0c4602434476f609ccca411847de3f85 Mon Sep 17 00:00:00 2001 From: Xiangan He Date: Thu, 31 Aug 2023 10:44:31 -0400 Subject: [PATCH 1/5] emergency section b link broken patch --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 9dae6a8..c3c3ad8 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -5,7 +5,7 @@ ## 💾 Filecoin Virtual Machine * [Section A: Upload, PoDSI and Deal ID](filecoin-virtual-machine/section-a.md) -* [Section B: RaaS](filecoin-virtual-machine/section-a.md) +* [Section B: RaaS](filecoin-virtual-machine/section-b.md) ## CLI Tool From f007089a0ea7dd6bddfcb374680fb7f071fd96c4 Mon Sep 17 00:00:00 2001 From: Xiangan He Date: Thu, 31 Aug 2023 10:45:31 -0400 Subject: [PATCH 2/5] emergency section b link broken patch --- filecoin-virtual-machine/section-b.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/filecoin-virtual-machine/section-b.md b/filecoin-virtual-machine/section-b.md index 3e77209..da5bb9b 100644 --- a/filecoin-virtual-machine/section-b.md +++ b/filecoin-virtual-machine/section-b.md @@ -1,10 +1,9 @@ +# Section B: RaaS Service Overview --- description: >- A concise guide detailing the functionalities and methods within the RaaS service smart contract on the Calibration Testnet. --- -# RaaS Service Overview - ## Self-hosted and Aggregator-Hosted RaaS Interfaces RaaS (renew, repair, replication) interacts with smart contracts to figure out which on-chain data deals to perform its services on. Specifically, it can interact with one of two types of interfaces: From 8f7a9e40224aa9d75a7153e2dc255b983cc1a75a Mon Sep 17 00:00:00 2001 From: Xiangan He Date: Thu, 31 Aug 2023 11:09:21 -0400 Subject: [PATCH 3/5] wonky description patch + reorg of section 2 --- filecoin-virtual-machine/section-a.md | 4 +++ filecoin-virtual-machine/section-b.md | 47 +++++++++++++++------------ 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/filecoin-virtual-machine/section-a.md b/filecoin-virtual-machine/section-a.md index 42286ca..f3ccb93 100644 --- a/filecoin-virtual-machine/section-a.md +++ b/filecoin-virtual-machine/section-a.md @@ -284,12 +284,16 @@ function uploadFile(bytes32 fileCID) public { require(!fileExists(fileCID), "File already exists"); // Check if the user's file contains the correct data + // The logic in verifyPoDSI() depends on your specific application + // Check out the various possibilities here https://docs.filecoin.io/smart-contracts/developing-contracts/solidity-libraries/ require(verifyPoDSI(fileCID), "File does not contain the correct data"); // Save the file's CID to prevent against replay attacks saveFile(fileCID); // Reward the user for uploading the file + // You can mint them a token or send them some $FIL + // Read more here: https://docs.filecoin.io/smart-contracts/developing-contracts/ethereum-libraries/#example-using-an-erc20-contract rewardUser(msg.sender); } ``` diff --git a/filecoin-virtual-machine/section-b.md b/filecoin-virtual-machine/section-b.md index da5bb9b..a634a31 100644 --- a/filecoin-virtual-machine/section-b.md +++ b/filecoin-virtual-machine/section-b.md @@ -1,26 +1,22 @@ -# Section B: RaaS Service Overview --- description: >- A concise guide detailing the functionalities and methods within the RaaS service smart contract on the Calibration Testnet. --- -## Self-hosted and Aggregator-Hosted RaaS Interfaces +# Section B: RaaS Service Overview -RaaS (renew, repair, replication) interacts with smart contracts to figure out which on-chain data deals to perform its services on. Specifically, it can interact with one of two types of interfaces: +## Aggregator-Hosted RaaS Interfaces -- Aggregator-hosted RaaS: A user relies on an existing FVM contract deployment to submit and complete data deals. Usually, the deployment is verified and maintained by storage infrastructures such as Lighthouse. -- Self-hosted RaaS: A user deploys a smart contract that inherits from [`IAggregatorOracle.sol`](https://github.com/xBalbinus/fevm-data-segment/blob/main/contracts/aggregator-oracle/IAggregatorOracle.sol) which allows them to rely on their own contract deployment to submit and complete data deals. +RaaS (renew, repair, replication) interacts with smart contracts to figure out which on-chain data deals to perform its services on. The Lighthouse aggregator hosts a RaaS service. A user can rely on an existing FVM contract deployment to submit and complete data deals. The deployment is verified and maintained by Lighthouse. -Among the two interfaces, some important common features stand out: +Within the smart contract interface, there are some outstanding important features that are critical to the RaaS service. These include:
#Function NamePurposeKey ParametersOutcome
1submitFunction that submits a new deal request to the oracle. Critical in all RaaS functionalities._cidEvent: SubmitAggregatorRequest
2getAllDealsGet all deal IDs for a specified cid_cidDeal[]
3getActiveDealsreturn all the _cid's active dealIds. Critical for replication deals._cidDeal[]
4getExpiringDealsreturn all the deals' dealIds if they are expiring within epochs. Critical for renewal and repair jobs._cid, epochsDeal[]
## Interacting with the Smart Contract -First, you'll need to either: -- Use an existing instance of the aggregator-hosted RaaS (hosted by Lighthouse) located at +First, you'll need to use an existing instance of the aggregator-hosted RaaS (hosted by Lighthouse) located at - **Calibration Testnet**: `0x6ec8722e6543fB5976a547434c8644b51e24785b` -- Or start an instance of the self-hosted RaaS by deploying a contract that inherits from `IAggregatorOracle` (`yarn deploy` in the [RaaS Starter Kit](https://github.com/filecoin-project/raas-starter-kit)) You can then interact with the smart contract by submitting a CID of your choice to the `submit` function. This will create a new deal request that will be picked up by the RaaS services. @@ -31,27 +27,25 @@ const dealStatus = await ethers.getContractAt("DealStatus", contractInstance); await dealStatus.submit(ethers.utils.toUtf8Bytes(newJob.cid)); ``` -The CID of the file comes from submitting the deal to Lighthouse. Recall from [Section A](./section-a.md) that there are two ways to upload a file to Lighthouse: +The CID of the file comes from submitting the deal to Lighthouse via. the file uploading process. With the Lighthouse SDK, uploading a file is as simple as: ```javascript import lighthouse from "@lighthouse-web3/sdk"; // ... other code + +// The upload function returns the CID of the file you uploaded. const uploadResponse = await lighthouse.upload('/path/to/adorable/dog.jpg', 'YOUR_API_KEY'); ``` -Alternatively, [RaaS Starter Kit](https://github.com/filecoin-project/raas-starter-kit) comes with a frontend that allows you to upload your file to Lighthouse, get a CID for the uploaded file, then seamlessly submit the CID to the smart contract (accessible via `yarn start`). - -![RaaS Starter Kit Frontend](../.gitbook/assets/Frontend.png) - But first, you'll need to know how to register the various RaaS workers. **RaaS functionality will not function automatically if deals are only created using submit function.** ## Add Replication, Renewal, Repair Workers -You can add workers to perform replication, renewal, and repair jobs by having them listen to the `SubmitAggregatorRequest`. The methods for doing so differ between the aggregator-hosted and self-hosted interfaces. +You can add workers to perform replication, renewal, and repair jobs by having them listen to the `SubmitAggregatorRequest`. -With aggregator-hosted interfaces you can register RaaS workers for any CID (including ones of files you didn't upload) by making a POST request to **`https://calibration.lighthouse.storage/api/register_job`** with your CID as the body of the request. +In the Lighthouse-aggreagtor hosted interface, you can register RaaS workers for any CID (including ones of files you didn't upload) by making a POST request to **`https://calibration.lighthouse.storage/api/register_job`** with your CID as the body of the request. ```bash # Example of registering a job @@ -83,10 +77,6 @@ const dealParams = { const uploadResponse = await lighthouse.upload('/path/to/adorable/dog.jpg', 'YOUR_API_KEY', false, dealParams); ``` -If you're hosting your own RaaS service (specifically, the one in the [RaaS Starter Kit](https://github.com/filecoin-project/raas-starter-kit)), there's an event listener inside that you can use to listen for new deal requests. - -To use this, simply do `yarn service` in the terminal and proceed through the frontend as you normally would - uploading any random file, and then registering the workers using the autocompleted CID that appears in the box. If you want to register the workers manually for a job that you didn't upload, simply paste in the known CID of your file and register the jobs anyway. For more information, check out the [RaaS Starter Kit README](https://github.com/filecoin-project/raas-starter-kit#readme) - ## Why Does This Matter? Building a decentralized application (dApp) or a Decentralized Autonomous Organization (DAO) to incentivize replications, renewals, and repairs of existing data could create a more resilient and economically sustainable data storage ecosystem. Some unique applications include: @@ -99,3 +89,20 @@ For more information, check out the full flow below.
+### Appendix: Self-hosted RaaS + +Alternatively, users can self-host RaaS. A user deploys a smart contract that inherits from [`IAggregatorOracle.sol`](https://github.com/xBalbinus/fevm-data-segment/blob/main/contracts/aggregator-oracle/IAggregatorOracle.sol) which allows them to rely on their own contract deployment to submit and complete data deals. + +#### Interacting with the Smart Contracts + +Start an instance of the self-hosted RaaS by deploying a contract that inherits from `IAggregatorOracle` (`yarn deploy` in the [RaaS Starter Kit](https://github.com/filecoin-project/raas-starter-kit)) + +The [RaaS Starter Kit](https://github.com/filecoin-project/raas-starter-kit) comes with a frontend that allows you to upload your file to Lighthouse, get a CID for the uploaded file, then seamlessly submit the CID to the smart contract (accessible via `yarn start`). + +![RaaS Starter Kit Frontend](../.gitbook/assets/Frontend.png) + +If you're hosting your own RaaS service (specifically, the one in the [RaaS Starter Kit](https://github.com/filecoin-project/raas-starter-kit)), there's an event listener inside that you can use to listen for new deal requests. + +To use this, simply do `yarn service` in the terminal and proceed through the frontend as you normally would - uploading any random file, and then registering the workers using the autocompleted CID that appears in the box. If you want to register the workers manually for a job that you didn't upload, simply paste in the known CID of your file and register the jobs anyway. + +For more information on self-hosting RaaS, check out the [RaaS Starter Kit README](https://github.com/filecoin-project/raas-starter-kit#readme). \ No newline at end of file From 0f77457000d2ec018075f2332673ece159a79a40 Mon Sep 17 00:00:00 2001 From: Xiangan He Date: Thu, 31 Aug 2023 13:13:03 -0400 Subject: [PATCH 4/5] readding the description to the top of the page to fix --- filecoin-virtual-machine/section-b.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/filecoin-virtual-machine/section-b.md b/filecoin-virtual-machine/section-b.md index d7cffe2..a634a31 100644 --- a/filecoin-virtual-machine/section-b.md +++ b/filecoin-virtual-machine/section-b.md @@ -1,9 +1,10 @@ -# Section B: RaaS Service Overview --- description: >- A concise guide detailing the functionalities and methods within the RaaS service smart contract on the Calibration Testnet. --- +# Section B: RaaS Service Overview + ## Aggregator-Hosted RaaS Interfaces RaaS (renew, repair, replication) interacts with smart contracts to figure out which on-chain data deals to perform its services on. The Lighthouse aggregator hosts a RaaS service. A user can rely on an existing FVM contract deployment to submit and complete data deals. The deployment is verified and maintained by Lighthouse. From 231627387193832a582029fbbadc50e7757e0082 Mon Sep 17 00:00:00 2001 From: Xiangan He Date: Sun, 10 Sep 2023 19:39:01 -0400 Subject: [PATCH 5/5] documentation addition and fixes --- filecoin-virtual-machine/section-a.md | 6 +++--- filecoin-virtual-machine/section-b.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/filecoin-virtual-machine/section-a.md b/filecoin-virtual-machine/section-a.md index f3ccb93..13abfe6 100644 --- a/filecoin-virtual-machine/section-a.md +++ b/filecoin-virtual-machine/section-a.md @@ -1,4 +1,4 @@ -# Section A: Upload, PoDSI and Deal ID +# Upload Your Data to Filecoin ## Quickstart: Uploading Your First 🐕 Onto Filecoin @@ -36,7 +36,7 @@ const dealParams = { num_copies: 2, }; // The `false` indicates that we're uploading a single file. -// Returns a CID (Content ID) for your file that you can use for PoDSI verification. +// Returns a CID (Content ID) for your file that you can use for provable storage verification. const uploadResponse = await lighthouse.upload('/path/to/adorable/dog.jpg', 'YOUR_API_KEY', false, dealParams); ``` @@ -106,7 +106,7 @@ const response = await lighthouse.upload(path, apiKey, false, dealParam_ignore); **Friendly Tip**: The term "epoch" can be thought of as a time unit in filecoin under which various operations occur like PoST PoRep..., with 2880 epochs being equivalent to a day. -### Understanding PoDSI: Getting the PoDSI for your file +### Understanding PoDSI: Getting the Provable Storage for your file Now that you've registered the picture of your puppy, how would you know that it's actually being maintained on the Filecoin network? This is where the PoDSI comes in. The PoDSI is a proof that your file is being maintained on the Filecoin network. diff --git a/filecoin-virtual-machine/section-b.md b/filecoin-virtual-machine/section-b.md index a634a31..c85b60d 100644 --- a/filecoin-virtual-machine/section-b.md +++ b/filecoin-virtual-machine/section-b.md @@ -3,7 +3,7 @@ description: >- A concise guide detailing the functionalities and methods within the RaaS service smart contract on the Calibration Testnet. --- -# Section B: RaaS Service Overview +# Renew Storage on Filecoin ## Aggregator-Hosted RaaS Interfaces