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

Add x/programs #360

Merged
merged 2 commits into from
Aug 17, 2023
Merged

Add x/programs #360

merged 2 commits into from
Aug 17, 2023

Conversation

hexfusion
Copy link
Contributor

@hexfusion hexfusion commented Aug 16, 2023

This PR adds WebAssembly (WASM) based program support and examples to the HyperSDK.

Rational: Why have the host in Go?
While there are many performance reasons to choose Rust as the host. AvalancheGo and HyperSDK are in Go. While we are making strides in many areas of Rust in the ecosystem (IE firewood) it made sense for us to build this solution on top of the existing HyperSDK. This will allow for devs to build upon our existing and very performance focused HyperSDK.

Rational: Why have the guest in Rust?
Rust was chosen because of its amazing crypto community and much like WebAssembly itself Rust developers tend to enjoy lower level programming. We find that Rust provides efficient handling of bytes and compiles down to very efficient WebAssembly.

Rational: Why name this programs?
Because that is exactly what they are autonomous programs that live on chain. They technically are not all that smart and also not always a contracts. We hope that by using the term programs developers and non technical folks can more easily understand the term.

Performance: Initial benchmarks for the token program using metering shows ~16ms. More work is required to improve/understand overall performance.

cpu: Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
BenchmarkTokenProgram
BenchmarkTokenProgram/benchmark_token_program
BenchmarkTokenProgram/benchmark_token_program-12                      67          16280692 ns/op         5042177 B/op      51418 allocs/op
PASS
ok      github.com/ava-labs/hypersdk/x/programs/examples        1.175s

@patrick-ogrady patrick-ogrady changed the title Add x/programs Add x/programs Aug 16, 2023
@hexfusion hexfusion force-pushed the x/programs branch 3 times, most recently from 95ce0d3 to e44b80f Compare August 17, 2023 13:26
@hexfusion hexfusion self-assigned this Aug 17, 2023
@hexfusion hexfusion added the enhancement New feature or request label Aug 17, 2023
@hexfusion hexfusion marked this pull request as ready for review August 17, 2023 15:01
@patrick-ogrady
Copy link
Contributor

Can you also post a benchmark without metering?

@patrick-ogrady
Copy link
Contributor

You can fix the static issue by running go mod tidy in each example vm.

x/programs/runtime/map.go Fixed Show resolved Hide resolved
Co-authored-by: Sam Liokumovich <samliok@stanford.edu>
Signed-off-by: Sam Batschelet <sam.batschelet@avalabs.org>
@hexfusion
Copy link
Contributor Author

Can you also post a benchmark without metering?

yes will add a few more example tests and these benches as a followup.

Signed-off-by: Sam Batschelet <sam.batschelet@avalabs.org>
Copy link
Contributor

@patrick-ogrady patrick-ogrady left a comment

Choose a reason for hiding this comment

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

Houston, we have lift off

@patrick-ogrady patrick-ogrady merged commit 5aec195 into main Aug 17, 2023
14 checks passed
@patrick-ogrady patrick-ogrady deleted the x/programs branch August 17, 2023 23:39
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

Successfully merging this pull request may close these issues.

None yet

4 participants