-
Notifications
You must be signed in to change notification settings - Fork 716
PoX-4 Signing Keys Stacking-State #4092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
72ca439
1e2e8e0
c66946a
013266a
7352f3e
166ac8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,21 +27,20 @@ | |
| (define-constant ERR_DELEGATION_WRONG_REWARD_SLOT 29) | ||
| (define-constant ERR_STACKING_IS_DELEGATED 30) | ||
| (define-constant ERR_STACKING_NOT_DELEGATED 31) | ||
| (define-constant ERR_STACKING_DURING_PREPARE_PHASE 32) | ||
| (define-constant ERR_STACK_EXTEND_NOT_SIGNED 33) | ||
|
|
||
| ;; PoX disabling threshold (a percent) | ||
| (define-constant POX_REJECTION_FRACTION u25) | ||
|
|
||
| ;; Valid values for burnchain address versions. | ||
| ;; These first four correspond to address hash modes in Stacks 2.1, | ||
| ;; and are defined in pox-mainnet.clar and pox-testnet.clar (so they | ||
| ;; cannot be defined here again). | ||
| ;; (define-constant ADDRESS_VERSION_P2PKH 0x00) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you're now using |
||
| ;; (define-constant ADDRESS_VERSION_P2SH 0x01) | ||
| ;; (define-constant ADDRESS_VERSION_P2WPKH 0x02) | ||
| ;; (define-constant ADDRESS_VERSION_P2WSH 0x03) | ||
| (define-constant ADDRESS_VERSION_NATIVE_P2WPKH 0x04) | ||
| (define-constant ADDRESS_VERSION_NATIVE_P2WSH 0x05) | ||
| (define-constant ADDRESS_VERSION_NATIVE_P2TR 0x06) | ||
| ;; (define-constant ADDRESS_VERSION_NATIVE_P2WPKH 0x04) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't commit commented-out code |
||
| ;; (define-constant ADDRESS_VERSION_NATIVE_P2WSH 0x05) | ||
| ;; (define-constant ADDRESS_VERSION_NATIVE_P2TR 0x06) | ||
| ;; Keep these constants in lock-step with the address version buffs above | ||
| ;; Maximum value of an address version as a uint | ||
| (define-constant MAX_ADDRESS_VERSION u6) | ||
|
|
@@ -117,7 +116,9 @@ | |
| ;; previous stack-stx calls, or prior to an extend) | ||
| reward-set-indexes: (list 12 uint), | ||
| ;; principal of the delegate, if stacker has delegated | ||
| delegated-to: (optional principal) | ||
| delegated-to: (optional principal), | ||
| ;; signing key for Nakamoto, only 'none' when delegated & before delegate calls stack-aggregation-commit-indexed | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
EDIT: this comment is out of date |
||
| signing-key: (buff 33) | ||
| } | ||
| ) | ||
|
|
||
|
|
@@ -576,13 +577,14 @@ | |
|
|
||
| ;; Lock up some uSTX for stacking! Note that the given amount here is in micro-STX (uSTX). | ||
| ;; The STX will be locked for the given number of reward cycles (lock-period). | ||
| ;; This is the self-service interface. tx-sender will be the Stacker. | ||
| ;; This is the self-service interface. tx-sender will be the Stacker. Stacker is responsible for providing a valid signing key. | ||
| ;; | ||
| ;; * The given stacker cannot currently be stacking. | ||
| ;; * You will need the minimum uSTX threshold. This will be determined by (get-stacking-minimum) | ||
| ;; at the time this method is called. | ||
| ;; * You may need to increase the amount of uSTX locked up later, since the minimum uSTX threshold | ||
| ;; may increase between reward cycles. | ||
| ;; * You need to provide a signing-key used to allocate signature-weight to a valid signer | ||
| ;; * The Stacker will receive rewards in the reward cycle following `start-burn-ht`. | ||
| ;; Importantly, `start-burn-ht` may not be further into the future than the next reward cycle, | ||
| ;; and in most cases should be set to the current burn block height. | ||
|
|
@@ -591,7 +593,8 @@ | |
| (define-public (stack-stx (amount-ustx uint) | ||
| (pox-addr (tuple (version (buff 1)) (hashbytes (buff 32)))) | ||
| (start-burn-ht uint) | ||
| (lock-period uint)) | ||
| (lock-period uint) | ||
| (signing-key (buff 33))) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a comment about
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated a sentence & added the following to comment doc above function: |
||
| ;; this stacker's first reward cycle is the _next_ reward cycle | ||
| (let ((first-reward-cycle (+ u1 (current-pox-reward-cycle))) | ||
| (specified-reward-cycle (+ u1 (burn-height-to-reward-cycle start-burn-ht)))) | ||
|
|
@@ -628,7 +631,8 @@ | |
| reward-set-indexes: reward-set-indexes, | ||
| first-reward-cycle: first-reward-cycle, | ||
| lock-period: lock-period, | ||
| delegated-to: none }) | ||
| delegated-to: none, | ||
| signing-key: signing-key }) | ||
|
|
||
| ;; return the lock-up information, so the node can actually carry out the lock. | ||
| (ok { stacker: tx-sender, lock-amount: amount-ustx, unlock-burn-height: (reward-cycle-to-burn-height (+ first-reward-cycle lock-period)) })))) | ||
|
|
@@ -824,12 +828,14 @@ | |
| (ok true)))) | ||
|
|
||
| ;; As a delegate, stack the given principal's STX using partial-stacked-by-cycle | ||
| ;; As a delegate, you need to provide a signing-key used to allocate signature-weight to a valid signer | ||
| ;; Once the delegate has stacked > minimum, the delegate should call stack-aggregation-commit | ||
| (define-public (delegate-stack-stx (stacker principal) | ||
| (amount-ustx uint) | ||
| (pox-addr { version: (buff 1), hashbytes: (buff 32) }) | ||
| (start-burn-ht uint) | ||
| (lock-period uint)) | ||
| (lock-period uint) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here -- can you add a comment to the method doc about the signing key?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated a sentence & added the following to comment doc above function:
|
||
| (signing-key (buff 33))) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jcnelson, we'd like to get this method ( Looking at PoX-3 tests, some candidates to copy over to PoX-4 are All of these tests seem to call into
|
||
| ;; this stacker's first reward cycle is the _next_ reward cycle | ||
| (let ((first-reward-cycle (+ u1 (current-pox-reward-cycle))) | ||
| (specified-reward-cycle (+ u1 (burn-height-to-reward-cycle start-burn-ht))) | ||
|
|
@@ -885,7 +891,8 @@ | |
| first-reward-cycle: first-reward-cycle, | ||
| reward-set-indexes: (list), | ||
| lock-period: lock-period, | ||
| delegated-to: (some tx-sender) }) | ||
| delegated-to: (some tx-sender), | ||
| signing-key: signing-key }) | ||
|
|
||
| ;; return the lock-up information, so the node can actually carry out the lock. | ||
| (ok { stacker: stacker, | ||
|
|
@@ -1022,12 +1029,14 @@ | |
| ;; This method extends the `tx-sender`'s current lockup for an additional `extend-count` | ||
| ;; and associates `pox-addr` with the rewards | ||
| (define-public (stack-extend (extend-count uint) | ||
| (pox-addr { version: (buff 1), hashbytes: (buff 32) })) | ||
| (pox-addr { version: (buff 1), hashbytes: (buff 32) }) | ||
| (updated-signing-key (optional (buff 33)))) | ||
| (let ((stacker-info (stx-account tx-sender)) | ||
| ;; to extend, there must already be an etry in the stacking-state | ||
| ;; to extend, there must already be an entry in the stacking-state | ||
| (stacker-state (unwrap! (get-stacker-info tx-sender) (err ERR_STACK_EXTEND_NOT_LOCKED))) | ||
| (amount-ustx (get locked stacker-info)) | ||
| (unlock-height (get unlock-height stacker-info)) | ||
| (next-signing-key (default-to (get signing-key stacker-state) updated-signing-key)) | ||
| (cur-cycle (current-pox-reward-cycle)) | ||
| ;; first-extend-cycle will be the cycle in which tx-sender *would have* unlocked | ||
| (first-extend-cycle (burn-height-to-reward-cycle unlock-height)) | ||
|
|
@@ -1093,7 +1102,8 @@ | |
| reward-set-indexes: reward-set-indexes, | ||
| first-reward-cycle: first-reward-cycle, | ||
| lock-period: lock-period, | ||
| delegated-to: none }) | ||
| delegated-to: none, | ||
| signing-key: next-signing-key }) | ||
|
|
||
| ;; return lock-up information | ||
| (ok { stacker: tx-sender, unlock-burn-height: new-unlock-ht }))))) | ||
|
|
@@ -1194,12 +1204,14 @@ | |
| (define-public (delegate-stack-extend | ||
| (stacker principal) | ||
| (pox-addr { version: (buff 1), hashbytes: (buff 32) }) | ||
| (extend-count uint)) | ||
| (extend-count uint) | ||
| (updated-signing-key (optional (buff 33)))) | ||
| (let ((stacker-info (stx-account stacker)) | ||
| ;; to extend, there must already be an entry in the stacking-state | ||
| (stacker-state (unwrap! (get-stacker-info stacker) (err ERR_STACK_EXTEND_NOT_LOCKED))) | ||
| (amount-ustx (get locked stacker-info)) | ||
| (unlock-height (get unlock-height stacker-info)) | ||
| (next-signing-key (default-to (get signing-key stacker-state) updated-signing-key)) | ||
| ;; first-extend-cycle will be the cycle in which tx-sender *would have* unlocked | ||
| (first-extend-cycle (burn-height-to-reward-cycle unlock-height)) | ||
| (cur-cycle (current-pox-reward-cycle)) | ||
|
|
@@ -1275,7 +1287,8 @@ | |
| reward-set-indexes: (list), | ||
| first-reward-cycle: first-reward-cycle, | ||
| lock-period: lock-period, | ||
| delegated-to: (some tx-sender) }) | ||
| delegated-to: (some tx-sender), | ||
| signing-key: next-signing-key }) | ||
|
|
||
| ;; return the lock-up information, so the node can actually carry out the lock. | ||
| (ok { stacker: stacker, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.