diff --git a/pkg/core/interop_neo.go b/pkg/core/interop_neo.go index 0dc9a1a75..e1211cdfb 100644 --- a/pkg/core/interop_neo.go +++ b/pkg/core/interop_neo.go @@ -736,3 +736,13 @@ func (ic *interopContext) assetRenew(v *vm.VM) error { v.Estack().PushVal(expiration) return nil } + +// runtimeSerialize serializes top stack item into a ByteArray. +func (ic *interopContext) runtimeSerialize(v *vm.VM) error { + return vm.RuntimeSerialize(v) +} + +// runtimeDeserialize deserializes ByteArray from a stack into an item. +func (ic *interopContext) runtimeDeserialize(v *vm.VM) error { + return vm.RuntimeDeserialize(v) +} diff --git a/pkg/core/interops.go b/pkg/core/interops.go index 9f7782a86..1df944eda 100644 --- a/pkg/core/interops.go +++ b/pkg/core/interops.go @@ -64,8 +64,8 @@ func (ic *interopContext) getSystemInteropMap() map[string]vm.InteropFuncPrice { "System.Storage.PutEx": {Func: ic.storagePutEx, Price: 0}, "System.StorageContext.AsReadOnly": {Func: ic.storageContextAsReadOnly, Price: 1}, "System.Transaction.GetHash": {Func: ic.txGetHash, Price: 1}, - // "System.Runtime.Deserialize": {Func: ic.runtimeDeserialize, Price: 1}, - // "System.Runtime.Serialize": {Func: ic.runtimeSerialize, Price: 1}, + "System.Runtime.Deserialize": {Func: ic.runtimeDeserialize, Price: 1}, + "System.Runtime.Serialize": {Func: ic.runtimeSerialize, Price: 1}, } } @@ -148,8 +148,8 @@ func (ic *interopContext) getNeoInteropMap() map[string]vm.InteropFuncPrice { // "Neo.Iterator.Key": {Func: ic.iteratorKey, Price: 1}, // "Neo.Iterator.Keys": {Func: ic.iteratorKeys, Price: 1}, // "Neo.Iterator.Values": {Func: ic.iteratorValues, Price: 1}, - // "Neo.Runtime.Deserialize": {Func: ic.runtimeDeserialize, Price: 1}, - // "Neo.Runtime.Serialize": {Func: ic.runtimeSerialize, Price: 1}, + "Neo.Runtime.Deserialize": {Func: ic.runtimeDeserialize, Price: 1}, + "Neo.Runtime.Serialize": {Func: ic.runtimeSerialize, Price: 1}, // "Neo.Storage.Find": {Func: ic.storageFind, Price: 1}, // "Neo.Witness.GetVerificationScript": {Func: ic.witnessGetVerificationScript, Price: 100}, diff --git a/pkg/vm/interop.go b/pkg/vm/interop.go index 8e83e0f11..c96477f6f 100644 --- a/pkg/vm/interop.go +++ b/pkg/vm/interop.go @@ -22,8 +22,8 @@ func runtimeNotify(vm *VM) error { return nil } -// runtimeSerialize handles syscalls System.Runtime.Serialize and Neo.Runtime.Serialize. -func runtimeSerialize(vm *VM) error { +// RuntimeSerialize handles syscalls System.Runtime.Serialize and Neo.Runtime.Serialize. +func RuntimeSerialize(vm *VM) error { item := vm.Estack().Pop() data, err := serializeItem(item.value) if err != nil { @@ -37,8 +37,8 @@ func runtimeSerialize(vm *VM) error { return nil } -// runtimeDeserialize handles syscalls System.Runtime.Deserialize and Neo.Runtime.Deserialize. -func runtimeDeserialize(vm *VM) error { +// RuntimeDeserialize handles syscalls System.Runtime.Deserialize and Neo.Runtime.Deserialize. +func RuntimeDeserialize(vm *VM) error { data := vm.Estack().Pop().Bytes() item, err := deserializeItem(data) diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index 0fb917883..0043afa11 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -86,10 +86,10 @@ func New() *VM { // Register native interop hooks. vm.RegisterInteropFunc("Neo.Runtime.Log", runtimeLog, 1) vm.RegisterInteropFunc("Neo.Runtime.Notify", runtimeNotify, 1) - vm.RegisterInteropFunc("Neo.Runtime.Serialize", runtimeSerialize, 1) - vm.RegisterInteropFunc("System.Runtime.Serialize", runtimeSerialize, 1) - vm.RegisterInteropFunc("Neo.Runtime.Deserialize", runtimeDeserialize, 1) - vm.RegisterInteropFunc("System.Runtime.Deserialize", runtimeDeserialize, 1) + vm.RegisterInteropFunc("Neo.Runtime.Serialize", RuntimeSerialize, 1) + vm.RegisterInteropFunc("System.Runtime.Serialize", RuntimeSerialize, 1) + vm.RegisterInteropFunc("Neo.Runtime.Deserialize", RuntimeDeserialize, 1) + vm.RegisterInteropFunc("System.Runtime.Deserialize", RuntimeDeserialize, 1) return vm }