Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Publish storage deals #599

Merged
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ subxt = { version = "0.38.0" }
subxt-signer = "0.38.0"
syn = { version = "2.0.53" }
tempfile = "3.10.1"
thiserror = { version = "2.0.3" }
thiserror = { version = "2.0.3", default-features = false }
tokio = "1.37.0"
tokio-stream = "0.1.15"
tokio-util = "0.7.11"
Expand Down
Binary file modified cli/artifacts/metadata.scale
Binary file not shown.
2 changes: 1 addition & 1 deletion cli/polka-storage/storagext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ serde_json = { workspace = true }
sha2 = { workspace = true }
subxt = { workspace = true, features = ["jsonrpsee", "substrate-compat"] }
subxt-signer = { workspace = true, features = ["subxt"] }
thiserror = { workspace = true }
thiserror = { workspace = true, default-features = true }
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }
Expand Down
2 changes: 1 addition & 1 deletion cli/polka-storage/storagext/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub mod display;
derive = "::serde::Serialize"
),
derive_for_type(
path = "pallet_market::pallet::DealSettlementError",
path = "pallet_market::error::DealSettlementError",
derive = "::serde::Serialize"
),
derive_for_type(
Expand Down
18 changes: 17 additions & 1 deletion docs/src/architecture/pallets/market.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ The Market Pallet actions can fail with following errors:
- `InsufficientFreeFunds` - Market participants do not have enough free funds.
- `NoProposalsToBePublished` - `publish_storage_deals` was called with an empty list of `deals`.
- `ProposalsPublishedByIncorrectStorageProvider` - Is returned when calling `publish_storage_deals` and the deals in a list are not published by the same storage provider.
- `AllProposalsInvalid` - `publish_storage_deals` call was supplied with a list of `deals` which are all invalid.
- `DuplicateDeal` - There is more than one deal with this ID in the Sector.
- `DealNotFound` - Tried to activate a deal that is not in the system.
- `DealActivationError` - Tried to activate a deal, but data was malformed.
Expand All @@ -222,6 +221,23 @@ The Market Pallet actions can fail with following errors:
- Deal is not pending.
- `DealsTooLargeToFitIntoSector` - Sum of all deals piece sizes for a sector exceeds sector size. The sector size is based on the registered proof type. We currently only support registered `StackedDRG2KiBV1P1` proofs, which have 2KiB sector sizes.
- `TooManyDealsPerBlock` - Tried to activate too many deals at a given `start_block`.
- `StorageProviderNotRegistered` - An account tries to call `publish_storage_deals` but is not registered as a storage provider.
- `CommD` - An error occurred when trying to calculate CommD.
- `TooManyPendingDeals` - A storage provider tried to propose a deal, but there are too many pending deals. The pending deals should be activated or wait for expiry.
- `InvalidProvider` - A deal was tried to be activated by a provider which does not own it.
- `StartBlockElapsed` - A storage provider tries to activate a deal after the start block.
- `SectorExpiresBeforeDeal` - Sector containing the deal will expire before the deal is supposed to end.
- `InvalidDealState` - A deal was attempted to be activated twice.
- `DealNotPending` - A storage provider tried to activate a deal which is not in the pending proposals.
- `WrongClientSignatureOnProposal` - The client signature did not match the client's public key and data.
- `DealEndBeforeStart` - A deal was attempted to be published but the end block is before the start block and the deal is rejected.
- `DealStartExpired` - A deal was attempted to be published but the start block is in the past and the deal is rejected.
- `DealNotPublished` - A deal was attempted to be published but is not in the correct state.
- `DealDurationOutOfBounds` - A deal was attempted to be published but the duration is not between [MinDealDuration](#constants) and [MaxDealDuration](#constants).
- `InvalidPieceCid` - The deal trying to be published has an invalid piece Cid.
- `DealIsNotActive` - When a sector is being terminated but the deal state is not active. This is the result of a programmer bug. Please [report an issue](https://github.com/eigerco/polka-storage-book/issues/new) to the developers.
- `InvalidCaller` - A deal was found that does not belong to the storage provider. This is the result of a programmer bug. Please [report an issue](https://github.com/eigerco/polka-storage-book/issues/new) to the developers.
- `DealNotFound` - A deal was attempted to be fetched but could not be found. This is the result of a programmer bug. Please [report an issue](https://github.com/eigerco/polka-storage-book/issues/new) to the developers.
- `UnexpectedValidationError` - `publish_storage_deals`'s core logic was invoked with a broken invariant that should be called by `validate_deals`. Please [report an issue](https://github.com/eigerco/polka-storage-book/issues/new) to the developers.
- `DealPreconditionFailed` - Due to a programmer bug. Please [report an issue](https://github.com/eigerco/polka-storage-book/issues/new) to the developers.

Expand Down
1 change: 1 addition & 0 deletions pallets/market/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ multihash-codetable = { workspace = true, features = ["blake2b"] }
primitives-commitment = { workspace = true }
primitives-proofs = { workspace = true, default-features = false }
scale-info = { workspace = true, default-features = false, features = ["derive"] }
thiserror = { workspace = true, default-features = false }

# frame deps
frame-benchmarking = { workspace = true, default-features = false, optional = true }
Expand Down
31 changes: 31 additions & 0 deletions pallets/market/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use codec::{Decode, Encode};
use scale_info::TypeInfo;

// Clone and PartialEq required because of the BoundedVec<(DealId, DealSettlementError)>
#[derive(TypeInfo, Encode, Decode, Clone, PartialEq, thiserror::Error)]
pub enum DealSettlementError {
/// The deal is going to be slashed.
#[error("DealSettlementError: Slashed Deal")]
SlashedDeal,
/// The deal last update is in the future — i.e. `last_update_block > current_block`.
#[error("DealSettlementError: Future Last Update")]
FutureLastUpdate,
/// The deal was not found.
#[error("DealSettlementError: Deal Not Found")]
DealNotFound,
/// The deal is too early to settle.
#[error("DealSettlementError: Early Settlement")]
EarlySettlement,
/// The deal has expired
#[error("DealSettlementError: Expired Deal")]
ExpiredDeal,
/// Deal is not activated
#[error("DealSettlementError: Deal Not Active")]
DealNotActive,
}

impl core::fmt::Debug for DealSettlementError {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
core::fmt::Display::fmt(self, f)
}
}
Loading
Loading