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

Abort transactions with already spent InputIDs #2229

Merged
merged 6 commits into from
Dec 6, 2023

Conversation

raychu86
Copy link
Contributor

@raychu86 raychu86 commented Dec 4, 2023

Motivation

This PR adds logic to VM::atomic_speculate to track spent InputIDs and abort transactions that attempt to spend an InputID that was already spent in this block.

Note: We may want to use the InputStore::get_speculative instead of per block trackers in atomic_speculate.

Related to: https://github.com/AleoHQ/snarkOS/pull/2852

Test Plan

A test has been added to check that the possible double spends are caught and aborted.

@ghostant-1017
Copy link
Contributor

ghostant-1017 commented Dec 5, 2023

It seems check at atomic_speculate is needless, we've already checked at check_next_block https://github.com/AleoHQ/snarkVM/blob/testnet3/ledger/block/src/verify.rs#L416

@raychu86
Copy link
Contributor Author

raychu86 commented Dec 6, 2023

It seems check at atomic_speculate is needless, we've already checked at check_next_block https://github.com/AleoHQ/snarkVM/blob/testnet3/ledger/block/src/verify.rs#L416

The logic change in atomic_speculate is not just a check, as it fully aborts subsequent transactions with spent InputIDs before creating a block. The check in check_next_block is to validate that the final block is well-formed.

@ghostant-1017
Copy link
Contributor

It seems check at atomic_speculate is needless, we've already checked at check_next_block https://github.com/AleoHQ/snarkVM/blob/testnet3/ledger/block/src/verify.rs#L416

The logic change in atomic_speculate is not just a check, as it fully aborts subsequent transactions with spent InputIDs before creating a block. The check in check_next_block is to validate that the final block is well-formed.

Thank you for explanation! I misunderstood it.

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.

3 participants