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

feat: fix bugs with status command #143

Merged
merged 2 commits into from
Aug 29, 2024
Merged

Conversation

wadealexc
Copy link
Contributor

@wadealexc wadealexc commented Aug 28, 2024

  1. fix a bug where we pulled the beacon state head even if we have an old checkpoint
  2. fix a bug where we compute the wrong diff if the pod owner queues a withdrawal
  3. still an outstanding bug: i think sumRestakedBalancesGwei also needs to use a prior state if we have an existing checkpoint

see comments below for explanation and testing

* fix a bug where we pulled the beacon state head even if we have an old checkpoint
* fix a bug where we compute the wrong diff if the pod owner queues a withdrawal
* still some outstanding bugs:
* i think `sumRestakedBalancesGwei` also needs to use a prior state if we have an existing checkpoint
* i ended up completing a 2 day old checkpoint and while status was _more_ accurate than the existing command off master, it was off by a bit. possibly precision issues? idk
@wadealexc
Copy link
Contributor Author

wadealexc commented Aug 29, 2024

Sharing some screenshots displaying bugfix # 1.

Running status on our preprod test pod, which has had a checkpoint active since yesterday, the master branch shows:

image

As you can see, the master branch uses the head state. This branch downloads the correct state:

image

@wadealexc
Copy link
Contributor Author

Bug # 2 explanation:

This bug occurs when the pod owner queues a withdrawal in the DelegationManager. The bug is that queuing a withdrawal results in a decrease of shares - so you had 32 ETH of shares, then you queued a withdrawal, now you have 0 ETH of shares.

When a checkpoint is completed in the pod, the change in shares is applied as a delta - so if you have gained 0.01 ETH, the checkpoint would add 0.01 ETH to your current shares, for a new total share count of 0.01 ETH.

The CLI bug here is that the master branch version computes your new shares as a total share value, rather than a delta. It sees that you have 32.01 ETH total assets, so assumes that completing the checkpoint will result in 32.01 ETH worth of shares. Since we have 0 ETH worth of shares at the moment due to our queued withdrawal, the master branch will assume that completing a checkpoint will result in a diff of 32.01 ETH.

The change in this PR correctly calculates a delta rather than using a total.

@wadealexc
Copy link
Contributor Author

Bug # 2 testing:

To test this change, I am manually altering the value returned when the status command fetches currentOwnerShares (on both master and this branch):

https://github.com/layr-labs/eigenpod-proofs-generation/blob/4acc4b03c09df33855c6d97467476f563cc3508c/cli/core/status.go#L157

This effectively simulates running the status command after the user has queued a withdrawal for all their shares. Then, running status command on master yields:

image

As you can see, master assumes we can get 64 ETH worth of shares from a checkpoint. This PR fixes this:

image

@wadealexc
Copy link
Contributor Author

Bug # 3 explanation:

If we have partially completed a checkpoint, status will not correctly compute the share diff for finishing the checkpoint. This is because it will base the beacon chain ETH delta portion of the share diff on the current checkpoint state, which has already ingested a few updated validator balances.

Those validators' balance diffs will not be accounted for in the delta the CLI calculates. To fix this I need to consider whether there's a way to use checkpoint.balanceDeltasGwei to correct the diff. Alternatively we can use the ETH rpc to read the pod's state when the checkpoint was started rather than partway through.

Not sure what's better here. TBH I think this is a fairly minor issue and the PR here is already a good improvement, so this might be something we want to earmark for a future fix.

@wadealexc wadealexc marked this pull request as ready for review August 29, 2024 16:59

if checkpointTimestamp != 0 {
// Change in the pod's native ETH balance (already calculated for us when the checkpoint was started)
nativeETHDeltaGwei = new(big.Float).SetUint64(checkpoint.PodBalanceGwei)
Copy link
Contributor

Choose a reason for hiding this comment

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

PodBalanceGwei is the delta?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep! it's calculated when the checkpoint is started on chain

Copy link
Contributor Author

Choose a reason for hiding this comment

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

probably couldve been named better 😬

Copy link
Contributor

@jbrower95 jbrower95 left a comment

Choose a reason for hiding this comment

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

I can clean this all up tomorrow. Your testing seems exhaustive, and I've run a few more scenarios on my side as well.

@jbrower95 jbrower95 merged commit d7a76a2 into master Aug 29, 2024
4 checks passed
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.

2 participants