Skip to content

Commit 32d0166

Browse files
runtime/wasmer: do not cache version in instance
1 parent dc829d6 commit 32d0166

File tree

3 files changed

+3
-25
lines changed

3 files changed

+3
-25
lines changed

lib/runtime/wasmer/exports.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ func (in *Instance) ValidateTransaction(e types.Extrinsic) (*transaction.Validit
3333

3434
// Version calls runtime function Core_Version
3535
func (in *Instance) Version() (runtime.Version, error) {
36-
// kusama seems to use the legacy version format
37-
if in.version != nil {
38-
return in.version, nil
39-
}
40-
4136
res, err := in.exec(runtime.CoreVersion, []byte{})
4237
if err != nil {
4338
return nil, err
@@ -141,13 +136,6 @@ func (in *Instance) ExecuteBlock(block *types.Block) ([]byte, error) {
141136
return nil, err
142137
}
143138

144-
if in.version == nil {
145-
in.version, err = in.Version()
146-
if err != nil {
147-
return nil, err
148-
}
149-
}
150-
151139
b.Header.Digest = types.NewDigest()
152140

153141
// remove seal digest only

lib/runtime/wasmer/imports.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -949,11 +949,9 @@ func ext_misc_runtime_version_version_1(context unsafe.Pointer, dataSpan C.int64
949949
return 0
950950
}
951951

952-
// instance version is set and cached in NewInstance
953-
version := instance.version
954-
955-
if version == nil {
956-
logger.Error("failed to get runtime version")
952+
version, err := instance.Version()
953+
if err != nil {
954+
logger.Errorf("failed to get runtime version: %s", err)
957955
out, _ := toWasmMemoryOptional(instanceContext, nil)
958956
return C.int64_t(out)
959957
}

lib/runtime/wasmer/instance.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ type Config struct {
4747
type Instance struct {
4848
vm wasm.Instance
4949
ctx *runtime.Context
50-
version runtime.Version
5150
imports func() (*wasm.Imports, error)
5251
isClosed bool
5352
codeHash common.Hash
@@ -162,7 +161,6 @@ func NewInstance(code []byte, cfg *Config) (*Instance, error) {
162161
codeHash: cfg.CodeHash,
163162
}
164163

165-
inst.version, _ = inst.Version()
166164
return inst, nil
167165
}
168166

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

199-
in.version = nil
200-
in.version, err = in.Version()
201-
if err != nil {
202-
return err
203-
}
204-
205197
return nil
206198
}
207199

0 commit comments

Comments
 (0)