Skip to content

Commit

Permalink
add docs and UI
Browse files Browse the repository at this point in the history
  • Loading branch information
LexLuthr committed Feb 27, 2025
1 parent 4944501 commit a89984b
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 13 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 70 additions & 1 deletion documentation/en/curio-market/deal-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: How to setup and use storage deal filters

## Overview

Curio provides a flexible filtering system to manage storage deals effectively. The filters allow you to:
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:

* Set pricing rules based on deal duration, size, and whether the data is verified.
* Define client-specific rules, including rate limits and acceptable wallets or peers.
Expand Down Expand Up @@ -172,3 +172,72 @@ DenyUnknownClients bool
* Verify the order and specificity of your filters.
* Check the Allow/Deny List for conflicting entries.
* Review client filters to ensure they are active and correctly configured.

# CIDGravity Filter

## What is CIDGravity?

[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.

For more details, refer to the [CIDGravity documentation](https://docs.cidgravity.com/).

## How to Enable CIDGravity in Curio

CIDGravity integration in Curio is controlled through Curio configuration. To enable CIDGravity, you need to set the below parameters in the configuration.
We highly recommend setting these values in "market" layer or a layer used by all market nodes to control the market behaviour.

```toml
# CIDGravityToken is the authorization token to use for CIDGravity filters.
# If empty then CIDGravity filters are not called.
#
# type: string
#CIDGravityToken = ""

# DefaultCIDGravityAccept when set to true till accept deals when CIDGravity service is not available.
# Default behaviors is to reject the deals
#
# type: bool
#DefaultCIDGravityAccept = false
```

### Configuration Options:

#### 1. `CIDGravityToken`
- **Description**: This is the authorization token required to use CIDGravity filters.
- **Default Behavior**: If left empty, CIDGravity filters will not be applied.
- **Type**: `string`

**Example Configuration:**
```toml
CIDGravityToken = "your-auth-token-here"
```

{% hint style="info" %}
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.
{% endhint %}

#### 2. `DefaultCIDGravityAccept`
- **Description**: Defines the default behavior when the CIDGravity service is unavailable.
- **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.
- **Type**: `bool`

**Example Configuration:**
```toml
DefaultCIDGravityAccept = false
```

### Steps to Enable CIDGravity in Curio:
1. Obtain a **CIDGravityToken** from the [CIDGravity platform](https://app.cidgravity.com/).
2. Add the token to the Curio configuration file under `CIDGravityToken`.
3. Set `DefaultCIDGravityAccept` based on your preference:
- `true` to accept deals when CIDGravity is unreachable.
- `false` to reject deals when CIDGravity is unreachable.
<figure><img src="../.gitbook/assets/cid_gravity_disabled.png" alt=""><figcaption><p>CID Gravity Disabled</p></figcaption></figure>
4. Restart Curio for the changes to take effect.
5. Verify that CIDGravity is enabled via UI Market Settings page.

<figure><img src="../.gitbook/assets/cid_gravity_enabled.png" alt=""><figcaption><p>CID Gravity Enabled</p></figcaption></figure>

Once enabled, Curio will automatically interact with CIDGravity to apply deal filtering and pricing rules according to the policies set in your CIDGravity account.


3 changes: 2 additions & 1 deletion web/api/webrpc/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/google/uuid"
"github.com/ipfs/go-cid"
"github.com/samber/lo"
"github.com/snadrus/must"
"github.com/yugabyte/pgx/v5"
"golang.org/x/xerrors"
Expand Down Expand Up @@ -477,7 +478,7 @@ func (a *WebRPC) MarketBalance(ctx context.Context) ([]MarketBalanceStatus, erro
return nil, err
}

for _, m := range miners {
for _, m := range lo.Uniq(miners) {
balance, err := a.deps.Chain.StateMarketBalance(ctx, m, types.EmptyTSK)
if err != nil {
return nil, err
Expand Down
17 changes: 14 additions & 3 deletions web/api/webrpc/market_filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,18 @@ func (a *WebRPC) RemoveAllowFilter(ctx context.Context, wallet string) error {
return nil
}

func (a *WebRPC) DefaultAllowBehaviour(ctx context.Context) (bool, error) {
ret := !a.deps.Cfg.Market.StorageMarketConfig.MK12.DenyUnknownClients
return ret, nil
type DefaultFilterBehaviourResponse struct {
AllowDealsFromUnknownClients bool `json:"allow_deals_from_unknown_clients"`
IsCidGravityEnabled bool `json:"is_cid_gravity_enabled"`
IsDealRejectedWhenCidGravityNotReachable bool `json:"is_deal_rejected_when_cid_gravity_not_reachable"`
}

func (a *WebRPC) DefaultFilterBehaviour(ctx context.Context) (*DefaultFilterBehaviourResponse, error) {

return &DefaultFilterBehaviourResponse{
AllowDealsFromUnknownClients: !a.deps.Cfg.Market.StorageMarketConfig.MK12.DenyUnknownClients,
IsCidGravityEnabled: a.deps.Cfg.Market.StorageMarketConfig.MK12.CIDGravityToken != "",
IsDealRejectedWhenCidGravityNotReachable: !a.deps.Cfg.Market.StorageMarketConfig.MK12.DefaultCIDGravityAccept,
}, nil

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LitElement, html, css } from 'https://cdn.jsdelivr.net/gh/lit/dist@3/all/lit-all.min.js';
import RPCCall from '/lib/jsonrpc.mjs';

class DefaultAllow extends LitElement {
class DefaultMarketFilters extends LitElement {
static properties = {
data: { type: Boolean },
};
Expand All @@ -15,7 +15,7 @@ class DefaultAllow extends LitElement {
async loadData() {
try {
// Load default allow behavior using the correct RPC method name
this.data = await RPCCall('DefaultAllowBehaviour', []);
this.data = await RPCCall('DefaultFilterBehaviour', []);
} catch (error) {
console.error('Failed to load default allow behavior:', error);
}
Expand All @@ -27,9 +27,17 @@ class DefaultAllow extends LitElement {
}
return html`
<div>
<h4 class=${this.data ? 'text-success' : 'text-danger'}>
<h4 class=${this.data.allow_deals_from_unknown_clients ? 'text-success' : 'text-danger'}>
Deals from unknown clients are
${this.data ? 'Allowed' : 'Denied'}
${this.data.allow_deals_from_unknown_clients ? 'Allowed' : 'Denied'}
</h4>
<h4 class=${this.data.is_cid_gravity_enabled ? 'text-success' : 'text-danger'}>
CID Gravity is
${this.data.is_cid_gravity_enabled ? 'Enabled' : 'Disabled'}
</h4>
<h4 class=${this.data.is_deal_rejected_when_cid_gravity_not_reachable ? 'text-danger' : 'text-success'}>
When CID Gravity is not reachable, deals are
${this.data.is_deal_rejected_when_cid_gravity_not_reachable ? 'Accepted' : 'Rejected'}
</h4>
</div>
`;
Expand All @@ -46,4 +54,4 @@ class DefaultAllow extends LitElement {
`;
}

customElements.define('default-allow', DefaultAllow);
customElements.define('default-market-filters', DefaultMarketFilters);
4 changes: 2 additions & 2 deletions web/static/pages/market-settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script type="module" src="allow-list.mjs"></script>
<script type="module" src="client-filters.mjs"></script>
<script type="module" src="pricing-filters.mjs"></script>
<script type="module" src="default-allow.mjs"></script>
<script type="module" src="defaults.mjs"></script>
</head>
<body style="visibility:hidden; background:rgb(11, 22, 34)" data-bs-theme="dark">
<curio-ux>
Expand All @@ -17,7 +17,7 @@ <h1>Market Setting</h1>
</div>
<div class="row">
<div class="col-md-auto" style="max-width: 95%">
<default-allow></default-allow>
<default-market-filters></default-market-filters>
</div>
</div>
</section>
Expand Down
2 changes: 1 addition & 1 deletion web/static/pages/market/market-asks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class MarketAsks extends LitElement {
VerifiedPrice: existingAsk.VerifiedPrice || '',
MinSize: existingAsk.MinSize || 4 * 1024 ** 3, // Default to 4 GiB
MaxSize: existingAsk.MaxSize || 32 * 1024 ** 3, // Default to 32 GiB
PriceFIL: '1',
PriceFIL: '0',
VerifiedPriceFIL: '0',
CreatedAt: '',
Expiry: '',
Expand Down

0 comments on commit a89984b

Please sign in to comment.