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

[x/programs] Add simulator feature to RustSDK #567

Merged
merged 4 commits into from
Oct 17, 2023

Conversation

hexfusion
Copy link
Contributor

@hexfusion hexfusion commented Oct 17, 2023

This PR adds the types to describe VM simulation Plans in Rust. This is the API that the Simulator will use, I adding this first will allow us to come to consensus on the API and unblock writing tests for program examples.

The idea behind this feature is to provide a simple API to communicate with the simulator using Rust types that serialize to JSON instead of JSON/YAML directly. This will allow for Rust developers to write tests for their programs completely in Rust or directly with YAML/JSON.

Signed-off-by: Sam Batschelet <[email protected]>
Signed-off-by: Sam Batschelet <[email protected]>
@hexfusion hexfusion requested a review from exdx October 17, 2023 14:47
@hexfusion hexfusion added the enhancement New feature or request label Oct 17, 2023
exdx
exdx previously approved these changes Oct 17, 2023
Copy link
Contributor

@richardpringle richardpringle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine as is, but I think my suggestions would improve things

x/programs/rust/wasmlanche_sdk/Cargo.toml Show resolved Hide resolved
x/programs/rust/wasmlanche_sdk/src/simulator.rs Outdated Show resolved Hide resolved
x/programs/rust/wasmlanche_sdk/src/simulator.rs Outdated Show resolved Hide resolved
x/programs/rust/wasmlanche_sdk/src/simulator.rs Outdated Show resolved Hide resolved
x/programs/rust/wasmlanche_sdk/src/simulator.rs Outdated Show resolved Hide resolved
x/programs/rust/wasmlanche_sdk/src/simulator.rs Outdated Show resolved Hide resolved
Signed-off-by: Sam Batschelet <[email protected]>
Signed-off-by: Sam Batschelet <[email protected]>
Copy link
Contributor

@richardpringle richardpringle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@patrick-ogrady patrick-ogrady merged commit 9c18457 into main Oct 17, 2023
35 of 36 checks passed
@patrick-ogrady patrick-ogrady deleted the rust_simulator_api branch October 17, 2023 18:43
Copy link
Contributor

@samliok samliok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few questions

/// # Errors
///
/// Returns an error if the if serialization or plan fails.
pub fn execute<T>(&self, data: Step, key: &str) -> Result<T, Box<dyn Error>>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the point of explicitly noting execute vs read_only?

Copy link
Contributor Author

@hexfusion hexfusion Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the expectation is that one returns a tx ID the other returns the result of a function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we will want the SDK to be able to better describe this. Some functions are read_only thus can be run against a local nodes as a read only call. But something that explicitly could change state would be part of a transaction. That's my thinking at least.

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
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants