Skip to content

Commit 395bc47

Browse files
authored
feat: CID gravity connector (#407)
* CID gravity connector * reorder internal filters * fix headers * add failure count * updated sealing states * struct to map for sealing states * sealing states to nested map * more error messages * fix error logging * send 0 when no storage * fix pipelineStats * fix state queries * fix http request creation * add request debugging log * add docs and UI
1 parent 43a3c22 commit 395bc47

File tree

15 files changed

+762
-72
lines changed

15 files changed

+762
-72
lines changed

cmd/curio/tasks/tasks.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,10 @@ func StartTasks(ctx context.Context, dependencies *deps.Deps, shutdownChan chan
218218

219219
{
220220
// Market tasks
221-
sc, err := slrLazy.Val()
222-
if err != nil {
223-
return nil, err
224-
}
225-
226221
if cfg.Subsystems.EnableDealMarket {
227222
// Main market poller should run on all nodes
228-
dm := storage_market.NewCurioStorageDealMarket(miners, db, cfg, sc, full)
229-
err = dm.StartMarket(ctx)
223+
dm := storage_market.NewCurioStorageDealMarket(miners, db, cfg, si, full, as)
224+
err := dm.StartMarket(ctx)
230225
if err != nil {
231226
return nil, err
232227
}
@@ -249,6 +244,11 @@ func StartTasks(ctx context.Context, dependencies *deps.Deps, shutdownChan chan
249244
go libp2p.NewDealProvider(ctx, db, cfg, dm.MK12Handler, full, sender, miners, machine, shutdownChan)
250245
}
251246

247+
sc, err := slrLazy.Val()
248+
if err != nil {
249+
return nil, err
250+
}
251+
252252
idxMax := taskhelp.Max(cfg.Subsystems.IndexingMaxTasks)
253253

254254
indexingTask := indexing.NewIndexingTask(db, sc, iStore, pp, cfg, idxMax)

deps/config/doc_gen.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps/config/types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,14 @@ type MK12Config struct {
693693

694694
// DenyOfflineDeals determines if the storage provider will accept offline deals
695695
DenyOfflineDeals bool
696+
697+
// CIDGravityToken is the authorization token to use for CIDGravity filters.
698+
// If empty then CIDGravity filters are not called.
699+
CIDGravityToken string
700+
701+
// DefaultCIDGravityAccept when set to true till accept deals when CIDGravity service is not available.
702+
// Default behaviors is to reject the deals
703+
DefaultCIDGravityAccept bool
696704
}
697705

698706
type PieceLocatorConfig struct {
Loading
Loading

documentation/en/configuration/default-curio-configuration.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,18 @@ description: The default curio configuration
482482
# type: bool
483483
#DenyOfflineDeals = false
484484

485+
# CIDGravityToken is the authorization token to use for CIDGravity filters.
486+
# If empty then CIDGravity filters are not called.
487+
#
488+
# type: string
489+
#CIDGravityToken = ""
490+
491+
# DefaultCIDGravityAccept when set to true till accept deals when CIDGravity service is not available.
492+
# Default behaviors is to reject the deals
493+
#
494+
# type: bool
495+
#DefaultCIDGravityAccept = false
496+
485497
[Market.StorageMarketConfig.IPNI]
486498
# Disable set whether to disable indexing announcement to the network and expose endpoints that
487499
# allow indexer nodes to process announcements. Default: False

documentation/en/curio-market/deal-filters.md

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: How to setup and use storage deal filters
66

77
## Overview
88

9-
Curio provides a flexible filtering system to manage storage deals effectively. The filters allow you to:
9+
Curio provides a flexible filtering system to manage storage deals effectively. User have an option to choose from external filter like [CIDGravity](#cidgravity-filter) and built-in filters. The built-in filters allow you to:
1010

1111
* Set pricing rules based on deal duration, size, and whether the data is verified.
1212
* Define client-specific rules, including rate limits and acceptable wallets or peers.
@@ -172,3 +172,72 @@ DenyUnknownClients bool
172172
* Verify the order and specificity of your filters.
173173
* Check the Allow/Deny List for conflicting entries.
174174
* Review client filters to ensure they are active and correctly configured.
175+
176+
# CIDGravity Filter
177+
178+
## What is CIDGravity?
179+
180+
[CIDGravity](https://www.cidgravity.com/) is a powerful pricing and client management tool designed for Filecoin storage providers. It enables storage providers to efficiently filter storage and retrieval deals through a user-friendly interface. With CIDGravity, providers can set rules and policies for accepting or rejecting deals based on their business preferences, ensuring better control over their storage operations.
181+
182+
For more details, refer to the [CIDGravity documentation](https://docs.cidgravity.com/).
183+
184+
## How to Enable CIDGravity in Curio
185+
186+
CIDGravity integration in Curio is controlled through Curio configuration. To enable CIDGravity, you need to set the below parameters in the configuration.
187+
We highly recommend setting these values in "market" layer or a layer used by all market nodes to control the market behaviour.
188+
189+
```toml
190+
# CIDGravityToken is the authorization token to use for CIDGravity filters.
191+
# If empty then CIDGravity filters are not called.
192+
#
193+
# type: string
194+
#CIDGravityToken = ""
195+
196+
# DefaultCIDGravityAccept when set to true till accept deals when CIDGravity service is not available.
197+
# Default behaviors is to reject the deals
198+
#
199+
# type: bool
200+
#DefaultCIDGravityAccept = false
201+
```
202+
203+
### Configuration Options:
204+
205+
#### 1. `CIDGravityToken`
206+
- **Description**: This is the authorization token required to use CIDGravity filters.
207+
- **Default Behavior**: If left empty, CIDGravity filters will not be applied.
208+
- **Type**: `string`
209+
210+
**Example Configuration:**
211+
```toml
212+
CIDGravityToken = "your-auth-token-here"
213+
```
214+
215+
{% hint style="info" %}
216+
To generate a CIDGravity token [claim your miner](https://docs.cidgravity.com/storage-providers/get-started/claim-a-miner/) in CIDGravity. If you already have an existing miner then you can use the same token.
217+
{% endhint %}
218+
219+
#### 2. `DefaultCIDGravityAccept`
220+
- **Description**: Defines the default behavior when the CIDGravity service is unavailable.
221+
- **Default Behavior**: If set to `false`, deals will be rejected when CIDGravity is not reachable. If set to `true`, deals will be accepted even if CIDGravity is not available.
222+
- **Type**: `bool`
223+
224+
**Example Configuration:**
225+
```toml
226+
DefaultCIDGravityAccept = false
227+
```
228+
229+
### Steps to Enable CIDGravity in Curio:
230+
1. Obtain a **CIDGravityToken** from the [CIDGravity platform](https://app.cidgravity.com/).
231+
2. Add the token to the Curio configuration file under `CIDGravityToken`.
232+
3. Set `DefaultCIDGravityAccept` based on your preference:
233+
- `true` to accept deals when CIDGravity is unreachable.
234+
- `false` to reject deals when CIDGravity is unreachable.
235+
<figure><img src="../.gitbook/assets/cid_gravity_disabled.png" alt=""><figcaption><p>CID Gravity Disabled</p></figcaption></figure>
236+
4. Restart Curio for the changes to take effect.
237+
5. Verify that CIDGravity is enabled via UI Market Settings page.
238+
239+
<figure><img src="../.gitbook/assets/cid_gravity_enabled.png" alt=""><figcaption><p>CID Gravity Enabled</p></figcaption></figure>
240+
241+
Once enabled, Curio will automatically interact with CIDGravity to apply deal filtering and pricing rules according to the policies set in your CIDGravity account.
242+
243+

0 commit comments

Comments
 (0)