-
Notifications
You must be signed in to change notification settings - Fork 671
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
PoX 2 Unlock #3260
PoX 2 Unlock #3260
Conversation
Codecov Report
@@ Coverage Diff @@
## next #3260 +/- ##
===========================================
- Coverage 83.92% 29.91% -54.01%
===========================================
Files 277 279 +2
Lines 227444 228223 +779
===========================================
- Hits 190880 68282 -122598
- Misses 36564 159941 +123377
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
;; calculate the index into the reward-set-indexes that `cycle` is at | ||
(moved-cycle-index (- cycle (get first-reward-cycle moved-state))) | ||
(moved-reward-list (get reward-set-indexes moved-state)) | ||
;; reward-set-indexes[moved-cycle-index] = set-index via slice, append, concat. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A pity that there isn't a set-element-at
keyword in Clarity for sequences. Maybe this could be a separate function that makes this clear? Then we could at least point it out to developers if they want to do the equivalent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a private method in 266caf2.
It would be pretty easy to add a new Clarity built-in for this, though. I might try to include in the stacks-increase PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be supportive!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly lgtm, just some minor comments
); | ||
for _i in 0..slots_taken { | ||
test_debug!("Add to PoX reward set: {:?}", &address); | ||
reward_set.push(address.clone()); | ||
} | ||
// if stacker did not qualify for a slot *and* they have a stacker | ||
// pointer set by the PoX contract, then add them to auto-unlock list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The case where they wouldn't have a stacker pointer is if they were in a pool, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep -- if they used delegation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pretty much LGTM. Thanks @kantai!
I just had one remaining design question about how to handle unlocks across reward cycle boundaries, which is still detailed in the comments. Let's get that addressed before merging. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for taking the time to address this @kantai! Users are gonna love auto-unlocks :D
self.inner_execute_contract(contract, tx_name, args, read_only, true) | ||
} | ||
|
||
fn inner_execute_contract( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can add a note on this function directly that specifies that allow_private
must always be false when doing user tx processing
|
||
#[derive(Debug, PartialEq, Serialize, Deserialize)] | ||
pub struct PoxStartCycleInfo { | ||
pub missed_reward_slots: Vec<(PrincipalData, u128)>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add comment about what PrincipalData
and u128 are referring to
// peak at the next address in the set, and see if we need to sum | ||
while addresses.last().map(|x| &x.0) == Some(&address) { | ||
let (_, additional_amt) = addresses | ||
while addresses.last().map(|x| &x.reward_address) == Some(&address) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the logic here, but it could be useful to leave a comment for posterity: The outer while loop pops the last element of the addresses vector, here we call last()... and since the addresses are sorted...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
for the future though, I think it would be desirable for the pox contract to have some meta documentation.
Fixed the CI tasks by switching to stable (thanks @lgalabru for pointing out that grcov works in stable now!), though it seems like the unit-tests tasks didn't successfully upload the coverage data. Will poke into that separately, but merging this PR now because the tests are passing, and its been approved. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR implements automatic unlocks for PoX 2.
Stackers who do not qualify for a slot in a reward set when the reward set is selected will be automatically unlocked after the reward set is selected. The auto unlock occurs 1 bitcoin block after the auto-unlock.
This requires a lot of complexity in
pox-2
. This PR adds a test for the simple use case, but probably more testing is needed.