-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Add return data to VM #19548
Add return data to VM #19548
Conversation
1ccad05
to
57b42a1
Compare
Codecov Report
@@ Coverage Diff @@
## master #19548 +/- ##
=========================================
- Coverage 82.6% 82.6% -0.1%
=========================================
Files 471 471
Lines 132557 132658 +101
=========================================
+ Hits 109574 109611 +37
- Misses 22983 23047 +64 |
57b42a1
to
99e1f45
Compare
Requires: - solana-labs/solana#19548 - solana-labs/solana#19318 Signed-off-by: Sean Young <[email protected]>
I've created a PR for Solang to use this new system, and it works very well. The result is much nicer. 🎉 |
dc92466
to
d54e41d
Compare
Compared the proposal, there are two changes:
|
e6c99ca
to
516cdaa
Compare
sdk/src/process_instruction.rs
Outdated
@@ -309,6 +313,19 @@ pub mod stable_log { | |||
ic_logger_msg!(logger, "Program log: {}", message); | |||
} | |||
|
|||
/// Log return data as from the program itself. |
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.
Just to be complete please also document here that the Program return data:
will not be present if no return data was provided (as opposed to an empty <program-generated-in-base64>
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.
So with the program_id, the return_data becomes an Option<>. Now it is present, even if it is empty.
sdk/src/process_instruction.rs
Outdated
/// The general form is: | ||
/// | ||
/// ```notrust | ||
/// "Program return data: <program-generated-in-base64>" |
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.
/// "Program return data: <program-generated-in-base64>" | |
/// "Program return data: <program-generated-data-in-base64>" |
If we end up adding the program id to the return data (cc: #19318 (comment)) then I think it'll be good to include the program id that generated the return data in this log as well
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.
Absolutely. Now it included the program_id of the setter.
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! Would want @jackcmay's careful 👁️ on this too
We want to avoid a program calling into the runtime and consuming cycles that are not accounted for. For example, a program could call |
programs/bpf_loader/src/syscalls.rs
Outdated
// Return the actual length, rather the length returned | ||
*result = Ok(return_data.len() as u64); | ||
} else { | ||
question_mark!( |
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.
Charge base cost always, then charge byte cost if there are bytes to get
0b02fde
to
b046897
Compare
sdk/program/src/program.rs
Outdated
if size == 0 { | ||
None | ||
} else { | ||
let size = std::cmp::min(size as usize, MAX_RETURN_DATA); |
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: use a use
for std::cmp
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 agree having the full namespace there is a bit much. Since this is in a target == bpf block, we can't have a use std::cmp::min;
at the top without `#[allow(unused)]'. So I've put the use in the same block.
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.
Looks great besides one last nit ;-)
sdk/src/process_instruction.rs
Outdated
/// The general form is: | ||
/// | ||
/// ```notrust | ||
/// "Program return data: <program-generated-data-in-base64>" |
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.
/// "Program return data: <program-generated-data-in-base64>" | |
/// "Program return data: <program-id> <program-generated-data-in-base64>" |
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.
Thanks for catching that, fixed.
b046897
to
b99ac2a
Compare
Pull request has been modified.
134b62e
to
dfd1b56
Compare
This consists of: - syscalls - passing return data from invoked to invoker - printing to stable log - rust and C SDK changes
dfd1b56
to
53b47b8
Compare
Requires: - solana-labs/solana#19548 - solana-labs/solana#19318 Signed-off-by: Sean Young <[email protected]>
Requires: - solana-labs/solana#19548 - solana-labs/solana#19318 Signed-off-by: Sean Young <[email protected]>
Requires: - solana-labs/solana#19548 - solana-labs/solana#19318 Signed-off-by: Sean Young <[email protected]>
Requires: - solana-labs/solana#19548 - solana-labs/solana#19318 Signed-off-by: Sean Young <[email protected]>
Requires: - solana-labs/solana#19548 - solana-labs/solana#19318 Signed-off-by: Sean Young <[email protected]>
Requires: - solana-labs/solana#19548 - solana-labs/solana#19318 Signed-off-by: Sean Young <[email protected]>
Requires solana-labs/solana#19548 Signed-off-by: Sean Young <[email protected]>
Requires solana-labs/solana#19548 Signed-off-by: Sean Young <[email protected]>
Implementation for #19318
Signed-off-by: Sean Young [email protected]