diff --git a/code/go/0chain.net/blobbercore/challenge/protocol.go b/code/go/0chain.net/blobbercore/challenge/protocol.go index 67a853300..9f5ecac0e 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 } diff --git a/code/go/0chain.net/blobbercore/writemarker/protocol.go b/code/go/0chain.net/blobbercore/writemarker/protocol.go index b11c82366..e8997d595 100644 --- a/code/go/0chain.net/blobbercore/writemarker/protocol.go +++ b/code/go/0chain.net/blobbercore/writemarker/protocol.go @@ -102,7 +102,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_tests.go b/code/go/0chain.net/blobbercore/writemarker/protocol_integration_tests.go new file mode 100644 index 000000000..7f284eb49 --- /dev/null +++ b/code/go/0chain.net/blobbercore/writemarker/protocol_integration_tests.go @@ -0,0 +1,29 @@ +//go:build integration_tests +// +build integration_tests + +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 + 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..f1cc05ac4 100644 --- a/code/go/0chain.net/conductor/conductrpc/entity.go +++ b/code/go/0chain.net/conductor/conductrpc/entity.go @@ -100,6 +100,13 @@ func (e *Entity) isMonitor() bool { //nolint:unused,deadcode // might be used la return state != nil && state.IsMonitor } +func (e *Entity) BlobberCommitted(blobberID string) { + err := e.client.blobberCommitted(blobberID) + if err != nil { + log.Println(err) + } +} + // // global // @@ -120,17 +127,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 } 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.