From 730d51752b72934b70e804a2689a0a65edf673df Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Mon, 5 Feb 2024 00:05:23 +0530 Subject: [PATCH 1/8] fix client sig --- tests/api_tests/blobber_hashnode_test.go | 8 ++++---- tests/api_tests/blobber_objecttree_test.go | 8 ++++---- tests/api_tests/get_blobberFileRef_test.go | 18 +++++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/api_tests/blobber_hashnode_test.go b/tests/api_tests/blobber_hashnode_test.go index fa80f4e460..34555f3a84 100644 --- a/tests/api_tests/blobber_hashnode_test.go +++ b/tests/api_tests/blobber_hashnode_test.go @@ -29,11 +29,11 @@ func TestHashnodeRoot(testSetup *testing.T) { usedBlobberID := getFirstUsedStorageNodeID(allocationBlobbers.Blobbers, allocation.Blobbers) require.NotZero(t, usedBlobberID, "Old blobber ID contains zero value") - sign, err := crypto.SignHashUsingSignatureScheme(crypto.Sha3256([]byte(allocation.ID)), "bls0chain", []*model.KeyPair{wallet.Keys}) - require.Nil(t, err) - blobberUrl := getBlobberURL(usedBlobberID, allocation.Blobbers) + sign, err := crypto.SignHashUsingSignatureScheme(crypto.Sha3256([]byte(allocation.ID+blobberUrl)), "bls0chain", []*model.KeyPair{wallet.Keys}) + require.Nil(t, err) + blobberRequest := &model.BlobberGetHashnodeRequest{ AllocationID: allocation.ID, URL: blobberUrl, @@ -59,7 +59,7 @@ func TestHashnodeRoot(testSetup *testing.T) { blobberUrl := apiClient.HealthyServiceProviders.Blobbers[0] - sign, err := crypto.SignHashUsingSignatureScheme(crypto.Sha3256([]byte(allocationID)), "bls0chain", []*model.KeyPair{wallet.Keys}) + sign, err := crypto.SignHashUsingSignatureScheme(crypto.Sha3256([]byte(allocationID+blobberUrl)), "bls0chain", []*model.KeyPair{wallet.Keys}) require.Nil(t, err) blobberRequest := &model.BlobberGetHashnodeRequest{ diff --git a/tests/api_tests/blobber_objecttree_test.go b/tests/api_tests/blobber_objecttree_test.go index a8ee18bf44..9977ecbe5e 100644 --- a/tests/api_tests/blobber_objecttree_test.go +++ b/tests/api_tests/blobber_objecttree_test.go @@ -36,7 +36,7 @@ func TestObjectTree(testSetup *testing.T) { blobber := apiClient.GetBlobber(t, blobberID, client.HttpOkStatus) url := blobber.BaseURL keyPair := crypto.GenerateKeys(t, sdkWalletMnemonics) - sign := encryption.Hash(allocation.Tx) + sign := encryption.Hash(allocation.Tx + url) clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey) @@ -68,7 +68,7 @@ func TestObjectTree(testSetup *testing.T) { blobber := apiClient.GetBlobber(t, blobberID, client.HttpOkStatus) url := blobber.BaseURL keyPair := crypto.GenerateKeys(t, sdkWalletMnemonics) - sign := encryption.Hash(allocation.Tx) + sign := encryption.Hash(allocation.Tx + url) clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey) @@ -101,7 +101,7 @@ func TestObjectTree(testSetup *testing.T) { blobber := apiClient.GetBlobber(t, blobberID, client.HttpOkStatus) blobberUrl := blobber.BaseURL keyPair := crypto.GenerateKeys(t, sdkWalletMnemonics) - sign := encryption.Hash(allocation.Tx) + sign := encryption.Hash(allocation.Tx + blobberUrl) clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey) blobberObjectTreeRequest := newBlobberObjectTreeRequest(blobberUrl, sdkWallet, "invalid_allocation_id", clientSignature, remoteFilePath) @@ -154,7 +154,7 @@ func TestObjectTree(testSetup *testing.T) { blobber := apiClient.GetBlobber(t, blobberID, client.HttpOkStatus) blobberUrl := blobber.BaseURL keyPair := crypto.GenerateKeys(t, sdkWalletMnemonics) - sign := encryption.Hash(allocation.Tx) + sign := encryption.Hash(allocation.Tx + blobberUrl) clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey) blobberObjectTreeRequest := newBlobberObjectTreeRequest(blobberUrl, sdkWallet, allocation.ID, clientSignature, "invalid_path") diff --git a/tests/api_tests/get_blobberFileRef_test.go b/tests/api_tests/get_blobberFileRef_test.go index 393819a578..15a0eaa991 100644 --- a/tests/api_tests/get_blobberFileRef_test.go +++ b/tests/api_tests/get_blobberFileRef_test.go @@ -37,7 +37,7 @@ func TestBlobberFileRefs(testSetup *testing.T) { url := blobber.BaseURL keyPair := crypto.GenerateKeys(t, sdkWalletMnemonics) refType := "regular" - sign := encryption.Hash(allocation.Tx) + sign := encryption.Hash(allocation.Tx + url) clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey) @@ -94,7 +94,7 @@ func TestBlobberFileRefs(testSetup *testing.T) { url := blobber.BaseURL keyPair := crypto.GenerateKeys(t, sdkWalletMnemonics) refType := "regular" - sign := encryption.Hash(allocation.Tx) + sign := encryption.Hash(allocation.Tx + url) clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey) @@ -124,7 +124,7 @@ func TestBlobberFileRefs(testSetup *testing.T) { url := blobber.BaseURL keyPair := crypto.GenerateKeys(t, sdkWalletMnemonics) refType := "regular" - sign := encryption.Hash(allocation.Tx) + sign := encryption.Hash(allocation.Tx + url) clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey) @@ -154,7 +154,7 @@ func TestBlobberFileRefs(testSetup *testing.T) { url := blobber.BaseURL keyPair := crypto.GenerateKeys(t, sdkWalletMnemonics) refType := "invalid-ref-type" - sign := encryption.Hash(allocation.Tx) + sign := encryption.Hash(allocation.Tx + url) clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey) @@ -184,7 +184,7 @@ func TestBlobberFileRefs(testSetup *testing.T) { url := blobber.BaseURL keyPair := crypto.GenerateKeys(t, sdkWalletMnemonics) refType := "invalid-ref-type" - sign := encryption.Hash(allocation.Tx) + sign := encryption.Hash(allocation.Tx + url) clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey) @@ -214,7 +214,7 @@ func TestBlobberFileRefs(testSetup *testing.T) { url := blobber.BaseURL keyPair := crypto.GenerateKeys(t, sdkWalletMnemonics) refType := "" - sign := encryption.Hash(allocation.Tx) + sign := encryption.Hash(allocation.Tx + url) clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey) @@ -244,7 +244,7 @@ func TestBlobberFileRefs(testSetup *testing.T) { url := blobber.BaseURL keyPair := crypto.GenerateKeys(t, sdkWalletMnemonics) refType := "" - sign := encryption.Hash(allocation.Tx) + sign := encryption.Hash(allocation.Tx + url) clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey) @@ -300,7 +300,7 @@ func TestBlobberFileRefs(testSetup *testing.T) { url := blobber.BaseURL keyPair := crypto.GenerateKeys(t, sdkWalletMnemonics) refType := "regular" - sign := encryption.Hash(allocation.Tx) + sign := encryption.Hash(allocation.Tx + url) clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey) @@ -332,7 +332,7 @@ func TestBlobberFileRefs(testSetup *testing.T) { url := blobber.BaseURL keyPair := crypto.GenerateKeys(t, sdkWalletMnemonics) refType := "regular" - sign := encryption.Hash(allocation.Tx) + sign := encryption.Hash(allocation.Tx + url) clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey) From f879b74394e5eaeac347ced286b2bb52a898c789 Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Thu, 8 Feb 2024 01:13:07 +0530 Subject: [PATCH 2/8] add v2 sig header --- internal/api/util/client/api_client.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/internal/api/util/client/api_client.go b/internal/api/util/client/api_client.go index 6f7f961db4..c37d5f06f0 100644 --- a/internal/api/util/client/api_client.go +++ b/internal/api/util/client/api_client.go @@ -645,11 +645,11 @@ func (c *APIClient) V1BlobberGetHashNodeRoot(t *test.SystemTest, blobberGetHashn var hashnode *model.BlobberGetHashnodeResponse headers := map[string]string{ - "X-App-Client-Id": blobberGetHashnodeRequest.ClientId, - "X-App-Client-Key": blobberGetHashnodeRequest.ClientKey, - "X-App-Client-Signature": blobberGetHashnodeRequest.ClientSignature, - "allocation": blobberGetHashnodeRequest.AllocationID, - "ALLOCATION-ID": blobberGetHashnodeRequest.AllocationID, + "X-App-Client-Id": blobberGetHashnodeRequest.ClientId, + "X-App-Client-Key": blobberGetHashnodeRequest.ClientKey, + "X-App-Client-Signature-V2": blobberGetHashnodeRequest.ClientSignature, + "allocation": blobberGetHashnodeRequest.AllocationID, + "ALLOCATION-ID": blobberGetHashnodeRequest.AllocationID, } blobberGetHashNodeRootURL := blobberGetHashnodeRequest.URL + "/" + strings.Replace(GetHashNodeRoot, ":allocation", blobberGetHashnodeRequest.AllocationID, 1) @@ -2103,10 +2103,10 @@ func (c *APIClient) V1BlobberGetFileRefs(t *test.SystemTest, blobberGetFileRefsR blobberGetFileRefsURL := blobberGetFileRefsRequest.URL + strings.Replace(GetFileRef, ":allocation_id", blobberGetFileRefsRequest.AllocationID, 1) + "?" + "path=" + blobberGetFileRefsRequest.RemotePath + "&" + "refType=" + blobberGetFileRefsRequest.RefType headers := map[string]string{ - "X-App-Client-Id": blobberGetFileRefsRequest.ClientID, - "X-App-Client-Key": blobberGetFileRefsRequest.ClientKey, - "X-App-Client-Signature": blobberGetFileRefsRequest.ClientSignature, - "ALLOCATION-ID": blobberGetFileRefsRequest.AllocationID, + "X-App-Client-Id": blobberGetFileRefsRequest.ClientID, + "X-App-Client-Key": blobberGetFileRefsRequest.ClientKey, + "X-App-Client-Signature-V2": blobberGetFileRefsRequest.ClientSignature, + "ALLOCATION-ID": blobberGetFileRefsRequest.AllocationID, } resp, err := c.executeForServiceProvider( t, @@ -2198,10 +2198,10 @@ func (c *APIClient) V1BlobberObjectTree(t *test.SystemTest, blobberObjectTreeReq blobberObjectTreeURL := blobberObjectTreeRequest.URL + strings.Replace(GetObjectTree, ":allocation_id", blobberObjectTreeRequest.AllocationID, 1) + "?" + "path=" + blobberObjectTreeRequest.Path headers := map[string]string{ - "X-App-Client-Id": blobberObjectTreeRequest.ClientID, - "X-App-Client-Key": blobberObjectTreeRequest.ClientKey, - "X-App-Client-Signature": blobberObjectTreeRequest.ClientSignature, - "ALLOCATION-ID": blobberObjectTreeRequest.AllocationID, + "X-App-Client-Id": blobberObjectTreeRequest.ClientID, + "X-App-Client-Key": blobberObjectTreeRequest.ClientKey, + "X-App-Client-Signature-V2": blobberObjectTreeRequest.ClientSignature, + "ALLOCATION-ID": blobberObjectTreeRequest.AllocationID, } resp, err := c.executeForServiceProvider( t, From 8eb46451fb797ec375f78a3b142f3b2ff2eae4d8 Mon Sep 17 00:00:00 2001 From: storybehind Date: Fri, 14 Jun 2024 12:17:22 +0530 Subject: [PATCH 3/8] add TestRepairSize --- tests/api_tests/repair_allocation_test.go | 100 ++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/tests/api_tests/repair_allocation_test.go b/tests/api_tests/repair_allocation_test.go index 8deecce837..3995adbb6b 100644 --- a/tests/api_tests/repair_allocation_test.go +++ b/tests/api_tests/repair_allocation_test.go @@ -347,3 +347,103 @@ func TestRepairAllocation(testSetup *testing.T) { } }) } + +func TestRepairSize(testSetup *testing.T) { + t := test.NewSystemTest(testSetup) + wallet := createWallet(t) + sdkClient.SetWallet(t, wallet) + apiClient.CreateReadPool(t, wallet, 0.5, client.TxSuccessfulStatus) + + t.RunSequentiallyWithTimeout("repair size in case of no blobber failure should be zero", 5 * time.Minute, func(t *test.SystemTest) { + // create allocation with default blobber requirements + blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey) + allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus) + allocationID := apiClient.CreateAllocation(t, wallet, allocationBlobbers, client.TxSuccessfulStatus) + t.Logf("allocationID: %v", allocationID) + + // create and upload a file of 2KB to allocation. + op := sdkClient.AddUploadOperation(t, "", "", int64(1024 * 2)) + sdkClient.MultiOperation(t, allocationID, []sdk.OperationRequest{op}) + + // assert both upload and download size should be zero + alloc, err := sdk.GetAllocation(allocationID) + require.NoErrorf(t, err, "allocation ID %v is not found", allocationID) + rs, err := alloc.RepairSize("/") + require.Nil(t, err) + t.Logf("repair size: %v", rs) + require.Equal(t, uint64(0), rs.UploadSize, "upload size doesn't match") + require.Equal(t, uint64(0), rs.DownloadSize, "download size doesn't match") + }) + + t.RunSequentiallyWithTimeout("repair size on single blobber failure should match", 5 * time.Minute, func(t *test.SystemTest) { + // create allocation with default blobber requirements + blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey) + blobberRequirements.DataShards = 2 + blobberRequirements.ParityShards = 2 + blobberRequirements.Size = 2056 + allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus) + allocationID := apiClient.CreateAllocation(t, wallet, allocationBlobbers, client.TxSuccessfulStatus) + t.Logf("allocationID: %v", allocationID) + + // create and upload a file of 2KB to allocation. + // one blobber url is set invalid to mimic failure. + alloc, err := sdk.GetAllocation(allocationID) + require.NoErrorf(t, err, "allocation ID %v is not found", allocationID) + alloc.Blobbers[0].Baseurl = "http://0zus.com/" + op := sdkClient.AddUploadOperation(t, "", "", int64(1024 * 2)) + sdkClient.MultiOperation(t, allocationID, []sdk.OperationRequest{op}, client.WithRepair(alloc.Blobbers)) + + // assert upload and download size should be 1KB and 2KB respectively + rs, err := alloc.RepairSize("/") + require.Nil(t, err) + t.Logf("repair size: %v", rs) + require.Equal(t, uint64(1024), rs.UploadSize, "upload size doesn't match") + require.Equal(t, uint64(1024 * 2), rs.DownloadSize, "download size doesn't match") + }) + + t.RunSequentiallyWithTimeout("repair size with nested directories and two blobber failure should match", 5 * time.Minute, func(t *test.SystemTest) { + // create allocation with default blobber requirements + blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey) + blobberRequirements.DataShards = 2 + blobberRequirements.ParityShards = 4 + allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus) + allocationID := apiClient.CreateAllocation(t, wallet, allocationBlobbers, client.TxSuccessfulStatus) + t.Logf("allocationID: %v", allocationID) + + // create and upload two files of 1KB each to / and /dir1. + // two blobber url is set invalid to mimic failure. + alloc, err := sdk.GetAllocation(allocationID) + require.NoErrorf(t, err, "allocation ID %v is not found", allocationID) + alloc.Blobbers[0].Baseurl = "http://0zus.com/" + alloc.Blobbers[1].Baseurl = "http://0zus.com/" + ops := []sdk.OperationRequest{ + sdkClient.AddUploadOperationWithPath(t, allocationID, "/dir1/"), + sdkClient.AddUploadOperationWithPath(t, allocationID, "/dir1/"), + sdkClient.AddUploadOperationWithPath(t, allocationID, "/"), + sdkClient.AddUploadOperationWithPath(t, allocationID, "/"), + } + sdkClient.MultiOperation(t, allocationID, ops, client.WithRepair(alloc.Blobbers)) + + // assert both upload and download size should be 2KB in /dir1 + rs, err := alloc.RepairSize("/dir1") + require.Nilf(t, err, "error getting repair size in /dir1: %v", err) + t.Logf("repair size: %v", rs) + require.Equal(t, uint64(1024 * 2), rs.UploadSize, "upload size in directory /dir1 doesn't match") + require.Equal(t, uint64(1024 * 2), rs.DownloadSize, "download size in directory dir1 doesn't match") + + // with trailing slash + // assert both upload and download size should be 2KB in /dir1/ + rs, err = alloc.RepairSize("/dir1/") + require.Nilf(t, err, "error getting repair size in /dir1/: %v", err) + t.Logf("repair size: %v", rs) + require.Equal(t, uint64(1024 * 2), rs.UploadSize, "upload size in directory /dir1/ doesn't match") + require.Equal(t, uint64(1024 * 2), rs.DownloadSize, "download size in directory /dir1/ doesn't match") + + // assert both upload and download size should be 4KB in root directory + rs, err = alloc.RepairSize("/") + require.Nilf(t, err, "error getting repair size in /: %v", err) + t.Logf("repair size: %v", rs) + require.Equal(t, uint64(1024 * 4), rs.UploadSize, "upload size in root directory doesn't match") + require.Equal(t, uint64(1024 * 4), rs.DownloadSize, "download size in root directory doesn't match") + }) +} \ No newline at end of file From cf721294d637f80a942c3daae2fad229cbb9166a Mon Sep 17 00:00:00 2001 From: storybehind Date: Fri, 14 Jun 2024 13:50:09 +0530 Subject: [PATCH 4/8] add cli tests --- internal/cli/model/model.go | 8 +++ tests/cli_tests/zboxcli_repair_test.go | 93 ++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 tests/cli_tests/zboxcli_repair_test.go diff --git a/internal/cli/model/model.go b/internal/cli/model/model.go index de279353f8..8bdc3a8588 100644 --- a/internal/cli/model/model.go +++ b/internal/cli/model/model.go @@ -733,6 +733,14 @@ type ReadMarker struct { BlockNumber int64 `json:"block_number"` } +// holds result of repair size +type RepairSize struct { + // upload size in bytes + UploadSize uint64 `json:"upload_size"` + // download size in bytes + DownloadSize uint64 `json:"download_size"` +} + var StorageKeySettings = []string{ "owner_id", } diff --git a/tests/cli_tests/zboxcli_repair_test.go b/tests/cli_tests/zboxcli_repair_test.go new file mode 100644 index 0000000000..9fa1123324 --- /dev/null +++ b/tests/cli_tests/zboxcli_repair_test.go @@ -0,0 +1,93 @@ +package cli_tests + +import ( + "encoding/json" + "fmt" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/0chain/system_test/internal/api/util/test" + "github.com/0chain/system_test/internal/cli/model" + cliutils "github.com/0chain/system_test/internal/cli/util" + "github.com/stretchr/testify/require" +) + +func TestRepairSize(testSetup *testing.T) { + t := test.NewSystemTest(testSetup) + + t.RunSequentiallyWithTimeout("repair size should work", 5 * time.Minute, func(t *test.SystemTest) { + allocSize := int64(1 * MB) + fileSize := int64(512 * KB) + + allocationID := setupAllocation(t, configPath, map[string]interface{}{ + "size": allocSize, + "parity": 1, + "data": 1, + }) + + filename := generateRandomTestFileName(t) + err := createFileWithSize(filename, fileSize) + require.Nil(t, err) + + output, err := uploadFile(t, configPath, map[string]interface{}{ + "allocation": allocationID, + "remotepath": "/", + "localpath": filename, + }, true) + require.Nil(t, err, strings.Join(output, "\n")) + require.Len(t, output, 2) + + expected := fmt.Sprintf( + "Status completed callback. Type = text/plain. Name = %s", + filepath.Base(filename), + ) + require.Equal(t, expected, output[1]) + + output, err = getRepairSize(t, configPath, map[string]interface{}{ + "allocation": allocationID, + "repairpath": "/", + }, true) + require.Nilf(t, err, "error getting repair size: %v", err) + var rs model.RepairSize + err = json.Unmarshal([]byte(output[0]), &rs) + require.Nilf(t, err, "error unmarshal repair size: %v", err) + require.Equal(t, uint64(0), rs.UploadSize, "upload size should be zero") + require.Equal(t, uint64(0), rs.DownloadSize, "download size should be zero") + + // optional repairpath + output, err = getRepairSize(t, configPath, map[string]interface{}{ + "allocation": allocationID, + }, true) + require.Nilf(t, err, "error getting repair size: %v", err) + var rs2 model.RepairSize + err = json.Unmarshal([]byte(output[0]), &rs2) + require.Nilf(t, err, "error unmarshal repair size: %v", err) + require.Equal(t, uint64(0), rs2.UploadSize, "upload size should be zero") + require.Equal(t, uint64(0), rs2.DownloadSize, "download size should be zero") + }) + +} + +func getRepairSize(t *test.SystemTest, cliConfigFilename string, param map[string]interface{}, retry bool) ([]string, error) { + return getRepairSizeForWallet(t, escapedTestName(t), cliConfigFilename, param, retry) +} + +func getRepairSizeForWallet(t *test.SystemTest, wallet, cliConfigFilename string, param map[string]interface{}, retry bool) ([]string, error) { + t.Logf("getting Repair size...") + + p := createParams(param) + cmd := fmt.Sprintf( + "./zbox repair-size %s --silent --wallet %s_wallet.json --configDir ./config --config %s", + p, + wallet, + cliConfigFilename, + ) + + if retry { + return cliutils.RunCommand(t, cmd, 3, time.Second*40) + } else { + return cliutils.RunCommandWithoutRetry(cmd) + } +} \ No newline at end of file From 8e451f9e2c7a02a1362ef741d1ee60540c8a103e Mon Sep 17 00:00:00 2001 From: storybehind Date: Fri, 14 Jun 2024 14:13:34 +0530 Subject: [PATCH 5/8] update gosdk version --- go.mod | 4 ++-- go.sum | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 6fbabdfc4b..031df856c1 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21 require ( github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.14.0-RC2 + github.com/0chain/gosdk v1.15.2-0.20240614082721-1b8ad4f48bc6 github.com/go-resty/resty/v2 v2.7.0 github.com/herumi/bls-go-binary v1.31.0 github.com/shopspring/decimal v1.3.1 @@ -23,7 +23,7 @@ require ( github.com/andybalholm/brotli v1.0.5 // indirect github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect github.com/hashicorp/golang-lru/v2 v2.0.1 // indirect - github.com/hitenjain14/fasthttp v0.0.0-20240229173600-722723e15e17 // indirect + github.com/hitenjain14/fasthttp v0.0.0-20240527123209-06019e79bff9 // indirect github.com/klauspost/compress v1.17.0 // indirect github.com/lithammer/shortuuid/v3 v3.0.7 // indirect github.com/minio/sha256-simd v1.0.1 // indirect diff --git a/go.sum b/go.sum index 378c1268f0..c59a4fa573 100644 --- a/go.sum +++ b/go.sum @@ -42,6 +42,8 @@ github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM= github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc= github.com/0chain/gosdk v1.14.0-RC2 h1:OIpjj7mDKxVqJVlxJKm8/fPzdJRN5roXO7/plBCtmTg= github.com/0chain/gosdk v1.14.0-RC2/go.mod h1:tgAiVAuIy+Vs1tGfKCPEuuWWARwNQBEw32y950LrqrU= +github.com/0chain/gosdk v1.15.2-0.20240614082721-1b8ad4f48bc6 h1:f8fN6PuvE/Iu1LqrJH5q20eWOFB/NjlDA8TIDMqZgAg= +github.com/0chain/gosdk v1.15.2-0.20240614082721-1b8ad4f48bc6/go.mod h1:Hzl56JJ66ZmoyNS7CbTJue7wUugBYvNx8/qJzTRWmkI= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw= @@ -240,6 +242,7 @@ github.com/herumi/bls-go-binary v1.31.0 h1:L1goQ2tMtGgpXCg5AwHAdJQpLs/pfnWWEc3Wo github.com/herumi/bls-go-binary v1.31.0/go.mod h1:O4Vp1AfR4raRGwFeQpr9X/PQtncEicMoOe6BQt1oX0Y= github.com/hitenjain14/fasthttp v0.0.0-20240229173600-722723e15e17 h1:FbyIK0BfvXVZTOxKOe2dlxJqSPSF2ZXOv2Mc7dvS7sc= github.com/hitenjain14/fasthttp v0.0.0-20240229173600-722723e15e17/go.mod h1:RZMcXy7u4S+E97IXYTe7WHZ3+mCYOh4vys8PkIGZeXk= +github.com/hitenjain14/fasthttp v0.0.0-20240527123209-06019e79bff9/go.mod h1:RZMcXy7u4S+E97IXYTe7WHZ3+mCYOh4vys8PkIGZeXk= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c h1:DZfsyhDK1hnSS5lH8l+JggqzEleHteTYfutAiVlSUM8= From 5a98103b50ae7584ad8284027d3f1fb3d2576a2d Mon Sep 17 00:00:00 2001 From: storybehind Date: Fri, 14 Jun 2024 14:28:19 +0530 Subject: [PATCH 6/8] apply gofmt --- internal/cli/model/model.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/cli/model/model.go b/internal/cli/model/model.go index 8bdc3a8588..b43542add2 100644 --- a/internal/cli/model/model.go +++ b/internal/cli/model/model.go @@ -736,9 +736,9 @@ type ReadMarker struct { // holds result of repair size type RepairSize struct { // upload size in bytes - UploadSize uint64 `json:"upload_size"` + UploadSize uint64 `json:"upload_size"` // download size in bytes - DownloadSize uint64 `json:"download_size"` + DownloadSize uint64 `json:"download_size"` } var StorageKeySettings = []string{ From bd990ec0b0ff35a64ca7560b8ba1cb0abb2a986d Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Sun, 23 Jun 2024 23:32:56 +0530 Subject: [PATCH 7/8] use allocation tx --- tests/api_tests/blobber_hashnode_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/api_tests/blobber_hashnode_test.go b/tests/api_tests/blobber_hashnode_test.go index a119f86d49..3ae77f9ed2 100644 --- a/tests/api_tests/blobber_hashnode_test.go +++ b/tests/api_tests/blobber_hashnode_test.go @@ -31,7 +31,7 @@ func TestHashnodeRoot(testSetup *testing.T) { blobberUrl := getBlobberURL(usedBlobberID, allocation.Blobbers) - sign, err := crypto.SignHashUsingSignatureScheme(crypto.Sha3256([]byte(allocation.ID+blobberUrl)), "bls0chain", []*model.KeyPair{wallet.Keys}) + sign, err := crypto.SignHashUsingSignatureScheme(crypto.Sha3256([]byte(allocation.Tx+blobberUrl)), "bls0chain", []*model.KeyPair{wallet.Keys}) require.Nil(t, err) blobberRequest := &model.BlobberGetHashnodeRequest{ From a82d148e68c308e7f89aab9d3c8a0615d6718d08 Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Mon, 24 Jun 2024 11:20:20 +0530 Subject: [PATCH 8/8] fix invalid sig message --- tests/api_tests/blobber_hashnode_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/api_tests/blobber_hashnode_test.go b/tests/api_tests/blobber_hashnode_test.go index 3ae77f9ed2..8d3b675ecc 100644 --- a/tests/api_tests/blobber_hashnode_test.go +++ b/tests/api_tests/blobber_hashnode_test.go @@ -102,7 +102,7 @@ func TestHashnodeRoot(testSetup *testing.T) { getBlobberResponse, restyResponse, err := apiClient.V1BlobberGetHashNodeRoot(t, blobberRequest, client.HttpOkStatus) require.NotNil(t, err) - require.Equal(t, "bad request: invalid signature badsign\n", string(restyResponse.Body())) + require.Equal(t, "bad request: invalid signature \n", string(restyResponse.Body())) require.Nil(t, getBlobberResponse) })