Skip to content

Commit

Permalink
Merge branch 'main' into disable-connected-peers
Browse files Browse the repository at this point in the history
  • Loading branch information
shamil-gadelshin authored Dec 11, 2023
2 parents fa2a669 + ed93719 commit e49138e
Show file tree
Hide file tree
Showing 32 changed files with 203 additions and 82 deletions.
6 changes: 3 additions & 3 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[target.'cfg(target_arch = "x64_64")']
[target.'cfg(target_arch = "x86_64")']
# Require AES-NI on x86-64 by default
rustflags = "-C target-feature=+aes"
rustflags = ["-C", "target-feature=+aes"]

[target.'cfg(target_arch = "aarch64")']
# TODO: Try to remove once https://github.com/paritytech/substrate/issues/11538 is resolved
# TODO: AES flag is such that we have decent performance on ARMv8, remove once `aes` crate bumps MSRV to at least
# 1.61: https://github.com/RustCrypto/block-ciphers/issues/373
rustflags = "--cfg aes_armv8"
rustflags = ["--cfg", "aes_armv8"]
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*
!/.cargo
!/crates
!/domains
!/orml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/snapshot-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || 'ubuntu-20.04') }}
target: x86_64-unknown-linux-gnu
suffix: ubuntu-x86_64-v2-${{ github.ref_name }}
rustflags: "-C target-cpu=x86-64-v2"
rustflags: "-C target-cpu=x86-64-v2 -C target-feature=+aes"
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || 'ubuntu-20.04') }}
target: aarch64-unknown-linux-gnu
suffix: ubuntu-aarch64-${{ github.ref_name }}
Expand All @@ -115,7 +115,7 @@ jobs:
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "windows-server-2022-x86-64"]' || 'windows-2022') }}
target: x86_64-pc-windows-msvc
suffix: windows-x86_64-v2-${{ github.ref_name }}
rustflags: "-C target-cpu=x86-64-v2"
rustflags: "-C target-cpu=x86-64-v2 -C target-feature=+aes"
runs-on: ${{ matrix.build.os }}
env:
PRODUCTION_TARGET: target/${{ matrix.build.target }}/production
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Dockerfile-bootstrap-node
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RUN \

RUN /root/.cargo/bin/rustup target add wasm32-unknown-unknown

COPY .cargo /code/.cargo
COPY Cargo.lock /code/Cargo.lock
COPY Cargo.toml /code/Cargo.toml
COPY rust-toolchain.toml /code/rust-toolchain.toml
Expand Down
1 change: 1 addition & 0 deletions Dockerfile-bootstrap-node.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RUN \

RUN /root/.cargo/bin/rustup target add wasm32-unknown-unknown

COPY .cargo /code/.cargo
COPY Cargo.lock /code/Cargo.lock
COPY Cargo.toml /code/Cargo.toml
COPY rust-toolchain.toml /code/rust-toolchain.toml
Expand Down
1 change: 1 addition & 0 deletions Dockerfile-farmer
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RUN \

RUN /root/.cargo/bin/rustup target add wasm32-unknown-unknown

COPY .cargo /code/.cargo
COPY Cargo.lock /code/Cargo.lock
COPY Cargo.toml /code/Cargo.toml
COPY rust-toolchain.toml /code/rust-toolchain.toml
Expand Down
1 change: 1 addition & 0 deletions Dockerfile-farmer.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RUN \

RUN /root/.cargo/bin/rustup target add wasm32-unknown-unknown

COPY .cargo /code/.cargo
COPY Cargo.lock /code/Cargo.lock
COPY Cargo.toml /code/Cargo.toml
COPY rust-toolchain.toml /code/rust-toolchain.toml
Expand Down
1 change: 1 addition & 0 deletions Dockerfile-node
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RUN \

RUN /root/.cargo/bin/rustup target add wasm32-unknown-unknown

COPY .cargo /code/.cargo
COPY Cargo.lock /code/Cargo.lock
COPY Cargo.toml /code/Cargo.toml
COPY rust-toolchain.toml /code/rust-toolchain.toml
Expand Down
1 change: 1 addition & 0 deletions Dockerfile-node.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RUN \

RUN /root/.cargo/bin/rustup target add wasm32-unknown-unknown

COPY .cargo /code/.cargo
COPY Cargo.lock /code/Cargo.lock
COPY Cargo.toml /code/Cargo.toml
COPY rust-toolchain.toml /code/rust-toolchain.toml
Expand Down
1 change: 1 addition & 0 deletions Dockerfile-runtime
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN \

RUN /root/.cargo/bin/rustup target add wasm32-unknown-unknown

COPY .cargo /code/.cargo
COPY Cargo.lock /code/Cargo.lock
COPY Cargo.toml /code/Cargo.toml
COPY rust-toolchain.toml /code/rust-toolchain.toml
Expand Down
8 changes: 6 additions & 2 deletions crates/sc-consensus-subspace-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ use sc_utils::mpsc::TracingUnboundedSender;
use sp_api::{ApiError, ProvideRuntimeApi};
use sp_blockchain::HeaderBackend;
use sp_consensus::SyncOracle;
use sp_consensus_subspace::{FarmerPublicKey, FarmerSignature, SubspaceApi as SubspaceRuntimeApi};
use sp_consensus_subspace::{
ChainConstants, FarmerPublicKey, FarmerSignature, SubspaceApi as SubspaceRuntimeApi,
};
use sp_core::crypto::ByteArray;
use sp_core::H256;
use sp_objects::ObjectsApi;
Expand Down Expand Up @@ -219,6 +221,7 @@ where
Arc<Mutex<ArchivedSegmentHeaderAcknowledgementSenders>>,
next_subscription_id: AtomicU64,
sync_oracle: SubspaceSyncOracle<SO>,
chain_constants: ChainConstants,
kzg: Kzg,
deny_unsafe: DenyUnsafe,
_block: PhantomData<Block>,
Expand Down Expand Up @@ -266,6 +269,7 @@ where
archived_segment_acknowledgement_senders: Arc::default(),
next_subscription_id: AtomicU64::default(),
sync_oracle: config.sync_oracle,
chain_constants,
kzg: config.kzg,
deny_unsafe: config.deny_unsafe,
_block: PhantomData,
Expand Down Expand Up @@ -303,7 +307,7 @@ where
})?;

let farmer_app_info: Result<FarmerAppInfo, ApiError> = try {
let chain_constants = runtime_api.chain_constants(best_hash)?;
let chain_constants = &self.chain_constants;
let protocol_info = FarmerProtocolInfo {
history_size: runtime_api.history_size(best_hash)?,
max_pieces_in_sector: runtime_api.max_pieces_in_sector(best_hash)?,
Expand Down
4 changes: 2 additions & 2 deletions crates/sc-subspace-chain-specs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ pub use utils::SerializableChainSpec;
use sc_chain_spec::NoExtension;

/// Devnet chain spec
pub const DEVNET_CHAIN_SPEC: &[u8] = include_bytes!("../res/chain-spec-raw-devnet.json");
pub const DEVNET_CHAIN_SPEC: &str = include_str!("../res/chain-spec-raw-devnet.json");
/// Gemini 3g chain spec
pub const GEMINI_3G_CHAIN_SPEC: &[u8] = include_bytes!("../res/chain-spec-raw-gemini-3g.json");
pub const GEMINI_3G_CHAIN_SPEC: &str = include_str!("../res/chain-spec-raw-gemini-3g.json");

/// Specialized `ChainSpec` for the consensus runtime.
pub type ConsensusChainSpec<GenesisConfig> = SerializableChainSpec<GenesisConfig>;
Expand Down
8 changes: 6 additions & 2 deletions crates/sp-domains-fraud-proof/src/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ where
.map(|resp| resp.into_domain_set_code_extrinsic())
.ok_or(VerificationError::FailedToDeriveDomainSetCodeExtrinsic)?;

let bad_receipt_valid_bundle_digests = bad_receipt.valid_bundle_digests();
if valid_bundle_digests.len() != bad_receipt_valid_bundle_digests.len() {
return Err(VerificationError::InvalidBundleDigest);
}

let mut bundle_extrinsics_digests = Vec::new();
for (bad_receipt_valid_bundle_digest, bundle_digest) in bad_receipt
.valid_bundle_digests()
for (bad_receipt_valid_bundle_digest, bundle_digest) in bad_receipt_valid_bundle_digests
.into_iter()
.zip(valid_bundle_digests)
{
Expand Down
2 changes: 1 addition & 1 deletion crates/subspace-farmer-components/src/plotting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ where
// happen at most as many times as there is number of chunks in the record,
// otherwise `n+1` iterations could happen and update extra `encoded_chunk_used`
// unnecessarily causing issues down the line
.take(record.iter().count())
.take(record.len())
.zip(record.iter_mut())
// Write encoded chunk back so we can reuse original allocation
.map(|(input_chunk, output_chunk)| {
Expand Down
5 changes: 2 additions & 3 deletions crates/subspace-farmer-components/src/sector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,7 @@ impl SectorContentsMap {
/// corresponds to the record to which chunk belongs and `encoded_chunk_used` indicates whether
/// it was encoded.
///
/// ## Panics
/// Panics if `s_bucket` is outside of [`Record::NUM_S_BUCKETS`] range.
/// Returns error if `s_bucket` is outside of [`Record::NUM_S_BUCKETS`] range.
pub fn iter_s_bucket_records(
&self,
s_bucket: SBucket,
Expand Down Expand Up @@ -577,7 +576,7 @@ fn record_has_s_bucket_chunk(
} else if num_encoded_record_chunks == Record::NUM_CHUNKS {
None
} else {
// Count how many encoded chunks we before current offset
// Count how many encoded chunks we have before current offset
let encoded_before = record_bitfields[..s_bucket].count_ones();
let unencoded_before = s_bucket - encoded_before;
// And how many unencoded we have total and how many before current offset
Expand Down
10 changes: 5 additions & 5 deletions crates/subspace-farmer/src/single_disk_farm/plotting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,14 @@ where
info!("Node is not synced yet, pausing plotting until sync status changes");

loop {
if node_sync_status.is_synced() {
info!("Node is synced, resuming plotting");
continue 'outer;
}

match node_sync_status_change_notifications.next().await {
Some(new_node_sync_status) => {
node_sync_status = new_node_sync_status;

if node_sync_status.is_synced() {
info!("Node is synced, resuming plotting");
continue 'outer;
}
}
None => {
// Subscription ended, nothing left to do
Expand Down
3 changes: 2 additions & 1 deletion crates/subspace-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ sc-cli = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-s
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" }
sc-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" }
sc-consensus-subspace = { version = "0.1.0", path = "../sc-consensus-subspace" }
sc-subspace-chain-specs = { version = "0.1.0", path = "../sc-subspace-chain-specs" }
sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" }
sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" }
sc-subspace-chain-specs = { version = "0.1.0", path = "../sc-subspace-chain-specs" }
sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false }
sc-storage-monitor = { version = "0.1.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false }
sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" }
Expand Down
2 changes: 2 additions & 0 deletions crates/subspace-node/src/bin/subspace-node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ fn main() -> Result<(), Error> {
ChainId::Consensus,
consensus_chain_node.client.clone(),
consensus_chain_node.transaction_pool.clone(),
consensus_chain_node.network_service.clone(),
consensus_msg_receiver,
);

Expand Down Expand Up @@ -667,6 +668,7 @@ fn main() -> Result<(), Error> {
consensus_offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(
consensus_chain_node.transaction_pool.clone(),
),
consensus_network: consensus_chain_node.network_service.clone(),
block_importing_notification_stream: consensus_chain_node
.block_importing_notification_stream
.clone(),
Expand Down
4 changes: 2 additions & 2 deletions crates/subspace-node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ pub fn gemini_3g_compiled() -> Result<ConsensusChainSpec<RuntimeGenesisConfig>,
}

pub fn gemini_3g_config() -> Result<ConsensusChainSpec<RuntimeGenesisConfig>, String> {
ConsensusChainSpec::from_json_bytes(GEMINI_3G_CHAIN_SPEC)
ConsensusChainSpec::from_json_bytes(GEMINI_3G_CHAIN_SPEC.as_bytes())
}

pub fn devnet_config() -> Result<ConsensusChainSpec<RuntimeGenesisConfig>, String> {
ConsensusChainSpec::from_json_bytes(DEVNET_CHAIN_SPEC)
ConsensusChainSpec::from_json_bytes(DEVNET_CHAIN_SPEC.as_bytes())
}

pub fn devnet_config_compiled() -> Result<ConsensusChainSpec<RuntimeGenesisConfig>, String> {
Expand Down
16 changes: 12 additions & 4 deletions crates/subspace-node/src/domain/domain_instance_starter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{evm_chain_spec, DomainCli};
use crate::domain::{AccountId20, EVMDomainExecutorDispatch};
use crate::ExecutorDispatch as CExecutorDispatch;
use cross_domain_message_gossip::Message;
use cross_domain_message_gossip::{ChainTxPoolMsg, Message};
use domain_client_operator::{BootstrapResult, OperatorStreams};
use domain_eth_service::provider::EthProvider;
use domain_eth_service::DefaultEthConfig;
Expand All @@ -13,6 +13,7 @@ use sc_cli::{CliConfiguration, Database, DefaultConfigurationValues, SubstrateCl
use sc_consensus_subspace::block_import::BlockImportingNotification;
use sc_consensus_subspace::notification::SubspaceNotificationStream;
use sc_consensus_subspace::slot_worker::NewSlotNotification;
use sc_network::NetworkPeers;
use sc_service::{BasePath, Configuration};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sc_utils::mpsc::{TracingUnboundedReceiver, TracingUnboundedSender};
Expand All @@ -24,7 +25,7 @@ use subspace_service::FullClient as CFullClient;

/// `DomainInstanceStarter` used to start a domain instance node based on the given
/// bootstrap result
pub struct DomainInstanceStarter {
pub struct DomainInstanceStarter<CNetwork> {
pub domain_cli: DomainCli,
pub tokio_handle: tokio::runtime::Handle,
pub consensus_client: Arc<CFullClient<CRuntimeApi, CExecutorDispatch>>,
Expand All @@ -33,11 +34,15 @@ pub struct DomainInstanceStarter {
SubspaceNotificationStream<BlockImportingNotification<CBlock>>,
pub new_slot_notification_stream: SubspaceNotificationStream<NewSlotNotification>,
pub consensus_sync_service: Arc<sc_network_sync::SyncingService<CBlock>>,
pub domain_message_receiver: TracingUnboundedReceiver<Vec<u8>>,
pub domain_message_receiver: TracingUnboundedReceiver<ChainTxPoolMsg>,
pub gossip_message_sink: TracingUnboundedSender<Message>,
pub consensus_network: Arc<CNetwork>,
}

impl DomainInstanceStarter {
impl<CNetwork> DomainInstanceStarter<CNetwork>
where
CNetwork: NetworkPeers + Send + Sync + 'static,
{
pub async fn start(
self,
bootstrap_result: BootstrapResult<CBlock>,
Expand All @@ -63,6 +68,7 @@ impl DomainInstanceStarter {
consensus_sync_service,
domain_message_receiver,
gossip_message_sink,
consensus_network,
} = self;

let domain_id = domain_cli.domain_id;
Expand Down Expand Up @@ -133,6 +139,7 @@ impl DomainInstanceStarter {
domain_created_at,
consensus_client,
consensus_offchain_tx_pool_factory,
consensus_network,
consensus_network_sync_oracle: consensus_sync_service.clone(),
operator_streams,
gossip_message_sink,
Expand All @@ -153,6 +160,7 @@ impl DomainInstanceStarter {
EVMDomainExecutorDispatch,
AccountId20,
_,
_,
>(domain_params)
.await?;

Expand Down
5 changes: 2 additions & 3 deletions crates/subspace-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("subspace"),
impl_name: create_runtime_str!("subspace"),
authoring_version: 0,
spec_version: 4,
spec_version: 5,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down Expand Up @@ -603,8 +603,7 @@ parameter_types! {
pub const StakeEpochDuration: DomainNumber = 100;
pub TreasuryAccount: AccountId = PalletId(*b"treasury").into_account_truncating();
pub const MaxPendingStakingOperation: u32 = 100;
// TODO: reset `MaxNominators` back to `100` once the gemini-3g chain spec is created
pub const MaxNominators: u32 = 0;
pub const MaxNominators: u32 = 256;
pub SudoId: AccountId = Sudo::key().expect("Sudo account must exist");
}

Expand Down
14 changes: 13 additions & 1 deletion crates/subspace-service/src/dsn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,25 @@ pub(crate) fn create_dsn_instance(
let metrics = enable_metrics.then(|| Metrics::new(&mut metric_registry));

let networking_parameters_registry = {
// TODO: Make `base_path` point to `network` once we can clean up below migration code
let path = dsn_config.base_path;
let network_path = path.join("network");

// TODO: Remove this in the future after enough upgrade time that this no longer exist
if path.join("known_addresses_db").is_dir() {
let _ = fs::remove_file(path.join("known_addresses_db"));
}
let file_path = path.join("known_addresses.bin");
if !network_path.is_dir() {
fs::create_dir(&network_path)
.map_err(|error| DsnConfigurationError::CreationError(CreationError::Io(error)))?;
}
if path.join("known_addresses.bin").is_dir() {
let _ = fs::rename(
path.join("known_addresses.bin"),
network_path.join("known_addresses.bin"),
);
}
let file_path = network_path.join("known_addresses.bin");

KnownPeersManager::new(KnownPeersManagerConfig {
path: Some(file_path.into_boxed_path()),
Expand Down
Loading

0 comments on commit e49138e

Please sign in to comment.