Skip to content

Commit 1bd2c18

Browse files
Merge branch 'staging' into sprint-1.19
2 parents 04412ef + 6e12623 commit 1bd2c18

File tree

9 files changed

+70
-61
lines changed

9 files changed

+70
-61
lines changed

.github/workflows/build-&-publish-docker-image.yml

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -234,19 +234,6 @@ jobs:
234234
version: '1.7'
235235
force: 'false'
236236

237-
- name: "Create Tenderly virtual testnet"
238-
run: |
239-
echo "TENDERLY_CREATION_INFO=$(curl -X POST \
240-
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \
241-
-H "Content-Type: application/json" \
242-
-d '{"slug":"mainnet-dev-${{ env.RUNNER_NUMBER }}-${{ github.run_id }}","displayName":"mainnet-dev-${{ env.RUNNER_NUMBER }}-${{ github.run_id }}","description":"","visibility":"TEAM","tags":{"purpose":"development"},"networkConfig":{"networkId":"1","blockNumber":"18512782","chainConfig":{"chainId":"1"},"baseFeePerGas":"1"},"explorerConfig":{"enabled":false,"verificationVisibility":"bytecode"},"syncState":false}' \
243-
https://api.tenderly.co/api/v1/account/zus_network/project/project/testnet/container)" >> $GITHUB_ENV
244-
245-
- name: "Parse Tenderly virtual testnet creation transaction result"
246-
run: |
247-
echo "TENDERLY_VIRTUAL_TESTNET_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.container.id')" >> $GITHUB_ENV
248-
echo "TENDERLY_VIRTUAL_TESTNET_RPC_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.container.connectivityConfig.endpoints[0].id')" >> $GITHUB_ENV
249-
250237
- name: "Deploy 0Chain"
251238
uses: 0chain/actions/deploy-0chain@master
252239
with:
@@ -256,10 +243,10 @@ jobs:
256243
blobber_image: ${{ env.TAG }}-${{ env.SHORT_SHA }}
257244
validator_image: ${{ env.TAG }}-${{ env.SHORT_SHA }}
258245
SUBGRAPH_API_URL: ${{ secrets.SUBGRAPH_API_URL }}
259-
TENDERLY_VIRTUAL_TESTNET_RPC_ID: ${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }}
246+
TENDERLY_VIRTUAL_TESTNET_RPC_ID: ""
260247
graphnode_sc: ${{ secrets.GRAPHNODE_SC }}
261248
graphnode_network: ${{ secrets.GRAPHNODE_NETWORK }}
262-
graphnode_ethereum_node_url: https://virtual.mainnet.rpc.tenderly.co/${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }}
249+
graphnode_ethereum_node_url: ""
263250
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}
264251

265252
- name: "Run System tests"
@@ -273,19 +260,11 @@ jobs:
273260
run_flaky_tests: false
274261
retry_failures: true
275262
run_smoke_tests: ${{ github.ref != 'refs/heads/staging' && github.base_ref != 'staging' && github.ref != 'refs/heads/master' && github.base_ref != 'master' }}
276-
TENDERLY_VIRTUAL_TESTNET_RPC_ID: ${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }}
263+
TENDERLY_VIRTUAL_TESTNET_RPC_ID: ""
277264
DEVOPS_CHANNEL_WEBHOOK_URL: ${{ secrets.DEVOPS_CHANNEL_WEBHOOK_URL }}
278265
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
279266
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
280267

281-
- name: "Remove Tenderly virtual testnet"
282-
if: always()
283-
run: |
284-
curl -X DELETE \
285-
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \
286-
-H "Content-Type: application/json" \
287-
https://api.tenderly.co/api/v1/account/zus_network/project/project/testnet/container/${{ env.TENDERLY_VIRTUAL_TESTNET_ID }}
288-
289268
- name: "Set PR status as ${{ job.status }}"
290269
if: ${{ (success() || failure()) && steps.findPr.outputs.number }}
291270
uses: 0chain/actions/set-pr-status@master

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package main
22

33
import (
44
"fmt"
5+
"time"
6+
57
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/config"
68
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/filestore"
79
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/handler"
@@ -11,8 +13,8 @@ import (
1113
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
1214
"github.com/0chain/blobber/code/go/0chain.net/core/node"
1315
"github.com/0chain/gosdk/core/client"
16+
"github.com/0chain/gosdk/zcncore"
1417
"go.uber.org/zap"
15-
"time"
1618
)
1719

1820
func registerOnChain() error {
@@ -81,8 +83,23 @@ func setupServerChain() error {
8183
serverChain := chain.NewChainFromConfig()
8284
chain.SetServerChain(serverChain)
8385

84-
if err := client.InitSDK(node.Self.GetWalletString(), serverChain.BlockWorker, config.Configuration.ChainID, config.Configuration.SignatureScheme,
85-
0, false, true); err != nil {
86+
//options := []int{
87+
// 0,
88+
// 10, // MinConfirmation
89+
// 20, // MinSubmit
90+
// 3, // ConfirmationChainLength
91+
// 3, // SharderConsensous
92+
// 1, // QuerySleepTime
93+
// 0, // VerifyOptimistic
94+
//}
95+
96+
err := client.InitSDK("{}", serverChain.BlockWorker, config.Configuration.ChainID, config.Configuration.SignatureScheme, 0, false)
97+
if err != nil {
98+
return err
99+
}
100+
101+
err = zcncore.SetGeneralWalletInfo(node.Self.GetWalletString(), config.Configuration.SignatureScheme)
102+
if err != nil {
86103
return err
87104
}
88105

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ func setup(t *testing.T) {
8282
},
8383
),
8484
)
85-
86-
//if err := client.InitSDK(server.URL, "ed25519"); err != nil {
87-
// t.Fatal(err)
88-
//}
8985
}
9086
func setupMockForFileManagerInit(mock sqlmock.Sqlmock) {
9187
mock.ExpectBegin()

code/go/0chain.net/blobbercore/handler/handler_common.go

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,19 @@ func HomepageHandler(w http.ResponseWriter, r *http.Request) {
9494
node.Self.ID, node.Self.PublicKey, build.BuildTag,
9595
)
9696

97-
fmt.Fprintf(w, "<div>Miners ...\n")
98-
network, _ := client.GetNetwork(context.Background())
99-
for _, miner := range network.Miners {
100-
fmt.Fprintf(w, "%v\n", miner)
101-
}
102-
fmt.Fprintf(w, "</div>\n")
103-
fmt.Fprintf(w, "<div>Sharders ...\n")
104-
for _, sharder := range network.Sharders {
105-
fmt.Fprintf(w, "%v\n", sharder)
97+
network, err := client.GetNetwork(context.Background())
98+
if err == nil {
99+
fmt.Fprintf(w, "<div>Miners ...\n")
100+
for _, miner := range network.Miners {
101+
fmt.Fprintf(w, "%v\n", miner)
102+
}
103+
fmt.Fprintf(w, "</div>\n")
104+
fmt.Fprintf(w, "<div>Sharders ...\n")
105+
for _, sharder := range network.Sharders {
106+
fmt.Fprintf(w, "%v\n", sharder)
107+
}
108+
fmt.Fprintf(w, "</div>\n")
106109
}
107-
fmt.Fprintf(w, "</div>\n")
108110
fmt.Fprintf(w, "</br>")
109111
fmt.Fprintf(w, "<div>Running since %v (Total elapsed time: %v)</div>\n", StartTime.Format(common.DateTimeFormat), time.Since(StartTime))
110112
fmt.Fprintf(w, "</br>")
@@ -187,11 +189,13 @@ func WithStatusConnectionForWM(handler common.StatusCodeResponderF) common.Statu
187189

188190
if blobberRes, ok := resp.(*blobberhttp.CommitResult); ok {
189191
// Save the write marker data
190-
writemarker.SaveMarkerData(allocationID, blobberRes.WriteMarker.WM.Timestamp, blobberRes.WriteMarker.WM.ChainLength)
191-
trie := blobberRes.Trie
192-
if trie != nil {
193-
_ = trie.DeleteNodes()
194-
blobberRes.Trie = nil
192+
if blobberRes.WriteMarker != nil {
193+
writemarker.SaveMarkerData(allocationID, blobberRes.WriteMarker.WM.Timestamp, blobberRes.WriteMarker.WM.ChainLength)
194+
trie := blobberRes.Trie
195+
if trie != nil {
196+
_ = trie.DeleteNodes()
197+
blobberRes.Trie = nil
198+
}
195199
}
196200
} else {
197201
Logger.Error("Invalid response type for commit handler")

code/go/0chain.net/blobbercore/handler/object_operation_handler.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -646,13 +646,17 @@ func (fsh *StorageHandler) CommitWrite(ctx context.Context, r *http.Request) (*b
646646
Logger.Error("Error checking pending markers", zap.Error(err))
647647
return nil, common.NewError("pending_markers", "previous marker is still pending to be redeemed")
648648
}
649-
649+
var result blobberhttp.CommitResult
650650
connectionObj, err := allocation.GetAllocationChanges(ctx, connectionID, allocationID, clientID)
651651
if err != nil {
652652
// might be good to check if blobber already has stored writemarker
653653
return nil, common.NewErrorf("invalid_parameters",
654654
"Invalid connection id. Connection id was not found: %v", err)
655655
}
656+
if connectionObj.Status == allocation.CommittedConnection {
657+
result.Success = true
658+
return &result, nil
659+
}
656660
if len(connectionObj.Changes) == 0 {
657661
if connectionObj.Status == allocation.NewConnection {
658662
return nil, common.NewError("invalid_parameters",
@@ -680,7 +684,6 @@ func (fsh *StorageHandler) CommitWrite(ctx context.Context, r *http.Request) (*b
680684
err)
681685
}
682686

683-
var result blobberhttp.CommitResult
684687
var latestWriteMarkerEntity *writemarker.WriteMarkerEntity
685688
if allocationObj.AllocationRoot == "" {
686689
latestWriteMarkerEntity = nil
@@ -867,7 +870,6 @@ func (fsh *StorageHandler) CommitWrite(ctx context.Context, r *http.Request) (*b
867870

868871
//Delete connection object and its changes
869872

870-
db.Delete(connectionObj)
871873
go allocation.DeleteConnectionObjEntry(connectionID)
872874
go AddWriteMarkerCount(clientID, connectionObj.Size <= 0)
873875

@@ -936,13 +938,17 @@ func (fsh *StorageHandler) CommitWriteV2(ctx context.Context, r *http.Request) (
936938
Logger.Error("Error checking pending markers", zap.Error(err))
937939
return nil, common.NewError("pending_markers", "previous marker is still pending to be redeemed")
938940
}
939-
941+
var result blobberhttp.CommitResult
940942
connectionObj, err := allocation.GetAllocationChanges(ctx, connectionID, allocationID, clientID)
941943
if err != nil {
942944
// might be good to check if blobber already has stored writemarker
943945
return nil, common.NewErrorf("invalid_parameters",
944946
"Invalid connection id. Connection id was not found: %v", err)
945947
}
948+
if connectionObj.Status == allocation.CommittedConnection {
949+
result.Success = true
950+
return &result, nil
951+
}
946952
if len(connectionObj.Changes) == 0 {
947953
if connectionObj.Status == allocation.NewConnection {
948954
return nil, common.NewError("invalid_parameters",
@@ -970,7 +976,6 @@ func (fsh *StorageHandler) CommitWriteV2(ctx context.Context, r *http.Request) (
970976
err)
971977
}
972978

973-
var result blobberhttp.CommitResult
974979
var latestWriteMarkerEntity *writemarker.WriteMarkerEntity
975980
if allocationObj.AllocationRoot == "" {
976981
latestWriteMarkerEntity = nil
@@ -1193,8 +1198,6 @@ func (fsh *StorageHandler) CommitWriteV2(ctx context.Context, r *http.Request) (
11931198
commitSuccess = true
11941199

11951200
//Delete connection object and its changes
1196-
1197-
db.Delete(connectionObj)
11981201
go allocation.DeleteConnectionObjEntry(connectionID)
11991202
go AddWriteMarkerCount(clientID, connectionObj.Size <= 0)
12001203

code/go/0chain.net/core/chain/entity.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Chain struct {
2929
OwnerID string
3030
ParentChainID string
3131
BlockWorker string
32+
ZauthServer string
3233

3334
GenesisBlockHash string
3435
}
@@ -44,7 +45,7 @@ func (c *Chain) Validate(ctx context.Context) error {
4445
return nil
4546
}
4647

47-
//NewChainFromConfig - create a new chain from config
48+
// NewChainFromConfig - create a new chain from config
4849
func NewChainFromConfig() *Chain {
4950
chain := Provider()
5051
chain.ID = common.ToKey(config.Configuration.ChainID)

code/go/0chain.net/validator/main.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import (
44
"context"
55
"flag"
66
"fmt"
7-
"github.com/0chain/gosdk/core/client"
8-
coreTxn "github.com/0chain/gosdk/core/transaction"
97
"log"
108
"net/http"
119
"os"
@@ -14,6 +12,9 @@ import (
1412
"strings"
1513
"time"
1614

15+
"github.com/0chain/gosdk/core/client"
16+
coreTxn "github.com/0chain/gosdk/core/transaction"
17+
1718
"github.com/0chain/blobber/code/go/0chain.net/core/build"
1819
"github.com/0chain/blobber/code/go/0chain.net/core/chain"
1920
"github.com/0chain/blobber/code/go/0chain.net/core/common/handler"
@@ -231,11 +232,19 @@ func SetupValidatorOnBC(logDir string) error {
231232
var logName = logDir + "/validator.log"
232233
zcncore.SetLogFile(logName, false)
233234
zcncore.SetLogLevel(3)
234-
if err := client.InitSDK(node.Self.GetWalletString(), serverChain.BlockWorker,
235-
config.Configuration.ChainID, config.Configuration.SignatureScheme, int64(0), false, true); err != nil {
235+
236+
err := client.InitSDK("{}", serverChain.BlockWorker, config.Configuration.ChainID, config.Configuration.SignatureScheme, int64(0), false)
237+
if err != nil {
236238
return err
237239
}
240+
241+
err = zcncore.SetGeneralWalletInfo(node.Self.GetWalletString(), config.Configuration.SignatureScheme)
242+
if err != nil {
243+
return err
244+
}
245+
238246
go RegisterValidator()
247+
239248
return nil
240249
}
241250

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ toolchain go1.22.5
66

77
require (
88
github.com/0chain/errors v1.0.3
9-
github.com/0chain/gosdk v1.18.0
9+
github.com/0chain/gosdk v1.18.15
1010
github.com/DATA-DOG/go-sqlmock v1.5.0
1111
github.com/didip/tollbooth/v6 v6.1.2
1212
github.com/go-openapi/runtime v0.26.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ github.com/0chain/common v1.18.3 h1:42dYOv2KyMTSanuS67iDtfv+ErbSRqR8NJ3MG72MwaI=
4040
github.com/0chain/common v1.18.3/go.mod h1:Lapu2Tj7z5Sm4r+X141e7vsz4NDODTEypeElYAP3iSw=
4141
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
4242
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
43-
github.com/0chain/gosdk v1.18.0 h1:6mSiUFb4liT50wdsx59tEWMHKWkKQUlZT91ouQAeKcc=
44-
github.com/0chain/gosdk v1.18.0/go.mod h1:8unFy9Dx2YyPKMYPDGR3MFhUEymbAfQcRDm9bobVLGw=
43+
github.com/0chain/gosdk v1.18.15 h1:jujBBRAv2xendebjdoC6nMmoVl5w+uhDrKBqokIvxKI=
44+
github.com/0chain/gosdk v1.18.15/go.mod h1:8unFy9Dx2YyPKMYPDGR3MFhUEymbAfQcRDm9bobVLGw=
4545
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
4646
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
4747
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=

0 commit comments

Comments
 (0)