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

Allow multiple redemptions per epoch #1009

Merged
merged 10 commits into from
Jan 8, 2024

Conversation

asalzmann
Copy link
Contributor

@asalzmann asalzmann commented Dec 5, 2023

Context and purpose of the change

Currently, and address can only redeem once per epoch. This was simpler to implement, but multiple redemptions per epoch are required to add redemptions to autopilot.

Brief Changelog

  • If a user has already redeemed, add the redemption amount to their UserRedemptionRecord (instead of creating a new one)
  • If a user has already redeemed, don't append the UserRedemptionRecord ID to the HostZoneUnbonding

The rest of the logic should work without being changed, but please review this carefully and think about potential ways it could break.

TODOs

  • Integration test
  • Unittest
  • Think deeply about protocol design

@asalzmann asalzmann changed the title multiple redemptions Allow multiple redemptions per epoch Dec 5, 2023
@asalzmann asalzmann requested a review from a team December 5, 2023 02:37
@sampocs sampocs added the v17 label Dec 6, 2023
Copy link
Collaborator

@sampocs sampocs left a comment

Choose a reason for hiding this comment

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

lgtm!

waiting to approve until the unit test is in here

x/stakeibc/keeper/msg_server_redeem_stake.go Outdated Show resolved Hide resolved
x/stakeibc/keeper/msg_server_redeem_stake.go Show resolved Hide resolved
x/stakeibc/keeper/msg_server_redeem_stake.go Show resolved Hide resolved
Copy link
Contributor

@riley-stride riley-stride left a comment

Choose a reason for hiding this comment

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

Looking good! Added one question. Waiting until integration and unit tests to approve.

x/stakeibc/keeper/msg_server_redeem_stake.go Outdated Show resolved Hide resolved
x/stakeibc/keeper/msg_server_redeem_stake.go Show resolved Hide resolved
x/stakeibc/keeper/msg_server_redeem_stake.go Show resolved Hide resolved
@sampocs
Copy link
Collaborator

sampocs commented Dec 15, 2023

Just pushed up a unit test. I also tested manually and it worked as expected

I think adding this to our long standing integrations tests is actually not as straightforward as it seems. But imo, I think the unit test is sufficient coverage

Copy link
Collaborator

@sampocs sampocs left a comment

Choose a reason for hiding this comment

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

One other issue - the record is key'd by just stride address. So if someone redeems twice with the same stride address, but a different receiver address, the second address will get ignored

I think this leaves us with the original attack vector.

First solution that comes to mind is the change the URR key, but that will require a painful migration. Curious if you guy can think of a better solution

Copy link
Contributor

@shellvish shellvish left a comment

Choose a reason for hiding this comment

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

Looks great to me! We should add integration tests on top of the unit test, then I'm all signed off 🙂

Happy to add the integration tests too if that would be helpful!

Copy link

github-actions bot commented Jan 2, 2024

This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you!

@github-actions github-actions bot added the Stale label Jan 2, 2024
Co-authored-by: riley-stride <104941670+riley-stride@users.noreply.github.com>
@asalzmann
Copy link
Contributor Author

Just pushed up a unit test. I also tested manually and it worked as expected

@sampocs is this unittest sufficient, or should I add more?

One other issue - the record is key'd by just stride address. So if someone redeems twice with the same stride address, but a different receiver address, the second address will get ignored
I think this leaves us with the original attack vector.
First solution that comes to mind is the change the URR key, but that will require a painful migration. Curious if you guy can think of a better solution

I think where we landed was to replace the sender address with the receiver - @sampocs did you happen to take notes on that call?

@sampocs
Copy link
Collaborator

sampocs commented Jan 3, 2024

@asalzmann

is this unittest sufficient, or should I add more?

Imo, it's sufficient - was there something else you thought should be included though?

I think where we landed was to replace the sender address with the receiver - @sampocs did you happen to take notes on that call?

Yeah we landed on replacing sender with receiver. This is done in #1035

Notes from that call are at the bottom of the PFM + Autopilot doc and are in the upgrade channel.

@github-actions github-actions bot removed the Stale label Jan 4, 2024
Copy link
Contributor

@shellvish shellvish left a comment

Choose a reason for hiding this comment

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

LGTM!

@sampocs sampocs added the A:automerge Automatically merge PR once checks pass label Jan 8, 2024
@mergify mergify bot merged commit b0750c2 into main Jan 8, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants