Skip to content

Commit 918288e

Browse files
authored
Merge branch 'main' into keep-reconstructor-state
2 parents ccb28cb + 5e15f59 commit 918288e

File tree

68 files changed

+1999
-1290
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1999
-1290
lines changed

Cargo.lock

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

crates/pallet-domains/src/bundle_storage_fund.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub fn refund_storage_fee<T: Config>(
136136
Ok(())
137137
}
138138

139-
/// Split the new deposit into 2 parts: the staking deposit and the the storage fee deposit,
139+
/// Split the new deposit into 2 parts: the staking deposit and the storage fee deposit,
140140
/// add the storage fee deposit to the bundle storage fund.
141141
pub fn deposit_reserve_for_storage_fund<T: Config>(
142142
operator_id: OperatorId,
Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,3 @@
1-
//! Migration module for pallet-domains
2-
//!
3-
//! TODO: remove this module after it has been deployed to Taurus.
1+
mod v1_to_v5;
42

5-
use crate::{Config, Pallet};
6-
use frame_support::migrations::VersionedMigration;
7-
use frame_support::traits::UncheckedOnRuntimeUpgrade;
8-
use frame_support::weights::Weight;
9-
10-
pub type VersionCheckedMigrateDomainsV4ToV5<T> = VersionedMigration<
11-
4,
12-
5,
13-
VersionUncheckedMigrateV4ToV5<T>,
14-
Pallet<T>,
15-
<T as frame_system::Config>::DbWeight,
16-
>;
17-
18-
pub struct VersionUncheckedMigrateV4ToV5<T>(sp_std::marker::PhantomData<T>);
19-
impl<T: Config> UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateV4ToV5<T> {
20-
fn on_runtime_upgrade() -> Weight {
21-
domain_genesis_receipt::set_domain_genesis_receipt::<T>()
22-
}
23-
}
24-
25-
mod domain_genesis_receipt {
26-
use super::Config;
27-
use crate::{DomainGenesisBlockExecutionReceipt, ExecutionReceiptOf};
28-
use hexlit::hex;
29-
use sp_core::{Get, H256};
30-
use sp_domains::DomainId;
31-
use sp_runtime::traits::{NumberFor, Zero};
32-
use sp_runtime::Weight;
33-
34-
pub(super) fn set_domain_genesis_receipt<T: Config>() -> Weight {
35-
let taurus_genesis_hash = T::Hash::from(H256::from(hex!(
36-
"0x295aeafca762a304d92ee1505548695091f6082d3f0aa4d092ac3cd6397a6c5e"
37-
)));
38-
let genesis_hash = frame_system::Pallet::<T>::block_hash(NumberFor::<T::Block>::zero());
39-
if genesis_hash != taurus_genesis_hash {
40-
return Weight::zero();
41-
}
42-
43-
let genesis_state_root = T::DomainHash::from(H256::from(hex!(
44-
"0x530eae1878202aa0ab5997eadf2b7245ee78f44a35ab25ff84151fab489aa334"
45-
)));
46-
47-
let genesis_block_hash = T::DomainHash::from(H256::from(hex!(
48-
"0x5a367ed131b9d8807f0166651095a9ed51aefa9aaec3152d3eb5cee322220ce6"
49-
)));
50-
51-
let domain_0_genesis_er = ExecutionReceiptOf::<T>::genesis(
52-
genesis_state_root,
53-
sp_domains::EMPTY_EXTRINSIC_ROOT.into(),
54-
genesis_block_hash,
55-
);
56-
57-
DomainGenesisBlockExecutionReceipt::<T>::insert(DomainId::new(0), domain_0_genesis_er);
58-
59-
T::DbWeight::get().reads_writes(0, 1)
60-
}
61-
}
3+
pub use v1_to_v5::VersionCheckedMigrateDomainsV1ToV5;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//! Migration module for pallet-domains
2+
3+
use crate::{Config, Pallet};
4+
use core::marker::PhantomData;
5+
use frame_support::migrations::VersionedMigration;
6+
use frame_support::traits::UncheckedOnRuntimeUpgrade;
7+
use frame_support::weights::Weight;
8+
9+
pub type VersionCheckedMigrateDomainsV1ToV5<T> = VersionedMigration<
10+
1,
11+
5,
12+
VersionUncheckedMigrateV1ToV5<T>,
13+
Pallet<T>,
14+
<T as frame_system::Config>::DbWeight,
15+
>;
16+
17+
pub struct VersionUncheckedMigrateV1ToV5<T>(PhantomData<T>);
18+
impl<T: Config> UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateV1ToV5<T> {
19+
fn on_runtime_upgrade() -> Weight {
20+
Weight::zero()
21+
}
22+
}

crates/pallet-domains/src/staking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ pub(crate) struct DepositInfo<Balance> {
404404
first_deposit_in_epoch: bool,
405405
}
406406

407-
/// Calculates shares for any pending deposit for previous epoch using the the epoch share price and
407+
/// Calculates shares for any pending deposit for previous epoch using the epoch share price and
408408
/// then create a new pending deposit in the current epoch.
409409
/// If there is a pending deposit for the current epoch, then simply increment the amount.
410410
/// Returns updated deposit info

crates/pallet-subspace/src/mock.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use sp_consensus_subspace::digests::{CompatibleDigestItem, PreDigest, PreDigestP
1111
use sp_consensus_subspace::{KzgExtension, PosExtension, PotExtension, SignedVote, Vote};
1212
use sp_io::TestExternalities;
1313
use sp_runtime::testing::{Digest, DigestItem, TestXt};
14-
use sp_runtime::traits::Block as BlockT;
1514
use sp_runtime::BuildStorage;
1615
use std::marker::PhantomData;
1716
use std::num::{NonZeroU32, NonZeroU64, NonZeroUsize};
@@ -38,7 +37,7 @@ use subspace_farmer_components::FarmerProtocolInfo;
3837
use subspace_kzg::Kzg;
3938
use subspace_proof_of_space::shim::ShimTable;
4039
use subspace_proof_of_space::{Table, TableGenerator};
41-
use subspace_runtime_primitives::ConsensusEventSegmentSize;
40+
use subspace_runtime_primitives::{BlockHashFor, ConsensusEventSegmentSize};
4241
use subspace_verification::is_within_solution_range;
4342

4443
type PosTable = ShimTable;
@@ -287,15 +286,15 @@ pub fn create_archived_segment() -> &'static NewArchivedSegment {
287286
pub fn create_signed_vote(
288287
keypair: &Keypair,
289288
height: u64,
290-
parent_hash: <Block as BlockT>::Hash,
289+
parent_hash: BlockHashFor<Block>,
291290
slot: Slot,
292291
proof_of_time: PotOutput,
293292
future_proof_of_time: PotOutput,
294293
archived_history_segment: &NewArchivedSegment,
295294
reward_address: <Test as frame_system::Config>::AccountId,
296295
solution_range: SolutionRange,
297296
vote_solution_range: SolutionRange,
298-
) -> SignedVote<u64, <Block as BlockT>::Hash, <Test as frame_system::Config>::AccountId> {
297+
) -> SignedVote<u64, BlockHashFor<Block>, <Test as frame_system::Config>::AccountId> {
299298
let kzg = kzg_instance();
300299
let erasure_coding = erasure_coding_instance();
301300
let reward_signing_context = schnorrkel::signing_context(REWARD_SIGNING_CONTEXT);
@@ -391,7 +390,7 @@ pub fn create_signed_vote(
391390
continue;
392391
}
393392

394-
let vote = Vote::<u64, <Block as BlockT>::Hash, _>::V0 {
393+
let vote = Vote::<u64, BlockHashFor<Block>, _>::V0 {
395394
height,
396395
parent_hash,
397396
slot,

crates/sc-consensus-subspace/src/block_import.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ where
297297
Client::Api: BlockBuilderApi<Block> + SubspaceApi<Block, PublicKey> + ApiExt<Block>,
298298
CIDP: CreateInherentDataProviders<Block, ()> + Send + Sync + 'static,
299299
AS: AuxStore + Send + Sync + 'static,
300-
BlockNumber: From<<Block::Header as HeaderT>::Number>,
300+
BlockNumber: From<NumberFor<Block>>,
301301
{
302302
/// Produce a Subspace block-import object to be used later on in the construction of an import-queue.
303303
pub fn new(
@@ -552,7 +552,7 @@ where
552552
Client::Api: BlockBuilderApi<Block> + SubspaceApi<Block, PublicKey> + ApiExt<Block>,
553553
CIDP: CreateInherentDataProviders<Block, ()> + Send + Sync + 'static,
554554
AS: AuxStore + Send + Sync + 'static,
555-
BlockNumber: From<<Block::Header as HeaderT>::Number>,
555+
BlockNumber: From<NumberFor<Block>>,
556556
{
557557
type Error = Error<Block::Header>;
558558

crates/sc-consensus-subspace/src/slot_worker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ where
313313
BS: BackoffAuthoringBlocksStrategy<NumberFor<Block>> + Send + Sync,
314314
Error: std::error::Error + Send + From<ConsensusError> + 'static,
315315
AS: AuxStore + Send + Sync + 'static,
316-
BlockNumber: From<<Block::Header as Header>::Number>,
316+
BlockNumber: From<NumberFor<Block>>,
317317
{
318318
type BlockImport = BoxBlockImport<Block>;
319319
type SyncOracle = SubspaceSyncOracle<SO>;
@@ -757,7 +757,7 @@ where
757757
BS: BackoffAuthoringBlocksStrategy<NumberFor<Block>> + Send + Sync,
758758
Error: std::error::Error + Send + From<ConsensusError> + 'static,
759759
AS: AuxStore + Send + Sync + 'static,
760-
BlockNumber: From<<Block::Header as Header>::Number>,
760+
BlockNumber: From<NumberFor<Block>>,
761761
{
762762
/// Create new Subspace slot worker
763763
pub fn new(

crates/sc-domains/src/domain_block_er/receipt_receiver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use std::time::Duration;
2222
use tokio::time::sleep;
2323
use tracing::{debug, error, trace};
2424

25-
const REQUEST_PAUSE: Duration = Duration::from_secs(5);
26-
const ATTEMPTS_NUMBER: u32 = 10;
25+
const REQUEST_PAUSE: Duration = Duration::from_secs(15);
26+
const ATTEMPTS_NUMBER: u32 = 20;
2727
const PEERS_THRESHOLD: usize = 20;
2828

2929
/// Last confirmed domain block info error.

crates/sc-subspace-block-relay/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ sc-transaction-pool-api.workspace = true
2727
sp-runtime = { workspace = true, features = ["std"] }
2828
strum_macros.workspace = true
2929
subspace-core-primitives = { workspace = true, features = ["std"] }
30+
subspace-runtime-primitives = { workspace = true, features = ["std"] }
3031
substrate-prometheus-endpoint.workspace = true
3132
thiserror.workspace = true
3233
tracing = { workspace = true, features = ["std"] }

crates/sc-subspace-block-relay/src/consensus/relay.rs

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! Consensus block relay implementation.
22
33
use crate::consensus::types::{
4-
BlockHash, ConsensusClientMetrics, ConsensusRequest, ConsensusServerMetrics, Extrinsic,
5-
FullDownloadRequest, FullDownloadResponse, InitialRequest, InitialResponse, PartialBlock,
6-
ProtocolInitialRequest, ProtocolInitialResponse, ProtocolMessage,
4+
ConsensusClientMetrics, ConsensusRequest, ConsensusServerMetrics, FullDownloadRequest,
5+
FullDownloadResponse, InitialRequest, InitialResponse, PartialBlock, ProtocolInitialRequest,
6+
ProtocolInitialResponse, ProtocolMessage,
77
};
88
use crate::protocol::compact_block::{
99
CompactBlockClient, CompactBlockHandshake, CompactBlockServer,
@@ -36,6 +36,7 @@ use std::num::{NonZeroU32, NonZeroUsize};
3636
use std::sync::Arc;
3737
use std::time::{Duration, Instant};
3838
use subspace_core_primitives::PublicKey;
39+
use subspace_runtime_primitives::{BlockHashFor, ExtrinsicFor};
3940
use substrate_prometheus_endpoint::{PrometheusError, Registry};
4041
use tracing::{debug, info, trace, warn};
4142

@@ -62,7 +63,7 @@ where
6263
{
6364
network: Arc<NetworkWrapper>,
6465
protocol_name: ProtocolName,
65-
compact_block: CompactBlockClient<BlockHash<Block>, TxHash<Pool>, Extrinsic<Block>>,
66+
compact_block: CompactBlockClient<BlockHashFor<Block>, TxHash<Pool>, ExtrinsicFor<Block>>,
6667
backend: Arc<ConsensusClientBackend<Pool>>,
6768
metrics: ConsensusClientMetrics,
6869
_phantom_data: std::marker::PhantomData<(Block, Pool)>,
@@ -90,7 +91,7 @@ where
9091
fn new(
9192
network: Arc<NetworkWrapper>,
9293
protocol_name: ProtocolName,
93-
compact_block: CompactBlockClient<BlockHash<Block>, TxHash<Pool>, Extrinsic<Block>>,
94+
compact_block: CompactBlockClient<BlockHashFor<Block>, TxHash<Pool>, ExtrinsicFor<Block>>,
9495
backend: Arc<ConsensusClientBackend<Pool>>,
9596
metrics: ConsensusClientMetrics,
9697
) -> Self {
@@ -195,9 +196,10 @@ where
195196
&self,
196197
protocol_response: ProtocolInitialResponse<Block, TxHash<Pool>>,
197198
network_peer_handle: &NetworkPeerHandle,
198-
) -> Result<(Vec<Extrinsic<Block>>, usize), RelayError>
199+
) -> Result<(Vec<ExtrinsicFor<Block>>, usize), RelayError>
199200
where
200-
Request: From<CompactBlockHandshake<BlockHash<Block>, TxHash<Pool>>> + Encode + Send + Sync,
201+
Request:
202+
From<CompactBlockHandshake<BlockHashFor<Block>, TxHash<Pool>>> + Encode + Send + Sync,
201203
{
202204
let ProtocolInitialResponse::CompactBlock(compact_response) = protocol_response;
203205
let (block_hash, resolved) = self
@@ -303,7 +305,7 @@ where
303305
/// The server side of the consensus block relay
304306
struct ConsensusRelayServer<Block: BlockT, Client, Pool: TransactionPool> {
305307
client: Arc<Client>,
306-
compact_block: CompactBlockServer<BlockHash<Block>, TxHash<Pool>, Extrinsic<Block>>,
308+
compact_block: CompactBlockServer<BlockHashFor<Block>, TxHash<Pool>, ExtrinsicFor<Block>>,
307309
request_receiver: async_channel::Receiver<IncomingRequest>,
308310
backend: Arc<ConsensusServerBackend<Client, Pool>>,
309311
metrics: ConsensusServerMetrics,
@@ -320,7 +322,7 @@ where
320322
/// Creates the consensus relay server.
321323
fn new(
322324
client: Arc<Client>,
323-
compact_block: CompactBlockServer<BlockHash<Block>, TxHash<Pool>, Extrinsic<Block>>,
325+
compact_block: CompactBlockServer<BlockHashFor<Block>, TxHash<Pool>, ExtrinsicFor<Block>>,
324326
request_receiver: async_channel::Receiver<IncomingRequest>,
325327
backend: Arc<ConsensusServerBackend<Client, Pool>>,
326328
metrics: ConsensusServerMetrics,
@@ -488,7 +490,7 @@ where
488490
/// Builds the partial block response
489491
fn get_partial_block(
490492
&self,
491-
block_hash: &BlockHash<Block>,
493+
block_hash: &BlockHashFor<Block>,
492494
block_attributes: BlockAttributes,
493495
) -> Result<PartialBlock<Block>, RelayError> {
494496
let block_header = match self.client.header(*block_hash) {
@@ -537,7 +539,7 @@ where
537539
}
538540

539541
/// Converts the BlockId to block hash
540-
fn block_hash(&self, block_id: &BlockId<Block>) -> Result<BlockHash<Block>, RelayError> {
542+
fn block_hash(&self, block_id: &BlockId<Block>) -> Result<BlockHashFor<Block>, RelayError> {
541543
match self.client.block_hash_from_id(block_id) {
542544
Ok(Some(hash)) => Ok(hash),
543545
Ok(None) => Err(RelayError::BlockHash(format!("Missing: {block_id:?}"))),
@@ -591,12 +593,12 @@ struct ConsensusClientBackend<Pool> {
591593
transaction_pool: Arc<Pool>,
592594
}
593595

594-
impl<Block, Pool> ClientBackend<TxHash<Pool>, Extrinsic<Block>> for ConsensusClientBackend<Pool>
596+
impl<Block, Pool> ClientBackend<TxHash<Pool>, ExtrinsicFor<Block>> for ConsensusClientBackend<Pool>
595597
where
596598
Block: BlockT,
597599
Pool: TransactionPool<Block = Block> + 'static,
598600
{
599-
fn protocol_unit(&self, tx_hash: &TxHash<Pool>) -> Option<Extrinsic<Block>> {
601+
fn protocol_unit(&self, tx_hash: &TxHash<Pool>) -> Option<ExtrinsicFor<Block>> {
600602
// Look up the transaction pool.
601603
self.transaction_pool
602604
.ready_transaction(tx_hash)
@@ -610,7 +612,7 @@ struct ConsensusServerBackend<Client, Pool> {
610612
transaction_pool: Arc<Pool>,
611613
}
612614

613-
impl<Block, Client, Pool> ServerBackend<BlockHash<Block>, TxHash<Pool>, Extrinsic<Block>>
615+
impl<Block, Client, Pool> ServerBackend<BlockHashFor<Block>, TxHash<Pool>, ExtrinsicFor<Block>>
614616
for ConsensusServerBackend<Client, Pool>
615617
where
616618
Block: BlockT,
@@ -620,8 +622,8 @@ where
620622
{
621623
fn download_unit_members(
622624
&self,
623-
block_hash: &BlockHash<Block>,
624-
) -> Result<Vec<ProtocolUnitInfo<TxHash<Pool>, Extrinsic<Block>>>, RelayError> {
625+
block_hash: &BlockHashFor<Block>,
626+
) -> Result<Vec<ProtocolUnitInfo<TxHash<Pool>, ExtrinsicFor<Block>>>, RelayError> {
625627
let txns = block_transactions(block_hash, self.client.as_ref())?;
626628
Ok(txns
627629
.into_iter()
@@ -642,9 +644,9 @@ where
642644

643645
fn protocol_unit(
644646
&self,
645-
block_hash: &BlockHash<Block>,
647+
block_hash: &BlockHashFor<Block>,
646648
tx_hash: &TxHash<Pool>,
647-
) -> Option<Extrinsic<Block>> {
649+
) -> Option<ExtrinsicFor<Block>> {
648650
// Look up the block extrinsics.
649651
match block_transactions(block_hash, self.client.as_ref()) {
650652
Ok(extrinsics) => {
@@ -674,9 +676,9 @@ where
674676

675677
/// Retrieves the block transactions/tx hash from the backend.
676678
fn block_transactions<Block, Client>(
677-
block_hash: &BlockHash<Block>,
679+
block_hash: &BlockHashFor<Block>,
678680
client: &Client,
679-
) -> Result<Vec<Extrinsic<Block>>, RelayError>
681+
) -> Result<Vec<ExtrinsicFor<Block>>, RelayError>
680682
where
681683
Block: BlockT,
682684
Client: HeaderBackend<Block> + BlockBackend<Block>,
@@ -702,7 +704,7 @@ pub fn build_consensus_relay<Block, Client, Pool>(
702704
pool: Arc<Pool>,
703705
registry: Option<&Registry>,
704706
) -> Result<
705-
BlockRelayParams<Block, NetworkWorker<Block, <Block as BlockT>::Hash>>,
707+
BlockRelayParams<Block, NetworkWorker<Block, BlockHashFor<Block>>>,
706708
BlockRelayConfigurationError,
707709
>
708710
where

0 commit comments

Comments
 (0)