Skip to content

Commit

Permalink
Merge pull request #4360 from stacks-network/feat/4354-aggregate-key
Browse files Browse the repository at this point in the history
Process successful .signers-voting results
  • Loading branch information
obycode authored Feb 21, 2024
2 parents 0b482e3 + d2e6ad8 commit 5f01065
Show file tree
Hide file tree
Showing 29 changed files with 3,032 additions and 714 deletions.
22 changes: 4 additions & 18 deletions contrib/core-contract-tests/tests/pox-4/signers-voting.test.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
import { Cl } from "@stacks/transactions";
import { beforeEach, describe, expect, it } from "vitest";
import { describe, expect, it } from "vitest";

const accounts = simnet.getAccounts();
const alice = accounts.get("wallet_1")!;
const bob = accounts.get("wallet_2")!;
const charlie = accounts.get("wallet_3")!;

const ERR_SIGNER_INDEX_MISMATCH = 10000;
const ERR_INVALID_SIGNER_INDEX = 10001;
const ERR_OUT_OF_VOTING_WINDOW = 10002
const ERR_OLD_ROUND = 10003;
const ERR_ILL_FORMED_AGGREGATE_PUBLIC_KEY = 10004;
const ERR_DUPLICATE_AGGREGATE_PUBLIC_KEY = 10005;
const ERR_DUPLICATE_VOTE = 10006;
const ERR_INVALID_BURN_BLOCK_HEIGHT = 10007

const KEY_1 = "123456789a123456789a123456789a123456789a123456789a123456789a010203";
const KEY_2 = "123456789a123456789a123456789a123456789a123456789a123456789ab0b1b2";
const SIGNERS_VOTING = "signers-voting";

describe("test signers-voting contract voting rounds", () => {
describe("test pox-info", () => {
it("should return correct burn-height", () => {
const { result:result1 } = simnet.callReadOnlyFn(SIGNERS_VOTING,
const { result: result1 } = simnet.callReadOnlyFn(SIGNERS_VOTING,
"reward-cycle-to-burn-height",
[Cl.uint(1)],
alice)
expect(result1).toEqual(Cl.uint(1050))

const { result:result2 } = simnet.callReadOnlyFn(SIGNERS_VOTING,
const { result: result2 } = simnet.callReadOnlyFn(SIGNERS_VOTING,
"reward-cycle-to-burn-height",
[Cl.uint(2)],
alice)
Expand All @@ -50,7 +36,7 @@ describe("test signers-voting contract voting rounds", () => {
})

it("should return true if in prepare phase", () => {
const { result:result999 } = simnet.callReadOnlyFn(SIGNERS_VOTING,
const { result: result999 } = simnet.callReadOnlyFn(SIGNERS_VOTING,
"is-in-prepare-phase",
[Cl.uint(999)],
alice)
Expand Down
3 changes: 3 additions & 0 deletions stackslib/src/burnchains/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,9 @@ impl PoxConstants {

// NOTE: first block in reward cycle is mod 1, so mod 0 is the last block in the
// prepare phase.
// TODO: I *think* the logic of `== 0` here requires some further digging.
// `mod 0` may not have any rewards, but it does not behave like "prepare phase" blocks:
// is it already a member of reward cycle "N" where N = block_height / reward_cycle_len
reward_index == 0 || reward_index > u64::from(reward_cycle_length - prepare_length)
}
}
Expand Down
2 changes: 2 additions & 0 deletions stackslib/src/burnchains/tests/burnchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

use rand::rngs::ThreadRng;
use rand::thread_rng;
use rand_chacha::ChaChaRng;
use rand_core::SeedableRng;
use serde::Serialize;
use sha2::Sha512;
use stacks_common::address::AddressHashMode;
Expand Down
3 changes: 2 additions & 1 deletion stackslib/src/chainstate/burn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ use std::fmt;
use std::io::Write;

use rand::seq::index::sample;
use rand::{Rng, SeedableRng};
use rand::Rng;
use rand_chacha::rand_core::SeedableRng;
use rand_chacha::ChaCha20Rng;
use ripemd::Ripemd160;
use rusqlite::{Connection, Transaction};
Expand Down
Loading

0 comments on commit 5f01065

Please sign in to comment.