Skip to content

Commit 9fd9b8c

Browse files
committed
Merge branch 'main' into staking_fuzzer
2 parents f861c60 + 4e0385e commit 9fd9b8c

File tree

28 files changed

+2422
-960
lines changed

28 files changed

+2422
-960
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ jobs:
197197
env:
198198
# Why `PROGRA~1` instead of `Program Files`? Because Windows!
199199
HIPCC: C:\PROGRA~1\AMD\ROCm\6.1\bin\hipcc.bin.exe
200+
HIP_PLATFORM: amd
200201
run: |
201202
cargo -Zgitoxide -Zgit clippy --locked --all-targets --features rocm -- -D warnings
202203
if: runner.os == 'Windows'

.github/workflows/snapshot-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ jobs:
253253
env:
254254
# Why `PROGRA~1` instead of `Program Files`? Because Windows!
255255
HIPCC: C:\PROGRA~1\AMD\ROCm\6.1\bin\hipcc.bin.exe
256+
HIP_PLATFORM: amd
256257
run: |
257258
cargo -Zgitoxide -Zgit build --locked -Z build-std --target ${{ matrix.build.target }} --profile production --bin subspace-farmer --features rocm
258259
move ${{ env.PRODUCTION_TARGET }}/subspace-farmer.exe ${{ env.PRODUCTION_TARGET }}/subspace-farmer-rocm.exe

Cargo.lock

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

Cargo.toml

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

2525
[workspace.dependencies]
26+
ab-chacha8 = { version = "0.1.0", path = "shared/ab-chacha8" }
2627
actix-web = { version = "4.9.0", default-features = false }
2728
aes = "0.9.0-pre.2"
2829
anyhow = "1.0.89"
@@ -111,6 +112,7 @@ mmr-gadget = { git = "https://github.com/subspace/polkadot-sdk", rev = "e8311328
111112
mmr-rpc = { git = "https://github.com/subspace/polkadot-sdk", rev = "e831132867930ca90a7088c7246301ab29f015ba" }
112113
multihash = "0.19.1"
113114
nohash-hasher = "0.2.0"
115+
no-panic = "0.1.35"
114116
num-traits = { version = "0.2.18", default-features = false }
115117
num_cpus = "1.16.0"
116118
num_enum = { version = "0.5.3", default-features = false }

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

Lines changed: 80 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ 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;
1617
use sp_runtime::traits::{AsSystemOriginSigner, Dispatchable, NumberFor};
17-
use sp_runtime::transaction_validity::TransactionSource;
18+
use sp_runtime::transaction_validity::{
19+
InvalidTransaction, TransactionSource, TransactionValidityError, UnknownTransaction,
20+
ValidTransaction,
21+
};
1822
use sp_std::collections::btree_map::BTreeMap;
1923
use subspace_core_primitives::pieces::PieceOffset;
2024
use subspace_core_primitives::sectors::SectorIndex;
@@ -82,11 +86,14 @@ mod benchmarks {
8286
(Option<T::AccountId>, RewardSignature),
8387
>::default());
8488

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

9299
#[benchmark]
@@ -132,11 +139,15 @@ mod benchmarks {
132139
*signed_vote.vote.slot(),
133140
Some(reward_address),
134141
));
142+
143+
let result;
135144
#[block]
136145
{
137-
SubspaceExtension::<T>::do_check_vote(&signed_vote, TransactionSource::InBlock)
138-
.unwrap();
139-
}
146+
result =
147+
SubspaceExtension::<T>::do_check_vote(&signed_vote, TransactionSource::InBlock);
148+
};
149+
150+
handle_error(result);
140151
}
141152

142153
impl_benchmark_test_suite!(
@@ -145,3 +156,65 @@ mod benchmarks {
145156
crate::mock::Test
146157
);
147158
}
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/std",
61+
"subspace-proof-of-space/alloc",
6262
"subspace-verification/kzg",
6363
"subspace-verification/std",
6464
"thiserror/std",

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

Lines changed: 7 additions & 1 deletion
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;
4+
use crate::pos::{PosProof, PosSeed};
55
use crate::sectors::SectorIndex;
66
use crate::segments::{HistorySize, SegmentIndex};
77
use crate::{PublicKey, ScalarBytes};
@@ -227,6 +227,12 @@ 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+
230236
/// Farmer solution for slot challenge.
231237
#[derive(Clone, Debug, Eq, PartialEq, Encode, Decode, TypeInfo)]
232238
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]

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

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

13+
[package.metadata.docs.rs]
14+
all-features = true
15+
1416
[lib]
1517
# Necessary for CLI options to work on benches
1618
bench = false
1719

1820
[dependencies]
21+
ab-chacha8.workspace = true
1922
blake3 = { workspace = true, default-features = false }
20-
chacha20.workspace = true
23+
chacha20 = { workspace = true, optional = true }
2124
derive_more = { workspace = true, features = ["full"] }
22-
parking_lot = { workspace = true, optional = true }
2325
rayon = { workspace = true, optional = true }
24-
seq-macro.workspace = true
25-
sha2.workspace = true
26-
spin.workspace = true
26+
seq-macro = { workspace = true, optional = true }
27+
sha2 = { workspace = true, optional = true }
2728
subspace-core-primitives.workspace = true
2829

2930
[dev-dependencies]
30-
bitvec.workspace = true
31+
chacha20.workspace = true
3132
criterion.workspace = true
33+
hex.workspace = true
3234
rayon.workspace = true
35+
seq-macro.workspace = true
36+
sha2.workspace = true
3337

3438
[[bench]]
3539
name = "pos"
3640
harness = false
3741

3842
[features]
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",
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",
4952
]
5053
parallel = [
54+
"alloc",
5155
"dep:rayon",
5256
]
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)