-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[rosetta] Fix staking balances #15247
Conversation
⏱️ 2h 3m total CI duration on this PR
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Looks good, the only logical change I see is the if statements for base, pool staking, and account staking as stated in the description.
Ok(Some(balance_result)) => { | ||
if let Some(balance) = balance_result.balance { | ||
has_staking = true; | ||
total_balance += u64::from_str(&balance.value).unwrap_or_default(); |
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.
Just to confirm, this isn't a 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.
User balance is a u64, but I can just change them all to u128 since they're being converted to and from strings
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.
Actually nevermind it will always be a u64
the last refactor made it get staking balances and the account's balance this should fix it so it never cross contaminates between staking, delegated staking, and normal balances. It's much more straightforward and should be easier to understand.
67b6773
to
d69cd07
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
the last refactor made it get staking balances and the account's balance this should fix it so it never cross contaminates between staking, delegated staking, and normal balances. It's much more straightforward and should be easier to understand. (cherry picked from commit 7d6d59c)
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
Description
This cleans up and ensures that Rosetta only returns either the base account balances, the staking balances, or the delegated staking balances. It will never return all three at the same time.
How Has This Been Tested?
Tested against existing accounts on mainnet with a local version. Prior version would return the account's balance and stake together, when requesting stake.
Now it only returns the balance
Key Areas to Review
Logically, this should be the same as before. The main issue was the fallthrough behavior that would handle the base account path on every path. Instead it should only be handled on the base path, where staking should do the staking path.
Type of Change
Which Components or Systems Does This Change Impact?
Checklist