Skip to content

fix: min floor when height > 0 - #5654

Merged
sbackend123 merged 3 commits into
masterfrom
fix/staking-height-deposit-floor
Oct 9, 2026
Merged

sbackend123 merged 3 commits into
masterfrom
fix/staking-height-deposit-floor

Conversation

@sbackend123

Copy link
Copy Markdown
Contributor

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have added or updated fuzz targets for any code handling untrusted input.
  • I have filled out the description and linked the related issues.

Description

On the contract side, the MIN × 2^height floor applies only to the first stake (lastUpdatedBlockNumber == 0). If the price drops by half, 1 PLUR does not decrease the commitment, and the contract records height 1 with a stake of 10^17. A new node at that height must deposit 2×10^17.

#5571 removed the client-side check potential + deposit >= MIN × 2^height. This PR restores it when height > 0

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

Related Issue (Optional)

Screenshots (if appropriate):

AI Disclosure

  • This PR contains code that has been generated by an LLM.
  • I have reviewed the AI generated code thoroughly.
  • I possess the technical expertise to responsibly review the code generated in this PR.


var minErr *staking.MinDepositError
if errors.As(err, &minErr) {
return // correct: deposit refused below the height floor

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This branch can't be reached: the test deposits exactly what GetMinDeposit returned, which DepositStake always accepts. And if no manageStake is sent at all, sentHeight stays nil and the test passes without checking anything.

Something tighter could be: GetMinDeposit returns MIN*2^h - potential; depositing one PLUR less returns *MinDepositError; depositing the reported minimum sends manageStake with height h and potential + deposit >= MIN*2^h. Also t.Fatal if sentHeight == nil.

@sbackend123
sbackend123 merged commit cc5c470 into master Oct 9, 2026
17 checks passed
@sbackend123
sbackend123 deleted the fix/staking-height-deposit-floor branch October 9, 2026 12:55
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.

3 participants