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: modify message vote tss to allow operators to vote on ballots assosiated with discarded keygen . #2674

Merged
merged 12 commits into from
Aug 26, 2024
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
### Fixes

* [2654](https://github.com/zeta-chain/node/pull/2654) - add validation for authorization list in when validating genesis state for authorization module
* [2674](https://github.com/zeta-chain/node/pull/2674) - allow operators to vote on ballots assosiated with discarded keygen without affecting the status of the current keygen.

## v19.0.0

Expand Down
20 changes: 15 additions & 5 deletions x/observer/keeper/msg_server_vote_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ func (k msgServer) VoteTSS(goCtx context.Context, msg *types.MsgVoteTSS) (*types
return &types.MsgVoteTSSResponse{}, errorsmod.Wrap(types.ErrKeygenNotFound, voteTSSid)
}

// Use a separate transaction to update keygen status to pending when trying to change the TSS address.
if keygen.Status == types.KeygenStatus_KeyGenSuccess {
return &types.MsgVoteTSSResponse{}, errorsmod.Wrap(types.ErrKeygenCompleted, voteTSSid)
}

fbac marked this conversation as resolved.
Show resolved Hide resolved
// GetBallot checks against the supported chains list before querying for Ballot.
ballotCreated := false
index := msg.Digest()
Expand Down Expand Up @@ -94,6 +89,21 @@ func (k msgServer) VoteTSS(goCtx context.Context, msg *types.MsgVoteTSS) (*types
}, nil
}

// The ballot is finalized, we check if this is the correct ballot for updating the TSS
// The requirements are
// 1. The keygen is still pending
// 2. The keygen block number matches the ballot block number ,which makes sure this the correct ballot for the current keygen

// Return without error so the vote is added to the ballot
if keygen.Status != types.KeygenStatus_PendingKeygen {
return &types.MsgVoteTSSResponse{}, nil
}

// For cases when an observer tries to vote for an older pending ballot , associated with a keygen that was discarded , we would return at this check while still adding the vote to the ballot
if msg.KeygenZetaHeight != keygen.BlockNumber {
fbac marked this conversation as resolved.
Show resolved Hide resolved
return &types.MsgVoteTSSResponse{}, nil
kingpinXD marked this conversation as resolved.
Show resolved Hide resolved
}

// Set TSS only on success, set keygen either way.
// Keygen block can be updated using a policy transaction if keygen fails.
keygenSuccess := false
Expand Down
Loading
Loading