Skip to content

Commit 2f6c837

Browse files
authored
Merge pull request #14 from fidlabs/feature/usage-docs
usage docs
2 parents 8c29186 + 6eb4b5a commit 2f6c837

File tree

3 files changed

+115
-9
lines changed

3 files changed

+115
-9
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ docs/
1313
# Dotenv file
1414
.env
1515

16+
example/cars/output.csv
17+
1618
z_notes
1719
precompiles
1820
broadcast

README.md

Lines changed: 113 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,20 @@ Auto Allocator that assigns data cap to each client and semi-random storage prov
1414
- [Allocation Phase](#allocation-phase)
1515
- [Claim Phase](#claim-phase)
1616
- [Collateral Retrieval](#collateral-retrieval)
17-
- [Requirements](#requirements)
1817
- [Demo](#demo)
18+
- [Usage](#usage)
19+
- [Flow overview](#flow-overview)
20+
- [Prepare CAR files](#prepare-car-files)
21+
- [Prepare input data for allocation](#prepare-input-data-for-allocation)
22+
- [Prepare ETH wallet with sufficient balance](#prepare-eth-wallet-with-sufficient-balance)
23+
- [Getting current collateral value per CID](#getting-current-collateral-value-per-cid)
24+
- [Create Allocation Package (Transfer Data Cap for multiple files)](#create-allocation-package-transfer-data-cap-for-multiple-files)
25+
- [Example of using the Frontend app](#example-of-using-the-frontend-app)
26+
- [Example of using the CSV file with `cast` command](#example-of-using-the-csv-file-with-cast-command)
27+
- [Monitoring Allocation Packages](#monitoring-allocation-packages)
28+
- [Retrieving Collateral](#retrieving-collateral)
1929
- [Deployment](#deployment)
30+
- [Requirements](#requirements)
2031
- [Environment Setup](#environment-setup)
2132
- [Deployment](#deployment-1)
2233
- [Calibnet Deployment](#calibnet-deployment)
@@ -89,21 +100,114 @@ The semi-random selection works by starting from a random index in the storage e
89100
- Each CID is only replicated once per provider
90101
- Allocations are distributed fairly across all active providers
91102

92-
## Requirements
93-
94-
- [Foundry](https://book.getfoundry.sh/getting-started/installation)
95-
- [Solidity](https://docs.soliditylang.org/) version 0.8.25
96-
- Access to a Filecoin network (Devnet/Calibnet/Mainnet)
97-
- DataCap allocation for the contract account
98-
- Environment file (.env) with appropriate configuration
99-
100103
## Demo
101104

102105
You can view and try out the Round Robin Allocator on the Filecoin Calibration network using the Louper explorer.
106+
103107
Direct link for the deployed contract: [https://louper.dev/diamond/0x71B65138aceBe6c010C366586B58BB01D5D97f4E?network=filecoinCalibration](https://louper.dev/diamond/0x71B65138aceBe6c010C366586B58BB01D5D97f4E?network=filecoinCalibration)
104108

109+
Demo Staging Frontend: [https://round-robin.staging.allocator.tech](https://round-robin.staging.allocator.tech)
110+
111+
Video of the demo Frontend: [YouTube Video](https://youtu.be/czBpO_WaVXA)
112+
113+
114+
## Usage
115+
116+
### Flow overview:
117+
118+
1. **Prepare CAR files**
119+
2. **Prepare input data for allocation**: Prepare `CommCID` and `Data Size` for each file.
120+
3. **Call `allocate` contract function**
121+
4. **Provide files to storage providers**: SPs will store the data and claim their allocations.
122+
5. **Retrieve collateral**: After all claims are verified, call `retrieveCollateral` to get your collateral back.
123+
124+
125+
### Prepare CAR files
126+
127+
Use CAR file preparation tools (e.g. Singularity, lotus, etc.) to create CAR files from your data.
128+
129+
### Prepare input data for allocation
130+
131+
To transfer data cap, for each file, you need to prepare the following:
132+
- **CommCID**: The CommP content identifier for the data you want to allocate, in HEX format
133+
- Example: `0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef`
134+
- **Data Size**: The padded size of the data in bytes
135+
- Example: `2048`
136+
137+
To prepare HEX format of CommP, you can use the following docker image: `mmach/car-processor:0.1.0`
138+
139+
This image will require directory with your CAR files to be mounted as a volume.
140+
141+
Output will be created in form of CSV file in the same directory named `output.csv` with the following columns: `CommPCID_InHex,DataSizeInBytes` without header.
142+
143+
Example docker image usage:
144+
```bash
145+
docker run --rm -it -v $(pwd)/cars:/data mmach/car-processor:0.1.0
146+
```
147+
148+
### Prepare ETH wallet with sufficient balance
149+
150+
To interact with the Round Robin AutoAllocator contract, you need an Ethereum wallet with sufficient balance to cover gas fees and collateral. You can use tools like [MetaMask](https://metamask.io/) (frontend) or [Foundry](https://book.getfoundry.sh/getting-started/installation) (CLI) to manage your wallet.
151+
152+
### Getting current collateral value per CID
153+
154+
The Easiest way to get current collateral value per CID is to use contract Frontend app where this information is displayed.
155+
156+
Alternatively, you can use the Louper explorer app (or CLI) to invoke the `getAppConfig` function of the contract (in read tab, choose ViewFacet [here](https://louper.dev/diamond/0x71B65138aceBe6c010C366586B58BB01D5D97f4E?network=filecoinCalibration#read)). This function returns current contract config including the collateral value per CID.
157+
158+
### Create Allocation Package (Transfer Data Cap for multiple files)
159+
160+
To create allocation package and transfer Data Cap, you can either:
161+
- Upload the CSV directly in the frontend demo application (refer to the video in demo section)
162+
- Use the CSV content and invoke `allocate` function through command line e.g. using [Foundry](https://book.getfoundry.sh/getting-started/installation) `cast` command to interact with the contract
163+
164+
#### Example of using the Frontend app
165+
166+
1. Open the [Round Robin Allocator Frontend](https://round-robin.staging.allocator.tech).
167+
2. Connect your Ethereum wallet (e.g. MetaMask).
168+
3. Upload CSV file with your prepared data.
169+
4. Specify the number of replicas you want to allocate.
170+
5. Click "Allocate" to send the transaction to the contract.
171+
172+
173+
#### Example of using the CSV file with `cast` command
174+
175+
1. Format CSV content into the required format for the `allocate` function.
176+
- params: ***replicaAmount, [(CommPCIDinHex, DataPaddedSize)]***
177+
2. Prepare private key and RPC URL in your environment variables or directly in the command.
178+
3. Calculate collateral value based on the number of CIDs and replicas.
179+
3. Use the following command to send the allocation request:
180+
181+
```bash
182+
cast send --json --value 0.1ether --gas-limit 9000000000 --private-key $(PRIVATE_KEY) --rpc-url $(RPC_URL) $(DIAMOND_CONTRACT_ADDRESS) 'allocate(uint256,(bytes,uint64)[])' 1 '[(0x0181e203922020ab68b07850bae544b4e720ff59fdc7de709a8b5a8e83d6b7ab3ac2fa83e8461b, 2048)]'
183+
```
184+
185+
### Monitoring Allocation Packages
186+
187+
The Easiest way to monitor your allocation packages is through the Frontend app, where you can connect your wallet and view your allocations.
188+
189+
Alternatively, you can use the Louper explorer to check your allocation packages by invoking the `getClientPackagesWithClaimStatus` function (in read tab, choose ViewFacet [here](https://louper.dev/diamond/0x71B65138aceBe6c010C366586B58BB01D5D97f4E?network=filecoinCalibration#read)). This function will return all allocation packages associated with your wallet address, along with their claim status.
190+
191+
### Retrieving Collateral
192+
193+
Collateral can be retrieved after all storage providers have successfully claimed their allocations.
194+
195+
You can view the status of your allocation packages and their claims using the Louper explorer or the Frontend app.
196+
197+
The Frontend app will let you call `retrieveCollateral` function directly when conditions are met.
198+
199+
In the Louper explorer, you can invoke the `retrieveCollateral` function (in write tab, choose RetrieveCollateralFacet [here](https://louper.dev/diamond/0x71B65138aceBe6c010C366586B58BB01D5D97f4E?network=filecoinCalibration#write)) to retrieve your collateral.
200+
105201
## Deployment
106202

203+
### Requirements
204+
205+
- [Foundry](https://book.getfoundry.sh/getting-started/installation)
206+
- [Solidity](https://docs.soliditylang.org/) version 0.8.25
207+
- Access to a Filecoin network (Devnet/Calibnet/Mainnet)
208+
- DataCap allocation for the contract account
209+
- Environment file (.env) with appropriate configuration
210+
107211
### Environment Setup
108212

109213
Copy the `.env.example` file to `.env` and fill in the required values:
Binary file not shown.

0 commit comments

Comments
 (0)