Skip to content

Commit

Permalink
fix tsnonce preventing multisignature bug (#2453)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryfan01234 authored Oct 3, 2024
1 parent dbd45b2 commit 77cef30
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
11 changes: 8 additions & 3 deletions protocol/x/accountplus/ante/timestampnonce.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ func IsTimestampNonceTx(ctx sdk.Context, tx sdk.Tx) (bool, error) {
return false, err
}

if len(signatures) != 1 {
return false, errorsmod.Wrap(sdkerrors.ErrTxDecode, "more than one signature")
// multi signature cannot contain timestamp nonce
if len(signatures) > 1 {
for _, sig := range signatures {
if accountpluskeeper.IsTimestampNonce(sig.Sequence) {
return false, errorsmod.Wrap(sdkerrors.ErrTxDecode, "multi signature contains timestampnonce")
}
}
}

return accountpluskeeper.IsTimestampNonce(signatures[0].Sequence), nil
return len(signatures) == 1 && accountpluskeeper.IsTimestampNonce(signatures[0].Sequence), nil
}
7 changes: 6 additions & 1 deletion protocol/x/accountplus/ante/timestampnonce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ func TestIsTimestampNonceTx(t *testing.T) {
expectedResult: true,
expectedErr: false,
},
"Returns error for more than one signature": {
"Returns false with no error if multisignature with regular seq number": {
seqs: []uint64{1, 1},
expectedResult: false,
expectedErr: false,
},
"Returns error for multisignature with timestamp nonce": {
seqs: []uint64{keeper.TimestampNonceSequenceCutoff, keeper.TimestampNonceSequenceCutoff},
expectedResult: false,
expectedErr: true,
Expand Down

0 comments on commit 77cef30

Please sign in to comment.