Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ Prerequisites:
* Grab `zombienet` utility used to start network from [releases](https://github.com/paritytech/zombienet/releases)


```
```bash
cd ./launch-configs/zombienet
zombienet spawn local.json

// Enable 2s blocktime
node scripts/assign_cores.js
```

### Interaction with the node
Expand Down
16 changes: 15 additions & 1 deletion launch-configs/zombienet/local.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
"patch": {
"configuration": {
"config": {
"scheduler_params": {
"num_cores": 3
},
"async_backing_params": {
"max_candidate_depth": 3,
"max_candidate_depth": 6,
"allowed_ancestry_len": 2
}
}
Expand All @@ -28,12 +31,23 @@
{
"name": "alice",
"ws_port": 9944,
"rpc_port": 9945,
"validator": true
},
{
"name": "bob",
"ws_port": 9955,
"validator": true
},
{
"name": "charlie",
"ws_port": 9966,
"validator": true
},
{
"name": "dave",
"ws_port": 9977,
"validator": true
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "basilisk"
version = "19.1.0"
version = "20.0.0"
description = "Basilisk node"
authors = ["GalacticCouncil"]
edition = "2021"
Expand Down
51 changes: 33 additions & 18 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use basilisk_runtime::{

// Cumulus Imports
use cumulus_client_collator::service::CollatorService;
use cumulus_client_consensus_aura::collators::slot_based::{SlotBasedBlockImport, SlotBasedBlockImportHandle};
use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport;
use cumulus_client_consensus_proposer::Proposer;
use cumulus_client_service::{
Expand Down Expand Up @@ -65,7 +66,8 @@ type ParachainClient = TFullClient<

type ParachainBackend = TFullBackend<Block>;

type ParachainBlockImport = TParachainBlockImport<Block, Arc<ParachainClient>, ParachainBackend>;
type ParachainBlockImport =
TParachainBlockImport<Block, SlotBasedBlockImport<Block, Arc<ParachainClient>, ParachainClient>, ParachainBackend>;

/// Starts a `ServiceBuilder` for a full service.
///
Expand All @@ -80,7 +82,12 @@ pub fn new_partial(
(),
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::TransactionPoolHandle<Block, ParachainClient>,
(ParachainBlockImport, Option<Telemetry>, Option<TelemetryWorkerHandle>),
(
ParachainBlockImport,
SlotBasedBlockImportHandle<Block>,
Option<Telemetry>,
Option<TelemetryWorkerHandle>,
),
>,
sc_service::Error,
> {
Expand Down Expand Up @@ -138,7 +145,8 @@ pub fn new_partial(
.build(),
);

let block_import = ParachainBlockImport::new(client.clone(), backend.clone());
let (slot_based_block_import, block_import_handle) = SlotBasedBlockImport::new(client.clone(), client.clone());
let block_import = ParachainBlockImport::new(slot_based_block_import, backend.clone());

let import_queue = build_import_queue(
client.clone(),
Expand All @@ -156,7 +164,7 @@ pub fn new_partial(
task_manager,
transaction_pool,
select_chain: (),
other: (block_import, telemetry, telemetry_worker_handle),
other: (block_import, block_import_handle, telemetry, telemetry_worker_handle),
})
}

Expand All @@ -174,7 +182,7 @@ async fn start_node_impl(
let parachain_config = prepare_node_config(parachain_config);

let params = new_partial(&parachain_config)?;
let (block_import, mut telemetry, telemetry_worker_handle) = params.other;
let (block_import, block_import_handle, mut telemetry, telemetry_worker_handle) = params.other;

let prometheus_registry = parachain_config.prometheus_registry().cloned();
let net_config = sc_network::config::FullNetworkConfiguration::<_, _, sc_network::NetworkWorker<Block, Hash>>::new(
Expand Down Expand Up @@ -329,6 +337,7 @@ async fn start_node_impl(
client.clone(),
backend.clone(),
block_import,
block_import_handle,
prometheus_registry.as_ref(),
telemetry.as_ref().map(|t| t.handle()),
&task_manager,
Expand Down Expand Up @@ -379,6 +388,7 @@ fn start_consensus(
client: Arc<ParachainClient>,
backend: Arc<ParachainBackend>,
block_import: ParachainBlockImport,
block_import_handle: SlotBasedBlockImportHandle<Block>,
prometheus_registry: Option<&Registry>,
telemetry: Option<TelemetryHandle>,
task_manager: &TaskManager,
Expand All @@ -388,13 +398,10 @@ fn start_consensus(
relay_chain_slot_duration: Duration,
para_id: ParaId,
collator_key: CollatorPair,
overseer_handle: OverseerHandle,
_overseer_handle: OverseerHandle,
announce_block: Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>,
) -> Result<(), sc_service::Error> {
use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams};

// NOTE: because we use Aura here explicitly, we can use `CollatorSybilResistance::Resistant`
// when starting the network.
use cumulus_client_consensus_aura::collators::slot_based::{self as slot_based, Params as SlotBasedParams};

let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
task_manager.spawn_handle(),
Expand All @@ -413,27 +420,35 @@ fn start_consensus(
client.clone(),
);

let params = AuraParams {
let client_for_aura = client.clone();
let params = SlotBasedParams {
create_inherent_data_providers: move |_, ()| async move { Ok(()) },
block_import,
para_client: client.clone(),
para_backend: backend.clone(),
relay_client: relay_chain_interface,
code_hash_provider: move |block_hash| client.code_at(block_hash).ok().map(|c| ValidationCode::from(c).hash()),
code_hash_provider: move |block_hash| {
client_for_aura
.code_at(block_hash)
.ok()
.map(|c| ValidationCode::from(c).hash())
},
keystore,
collator_key,
para_id,
overseer_handle,
relay_chain_slot_duration,
proposer,
collator_service,
authoring_duration: Duration::from_millis(1500),
authoring_duration: Duration::from_millis(2000),
reinitialize: false,
max_pov_percentage: None, // Defaults to 85% of max PoV size (safe default)
slot_offset: Duration::from_secs(1),
block_import_handle,
spawner: task_manager.spawn_handle(),
relay_chain_slot_duration,
export_pov: None,
max_pov_percentage: None,
};

let fut = aura::run::<Block, sp_consensus_aura::sr25519::AuthorityPair, _, _, _, _, _, _, _, _>(params);
task_manager.spawn_essential_handle().spawn("aura", None, fut);
slot_based::run::<Block, sp_consensus_aura::sr25519::AuthorityPair, _, _, _, _, _, _, _, _, _>(params);

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "primitives"
version = "6.7.0"
version = "6.7.1"
authors = ["GalacticCouncil"]
edition = "2021"
repository = "https://github.com/galacticcouncil/Basilisk-node"
Expand Down
20 changes: 12 additions & 8 deletions primitives/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ pub mod time {
/// up by `pallet_aura` to implement `fn slot_duration()`.
///
/// Change this to adjust the block time.
pub const MILLISECS_PER_BLOCK: u64 = 6000;
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
pub const MILLISECS_PER_BLOCK: u64 = 2000;

// The slot duration determines the length of each author's turn and is decoupled from the block
// production interval. During their slot, authors are allowed to produce multiple blocks. **The
// slot duration is required to be at least 6s (same as on the relay chain).**
pub const SLOT_DURATION: u64 = 6000;

// Time is measured by number of blocks.
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
Expand Down Expand Up @@ -75,9 +79,9 @@ pub mod chain {
/// Minimum pool liquidity
pub const MIN_POOL_LIQUIDITY: Balance = 1000;

/// We allow for 2 seconds of compute with a 6 second average block.
/// We allow for 1.5 seconds of compute with a 2 second average block.
pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
WEIGHT_REF_TIME_PER_SECOND.saturating_mul(3).saturating_div(2),
polkadot_primitives::v8::MAX_POV_SIZE as u64,
);

Expand All @@ -96,10 +100,10 @@ mod tests {
assert_eq!(DAYS / 24, HOURS);
// 60 minuts in an hour
assert_eq!(HOURS / 60, MINUTES);
// 1 minute = 60s = 10 blocks 6s each
assert_eq!(MINUTES, 10);
// 6s per block
assert_eq!(SECS_PER_BLOCK, 6);
// 1 minute = 60s = 10 blocks 2s each
assert_eq!(MINUTES, 30);
// 2s per block
assert_eq!(SECS_PER_BLOCK, 2);
// 1s = 1000ms
assert_eq!(MILLISECS_PER_BLOCK / 1000, SECS_PER_BLOCK);
// Extra check for epoch time because changing it bricks the block production and requires regenesis
Expand Down
2 changes: 1 addition & 1 deletion runtime/basilisk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "basilisk-runtime"
version = "129.0.0"
version = "130.0.0"
authors = ["GalacticCouncil"]
edition = "2021"
homepage = "https://github.com/galacticcouncil/Basilisk-node"
Expand Down
15 changes: 15 additions & 0 deletions runtime/basilisk/src/apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,21 @@ impl_runtime_apis! {
}
}

impl cumulus_primitives_core::RelayParentOffsetApi<Block> for Runtime {
fn relay_parent_offset() -> u32 {
RELAY_PARENT_OFFSET
}
}

impl cumulus_primitives_core::GetCoreSelectorApi<Block> for Runtime {
fn core_selector() -> (
cumulus_primitives_core::CoreSelector,
cumulus_primitives_core::ClaimQueueOffset,
) {
ParachainSystem::core_selector()
}
}

#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn benchmark_metadata(extra: bool) -> (
Expand Down
2 changes: 1 addition & 1 deletion runtime/basilisk/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: Cow::Borrowed("basilisk"),
impl_name: Cow::Borrowed("basilisk"),
authoring_version: 1,
spec_version: 129,
spec_version: 130,
impl_version: 0,
apis: apis::RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
Loading
Loading