Staking precision/rounding anomaly
Describe the Bug Intermittent precision/rounding anomaly when staking via the precompile. Occasionally, staking an exact integer amount (e.g., 10 ZETA) results in the delegation being recorded as 9.999999999999999999 ZETA, followed by an automatic creation of a separate delegation for the residual 0.000000000000000001 ZETA after undelegation.
To Reproduce
Stake exactly 10 ZETA through the staking precompile.
Observe the resulting delegation amount.
If the recorded delegation shows 9.999999999999999999 ZETA, undelegate the full displayed amount.
Observe that a new delegation appears for the remainder 0.000000000000000001 ZETA.
This one works:
cast send 0x0000000000000000000000000000000000000800 \
"delegate(address,string,uint256)" \
0x4955a3F38ff86ae92A914445099caa8eA2B9bA32 \
"zetavaloper15ruj2tc76pnj9xtw64utktee7cc7w6vzeegzu5" \
1000000000000000000 \
--rpc-url https://zetachain-athens-evm.blockpi.network/v1/rpc/public \
--private-key $PRIVATE_KEY \
--value 1000000000000000000
This one reproduced the issue:
cast send 0x0000000000000000000000000000000000000800 \
"delegate(address,string,uint256)" \
0x4955a3F38ff86ae92A914445099caa8eA2B9bA32 \
"zetavaloper15ruj2tc76pnj9xtw64utktee7cc7w6vzeegzu5" \
300000000000000000 \
--rpc-url https://zetachain-athens-evm.blockpi.network/v1/rpc/public \
--private-key $PRIVATE_KEY \
--value 300000000000000000
https://zetachain-athens.blockpi.network/lcd/v1/public/cosmos/staking/v1beta1/delegations/zeta1f9268uu0lp4wj253g3zsn892363tnw3jlvjfx3
Notes:
Behavior is intermittent: sometimes the stake is recorded as the exact integer (10 ZETA), other times it’s off by 1e-18.
The stake transaction input is exactly 10 ZETA in all cases.
Expected Behavior
Staking an integer amount (e.g., 10 ZETA) should consistently result in an exact 10 ZETA delegation with no residual “dust.”
Undelegating the full staked amount should not leave a leftover micro-fractional delegation.
Actual Behavior
Sometimes 10 ZETA → 9.999999999999999999 ZETA recorded.
When undelegating that amount, a new delegation appears for the remaining 0.000000000000000001 ZETA.
Screenshots
Environment (please complete the following information):
OS: macOS
Version used:
- Binary: v34.1.0
- Cast
- Precompile: 0x0000000000000000000000000000000000000800
Wallet/SDK: zetacored and Hub
Updating the PR title as it is not linked to the precompile
Issue was already existing (currently on mainnet), and happen when staking to a validator that was previously jailed
We can track this issue on the sdk https://github.com/cosmos/cosmos-sdk/issues/25263
older issue shared by stefan for reference https://github.com/cosmos/gaia/issues/1229