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

Consolidate transaction inputs and outputs in dedicated modules #385

Merged
merged 26 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
17077e8
refactor: consolidate input transaction info in a single module
bobbinth Dec 26, 2023
0a29e02
refactor: consolidate transaction output structs in a single module
bobbinth Dec 26, 2023
61ad737
refactor: simplify PreparedTransaction
bobbinth Dec 26, 2023
dc02894
refactor: use TransactionInputs in ExecutedTransaction
bobbinth Dec 26, 2023
424adf7
refactor: construct TransactionResult with TransactionInputs
bobbinth Dec 26, 2023
9e21d5a
refactor: added TransactionOutputs
bobbinth Dec 26, 2023
8a74896
chore: remove obsolete NoteStub file
bobbinth Dec 26, 2023
b3cd416
refactor: integrate TransactionOutputs into ExecutedTransaction
bobbinth Dec 27, 2023
c8be761
refactor: replace TransactionResult with ExecutedTransaction
bobbinth Dec 27, 2023
7a68d49
refactor: consolidate transaction errors
bobbinth Dec 27, 2023
950bb1e
refactor: move tx input construction to miden-lib
bobbinth Dec 27, 2023
733c2c8
refactor: move advice inputs construction logic to miden-lib
bobbinth Dec 27, 2023
5d30eba
refactor: organization of midenlib
bobbinth Dec 29, 2023
ddfd118
refactor: use InputNotes and OutputNotes in ProvenTransaction
bobbinth Dec 29, 2023
7913c4b
refactor: move transaction output parsing to miden-lib
bobbinth Dec 30, 2023
f952ea7
refactor: move output stack construction logic out of transaction ver…
bobbinth Dec 31, 2023
79f72d2
refactor: remove proving of prepared transactions
bobbinth Dec 31, 2023
6b911a3
refactor: move full transaction inputs into TransactionWitness
bobbinth Dec 31, 2023
03491b7
refactor: delete TransactionWitnessError
bobbinth Jan 2, 2024
1949366
refactor: replace TransactionError with TransactionInputError
bobbinth Jan 2, 2024
74f1930
feat: add more DataStoreError variants
bobbinth Jan 2, 2024
4406cfc
Merge pull request #390 from 0xPolygonMiden/bobbin-tx-io-parsing
bobbinth Jan 2, 2024
fa5b96f
Merge pull request #389 from 0xPolygonMiden/bobbin-proven-tx
bobbinth Jan 2, 2024
e214f7e
Merge pull request #388 from 0xPolygonMiden/bobbin-midenlib-refactor
bobbinth Jan 2, 2024
f92a72e
Merge pull request #387 from 0xPolygonMiden/bobbin-tx-advice
bobbinth Jan 2, 2024
cba8edb
Merge pull request #386 from 0xPolygonMiden/bobbin-tx-result
bobbinth Jan 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions miden-lib/src/notes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use miden_objects::{
accounts::AccountId,
assembly::ProgramAst,
assets::Asset,
notes::{Note, NoteMetadata, NoteScript, NoteStub, NoteVault},
notes::{Note, NoteMetadata, NoteScript, NoteVault},
transaction::OutputNote,
utils::{collections::Vec, vec},
Digest, Felt, Hasher, NoteError, StarkField, Word, WORD_SIZE, ZERO,
};
Expand Down Expand Up @@ -80,7 +81,7 @@ pub fn create_note(
Note::new(note_script.clone(), &inputs, &assets, serial_num, sender, tag.unwrap_or(ZERO))
}

pub fn notes_try_from_elements(elements: &[Word]) -> Result<NoteStub, NoteError> {
pub fn notes_try_from_elements(elements: &[Word]) -> Result<OutputNote, NoteError> {
if elements.len() < CREATED_NOTE_CORE_DATA_SIZE {
return Err(NoteError::InvalidStubDataLen(elements.len()));
}
Expand All @@ -104,7 +105,7 @@ pub fn notes_try_from_elements(elements: &[Word]) -> Result<NoteStub, NoteError>
return Err(NoteError::InconsistentStubVaultHash(vault_hash, vault.hash()));
}

let stub = NoteStub::new(recipient, vault, metadata)?;
let stub = OutputNote::new(recipient, vault, metadata);
if stub.hash() != hash {
return Err(NoteError::InconsistentStubHash(stub.hash(), hash));
}
Expand Down
14 changes: 7 additions & 7 deletions miden-lib/src/tests/test_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn test_set_code_is_not_immediate() {
prepare_transaction(account, None, block_header, chain, notes, None, code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand All @@ -67,7 +67,7 @@ pub fn test_set_code_succeeds() {
let executed_transaction = mock_executed_tx(AssetPreservationStatus::Preserved);

let created_notes_data_procedure =
created_notes_data_procedure(executed_transaction.created_notes());
created_notes_data_procedure(executed_transaction.output_notes());

let code = format!(
"
Expand Down Expand Up @@ -261,7 +261,7 @@ fn test_get_item() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let _process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -321,7 +321,7 @@ fn test_set_item() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let _process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -376,7 +376,7 @@ fn test_get_map_item() {
);

let _process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -413,7 +413,7 @@ fn test_get_vault_commitment() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let _process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -461,7 +461,7 @@ fn test_authenticate_procedure() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
);
Expand Down
16 changes: 5 additions & 11 deletions miden-lib/src/tests/test_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ fn test_create_fungible_asset_succeeds() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let mut advice_provider = MemAdviceProvider::from(transaction.advice_provider_inputs());
let _process = run_tx(
transaction.tx_program().clone(),
transaction.stack_inputs(),
&mut advice_provider,
);
let _process =
run_tx(transaction.program().clone(), transaction.stack_inputs(), &mut advice_provider);
}

#[test]
Expand Down Expand Up @@ -93,10 +90,7 @@ fn test_create_non_fungible_asset_succeeds() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let mut advice_provider = MemAdviceProvider::from(transaction.advice_provider_inputs());
let _process = run_tx(
transaction.tx_program().clone(),
transaction.stack_inputs(),
&mut advice_provider,
)
.unwrap();
let _process =
run_tx(transaction.program().clone(), transaction.stack_inputs(), &mut advice_provider)
.unwrap();
}
24 changes: 12 additions & 12 deletions miden-lib/src/tests/test_asset_vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn test_get_balance() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -74,7 +74,7 @@ fn test_get_balance_non_fungible_fails() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
);
Expand Down Expand Up @@ -106,7 +106,7 @@ fn test_has_non_fungible_asset() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
inputs.tx_program().clone(),
inputs.program().clone(),
inputs.stack_inputs(),
MemAdviceProvider::from(inputs.advice_provider_inputs()),
)
Expand Down Expand Up @@ -144,7 +144,7 @@ fn test_add_fungible_asset_success() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -190,7 +190,7 @@ fn test_add_non_fungible_asset_fail_overflow() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
);
Expand Down Expand Up @@ -231,7 +231,7 @@ fn test_add_non_fungible_asset_success() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -278,7 +278,7 @@ fn test_add_non_fungible_asset_fail_duplicate() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
);
Expand Down Expand Up @@ -316,7 +316,7 @@ fn test_remove_fungible_asset_success_no_balance_remaining() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -361,7 +361,7 @@ fn test_remove_fungible_asset_fail_remove_too_much() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
);
Expand Down Expand Up @@ -397,7 +397,7 @@ fn test_remove_fungible_asset_success_balance_remaining() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -444,7 +444,7 @@ fn test_remove_non_fungible_asset_fail_doesnt_exist() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
);
Expand Down Expand Up @@ -483,7 +483,7 @@ fn test_remove_non_fungible_asset_success() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down
12 changes: 6 additions & 6 deletions miden-lib/src/tests/test_epilogue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn test_epilogue() {
let executed_transaction = mock_executed_tx(AssetPreservationStatus::Preserved);

let created_notes_data_procedure =
created_notes_data_procedure(executed_transaction.created_notes());
created_notes_data_procedure(executed_transaction.output_notes());

let imports = "use.miden::sat::internal::prologue\n";
let code = format!(
Expand Down Expand Up @@ -81,9 +81,9 @@ fn test_compute_created_note_hash() {
let executed_transaction = mock_executed_tx(AssetPreservationStatus::Preserved);

let created_notes_data_procedure =
created_notes_data_procedure(executed_transaction.created_notes());
created_notes_data_procedure(executed_transaction.output_notes());

for (note, i) in executed_transaction.created_notes().iter().zip(0u32..) {
for (note, i) in executed_transaction.output_notes().iter().zip(0u32..) {
let imports = "use.miden::sat::internal::prologue\n";
let test = format!(
"
Expand Down Expand Up @@ -132,7 +132,7 @@ fn test_epilogue_asset_preservation_violation() {
let executed_transaction = mock_executed_tx(asset_preservation);

let created_notes_data_procedure =
created_notes_data_procedure(executed_transaction.created_notes());
created_notes_data_procedure(executed_transaction.output_notes());

let imports = "use.miden::sat::internal::prologue\n";
let code = format!(
Expand Down Expand Up @@ -166,7 +166,7 @@ fn test_epilogue_increment_nonce_success() {
let executed_transaction = mock_executed_tx(AssetPreservationStatus::Preserved);

let created_notes_data_procedure =
created_notes_data_procedure(executed_transaction.created_notes());
created_notes_data_procedure(executed_transaction.output_notes());

let imports = "use.miden::sat::internal::prologue\n";
let code = format!(
Expand Down Expand Up @@ -198,7 +198,7 @@ fn test_epilogue_increment_nonce_violation() {
let executed_transaction = mock_executed_tx(AssetPreservationStatus::Preserved);

let created_notes_data_procedure =
created_notes_data_procedure(executed_transaction.created_notes());
created_notes_data_procedure(executed_transaction.output_notes());

let imports = "use.miden::sat::internal::prologue\n";
let code = format!(
Expand Down
Loading
Loading