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 a practical sample for using Sputnik as a stateless virtual machine #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
main
build/sample
9 changes: 7 additions & 2 deletions go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))

build:
make -C ../c build
CGO_LDFLAGS="$(ROOT_DIR)../c/libsputnikvm.a -ldl" go build main.go
CGO_LDFLAGS="$(ROOT_DIR)../c/libsputnikvm.a -ldl" go build -o build/sample

run: build
./main
./build/sample

debug:
make -C ../c debug
CGO_LDFLAGS="$(ROOT_DIR)../c/libsputnikvm.a -ldl" go build -o build/sample
./build/sample
12 changes: 12 additions & 0 deletions go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ import (
)

func main() {

//Run Original Sample of SputnikVM-ffi
fmt.Println("\n/////////////////////////////////////////////////////////\n[ riginal Sample ]\n/////////////////////////////////////////////////////////")
runOriginalSample()

//Use Sputnik as Stateless Virtual Machine
fmt.Println("\n/////////////////////////////////////////////////////////\n[ Sateless Sample ]\n/////////////////////////////////////////////////////////")
runStatelessSample()

}

func runOriginalSample() {
goint := big.NewInt(100000000000000)
cint := sputnikvm.ToCU256(goint)
fmt.Printf("%v\n", cint)
Expand Down
Loading