From 326213b667a98e379b3a25bbaa784d1e9c25fbb2 Mon Sep 17 00:00:00 2001 From: aidan46 Date: Tue, 26 Nov 2024 13:47:45 +0800 Subject: [PATCH] feat(sp): Add batch event for faulty partitions --- cli/artifacts/metadata.scale | Bin 163504 -> 163530 bytes .../src/runtime/display/storage_provider.rs | 18 +++++--- .../architecture/pallets/storage-provider.md | 5 +-- pallets/storage-provider/src/lib.rs | 40 ++++++++++-------- .../storage-provider/src/tests/post_hook.rs | 12 ++++-- .../src/tests/pre_commit_sector_hook.rs | 11 +++-- 6 files changed, 53 insertions(+), 33 deletions(-) diff --git a/cli/artifacts/metadata.scale b/cli/artifacts/metadata.scale index 39038327f429a42636881cc5f8cb06979df7cfeb..4e0ecf17cffa2b81032bc97ae60f3bf48035924f 100644 GIT binary patch delta 8764 zcmd5ie^gY})_0$K=NCc^!T_V7fPkQ)GyG6cNKh%MKv6L@iAK2UB)^;)5KK}kO6vJu zbfhCGDw!!?S?PRsvlp*?Wo1RhD!(Q5NXhVv^|Ios#OY*1BuX zx##R(XP>?IIeXuEdC2tskV#)IdmJ~n9Myj-PCQ5;c=39NTNWT#u8}J|%RtHzAk0%) ze2wg)%ia6H!M2vcJa3w3m2rj?slw$s zs*KVdV3w9cCJ`iIB@qPmhZGS3A3-vjal%0h8toRDNK0` z&9C3>=R{~C6QP{2d<8w)ItZadkNlpr6Si$L z_Dv6rp)WrAG#sS4+Y7B795O{X!keQ+zz6kaGYiM5vVA3-pn**jj3;nVM}$r~t7$cy z^zLl>8Q>Is;_-RV<^A;WUv<_~9Q!m8@ImafG@*+RqzT>hug$CB3|;tS963X1lwTPA zg<8^jh~N)l6_u`XM_CU6X_)}iDyw9dgWJl;P)xa_qSS$AP^ZBNJ@m|zOQ4s=(}<*A z0%?n?IDE!kvUA;f&n*H(x@5QPs*y`?Fe&uXO*9tzXd9gp(NAF6V%fF8>8^5kO4iRW zbGY3Z)yYX{6aB+dE`$M^voixO(Fb=cu1qCi>FeXli>ph;D9;gaEp`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KKs^U3eQ?HIk;--EdI;fArdwZ-tG+uDN5@Scf8 zIJ}wBFBvh7dq~cPXoNN1wM{065II40Rmmh;1CHh`AHa03e;;Bny^`=g2A&B#_kBzw z#A!48--j1)NQK(k4|idFr}Sg?CWZI+!>q&qZL*fSVi+B{>;a)%`Z`c z2w`GEB|LKg^KtE^alGQMFs-oW2E`mky|h!`t{%RwmUeVCXaco2uqFU+`X#~#S0{wW zc0E4J&V+E?Ct#shD3ACA=Eo#5({iIEd1d?+@m4hI*7?9 z9q%1PeKhg$pQ3y1;444H$fuh>@F_Zg9{vka^(yaw3QKg*ri6cv5ip!mc7B1`ABB1#Q(ydmW04xLn^&Wm5pD+T7YQfS0k`ef&}He{{{w-q8$7NUIu&{=Y9t>05TN! zRpcJBm1n=l2o>@>ZlPHq*`!@O@-v9wFIGO_o_)r`Q*vO-2(M!nlx3f@ui?Vb!)$7n4a;$VKUcv2FdI2!QQJqBZ#;P}o z-Y1>Xwe$J&=yBZnKhHz`cJeoq=?bY^*TX|n=z8c^%2Mc2DHPM;rwI({rjgiX9;c_& z<3eL3cy~sm(FGXCyTw+8^Brk)w|qr+RmZkoKVYhymu#SYxV=m7 zre|x4=pfXk-<)bB68J(lT+NT9Jz-+hd%=FC56b!S*4_q?gRZzbQrq)rih;Q>($2)`Ld*wb-GKuqL>D6 z?b9D#vaG~jv~6vLy=c9?%7wqs_Up~5>e#w!-^hU8Y*j~=+so`Ohig!utU;_SuX5W; z9qyVTeR8Y{fxl`N*@yLq`C+_m^qv2Cken^wSWr^=R9;V>q1y|5VLEk~)#=;x_+`v7bP!Z&ZHQ+d9Jt}*IlZ58)= zsB5%mQ|4^PQ)@ICoCb4q#Ih%dkhQWiZxH%L&Yuv(f3dY!zk H-a!5bcC+5& diff --git a/cli/polka-storage/storagext/src/runtime/display/storage_provider.rs b/cli/polka-storage/storagext/src/runtime/display/storage_provider.rs index 3b96f2f2c..42e7afb8c 100644 --- a/cli/polka-storage/storagext/src/runtime/display/storage_provider.rs +++ b/cli/polka-storage/storagext/src/runtime/display/storage_provider.rs @@ -115,16 +115,22 @@ impl std::fmt::Display for Event { ) .collect::() )), - Event::PartitionFaulty { + Event::PartitionsFaulty { owner, - partition, - sectors, + faulty_partitions, } => f.write_fmt(format_args!( - "Faulty Partition: {{ owner: {}, partition: {}, sectors: [{}] }}", + "Faulty Partitions: {{ owner: {}, faulty_partitions: [{}] }}", owner, - partition, itertools::Itertools::intersperse( - sectors.0.iter().map(|recovery| format!("{}", recovery)), + faulty_partitions.iter().map(|(partition, sectors)| format!( + "{{ partition: {}, sectors: {} }}", + partition, + itertools::Itertools::intersperse( + sectors.iter().map(|sector| format!("{}", sector)), + ", ".to_string() + ) + .collect::() + )), ", ".to_string() ) .collect::() diff --git a/docs/src/architecture/pallets/storage-provider.md b/docs/src/architecture/pallets/storage-provider.md index 0ee5971ff..b8fe02a5f 100644 --- a/docs/src/architecture/pallets/storage-provider.md +++ b/docs/src/architecture/pallets/storage-provider.md @@ -343,10 +343,9 @@ The Storage Provider Pallet emits the following events: - `deadline` - The deadline to which the recovered sectors are assigned. - `partition` - Partition number within the deadline containing the recovered sectors. - `sectors` - Sectors in the partition being declared as recovered. -- `PartitionFaulty` - It was detected that a storage provider has not submitted their PoSt on time and has marked some sectors as faulty. +- `PartitionsFaulty` - It was detected that a storage provider has not submitted their PoSt on time and has marked some partitions and sectors as faulty. - `owner` - SS58 address of the storage provider. - - `partition` - Partition number for which the PoSt was missed. - - `sectors` - The sectors in the partition declared faulty by the system. + - `faulty_partitions` - A map with partition numbers and the sectors associated with the partition number that are faulty. - `SectorsTerminated` - A storage provider has terminated some sectors. - `owner` - SS58 address of the storage provider. - `terminations` - An array with information about the terminated sectors. This information includes: diff --git a/pallets/storage-provider/src/lib.rs b/pallets/storage-provider/src/lib.rs index 3ba72c802..26c2dc0f1 100644 --- a/pallets/storage-provider/src/lib.rs +++ b/pallets/storage-provider/src/lib.rs @@ -35,7 +35,11 @@ pub mod pallet { extern crate alloc; - use alloc::{vec, vec::Vec}; + use alloc::{ + collections::{BTreeMap, BTreeSet}, + vec, + vec::Vec, + }; use core::fmt::Debug; use cid::Cid; @@ -293,10 +297,10 @@ pub mod pallet { recoveries: BoundedVec>, }, /// Emitted when an SP doesn't submit Windowed PoSt in time and PoSt hook marks partitions as faulty - PartitionFaulty { + PartitionsFaulty { owner: T::AccountId, - partition: PartitionNumber, - sectors: BoundedBTreeSet>, + // No need to be bounded as we are creating the sets ourselves + faulty_partitions: BTreeMap>, }, /// Emitted when an SP terminates some sectors. SectorsTerminated { @@ -1231,9 +1235,9 @@ pub mod pallet { } log::info!(target: LOG_TARGET, "block: {:?}, checking storage provider {:?} deadline: {:?}", - current_block, - storage_provider, - current_deadline.idx, + current_block, + storage_provider, + current_deadline.idx, ); let Ok(deadline) = @@ -1244,7 +1248,10 @@ pub mod pallet { continue; }; - let mut faulty_partitions = 0; + let mut faulty_partitions_amount = 0; + // Create collection for fault partitions, 1 event per SP + let mut faulty_partitions: BTreeMap> = + BTreeMap::new(); for (partition_number, partition) in deadline.partitions.iter_mut() { if partition.sectors.len() == 0 { continue; @@ -1278,24 +1285,23 @@ pub mod pallet { current_block, storage_provider, partition_number, new_faults.len()); if new_faults.len() > 0 { - Self::deposit_event(Event::PartitionFaulty { - owner: storage_provider.clone(), - partition: *partition_number, - sectors: new_faults.try_into() - .expect("new_faults.len() <= MAX_SECTORS, cannot be more new faults than all of the sectors in partition"), - }); - faulty_partitions += 1; + faulty_partitions.insert(*partition_number, new_faults); + faulty_partitions_amount += 1; } } // TODO(@th7nder,[#106,#187],08/08/2024): figure out slashing amounts (for continued faults, new faults). - if faulty_partitions > 0 { + if faulty_partitions_amount > 0 { log::warn!(target: LOG_TARGET, "block: {:?}, sp: {:?}, deadline: {:?} - should have slashed {} partitions...", current_block, storage_provider, current_deadline.idx, - faulty_partitions, + faulty_partitions_amount, ); + Self::deposit_event(Event::PartitionsFaulty { + owner: storage_provider.clone(), + faulty_partitions, + }) } else { log::info!(target: LOG_TARGET, "block: {:?}, sp: {:?}, deadline: {:?} - all proofs submitted on time.", current_block, diff --git a/pallets/storage-provider/src/tests/post_hook.rs b/pallets/storage-provider/src/tests/post_hook.rs index 1950979d3..aab3f8432 100644 --- a/pallets/storage-provider/src/tests/post_hook.rs +++ b/pallets/storage-provider/src/tests/post_hook.rs @@ -1,5 +1,7 @@ extern crate alloc; +use alloc::collections::{BTreeMap, BTreeSet}; + use frame_support::{assert_ok, pallet_prelude::Get}; use primitives_proofs::{DealId, SectorNumber}; use sp_core::bounded_vec; @@ -68,16 +70,18 @@ fn marks_partitions_as_faulty() { let partition = &deadline.partitions[&0]; let expected_sectors = sector_set::(&[first_sector_number, second_sector_number]); - + let faulty_sectors = BTreeSet::from([ + SectorNumber::new(first_sector_number).unwrap(), + SectorNumber::new(second_sector_number).unwrap(), + ]); assert_eq!(partition.faults.len(), 2); assert_eq!(expected_sectors, partition.faults); assert_eq!( events(), [RuntimeEvent::StorageProvider( - Event::::PartitionFaulty { + Event::::PartitionsFaulty { owner: account(storage_provider), - partition: 0, - sectors: expected_sectors.clone() + faulty_partitions: BTreeMap::from([(0u32, faulty_sectors)]), } ),] ); diff --git a/pallets/storage-provider/src/tests/pre_commit_sector_hook.rs b/pallets/storage-provider/src/tests/pre_commit_sector_hook.rs index 2bcc73cc9..85737c987 100644 --- a/pallets/storage-provider/src/tests/pre_commit_sector_hook.rs +++ b/pallets/storage-provider/src/tests/pre_commit_sector_hook.rs @@ -1,5 +1,8 @@ extern crate alloc; +use alloc::collections::{BTreeMap, BTreeSet}; + +use primitives_proofs::SectorNumber; use sp_core::bounded_vec; use super::new_test_ext; @@ -79,10 +82,12 @@ fn pre_commit_hook_slashed_deal() { assert_eq!( events(), [ - RuntimeEvent::StorageProvider(Event::::PartitionFaulty { + RuntimeEvent::StorageProvider(Event::::PartitionsFaulty { owner: account(storage_provider), - partition: 0, - sectors: sector_set(&[2]) + faulty_partitions: BTreeMap::from([( + 0, + BTreeSet::from([SectorNumber::new(2).unwrap()]) + )]), }), RuntimeEvent::StorageProvider(Event::::SectorSlashed { owner: account(storage_provider),