Skip to content
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

Add cycle-id ranges to synthetic pox events #4414

Merged
merged 12 commits into from Mar 14, 2024
Merged

Conversation

zone117x
Copy link
Member

@zone117x zone117x commented Feb 22, 2024

Fixes #4413

WIP:

  • Add start-cycle-id to pox events
  • Add end-cycle-id to pox events
  • Tests

@zone117x zone117x requested a review from kantai February 22, 2024 18:10
Copy link

codecov bot commented Feb 22, 2024

Codecov Report

Attention: Patch coverage is 93.91892% with 36 lines in your changes are missing coverage. Please review.

Project coverage is 73.15%. Comparing base (87347e4) to head (1e14b29).
Report is 13 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #4414      +/-   ##
==========================================
- Coverage   83.10%   73.15%   -9.95%     
==========================================
  Files         453      453              
  Lines      327459   328034     +575     
  Branches      323      323              
==========================================
- Hits       272122   239972   -32150     
- Misses      55329    88054   +32725     
  Partials        8        8              
Files Coverage Δ
...tackslib/src/chainstate/stacks/boot/pox_4_tests.rs 80.08% <97.37%> (-19.60%) ⬇️
pox-locking/src/events.rs 81.23% <76.28%> (-9.41%) ⬇️

... and 225 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 87347e4...1e14b29. Read the comment docs.

@zone117x zone117x marked this pull request as ready for review February 23, 2024 10:55
@zone117x zone117x linked an issue Feb 23, 2024 that may be closed by this pull request
hstove
hstove previously approved these changes Feb 23, 2024
Copy link
Contributor

@hstove hstove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good, and tests will catch any Clarity errors, right? It would be nice to have tests for these new event keys.

@kantai
Copy link
Member

kantai commented Feb 23, 2024

Yes -- the existing pox-4 tests would invoke these paths. Those tests should be expanded to check the event receipts though.

pox-locking/src/events.rs Outdated Show resolved Hide resolved
pox-locking/src/events.rs Outdated Show resolved Hide resolved
@saralab saralab requested a review from setzeus March 7, 2024 14:58
pox-locking/src/events.rs Outdated Show resolved Hide resolved
@8marz8
Copy link
Contributor

8marz8 commented Mar 8, 2024

I took @hstove 's suggestion and chaned end-cycle-id to an optional since it was relying on an optional (until_burn_height) for calculation in delegate-stx.

The test ensures that the events are emitted without Clarity parsing issues BUT, I am not sure about the values I am asserting against at all - I basically filled those from what was being returned so @zone117x @hstove @kantai please check if those values actually make sense for what was intended here.

@8marz8 8marz8 force-pushed the feat/pox-events-cycle-data branch from 6728855 to a5d514b Compare March 8, 2024 05:27
@zone117x
Copy link
Member Author

zone117x commented Mar 8, 2024

Thanks for the help with this @8marz8! I'm going to test this in an end-to-end environment because I'm also not totally sure if the cycle ids in the tests are accurate or not.

@8marz8 8marz8 force-pushed the feat/pox-events-cycle-data branch from a5a2bfb to 503afd9 Compare March 8, 2024 20:51
Copy link
Contributor

@hstove hstove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@8marz8 so for the check against Steph's stack-stx, the assertion is that start-cycle-id is 22 and end-cycle-id is 24. Steph made the transaction during 22, with a lock period of 1. So she would start stacking in 23, and end at the start of 24. This might be ok if we said "the user starts stacking in the cycle after start-cycle-id, but we just need to be consistent with these events. This is also kinda subjective, I'm curious of @zone117x 's thoughts.

Then for the stack-increase check, both the start and end are 24. When calling stack increase, you don't change your cycles at all, you're just adding more to the existing cycles. So in my opinion, this should match the stack-stx behavior, especially because the tx is made in the same cycle as the stack-stx tx.

This is very close though, nice job!

pox-locking/src/events.rs Outdated Show resolved Hide resolved
stackslib/src/chainstate/stacks/boot/pox_4_tests.rs Outdated Show resolved Hide resolved
pox-locking/src/events.rs Show resolved Hide resolved
@zone117x
Copy link
Member Author

the assertion is that start-cycle-id is 22 and end-cycle-id is 24. Steph made the transaction during 22, with a lock period of 1. So she would start stacking in 23, and end at the start of 24. This might be ok if we said "the user starts stacking in the cycle after start-cycle-id, but we just need to be consistent with these events. This is also kinda subjective, I'm curious of @zone117x 's thoughts.

In this case I think we'd want start-cycle-id to be 23, because we are using these IDs to match against reward set data. So IIUC we don't care about when stx are locked, we care about when stx are committed. Does that make sense, or is my understanding/terminology correct here?

@janniks
Copy link
Contributor

janniks commented Mar 12, 2024

✅ Updated this PR to match my understanding of what the range queries should achieve from a consumer perspective (be able to use event data for reward/voting-power calculations). I hope I haven't misinterpreted anything here.

  • Update test to use dynamic cycle id and lock periods -- using the assumption: start-cycle-id == next_cycle by default, (if not in prepare phase case)
  • Update aggregation functions to have start&end == {reward_cycle} (they don't span multiple cycles)
  • Update prepare_offsets to always be based on current burn_height (this could be hardcoded into the prepare snippet)
  • Removed let/prepare_offset blocks where not needed
  • Increase methods will use the normal current burn_height for "start" and re-use the previous "end". (Careful: this will generate [contained] overlapping ranges, either use the never one or modify the existing entry on ingest)
  • Extend methods are the same but use the new unlock-ht for "end". (Careful: same warnings apply, but with an [protruding] overlap here)

@zone117x zone117x requested a review from hstove March 13, 2024 10:21
hstove
hstove previously approved these changes Mar 13, 2024
Copy link
Contributor

@hstove hstove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice improvements and tests @janniks !

@zone117x zone117x requested a review from obycode March 14, 2024 12:56
@zone117x zone117x enabled auto-merge March 14, 2024 14:27
@zone117x zone117x added this pull request to the merge queue Mar 14, 2024
Merged via the queue into next with commit 86fdb80 Mar 14, 2024
1 of 2 checks passed
ASuciuX added a commit to ASuciuX/stacks-core that referenced this pull request Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add cycle-id ranges to synthetic pox events
5 participants