Skip to content

Determine Amulet total supply by ACS snapshot when possible - #2334

Merged
OriolMunoz-da merged 14 commits into
mainfrom
oriol/metadata-token-supply
Sep 22, 2025
Merged

Determine Amulet total supply by ACS snapshot when possible#2334
OriolMunoz-da merged 14 commits into
mainfrom
oriol/metadata-token-supply

Conversation

@OriolMunoz-da

@OriolMunoz-da OriolMunoz-da commented Sep 18, 2025

Copy link
Copy Markdown
Contributor

Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>
Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>
Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>
[ci]

Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>
}

private def getAmuletInstrument()(implicit ec: ExecutionContext, tc: TraceContext) =
for {

@OriolMunoz-da OriolMunoz-da Sep 18, 2025

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.

called in the line just below this

there aren't any tests... I'm also not sure there's much value in one since there already are for the endpoints that use the 2 options directly, but lmk

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.

actually, at least it can be checked in the sanity plugin: #2318 (review)

@OriolMunoz-da
OriolMunoz-da marked this pull request as ready for review September 18, 2025 17:24
Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>

@moritzkiefer-da moritzkiefer-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.

nice thanks!

Comment thread scripts/scan-txlog/scan_txlog.py Outdated
if args.scan_balance_assertions:
# this will only work if a snapshot was taken, which is guaranteed by compare_acs_with_snapshot=True
token_metadata = await scan_client.get_amulet_token_metadata()
latest_per_party_balances = app_state.state.balance_end_of_round().values()

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.

can you remind me what balance_end_of_round does here? I think ideally we would just check the acs state that the script has, no point in aligning anything to rounds.

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.

def balance_end_of_round(self):
        amulets = self.list_contracts(TemplateQualifiedNames.amulet)
        locked_amulets = self.list_contracts(TemplateQualifiedNames.locked_amulet)
        per_party_balances = {}
        for amulet in amulets.values():
            owner = amulet.payload.get_amulet_owner()
            per_party_balances.setdefault(owner, PerPartyBalance())
            per_party_balances[owner].amulets += [amulet]
        for locked_amulet in locked_amulets.values():
            amulet = locked_amulet.payload.get_locked_amulet_amulet()
            owner = amulet.get_amulet_owner()
            per_party_balances.setdefault(owner, PerPartyBalance())
            per_party_balances[owner].locked_amulets += [locked_amulet]
        return per_party_balances

doesn't seem to be related to rounds at all - will rename

@meiersi-da meiersi-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 a lot!

LOG.error(f"Contracts missing in script ACS: {missing}")
if args.scan_balance_assertions:
# this will only work if a snapshot was taken, which is guaranteed by compare_acs_with_snapshot=True
token_metadata = await scan_client.get_amulet_token_metadata()

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 will only work once amulet-0.1.14 has been voted in correct? Consider gating the check by exposing whether that's the case in https://github.com/hyperledger-labs/splice/blob/c062908d98ab604ec4ab155a5c0c85733a78ec12/apps/scan/src/main/openapi/scan.yaml#L1520

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.

Hmm... probably better to not do that to avoid accidentally not testing the balance computation as part of the sanity check plugin. If needed we could add a separate parameter to disable this check in case it causes problems.

Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>
Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>
Base automatically changed from oriol/scan-snapshot-add-balances to main September 19, 2025 09:58
Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>
Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>
Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>
Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>
Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>
Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>
@OriolMunoz-da
OriolMunoz-da force-pushed the oriol/metadata-token-supply branch from d943a96 to d426a88 Compare September 22, 2025 15:54
@OriolMunoz-da
OriolMunoz-da merged commit e18662a into main Sep 22, 2025
109 checks passed
@OriolMunoz-da
OriolMunoz-da deleted the oriol/metadata-token-supply branch September 22, 2025 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants