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

Fix staked amount too high after unstake issue #1270

Merged
merged 2 commits into from
Jun 20, 2024

Conversation

Dinonard
Copy link
Member

@Dinonard Dinonard commented Jun 19, 2024

Issue Description

Fixes the issue where the unstake call wouldn't correctly update future era staked amount.
E.g. for a situation where we have:

  • staked: { era: 10, amount: 20 }, future_staked: { era: 11, amount: 21 }
  • staker calls unstake(era: 10, amount: 5)
  • state is incorrectly updated to: staked: {era: 10, amount: 15}, future_staked: {era: 11, amount: 21}
  • the future era amount isn't correctly reduced, resulting in ContractStake remaining too high for a contract

Consequence

dApps might have ended up in higher tier than they were supposed to.
No actions will be taken around this - whatever dApps earned, it's theirs.

Fix

When unstake operation is performed on SingularStakingInfo struct, it will now correctly account for the scenario where potential future era amount also needs to be reduced.

@Dinonard Dinonard added shiden related to shiden runtime astar Related to Astar shibuya related to shibuya runtime This PR/Issue is related to the topic “runtime”. labels Jun 19, 2024
@Dinonard Dinonard self-assigned this Jun 19, 2024
@Dinonard Dinonard marked this pull request as ready for review June 19, 2024 13:41
Copy link

Code Coverage

Package Line Rate Branch Rate Health
precompiles/sr25519/src 64% 0%
precompiles/xvm/src 75% 0%
pallets/dapp-staking-v3/src/test 0% 0%
precompiles/substrate-ecdsa/src 74% 0%
pallets/dapp-staking-v3/src/benchmarking 98% 0%
precompiles/dapp-staking-v3/src/test 0% 0%
precompiles/dapp-staking-v3/src 90% 0%
pallets/collator-selection/src 92% 0%
chain-extensions/types/xvm/src 0% 0%
precompiles/dispatch-lockdrop/src 86% 0%
pallets/inflation/src 83% 0%
pallets/xc-asset-config/src 64% 0%
precompiles/xcm/src 73% 0%
primitives/src 62% 0%
pallets/dynamic-evm-base-fee/src 92% 0%
chain-extensions/xvm/src 0% 0%
precompiles/assets-erc20/src 81% 0%
pallets/astar-xcm-benchmarks/src/generic 100% 0%
chain-extensions/pallet-assets/src 56% 0%
pallets/unified-accounts/src 86% 0%
pallets/oracle-benchmarks/src 0% 0%
pallets/static-price-provider/src 52% 0%
pallets/dapp-staking-migration/src 0% 0%
chain-extensions/unified-accounts/src 0% 0%
pallets/astar-xcm-benchmarks/src 88% 0%
pallets/price-aggregator/src 72% 0%
chain-extensions/types/assets/src 0% 0%
pallets/xvm/src 54% 0%
pallets/dapp-staking-v3/src 90% 0%
chain-extensions/types/unified-accounts/src 0% 0%
precompiles/unified-accounts/src 100% 0%
pallets/astar-xcm-benchmarks/src/fungible 100% 0%
pallets/ethereum-checked/src 79% 0%
pallets/dapp-staking-v3/rpc/runtime-api/src 0% 0%
primitives/src/xcm 64% 0%
Summary 77% (3647 / 4717) 0% (0 / 0)

Minimum allowed line rate is 50%

@Dinonard Dinonard merged commit 602c1c6 into master Jun 20, 2024
9 checks passed
@Dinonard Dinonard deleted the fix/dapp-staking-contract-stake-issue branch June 20, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astar Related to Astar runtime This PR/Issue is related to the topic “runtime”. shibuya related to shibuya shiden related to shiden runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants