Skip to content

Commit

Permalink
Merge branch 'main' into launch-test-spec
Browse files Browse the repository at this point in the history
  • Loading branch information
dariolina committed Oct 4, 2024
2 parents a878c00 + 4efd8d6 commit 94775b3
Show file tree
Hide file tree
Showing 117 changed files with 1,440 additions and 1,352 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/rustdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ jobs:
RUSTDOCFLAGS: "-Z unstable-options --enable-index-page"

- name: Deploy Docs
uses: JamesIves/github-pages-deploy-action@65b5dfd4f5bcd3a7403bbc2959c144256167464e # v4.5.0
uses: JamesIves/github-pages-deploy-action@881db5376404c5c8d621010bcbec0310b58d5e29 # v4.6.8
with:
branch: gh-pages
single-commit: true
folder: target/doc
41 changes: 32 additions & 9 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion crates/pallet-subspace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ rand = { version = "0.8.5", features = ["min_const_gen"] }
sp-io = { git = "https://github.com/subspace/polkadot-sdk", rev = "5871818e1d736f1843eb9078f886290695165c42" }
subspace-archiving = { version = "0.1.0", path = "../subspace-archiving" }
subspace-core-primitives = { version = "0.1.0", path = "../subspace-core-primitives" }
subspace-farmer-components = { version = "0.1.0", path = "../subspace-farmer-components" }
subspace-erasure-coding = { version = "0.1.0", path = "../subspace-erasure-coding" }
subspace-farmer-components = { version = "0.1.0", path = "../subspace-farmer-components" }
subspace-kzg = { version = "0.1.0", path = "../../shared/subspace-kzg" }
subspace-proof-of-space = { version = "0.1.0", path = "../subspace-proof-of-space" }

[features]
Expand Down
6 changes: 3 additions & 3 deletions crates/pallet-subspace/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ mod benchmarks {
use sp_consensus_subspace::{SignedVote, Vote};
use sp_std::boxed::Box;
use sp_std::num::NonZeroU32;
use subspace_core_primitives::hashes::Blake3Hash;
use subspace_core_primitives::pot::{PotCheckpoints, PotOutput};
use subspace_core_primitives::segments::{
ArchivedBlockProgress, LastArchivedBlock, SegmentHeader, SegmentIndex,
};
use subspace_core_primitives::{
Blake3Hash, PublicKey, RewardSignature, Solution, SolutionRange,
};
use subspace_core_primitives::solutions::{RewardSignature, Solution, SolutionRange};
use subspace_core_primitives::PublicKey;

const SEED: u32 = 0;

Expand Down
23 changes: 11 additions & 12 deletions crates/pallet-subspace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ use sp_runtime::transaction_validity::{
};
use sp_std::collections::btree_map::BTreeMap;
use sp_std::prelude::*;
use subspace_core_primitives::crypto::Scalar;
use subspace_core_primitives::pieces::PieceOffset;
use subspace_core_primitives::sectors::{SectorId, SectorIndex};
use subspace_core_primitives::segments::{
ArchivedHistorySegment, HistorySize, SegmentHeader, SegmentIndex,
};
use subspace_core_primitives::solutions::{RewardSignature, SolutionRange};
use subspace_core_primitives::{
BlockHash, PublicKey, RewardSignature, SlotNumber, SolutionRange, REWARD_SIGNING_CONTEXT,
BlockHash, PublicKey, ScalarBytes, SlotNumber, REWARD_SIGNING_CONTEXT,
};
use subspace_verification::{
check_reward_signature, derive_next_solution_range, derive_pot_entropy, PieceCheckParams,
Expand Down Expand Up @@ -112,14 +112,13 @@ pub mod pallet {
use sp_std::collections::btree_map::BTreeMap;
use sp_std::num::NonZeroU32;
use sp_std::prelude::*;
use subspace_core_primitives::crypto::Scalar;
use subspace_core_primitives::hashes::Blake3Hash;
use subspace_core_primitives::pieces::PieceOffset;
use subspace_core_primitives::pot::PotCheckpoints;
use subspace_core_primitives::sectors::SectorIndex;
use subspace_core_primitives::segments::{HistorySize, SegmentHeader, SegmentIndex};
use subspace_core_primitives::{
Blake3Hash, PublicKey, Randomness, RewardSignature, SolutionRange,
};
use subspace_core_primitives::solutions::{RewardSignature, SolutionRange};
use subspace_core_primitives::{PublicKey, Randomness, ScalarBytes};

pub(super) struct InitialSolutionRanges<T: Config> {
_config: T,
Expand Down Expand Up @@ -437,7 +436,7 @@ pub mod pallet {
/// Parent block author information.
#[pallet::storage]
pub(super) type ParentBlockAuthorInfo<T> =
StorageValue<_, (PublicKey, SectorIndex, PieceOffset, Scalar, Slot)>;
StorageValue<_, (PublicKey, SectorIndex, PieceOffset, ScalarBytes, Slot)>;

/// Enable rewards since specified block number.
#[pallet::storage]
Expand All @@ -455,7 +454,7 @@ pub mod pallet {
PublicKey,
SectorIndex,
PieceOffset,
Scalar,
ScalarBytes,
Slot,
Option<T::AccountId>,
),
Expand All @@ -466,7 +465,7 @@ pub mod pallet {
pub(super) type ParentBlockVoters<T: Config> = StorageValue<
_,
BTreeMap<
(PublicKey, SectorIndex, PieceOffset, Scalar, Slot),
(PublicKey, SectorIndex, PieceOffset, ScalarBytes, Slot),
(Option<T::AccountId>, RewardSignature),
>,
ValueQuery,
Expand All @@ -477,7 +476,7 @@ pub mod pallet {
pub(super) type CurrentBlockVoters<T: Config> = StorageValue<
_,
BTreeMap<
(PublicKey, SectorIndex, PieceOffset, Scalar, Slot),
(PublicKey, SectorIndex, PieceOffset, ScalarBytes, Slot),
(Option<T::AccountId>, RewardSignature),
>,
>;
Expand Down Expand Up @@ -846,7 +845,7 @@ impl<T: Config> Pallet<T> {
}
}
CurrentBlockVoters::<T>::put(BTreeMap::<
(PublicKey, SectorIndex, PieceOffset, Scalar, Slot),
(PublicKey, SectorIndex, PieceOffset, ScalarBytes, Slot),
(Option<T::AccountId>, RewardSignature),
>::default());

Expand Down Expand Up @@ -920,7 +919,7 @@ impl<T: Config> Pallet<T> {

if (block_number % pot_entropy_injection_interval).is_zero() {
let current_block_entropy = derive_pot_entropy(
pre_digest.solution().chunk,
&pre_digest.solution().chunk,
pre_digest.pot_info().proof_of_time(),
);
// Collect entropy every `T::PotEntropyInjectionInterval` blocks
Expand Down
16 changes: 7 additions & 9 deletions crates/pallet-subspace/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use std::simd::Simd;
use std::sync::{Once, OnceLock};
use std::{iter, slice};
use subspace_archiving::archiver::{Archiver, NewArchivedSegment};
use subspace_core_primitives::crypto::kzg::{embedded_kzg_settings, Kzg};
use subspace_core_primitives::hashes::Blake3Hash;
use subspace_core_primitives::pieces::{Piece, PieceOffset, Record};
use subspace_core_primitives::pos::PosSeed;
use subspace_core_primitives::pot::PotOutput;
Expand All @@ -44,15 +44,14 @@ use subspace_core_primitives::segments::{
ArchivedBlockProgress, ArchivedHistorySegment, HistorySize, LastArchivedBlock,
RecordedHistorySegment, SegmentCommitment, SegmentHeader, SegmentIndex,
};
use subspace_core_primitives::{
Blake3Hash, BlockNumber, PublicKey, RewardSignature, SlotNumber, Solution, SolutionRange,
REWARD_SIGNING_CONTEXT,
};
use subspace_core_primitives::solutions::{RewardSignature, Solution, SolutionRange};
use subspace_core_primitives::{BlockNumber, PublicKey, SlotNumber, REWARD_SIGNING_CONTEXT};
use subspace_erasure_coding::ErasureCoding;
use subspace_farmer_components::auditing::audit_sector_sync;
use subspace_farmer_components::plotting::{plot_sector, CpuRecordsEncoder, PlotSectorOptions};
use subspace_farmer_components::reading::ReadSectorRecordChunksMode;
use subspace_farmer_components::FarmerProtocolInfo;
use subspace_kzg::Kzg;
use subspace_proof_of_space::shim::ShimTable;
use subspace_proof_of_space::{Table, TableGenerator};
use subspace_verification::is_within_solution_range;
Expand All @@ -67,7 +66,7 @@ const MAX_PIECES_IN_SECTOR: u16 = 1;
fn kzg_instance() -> &'static Kzg {
static KZG: OnceLock<Kzg> = OnceLock::new();

KZG.get_or_init(|| Kzg::new(embedded_kzg_settings()))
KZG.get_or_init(Kzg::new)
}

fn erasure_coding_instance() -> &'static ErasureCoding {
Expand Down Expand Up @@ -388,9 +387,8 @@ pub fn create_signed_vote(
solution.sector_index,
);
let sector_slot_challenge = sector_id.derive_sector_slot_challenge(&global_challenge);
let masked_chunk = (Simd::from(solution.chunk.to_bytes())
^ Simd::from(*solution.proof_of_space.hash()))
.to_array();
let masked_chunk =
(Simd::from(*solution.chunk) ^ Simd::from(*solution.proof_of_space.hash())).to_array();

// Check that solution quality is not too high
if is_within_solution_range(
Expand Down
8 changes: 4 additions & 4 deletions crates/pallet-subspace/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ use std::assert_matches::assert_matches;
use std::collections::BTreeMap;
use std::num::NonZeroU32;
use std::sync::{Arc, Mutex};
use subspace_core_primitives::crypto::Scalar;
use subspace_core_primitives::pieces::PieceOffset;
use subspace_core_primitives::pot::PotOutput;
use subspace_core_primitives::segments::SegmentIndex;
use subspace_core_primitives::{PublicKey, RewardSignature, SolutionRange};
use subspace_core_primitives::solutions::{RewardSignature, SolutionRange};
use subspace_core_primitives::{PublicKey, ScalarBytes};
use subspace_runtime_primitives::{FindBlockRewardAddress, FindVotingRewardAddresses};

#[test]
Expand Down Expand Up @@ -1277,7 +1277,7 @@ fn enabling_block_rewards_works() {
PublicKey::from(Keypair::generate().public.to_bytes()),
0,
PieceOffset::ZERO,
Scalar::default(),
ScalarBytes::default(),
Subspace::current_slot(),
Some(1),
));
Expand All @@ -1288,7 +1288,7 @@ fn enabling_block_rewards_works() {
PublicKey::from(Keypair::generate().public.to_bytes()),
0,
PieceOffset::ZERO,
Scalar::default(),
ScalarBytes::default(),
Subspace::current_slot(),
),
(Some(2), RewardSignature::from([0; 64])),
Expand Down
1 change: 1 addition & 0 deletions crates/sc-consensus-subspace-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ subspace-archiving = { version = "0.1.0", path = "../subspace-archiving" }
subspace-core-primitives = { version = "0.1.0", path = "../subspace-core-primitives" }
subspace-erasure-coding = { version = "0.1.0", path = "../subspace-erasure-coding" }
subspace-farmer-components = { version = "0.1.0", path = "../subspace-farmer-components" }
subspace-kzg = { version = "0.1.0", path = "../../shared/subspace-kzg" }
subspace-networking = { version = "0.1.0", path = "../subspace-networking" }
subspace-rpc-primitives = { version = "0.1.0", path = "../subspace-rpc-primitives" }
thiserror = "1.0.64"
Expand Down
6 changes: 4 additions & 2 deletions crates/sc-consensus-subspace-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::{Arc, Weak};
use std::time::Duration;
use subspace_archiving::archiver::NewArchivedSegment;
use subspace_core_primitives::crypto::kzg::Kzg;
use subspace_core_primitives::hashes::Blake3Hash;
use subspace_core_primitives::objects::GlobalObjectMapping;
use subspace_core_primitives::pieces::{Piece, PieceIndex};
use subspace_core_primitives::segments::{HistorySize, SegmentHeader, SegmentIndex};
use subspace_core_primitives::{Blake3Hash, BlockHash, PublicKey, SlotNumber, Solution};
use subspace_core_primitives::solutions::Solution;
use subspace_core_primitives::{BlockHash, PublicKey, SlotNumber};
use subspace_erasure_coding::ErasureCoding;
use subspace_farmer_components::FarmerProtocolInfo;
use subspace_kzg::Kzg;
use subspace_networking::libp2p::Multiaddr;
use subspace_rpc_primitives::{
FarmerAppInfo, RewardSignatureResponse, RewardSigningInfo, SlotInfo, SolutionResponse,
Expand Down
Loading

0 comments on commit 94775b3

Please sign in to comment.