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

feat(runtime/wasmer): write wasmer using latest wasmer version #3168

Merged
merged 61 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
afe1e96
create wrapper around wasmer.Memory and test it
jimjbrettj Mar 14, 2023
377ba1f
lint and clean
jimjbrettj Mar 14, 2023
39eb9ab
rename to newWasmer
jimjbrettj Mar 14, 2023
6a5f515
add copyright
jimjbrettj Mar 15, 2023
6ade315
add safe casting to memory file
jimjbrettj Mar 27, 2023
90dcf5a
respond to PR feedback
jimjbrettj Mar 27, 2023
7f59893
create wrapper around wasmer.Memory and test it
jimjbrettj Mar 14, 2023
e454587
add config and interfaces file
jimjbrettj Mar 15, 2023
5be3fd0
code gen around newInstance
jimjbrettj Mar 15, 2023
8e64e11
basic instance first take
jimjbrettj Mar 15, 2023
589ff41
ext_crypto_ed25519_generate_version_1
jimjbrettj Mar 15, 2023
2e09169
ext_crypto_ed25519_public_keys_version_1
jimjbrettj Mar 15, 2023
8c04200
ext_crypto_ed25519_sign_version_1
jimjbrettj Mar 15, 2023
8c71d4e
ext_crypto_ed25519_verify_version_1
jimjbrettj Mar 15, 2023
4af1d28
ext_crypto_ecdsa_verify_version_2
jimjbrettj Mar 15, 2023
65ed8c1
ext_crypto_secp256k1_ecdsa_recover_compressed_version_1
jimjbrettj Mar 15, 2023
283464a
ext_crypto_sr25519_generate_version_1
jimjbrettj Mar 15, 2023
cf52286
ext_crypto_sr25519_public_keys_version_1
jimjbrettj Mar 15, 2023
8ac5de0
ext_crypto_sr25519_sign_version_1
jimjbrettj Mar 15, 2023
cd82eb6
ext_crypto_sr25519_verify_version_1
jimjbrettj Mar 15, 2023
35fa2d3
ext_crypto_sr25519_verify_version_2
jimjbrettj Mar 15, 2023
9e0d9db
ext_misc_runtime_version_version_1
jimjbrettj Mar 15, 2023
e0330f9
ext_default_child_storage_next_key_version_1
jimjbrettj Mar 15, 2023
7c0b230
ext_default_child_storage_storage_kill_version_2
jimjbrettj Mar 15, 2023
95e7bcc
ext_offchain_local_storage_set_version_1
jimjbrettj Mar 15, 2023
99e2d5c
rewrite imports.go using newest version of wasmer
jimjbrettj Mar 15, 2023
d190904
create correct function signatures for new imports
jimjbrettj Mar 16, 2023
0aaa86f
getImports function
jimjbrettj Mar 16, 2023
a7f6898
more work on instance and start testing
jimjbrettj Mar 16, 2023
f98cdef
wip/fix imports tests
jimjbrettj Mar 17, 2023
7b68753
remove parallel exec and pass imports tests
jimjbrettj Mar 20, 2023
df559b9
add exports and exports test TODO/fix a few tests
jimjbrettj Mar 20, 2023
75d947f
fix exports version test
jimjbrettj Mar 20, 2023
1f5fed5
add config_test
jimjbrettj Mar 20, 2023
dd4fc5e
fix TestInstance_DecodeSessionKeys
jimjbrettj Mar 20, 2023
3a096bd
TODO fix panic
jimjbrettj Mar 20, 2023
801d942
close instance after ech test and fix tests
jimjbrettj Mar 20, 2023
fb6f5f9
tests still inconsistent
jimjbrettj Mar 20, 2023
e99f7d1
swap out wasmer packages
jimjbrettj Mar 21, 2023
d22b781
add LoadCode to runtime storage interface
jimjbrettj Mar 21, 2023
fb7607e
unskip all tests in exports test
jimjbrettj Mar 21, 2023
6e6f2d8
pass core tests
jimjbrettj Mar 21, 2023
ea764fb
pass rpc/module tests
jimjbrettj Mar 21, 2023
627d5c1
remove old wasmer
jimjbrettj Mar 21, 2023
d2a3e89
lint
jimjbrettj Mar 21, 2023
fe74359
add missing funcs to helpers test
jimjbrettj Mar 21, 2023
d8e57fe
comment out wasmer part of dockerfile
jimjbrettj Mar 21, 2023
bb742ea
clean up
jimjbrettj Mar 23, 2023
e7c701c
remove arm installation instructions in README
jimjbrettj Mar 27, 2023
47515d7
resolve codec error
jimjbrettj Mar 30, 2023
c0b5a9a
rebase and clean
jimjbrettj Mar 30, 2023
9625982
solve some quick feedback
jimjbrettj Apr 10, 2023
0596cd5
add safe casting to runtime pointer casts
jimjbrettj Apr 10, 2023
303eaaa
remove updateRuntimeCode
jimjbrettj Apr 17, 2023
e9bb5eb
Update lib/runtime/wasmer/imports_test.go
jimjbrettj Apr 18, 2023
e1e0a32
Update lib/runtime/wasmer/imports_test.go
jimjbrettj Apr 18, 2023
389a6f1
panic on invalid pointer cast
jimjbrettj Apr 18, 2023
6981dd5
make runtime tests sequencial
jimjbrettj Apr 25, 2023
fb5dda1
return copied data rather than direct slice from wasm
jimjbrettj Apr 25, 2023
84f8b17
move instantiated runtime call to caller funcs
jimjbrettj Apr 25, 2023
046d65b
update readme
jimjbrettj Apr 25, 2023
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
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ WORKDIR /go/src/github.com/ChainSafe/gossamer
COPY go.mod go.sum ./
RUN go mod download

# Prepare libwasmer.so for COPY
RUN cp /go/pkg/mod/github.com/wasmerio/go-ext-wasm@*/wasmer/libwasmer.so libwasmer.so

jimjbrettj marked this conversation as resolved.
Show resolved Hide resolved
# Copy gossamer sources
COPY . .

Expand Down
25 changes: 9 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,15 @@ make install

To install Gossamer

#### Troubleshooting for Apple Silicon users

Apple Silicon users may encounter these errors:

```sh
undefined: cWasmerImportObjectT
undefined: cWasmerImportFuncT
undefined: cWasmerValueTag
```

If so, set the following
[Golang environment variables](https://pkg.go.dev/cmd/go#hdr-Environment_variables):

```sh
GOARCH="amd64"
```
**Note**: Apple Silicon users running aarch64 might run into issues
with our wasm interpreter since wasmer is still working on supporting this architecture.
See their [README](https://github.com/wasmerio/wasmer-go) for me info on supported platforms.
Currently, there are no known issues regarding this within the Gossamer repo, but if you run into one please open an issue
on our GitHub.
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved

If you are an Apple Silicon user make sure the `GOARCH` env variable is
set to `arm64` by executing `go env`, if the variable contains another value you can change
by executing `go env -w GOARCH=arm64`

## Use Gossamer

Expand Down
1 change: 0 additions & 1 deletion dot/core/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

// RuntimeInstance for runtime methods
type RuntimeInstance interface {
UpdateRuntimeCode([]byte) error
Stop()
NodeStorage() runtime.NodeStorage
NetworkService() runtime.BasicNetwork
Expand Down
14 changes: 0 additions & 14 deletions dot/core/mocks_test.go

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

2 changes: 2 additions & 0 deletions dot/core/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ func (s *Service) handleCodeSubstitution(hash common.Hash,
return fmt.Errorf("creating new runtime instance: %w", err)
}

logger.Info("instantiated runtime!!!")

err = s.codeSubstitutedState.StoreCodeSubstitutedBlockHash(hash)
if err != nil {
return fmt.Errorf("storing code substituted block hash: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion dot/core/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func Test_Service_handleCodeSubstitution(t *testing.T) {
},
blockHash: common.Hash{0x01},
errWrapped: wasmer.ErrWASMDecompress,
errMessage: "creating new runtime instance: setting up VM: " +
errMessage: "creating new runtime instance: " +
"wasm decompression failed: unexpected EOF",
},
"store_code_substitution_block_hash_error": {
Expand Down
1 change: 0 additions & 1 deletion dot/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type Telemetry interface {
// Note: only used internally in `loadRuntime` and
// `createRuntime`.
type runtimeInterface interface {
UpdateRuntimeCode([]byte) error
Stop()
NodeStorage() runtime.NodeStorage
NetworkService() runtime.BasicNetwork
Expand Down
1 change: 0 additions & 1 deletion dot/rpc/modules/interfaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
)

type Runtime interface {
UpdateRuntimeCode([]byte) error
Stop()
NodeStorage() runtime.NodeStorage
NetworkService() runtime.BasicNetwork
Expand Down
1 change: 1 addition & 0 deletions dot/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func createRuntime(cfg *Config, ns runtime.NodeStorage, st *state.Service,
if err != nil {
return nil, fmt.Errorf("failed to create runtime executor: %s", err)
}
logger.Info("instantiated runtime!!!")
default:
return nil, fmt.Errorf("%w: %s", ErrWasmInterpreterName, cfg.Core.WasmInterpreter)
}
Expand Down
2 changes: 2 additions & 0 deletions dot/state/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,8 @@ func (bs *BlockState) HandleRuntimeChanges(newState *rtstorage.TrieState,
return err
}

logger.Info("instantiated runtime!!!")

bs.StoreRuntime(bHash, instance)

err = bs.baseState.StoreCodeSubstitutedBlockHash(common.Hash{})
Expand Down
2 changes: 2 additions & 0 deletions dot/state/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,7 @@ func (s *Service) CreateGenesisRuntime(t *trie.Trie, gen *genesis.Genesis) (Runt
return nil, fmt.Errorf("failed to create genesis runtime: %w", err)
}

logger.Info("instantiated runtime!!!")

return r, nil
}
1 change: 0 additions & 1 deletion dot/state/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ type NewBatcher interface {

// Runtime interface.
type Runtime interface {
UpdateRuntimeCode([]byte) error
Stop()
NodeStorage() runtime.NodeStorage
NetworkService() runtime.BasicNetwork
Expand Down
14 changes: 0 additions & 14 deletions dot/sync/mock_runtime_test.go

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

1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ require (
github.com/qdm12/gotree v0.2.0
github.com/stretchr/testify v1.8.2
github.com/urfave/cli/v2 v2.25.1
github.com/wasmerio/go-ext-wasm v0.3.2-0.20200326095750-0a32be6068ec
github.com/wasmerio/wasmer-go v1.0.4
github.com/whyrusleeping/mdns v0.0.0-20190826153040-b9b60ed33aa9
golang.org/x/crypto v0.8.0
Expand Down
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,6 @@ github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/urfave/cli/v2 v2.25.1 h1:zw8dSP7ghX0Gmm8vugrs6q9Ku0wzweqPyshy+syu9Gw=
github.com/urfave/cli/v2 v2.25.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/vedhavyas/go-subkey v1.0.3 h1:iKR33BB/akKmcR2PMlXPBeeODjWLM90EL98OrOGs8CA=
Expand All @@ -620,8 +619,6 @@ github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49u
github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM=
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSDJfjId/PEGEShv6ugrt4kYsC5UIDaQ=
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
github.com/wasmerio/go-ext-wasm v0.3.2-0.20200326095750-0a32be6068ec h1:VElCeVyfCWNmCv6UisKQrr+P2/JRG0uf4/FIdCB4pL0=
github.com/wasmerio/go-ext-wasm v0.3.2-0.20200326095750-0a32be6068ec/go.mod h1:VGyarTzasuS7k5KhSIGpM3tciSZlkP31Mp9VJTHMMeI=
github.com/wasmerio/wasmer-go v1.0.4 h1:MnqHoOGfiQ8MMq2RF6wyCeebKOe84G88h5yv+vmxJgs=
github.com/wasmerio/wasmer-go v1.0.4/go.mod h1:0gzVdSfg6pysA6QVp6iVRPTagC6Wq9pOE8J86WKb2Fk=
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k=
Expand Down
14 changes: 0 additions & 14 deletions lib/babe/mocks/runtime.go

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

1 change: 0 additions & 1 deletion lib/blocktree/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

// Runtime interface.
type Runtime interface {
UpdateRuntimeCode([]byte) error
Stop()
NodeStorage() runtime.NodeStorage
NetworkService() runtime.BasicNetwork
Expand Down
14 changes: 0 additions & 14 deletions lib/blocktree/mocks_test.go

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

14 changes: 0 additions & 14 deletions lib/grandpa/mocks_runtime_test.go

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

1 change: 1 addition & 0 deletions lib/runtime/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Storage interface {
BeginStorageTransaction()
CommitStorageTransaction()
RollbackStorageTransaction()
LoadCode() []byte
}

// BasicNetwork interface for functions used by runtime network state function
Expand Down
Loading