-
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
Merged
Merged
Use evaluate_function for CallStack::PackageRun; Sample response for CallStack::CheckDeployment #2230
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
72b8b3f
Use evaluate_function for CallStack::PackageRun; Sample response for …
vicsn b881c21
Remove unused StackProgramTypes
vicsn 5b68ab6
Import and comment cleanups
vicsn c2acc5f
Update synthesizer/process/src/stack/call/mod.rs
howardwu a9f3483
Sample ExternalRecord in sample_value
vicsn 53c69a8
Prevent allocation
vicsn 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,12 +12,23 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use crate::{CallStack, Registers, RegistersCall, StackEvaluate, StackExecute}; | ||
use crate::{ | ||
stack::{ | ||
Address, | ||
ValueType::{ExternalRecord, Record}, | ||
}, | ||
CallStack, | ||
Registers, | ||
RegistersCall, | ||
StackEvaluate, | ||
StackExecute, | ||
}; | ||
use aleo_std::prelude::{finish, lap, timer}; | ||
use console::{network::prelude::*, program::Request}; | ||
use synthesizer_program::{ | ||
Call, | ||
CallOperator, | ||
Operand, | ||
RegistersLoad, | ||
RegistersLoadCircuit, | ||
RegistersSigner, | ||
|
@@ -241,7 +252,7 @@ impl<N: Network> CallTrait<N> for Call<N> { | |
// Return the request and response. | ||
(request, response) | ||
} | ||
CallStack::CheckDeployment(_, private_key, ..) | CallStack::PackageRun(_, private_key, ..) => { | ||
CallStack::PackageRun(_, private_key, ..) => { | ||
// Compute the request. | ||
let request = Request::sign( | ||
&private_key, | ||
|
@@ -257,8 +268,66 @@ impl<N: Network> CallTrait<N> for Call<N> { | |
// Push the request onto the call stack. | ||
call_stack.push(request.clone())?; | ||
|
||
// Execute the request. | ||
let response = substack.execute_function::<A, R>(call_stack, console_caller, rng)?; | ||
// Evaluate the request. | ||
let response = substack.evaluate_function::<A>(call_stack, console_caller)?; | ||
|
||
// Return the request and response. | ||
(request, response) | ||
} | ||
CallStack::CheckDeployment(_, private_key, ..) => { | ||
// Compute the request. | ||
let request = Request::sign( | ||
&private_key, | ||
*substack.program_id(), | ||
*function.name(), | ||
inputs.iter(), | ||
&function.input_types(), | ||
rng, | ||
)?; | ||
|
||
// Compute the address. | ||
let address = Address::try_from(&private_key)?; | ||
// Sample dummy outputs | ||
let outputs = function | ||
.outputs() | ||
.iter() | ||
.map(|output| match output.value_type() { | ||
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) | ||
} | ||
_ => substack.sample_value(&address, output.value_type(), rng), | ||
}) | ||
.collect::<Result<Vec<_>>>()?; | ||
|
||
// 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Blind code copy pasta 53c69a8 |
||
|
||
// Map the output operands to registers. | ||
let output_registers = output_operands | ||
.iter() | ||
.map(|operand| match operand { | ||
Operand::Register(register) => Some(register.clone()), | ||
_ => None, | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
// Compute the response. | ||
let response = crate::Response::new( | ||
request.network_id(), | ||
substack.program().id(), | ||
function.name(), | ||
request.inputs().len(), | ||
request.tvk(), | ||
request.tcm(), | ||
outputs, | ||
&function.output_types(), | ||
&output_registers, | ||
)?; | ||
|
||
// Return the request and response. | ||
(request, response) | ||
} | ||
|
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
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.
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