Skip to content

Commit

Permalink
fix: various swip21 fixes (#4874)
Browse files Browse the repository at this point in the history
  • Loading branch information
istae authored Oct 23, 2024
1 parent c127b31 commit 13fc473
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 4 additions & 6 deletions pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1031,12 +1031,10 @@ func NewBee(
logger.Info("updated new reserve capacity doubling height in the staking contract", "transaction", tx, "new_height", o.ReserveCapacityDoubling)
}

if o.ReserveCapacityDoubling > 0 {
// Check if the staked amount is sufficient to cover the additional neighborhoods.
// The staked amount must be at least 2^h * MinimumStake.
if stake.Cmp(big.NewInt(0).Mul(big.NewInt(1<<o.ReserveCapacityDoubling), staking.MinimumStakeAmount)) < 0 {
logger.Warning("staked amount does not sufficiently cover the additional reserve capacity. Stake should be at least 2^h * 10 BZZ, where h is the number extra doublings.")
}
// Check if the staked amount is sufficient to cover the additional neighborhoods.
// The staked amount must be at least 2^h * MinimumStake.
if o.ReserveCapacityDoubling > 0 && stake.Cmp(big.NewInt(0).Mul(big.NewInt(1<<o.ReserveCapacityDoubling), staking.MinimumStakeAmount)) < 0 {
logger.Warning("staked amount does not sufficiently cover the additional reserve capacity. Stake should be at least 2^h * 10 BZZ, where h is the number extra doublings.")
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/storageincentives/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ func (a *Agent) start(blockTime time.Duration, blocksPerRound, blocksPerPhase ui
a.state.SetHealthy(a.health.IsHealthy())
go a.state.purgeStaleRoundData()

isFrozen, err := a.redistributionStatuser.IsOverlayFrozen(ctx, block)
// check if node is frozen starting from the next block
isFrozen, err := a.redistributionStatuser.IsOverlayFrozen(ctx, block+1)
if err != nil {
a.logger.Error(err, "error checking if stake is frozen")
} else {
Expand Down
4 changes: 4 additions & 0 deletions pkg/storer/reserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ func (db *DB) reserveWorker(ctx context.Context) {

_, _ = db.countWithinRadius(ctx)

if !db.reserve.IsWithinCapacity() {
db.events.Trigger(reserveOverCapacity)
}

for {
select {
case <-ctx.Done():
Expand Down

0 comments on commit 13fc473

Please sign in to comment.