Skip to content

Commit

Permalink
feat(pallet-storage-provider): extract ProveCommitSector
Browse files Browse the repository at this point in the history
  • Loading branch information
jmg-duarte committed Jan 24, 2025
1 parent 04f3c82 commit 352d1c7
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 20 deletions.
4 changes: 2 additions & 2 deletions pallets/storage-provider/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub mod pallet {
},
proofs::{derive_prover_id, PublicReplicaInfo, RegisteredPoStProof},
randomness::{draw_randomness, AuthorVrfHistory, DomainSeparationTag},
sector::{SectorNumber, SectorPreCommitInfo},
sector::{ProveCommitSector, SectorNumber, SectorPreCommitInfo},
PartitionNumber, MAX_PARTITIONS_PER_DEADLINE, MAX_SEAL_PROOF_BYTES, MAX_SECTORS,
MAX_SECTORS_PER_CALL,
};
Expand All @@ -75,7 +75,7 @@ pub mod pallet {
},
proofs::{assign_proving_period_offset, SubmitWindowedPoStParams},
sector::{
ProveCommitResult, ProveCommitSector, SectorOnChainInfo, SectorPreCommitOnChainInfo,
ProveCommitResult, SectorOnChainInfo, SectorPreCommitOnChainInfo,
TerminateSectorsParams, TerminationDeclaration,
},
sector_map::DeadlineSectorMap,
Expand Down
9 changes: 1 addition & 8 deletions pallets/storage-provider/src/sector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use primitives::{
pallets::SectorDeal,
proofs::RegisteredSealProof,
sector::{SectorNumber, SectorPreCommitInfo},
PartitionNumber, CID_SIZE_IN_BYTES, MAX_SEAL_PROOF_BYTES, MAX_TERMINATIONS_PER_CALL,
PartitionNumber, CID_SIZE_IN_BYTES, MAX_TERMINATIONS_PER_CALL,
};
use scale_info::TypeInfo;

Expand Down Expand Up @@ -89,13 +89,6 @@ where
}
}

/// Arguments passed into the `prove_commit_sector` extrinsic.
#[derive(Clone, RuntimeDebug, Decode, Encode, PartialEq, TypeInfo)]
pub struct ProveCommitSector {
pub sector_number: SectorNumber,
pub proof: BoundedVec<u8, ConstU32<MAX_SEAL_PROOF_BYTES>>,
}

/// Type that is emitted after a successful prove commit extrinsic.
#[derive(Clone, RuntimeDebug, Decode, Encode, PartialEq, TypeInfo)]
pub struct ProveCommitResult {
Expand Down
3 changes: 1 addition & 2 deletions pallets/storage-provider/src/tests/declare_faults.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use frame_support::{assert_err, assert_noop, assert_ok, pallet_prelude::*};
use primitives::sector::SectorNumber;
use primitives::sector::{ProveCommitSector, SectorNumber};
use rstest::rstest;
use sp_core::bounded_vec;
use sp_runtime::{traits::BlockNumberProvider, BoundedVec};
Expand All @@ -9,7 +9,6 @@ use crate::{
error::GeneralPalletError,
fault::{DeclareFaultsParams, FaultDeclaration},
pallet::{Error, Event, StorageProviders, DECLARATIONS_MAX},
sector::ProveCommitSector,
tests::{
account, events, new_test_ext, register_storage_provider, run_to_block, sector_set,
DealProposalBuilder, DeclareFaultsBuilder, Market, RuntimeEvent, RuntimeOrigin,
Expand Down
6 changes: 4 additions & 2 deletions pallets/storage-provider/src/tests/post_hook.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use frame_support::{assert_ok, pallet_prelude::Get};
use primitives::{sector::SectorNumber, DealId, MAX_SECTORS};
use primitives::{
sector::{ProveCommitSector, SectorNumber},
DealId, MAX_SECTORS,
};
use sp_core::bounded_vec;
use sp_runtime::{BoundedBTreeMap, BoundedBTreeSet};

use super::new_test_ext;
use crate::{
pallet::{Config, Event, StorageProviders},
sector::ProveCommitSector,
tests::{
account, events, publish_deals, register_storage_provider, run_to_block, sector_set,
RuntimeEvent, RuntimeOrigin, SectorPreCommitInfoBuilder, StorageProvider,
Expand Down
3 changes: 1 addition & 2 deletions pallets/storage-provider/src/tests/pre_commit_sector_hook.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use primitives::sector::SectorNumber;
use primitives::sector::{ProveCommitSector, SectorNumber};
use sp_core::bounded_vec;
use sp_runtime::{BoundedBTreeMap, BoundedBTreeSet};

use super::new_test_ext;
use crate::{
pallet::{Event, StorageProviders},
sector::ProveCommitSector,
tests::{
account, events, publish_deals, register_storage_provider, run_to_block, Market,
RuntimeEvent, RuntimeOrigin, SectorPreCommitInfoBuilder, StorageProvider, System, Test,
Expand Down
7 changes: 5 additions & 2 deletions pallets/storage-provider/src/tests/prove_commit_sectors.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
use frame_support::{assert_noop, assert_ok, pallet_prelude::*};
use frame_system::pallet_prelude::BlockNumberFor;
use primitives::{sector::SectorPreCommitInfo, MAX_SECTORS_PER_CALL};
use primitives::{
sector::{ProveCommitSector, SectorPreCommitInfo},
MAX_SECTORS_PER_CALL,
};
use sp_core::bounded_vec;

use super::{new_test_ext, MaxProveCommitDuration};
use crate::{
deadline::deadline_is_mutable,
error::GeneralPalletError,
pallet::{Error, Event, StorageProviders},
sector::{ProveCommitResult, ProveCommitSector},
sector::ProveCommitResult,
tests::{
account, events, publish_deals, register_storage_provider, run_to_block, Market,
RuntimeEvent, RuntimeOrigin, SectorPreCommitInfoBuilder, StorageProvider, System, Test,
Expand Down
3 changes: 1 addition & 2 deletions pallets/storage-provider/src/tests/submit_windowed_post.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use frame_support::{assert_noop, assert_ok};
use primitives::{testing::INVALID_PROOF, PartitionNumber};
use primitives::{sector::ProveCommitSector, testing::INVALID_PROOF, PartitionNumber};
use rstest::rstest;
use sp_core::bounded_vec;
use sp_runtime::{BoundedVec, DispatchError};

use crate::{
error::GeneralPalletError,
pallet::{Error, Event, StorageProviders},
sector::ProveCommitSector,
tests::{
account, declare_faults::setup_sp_with_many_sectors_multiple_partitions, events,
new_test_ext, register_storage_provider, run_to_block, DealProposalBuilder, Market,
Expand Down
2 changes: 2 additions & 0 deletions primitives/src/sector/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
mod number;
mod pre_commit;
mod prove_commit;
mod size;

// NOTE(@jmg-duarte,16/01/2025): unsure if the visitor should be exposed
pub use number::{SectorNumber, SectorNumberError};
pub use pre_commit::SectorPreCommitInfo;
pub use prove_commit::ProveCommitSector;
pub use size::SectorSize;

// `test` is only useful locally
Expand Down
13 changes: 13 additions & 0 deletions primitives/src/sector/prove_commit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_core::{ConstU32, RuntimeDebug};
use sp_runtime::BoundedVec;

use crate::{sector::SectorNumber, MAX_SEAL_PROOF_BYTES};

/// Arguments passed into the `prove_commit_sector` extrinsic.
#[derive(Clone, RuntimeDebug, Decode, Encode, PartialEq, TypeInfo)]
pub struct ProveCommitSector {
pub sector_number: SectorNumber,
pub proof: BoundedVec<u8, ConstU32<MAX_SEAL_PROOF_BYTES>>,
}

0 comments on commit 352d1c7

Please sign in to comment.