Skip to content

chore: remove decorators from Note's masm#1194

Merged
SantiagoPittella merged 3 commits intomainfrom
santiagopittella-avoid-decorators-in-note
Sep 4, 2025
Merged

chore: remove decorators from Note's masm#1194
SantiagoPittella merged 3 commits intomainfrom
santiagopittella-avoid-decorators-in-note

Conversation

@SantiagoPittella
Copy link
Collaborator

partially address 0xMiden/protocol#1812

This PR is using main as the base branch

Removes decoratos from the note before inserting it in the DB.

@SantiagoPittella SantiagoPittella force-pushed the santiagopittella-avoid-decorators-in-note branch from 18b63a5 to 194d8f5 Compare September 2, 2025 14:18
Copy link
Collaborator

@igamigo igamigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Not that it makes a difference, but would this cover the network transaction builder mempool events? AFAIK when a transaction gets added to the mempool, new notes are sent to the ntx builder so maybe it would receive notes with the decorators.

@Mirko-von-Leipzig
Copy link
Collaborator

LGTM. Not that it makes a difference, but would this cover the network transaction builder mempool events? AFAIK when a transaction gets added to the mempool, new notes are sent to the ntx builder so maybe it would receive notes with the decorators.

Yeah it would still have the decorators. Good point. Maybe this should be done in the RPC then to strip them at arrival? Bit of a waste but its the single point of entry for now..

@SantiagoPittella
Copy link
Collaborator Author

Should this be moved to submit_proven_transaction and submit_proven_batch handlers?

@bobbinth
Copy link
Contributor

bobbinth commented Sep 2, 2025

Yeah, doing it in the PRC is a bit more robust. We could still have a check before inserting into DB, just in case. Basically, at the DB level we'd check if there are any decorators, and if so, remove them.

@SantiagoPittella
Copy link
Collaborator Author

Implemented this change, leaving the decorator removal before inserting in the DB too. wdyt?

@bobbinth @Mirko-von-Leipzig @igamigo

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works but feels extremely fragile and expensive since we build everything twice. I don't think there is currently a better way though.

Maybe notes should be stripped as part of building a transaction already? I'm a bit unclear on when the decorators are desired.

As a side note ProvenTransactionBuilder::new feels like it really needs wrapper types since it has many words and block numbers which can be trivially swapped around. cc @PhilippGackstatter

Copy link
Contributor

@PhilippGackstatter PhilippGackstatter Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a side note ProvenTransactionBuilder::new feels like it really needs wrapper types since it has many words and block numbers which can be trivially swapped around.

Agreed, but we need 0xMiden/crypto#430 for this first.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe notes should be stripped as part of building a transaction already? I'm a bit unclear on when the decorators are desired.

In a mock-chain context, we often consume notes that were created by a previous transaction, so we'd ideally retain the decorators. It would be sufficient to have that on testing though, and strip them in non-testing during ProvenTransactionBuilder::build. I think that could work - but there may be more cases where we'd want decorators that I'm not thinking about.

Copy link
Collaborator

@igamigo igamigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in terms of code. Although it feels redundant to do it in the DB if we are already stripping them at the only available RPC entrypoints, if we do it we might want to check if the note had decorators before attempting to do the reconstruction as suggested here.

@SantiagoPittella SantiagoPittella merged commit 92d5fc1 into main Sep 4, 2025
6 checks passed
@SantiagoPittella SantiagoPittella deleted the santiagopittella-avoid-decorators-in-note branch September 4, 2025 14:22
Comment on lines +331 to +343
let mut builder = ProvenTransactionBuilder::new(
tx.account_id(),
tx.account_update().initial_state_commitment(),
tx.account_update().final_state_commitment(),
tx.account_update().account_delta_commitment(),
tx.ref_block_num(),
tx.ref_block_commitment(),
tx.fee(),
tx.expiration_block_num(),
tx.proof().clone(),
)
.account_update_details(tx.account_update().details().clone())
.add_input_notes(tx.input_notes().iter().cloned());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now, but ideally, we should have a less error-prone way to strip decorators from any note in a transaction. I'm not sure what this way would be - but let's create an issue about for this.

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.

5 participants