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

MIN_STAKE not enforced #277

Open
ldeffenb opened this issue Nov 12, 2024 · 0 comments
Open

MIN_STAKE not enforced #277

ldeffenb opened this issue Nov 12, 2024 · 0 comments

Comments

@ldeffenb
Copy link

ldeffenb commented Nov 12, 2024

In Staking.sol, the MIN_STAKE is only enforced if the node is not already staked.

if (_addAmount < MIN_STAKE * 2 ** _height && _stakingSet == 0) {
revert BelowMinimumStake();
}

This means that if a node initially stakes 10 BZZ (MIN_STAKE) at a height of zero and subsequently increases that height to 1 via reserve-capacity-doubling, the new stake is not validated to cover the increased number of neighborhoods. This newly doubled node is now able to compete in two different neighborhoods with an effective stake of 5 BZZ in each of them.

The bee source does have a warning log in this situation, but the storage incentives agent will compete in every selected round with the below-minimum stake.
https://github.com/ethersphere/bee/blob/9e388ed3535710d7126188120c3665c3a2864149/pkg/node/node.go#L1037-L1039

You can see this in action between the following two manageStake transactions followed by the node competing the next time one of its selected neighborhoods was selected. (Yes, this node is running a reserve-capacity-doubling value of 2 resulting in 4 covered neighborhoods.)

Stake 10 sBZZ height 0:
https://sepolia.etherscan.io/tx/0x067df4b88a47cb89521a4052077ed98124d08dfdf952c09fd32c44bddfbac6be

Increase height to 2:
https://sepolia.etherscan.io/tx/0x4e59edbb38eac6a7d7c8b41485d3bccd202eeccb170156b7e1fe43de8224d0c7

Commit showing height 2 in the logs:
https://sepolia.etherscan.io/tx/0x5c301416ff14adea3c1fb881c7b6bcb286b209c703344d4148762eca99b7aa7a#eventlog

Reveal showing effective stake of 10/2^2 or 2.5 BZZ times 2^3 (depth) giving a stakeDensity of only 20 when the MIN_STAKE at depth 3 is 80:
https://sepolia.etherscan.io/tx/0x27624efec71b215ecaa2c78ac11a729dff1628fbf5a6ac048c847fba3ae669f7#eventlog

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