Skip to content

Commit c56a418

Browse files
Merge pull request #481 from opentensor/feat/localnet-fast-blocks
feat: localnet fast blocks
2 parents 38ea19d + 7c6e34f commit c56a418

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

runtime/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ substrate-wasm-builder = { workspace = true, optional = true }
9494
[features]
9595
default = ["std"]
9696
pow-faucet = ["pallet-subtensor/pow-faucet"]
97+
fast-blocks = []
9798
std = [
9899
"frame-try-runtime?/std",
99100
"frame-system-benchmarking?/std",

runtime/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,13 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
148148
/// up by `pallet_aura` to implement `fn slot_duration()`.
149149
///
150150
/// Change this to adjust the block time.
151+
#[cfg(not(feature = "fast-blocks"))]
151152
pub const MILLISECS_PER_BLOCK: u64 = 12000;
152153

154+
/// Fast blocks for development
155+
#[cfg(feature = "fast-blocks")]
156+
pub const MILLISECS_PER_BLOCK: u64 = 250;
157+
153158
// NOTE: Currently it is not possible to change the slot duration after the chain has started.
154159
// Attempting to do so will brick block production.
155160
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;

scripts/localnet.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ BASE_DIR="$SCRIPT_DIR/.."
88

99
: "${CHAIN:=local}"
1010
: "${BUILD_BINARY:=1}"
11-
: "${FEATURES:=pow-faucet}"
11+
: "${FEATURES:="pow-faucet fast-blocks"}"
1212

1313
SPEC_PATH="${SCRIPT_DIR}/specs/"
1414
FULL_PATH="$SPEC_PATH$CHAIN.json"
1515

16+
# Kill any existing nodes which may have not exited correctly after a previous
17+
# run.
18+
pkill -9 'node-subtensor'
19+
1620
if [ ! -d "$SPEC_PATH" ]; then
1721
echo "*** Creating directory ${SPEC_PATH}..."
1822
mkdir $SPEC_PATH
@@ -59,8 +63,10 @@ bob_start=(
5963
--discover-local
6064
)
6165

66+
trap 'pkill -P $$' EXIT SIGINT SIGTERM
67+
6268
(
63-
trap 'kill 0' SIGINT
6469
("${alice_start[@]}" 2>&1) &
6570
("${bob_start[@]}" 2>&1)
71+
wait
6672
)

0 commit comments

Comments
 (0)