Skip to content

Commit 7b4faea

Browse files
authored
Revert "Backport Proof of Space perf improvements from abundance"
1 parent 6cfeeea commit 7b4faea

File tree

25 files changed

+959
-2419
lines changed

25 files changed

+959
-2419
lines changed

Cargo.lock

Lines changed: 13 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ members = [
2323
]
2424

2525
[workspace.dependencies]
26-
ab-chacha8 = { version = "0.1.0", path = "shared/ab-chacha8" }
2726
actix-web = { version = "4.9.0", default-features = false }
2827
aes = "0.9.0-pre.2"
2928
anyhow = "1.0.89"
@@ -112,7 +111,6 @@ mmr-gadget = { git = "https://github.com/subspace/polkadot-sdk", rev = "e8311328
112111
mmr-rpc = { git = "https://github.com/subspace/polkadot-sdk", rev = "e831132867930ca90a7088c7246301ab29f015ba" }
113112
multihash = "0.19.1"
114113
nohash-hasher = "0.2.0"
115-
no-panic = "0.1.35"
116114
num-traits = { version = "0.2.18", default-features = false }
117115
num_cpus = "1.16.0"
118116
num_enum = { version = "0.5.3", default-features = false }

crates/pallet-subspace/src/extensions/benchmarking.rs

Lines changed: 7 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@ use parity_scale_codec::{Decode, Encode};
1313
use scale_info::prelude::fmt;
1414
use sp_consensus_slots::Slot;
1515
use sp_consensus_subspace::SignedVote;
16-
use sp_runtime::Weight;
1716
use sp_runtime::traits::{AsSystemOriginSigner, Dispatchable, NumberFor};
18-
use sp_runtime::transaction_validity::{
19-
InvalidTransaction, TransactionSource, TransactionValidityError, UnknownTransaction,
20-
ValidTransaction,
21-
};
17+
use sp_runtime::transaction_validity::TransactionSource;
2218
use sp_std::collections::btree_map::BTreeMap;
2319
use subspace_core_primitives::pieces::PieceOffset;
2420
use subspace_core_primitives::sectors::SectorIndex;
@@ -86,14 +82,11 @@ mod benchmarks {
8682
(Option<T::AccountId>, RewardSignature),
8783
>::default());
8884

89-
let result;
9085
#[block]
9186
{
92-
result =
93-
SubspaceExtension::<T>::do_check_vote(&signed_vote, TransactionSource::InBlock);
94-
};
95-
96-
handle_error(result);
87+
SubspaceExtension::<T>::do_check_vote(&signed_vote, TransactionSource::InBlock)
88+
.unwrap();
89+
}
9790
}
9891

9992
#[benchmark]
@@ -139,15 +132,11 @@ mod benchmarks {
139132
*signed_vote.vote.slot(),
140133
Some(reward_address),
141134
));
142-
143-
let result;
144135
#[block]
145136
{
146-
result =
147-
SubspaceExtension::<T>::do_check_vote(&signed_vote, TransactionSource::InBlock);
148-
};
149-
150-
handle_error(result);
137+
SubspaceExtension::<T>::do_check_vote(&signed_vote, TransactionSource::InBlock)
138+
.unwrap();
139+
}
151140
}
152141

153142
impl_benchmark_test_suite!(
@@ -156,65 +145,3 @@ mod benchmarks {
156145
crate::mock::Test
157146
);
158147
}
159-
160-
fn handle_error(result: Result<(ValidTransaction, Weight), TransactionValidityError>) {
161-
// This exhaustive match is required because the production runtime does not generate debug impls.
162-
if let Err(e) = result {
163-
match e {
164-
TransactionValidityError::Invalid(e) => match e {
165-
InvalidTransaction::Call => {
166-
log::error!("Invalid transaction: Call");
167-
}
168-
InvalidTransaction::Payment => {
169-
log::error!("Invalid transaction: Payment");
170-
panic!("Invalid transaction: Payment");
171-
}
172-
InvalidTransaction::Future => {
173-
log::error!("Invalid transaction: Future");
174-
}
175-
InvalidTransaction::Stale => {
176-
log::error!("Invalid transaction: Stale");
177-
}
178-
InvalidTransaction::BadProof => {
179-
log::error!("Invalid transaction: BadProof");
180-
}
181-
InvalidTransaction::AncientBirthBlock => {
182-
log::error!("Invalid transaction: AncientBirthBlock");
183-
}
184-
InvalidTransaction::ExhaustsResources => {
185-
log::error!("Invalid transaction: ExhaustsResources");
186-
}
187-
InvalidTransaction::Custom(e) => {
188-
log::error!("Invalid transaction: Custom({})", e);
189-
}
190-
InvalidTransaction::BadMandatory => {
191-
log::error!("Invalid transaction: BadMandatory");
192-
}
193-
InvalidTransaction::MandatoryValidation => {
194-
log::error!("Invalid transaction: MandatoryValidation");
195-
}
196-
InvalidTransaction::BadSigner => {
197-
log::error!("Invalid transaction: BadSigner");
198-
}
199-
InvalidTransaction::IndeterminateImplicit => {
200-
log::error!("Invalid transaction: IndeterminateImplicit");
201-
}
202-
InvalidTransaction::UnknownOrigin => {
203-
log::error!("Invalid transaction: UnknownOrigin");
204-
}
205-
},
206-
TransactionValidityError::Unknown(e) => match e {
207-
UnknownTransaction::CannotLookup => {
208-
log::error!("Unknown transaction: CannotLookup");
209-
}
210-
UnknownTransaction::NoUnsignedValidator => {
211-
log::error!("Unknown transaction: NoUnsignedValidator");
212-
}
213-
UnknownTransaction::Custom(e) => {
214-
log::error!("Unknown transaction: Custom({})", e);
215-
}
216-
},
217-
}
218-
panic!("Error: {e:?}");
219-
}
220-
}

crates/sp-consensus-subspace/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ std = [
5858
"sp-weights/std",
5959
"subspace-core-primitives/std",
6060
"subspace-kzg/std",
61-
"subspace-proof-of-space/alloc",
61+
"subspace-proof-of-space/std",
6262
"subspace-verification/kzg",
6363
"subspace-verification/std",
6464
"thiserror/std",

crates/subspace-core-primitives/src/solutions.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Solutions-related data structures and functions.
22
33
use crate::pieces::{PieceOffset, Record, RecordCommitment, RecordWitness};
4-
use crate::pos::{PosProof, PosSeed};
4+
use crate::pos::PosProof;
55
use crate::sectors::SectorIndex;
66
use crate::segments::{HistorySize, SegmentIndex};
77
use crate::{PublicKey, ScalarBytes};
@@ -227,12 +227,6 @@ impl ChunkWitness {
227227
pub const SIZE: usize = 48;
228228
}
229229

230-
/// Proof-of-time verifier trait, used in abundance backports.
231-
pub trait SolutionPotVerifier {
232-
/// Check whether proof created earlier is valid
233-
fn is_proof_valid(seed: &PosSeed, challenge_index: u32, proof: &PosProof) -> bool;
234-
}
235-
236230
/// Farmer solution for slot challenge.
237231
#[derive(Clone, Debug, Eq, PartialEq, Encode, Decode, TypeInfo)]
238232
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]

crates/subspace-proof-of-space/Cargo.toml

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,52 @@ version = "0.1.0"
66
authors = ["Nazar Mokrynskyi <[email protected]>"]
77
edition.workspace = true
88
include = [
9+
"/benches",
910
"/src",
1011
"/Cargo.toml",
1112
]
1213

13-
[package.metadata.docs.rs]
14-
all-features = true
15-
1614
[lib]
1715
# Necessary for CLI options to work on benches
1816
bench = false
1917

2018
[dependencies]
21-
ab-chacha8.workspace = true
2219
blake3 = { workspace = true, default-features = false }
23-
chacha20 = { workspace = true, optional = true }
20+
chacha20.workspace = true
2421
derive_more = { workspace = true, features = ["full"] }
22+
parking_lot = { workspace = true, optional = true }
2523
rayon = { workspace = true, optional = true }
26-
seq-macro = { workspace = true, optional = true }
27-
sha2 = { workspace = true, optional = true }
24+
seq-macro.workspace = true
25+
sha2.workspace = true
26+
spin.workspace = true
2827
subspace-core-primitives.workspace = true
2928

3029
[dev-dependencies]
31-
chacha20.workspace = true
30+
bitvec.workspace = true
3231
criterion.workspace = true
33-
hex.workspace = true
3432
rayon.workspace = true
35-
seq-macro.workspace = true
36-
sha2.workspace = true
3733

3834
[[bench]]
3935
name = "pos"
4036
harness = false
4137

4238
[features]
43-
default = []
44-
alloc = [
45-
"dep:chacha20",
46-
"dep:seq-macro",
47-
]
48-
# Enabling this feature exposes quality search on `chiapos` module as well as enables support for K=15..=25 (by default
49-
# only K=20 is exposed)
50-
full-chiapos = [
51-
"dep:sha2",
39+
default = ["std"]
40+
std = [
41+
# TODO: `std` will not be necessary once 1.8.3+ is released with https://github.com/BLAKE3-team/BLAKE3/pull/469
42+
"blake3/std",
43+
"chacha20/std",
44+
"derive_more/std",
45+
# In no-std environment we use `spin`
46+
"parking_lot",
47+
"sha2/std",
48+
"subspace-core-primitives/std",
5249
]
5350
parallel = [
54-
"alloc",
5551
"dep:rayon",
5652
]
53+
54+
# The std and no_std features are mutually exclusive, so when checking for unused dependencies,
55+
# ignore the `spin` dependency, which is only used in no_std.
56+
[package.metadata.cargo-udeps.ignore]
57+
normal = ["spin"]

0 commit comments

Comments
 (0)