Skip to content

Commit

Permalink
feat(runtime/wasmer): write wasmer using latest wasmer version (#3168)
Browse files Browse the repository at this point in the history
Co-authored-by: Diego Romero <diego2737@gmail.com>
  • Loading branch information
jimjbrettj and dimartiro authored Apr 27, 2023
1 parent 0d0354b commit 32f1aa8
Show file tree
Hide file tree
Showing 36 changed files with 1,552 additions and 1,628 deletions.
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

# 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.

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

0 comments on commit 32f1aa8

Please sign in to comment.