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

Stake may able to unlock before the StakeWithdrawalLockingPeriod pass in the first challenge period #2971

Open
NingLin-P opened this issue Aug 13, 2024 · 0 comments

Comments

@NingLin-P
Copy link
Member

When an operator/nominator deregisters or withdraws stake, the stake is only able to unlock after StakeWithdrawalLockingPeriod number of domain blocks:

let latest_confirmed_domain_block_number =
Pallet::<T>::latest_confirmed_domain_block_number(operator.current_domain_id);
let unlock_at_confirmed_domain_block_number = latest_confirmed_domain_block_number
.checked_add(&T::StakeWithdrawalLockingPeriod::get())
.ok_or(Error::BlockNumberOverflow)?;

But because we are using the confirmed domain block number to calculate the unlocked block number, in the first challenge period of a new instantiated domain, the latest_confirmed_domain_block_number is always zero since only the genesis receipt is confirmed, as a result, anyone deregister/withdraw in the first challenge period will be able to unlock at the same block 0 + StakeWithdrawalLockingPeriod, no matter it is deregistered/withdraw at the first block or the last of the challenge period. So the attacker may able to submit a bad ER and deregister in the last block of the challenge period and unlock its fund in the next block before it is slashed by fraud proof.

To fix it we should use the head domain number to calculate the unlocked block number: HeadDomainNumber + StakeWithdrawalLockingPeriod

cc @vedhavyas @dariolina

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

No branches or pull requests

1 participant