Skip to content

Commit a89984b

Browse files
committed
add docs and UI
1 parent 4944501 commit a89984b

File tree

8 files changed

+102
-13
lines changed

8 files changed

+102
-13
lines changed
Loading
Loading

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+

web/api/webrpc/market.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/google/uuid"
1515
"github.com/ipfs/go-cid"
16+
"github.com/samber/lo"
1617
"github.com/snadrus/must"
1718
"github.com/yugabyte/pgx/v5"
1819
"golang.org/x/xerrors"
@@ -477,7 +478,7 @@ func (a *WebRPC) MarketBalance(ctx context.Context) ([]MarketBalanceStatus, erro
477478
return nil, err
478479
}
479480

480-
for _, m := range miners {
481+
for _, m := range lo.Uniq(miners) {
481482
balance, err := a.deps.Chain.StateMarketBalance(ctx, m, types.EmptyTSK)
482483
if err != nil {
483484
return nil, err

web/api/webrpc/market_filters.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,18 @@ func (a *WebRPC) RemoveAllowFilter(ctx context.Context, wallet string) error {
361361
return nil
362362
}
363363

364-
func (a *WebRPC) DefaultAllowBehaviour(ctx context.Context) (bool, error) {
365-
ret := !a.deps.Cfg.Market.StorageMarketConfig.MK12.DenyUnknownClients
366-
return ret, nil
364+
type DefaultFilterBehaviourResponse struct {
365+
AllowDealsFromUnknownClients bool `json:"allow_deals_from_unknown_clients"`
366+
IsCidGravityEnabled bool `json:"is_cid_gravity_enabled"`
367+
IsDealRejectedWhenCidGravityNotReachable bool `json:"is_deal_rejected_when_cid_gravity_not_reachable"`
368+
}
369+
370+
func (a *WebRPC) DefaultFilterBehaviour(ctx context.Context) (*DefaultFilterBehaviourResponse, error) {
371+
372+
return &DefaultFilterBehaviourResponse{
373+
AllowDealsFromUnknownClients: !a.deps.Cfg.Market.StorageMarketConfig.MK12.DenyUnknownClients,
374+
IsCidGravityEnabled: a.deps.Cfg.Market.StorageMarketConfig.MK12.CIDGravityToken != "",
375+
IsDealRejectedWhenCidGravityNotReachable: !a.deps.Cfg.Market.StorageMarketConfig.MK12.DefaultCIDGravityAccept,
376+
}, nil
377+
367378
}

web/static/pages/market-settings/default-allow.mjs renamed to web/static/pages/market-settings/defaults.mjs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { LitElement, html, css } from 'https://cdn.jsdelivr.net/gh/lit/dist@3/all/lit-all.min.js';
22
import RPCCall from '/lib/jsonrpc.mjs';
33

4-
class DefaultAllow extends LitElement {
4+
class DefaultMarketFilters extends LitElement {
55
static properties = {
66
data: { type: Boolean },
77
};
@@ -15,7 +15,7 @@ class DefaultAllow extends LitElement {
1515
async loadData() {
1616
try {
1717
// Load default allow behavior using the correct RPC method name
18-
this.data = await RPCCall('DefaultAllowBehaviour', []);
18+
this.data = await RPCCall('DefaultFilterBehaviour', []);
1919
} catch (error) {
2020
console.error('Failed to load default allow behavior:', error);
2121
}
@@ -27,9 +27,17 @@ class DefaultAllow extends LitElement {
2727
}
2828
return html`
2929
<div>
30-
<h4 class=${this.data ? 'text-success' : 'text-danger'}>
30+
<h4 class=${this.data.allow_deals_from_unknown_clients ? 'text-success' : 'text-danger'}>
3131
Deals from unknown clients are
32-
${this.data ? 'Allowed' : 'Denied'}
32+
${this.data.allow_deals_from_unknown_clients ? 'Allowed' : 'Denied'}
33+
</h4>
34+
<h4 class=${this.data.is_cid_gravity_enabled ? 'text-success' : 'text-danger'}>
35+
CID Gravity is
36+
${this.data.is_cid_gravity_enabled ? 'Enabled' : 'Disabled'}
37+
</h4>
38+
<h4 class=${this.data.is_deal_rejected_when_cid_gravity_not_reachable ? 'text-danger' : 'text-success'}>
39+
When CID Gravity is not reachable, deals are
40+
${this.data.is_deal_rejected_when_cid_gravity_not_reachable ? 'Accepted' : 'Rejected'}
3341
</h4>
3442
</div>
3543
`;
@@ -46,4 +54,4 @@ class DefaultAllow extends LitElement {
4654
`;
4755
}
4856

49-
customElements.define('default-allow', DefaultAllow);
57+
customElements.define('default-market-filters', DefaultMarketFilters);

web/static/pages/market-settings/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<script type="module" src="allow-list.mjs"></script>
77
<script type="module" src="client-filters.mjs"></script>
88
<script type="module" src="pricing-filters.mjs"></script>
9-
<script type="module" src="default-allow.mjs"></script>
9+
<script type="module" src="defaults.mjs"></script>
1010
</head>
1111
<body style="visibility:hidden; background:rgb(11, 22, 34)" data-bs-theme="dark">
1212
<curio-ux>
@@ -17,7 +17,7 @@ <h1>Market Setting</h1>
1717
</div>
1818
<div class="row">
1919
<div class="col-md-auto" style="max-width: 95%">
20-
<default-allow></default-allow>
20+
<default-market-filters></default-market-filters>
2121
</div>
2222
</div>
2323
</section>

web/static/pages/market/market-asks.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class MarketAsks extends LitElement {
8686
VerifiedPrice: existingAsk.VerifiedPrice || '',
8787
MinSize: existingAsk.MinSize || 4 * 1024 ** 3, // Default to 4 GiB
8888
MaxSize: existingAsk.MaxSize || 32 * 1024 ** 3, // Default to 32 GiB
89-
PriceFIL: '1',
89+
PriceFIL: '0',
9090
VerifiedPriceFIL: '0',
9191
CreatedAt: '',
9292
Expiry: '',

0 commit comments

Comments
 (0)