Skip to content

Commit

Permalink
runtime/wasmer: do not cache version in instance
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianFranzen committed Mar 22, 2022
1 parent 723c7ac commit e374be5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 25 deletions.
12 changes: 0 additions & 12 deletions lib/runtime/wasmer/exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ func (in *Instance) ValidateTransaction(e types.Extrinsic) (*transaction.Validit

// Version calls runtime function Core_Version
func (in *Instance) Version() (runtime.Version, error) {
// kusama seems to use the legacy version format
if in.version != nil {
return in.version, nil
}

res, err := in.exec(runtime.CoreVersion, []byte{})
if err != nil {
return nil, err
Expand Down Expand Up @@ -141,13 +136,6 @@ func (in *Instance) ExecuteBlock(block *types.Block) ([]byte, error) {
return nil, err
}

if in.version == nil {
in.version, err = in.Version()
if err != nil {
return nil, err
}
}

b.Header.Digest = types.NewDigest()

// remove seal digest only
Expand Down
8 changes: 3 additions & 5 deletions lib/runtime/wasmer/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,11 +949,9 @@ func ext_misc_runtime_version_version_1(context unsafe.Pointer, dataSpan C.int64
return 0
}

// instance version is set and cached in NewInstance
version := instance.version

if version == nil {
logger.Error("failed to get runtime version")
version, err := instance.Version()
if err != nil {
logger.Error("failed to get runtime version: %s", err)
out, _ := toWasmMemoryOptional(instanceContext, nil)
return C.int64_t(out)
}
Expand Down
8 changes: 0 additions & 8 deletions lib/runtime/wasmer/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ type Config struct {
type Instance struct {
vm wasm.Instance
ctx *runtime.Context
version runtime.Version
imports func() (*wasm.Imports, error)
isClosed bool
codeHash common.Hash
Expand Down Expand Up @@ -162,7 +161,6 @@ func NewInstance(code []byte, cfg *Config) (*Instance, error) {
codeHash: cfg.CodeHash,
}

inst.version, _ = inst.Version()
return inst, nil
}

Expand Down Expand Up @@ -196,12 +194,6 @@ func (in *Instance) UpdateRuntimeCode(code []byte) error {
return err
}

in.version = nil
in.version, err = in.Version()
if err != nil {
return err
}

return nil
}

Expand Down

0 comments on commit e374be5

Please sign in to comment.