From c8de907b1832cbf4e3043340ade8f2c69ea5778f Mon Sep 17 00:00:00 2001 From: lpoli Date: Tue, 11 Jul 2023 14:09:07 +0545 Subject: [PATCH 1/5] 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 2/5] 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 3/5] 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 4/5] 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 418a64840614e7d3e92bed6b4eb4dd88cea2cca9 Mon Sep 17 00:00:00 2001 From: lpoli Date: Fri, 4 Aug 2023 16:07:06 +0545 Subject: [PATCH 5/5] 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 9965c9a79..f1cc05ac4 100644 --- a/code/go/0chain.net/conductor/conductrpc/entity.go +++ b/code/go/0chain.net/conductor/conductrpc/entity.go @@ -101,7 +101,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) + } } //