Skip to content

Traffic-Based App Rewards: Fix hashing of batches#5193

Open
adetokunbo wants to merge 2 commits intoadetokunbo/use-actual-crypto-hash-in-equivalence-testfrom
adetokunbo/cip-104-test-and-fix-crypto-hash-of-batches
Open

Traffic-Based App Rewards: Fix hashing of batches#5193
adetokunbo wants to merge 2 commits intoadetokunbo/use-actual-crypto-hash-in-equivalence-testfrom
adetokunbo/cip-104-test-and-fix-crypto-hash-of-batches

Conversation

@adetokunbo
Copy link
Copy Markdown
Contributor

Follow-up/Stacked on to #5118
Fixes a bug in computation of hash of batches, and adds tests to confirm the fix

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 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).

- fixes a bug in how numbers were serialized; they did not match Daml
- addes a migration with the SQL function that performs the fix

Signed-off-by: Tim Emiola <adetokunbo@emio.la>
@adetokunbo adetokunbo added this to the Traffic-Based App Rewards milestone Apr 23, 2026
@adetokunbo adetokunbo changed the title Adetokunbo/cip 104 test and fix crypto hash of batches Traffic-Based App Rewards: Fix hashing of batches Apr 23, 2026
@adetokunbo adetokunbo self-assigned this Apr 23, 2026
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
@adetokunbo adetokunbo force-pushed the adetokunbo/cip-104-test-and-fix-crypto-hash-of-batches branch from d4a20cd to daca6ed Compare April 23, 2026 11:30
// Decimal values to test format equivalence between Daml's show on Decimal
// and Postgres daml_numeric_to_text. Covers trailing zeros, negatives,
// small fractions, and integers.
val decimalFormatCases: Seq[String] = Seq(
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.

How was this obtained, could you describe the source, such that us+ future readers know / verify the coverage

Copy link
Copy Markdown
Contributor

@dfordivam dfordivam Apr 24, 2026

Choose a reason for hiding this comment

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

From an brief look I noticed that max/min values are missing. so this must be hand-written.
Lets make sure we have full coverage / edge cases

with
input : Decimal
controller owner
do pure (hash (show input)).value
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 show needed? we don't have instance for Decimal?

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.

We use the instance in our code, please remove show

instance CryptoHash.Hashable MintingAllowance where
  hash MintingAllowance {provider, amount} =
    CryptoHash.hashRecord [CryptoHash.hash provider , CryptoHash.hash amount]

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.

2 participants