Skip to content

Commit

Permalink
Add handle override pubkey event
Browse files Browse the repository at this point in the history
  • Loading branch information
p0p3yee committed Apr 5, 2024
1 parent c05a9e9 commit 7000509
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/spf13/cobra"
)

const ClientVersion = "v0.5.1"
const ClientVersion = "v0.5.2"

// configCmd represents the config command
var versionCmd = &cobra.Command{
Expand Down
27 changes: 27 additions & 0 deletions internal/fairyringclient/fairyringclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ func handleTxEvents(txOut <-chan coretypes.ResultEvent) {
case "queued-pubkey-created.pubkey":
handleNewPubKeyEvent(result.Events)
break
case "pubkey-overrode.pubkey":
handlePubKeyOverrodeEvent(result.Events)
break
}
}
}
Expand Down Expand Up @@ -343,6 +346,30 @@ func handleStartSubmitGeneralKeyShareEvent(identity string) {
log.Printf("Submit General KeyShare for Identity %s Confirmed\n", identity)
}

func handlePubKeyOverrodeEvent(data map[string][]string) {
pubKey, found := data["pubkey-overrode.pubkey"]
if !found {
return
}

log.Printf("Old Pubkey Overrode, New Pubkey found: %s\n", pubKey[0])

for {
err := validatorCosmosClient.UpdateKeyShareFromChain(false)
if err != nil {
time.Sleep(3 * time.Second)
continue
}
log.Printf(
"Successfully Updated Shares for the current overrode round: %s | Index: %d",
validatorCosmosClient.CurrentShare.Share.Value.String(),
validatorCosmosClient.CurrentShare.Index,
)
validatorCosmosClient.RemovePendingShare()
break
}
}

func handleNewPubKeyEvent(data map[string][]string) {
pubKey, found := data["queued-pubkey-created.pubkey"]
if !found {
Expand Down
5 changes: 5 additions & 0 deletions internal/fairyringclient/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ func (v *ValidatorClients) RemoveCurrentShare() {
v.CurrentShareExpiryBlock = 0
}

func (v *ValidatorClients) RemovePendingShare() {
v.PendingShare = nil
v.PendingShareExpiryBlock = 0
}

func (v *ValidatorClients) UpdateKeyShareFromChain(forNextRound bool) error {
share, shareIndex, expiry, err := v.CosmosClient.GetKeyShare(forNextRound)
if err != nil {
Expand Down

0 comments on commit 7000509

Please sign in to comment.