-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Use evaluate_function for CallStack::PackageRun; Sample response for CallStack::CheckDeployment #2230
Conversation
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.
LGTM! Left a few minor comments.
@@ -182,4 +172,46 @@ impl<N: Network> Stack<N> { | |||
// Return the plaintext. | |||
Ok(plaintext) | |||
} | |||
|
|||
/// Returns a future for the given TODO. |
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.
Should the TODO
be swapped out?
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.
Thx 7cba76f!
ExternalRecord(locator) => { | ||
// Retrieve the external stack. | ||
let stack = substack.get_external_stack(locator.program_id())?; | ||
// Sample the input. |
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.
// Sample the input. | |
// Sample the output. |
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.
Thx 7cba76f!
@@ -83,6 +84,14 @@ pub trait StackProgram<N: Network> { | |||
|
|||
/// Returns the expected number of calls for the given function name. | |||
fn get_number_of_calls(&self, function_name: &Identifier<N>) -> Result<usize>; | |||
|
|||
/// Samples a value for the given value_type |
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.
/// Samples a value for the given value_type | |
/// Samples a value for the given value_type. |
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.
Thx 7cba76f!
@@ -13,7 +13,7 @@ | |||
// limitations under the License. | |||
|
|||
use super::*; | |||
use console::program::{Argument, FinalizeType}; | |||
pub use console::program::{Argument, FinalizeType}; |
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.
Nit: You can move the use
here and in sample.rs
to the module above. It'll let you get rid of the pub
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.
Thx 7cba76f!
7cba76f
to
5b68ab6
Compare
Did another walk through the code, running on a local devnet and deploying and executing max nested programs succeeds. |
Signed-off-by: Howard Wu <9260812+howardwu@users.noreply.github.com>
ExternalRecord(locator) => { | ||
// Retrieve the external stack. | ||
let stack = substack.get_external_stack(locator.program_id())?; | ||
// Sample the output. | ||
stack.sample_value(&address, &Record(*locator.resource()), rng) | ||
} |
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.
Why not move this case directly into the impl of fn sample_value
?
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.
Smart a9f3483
|
||
// Retrieve the output operands. | ||
let output_operands = | ||
&function.outputs().iter().map(|output| output.operand()).collect::<Vec<_>>(); |
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.
Why are we collecting?
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.
Blind code copy pasta 53c69a8
Motivation
If we
evaluate_function
during deployment, we risk hitting false positive failed constraints on our random assignment.So instead, this PR proposes to sample a response. After sampling, construction of Response is handled the same way evaluate_function.
Test Plan
In the future we will test a wider range of programs.
Related PRs
https://github.com/AleoHQ/snarkVM/pull/2176
https://github.com/AleoHQ/snarkVM/pull/2224
https://github.com/AleoHQ/snarkVM/pull/2226