Skip to content

Commit

Permalink
Fix set last submitted height for validator instead of authorized add…
Browse files Browse the repository at this point in the history
…ress
  • Loading branch information
p0p3yee committed Oct 24, 2024
1 parent 7071416 commit 1af6c20
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion x/keyshare/keeper/msg_send_keyshare.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ func (k msgServer) SendKeyshare(goCtx context.Context, msg *types.MsgSendKeyshar
// Save the new keyshare to state
k.SetKeyshare(ctx, keyshare)

k.SetLastSubmittedHeight(ctx, msg.Creator, strconv.FormatUint(msg.BlockHeight, 10))
// It should set the validator last submitted height instead of the `msg.creator`,
// which might be the authorized address
k.SetLastSubmittedHeight(ctx, validatorInfo.Validator, strconv.FormatUint(msg.BlockHeight, 10))

validatorList := k.GetAllValidatorSet(ctx)

Expand Down
7 changes: 4 additions & 3 deletions x/keyshare/keeper/msg_submit_encrypted_keyshare.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ func (k msgServer) SubmitEncryptedKeyshare(goCtx context.Context, msg *types.Msg
ctx := sdk.UnwrapSDKContext(goCtx)

// check if validator is registered
_, found := k.GetValidatorSet(ctx, msg.Creator)
validatorInfo, found := k.GetValidatorSet(ctx, msg.Creator)

if !found {
authorizedAddrInfo, found := k.GetAuthorizedAddress(ctx, msg.Creator)
if !found || !authorizedAddrInfo.IsAuthorized {
return nil, types.ErrAddrIsNotValidatorOrAuthorized.Wrap(msg.Creator)
}

_, found = k.GetValidatorSet(ctx, authorizedAddrInfo.AuthorizedBy)
authorizedByValInfo, found := k.GetValidatorSet(ctx, authorizedAddrInfo.AuthorizedBy)
if !found {
return nil, types.ErrAuthorizerIsNotValidator.Wrap(authorizedAddrInfo.AuthorizedBy)
}
validatorInfo = authorizedByValInfo

// If the sender is in the validator set & authorized another address to submit key share
} else if count := k.GetAuthorizedCount(ctx, msg.Creator); count != 0 {
Expand Down Expand Up @@ -62,7 +63,7 @@ func (k msgServer) SubmitEncryptedKeyshare(goCtx context.Context, msg *types.Msg

// Save the new private keyshare to state
k.SetPrivateKeyshare(ctx, valEncKeyshare)
k.SetLastSubmittedHeight(ctx, msg.Creator, strconv.FormatInt(ctx.BlockHeight(), 10))
k.SetLastSubmittedHeight(ctx, validatorInfo.Validator, strconv.FormatInt(ctx.BlockHeight(), 10))

validatorList := k.GetAllValidatorSet(ctx)

Expand Down
2 changes: 1 addition & 1 deletion x/keyshare/keeper/msg_submit_general_keyshare.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (k msgServer) SubmitGeneralKeyshare(

// Save the new general key share to state
k.SetGeneralKeyshare(ctx, generalKeyshare)
k.SetLastSubmittedHeight(ctx, msg.Creator, strconv.FormatInt(ctx.BlockHeight(), 10))
k.SetLastSubmittedHeight(ctx, validatorInfo.Validator, strconv.FormatInt(ctx.BlockHeight(), 10))

validatorList := k.GetAllValidatorSet(ctx)

Expand Down

0 comments on commit 1af6c20

Please sign in to comment.