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

chore: Add inclusion height to early unbonding event #228

Merged
merged 3 commits into from
Oct 25, 2024

Conversation

gitferry
Copy link
Member

@gitferry gitferry commented Oct 24, 2024

Closes #225.

  • added unbonding start height to early unbonding event
  • changed that early unbonding event is emitted as a tx event

@gitferry gitferry added consensus breaking change modifies `appHash` of the application api breaking breaks grpc api in non-compatible way backport release/v0.14.x labels Oct 24, 2024
@gitferry gitferry marked this pull request as ready for review October 24, 2024 03:37
@gitferry gitferry requested a review from a team as a code owner October 24, 2024 03:37
@gitferry gitferry requested review from KonradStaniec, samricotta and jrwbabylonlab and removed request for a team October 24, 2024 03:37
message DelegatorUnbondingInfo {
// spend_stake_tx is the transaction which spent the staking output. It is
// filled only if spend_stake_tx is different than unbonding_tx registered
// on the Babylon chain.
bytes spend_stake_tx = 1;
// inclusion_height is the height of the block in which the spend_staking_tx is included
uint32 inclusion_height = 2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

So this makes me a bit nervous, as due to re-orgs is is possible that this inclusion height can change. So we can be left with data is database that do not match reality.

In other words, I am fine with putting this info in event which is kind of ephemeral thing and we can treat it as inclusion height at the time of receiving unbonding transaction on BTC but I am not too sure about storing this data in database.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that re-orgs can cause mismatch issues. The tricky thing is that in our current flow, we deal with undelegate in message handler but deal with the relevant event in BeginBlocker. This means that the inclusion height is passed via db write and read. If we don't want to store the height in db, we would have to emit the early unbonding event in the message handler directly. So, two options:

  1. leave it what it is with a note that the inclusion height is subjective to re-orgs, maybe rename it to reported_inclusion_height as it is only used for emitting events for now
  2. do not store the inclusion height but emit the early unbonding event in the message handler. This will change the logic of handling delegation events a bit and make the early unbonding a tx event

I'll try with option 2 to see if it could work without significant change

Choose a reason for hiding this comment

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

@gitferry for (2), does it only work for new events, or it can be replayed?

Copy link
Collaborator

Choose a reason for hiding this comment

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

2 would most probably work but then: expiration event would be block event, and early unbonding would be transaction event. It is a bit inconsistent from api perspective, but I prefer that over storing inconsistent data in state tbh.

Copy link
Member Author

Choose a reason for hiding this comment

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

it can be replayed just like other events

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @jrwbabylonlab and @KonradStaniec for the discussion. I have changed it to (2) in 59bfc27.

@jrwbabylonlab please keep in mind that early unbonding will be a tx event while expired unbonding is still a block event.

Btw, do we want to backport it to release/v0.14.x?

@gitferry gitferry changed the title chore: Add inclusion height to unbonding chore: Add inclusion height to early unbonding event Oct 24, 2024
@gitferry gitferry removed the consensus breaking change modifies `appHash` of the application label Oct 24, 2024
@gitferry gitferry force-pushed the chore/add-unbonding-height-in-event branch from 8dd0da3 to 59bfc27 Compare October 24, 2024 13:49
Copy link
Collaborator

@KonradStaniec KonradStaniec left a comment

Choose a reason for hiding this comment

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

Looks good 👍

I think we can backport it and release 0.14.1, as it is not consensus breaking

@gitferry gitferry merged commit 77462ca into main Oct 25, 2024
20 checks passed
@gitferry gitferry deleted the chore/add-unbonding-height-in-event branch October 25, 2024 01:15
gitferry added a commit that referenced this pull request Oct 25, 2024
Closes #225.

* added unbonding start height to early unbonding event
* changed that early unbonding event is emitted  as a tx event
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api breaking breaks grpc api in non-compatible way backport release/v0.14.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Insert unbonding height to early unbonding event
3 participants