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

feat: adding note args and tests #442

Merged
merged 10 commits into from
Feb 15, 2024
Merged

Conversation

Dominik1999
Copy link
Collaborator

@Dominik1999 Dominik1999 commented Jan 26, 2024

Closes #338

Supersedes #374

Still unsure how we want a user to set note_args. Atm a user need to define note_args when creating the InputNote

@Dominik1999 Dominik1999 requested a review from bobbinth January 26, 2024 13:50
@Dominik1999 Dominik1999 force-pushed the dominik_new_try_note_args branch 2 times, most recently from f83112e to c1dfa97 Compare January 29, 2024 14:21
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Thank you! Looks good! I left a could of comment inline - the main one is about how we provide note args to the transaction executor.

Also, the MASM code will need to be updated a bit once this PR is rebased from the latest next.

objects/src/transaction/inputs.rs Outdated Show resolved Hide resolved
miden-lib/asm/miden/kernels/tx/note.masm Outdated Show resolved Hide resolved
@Dominik1999 Dominik1999 force-pushed the dominik_new_try_note_args branch 5 times, most recently from 5b7cf65 to 759a0f8 Compare February 13, 2024 16:28
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Thank you! Looks good. I left some comments inline. The main thing is that I think we can simplify the structure quite a bit by following a similar pattern as for note inputs. Specifically:

  1. In the prologue (i.e., in the process_input_notes_data procedure), we can get note args from the advice provider and put them next to other note data.
  2. Then, right before the note is executed (e.g., as a part of prepare_note procedure), we would put note args onto the stack.

This way, when a note scripts starts executing, the state of the stack would be:

[SCRIPT_ROOT, NOTE_ARGS, ...]

objects/src/transaction/prepared_tx.rs Outdated Show resolved Hide resolved
miden-tx/src/executor/mod.rs Outdated Show resolved Hide resolved
miden-tx/src/executor/mod.rs Outdated Show resolved Hide resolved
mock/src/lib.rs Outdated Show resolved Hide resolved
miden-lib/src/transaction/inputs.rs Outdated Show resolved Hide resolved
miden-lib/asm/kernels/transaction/api.masm Outdated Show resolved Hide resolved
miden-lib/asm/miden/kernels/tx/note.masm Outdated Show resolved Hide resolved
miden-lib/asm/miden/note.masm Outdated Show resolved Hide resolved
miden-lib/asm/miden/kernels/tx/note.masm Show resolved Hide resolved
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Thank you! Looks good! I left a some more comments inline. Most are pretty minor. The main one is about figuring out the right place to add note args into the process.

miden-lib/src/transaction/memory.rs Outdated Show resolved Hide resolved
miden-tx/tests/integration/scripts/faucet.rs Show resolved Hide resolved
miden-lib/asm/miden/kernels/tx/note.masm Outdated Show resolved Hide resolved
miden-lib/asm/miden/kernels/tx/memory.masm Outdated Show resolved Hide resolved
miden-lib/asm/miden/kernels/tx/memory.masm Outdated Show resolved Hide resolved
miden-lib/asm/miden/kernels/tx/memory.masm Outdated Show resolved Hide resolved
miden-lib/asm/kernels/transaction/main.masm Outdated Show resolved Hide resolved
miden-lib/asm/miden/kernels/tx/prologue.masm Show resolved Hide resolved
objects/src/transaction/prepared_tx.rs Outdated Show resolved Hide resolved
@Dominik1999 Dominik1999 force-pushed the dominik_new_try_note_args branch 2 times, most recently from a98b425 to d235dbc Compare February 14, 2024 20:39
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Thank you! I think this approach works better. I left some more comments inline.

miden-lib/src/transaction/memory.rs Outdated Show resolved Hide resolved
mock/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines +21 to +24
pub struct TransactionArgs {
tx_script: Option<TransactionScript>,
note_args: Option<BTreeMap<NoteId, Word>>,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this was supposed be be:

pub struct TransactionArgs {
    tx_script: Option<TransactionScript>,
    note_args: BTreeMap<NoteId, Word>,
}

Copy link
Collaborator Author

@Dominik1999 Dominik1999 Feb 15, 2024

Choose a reason for hiding this comment

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

Not sure if I follow. NoteArgs are optional to a transaction the same way as a TransactionScript, right? So the canonical way to indicate this optionality would be

pub struct TransactionArgs {
    tx_script: Option<TransactionScript>,
    note_args: Option<BTreeMap<NoteId, Word>>,
}

Why would you put note_args: BTreeMap<NoteId, Word> not as an option?

Copy link
Contributor

Choose a reason for hiding this comment

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

An empty BTreeMap is functionally equivalent to None in this case but without the extra step we need to take to unwrap it.

objects/src/transaction/tx_script.rs Outdated Show resolved Hide resolved
objects/src/transaction/tx_script.rs Outdated Show resolved Hide resolved
miden-tx/tests/integration/scripts/p2id.rs Outdated Show resolved Hide resolved
miden-tx/tests/integration/scripts/faucet.rs Outdated Show resolved Hide resolved
miden-tx/src/executor/mod.rs Outdated Show resolved Hide resolved
miden-lib/src/transaction/inputs.rs Outdated Show resolved Hide resolved
miden-lib/src/transaction/inputs.rs Outdated Show resolved Hide resolved
@Dominik1999 Dominik1999 force-pushed the dominik_new_try_note_args branch from eb51835 to 8bf5ad0 Compare February 15, 2024 09:58
@Dominik1999 Dominik1999 force-pushed the dominik_new_try_note_args branch from 8bf5ad0 to 924bd42 Compare February 15, 2024 10:18
@Dominik1999 Dominik1999 merged commit 353589b into main Feb 15, 2024
8 checks passed
@Dominik1999 Dominik1999 deleted the dominik_new_try_note_args branch February 15, 2024 10:25
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.

Enable transaction-specified inputs for notes
2 participants