Skip to content

Commit

Permalink
CRC: add clarifying comments and names
Browse files Browse the repository at this point in the history
Signed-off-by: Jacinta Ferrant <[email protected]>
  • Loading branch information
jferrant committed Nov 29, 2023
1 parent 69966a5 commit ff3a01c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions stackslib/src/chainstate/nakamoto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1444,9 +1444,9 @@ impl NakamotoChainState {
ch_sn.block_height,
)
else {
// can't do anything
// This should be unreachable, but we'll return an error just in case.
let msg = format!(
"Failed to determine reward cycle of block height: {}.",
"BUG: Failed to determine reward cycle of block height: {}.",
ch_sn.block_height
);
warn!("{msg}");
Expand Down
17 changes: 9 additions & 8 deletions stackslib/src/chainstate/nakamoto/tests/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub struct TestSigners {
/// The parties that will sign the blocks
pub signer_parties: Vec<wsts::v2::Party>,
/// The commitments to the polynomials for the aggregate public key
pub comms: Vec<wsts::common::PolyCommitment>,
pub poly_commitments: Vec<wsts::common::PolyCommitment>,
/// The aggregate public key
pub aggregate_public_key: wsts::Point,
/// The total number of key ids distributed among signer_parties
Expand Down Expand Up @@ -105,19 +105,20 @@ impl Default for TestSigners {
.collect();

// Generate an aggregate public key
let comms = match wsts::v2::test_helpers::dkg(&mut signer_parties, &mut rng) {
Ok(comms) => comms,
let poly_commitments = match wsts::v2::test_helpers::dkg(&mut signer_parties, &mut rng) {
Ok(poly_commitments) => poly_commitments,
Err(secret_errors) => {
panic!("Got secret errors from DKG: {:?}", secret_errors);
}
};
let aggregate_public_key = comms
.iter()
.fold(wsts::Point::default(), |s, comm| s + comm.poly[0]);
let aggregate_public_key = poly_commitments.iter().fold(
wsts::Point::default(),
|s, poly_commitment: &wsts::common::PolyCommitment| s + poly_commitment.poly[0],
);
Self {
signer_parties,
aggregate_public_key,
comms,
poly_commitments,
num_keys,
threshold,
}
Expand All @@ -137,7 +138,7 @@ impl TestSigners {

let mut sig_aggregator = wsts::v2::Aggregator::new(self.num_keys, self.threshold);
sig_aggregator
.init(self.comms.clone())
.init(self.poly_commitments.clone())
.expect("aggregator init failed");
let signature = sig_aggregator
.sign(msg.as_slice(), &nonces, &sig_shares, &key_ids)
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/chainstate/stacks/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ impl StacksChainState {
block_id: &StacksBlockId,
reward_cycle: u64,
) -> Result<Option<Point>, Error> {
if !self.is_pox_active(sortdb, block_id, reward_cycle as u128, POX_4_NAME)? {
if !self.is_pox_active(sortdb, block_id, u128::from(reward_cycle), POX_4_NAME)? {
debug!(
"PoX was voted disabled in block {} (reward cycle {})",
block_id, reward_cycle
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/chainstate/stacks/boot/pox-4.clar
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,7 @@
)

;; Set the aggregate public key to the provided value
;; TODO: REMOVE THIS
;; TODO: https://github.com/stacks-network/stacks-core/issues/4101
;; *New in Stacks 3.0*
(define-public (set-aggregate-public-key (reward-cycle uint) (aggregate-public-key (buff 33)))
(begin
Expand Down

0 comments on commit ff3a01c

Please sign in to comment.