fix(nano): allow create token and withdraw on same tx#1454
Merged
Conversation
jansegre
approved these changes
Oct 9, 2025
glevco
approved these changes
Oct 9, 2025
|
| Branch | fix/create-withdraw-same-tx |
| Testbed | ubuntu-22.04 |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | minutes (m) |
|---|---|---|
| sync-v2 (up to 20000 blocks) | 📈 view plot | 1.95 m |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
There's a bug in the token index, where an assertion fails when we try to withdraw a nonexistent token. This PR solves this problem by adding support to unknown tokens to the
TokenIndex. So all transactions keep being added to the index when they are added to the mempool. If a token does not exist, an unknown token is kept in the index to keep track of the supply and authorities. When the token is created, its information is added to the index too. If the token is never created, this unknown token entry will remain orphan in the index.Root cause analysis
When adding a nano tx with a withdrawal action and an output of an unknown token is failing, it fails an assert in the token index, therefore causing the full node to crash.
Because the nano tx passes all verifications, leading to an update in the token index as the nano tx is added to the mempool. However, this index update assumes that the token already exists.
This assumption held true before we allowed contracts to dynamically create tokens. But now, it might happen that tokens do not exist when transactions reach mempool. It is actually impossible to know beforehand whether a token will exist or not after the execution.
The nano tx passes all verifications because we check that
sum(txin) + sum(withdrawals) == sum(txout) + sum(deposits)which is true because the withdrawal of the unknown token balances out the output.Acceptance Criteria
_InfoDicttype from a typed dict to a dataclass.RocksDBTokenIndex.get_token_info()anditer_all_tokens().TKN.token_idto the DAG Builder to skip token creation.Checklist
master, confirm this code is production-ready and can be included in future releases as soon as it gets merged