Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Mutants next/test stackslib with 5 shards 1/source #37

Open
wants to merge 46 commits into
base: mutants-next/test-stackslib-with-5-shards-1/base
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
f697611
Create a boot contract to initialize pre-pox-4 aggregate key
jferrant Dec 1, 2023
8783eab
Retrieve boot contract init agg key and set all pre-pox-4 cycles to it
jferrant Dec 1, 2023
24a16cd
Only use the self_signer aggregate pub key for genesis blocks
jferrant Dec 1, 2023
cad57dc
Set the aggregate public key for the NEXT reward cycle in every block
jferrant Dec 1, 2023
76ccefa
Cleanup mine_stacks_block by pulling transaction construction into se…
jferrant Dec 1, 2023
03848a3
CRC: add test to set and get the aggregate public key
jferrant Dec 4, 2023
90dce75
CRC: check that the initial aggregate key was set correctly
jferrant Dec 4, 2023
b79762a
Fix failed rebase by updating mockamoto tests.rs to use insert instea…
jferrant Dec 7, 2023
287c19b
make set-aggregate-public-key private in the pox4 contract
xoloki Dec 1, 2023
5998f3b
replace manual set-aggregate-public-key test with one that checks to …
xoloki Dec 7, 2023
9865cb6
execute private contract call using as_transaction/with_abort_callbac…
xoloki Dec 11, 2023
18fafdd
Create a boot contract to initialize pre-pox-4 aggregate key
jferrant Dec 1, 2023
f2772d2
Retrieve boot contract init agg key and set all pre-pox-4 cycles to it
jferrant Dec 1, 2023
949e0fd
Only use the self_signer aggregate pub key for genesis blocks
jferrant Dec 1, 2023
c2f3c5f
Set the aggregate public key for the NEXT reward cycle in every block
jferrant Dec 1, 2023
ef6b7f4
Cleanup mine_stacks_block by pulling transaction construction into se…
jferrant Dec 1, 2023
e9f9974
CRC: add test to set and get the aggregate public key
jferrant Dec 4, 2023
76eea0a
CRC: check that the initial aggregate key was set correctly
jferrant Dec 4, 2023
96911d0
Make sure thread exits before looking for transfer tx
jferrant Dec 12, 2023
dcd522f
feat: add nakamoto_node, nakamoto-neon mode
kantai Dec 4, 2023
7f0e1d4
expand first nakamoto-neon test, update block commit logic to issue c…
kantai Dec 7, 2023
25d1b52
feat: add boot_nakamoto to wrap the 2.x/3.x node handoff
kantai Dec 9, 2023
b5bb4ac
add copyright headers, some code cleanup
kantai Dec 9, 2023
b84b483
chore: comments, cleanup unused functions
kantai Dec 10, 2023
aa5ca43
chore: handle merge/rebase artifacts, address PR feedback
kantai Dec 12, 2023
fc147df
remove unconfirmed tx handling in nakamoto RelayerThread
kantai Dec 12, 2023
16bb688
add epoch-3.0 burnchain configuration assertions
kantai Dec 12, 2023
56f5f1e
Merge branch 'feat/naka-neon' into feat/mockamoto-set-aggregate-publi…
jcnelson Dec 12, 2023
5ed69d8
Merge branch 'chore/make-set-agg-pubkey-private' into feat/mockamoto-…
jcnelson Dec 12, 2023
186f52c
Merge branch 'next' into feat/mockamoto-set-aggregate-public-key
jcnelson Dec 12, 2023
81c163f
chore: put set-aggregate-public-key call into NakamotoChainState::set…
jcnelson Dec 13, 2023
4ce8f72
fix: reward cycle prepare phase length of 3
jcnelson Dec 13, 2023
eb043c6
fix: get aggregate public key from sortition tip parent height
jcnelson Dec 13, 2023
bc5f9f0
chore: delete old test -- we can't set the aggregate public key via a tx
jcnelson Dec 13, 2023
21aa307
chore: load aggregate public key from clarity
jcnelson Dec 13, 2023
a4c2a7d
chore: set aggregate public key smart contract on bootup
jcnelson Dec 13, 2023
3785db7
fix: when searching for the aggregate public key, search _all prior r…
jcnelson Dec 13, 2023
0a6aa26
fix: install initial aggregate public key to neon, not nakamoto
jcnelson Dec 13, 2023
e409b0a
fix: search reward cycle 0 as well
jcnelson Dec 13, 2023
7a910e7
fix: expect to wait up to 10 minutes for a block to be processed (not…
jcnelson Dec 13, 2023
5a29874
Merge branch 'next' into feat/get-set-aggregate-public-key
jcnelson Dec 13, 2023
ea7b165
chore: address PR feedback
jcnelson Dec 13, 2023
b63ca21
chore: address PR feedback and force epoch 2.5 to begin after the int…
jcnelson Dec 13, 2023
8cffc38
Merge pull request #4165 from stacks-network/feat/get-set-aggregate-p…
jcnelson Dec 14, 2023
ece58d3
feat: ready source branch
ASuciuX Dec 19, 2023
0b27aed
feat: run again with `cargo test --test-threads` arg
ASuciuX Dec 22, 2023
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
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion clarity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ resolver = "2"

[lib]
name = "clarity"
path = "./src/libclarity.rs"
path = "./src/lib.rs"

[dependencies]
rand = "0.7.3"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion libsigner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ edition = "2021"

[lib]
name = "libsigner"
path = "./src/libsigner.rs"
path = "./src/lib.rs"

[dependencies]
clarity = { path = "../clarity" }
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion stacks-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ edition = "2021"

[lib]
name = "stacks_common"
path = "./src/libcommon.rs"
path = "./src/lib.rs"

[dependencies]
rand = "0.7.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#![allow(non_upper_case_globals)]
#![cfg_attr(test, allow(unused_variables, unused_assignments))]
#![allow(clippy::assertions_on_constants)]

// test to trigger mutants re-run
#[macro_use(o, slog_log, slog_trace, slog_debug, slog_info, slog_warn, slog_error)]
extern crate slog;

Expand Down
2 changes: 1 addition & 1 deletion stackslib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pox-locking = { path = "../pox-locking" }
libstackerdb = { path = "../libstackerdb" }
siphasher = "0.3.7"
wsts = {workspace = true}
rand_core = "0.6"
rand_core = {workspace = true}

[target.'cfg(unix)'.dependencies]
nix = "0.23"
Expand Down
22 changes: 22 additions & 0 deletions stackslib/src/chainstate/burn/db/sortdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,12 @@ pub trait SortitionHandle {
block_height: u64,
) -> Result<Option<BlockSnapshot>, db_error>;

/// Get the first burn block height
fn first_burn_block_height(&self) -> u64;

/// Get a ref to the PoX constants
fn pox_constants(&self) -> &PoxConstants;

/// is the given block a descendant of `potential_ancestor`?
/// * block_at_burn_height: the burn height of the sortition that chose the stacks block to check
/// * potential_ancestor: the stacks block hash of the potential ancestor
Expand Down Expand Up @@ -1396,6 +1402,14 @@ impl SortitionHandle for SortitionHandleTx<'_> {
SortitionDB::get_ancestor_snapshot_tx(self, block_height, &chain_tip)
}

fn first_burn_block_height(&self) -> u64 {
self.context.first_block_height
}

fn pox_constants(&self) -> &PoxConstants {
&self.context.pox_constants
}

fn sqlite(&self) -> &Connection {
self.tx()
}
Expand All @@ -1409,6 +1423,14 @@ impl SortitionHandle for SortitionHandleConn<'_> {
SortitionHandleConn::get_block_snapshot_by_height(self, block_height)
}

fn first_burn_block_height(&self) -> u64 {
self.context.first_block_height
}

fn pox_constants(&self) -> &PoxConstants {
&self.context.pox_constants
}

fn sqlite(&self) -> &Connection {
self.conn()
}
Expand Down
61 changes: 22 additions & 39 deletions stackslib/src/chainstate/nakamoto/coordinator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use crate::net::relay::Relayer;
use crate::net::test::{TestPeer, TestPeerConfig};

/// Bring a TestPeer into the Nakamoto Epoch
fn advance_to_nakamoto(peer: &mut TestPeer, aggregate_public_key: &Point) {
fn advance_to_nakamoto(peer: &mut TestPeer) {
let mut peer_nonce = 0;
let private_key = peer.config.private_key.clone();
let addr = StacksAddress::from_public_keys(
Expand All @@ -70,13 +70,7 @@ fn advance_to_nakamoto(peer: &mut TestPeer, aggregate_public_key: &Point) {
12,
34,
);
let aggregate_tx: StacksTransaction = make_pox_4_aggregate_key(
&private_key,
1,
sortition_height + 1,
aggregate_public_key,
);
vec![stack_tx, aggregate_tx]
vec![stack_tx]
} else {
vec![]
};
Expand All @@ -95,6 +89,7 @@ pub fn boot_nakamoto(
aggregate_public_key: Point,
) -> TestPeer {
let mut peer_config = TestPeerConfig::new(test_name, 0, 0);
peer_config.aggregate_public_key = Some(aggregate_public_key.clone());
let private_key = peer_config.private_key.clone();
let addr = StacksAddress::from_public_keys(
C32_ADDRESS_VERSION_TESTNET_SINGLESIG,
Expand All @@ -117,19 +112,19 @@ pub fn boot_nakamoto(
peer_config.burnchain.pox_constants.pox_4_activation_height = 31;

let mut peer = TestPeer::new(peer_config);
advance_to_nakamoto(&mut peer, &aggregate_public_key);
advance_to_nakamoto(&mut peer);
peer
}

/// Make a replay peer, used for replaying the blockchain
fn make_replay_peer<'a>(peer: &'a mut TestPeer<'a>, aggregate_public_key: &Point) -> TestPeer<'a> {
fn make_replay_peer<'a>(peer: &'a mut TestPeer<'a>) -> TestPeer<'a> {
let mut replay_config = peer.config.clone();
replay_config.test_name = format!("{}.replay", &peer.config.test_name);
replay_config.server_port = 0;
replay_config.http_port = 0;

let mut replay_peer = TestPeer::new(replay_config);
advance_to_nakamoto(&mut replay_peer, aggregate_public_key);
advance_to_nakamoto(&mut replay_peer);

// sanity check
let replay_tip = {
Expand Down Expand Up @@ -244,7 +239,11 @@ fn replay_reward_cycle(
#[test]
fn test_simple_nakamoto_coordinator_bootup() {
let mut test_signers = TestSigners::default();
let mut peer = boot_nakamoto(function_name!(), vec![], test_signers.aggregate_public_key);
let mut peer = boot_nakamoto(
function_name!(),
vec![],
test_signers.aggregate_public_key.clone(),
);

let (burn_ops, mut tenure_change, miner_key) =
peer.begin_nakamoto_tenure(TenureChangeCause::BlockFound);
Expand Down Expand Up @@ -303,7 +302,7 @@ fn test_simple_nakamoto_coordinator_1_tenure_10_blocks() {
let mut peer = boot_nakamoto(
function_name!(),
vec![(addr.into(), 100_000_000)],
test_signers.aggregate_public_key,
test_signers.aggregate_public_key.clone(),
);

let (burn_ops, mut tenure_change, miner_key) =
Expand Down Expand Up @@ -376,7 +375,7 @@ fn test_simple_nakamoto_coordinator_1_tenure_10_blocks() {

// replay the blocks and sortitions in random order, and verify that we still reach the chain
// tip
let mut replay_peer = make_replay_peer(&mut peer, &test_signers.aggregate_public_key);
let mut replay_peer = make_replay_peer(&mut peer);
replay_reward_cycle(&mut replay_peer, &[burn_ops], &blocks);

let tip = {
Expand Down Expand Up @@ -424,7 +423,7 @@ fn test_nakamoto_chainstate_getters() {
let mut peer = boot_nakamoto(
function_name!(),
vec![(addr.into(), 100_000_000)],
test_signers.aggregate_public_key,
test_signers.aggregate_public_key.clone(),
);

let sort_tip = {
Expand Down Expand Up @@ -913,7 +912,7 @@ fn test_simple_nakamoto_coordinator_10_tenures_10_blocks() {
let mut peer = boot_nakamoto(
function_name!(),
vec![(addr.into(), 100_000_000)],
test_signers.aggregate_public_key,
test_signers.aggregate_public_key.clone(),
);

let mut all_blocks = vec![];
Expand Down Expand Up @@ -953,7 +952,6 @@ fn test_simple_nakamoto_coordinator_10_tenures_10_blocks() {
// do a stx transfer in each block to a given recipient
let recipient_addr =
StacksAddress::from_string("ST2YM3J4KQK09V670TD6ZZ1XYNYCNGCWCVTASN5VM").unwrap();
let aggregate_public_key = test_signers.aggregate_public_key.clone();
let blocks_and_sizes = peer.make_nakamoto_tenure(
tenure_change_tx,
coinbase_tx,
Expand All @@ -973,14 +971,7 @@ fn test_simple_nakamoto_coordinator_10_tenures_10_blocks() {
1,
&recipient_addr,
);

let aggregate_tx = make_pox_4_aggregate_key(
&private_key,
account.nonce + 1,
7 + i,
&aggregate_public_key,
);
vec![stx_transfer, aggregate_tx]
vec![stx_transfer]
} else {
vec![]
}
Expand Down Expand Up @@ -1196,7 +1187,7 @@ fn test_simple_nakamoto_coordinator_10_tenures_10_blocks() {
}
// replay the blocks and sortitions in random order, and verify that we still reach the chain
// tip
let mut replay_peer = make_replay_peer(&mut peer, &test_signers.aggregate_public_key);
let mut replay_peer = make_replay_peer(&mut peer);
for (burn_ops, blocks) in rc_burn_ops.iter().zip(rc_blocks.iter()) {
replay_reward_cycle(&mut replay_peer, burn_ops, blocks);
}
Expand Down Expand Up @@ -1241,7 +1232,7 @@ fn test_simple_nakamoto_coordinator_2_tenures_3_sortitions() {
let mut peer = boot_nakamoto(
function_name!(),
vec![(addr.into(), 100_000_000)],
test_signers.aggregate_public_key,
test_signers.aggregate_public_key.clone(),
);

let mut rc_burn_ops = vec![];
Expand Down Expand Up @@ -1530,7 +1521,7 @@ fn test_simple_nakamoto_coordinator_2_tenures_3_sortitions() {

// replay the blocks and sortitions in random order, and verify that we still reach the chain
// tip
let mut replay_peer = make_replay_peer(&mut peer, &test_signers.aggregate_public_key);
let mut replay_peer = make_replay_peer(&mut peer);
replay_reward_cycle(&mut replay_peer, &rc_burn_ops, &all_blocks);

let tip = {
Expand Down Expand Up @@ -1569,7 +1560,7 @@ fn test_simple_nakamoto_coordinator_10_tenures_and_extensions_10_blocks() {
let mut peer = boot_nakamoto(
function_name!(),
vec![(addr.into(), 100_000_000)],
test_signers.aggregate_public_key,
test_signers.aggregate_public_key.clone(),
);

let mut all_blocks = vec![];
Expand Down Expand Up @@ -1598,7 +1589,6 @@ fn test_simple_nakamoto_coordinator_10_tenures_and_extensions_10_blocks() {
// do a stx transfer in each block to a given recipient
let recipient_addr =
StacksAddress::from_string("ST2YM3J4KQK09V670TD6ZZ1XYNYCNGCWCVTASN5VM").unwrap();
let aggregate_public_key = test_signers.aggregate_public_key.clone();
let blocks_and_sizes = peer.make_nakamoto_tenure(
tenure_change_tx,
coinbase_tx,
Expand All @@ -1619,13 +1609,6 @@ fn test_simple_nakamoto_coordinator_10_tenures_and_extensions_10_blocks() {
&recipient_addr,
);

let aggregate_tx = make_pox_4_aggregate_key(
&private_key,
account.nonce + 1,
7 + i,
&aggregate_public_key,
);

let last_block_opt = blocks_so_far
.last()
.as_ref()
Expand All @@ -1642,7 +1625,7 @@ fn test_simple_nakamoto_coordinator_10_tenures_and_extensions_10_blocks() {
miner.make_nakamoto_tenure_change(tenure_extension.clone());
txs.push(tenure_extension_tx);
}
txs.append(&mut vec![stx_transfer, aggregate_tx]);
txs.append(&mut vec![stx_transfer]);
txs
} else {
vec![]
Expand Down Expand Up @@ -1792,7 +1775,7 @@ fn test_simple_nakamoto_coordinator_10_tenures_and_extensions_10_blocks() {

// replay the blocks and sortitions in random order, and verify that we still reach the chain
// tip
let mut replay_peer = make_replay_peer(&mut peer, &test_signers.aggregate_public_key);
let mut replay_peer = make_replay_peer(&mut peer);
for (burn_ops, blocks) in rc_burn_ops.iter().zip(rc_blocks.iter()) {
replay_reward_cycle(&mut replay_peer, burn_ops, blocks);
}
Expand Down
1 change: 1 addition & 0 deletions stackslib/src/chainstate/nakamoto/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ impl NakamotoBlockBuilder {
&mut info.chainstate_tx,
info.clarity_instance,
burn_dbconn,
burn_dbconn.context.first_block_height,
&burn_dbconn.context.pox_constants,
info.parent_consensus_hash,
info.parent_header_hash,
Expand Down
Loading
Loading