Skip to content

Commit 4983b3c

Browse files
authored
Merge branch 'sprint-1.18' into fix/v1-rootsig
2 parents 0745100 + 3fc5621 commit 4983b3c

38 files changed

+271
-894
lines changed

code/go/0chain.net/blobber/settings.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import (
44
"context"
55
"encoding/json"
66
"errors"
7+
"github.com/0chain/gosdk/core/transaction"
78
"strconv"
89
"time"
910

1011
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/config"
1112
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
12-
"github.com/0chain/gosdk/zcncore"
1313
)
1414

1515
type storageScCB struct {
@@ -58,20 +58,24 @@ func (ssc *storageScCB) OnInfoAvailable(op int, status int, info string, errStr
5858
}
5959

6060
func setStorageScConfigFromChain() error {
61-
cb := &storageScCB{
62-
done: make(chan struct{}),
61+
conf, err := transaction.GetConfig("storage_sc_config")
62+
if err != nil {
63+
return err
6364
}
64-
err := zcncore.GetStorageSCConfig(cb)
65+
66+
maxChallengeCompletionRoundsString := conf.Fields["max_challenge_completion_rounds"]
67+
maxChallengeCompletionRoundsInt, err := strconv.ParseInt(maxChallengeCompletionRoundsString, 10, 64)
6568
if err != nil {
6669
return err
6770
}
68-
<-cb.done
69-
if cb.err != nil {
71+
maxFileSizeString := conf.Fields["max_file_size"]
72+
maxFileSizeInt64, err := strconv.ParseInt(maxFileSizeString, 10, 64)
73+
if err != nil {
7074
return err
7175
}
7276

73-
config.StorageSCConfig.ChallengeCompletionTime = cb.cct
74-
config.StorageSCConfig.MaxFileSize = cb.mfs
77+
config.StorageSCConfig.ChallengeCompletionTime = maxChallengeCompletionRoundsInt
78+
config.StorageSCConfig.MaxFileSize = maxFileSizeInt64
7579
return nil
7680
}
7781

code/go/0chain.net/blobber/zcn.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import (
1010
handleCommon "github.com/0chain/blobber/code/go/0chain.net/core/common/handler"
1111
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
1212
"github.com/0chain/blobber/code/go/0chain.net/core/node"
13-
"github.com/0chain/gosdk/zboxcore/sdk"
14-
"github.com/0chain/gosdk/zcncore"
13+
"github.com/0chain/gosdk/core/client"
1514
"go.uber.org/zap"
1615
"time"
1716
)
@@ -82,15 +81,8 @@ func setupServerChain() error {
8281
serverChain := chain.NewChainFromConfig()
8382
chain.SetServerChain(serverChain)
8483

85-
if err := zcncore.InitZCNSDK(serverChain.BlockWorker, config.Configuration.SignatureScheme); err != nil {
86-
return err
87-
}
88-
if err := zcncore.SetWalletInfo(node.Self.GetWalletString(), false); err != nil {
89-
return err
90-
}
91-
92-
if err := sdk.InitStorageSDK(node.Self.GetWalletString(), serverChain.BlockWorker, config.Configuration.ChainID, config.Configuration.SignatureScheme,
93-
nil, 0); err != nil {
84+
if err := client.InitSDK(node.Self.GetWalletString(), serverChain.BlockWorker, config.Configuration.ChainID, config.Configuration.SignatureScheme,
85+
0, false, true); err != nil {
9486
return err
9587
}
9688

code/go/0chain.net/blobbercore/allocation/copyfilechange_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616
"github.com/0chain/blobber/code/go/0chain.net/core/common"
1717
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
1818
"github.com/0chain/gosdk/constants"
19+
"github.com/0chain/gosdk/core/client"
1920
"github.com/0chain/gosdk/core/zcncrypto"
20-
"github.com/0chain/gosdk/zboxcore/client"
2121
mocket "github.com/selvatico/go-mocket"
2222
"go.uber.org/zap"
2323
"google.golang.org/grpc/metadata"
@@ -38,7 +38,7 @@ func TestBlobberCore_CopyFile(t *testing.T) {
3838
ts := time.Now().Add(time.Hour)
3939
alloc := makeTestAllocation(common.Timestamp(ts.Unix()))
4040
alloc.OwnerPublicKey = sch.GetPublicKey()
41-
alloc.OwnerID = client.GetClientID()
41+
alloc.OwnerID = client.ClientID()
4242

4343
testCases := []struct {
4444
name string

code/go/0chain.net/blobbercore/allocation/deletefilechange_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/filestore"
1414
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/reference"
1515
"github.com/0chain/blobber/code/go/0chain.net/core/common"
16+
"github.com/0chain/gosdk/core/client"
1617
"github.com/0chain/gosdk/core/zcncrypto"
17-
"github.com/0chain/gosdk/zboxcore/client"
1818
mocket "github.com/selvatico/go-mocket"
1919
"github.com/stretchr/testify/assert"
2020
"github.com/stretchr/testify/require"
@@ -32,7 +32,7 @@ func TestBlobberCore_DeleteFile(t *testing.T) {
3232
ts := time.Now().Add(time.Hour)
3333
alloc := makeTestAllocation(common.Timestamp(ts.Unix()))
3434
alloc.OwnerPublicKey = sch.GetPublicKey()
35-
alloc.OwnerID = client.GetClientID()
35+
alloc.OwnerID = client.ClientID()
3636
testCases := []struct {
3737
name string
3838
context metadata.MD

code/go/0chain.net/blobbercore/allocation/file_changer_upload_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
"github.com/0chain/blobber/code/go/0chain.net/core/encryption"
1919
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
2020
"github.com/0chain/gosdk/constants"
21+
"github.com/0chain/gosdk/core/client"
2122
"github.com/0chain/gosdk/core/zcncrypto"
22-
"github.com/0chain/gosdk/zboxcore/client"
2323
mocket "github.com/selvatico/go-mocket"
2424
"go.uber.org/zap"
2525
"google.golang.org/grpc/metadata"
@@ -39,7 +39,7 @@ func TestBlobberCore_FileChangerUpload(t *testing.T) {
3939
ts := time.Now().Add(time.Hour)
4040
alloc := makeTestAllocation(common.Timestamp(ts.Unix()))
4141
alloc.OwnerPublicKey = sch.GetPublicKey()
42-
alloc.OwnerID = client.GetClientID()
42+
alloc.OwnerID = client.ClientID()
4343

4444
testCases := []struct {
4545
name string

code/go/0chain.net/blobbercore/allocation/movefilechange_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/filestore"
1717
"github.com/0chain/blobber/code/go/0chain.net/core/common"
1818
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
19+
"github.com/0chain/gosdk/core/client"
1920
"github.com/0chain/gosdk/core/zcncrypto"
20-
"github.com/0chain/gosdk/zboxcore/client"
2121
"go.uber.org/zap"
2222
"google.golang.org/grpc/metadata"
2323
)
@@ -37,7 +37,7 @@ func TestBlobberCore_MoveFile(t *testing.T) {
3737
ts := time.Now().Add(time.Hour)
3838
alloc := makeTestAllocation(common.Timestamp(ts.Unix()))
3939
alloc.OwnerPublicKey = sch.GetPublicKey()
40-
alloc.OwnerID = client.GetClientID()
40+
alloc.OwnerID = client.ClientID()
4141

4242
testCases := []struct {
4343
name string

code/go/0chain.net/blobbercore/allocation/multiop_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/datastore"
1414
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/reference"
1515
"github.com/0chain/blobber/code/go/0chain.net/core/common"
16+
"github.com/0chain/gosdk/core/client"
1617
"github.com/0chain/gosdk/core/zcncrypto"
17-
"github.com/0chain/gosdk/zboxcore/client"
1818
mocket "github.com/selvatico/go-mocket"
1919
"github.com/stretchr/testify/require"
2020
)
@@ -30,7 +30,7 @@ func TestMultiOp(t *testing.T) {
3030
ts := time.Now().Add(time.Hour)
3131
alloc := makeTestAllocation(common.Timestamp(ts.Unix()))
3232
alloc.OwnerPublicKey = sch.GetPublicKey()
33-
alloc.OwnerID = client.GetClientID()
33+
alloc.OwnerID = client.ClientID()
3434
datastore.MocketTheStore(t, true)
3535
ctx := datastore.GetStore().CreateTransaction(context.TODO())
3636
setupDbMock()

code/go/0chain.net/blobbercore/allocation/renamefilechange_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import (
1717
"github.com/0chain/blobber/code/go/0chain.net/core/common"
1818
"github.com/0chain/blobber/code/go/0chain.net/core/config"
1919
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
20+
"github.com/0chain/gosdk/core/client"
21+
coreNetwork "github.com/0chain/gosdk/core/conf"
2022
"github.com/0chain/gosdk/core/zcncrypto"
21-
"github.com/0chain/gosdk/zboxcore/client"
2223
zencryption "github.com/0chain/gosdk/zboxcore/encryption"
2324
"github.com/0chain/gosdk/zcncore"
2425
"github.com/DATA-DOG/go-sqlmock"
@@ -55,7 +56,7 @@ func setup(t *testing.T) {
5556
if err != nil {
5657
t.Fatal(err)
5758
}
58-
if err := zcncore.SetWalletInfo(string(wBlob), true); err != nil {
59+
if err := zcncore.SetWalletInfo(string(wBlob), "bls0chain", false); err != nil {
5960
t.Fatal(err)
6061
}
6162

@@ -66,10 +67,10 @@ func setup(t *testing.T) {
6667
},
6768
),
6869
)
69-
server := httptest.NewServer(
70+
_ = httptest.NewServer(
7071
http.HandlerFunc(
7172
func(w http.ResponseWriter, r *http.Request) {
72-
n := zcncore.Network{Miners: []string{"miner 1"}, Sharders: []string{sharderServ.URL}}
73+
n := coreNetwork.Network{Miners: []string{"miner 1"}, Sharders: []string{sharderServ.URL}}
7374
blob, err := json.Marshal(n)
7475
if err != nil {
7576
t.Fatal(err)
@@ -82,9 +83,9 @@ func setup(t *testing.T) {
8283
),
8384
)
8485

85-
if err := zcncore.InitZCNSDK(server.URL, "ed25519"); err != nil {
86-
t.Fatal(err)
87-
}
86+
//if err := client.InitSDK(server.URL, "ed25519"); err != nil {
87+
// t.Fatal(err)
88+
//}
8889
}
8990
func setupMockForFileManagerInit(mock sqlmock.Sqlmock) {
9091
mock.ExpectBegin()
@@ -151,7 +152,7 @@ func TestBlobberCore_RenameFile(t *testing.T) {
151152
ts := time.Now().Add(time.Hour)
152153
alloc := makeTestAllocation(common.Timestamp(ts.Unix()))
153154
alloc.OwnerPublicKey = sch.GetPublicKey()
154-
alloc.OwnerID = client.GetClientID()
155+
alloc.OwnerID = client.ClientID()
155156

156157
testCases := []struct {
157158
name string

code/go/0chain.net/blobbercore/allocation/updatefilechange_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
"github.com/0chain/blobber/code/go/0chain.net/core/common"
1313
"github.com/0chain/blobber/code/go/0chain.net/core/encryption"
1414
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
15+
"github.com/0chain/gosdk/core/client"
1516
"github.com/0chain/gosdk/core/zcncrypto"
16-
"github.com/0chain/gosdk/zboxcore/client"
1717
mocket "github.com/selvatico/go-mocket"
1818
"github.com/stretchr/testify/assert"
1919
"github.com/stretchr/testify/require"
@@ -36,7 +36,7 @@ func TestBlobberCore_UpdateFile(t *testing.T) {
3636
ts := time.Now().Add(time.Hour)
3737
alloc := makeTestAllocation(common.Timestamp(ts.Unix()))
3838
alloc.OwnerPublicKey = sch.GetPublicKey()
39-
alloc.OwnerID = client.GetClientID()
39+
alloc.OwnerID = client.ClientID()
4040

4141
testCases := []struct {
4242
name string

code/go/0chain.net/blobbercore/allocation/workers.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import (
66
"math"
77
"time"
88

9-
"github.com/0chain/blobber/code/go/0chain.net/core/node"
9+
coreTxn "github.com/0chain/gosdk/core/transaction"
1010

1111
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/datastore"
1212
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/filestore"
1313
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/reference"
1414
"github.com/0chain/blobber/code/go/0chain.net/core/common"
1515
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
16+
"github.com/0chain/blobber/code/go/0chain.net/core/node"
1617
"github.com/0chain/blobber/code/go/0chain.net/core/transaction"
1718

1819
"go.uber.org/zap"
@@ -306,20 +307,15 @@ type finalizeRequest struct {
306307
}
307308

308309
func sendFinalizeAllocation(allocationID string) {
309-
var tx, err = transaction.NewTransactionEntity()
310-
if err != nil {
311-
logging.Logger.Error("creating new transaction entity", zap.Error(err))
312-
return
313-
}
314-
315310
var request finalizeRequest
316311
request.AllocationID = allocationID
317312

318-
err = tx.ExecuteSmartContract(
313+
_, _, _, _, err := coreTxn.SmartContractTxn(
319314
transaction.STORAGE_CONTRACT_ADDRESS,
320-
transaction.FINALIZE_ALLOCATION,
321-
request,
322-
0)
315+
coreTxn.SmartContractTxnData{
316+
Name: transaction.FINALIZE_ALLOCATION,
317+
InputArgs: request,
318+
})
323319
if err != nil {
324320
logging.Logger.Error("sending finalize allocation", zap.Error(err))
325321
return

0 commit comments

Comments
 (0)