Skip to content

MIN_STAKE not enforced #277

@ldeffenb

Description

@ldeffenb

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions