Skip to content

Commit

Permalink
fix: bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
istae committed Aug 4, 2023
1 parent 44dd232 commit c9b524f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
19 changes: 1 addition & 18 deletions pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"fmt"
"io"
stdlog "log"
"math"
"math/big"
"net"
"net/http"
Expand Down Expand Up @@ -982,22 +981,6 @@ func NewBee(
return uint8(radius.Load()), nil
}

maxReserveRadius := func() (uint8, error) {

commitment, err := batchStore.Commitment()
if err != nil {
return 0, fmt.Errorf("commitment: %w", err)
}

if commitment <= ReserveCapacity {
return 0, nil
} else {
// totalCommitment/node_capacity = 2^R
// log2(totalCommitment/node_capacity) = R
return uint8(math.Ceil(math.Log2(float64(commitment) / float64(ReserveCapacity)))), nil
}
}

pusherService := pusher.New(networkID, localStore, networkRadiusFunc, pushSyncProtocol, validStamp, logger, tracer, warmupTime, pusher.DefaultRetryCount)
b.pusherCloser = pusherService

Expand Down Expand Up @@ -1052,7 +1035,7 @@ func NewBee(
pullerService = puller.New(stateStore, kad, localStore, pullSyncProtocol, p2ps, logger, puller.Options{})
b.pullerCloser = pullerService

localStore.StartReserveWorker(ctx, pullerService, maxReserveRadius)
localStore.StartReserveWorker(ctx, pullerService, networkRadiusFunc)
nodeStatus.SetSync(pullerService)

if o.EnableStorageIncentives {
Expand Down
20 changes: 14 additions & 6 deletions pkg/storer/reserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,20 @@ func (db *DB) startReserveWorkers(

// possibly a fresh node, acquire initial radius externally
if initialRadius == 0 {
r, err := radius()
if err != nil {
db.logger.Error(err, "reserve worker initial radius")
} else {
initialRadius = r
}

// August 4, 2023 18:47 CET, storage radius is 9 on the mainnet.
// Because the initial radius is acquired from the network, the radius needs to be boostrapped at
// the time of the release. The bootstrap needs to be removed after the release.
initialRadius = 9

/*
r, err := radius()
if err != nil {
db.logger.Error(err, "reserve worker initial radius")
} else {
initialRadius = r
}
*/
}

if err := db.reserve.SetRadius(db.repo.IndexStore(), initialRadius); err != nil {
Expand Down

0 comments on commit c9b524f

Please sign in to comment.