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

asset: limit max value of issuance leaf to math.MaxUint32 #545

Closed
wants to merge 2 commits into from

Conversation

Roasbeef
Copy link
Member

@Roasbeef Roasbeef commented Oct 3, 2023

This is a step towards fixing:
#544.

In this commit, we limit the max amount of an asset that can be issued
at one time to math.MaxUint32. The existing 32-bit sum is left in place.
This gives us enough buffer room, as we'd need 4 billion UTXOs of the
same assets to overflow the root sum. In the future, we can lift this
limit with future asset versions.

An asset can have more than 4 billion ish units if they issue with
distinct UTXOs. This value can be viewed as the max amt that can be
issued in a single tranche.

@Roasbeef Roasbeef requested review from ffranr and jharveyb October 3, 2023 23:39
This is a step towards fixing:
lightninglabs#544.

In this commit, we limit the max amount of an asset that can be issued
at one time to math.MaxUint32. The existing 32-bit sum is left in place.
This gives us enough buffer room, as we'd need 4 billion UTXOs of the
same assets to overflow the root sum. In the future, we can lift this
limit with future asset versions.

An asset can have more than 4 billion ish units if they issue with
distinct UTXOs. This value can be viewed as the max amt that can be
issued in a single tranche.
@Roasbeef Roasbeef force-pushed the 32-bit-issuance-max branch from 3f55973 to e8ec228 Compare October 4, 2023 22:58
@jharveyb
Copy link
Contributor

jharveyb commented Oct 5, 2023

Thinking that the amount field for addresses should now also be a uint32? And receiving more than that requires the interactive flow or multiple addresses.

@Roasbeef
Copy link
Member Author

Roasbeef commented Oct 5, 2023

Thinking that the amount field for addresses should now also be a uint32?

Hmm, yeah good point, hadn't thought about that interaction. In that case, it's possible to actually just re-use the address if needed.

@jharveyb
Copy link
Contributor

jharveyb commented Oct 6, 2023

Should also update the overflow checks we have for tree leaves so we can fail earlier than asset.New(), e.x. in the porter:

if inputAsset.Amount > math.MaxInt64 {

RPC types also need to be updated, like MintAssetRequest, so we don't ingest uint64s where relevant.

@jharveyb
Copy link
Contributor

jharveyb commented Oct 6, 2023

Thinking that the amount field for addresses should now also be a uint32?

Hmm, yeah good point, hadn't thought about that interaction. In that case, it's possible to actually just re-use the address if needed.

Unrelated but would be neat to signal to the sender that those two asset leaves could be merged into the same anchor output; maybe if they share the same internal key?

Could also be useful for handling receiving for asset groups.

@Roasbeef Roasbeef closed this Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants