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

[OTE-553] Fix early return during timestamp nonce check bug #1984

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion protocol/app/ante/sigverify.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ func (svd SigVerificationDecorator) AnteHandle(
1,
[]gometrics.Label{metrics.GetLabelForIntValue(metrics.ExecMode, int(ctx.ExecMode()))},
)
return ctx, nil
Copy link
Contributor

@teddyding teddyding Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we clean up by minimizing indent and removing else condition:

			if accountpluskeeper.IsTimestampNonce(sig.Sequence) {
				if err := svd.akp.ProcessTimestampNonce(ctx, acc, sig.Sequence); err != nil {
					telemetry.IncrCounterWithLabels(
						[]string{metrics.TimestampNonce, metrics.Invalid, metrics.Count},
						1,
						[]gometrics.Label{metrics.GetLabelForIntValue(metrics.ExecMode, int(ctx.ExecMode()))},
					)
					return ctx, errorsmod.Wrapf(sdkerrors.ErrWrongSequence, err.Error())
				}
				telemetry.IncrCounterWithLabels(
					[]string{metrics.TimestampNonce, metrics.Valid, metrics.Count},
					1,
					[]gometrics.Label{metrics.GetLabelForIntValue(metrics.ExecMode, int(ctx.ExecMode()))},
				)
			} else {

See https://go.dev/wiki/CodeReviewComments#indent-error-flow

} else {
telemetry.IncrCounterWithLabels(
[]string{metrics.TimestampNonce, metrics.Invalid, metrics.Count},
Expand Down
16 changes: 16 additions & 0 deletions protocol/app/ante/sigverify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,22 @@ func TestSigVerification(t *testing.T) {
"",
true,
},
{
"timestamp nonce invalid sigs",
testMsgs,
[]cryptotypes.PrivKey{priv1, priv2, priv3},
[]uint64{accs[0].GetAccountNumber(), accs[1].GetAccountNumber(), accs[2].GetAccountNumber()},
[]uint64{
testante.TestBlockTime + 5000, // ts > min(tsNonces)
testante.TestBlockTime + 5000,
testante.TestBlockTime + 5000,
},
!validSigs,
false,
true,
"",
true,
},
}

for i, tc := range testCases {
Expand Down
Loading