-
Notifications
You must be signed in to change notification settings - Fork 47
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: add new get_script_hash
kernel procedure
#995
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d4a9930
feat: add `get_note_script_hash`
tomyrd bfd0e7f
feat: add test
tomyrd 64aa9b2
fix: kernel offsets
tomyrd 274f3b3
fix: unit tests
tomyrd cf88c7f
refactor: rename procedure
tomyrd 67a3151
chore: add procedure documentation
tomyrd 8c94107
chore: add procedures to docs
tomyrd bff7b96
chore: update CHANGELOG
tomyrd 15c84b3
Merge branch 'next' into tomyrd-get-script-hash
tomyrd 56545a8
Merge branch 'next' into tomyrd-get-script-hash
tomyrd e7d6a5b
refactor: remove `Word` import from test
tomyrd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ use miden_lib::{ | |
use miden_objects::{ | ||
notes::Note, testing::prepare_word, transaction::TransactionArgs, Hasher, WORD_SIZE, | ||
}; | ||
use vm_processor::{ProcessState, EMPTY_WORD, ONE}; | ||
use vm_processor::{ProcessState, Word, EMPTY_WORD, ONE}; | ||
|
||
use super::{Felt, Process, ZERO}; | ||
use crate::{ | ||
|
@@ -403,13 +403,10 @@ fn test_get_note_serial_number() { | |
// calling get_serial_number should return the serial number of the note | ||
let code = " | ||
use.kernel::prologue | ||
use.kernel::note->note_internal | ||
use.kernel::note | ||
use.miden::note | ||
|
||
begin | ||
exec.prologue::prepare_transaction | ||
exec.note_internal::prepare_note | ||
dropw dropw dropw dropw | ||
exec.note::get_serial_number | ||
|
||
# truncate the stack | ||
|
@@ -520,3 +517,29 @@ fn test_get_inputs_hash() { | |
|
||
assert_eq!(process.get_stack_state()[0..16], expected_stack); | ||
} | ||
|
||
#[test] | ||
fn test_get_current_script_hash() { | ||
let tx_context = TransactionContextBuilder::with_standard_account(ONE) | ||
.with_mock_notes_preserved() | ||
.build(); | ||
|
||
// calling get_script_hash should return script hash | ||
let code = " | ||
use.kernel::prologue | ||
use.miden::note | ||
|
||
begin | ||
exec.prologue::prepare_transaction | ||
exec.note::get_script_hash | ||
|
||
# truncate the stack | ||
swapw dropw | ||
end | ||
"; | ||
|
||
let process = tx_context.execute_code(code).unwrap(); | ||
|
||
let script_hash: Word = tx_context.input_notes().get_note(0).note().script().hash().into(); | ||
assert_eq!(process.stack.get_word(0), script_hash); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can avoid importing the let script_hash = tx_context.input_notes().get_note(0).note().script().hash();
assert_eq!(process.stack.get_word(0), script_hash.as_elements()); |
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should note this change as breaking, since it changes the offsets of the kernel procedures.