-
Notifications
You must be signed in to change notification settings - Fork 8
Execute sc does not return execution result #355
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -104,26 +104,17 @@ impl ASContext { | |||||||
|
|
||||||||
| match res { | ||||||||
| Ok(value) => { | ||||||||
| if function.eq(crate::settings::MAIN) { | ||||||||
| let remaining_gas = if cfg!(feature = "gas_calibration") { | ||||||||
| Ok(0_u64) | ||||||||
| } else { | ||||||||
| get_remaining_points(&self.env, store) | ||||||||
| }; | ||||||||
|
|
||||||||
| return Ok(Response { | ||||||||
| ret: Vec::new(), // main return empty vec | ||||||||
| remaining_gas: remaining_gas?, | ||||||||
| init_gas_cost: 0, | ||||||||
| #[cfg(feature = "execution-trace")] | ||||||||
| trace: Default::default(), | ||||||||
| }); | ||||||||
| } | ||||||||
| let ret = if let Some(offset) = value.first() { | ||||||||
| if let Some(offset) = offset.i32() { | ||||||||
| let buffer_ptr = BufferPtr::new(offset as u32); | ||||||||
| let memory = instance.exports.get_memory("memory")?; | ||||||||
| buffer_ptr.read(memory, store)? | ||||||||
| // Offset 0 means no return value in AssemblyScript | ||||||||
| if offset == 0 { | ||||||||
| Vec::new() | ||||||||
| } else { | ||||||||
| let buffer_ptr = BufferPtr::new(offset as u32); | ||||||||
| let memory = instance.exports.get_memory("memory")?; | ||||||||
| // If reading fails (e.g., invalid offset), return empty vec | ||||||||
| buffer_ptr.read(memory, store).unwrap_or_default() | ||||||||
|
Comment on lines
+115
to
+116
|
||||||||
| // If reading fails (e.g., invalid offset), return empty vec | |
| buffer_ptr.read(memory, store).unwrap_or_default() | |
| buffer_ptr.read(memory, store)? |
Copilot
AI
Jan 6, 2026
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.
The removal of the special case for the main function changes the established behavior. Previously, the main function always returned an empty vector. Now it can return values based on the offset. This breaks the test at line 1202-1204 in src/tests/tests_runtime.rs which explicitly expects main to return an empty vector with the comment "Note: for now, exec main always return an empty vec". Either update the test to reflect the new behavior, or ensure backward compatibility by handling the main function case appropriately.
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.
The comment claims "Offset 0 means no return value in AssemblyScript" but there is no documentation or reference to support this convention in the codebase. This assumption should be validated against AssemblyScript's FFI documentation or the massa-sc-std implementation. If this is indeed the convention, consider adding a reference to the documentation. If not, this logic may incorrectly treat valid return values as empty.