Skip to content

Test handling of multiple verdicts with the same update_id - #7007

Open
mrdziuban wants to merge 6 commits into
canton-network:mainfrom
obsidiansystems:mrdziuban/dupe-verdict-update-id/6192
Open

Test handling of multiple verdicts with the same update_id#7007
mrdziuban wants to merge 6 commits into
canton-network:mainfrom
obsidiansystems:mrdziuban/dupe-verdict-update-id/6192

Conversation

@mrdziuban

Copy link
Copy Markdown
Contributor

Fixes #6192

Addresses the following points from @rautenrieth-da's comment:

  • Make sure both edge cases have test coverage, including reward computation
  • Check if we can emit a warning for duplicate verdicts, at least if the second verdict is an accept
  • Document the dropping of duplicate rejections in the scan OpenAPI spec

Pull Request Checklist

Cluster Testing

  • If a cluster test is required, comment /cluster_test on this PR to request it, and ping someone with access to the DA-internal system to approve it.
  • If an upgrade test is required, comment /upgrade_test on this PR to request it, and ping someone with access to the DA-internal system to approve it.
  • If a hard-migration test is required (from the latest release), comment /hdm_test on this PR to request it, and ping someone with access to the DA-internal system to approve it.
  • If a logical synchronizer upgrade test is required (from canton-3.5), comment /lsu_test on this PR to request it, and ping someone with access to the DA-internal system to approve it.

PR Guidelines

  • Include any change that might be observable by our partners or affect their deployment in the release notes.
  • Specify fixed issues with Fixes #n, and mention issues worked on using #n
  • Include a screenshot for frontend-related PRs - see README or use your favorite screenshot tool

Merge Guidelines

  • Make the git commit message look sensible when squash-merging on GitHub (most likely: just copy your PR description).

@rautenrieth-da rautenrieth-da left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! This nicely handles duplicate update ids across batches. I only now realized that we can also have duplicate update ids within the same batch. These won't be caught by the checkExist SQL statement.

Could you please change the code in ScanVerdictIngestionService.batchSource to log duplicate accept verdicts at WARN level, like you do in DbScanVerdictStore here, and add corresponding tests?

Comment thread apps/scan/src/main/openapi/scan.yaml Outdated
description: |
The ID of the transaction update associated with this verdict.

Verdicts are deduplicated by update_id. Only the first verdict ingested for a given update_id is stored and returned, while a subsequent verdict with the same update_id is dropped.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is dropped

That sounds a bit scary, like the scan app could be losing useful data. Consider describing the reject-after-accept scenario here. We don't expect the accept-after-reject scenario to happen in production, even though it is in theory possible.

This can happen for example if a sequencer client retries a successful submission. In that case, the retry is rejected as a duplicate, and the events endpoint will only show the successful verdict but not the rejected duplicates.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, I updated the wording to say "is rejected" instead of "is dropped" and I added the additional reject-after-accept description.

When dropped duplicates only include rejections, we log at info level.

Signed-off-by: Matt Dziuban <mrdziuban@gmail.com>
The tests cover both the reject after accept and accept after reject cases.

Signed-off-by: Matt Dziuban <mrdziuban@gmail.com>
Signed-off-by: Matt Dziuban <mrdziuban@gmail.com>
Signed-off-by: Matt Dziuban <mrdziuban@gmail.com>
Signed-off-by: Matt Dziuban <mrdziuban@gmail.com>
@mrdziuban
mrdziuban force-pushed the mrdziuban/dupe-verdict-update-id/6192 branch from f839fc4 to 68f0f8b Compare August 28, 2026 13:42
@mrdziuban

Copy link
Copy Markdown
Contributor Author

Could you please change the code in ScanVerdictIngestionService.batchSource to log duplicate accept verdicts at WARN level, like you do in DbScanVerdictStore here, and add corresponding tests?

Definitely, I added a few helper methods to take care of this, as well as tests to cover the behavior.

Comment on lines +76 to +77
duplicates.values.flatten.exists { case (v, _) =>
v.verdict == v30.VerdictResult.VERDICT_RESULT_ACCEPTED

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks off. We should only warn if we see an accept after seeing another verdict for the same update id.

Seeing a reject after an accept is fine and should not trigger a warning (and thus a production alert).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Got it. I renamed this duplicatesContainSubsequentAccept, tweaked the logic, and updated the tests accordingly.

ScanVerdictIngestionService.duplicatesContainAccept(duplicates) shouldBe false
}

"return true when a duplicate group contains an accept" in {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This tests accept-after-reject. Add the same test for reject-after-accept.

"log at warning level when a duplicate is an accept" in {
loggerFactory.assertLogs(
ScanVerdictIngestionService.logDuplicateUpdateIds(
Seq(mkVerdict("a", true), mkVerdict("a", false)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As noted above, this particular order should not warn.

}
}

"drop a rejected verdict that's a duplicate of a prior accept" in {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here we already have the behavior that reject-after-accept does not warn.

Signed-off-by: Matt Dziuban <mrdziuban@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle multiple verdicts for the same update id in scan verdict ingestion

5 participants