Skip to content

feat: Enable CodeBuilder to add advice map entries to compiled scripts#2275

Merged
bobbinth merged 7 commits intonextfrom
huitseeker/issue-2267
Jan 21, 2026
Merged

feat: Enable CodeBuilder to add advice map entries to compiled scripts#2275
bobbinth merged 7 commits intonextfrom
huitseeker/issue-2267

Conversation

@huitseeker
Copy link
Copy Markdown
Contributor

Fixes #2267.

@huitseeker huitseeker marked this pull request as ready for review January 14, 2026 14:09
@PhilippGackstatter
Copy link
Copy Markdown
Contributor

PhilippGackstatter commented Jan 15, 2026

Looks great, thanks!

Can you address the TODO in test_send_note_script_basic_wallet (after merging next) by making use of the new functionality? I think this should work now by adding the NoteAttachment elements to the CodeBuilder in build_send_notes_script.

Also, afaict this does not make it possible to add advice map entries for AccountComponentCode. Maybe we should do this for feature parity between scripts and account components?

huitseeker added a commit that referenced this pull request Jan 16, 2026
…otes_script

This addresses reviewer feedback on PR #2275:

1. build_send_notes_script now automatically adds NoteAttachmentContent::Array
   entries to the transaction script's advice map, eliminating the need for
   callers to manually add attachment data via extend_advice_map.

2. AccountComponentCode now has a with_advice_map method for feature parity
   with TransactionScript and NoteScript.

3. CodeBuilder's compile_component_code now applies the advice map to the
   compiled library, consistent with compile_tx_script and compile_note_script.

4. Added tests for the new functionality.
@huitseeker huitseeker force-pushed the huitseeker/issue-2267 branch from 6e5a34f to 988ce7b Compare January 16, 2026 08:57
huitseeker added a commit that referenced this pull request Jan 17, 2026
…otes_script

This addresses reviewer feedback on PR #2275:

1. build_send_notes_script now automatically adds NoteAttachmentContent::Array
   entries to the transaction script's advice map, eliminating the need for
   callers to manually add attachment data via extend_advice_map.

2. AccountComponentCode now has a with_advice_map method for feature parity
   with TransactionScript and NoteScript.

3. CodeBuilder's compile_component_code now applies the advice map to the
   compiled library, consistent with compile_tx_script and compile_note_script.

4. Added tests for the new functionality.
@huitseeker huitseeker force-pushed the huitseeker/issue-2267 branch from 988ce7b to fc8a1a8 Compare January 17, 2026 16:03
Copy link
Copy Markdown
Contributor

@PhilippGackstatter PhilippGackstatter left a comment

Choose a reason for hiding this comment

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

Looks great, thank you!

Enable CodeBuilder to add advice map entries to compiled scripts.
This addresses issue #2267 by allowing advice entries to be included
in transaction scripts and note scripts via the MastForest.

Added methods:
- add_advice_map_entry: adds a single entry
- with_advice_map_entry: builder pattern for single entry
- extend_advice_map: adds multiple entries
- with_extended_advice_map: builder pattern for multiple entries

The advice map entries are incorporated into the Program via
Program::with_advice_map() before wrapping in TransactionScript
or NoteScript.
Extract duplicate advice map application logic into a private helper
method apply_advice_map(). This reduces code duplication between
compile_tx_script and compile_note_script.

Also simplify test assertions by using expect() instead of
is_some() + unwrap() pattern, which is more idiomatic for tests.
Add `with_advice_map` method to both `TransactionScript` and `NoteScript`,
allowing advice map entries to be added after script compilation. This
complements the CodeBuilder API by enabling post-compilation advice
map modifications directly on script types.
…ports

Simplify test structure by merging separate empty and non-empty advice
map test cases into single comprehensive tests. Add AdviceMap to import
list in script.rs for consistency.
huitseeker added a commit that referenced this pull request Jan 20, 2026
…otes_script

This addresses reviewer feedback on PR #2275:

1. build_send_notes_script now automatically adds NoteAttachmentContent::Array
   entries to the transaction script's advice map, eliminating the need for
   callers to manually add attachment data via extend_advice_map.

2. AccountComponentCode now has a with_advice_map method for feature parity
   with TransactionScript and NoteScript.

3. CodeBuilder's compile_component_code now applies the advice map to the
   compiled library, consistent with compile_tx_script and compile_note_script.

4. Added tests for the new functionality.
@huitseeker huitseeker force-pushed the huitseeker/issue-2267 branch from 6615a39 to 2935eb5 Compare January 20, 2026 08:26
…otes_script

This addresses reviewer feedback on PR #2275:

1. build_send_notes_script now automatically adds NoteAttachmentContent::Array
   entries to the transaction script's advice map, eliminating the need for
   callers to manually add attachment data via extend_advice_map.

2. AccountComponentCode now has a with_advice_map method for feature parity
   with TransactionScript and NoteScript.

3. CodeBuilder's compile_component_code now applies the advice map to the
   compiled library, consistent with compile_tx_script and compile_note_script.

4. Added tests for the new functionality.
@huitseeker huitseeker force-pushed the huitseeker/issue-2267 branch from 2935eb5 to a9751db Compare January 20, 2026 17:44
Copy link
Copy Markdown
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.

All looks good! Thank you!

@bobbinth bobbinth merged commit fc869e8 into next Jan 21, 2026
17 checks passed
@bobbinth bobbinth deleted the huitseeker/issue-2267 branch January 21, 2026 05:50
afa7789 pushed a commit to afa7789/miden-base that referenced this pull request Mar 9, 2026
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 CodeBuilder to add advice map entries to compiled scripts

3 participants