Skip to content

Creating an invalid tx when trying to mint too large amount of tokens #336

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

Closed
nielstron opened this issue Apr 19, 2024 · 5 comments · Fixed by #338
Closed

Creating an invalid tx when trying to mint too large amount of tokens #336

nielstron opened this issue Apr 19, 2024 · 5 comments · Fixed by #338
Labels
bug Something isn't working

Comments

@nielstron
Copy link
Contributor

Describe the bug
Trying to mint too many tokens produces and invalid transaction (basically minting 1231234145232534000000 here for example)
This results in ogmios failing to evaluate/submit the transaction with a very obscure error message.

To Reproduce
TBD

Logs

ogmios.errors.ResponseError: Ogmios responded with error: {'jsonrpc': '2.0', 'method': 'evaluateTransaction', 'error': {'code': -32602, 'message': "Invalid transaction; It looks like the given transaction wasn't well-formed. Note that I try to decode the transaction in every possible era and it was malformed in ALL eras. Yet, I can't pinpoint the exact issue for I do not know in which era / format you intended the transaction to be. The 'data' field, therefore, contains errors for each era.", 'data': {'babbage': "invalid or incomplete value of type 'Transaction': expected word", 'conway': "invalid or incomplete value of type 'Transaction': expected word", 'alonzo': "invalid or incomplete value of type 'Transaction': expected list len or indef", 'mary': "invalid or incomplete value of type 'Transaction': Size mismatch when decoding Object / Array. Expected 4, but found 3.", 'allegra': "invalid or incomplete value of type 'Transaction': Size mismatch when decoding Object / Array. Expected 4, but found 3.", 'shelley': "invalid or incomplete value of type 'Transaction': Size mismatch when decoding Object / Array. Expected 4, but found 3."}}, 'id': None}

Expected behavior
Ogmios could report that the integer is breaking/incorrectly serialized. PyCardano should abort the building or raise an error/warning this.

Environment and software version (please complete the following information):

  • OS: Ubuntu 22
  • PyCardano Version: 0.10.0

Additional context
Looping in @KtorZ for ogmios, but the error is really with PyCardano here.

@nielstron nielstron added the bug Something isn't working label Apr 19, 2024
@nielstron nielstron changed the title Getting an invalid tx when trying to mint too large amount of tokens Creating an invalid tx when trying to mint too large amount of tokens Apr 19, 2024
@KtorZ
Copy link
Contributor

KtorZ commented Apr 21, 2024

Indeed, the mint value must fit into a word which is a u64 or u32 depending on OS arch, but most likely u64 (so 18_446_744_073_709_551_615 max).

@KtorZ
Copy link
Contributor

KtorZ commented Apr 21, 2024

Note that: this is as good as it gets when it comes to deserialization errors here. I cannot get anything better without re-writing the CBOR parsers which I am slightly reluctant to at the moment 😅 ...

@nielstron
Copy link
Contributor Author

So it should be possible to just check that mint is smaller than sys.maxsize.

@cffls
Copy link
Collaborator

cffls commented Apr 22, 2024

From the ledger spec, it looks like mint field should be int64, and uint should be used in all other cases, which doesn't have an upper bound (at least I couldn't find its definition in the spec). Maybe we should only limit mint field to int64. What do you think?

@nielstron
Copy link
Contributor Author

nielstron commented Apr 22, 2024

If the spec sais i64 I agree we should restrict to that, not sys.maxsize

@cffls cffls closed this as completed in #338 May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants