Skip to content

Commit

Permalink
fix: turn off immutable header (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
istae authored Sep 14, 2023
1 parent 64a91f8 commit 57ad84f
Show file tree
Hide file tree
Showing 19 changed files with 30 additions and 33 deletions.
8 changes: 4 additions & 4 deletions pkg/bee/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func (c *Client) Settlement(ctx context.Context, a swarm.Address) (resp Settleme
}

// CreatePostageBatch returns the batchID of a batch of postage stamps
func (c *Client) CreatePostageBatch(ctx context.Context, amount int64, depth uint64, gasPrice, label string, verbose bool) (string, error) {
func (c *Client) CreatePostageBatch(ctx context.Context, amount int64, depth uint64, label string, verbose bool) (string, error) {
if depth < MinimumBatchDepth {
depth = MinimumBatchDepth
}
Expand All @@ -374,7 +374,7 @@ func (c *Client) CreatePostageBatch(ctx context.Context, amount int64, depth uin
}
c.logger.Infof("reserve state (prior to buying the batch):%s", rs.String())
}
id, err := c.debug.Postage.CreatePostageBatch(ctx, amount, depth, gasPrice, label)
id, err := c.debug.Postage.CreatePostageBatch(ctx, amount, depth, label)
if err != nil {
return "", fmt.Errorf("create postage stamp: %w", err)
}
Expand Down Expand Up @@ -408,7 +408,7 @@ func (c *Client) CreatePostageBatch(ctx context.Context, amount int64, depth uin
return id, nil
}

func (c *Client) GetOrCreateBatch(ctx context.Context, amount int64, depth uint64, gasPrice, label string) (string, error) {
func (c *Client) GetOrCreateBatch(ctx context.Context, amount int64, depth uint64, label string) (string, error) {
batches, err := c.PostageBatches(ctx)
if err != nil {
return "", err
Expand All @@ -426,7 +426,7 @@ func (c *Client) GetOrCreateBatch(ctx context.Context, amount int64, depth uint6
}
}

return c.CreatePostageBatch(ctx, amount, depth, gasPrice, label, false)
return c.CreatePostageBatch(ctx, amount, depth, label, false)
}

// PostageBatches returns the list of batches of node
Expand Down
13 changes: 5 additions & 8 deletions pkg/bee/debugapi/postage.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,14 @@ type postageStampsResponse struct {
}

// Sends a create postage request to a node that returns the batchID
func (p *PostageService) CreatePostageBatch(ctx context.Context, amount int64, depth uint64, gasPrice, label string) (batchID string, err error) {
func (p *PostageService) CreatePostageBatch(ctx context.Context, amount int64, depth uint64, label string) (batchID string, err error) {
url := fmt.Sprintf("/stamps/%d/%d?label=%s", amount, depth, label)
var resp postageResponse
if gasPrice != "" {
h := http.Header{}
h.Add("Gas-Price", gasPrice)
err = p.client.requestWithHeader(ctx, http.MethodPost, url, h, nil, &resp)
} else {
err = p.client.request(ctx, http.MethodPost, url, nil, &resp)
}

h := http.Header{}
h.Add("Immutable", "false")

err = p.client.requestWithHeader(ctx, http.MethodPost, url, h, nil, &resp)
if err != nil {
return "", err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/check/fileretrieval/fileretrieval.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (c *Check) defaultCheck(ctx context.Context, cluster orchestration.Cluster,
file := bee.NewRandomFile(rnds[i], fmt.Sprintf("%s-%d-%d", o.FileName, i, j), o.FileSize)

depth := 2 + bee.EstimatePostageBatchDepth(file.Size())
batchID, err := clients[nodeName].CreatePostageBatch(ctx, o.PostageAmount, depth, o.GasPrice, o.PostageLabel, false)
batchID, err := clients[nodeName].CreatePostageBatch(ctx, o.PostageAmount, depth, o.PostageLabel, false)
if err != nil {
return fmt.Errorf("node %s: created batched id %w", nodeName, err)
}
Expand Down Expand Up @@ -171,7 +171,7 @@ func (c *Check) fullCheck(ctx context.Context, cluster orchestration.Cluster, o
file := bee.NewRandomFile(rnds[i], fmt.Sprintf("%s-%d-%d", o.FileName, i, j), o.FileSize)

depth := 2 + bee.EstimatePostageBatchDepth(file.Size())
batchID, err := clients[nodeName].CreatePostageBatch(ctx, o.PostageAmount, depth, o.GasPrice, o.PostageLabel, false)
batchID, err := clients[nodeName].CreatePostageBatch(ctx, o.PostageAmount, depth, o.PostageLabel, false)
if err != nil {
return fmt.Errorf("node %s: created batched id %w", nodeName, err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/check/gc/reserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int
return fmt.Errorf("wrong initial storage radius, got %d want %d", origState.StorageRadius, 0)
}

batchID, err := client.CreatePostageBatch(ctx, cheapBatchAmount, batchDepth, o.GasPrice, o.PostageLabel, true)
batchID, err := client.CreatePostageBatch(ctx, cheapBatchAmount, batchDepth, o.PostageLabel, true)
if err != nil {
return fmt.Errorf("create batch: %w", err)
}
Expand All @@ -207,7 +207,7 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int

c.logger.Infof("uploaded %d chunks with batch depth %d, amount %d, at radius 4", len(lowValueChunks), batchDepth, cheapBatchAmount)

highValueBatch, err := client.CreatePostageBatch(ctx, expensiveBatchAmount, batchDepth, o.GasPrice, o.PostageLabel, true)
highValueBatch, err := client.CreatePostageBatch(ctx, expensiveBatchAmount, batchDepth, o.PostageLabel, true)
if err != nil {
return fmt.Errorf("create batch: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/check/manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int

client := clients[node]

batchID, err := client.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.GasPrice, o.PostageLabel)
batchID, err := client.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.PostageLabel)
if err != nil {
return fmt.Errorf("node %s: batch id %w", node, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/check/postage/postage.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int

client := clients[node]

batchID, err := client.CreatePostageBatch(ctx, o.PostageAmount, o.PostageDepth, o.GasPrice, o.PostageLabel, false)
batchID, err := client.CreatePostageBatch(ctx, o.PostageAmount, o.PostageDepth, o.PostageLabel, false)
if err != nil {
return fmt.Errorf("node %s: batch id %w", node, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/check/pss/pss.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (c *Check) testPss(nodeAName, nodeBName string, clients map[string]*bee.Cli
return err
}

batchID, err := nodeA.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.GasPrice, o.PostageLabel)
batchID, err := nodeA.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.PostageLabel)
if err != nil {
cancel()
return fmt.Errorf("node %s: batched id %w", nodeAName, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/check/pullsync/pullsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int
nodeName := sortedNodes[i]
client := clients[nodeName]

batchID, err := client.CreatePostageBatch(ctx, o.PostageAmount, bee.MinimumBatchDepth, o.GasPrice, o.PostageLabel, false)
batchID, err := client.CreatePostageBatch(ctx, o.PostageAmount, bee.MinimumBatchDepth, o.PostageLabel, false)
if err != nil {
return fmt.Errorf("node %s: created batched id %w", nodeName, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/check/pushsync/check_chunks.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func checkChunks(ctx context.Context, c orchestration.Cluster, o Options, l logg

uploader := clients[nodeName]

batchID, err := uploader.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.GasPrice, o.PostageLabel)
batchID, err := uploader.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.PostageLabel)
if err != nil {
return fmt.Errorf("node %s: batch id %w", nodeName, err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/check/pushsync/check_lightnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func checkLightChunks(ctx context.Context, cluster orchestration.Cluster, o Opti
// prepare postage batches
for i := 0; i < len(lightNodes); i++ {
nodeName := lightNodes[i]
batchID, err := clients[nodeName].GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.GasPrice, o.PostageLabel)
batchID, err := clients[nodeName].GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.PostageLabel)
if err != nil {
return fmt.Errorf("node %s: batch id %w", nodeName, err)
}
Expand All @@ -46,7 +46,7 @@ func checkLightChunks(ctx context.Context, cluster orchestration.Cluster, o Opti
nodeName := lightNodes[i]

uploader := clients[nodeName]
batchID, err := uploader.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.GasPrice, o.PostageLabel)
batchID, err := uploader.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.PostageLabel)
if err != nil {
return fmt.Errorf("node %s: batch id %w", nodeName, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/check/pushsync/pushsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (c *Check) defaultCheck(ctx context.Context, cluster orchestration.Cluster,
nodeName := sortedNodes[i]
client := clients[nodeName]

batchID, err := client.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.GasPrice, o.PostageLabel)
batchID, err := client.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.PostageLabel)
if err != nil {
return fmt.Errorf("node %s: batch id %w", nodeName, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/check/settlements/settlements.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int
client := clients[uNode]

c.logger.Info("node", uNode)
batchID, err := client.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.GasPrice, o.PostageLabel)
batchID, err := client.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.PostageLabel)
if err != nil {
return fmt.Errorf("node %s: batch id %w", uNode, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/check/smoke/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (c *LoadCheck) Run(ctx context.Context, cluster orchestration.Cluster, opts

batchID := batches.Get(txName)
if batchID == "" {
batchID, err = clients[txName].CreatePostageBatch(ctx, o.PostageAmount, o.PostageDepth, o.GasPrice, "load-test", true)
batchID, err = clients[txName].CreatePostageBatch(ctx, o.PostageAmount, o.PostageDepth, "load-test", true)
if err != nil {
c.logger.Errorf("create new batch: %v", err)
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/check/smoke/smoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int

batchID := batches.Get(txName)
if batchID == "" {
batchID, err = clients[txName].CreatePostageBatch(txCtx, o.PostageAmount, o.PostageDepth, o.GasPrice, "load-test", true)
batchID, err = clients[txName].CreatePostageBatch(txCtx, o.PostageAmount, o.PostageDepth, "load-test", true)
if err != nil {
c.logger.Errorf("create new batch: %v", err)
continue
Expand Down
2 changes: 1 addition & 1 deletion pkg/check/soc/soc.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int
id := hex.EncodeToString(idBytes)
sig := hex.EncodeToString(signatureBytes)

batchID, err := node.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.GasPrice, o.PostageLabel)
batchID, err := node.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.PostageLabel)
if err != nil {
return fmt.Errorf("node %s: batch id %w", nodeName, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/simulate/pushsync/pushsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (s *Simulation) Run(ctx context.Context, cluster orchestration.Cluster, opt
}

func uploadChunks(ctx context.Context, rnd *rand.Rand, o Options, client *bee.Client, chunks []swarm.Chunk) error {
batchID, err := client.CreatePostageBatch(ctx, o.PostageAmount, o.PostageDepth, o.GasPrice, "sim-pushsync", false)
batchID, err := client.CreatePostageBatch(ctx, o.PostageAmount, o.PostageDepth, "sim-pushsync", false)
if err != nil {
return fmt.Errorf("batch create %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/simulate/retrieval/retrieval.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (s *Simulation) Run(ctx context.Context, cluster orchestration.Cluster, opt
nodeName := sortedNodes[i]
client := clients[nodeName]

batchID, err := client.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.GasPrice, o.PostageLabel)
batchID, err := client.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.PostageLabel)
if err != nil {
s.logger.Infof("error: node %s: batch id %v", nodeName, err)
continue
Expand Down
2 changes: 1 addition & 1 deletion pkg/simulate/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (s *Simulation) Run(ctx context.Context, cluster orchestration.Cluster, opt
return ctx.Err()
}

batchID, err = c.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.GasPrice, o.PostageLabel)
batchID, err = c.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.PostageLabel)
if err != nil {
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
return nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/test/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (b *BeeV2) UploadRandomFile(ctx context.Context) (File, error) {

func (b *BeeV2) UploadFile(ctx context.Context, file File) error {
depth := 2 + bee.EstimatePostageBatchDepth(b.opts.FileSize)
batchID, err := b.client.CreatePostageBatch(ctx, b.opts.PostageAmount, depth, b.opts.GasPrice, b.opts.PostageLabel, false)
batchID, err := b.client.CreatePostageBatch(ctx, b.opts.PostageAmount, depth, b.opts.PostageLabel, false)
if err != nil {
return fmt.Errorf("node %s: created batch id %w", b.name, err)
}
Expand Down Expand Up @@ -81,7 +81,7 @@ func (b *BeeV2) ExpectToHaveFile(ctx context.Context, file File) error {

func (b *BeeV2) NewChunkUploader(ctx context.Context) (*ChunkUploader, error) {
o := b.opts
batchID, err := b.client.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.GasPrice, o.PostageLabel)
batchID, err := b.client.GetOrCreateBatch(ctx, o.PostageAmount, o.PostageDepth, o.PostageLabel)
if err != nil {
return nil, fmt.Errorf("node %s: batch id %w", b.name, err)
}
Expand Down

0 comments on commit 57ad84f

Please sign in to comment.