Skip to content

Conversation

@stephencompall-DA
Copy link
Contributor

SQL to retrieve all unique parties that were party to a transfer from ledger beginning up to record time, from Scan BigQuery. We only look at receivers because being a receiver at one point is the only way to become a sender.

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.

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

Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
@stephencompall-DA stephencompall-DA self-assigned this Jun 26, 2025
@stephencompall-DA stephencompall-DA marked this pull request as draft June 26, 2025 20:22
@stephencompall-DA stephencompall-DA changed the title initial transfer participants extraction for scan bigquery transfer participants extraction for scan bigquery Jun 26, 2025
@moritzkiefer-da
Copy link
Contributor

We only look at receivers because being a receiver at one point is the only way to become a sender.

I might not have full context here but reward minting is a self-transfer where the only output is your sender change and you are not listed explicitly as a receiver. Aren't you missing that?

Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
@stephencompall-DA
Copy link
Contributor Author

I might not have full context here but reward minting is a self-transfer where the only output is your sender change and you are not listed explicitly as a receiver. Aren't you missing that?

It depends on what we mean by "transfer participant". Also, can those be incorporated simply by including the .transfer.sender in the union from the same choice arguments?

@stephencompall-DA stephencompall-DA marked this pull request as ready for review June 26, 2025 20:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces an SQL test resource to extract unique transfer participants from Scan BigQuery using JSON extraction. Key changes include adding a new SQL query that declares configuration parameters, extracts JSON arrays from transfer exercises, and filters records based on migration_id and record time.

Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
Comment on lines 26 to 27
FROM daml_TransferOutput_jsons
INNER JOIN UNNEST(daml_TransferOutput_jsons.TransferOutput_array) AS TransferOutput;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pulled from the docs here (this is JSON, not a struct, but a similar idea applies)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
Comment on lines 19 to 21
AND (e.migration_id < migration_id
OR (e.migration_id = migration_id
AND e.record_time <= UNIX_MICROS(as_of_record_time)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this buy us anything given that the request was "all", and we're anyway putting "<= now" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A couple things:

  1. As this is concurrent with ingestion, it's best to choose a time where ingestion has likely stabilized, so that there's no chance of partial data.
  2. If you refactor or alter the query later, you can compare results knowing it's against the same set of transactions.

@moritzkiefer-da
Copy link
Contributor

It depends on what we mean by "transfer participant". Also, can those be incorporated simply by including the .transfer.sender in the union from the same choice arguments?

Yes just including transfer.sender sounds fine to me.

…transfer-participants

[skip ci]

Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
@isegall-da
Copy link
Contributor

isegall-da commented Jun 30, 2025

We only look at receivers because being a receiver at one point is the only way to become a sender.

I might not have full context here but reward minting is a self-transfer where the only output is your sender change and you are not listed explicitly as a receiver. Aren't you missing that?

@moritzkiefer-da I'm missing something here. How come you're not listed as the receiver? It's a self-transfer, so you are the receiver, aren't you? Or is it implemented as a "send to nobody", so all outputs are change to the sender?

@moritzkiefer-da
Copy link
Contributor

@moritzkiefer-da I'm missing something here. How come you're not listed as the receiver? It's a self-transfer, so you are the receiver, aren't you? Or is it implemented as a "send to nobody", so all outputs are change to the sender?

send to nobody so it only has the sender change output

Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
- suggested by @moritzkiefer-da; thanks

Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
@stephencompall-DA
Copy link
Contributor Author

Yes just including transfer.sender sounds fine to me.

5c20a9c

Copy link
Contributor

@moritzkiefer-da moritzkiefer-da left a comment

Choose a reason for hiding this comment

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

Query lgtm, I have two questions:

  1. What is the plan for testing these queries?
  2. Have we double checked what the intent is with the people requesting this query? We do have all transfer senders and receivers now. But there are two things I'm unsure about:
    2.1. Is the intent really all transfer senders and receivers or is it anyone that ever held CC? Because the latter seems like a much simpler query where you just go over all created events and get the holder. It's almost identical in terms of result. Tap makes a difference but that's not even available on mainnet. Importantly this one is also robust against us adding more choices that create amulet other than AmuletRules_Transfer.
    2.2. How do we want to treat lock holders? They are not receivers so if we want to include them we need to do more.

WITH daml_Transfer_jsons AS (
SELECT JSON_VALUE(e.argument,
-- .transfer.sender
'$.record.fields[0].value.record.fields[0].value.party')
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to create functions for these kind of 'paths', or is that too far? probably easy to use for others.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure, it depends on what functionality is available in temp function signatures.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe have a look?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed total-supply to include this (as well as this file); what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I like it! I think it gives a good basis for reuse and ease of use.

…icipants

[skip ci]

Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
@stephencompall-DA stephencompall-DA merged commit e173691 into main Jul 3, 2025
41 checks passed
@stephencompall-DA stephencompall-DA deleted the s11/703-transfer-participants branch July 3, 2025 20:09
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.

5 participants