Skip to content

Commit

Permalink
feat: add devnet tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocaillard committed Jan 23, 2024
1 parent f394a3b commit 2d17422
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 41 deletions.
6 changes: 5 additions & 1 deletion Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ ARG STACKS_NODE_VERSION="No Version Info"
ARG GIT_BRANCH='No Branch Info'
ARG GIT_COMMIT='No Commit Info'

RUN apt update && apt-get install -y libclang-dev

RUN rustup toolchain install stable
RUN rustup component add rustfmt --toolchain stable

WORKDIR /src

COPY . .
Expand All @@ -16,7 +21,6 @@ RUN cp target/release/stacks-node /out

FROM debian:bullseye-slim

RUN apt update && apt install -y netcat
COPY --from=build /out/ /bin/

CMD ["stacks-node", "mainnet"]
7 changes: 4 additions & 3 deletions stackslib/src/burnchains/bitcoin/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,9 +1000,10 @@ impl BurnchainIndexer for BitcoinIndexer {
false,
)?;
let first_block_height = self.get_first_block_height();
let first_header = spv_client
.read_block_header(first_block_height)?
.expect("BUG: no first block header hash");
let first_header = match spv_client.read_block_header(first_block_height) {
Ok(Some(res)) => res,
_ => return Err(burnchain_error::MissingHeaders),
};

let first_block_header_hash =
BurnchainHeaderHash::from_bitcoin_hash(&first_header.header.bitcoin_hash());
Expand Down
22 changes: 13 additions & 9 deletions stackslib/src/burnchains/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,18 +459,22 @@ impl PoxConstants {

pub fn regtest_default() -> PoxConstants {
PoxConstants::new(
10,
4,
3,
25,
5,
1,
1,
3333333333333333,
1,
BITCOIN_REGTEST_FIRST_BLOCK_HEIGHT + POX_SUNSET_START,
BITCOIN_REGTEST_FIRST_BLOCK_HEIGHT + POX_SUNSET_END,
1_000_000,
2_000_000,
3_000_000,
4_000_000,
5_000_000,
POX_V1_REGTEST_EARLY_UNLOCK_HEIGHT,
POX_V2_REGTEST_EARLY_UNLOCK_HEIGHT,
POX_V3_REGTEST_EARLY_UNLOCK_HEIGHT,
BITCOIN_REGTEST_STACKS_24_BURN_HEIGHT
.try_into()
.expect("Epoch transition height must be <= u32::MAX"),
BITCOIN_REGTEST_STACKS_30_BURN_HEIGHT
.try_into()
.expect("Epoch transition height must be <= u32::MAX"),
)
}

Expand Down
4 changes: 2 additions & 2 deletions stackslib/src/chainstate/stacks/boot/pox-testnet.clar
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
(define-constant MAX_POX_REWARD_CYCLES u12)

;; Default length of the PoX registration window, in burnchain blocks.
(define-constant PREPARE_CYCLE_LENGTH u50)
(define-constant PREPARE_CYCLE_LENGTH u4)

;; Default length of the PoX reward cycle, in burnchain blocks.
(define-constant REWARD_CYCLE_LENGTH u1050)
(define-constant REWARD_CYCLE_LENGTH u10)

;; Valid values for burnchain address versions.
;; These correspond to address hash modes in Stacks 2.0.
Expand Down
48 changes: 32 additions & 16 deletions stackslib/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,17 @@ pub const BITCOIN_TESTNET_STACKS_24_BURN_HEIGHT: u64 = 2_432_545;
pub const BITCOIN_TESTNET_STACKS_25_BURN_HEIGHT: u64 = 20_000_000;
pub const BITCOIN_TESTNET_STACKS_30_BURN_HEIGHT: u64 = 30_000_000;

pub const BITCOIN_REGTEST_FIRST_BLOCK_HEIGHT: u64 = 0;
// On regtest networks, we need to matured coinbases for mining Stacks blocks.
// We start at block #100 so we avoid indexing the first 100 non matured
// coinbases.
pub const BITCOIN_REGTEST_FIRST_BLOCK_HEIGHT: u64 = 100;
pub const BITCOIN_REGTEST_STACKS_2_05_BURN_HEIGHT: u64 = 120;
pub const BITCOIN_REGTEST_STACKS_21_BURN_HEIGHT: u64 = 140;
pub const BITCOIN_REGTEST_STACKS_22_BURN_HEIGHT: u64 = 160;
pub const BITCOIN_REGTEST_STACKS_23_BURN_HEIGHT: u64 = 180;
pub const BITCOIN_REGTEST_STACKS_24_BURN_HEIGHT: u64 = 200;
pub const BITCOIN_REGTEST_STACKS_25_BURN_HEIGHT: u64 = 220;
pub const BITCOIN_REGTEST_STACKS_30_BURN_HEIGHT: u64 = 240;
pub const BITCOIN_REGTEST_FIRST_BLOCK_TIMESTAMP: u32 = 0;
pub const BITCOIN_REGTEST_FIRST_BLOCK_HASH: &str =
"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206";
Expand Down Expand Up @@ -181,16 +191,22 @@ pub const POX_V1_MAINNET_EARLY_UNLOCK_HEIGHT: u32 =
(BITCOIN_MAINNET_STACKS_21_BURN_HEIGHT as u32) + 1;
pub const POX_V1_TESTNET_EARLY_UNLOCK_HEIGHT: u32 =
(BITCOIN_TESTNET_STACKS_21_BURN_HEIGHT as u32) + 1;
pub const POX_V1_REGTEST_EARLY_UNLOCK_HEIGHT: u32 =
(BITCOIN_REGTEST_STACKS_21_BURN_HEIGHT as u32) + 1;

pub const POX_V2_MAINNET_EARLY_UNLOCK_HEIGHT: u32 =
(BITCOIN_MAINNET_STACKS_22_BURN_HEIGHT as u32) + 1;
pub const POX_V2_TESTNET_EARLY_UNLOCK_HEIGHT: u32 =
(BITCOIN_TESTNET_STACKS_22_BURN_HEIGHT as u32) + 1;
pub const POX_V2_REGTEST_EARLY_UNLOCK_HEIGHT: u32 =
(BITCOIN_REGTEST_STACKS_22_BURN_HEIGHT as u32) + 1;

pub const POX_V3_MAINNET_EARLY_UNLOCK_HEIGHT: u32 =
(BITCOIN_MAINNET_STACKS_24_BURN_HEIGHT as u32) + 1;
pub const POX_V3_TESTNET_EARLY_UNLOCK_HEIGHT: u32 =
(BITCOIN_TESTNET_STACKS_24_BURN_HEIGHT as u32) + 1;
pub const POX_V3_REGTEST_EARLY_UNLOCK_HEIGHT: u32 =
(BITCOIN_REGTEST_STACKS_24_BURN_HEIGHT as u32) + 1;

/// Burn block height at which the ASTRules::PrecheckSize becomes the default behavior on mainnet
pub const AST_RULES_PRECHECK_SIZE: u64 = 752000; // on or about Aug 30 2022
Expand Down Expand Up @@ -402,56 +418,56 @@ lazy_static! {
},
StacksEpoch {
epoch_id: StacksEpochId::Epoch20,
start_height: 0,
end_height: 1000,
start_height: BITCOIN_REGTEST_FIRST_BLOCK_HEIGHT,
end_height: BITCOIN_REGTEST_STACKS_2_05_BURN_HEIGHT,
block_limit: HELIUM_BLOCK_LIMIT_20.clone(),
network_epoch: PEER_VERSION_EPOCH_2_0
},
StacksEpoch {
epoch_id: StacksEpochId::Epoch2_05,
start_height: 1000,
end_height: 2000,
start_height: BITCOIN_REGTEST_STACKS_2_05_BURN_HEIGHT,
end_height: BITCOIN_REGTEST_STACKS_21_BURN_HEIGHT,
block_limit: HELIUM_BLOCK_LIMIT_20.clone(),
network_epoch: PEER_VERSION_EPOCH_2_05
},
StacksEpoch {
epoch_id: StacksEpochId::Epoch21,
start_height: 2000,
end_height: 3000,
start_height: BITCOIN_REGTEST_STACKS_21_BURN_HEIGHT,
end_height: BITCOIN_REGTEST_STACKS_22_BURN_HEIGHT,
block_limit: HELIUM_BLOCK_LIMIT_20.clone(),
network_epoch: PEER_VERSION_EPOCH_2_1
},
StacksEpoch {
epoch_id: StacksEpochId::Epoch22,
start_height: 3000,
end_height: 4000,
start_height: BITCOIN_REGTEST_STACKS_22_BURN_HEIGHT,
end_height: BITCOIN_REGTEST_STACKS_23_BURN_HEIGHT,
block_limit: HELIUM_BLOCK_LIMIT_20.clone(),
network_epoch: PEER_VERSION_EPOCH_2_2
},
StacksEpoch {
epoch_id: StacksEpochId::Epoch23,
start_height: 4000,
end_height: 5000,
start_height: BITCOIN_REGTEST_STACKS_23_BURN_HEIGHT,
end_height: BITCOIN_REGTEST_STACKS_24_BURN_HEIGHT,
block_limit: HELIUM_BLOCK_LIMIT_20.clone(),
network_epoch: PEER_VERSION_EPOCH_2_3
},
StacksEpoch {
epoch_id: StacksEpochId::Epoch24,
start_height: 5000,
end_height: 6000,
start_height: BITCOIN_REGTEST_STACKS_24_BURN_HEIGHT,
end_height: BITCOIN_REGTEST_STACKS_25_BURN_HEIGHT,
block_limit: HELIUM_BLOCK_LIMIT_20.clone(),
network_epoch: PEER_VERSION_EPOCH_2_4
},
StacksEpoch {
epoch_id: StacksEpochId::Epoch25,
start_height: 6000,
end_height: 7000,
start_height: BITCOIN_REGTEST_STACKS_25_BURN_HEIGHT,
end_height: BITCOIN_REGTEST_STACKS_30_BURN_HEIGHT,
block_limit: BLOCK_LIMIT_MAINNET_21.clone(),
network_epoch: PEER_VERSION_EPOCH_2_5
},
StacksEpoch {
epoch_id: StacksEpochId::Epoch30,
start_height: 7000,
start_height: BITCOIN_REGTEST_STACKS_30_BURN_HEIGHT,
end_height: STACKS_EPOCH_MAX,
block_limit: BLOCK_LIMIT_MAINNET_21.clone(),
network_epoch: PEER_VERSION_EPOCH_3_0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,12 +578,12 @@ impl BitcoinRegtestController {
burnchain_error::BurnchainPeerBroken => {
// remote burnchain peer broke, and produced a shorter blockchain fork.
// just keep trying
sleep_ms(5000);
sleep_ms(1000);
continue;
}
_ => {
// delay and try again
sleep_ms(5000);
sleep_ms(1000);
continue;
}
}
Expand Down
19 changes: 11 additions & 8 deletions testnet/stacks-node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::fs;
use std::net::{SocketAddr, ToSocketAddrs};
use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use std::thread::sleep;
use std::time::Duration;

use clarity::vm::costs::ExecutionCost;
Expand Down Expand Up @@ -768,7 +769,7 @@ impl Config {
);
}

// epochs must be a prefix of [1.0, 2.0, 2.05, 2.1]
// epochs must be a prefix of [1.0, 2.0, 2.05, 2.1, 2.2, 2.3, 2.4, 2.5, 3.0]
let expected_list = [
StacksEpochId::Epoch10,
StacksEpochId::Epoch20,
Expand Down Expand Up @@ -984,7 +985,6 @@ impl Config {
.collect();

let endpoint = format!("{}", observer.endpoint);

observers.insert(EventObserverConfig {
endpoint,
events_keys,
Expand Down Expand Up @@ -1409,18 +1409,21 @@ impl BurnchainConfigFile {
// Using std::net::LookupHost would be preferable, but it's
// unfortunately unstable at this point.
// https://doc.rust-lang.org/1.6.0/std/net/struct.LookupHost.html
let mut sock_addrs = format!("{}:1", &peer_host)
.to_socket_addrs()
.map_err(|e| format!("Invalid burnchain.peer_host: {}", &e))?;
let sock_addr = match sock_addrs.next() {
Some(addr) => addr,
None => {
let mut attempts = 0;
let mut addrs_iter = loop {
if let Ok(addrs_iter) = format!("{}:1", peer_host).to_socket_addrs() {
break addrs_iter;
}
attempts += 1;
if attempts == 15 {
return Err(format!(
"No IP address could be queried for '{}'",
&peer_host
));
}
sleep(std::time::Duration::from_secs(5));
};
let sock_addr = addrs_iter.next().unwrap();
format!("{}", sock_addr.ip())
}
None => default_burnchain_config.peer_host,
Expand Down

0 comments on commit 2d17422

Please sign in to comment.