Skip to content

Commit

Permalink
continue undoing #4094 rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
setzeus committed Dec 20, 2023
1 parent 72ca439 commit 1e2e8e0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
27 changes: 27 additions & 0 deletions stackslib/src/chainstate/stacks/boot/contract_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ lazy_static! {
boot_code_id("pox-2", false);
pub static ref COST_VOTING_CONTRACT_TESTNET: QualifiedContractIdentifier =
boot_code_id("cost-voting", false);
pub static ref POX_4_CONTRACT_TESTNET: QualifiedContractIdentifier =
boot_code_id("pox-4", false);
pub static ref USER_KEYS: Vec<StacksPrivateKey> =
(0..50).map(|_| StacksPrivateKey::new()).collect();
pub static ref POX_ADDRS: Vec<Value> = (0..50u64)
Expand Down Expand Up @@ -559,6 +561,31 @@ impl HeadersDB for TestSimHeadersDB {
}
}

#[test]
fn pox_4_instantiates() {
let mut sim = ClarityTestSim::new();
sim.epoch_bounds = vec![0, 1, 2];
let delegator = StacksPrivateKey::new();

let expected_unlock_height = POX_TESTNET_CYCLE_LENGTH * 4;

// execute past 2.1 epoch initialization
sim.execute_next_block(|_env| {});
sim.execute_next_block(|_env| {});
sim.execute_next_block(|_env| {});

sim.execute_next_block(|env| {
env.initialize_versioned_contract(
POX_4_CONTRACT_TESTNET.clone(),
ClarityVersion::Clarity2,
&boot::POX_4_TESTNET_CODE,
None,
ASTRules::PrecheckSize,
)
.unwrap()
});
}

#[test]
fn pox_2_contract_caller_units() {
let mut sim = ClarityTestSim::new();
Expand Down
27 changes: 0 additions & 27 deletions stackslib/src/chainstate/stacks/boot/pox-4.clar
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,6 @@
;; (0x05 and 0x06 have 32-byte hashbytes)
(define-constant MAX_ADDRESS_VERSION_BUFF_32 u6)

;; PoX mainnet constants
;; Min/max number of reward cycles uSTX can be locked for
(define-constant MIN_POX_REWARD_CYCLES u1)
(define-constant MAX_POX_REWARD_CYCLES u12)

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

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

;; Stacking thresholds
(define-constant STACKING_THRESHOLD_25 (if is-in-mainnet u20000 u8000))
(define-constant STACKING_THRESHOLD_100 (if is-in-mainnet u5000 u2000))

;; Data vars that store a copy of the burnchain configuration.
;; Implemented as data-vars, so that different configurations can be
;; used in e.g. test harnesses.
Expand Down Expand Up @@ -535,14 +520,6 @@
(and (>= lock-period MIN_POX_REWARD_CYCLES)
(<= lock-period MAX_POX_REWARD_CYCLES)))

;; Is the given burn block height in the prepare phase?
;; This computes `((height - first-burnchain-block-height) + pox-prepare-cycle-length) % pox-reward-cycle-length) < pox-prepare-cycle-length`.
(define-read-only (check-prepare-phase (height uint))
(let ((prepare-cycle-length (var-get pox-prepare-cycle-length)))
(< (mod (+ (- height (var-get first-burnchain-block-height)) prepare-cycle-length)
(var-get pox-reward-cycle-length))
prepare-cycle-length)))

;; Evaluate if a participant can stack an amount of STX for a given period.
;; This method is designed as a read-only method so that it can be used as
;; a set of guard conditions and also as a read-only RPC call that can be
Expand Down Expand Up @@ -580,10 +557,6 @@
(asserts! (check-pox-lock-period num-cycles)
(err ERR_STACKING_INVALID_LOCK_PERIOD))

;; stacking must not happen during prepare phase
(asserts! (not (check-prepare-phase burn-block-height))
(err ERR_STACKING_DURING_PREPARE_PHASE))

;; address version must be valid
(asserts! (check-pox-addr-version (get version pox-addr))
(err ERR_STACKING_INVALID_POX_ADDRESS))
Expand Down

0 comments on commit 1e2e8e0

Please sign in to comment.