Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return error if 2/3 votes have not been achieved #32

Merged
merged 14 commits into from
Mar 23, 2023
7 changes: 7 additions & 0 deletions verifier/hash_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/hex"
"io"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -83,6 +84,12 @@ func (v *Verifier) verifyForSingleEvent(event *model.Event) error {
// Call blockchain for object info to get original hash
checksums, err := v.executor.GetObjectInfoChecksums(event.ObjectId)
if err != nil {
if strings.Contains(err.Error(), "No such object") {
err := v.daoManager.EventDao.UpdateEventStatusVerifyResultByChallengeId(event.ChallengeId, model.Skipped, model.Unknown)
if err != nil {
return err
}
}
return err
}
chainRootHash := checksums[event.RedundancyIndex+1]
Expand Down
11 changes: 5 additions & 6 deletions vote/vote_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,11 @@ func (p *VoteProcessor) queryMoreThanTwoThirdVotesForEvent(event *model.Event, v
// skip current tx if reach the max retry.
if triedTimes > QueryVotepoolMaxRetry {
alert.SendTelegramMessage(p.config.AlertConfig.Identity, p.config.AlertConfig.TelegramChatId, p.config.AlertConfig.TelegramBotId, fmt.Sprintf("failed to collect votes for challenge after retry, id: %d", event.ChallengeId))
logging.Logger.Infof("failed to collect votes for challenge after retry, id: %d", event.ChallengeId)
return p.UpdateEventStatus(event.ChallengeId, model.NoEnoughVotesCollected)
err := p.UpdateEventStatus(event.ChallengeId, model.NoEnoughVotesCollected)
if err != nil {
return err
}
return fmt.Errorf("failed to collect votes for challenge after retry, id: %d", event.ChallengeId)
}

queriedVotes, err := p.executor.QueryVotes(localVote.EventHash, votepool.DataAvailabilityChallengeEvent)
Expand All @@ -203,10 +206,6 @@ func (p *VoteProcessor) queryMoreThanTwoThirdVotesForEvent(event *model.Event, v
return err
}
validVotesCountPerReq := len(queriedVotes)
if validVotesCountPerReq == 0 {
continue
}

isLocalVoteIncluded := false

for _, v := range queriedVotes {
Expand Down