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

Store transaction outputs with correct pos #1349

Open
vlopes11 opened this issue Mar 23, 2022 · 0 comments
Open

Store transaction outputs with correct pos #1349

vlopes11 opened this issue Mar 23, 2022 · 0 comments

Comments

@vlopes11
Copy link

Describe what you want implemented
The transaction outputs should be stored in the chain with their correct post-execution position index.

Describe "Why" this is needed
This is needed to increase the clarity of the protocol and decouple the chain from implementation details of Rusk.

Currently, we are using u64::MAX in the stored positions, expecting these to be replaced by Rusk.

Creating the note
https://github.com/dusk-network/phoenix-core/blob/efdbc4adbaad7c9234dbd81977ad0dc69f36600f/src/note.rs#L169-L170

Replacing the index
https://github.com/dusk-network/Poseidon252/blob/f6c1e914956d115858cc796fbaaa3063e763de56/src/tree.rs#L85

This is an implementation detail. Whatever is stored in the blockchain should reflect its state. Meaning: the outputs in the block should be in the same state that composes the state root (e.g. final index in the tree).

As result, the block payload contains outputs with masked positions, when these are intended to be public (and easily checked by third parties).

This implementation detail had some implications on the general design. Currently we are using this magic constant u64::MAX as part of the txid:

https://github.com/dusk-network/wallet-core/blob/42c86072f71fd8c8303d7ba2b5c1068fe0ef4e0f/src/tx.rs#L260-L262

https://github.com/dusk-network/phoenix-core/blob/efdbc4adbaad7c9234dbd81977ad0dc69f36600f/src/note.rs#L356

The txid is committed to the block, and uses an information that doesn't belong to the block (u64::MAX). This greatly couples the protocol to the implementation details of Rusk, and can be easily fixed by removing pos from txid arguments.

Describe alternatives you've considered
Leaving u64::MAX in the block will make the protocol less clear, will show bogus data on the block explorer and will couple its logic to implementation details.

Additional context
A block verification should rely only in its data, and nothing external. If we are to depend on coupled logic, we cannot query the outputs of a block from a state and expect them exactly as they were inserted.

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

No branches or pull requests

1 participant