From c8de907b1832cbf4e3043340ade8f2c69ea5778f Mon Sep 17 00:00:00 2001 From: lpoli Date: Tue, 11 Jul 2023 14:09:07 +0545 Subject: [PATCH 01/13] Send WM commit status to conductor --- .../blobbercore/writemarker/protocol.go | 2 +- .../writemarker/protocol_integration_test.go | 20 +++++++++++++++ .../blobbercore/writemarker/protocol_main.go | 10 ++++++++ .../0chain.net/conductor/conductrpc/client.go | 5 ++++ .../0chain.net/conductor/conductrpc/entity.go | 25 +++++++++++-------- 5 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 code/go/0chain.net/blobbercore/writemarker/protocol_integration_test.go create mode 100644 code/go/0chain.net/blobbercore/writemarker/protocol_main.go diff --git a/code/go/0chain.net/blobbercore/writemarker/protocol.go b/code/go/0chain.net/blobbercore/writemarker/protocol.go index 5bb8e1543..86725ebcd 100644 --- a/code/go/0chain.net/blobbercore/writemarker/protocol.go +++ b/code/go/0chain.net/blobbercore/writemarker/protocol.go @@ -96,7 +96,7 @@ func (wme *WriteMarkerEntity) VerifyMarker(ctx context.Context, dbAllocation *al return nil } -func (wme *WriteMarkerEntity) RedeemMarker(ctx context.Context) error { +func (wme *WriteMarkerEntity) redeemMarker(ctx context.Context) error { if len(wme.CloseTxnID) > 0 { t, err := transaction.VerifyTransaction(wme.CloseTxnID, chain.GetServerChain()) if err == nil { diff --git a/code/go/0chain.net/blobbercore/writemarker/protocol_integration_test.go b/code/go/0chain.net/blobbercore/writemarker/protocol_integration_test.go new file mode 100644 index 000000000..b506ebade --- /dev/null +++ b/code/go/0chain.net/blobbercore/writemarker/protocol_integration_test.go @@ -0,0 +1,20 @@ +//go:build integration_tests +// +build integration_tests + +package writemarker + +import ( + "context" + + "github.com/0chain/blobber/code/go/0chain.net/conductor/conductrpc" + "github.com/0chain/blobber/code/go/0chain.net/core/node" +) + +func (wme *WriteMarkerEntity) RedeemMarker(ctx context.Context) error { + err := wme.redeemMarker(ctx) + if err == nil { + // send state to conductor server + conductrpc.Client().BlobberCommitted(node.Self.ID) + } + return err +} diff --git a/code/go/0chain.net/blobbercore/writemarker/protocol_main.go b/code/go/0chain.net/blobbercore/writemarker/protocol_main.go new file mode 100644 index 000000000..77b2ebcbb --- /dev/null +++ b/code/go/0chain.net/blobbercore/writemarker/protocol_main.go @@ -0,0 +1,10 @@ +//go:build !integration_tests +// +build !integration_tests + +package writemarker + +import "context" + +func (wme *WriteMarkerEntity) RedeemMarker(ctx context.Context) error { + return wme.redeemMarker(ctx) +} diff --git a/code/go/0chain.net/conductor/conductrpc/client.go b/code/go/0chain.net/conductor/conductrpc/client.go index 97db9917a..e73885538 100644 --- a/code/go/0chain.net/conductor/conductrpc/client.go +++ b/code/go/0chain.net/conductor/conductrpc/client.go @@ -47,3 +47,8 @@ func (c *client) state(me NodeID) (state *State, err error) { } return } + +func (c *client) blobberCommitted(blobberID string) (err error) { + err = c.client.Call("Server.BlobberCommitted", blobberID, nil) + return +} diff --git a/code/go/0chain.net/conductor/conductrpc/entity.go b/code/go/0chain.net/conductor/conductrpc/entity.go index e37473236..9965c9a79 100644 --- a/code/go/0chain.net/conductor/conductrpc/entity.go +++ b/code/go/0chain.net/conductor/conductrpc/entity.go @@ -100,6 +100,10 @@ func (e *Entity) isMonitor() bool { //nolint:unused,deadcode // might be used la return state != nil && state.IsMonitor } +func (e *Entity) BlobberCommitted(blobberID string) { + e.client.blobberCommitted(blobberID) +} + // // global // @@ -120,17 +124,16 @@ func Shutdown() { // Client returns global Entity to interact with. Use it, for example, // -// var state = conductrpc.Client().State() -// for _, minerID := range miners { -// if state.VRFS.IsBad(state, minerID) { -// // send bad VRFS to this miner -// } else if state.VRFS.IsGood(state, minerID) { -// // send good VRFS to this miner -// } else { -// // don't send a VRFS to this miner -// } -// } -// +// var state = conductrpc.Client().State() +// for _, minerID := range miners { +// if state.VRFS.IsBad(state, minerID) { +// // send bad VRFS to this miner +// } else if state.VRFS.IsGood(state, minerID) { +// // send good VRFS to this miner +// } else { +// // don't send a VRFS to this miner +// } +// } func Client() *Entity { return global } From 8e99dbf5c0075c238c6d41f15eb5f43fd12044c9 Mon Sep 17 00:00:00 2001 From: lpoli Date: Wed, 12 Jul 2023 19:35:52 +0545 Subject: [PATCH 02/13] Rename file --- ...protocol_integration_test.go => protocol_integration_tests.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename code/go/0chain.net/blobbercore/writemarker/{protocol_integration_test.go => protocol_integration_tests.go} (100%) diff --git a/code/go/0chain.net/blobbercore/writemarker/protocol_integration_test.go b/code/go/0chain.net/blobbercore/writemarker/protocol_integration_tests.go similarity index 100% rename from code/go/0chain.net/blobbercore/writemarker/protocol_integration_test.go rename to code/go/0chain.net/blobbercore/writemarker/protocol_integration_tests.go From 71aaa876ea4e39803643d4c4f6ff18157934bdf3 Mon Sep 17 00:00:00 2001 From: lpoli Date: Tue, 25 Jul 2023 09:57:25 +0545 Subject: [PATCH 03/13] Modify log type --- code/go/0chain.net/blobbercore/challenge/protocol.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/go/0chain.net/blobbercore/challenge/protocol.go b/code/go/0chain.net/blobbercore/challenge/protocol.go index 1c297fdf3..aa4423f8c 100644 --- a/code/go/0chain.net/blobbercore/challenge/protocol.go +++ b/code/go/0chain.net/blobbercore/challenge/protocol.go @@ -255,7 +255,7 @@ func (cr *ChallengeEntity) LoadValidationTickets(ctx context.Context) error { resp, err := util.SendPostRequest(url, postDataBytes, nil) if err != nil { //network issue, don't cancel it, and try it again - logging.Logger.Info("[challenge]post: ", zap.Any("error", err.Error())) + logging.Logger.Error("[challenge]post: ", zap.Any("error", err.Error())) updateMapAndSlice(validatorID, i, nil) return } From 8e765d0bda54abc1ddad7ab7702a15f617419efd Mon Sep 17 00:00:00 2001 From: lpoli Date: Sat, 29 Jul 2023 10:02:49 +0545 Subject: [PATCH 04/13] Add state for stopping blobber from committing WM --- .../writemarker/protocol_integration_tests.go | 9 +++++ .../0chain.net/conductor/conductrpc/state.go | 34 ++----------------- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/code/go/0chain.net/blobbercore/writemarker/protocol_integration_tests.go b/code/go/0chain.net/blobbercore/writemarker/protocol_integration_tests.go index b506ebade..7f284eb49 100644 --- a/code/go/0chain.net/blobbercore/writemarker/protocol_integration_tests.go +++ b/code/go/0chain.net/blobbercore/writemarker/protocol_integration_tests.go @@ -5,12 +5,21 @@ package writemarker import ( "context" + "time" "github.com/0chain/blobber/code/go/0chain.net/conductor/conductrpc" "github.com/0chain/blobber/code/go/0chain.net/core/node" ) func (wme *WriteMarkerEntity) RedeemMarker(ctx context.Context) error { + for { + state := conductrpc.Client().State() + if state.StopWMCommit != nil && *state.StopWMCommit { + time.Sleep(time.Second * 5) + continue + } + break + } err := wme.redeemMarker(ctx) if err == nil { // send state to conductor server diff --git a/code/go/0chain.net/conductor/conductrpc/state.go b/code/go/0chain.net/conductor/conductrpc/state.go index 13933050b..d244a4a44 100644 --- a/code/go/0chain.net/conductor/conductrpc/state.go +++ b/code/go/0chain.net/conductor/conductrpc/state.go @@ -50,37 +50,8 @@ type State struct { // Nodes maps NodeID -> NodeName. Nodes map[NodeID]NodeName - IsMonitor bool // send monitor events (round, phase, etc) - IsLock bool // node locked - IsRevealed bool // revealed shares - // Byzantine state. Below, if a value is nil, then node behaves as usual - // for it. - // - // Byzantine blockchain - VRFS *config.Bad - RoundTimeout *config.Bad - CompetingBlock *config.Bad - SignOnlyCompetingBlocks *config.Bad - DoubleSpendTransaction *config.Bad - WrongBlockSignHash *config.Bad - WrongBlockSignKey *config.Bad - WrongBlockHash *config.Bad - VerificationTicketGroup *config.Bad - WrongVerificationTicketHash *config.Bad - WrongVerificationTicketKey *config.Bad - WrongNotarizedBlockHash *config.Bad - WrongNotarizedBlockKey *config.Bad - NotarizeOnlyCompetingBlock *config.Bad - NotarizedBlock *config.Bad - // Byzantine blockchain sharders - FinalizedBlock *config.Bad - MagicBlock *config.Bad - VerifyTransaction *config.Bad - // Byzantine View Change - MPK *config.Bad - Shares *config.Bad - Signatures *config.Bad - Publish *config.Bad + IsMonitor bool // send monitor events (round, phase, etc) + IsLock bool // node locked // Blobbers related states StorageTree *config.Bad // blobber sends bad files/tree responses @@ -91,6 +62,7 @@ type State struct { BlobberUpload BlobberUpload BlobberDelete BlobberDelete AdversarialValidator AdversarialValidator + StopWMCommit *bool } // Name returns NodeName by given NodeID. From bce9c4524159f01403a3e3ba9398240462e852f9 Mon Sep 17 00:00:00 2001 From: lpoli Date: Thu, 3 Aug 2023 16:01:32 +0545 Subject: [PATCH 05/13] Send file meta root to rpc server --- .../0chain.net/conductor/conductrpc/client.go | 5 ++ .../0chain.net/conductor/conductrpc/entity.go | 17 +++++++ .../conductor/conductrpc/file_meta.go | 51 +++++++++++++++++++ .../0chain.net/conductor/conductrpc/state.go | 1 + 4 files changed, 74 insertions(+) create mode 100644 code/go/0chain.net/conductor/conductrpc/file_meta.go diff --git a/code/go/0chain.net/conductor/conductrpc/client.go b/code/go/0chain.net/conductor/conductrpc/client.go index e73885538..f21410310 100644 --- a/code/go/0chain.net/conductor/conductrpc/client.go +++ b/code/go/0chain.net/conductor/conductrpc/client.go @@ -52,3 +52,8 @@ func (c *client) blobberCommitted(blobberID string) (err error) { err = c.client.Call("Server.BlobberCommitted", blobberID, nil) return } + +func (c *client) sendFileMetaRoot(m map[string]string) (err error) { + err = c.client.Call("Server.GetFileMetaRoot", m, nil) + return +} diff --git a/code/go/0chain.net/conductor/conductrpc/entity.go b/code/go/0chain.net/conductor/conductrpc/entity.go index 9965c9a79..4b218a73d 100644 --- a/code/go/0chain.net/conductor/conductrpc/entity.go +++ b/code/go/0chain.net/conductor/conductrpc/entity.go @@ -1,6 +1,7 @@ package conductrpc import ( + "context" "log" "sync" "sync/atomic" @@ -31,6 +32,10 @@ func (e *Entity) State() (state *State) { // SetState sets current state. func (e *Entity) SetState(state *State) { e.state.Store(state) // update + + if state.GetFileMetaRoot != nil { + go SendFileMetaRoot() + } } // NewEntity creates RPC client for integration tests. @@ -104,6 +109,18 @@ func (e *Entity) BlobberCommitted(blobberID string) { e.client.blobberCommitted(blobberID) } +func (e *Entity) SendFileMetaRoot(blobberID, fileMetaRoot string, ctxCncl context.CancelFunc) { + m := map[string]string{ + "blobber_id": blobberID, + "file_meta_root": fileMetaRoot, + } + err := e.client.sendFileMetaRoot(m) + if err != nil { + return + } + ctxCncl() +} + // // global // diff --git a/code/go/0chain.net/conductor/conductrpc/file_meta.go b/code/go/0chain.net/conductor/conductrpc/file_meta.go new file mode 100644 index 000000000..8f628f893 --- /dev/null +++ b/code/go/0chain.net/conductor/conductrpc/file_meta.go @@ -0,0 +1,51 @@ +package conductrpc + +import ( + "context" + + "log" + + "github.com/0chain/blobber/code/go/0chain.net/core/node" +) + +// alreadyRunning is simple indicator that given function is running +// no need to acquire mutex lock. It does not matter if at a time it +// somehow runs the given function multiple times. Since it takes some +// time to acquire state from rpc server there is no concurrent running +var alreadyRunning bool + +func SendFileMetaRoot() { + if alreadyRunning { + return + } + alreadyRunning = true + defer func() { + alreadyRunning = false + }() + + ctx, ctxCncl := context.WithCancel(context.TODO()) + defer ctxCncl() + + for { + select { + case <-ctx.Done(): + return + default: + } + + s := global.State() + if s.GetFileMetaRoot != nil { + fmr, err := getFileMetaRoot() + if err != nil { + log.Printf("Error: %v", err) + continue + } + + global.SendFileMetaRoot(node.Self.ID, fmr, ctxCncl) + } + } +} + +func getFileMetaRoot() (string, error) { + return "", nil +} diff --git a/code/go/0chain.net/conductor/conductrpc/state.go b/code/go/0chain.net/conductor/conductrpc/state.go index d244a4a44..341a870cd 100644 --- a/code/go/0chain.net/conductor/conductrpc/state.go +++ b/code/go/0chain.net/conductor/conductrpc/state.go @@ -63,6 +63,7 @@ type State struct { BlobberDelete BlobberDelete AdversarialValidator AdversarialValidator StopWMCommit *bool + GetFileMetaRoot *bool } // Name returns NodeName by given NodeID. From c5a30581f0df63976eb4b2d810ac5749ed7ab94e Mon Sep 17 00:00:00 2001 From: lpoli Date: Fri, 4 Aug 2023 13:04:00 +0545 Subject: [PATCH 06/13] Export function to use it in conductor client --- code/go/0chain.net/blobbercore/allocation/workers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/go/0chain.net/blobbercore/allocation/workers.go b/code/go/0chain.net/blobbercore/allocation/workers.go index f04ac5a30..6096a0541 100644 --- a/code/go/0chain.net/blobbercore/allocation/workers.go +++ b/code/go/0chain.net/blobbercore/allocation/workers.go @@ -88,7 +88,7 @@ func updateWork(ctx context.Context) { // iterate all in loop accepting allocations with limit for start := true; start || (offset < count); start = false { - allocs, count, err = findAllocations(ctx, offset) + allocs, count, err = FindAllocations(ctx, offset) if err != nil { logging.Logger.Error("finding allocations in DB", zap.Error(err)) if waitOrQuit(ctx, UPDATE_DB_INTERVAL) { @@ -109,7 +109,7 @@ func updateWork(ctx context.Context) { } // not finalized, not cleaned up -func findAllocations(ctx context.Context, offset int64) (allocs []*Allocation, count int64, err error) { +func FindAllocations(ctx context.Context, offset int64) (allocs []*Allocation, count int64, err error) { const query = `finalized = false AND cleaned_up = false` ctx = datastore.GetStore().CreateTransaction(ctx) From 8a6aeeda6c219cf9ab7d2c4092d91e39a346cddb Mon Sep 17 00:00:00 2001 From: lpoli Date: Fri, 4 Aug 2023 13:04:15 +0545 Subject: [PATCH 07/13] Modify field type --- code/go/0chain.net/conductor/conductrpc/entity.go | 2 +- code/go/0chain.net/conductor/conductrpc/state.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/go/0chain.net/conductor/conductrpc/entity.go b/code/go/0chain.net/conductor/conductrpc/entity.go index 4b218a73d..13461df47 100644 --- a/code/go/0chain.net/conductor/conductrpc/entity.go +++ b/code/go/0chain.net/conductor/conductrpc/entity.go @@ -33,7 +33,7 @@ func (e *Entity) State() (state *State) { func (e *Entity) SetState(state *State) { e.state.Store(state) // update - if state.GetFileMetaRoot != nil { + if state.GetFileMetaRoot { go SendFileMetaRoot() } } diff --git a/code/go/0chain.net/conductor/conductrpc/state.go b/code/go/0chain.net/conductor/conductrpc/state.go index 341a870cd..87b42c0f9 100644 --- a/code/go/0chain.net/conductor/conductrpc/state.go +++ b/code/go/0chain.net/conductor/conductrpc/state.go @@ -63,7 +63,7 @@ type State struct { BlobberDelete BlobberDelete AdversarialValidator AdversarialValidator StopWMCommit *bool - GetFileMetaRoot *bool + GetFileMetaRoot bool } // Name returns NodeName by given NodeID. From 7dd0419b2abfb2b0e20a6783f6958667017fc45d Mon Sep 17 00:00:00 2001 From: lpoli Date: Fri, 4 Aug 2023 13:04:42 +0545 Subject: [PATCH 08/13] Add code to get file meta root --- .../0chain.net/conductor/conductrpc/file_meta.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/code/go/0chain.net/conductor/conductrpc/file_meta.go b/code/go/0chain.net/conductor/conductrpc/file_meta.go index 8f628f893..c0a950d15 100644 --- a/code/go/0chain.net/conductor/conductrpc/file_meta.go +++ b/code/go/0chain.net/conductor/conductrpc/file_meta.go @@ -2,9 +2,11 @@ package conductrpc import ( "context" + "errors" "log" + "github.com/0chain/blobber/code/go/0chain.net/blobbercore/allocation" "github.com/0chain/blobber/code/go/0chain.net/core/node" ) @@ -34,7 +36,7 @@ func SendFileMetaRoot() { } s := global.State() - if s.GetFileMetaRoot != nil { + if s.GetFileMetaRoot { fmr, err := getFileMetaRoot() if err != nil { log.Printf("Error: %v", err) @@ -47,5 +49,13 @@ func SendFileMetaRoot() { } func getFileMetaRoot() (string, error) { - return "", nil + allocs, _, err := allocation.FindAllocations(context.TODO(), 0) + if err != nil { + return "", err + } + if len(allocs) == 0 { + return "", errors.New("allocation not found") + } + alloc := allocs[0] + return alloc.FileMetaRoot, nil } From efc4535283047194f457d57c083d9932a8095764 Mon Sep 17 00:00:00 2001 From: lpoli Date: Fri, 4 Aug 2023 14:31:13 +0545 Subject: [PATCH 09/13] Modify file meta root retrieval --- .../conductor/conductrpc/file_meta.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/code/go/0chain.net/conductor/conductrpc/file_meta.go b/code/go/0chain.net/conductor/conductrpc/file_meta.go index c0a950d15..09a503cb6 100644 --- a/code/go/0chain.net/conductor/conductrpc/file_meta.go +++ b/code/go/0chain.net/conductor/conductrpc/file_meta.go @@ -2,11 +2,11 @@ package conductrpc import ( "context" - "errors" "log" - "github.com/0chain/blobber/code/go/0chain.net/blobbercore/allocation" + "github.com/0chain/blobber/code/go/0chain.net/blobbercore/datastore" + "github.com/0chain/blobber/code/go/0chain.net/core/node" ) @@ -49,13 +49,14 @@ func SendFileMetaRoot() { } func getFileMetaRoot() (string, error) { - allocs, _, err := allocation.FindAllocations(context.TODO(), 0) + db := datastore.GetStore().GetDB() + var fmr string + + err := db.Raw("SELECT file_meta_root FROM allocations LIMIT 1").Scan(&fmr).Error + if err != nil { return "", err } - if len(allocs) == 0 { - return "", errors.New("allocation not found") - } - alloc := allocs[0] - return alloc.FileMetaRoot, nil + + return fmr, nil } From 5eb0285d25e8a169aff0ae9c438424f6ba5ba8a5 Mon Sep 17 00:00:00 2001 From: lpoli Date: Fri, 4 Aug 2023 14:31:21 +0545 Subject: [PATCH 10/13] Add field --- code/go/0chain.net/conductor/conductrpc/state.go | 1 + 1 file changed, 1 insertion(+) diff --git a/code/go/0chain.net/conductor/conductrpc/state.go b/code/go/0chain.net/conductor/conductrpc/state.go index 87b42c0f9..f503156a5 100644 --- a/code/go/0chain.net/conductor/conductrpc/state.go +++ b/code/go/0chain.net/conductor/conductrpc/state.go @@ -63,6 +63,7 @@ type State struct { BlobberDelete BlobberDelete AdversarialValidator AdversarialValidator StopWMCommit *bool + FailRenameCommit []string GetFileMetaRoot bool } From 416965aa0acd2fe86540b0ce54447fe266babc25 Mon Sep 17 00:00:00 2001 From: lpoli Date: Fri, 4 Aug 2023 14:31:43 +0545 Subject: [PATCH 11/13] Apply rename for conductor test based on conductor state --- .../allocation/renamefilechange.go | 2 +- .../renamefilechange_integration.go | 28 +++++++++++++++++++ .../allocation/renamefilechange_main.go | 17 +++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 code/go/0chain.net/blobbercore/allocation/renamefilechange_integration.go create mode 100644 code/go/0chain.net/blobbercore/allocation/renamefilechange_main.go diff --git a/code/go/0chain.net/blobbercore/allocation/renamefilechange.go b/code/go/0chain.net/blobbercore/allocation/renamefilechange.go index 75145e6e3..43a78e583 100644 --- a/code/go/0chain.net/blobbercore/allocation/renamefilechange.go +++ b/code/go/0chain.net/blobbercore/allocation/renamefilechange.go @@ -24,7 +24,7 @@ func (rf *RenameFileChange) DeleteTempFile() error { return nil } -func (rf *RenameFileChange) ApplyChange(ctx context.Context, rootRef *reference.Ref, change *AllocationChange, +func (rf *RenameFileChange) applyChange(ctx context.Context, rootRef *reference.Ref, change *AllocationChange, allocationRoot string, ts common.Timestamp, _ map[string]string) (*reference.Ref, error) { if rf.Path == "/" { diff --git a/code/go/0chain.net/blobbercore/allocation/renamefilechange_integration.go b/code/go/0chain.net/blobbercore/allocation/renamefilechange_integration.go new file mode 100644 index 000000000..1e23b568a --- /dev/null +++ b/code/go/0chain.net/blobbercore/allocation/renamefilechange_integration.go @@ -0,0 +1,28 @@ +//go:build integration_tests +// +build integration_tests + +package allocation + +import ( + "context" + "errors" + + "github.com/0chain/blobber/code/go/0chain.net/blobbercore/reference" + "github.com/0chain/blobber/code/go/0chain.net/conductor/conductrpc" + "github.com/0chain/blobber/code/go/0chain.net/core/common" + "github.com/0chain/blobber/code/go/0chain.net/core/node" +) + +func (rf *RenameFileChange) ApplyChange(ctx context.Context, rootRef *reference.Ref, change *AllocationChange, + allocationRoot string, ts common.Timestamp, _ map[string]string) (*reference.Ref, error) { + + state := conductrpc.Client().State() + if state.FailRenameCommit != nil { + for _, nodeId := range state.FailRenameCommit { + if nodeId == node.Self.ID { + return nil, errors.New("error directed by conductor") + } + } + } + return rf.applyChange(ctx, rootRef, change, allocationRoot, ts, nil) +} diff --git a/code/go/0chain.net/blobbercore/allocation/renamefilechange_main.go b/code/go/0chain.net/blobbercore/allocation/renamefilechange_main.go new file mode 100644 index 000000000..9c773cab7 --- /dev/null +++ b/code/go/0chain.net/blobbercore/allocation/renamefilechange_main.go @@ -0,0 +1,17 @@ +//go:build !integration_tests +// +build !integration_tests + +package allocation + +import ( + "context" + + "github.com/0chain/blobber/code/go/0chain.net/blobbercore/reference" + "github.com/0chain/blobber/code/go/0chain.net/core/common" +) + +func (rf *RenameFileChange) ApplyChange(ctx context.Context, rootRef *reference.Ref, change *AllocationChange, + allocationRoot string, ts common.Timestamp, _ map[string]string) (*reference.Ref, error) { + + return rf.applyChange(ctx, rootRef, change, allocationRoot, ts, nil) +} From 66319cfaa11a13538fdef91957431c0aefc449fb Mon Sep 17 00:00:00 2001 From: lpoli Date: Fri, 4 Aug 2023 15:42:24 +0545 Subject: [PATCH 12/13] Add comment --- code/go/0chain.net/conductor/conductrpc/file_meta.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/go/0chain.net/conductor/conductrpc/file_meta.go b/code/go/0chain.net/conductor/conductrpc/file_meta.go index 09a503cb6..b203c5ec6 100644 --- a/code/go/0chain.net/conductor/conductrpc/file_meta.go +++ b/code/go/0chain.net/conductor/conductrpc/file_meta.go @@ -52,6 +52,8 @@ func getFileMetaRoot() (string, error) { db := datastore.GetStore().GetDB() var fmr string + // It will work fine because this blobber will have only single allocation + // created by conductor err := db.Raw("SELECT file_meta_root FROM allocations LIMIT 1").Scan(&fmr).Error if err != nil { From 3c2357f1e930f3311b12d14c32800d8a8f27be3f Mon Sep 17 00:00:00 2001 From: lpoli Date: Fri, 4 Aug 2023 20:34:16 +0545 Subject: [PATCH 13/13] Log error --- code/go/0chain.net/conductor/conductrpc/entity.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/go/0chain.net/conductor/conductrpc/entity.go b/code/go/0chain.net/conductor/conductrpc/entity.go index 13461df47..a65f75a8c 100644 --- a/code/go/0chain.net/conductor/conductrpc/entity.go +++ b/code/go/0chain.net/conductor/conductrpc/entity.go @@ -106,7 +106,10 @@ func (e *Entity) isMonitor() bool { //nolint:unused,deadcode // might be used la } func (e *Entity) BlobberCommitted(blobberID string) { - e.client.blobberCommitted(blobberID) + err := e.client.blobberCommitted(blobberID) + if err != nil { + log.Println(err) + } } func (e *Entity) SendFileMetaRoot(blobberID, fileMetaRoot string, ctxCncl context.CancelFunc) {