Skip to content
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

Stack Output Parser for Transaction Script Results #1161

Open
JordyRo1 opened this issue Feb 17, 2025 · 1 comment
Open

Stack Output Parser for Transaction Script Results #1161

JordyRo1 opened this issue Feb 17, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@JordyRo1
Copy link

JordyRo1 commented Feb 17, 2025

Feature description

We need to implement functionality to parse and load the stack output from transaction script executions into a Rust data structure. This will make stack values accessible and manipulable as Rust entities.

This feature might be already existing.I would appreciate if you can provide any documentation/code, that might help solve this.

Current behavior

Currently, when executing a transaction script like:

use.oracle_component::oracle_module
use.std::sys

begin
    push.{pair}
    call.oracle_module::get_median
    debug.stack
    exec.sys::truncate_stack
end

The get_median function returns a price value that is pushed onto the stack. The debug.stack output shows a 20-element stack with the price value (98179860000) at index 0, followed by zeros:
Stack state before step 7234:

├──  0: 98179860000
├──  1: 0
[...]
└── 19: 0

Why is this feature needed?

Implement functionality to:

  • Parse the stack output into a Rust data structure (e.g., Vec or similar appropriate type)
  • Preserve the order and values of stack elements
  • Make the stack data easily accessible for further processing in Rust
@JordyRo1 JordyRo1 added the enhancement New feature or request label Feb 17, 2025
@bobbinth
Copy link
Contributor

Thank you for such a detailed description! I do have a couple of clarifying questions:

use.oracle_component::oracle_module
use.std::sys

begin
push.{pair}
call.oracle_module::get_median
debug.stack
exec.sys::truncate_stack
end

Transaction scripts are usually meant to be execute as a part of a transaction to update account state, create notes etc. The above script (as currently written) just reads the account state and puts the data on the stack - so, it won't really have a meaningful effect on a transaction. So, I'm curious if you are planning to execute it as a part of a transaction or as a "stand-alone" program.

If the intent is to run it as a stand-alone program, is this mostly for testing/debugging purposes? Or is the result meant to be used for something meaningful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants