Skip to content
Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
make release-linux

- name: Push artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: libgo_owasm.so
path: api/libgo_owasm.so
Expand All @@ -44,7 +44,7 @@ jobs:
make release-osx

- name: Push artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: libgo_owasm.dylib
path: api/libgo_owasm.dylib
Expand All @@ -60,13 +60,13 @@ jobs:
uses: actions/checkout@v3

- name: Download libgo_owasm.so
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: libgo_owasm.so
path: api

- name: Download libgo_owasm.dylib
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: libgo_owasm.dylib
path: api
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Install Rust and rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.76
override: true

- name: Install Go
Expand Down
Binary file modified api/libgo_owasm.dylib
Binary file not shown.
Binary file modified api/libgo_owasm.so
Binary file not shown.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ require github.com/stretchr/testify v1.6.1
require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
160 changes: 148 additions & 12 deletions libgo_owasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions libgo_owasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "go-owasm"
version = "0.2.2"
version = "0.3.2"
authors = ["Sorawit Suriyakarn <swit@bandprotocol.com>"]
edition = "2021"

Expand All @@ -14,7 +14,7 @@ path = "src/lib.rs"
crate-type = ["staticlib"]

[dependencies]
owasm-vm = "0.3.1"
owasm-vm = "0.3.2"
failure = "0.1.6"
Comment thread
RogerKSI marked this conversation as resolved.

[build-dependencies]
Expand Down
12 changes: 8 additions & 4 deletions libgo_owasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use env::{Env, RunOutput};
use span::Span;

use failure::{bail, Error as FailureError};
use std::panic::catch_unwind;
use std::panic::{catch_unwind, AssertUnwindSafe};

use owasm_vm;
use owasm_vm::cache::{Cache, CacheOptions};
Expand Down Expand Up @@ -73,12 +73,16 @@ pub extern "C" fn do_run(
) -> Error {
if !cache.is_null() {
let vm_querier = vm::VMQuerier::new(env);
match owasm_vm::run(to_cache(cache).unwrap(), code.read(), gas_limit, is_prepare, vm_querier) {
Ok(gas_used) => {
let result = catch_unwind(AssertUnwindSafe(|| {
owasm_vm::run(to_cache(cache).unwrap(), code.read(), gas_limit, is_prepare, vm_querier)
}));
match result {
Ok(Ok(gas_used)) => {
output.gas_used = gas_used;
Error::NoError
}
Err(e) => e,
Ok(Err(e)) => e,
Err(_) => Error::RuntimeError, // panic → safe error
}
Comment thread
RogerKSI marked this conversation as resolved.
} else {
Error::UnknownError
Expand Down
Loading