Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
a00430a
fixing todos
sasurobert Aug 5, 2025
06e2470
AI Agent review and code refactor
sasurobert Aug 5, 2025
a92b826
disable function
sasurobert Aug 5, 2025
c6f5a0a
asynclocal refactor
sasurobert Aug 5, 2025
71f4c2c
more refactors
sasurobert Aug 5, 2025
60ad7cd
more refactors
sasurobert Aug 5, 2025
29de47b
hardening endpoint with fail execution.
sasurobert Aug 5, 2025
0178e07
hardening endpoint with fail execution.
sasurobert Aug 6, 2025
1e817e2
hardening endpoint with fail execution.
sasurobert Aug 6, 2025
9e21c98
tests things alone.
sasurobert Aug 6, 2025
ab2324c
new generated testing
sasurobert Aug 6, 2025
5f3ebaf
unit test improvements.
sasurobert Aug 6, 2025
6e443cf
unit test improvements.
sasurobert Aug 6, 2025
f07bc54
storage refactor
sasurobert Aug 6, 2025
df55ec3
simplify
sasurobert Aug 6, 2025
62fa8d3
adding more AI generated tests, and trying to see how to make him do …
sasurobert Aug 6, 2025
6584d27
adding more AI generated tests, and trying to see how to make him do …
sasurobert Aug 6, 2025
0f737ae
adding more AI generated tests, and trying to see how to make him do …
sasurobert Aug 7, 2025
8500f9f
stubbing the mock
sasurobert Aug 7, 2025
5ba8eac
stubbing the mock
sasurobert Aug 7, 2025
2784f78
stubbing the mock
sasurobert Aug 7, 2025
8960131
teeeeeeeeeests
sasurobert Aug 7, 2025
343a6a5
more ai generated tests.
sasurobert Aug 7, 2025
15156dd
more ai generated tests.
sasurobert Aug 7, 2025
a7bb171
more ai generated tests.
sasurobert Aug 7, 2025
5015248
mandos test update (out of bounds protection)
andrei-marinica Aug 8, 2025
bac0d1a
initial implementation of unSafe mode
sasurobert Aug 8, 2025
a789982
mandos - merged barnard-features into basic-features
andrei-marinica Aug 8, 2025
be9de75
mandos - merged forwarder-barnard into forwarder & removed payable-fe…
andrei-marinica Aug 10, 2025
6116b85
mandos - framework version v0.60.0
andrei-marinica Aug 10, 2025
2df0321
update executor binaries
laurci Aug 11, 2025
07402dd
go lint fix
sasurobert Aug 11, 2025
0ee2b6d
hardening, small refactor, adding enable epochs.
sasurobert Aug 11, 2025
3dbe939
using FailExecutionConditionally
sasurobert Aug 11, 2025
28820e7
using FailExecutionConditionally
sasurobert Aug 11, 2025
dfd6ca5
added managedGetErrors OpCodes.
sasurobert Aug 11, 2025
d901632
Merge pull request #957 from multiversx/add-unit-tests-for-vmhost
sasurobert Aug 12, 2025
0d544d9
added managedGetErrors OpCodes.
sasurobert Aug 12, 2025
a04e4ca
making return values consistent.
sasurobert Aug 12, 2025
1209d33
Merge branch 'rc/after-supernova' into unsafe-operations-code
sasurobert Aug 12, 2025
ba325de
Merge branch 'rc/after-supernova' into start-resolving-todos
sasurobert Aug 12, 2025
e93a93a
fix after merge
sasurobert Aug 12, 2025
76213b3
fix after merge
sasurobert Aug 12, 2025
4d85883
update executor binaries
laurci Aug 12, 2025
7c5b391
Merge branch 'start-resolving-todos' into unsafe-operations-code
sasurobert Aug 12, 2025
35ee559
fix after merge
sasurobert Aug 12, 2025
8537675
fix after merge
sasurobert Aug 12, 2025
94b3a87
go lint
sasurobert Aug 12, 2025
ec0bd90
test fixes and backward compatibility
sasurobert Aug 12, 2025
e58dd12
fixes after merge or something.
sasurobert Aug 12, 2025
f814b1f
add missing file
sasurobert Aug 12, 2025
af72b42
Merge branch 'start-resolving-todos' into unsafe-operations-code
sasurobert Aug 12, 2025
a0168e5
Merge branch 'rc/after-supernova' into mandos-v60
andrei-marinica Aug 13, 2025
3b4e1cf
cleanup
andrei-marinica Aug 13, 2025
bf4967c
Merge pull request #961 from multiversx/mandos-v60
andrei-marinica Aug 13, 2025
d55c62a
Merge branch 'rc/after-supernova' into start-resolving-todos
andrei-marinica Aug 13, 2025
7a363e0
Merge branch 'rc/after-supernova' into start-resolving-todos
sasurobert Aug 14, 2025
f19c37e
Merge branch 'start-resolving-todos' into unsafe-operations-code
sasurobert Aug 14, 2025
1433dce
timelock refactor fix
andrei-marinica Aug 19, 2025
8a24232
error message fix
andrei-marinica Aug 19, 2025
7914cc6
mandos - contract upgrade (hardened managed slices in framework)
andrei-marinica Aug 19, 2025
bc84e5b
Merge branch 'start-resolving-todos' into todos-test-fix
andrei-marinica Aug 19, 2025
fff1b08
Merge pull request #966 from multiversx/todos-test-fix
andrei-marinica Aug 19, 2025
9fe7642
Merge pull request #956 from multiversx/start-resolving-todos
sasurobert Aug 20, 2025
1c6a882
Merge branch 'rc/after-supernova' into unsafe-operations-code
sasurobert Aug 20, 2025
d0ece5b
change to trace
sasurobert Aug 20, 2025
765285c
delete unused func
sasurobert Aug 20, 2025
dd2861b
code coverage improvements
sasurobert Aug 20, 2025
46d5b71
Merge pull request #962 from multiversx/unsafe-operations-code
sasurobert Aug 21, 2025
ce7ab6e
integrated mx-scenario-go 1.7.0, test update
andrei-marinica Oct 14, 2025
93e6be9
test fix
andrei-marinica Oct 14, 2025
af07ca9
Merge pull request #974 from multiversx/scenario-go-1.7.0
andrei-marinica Oct 15, 2025
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
9 changes: 9 additions & 0 deletions executor/vmHooks.go

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

41 changes: 41 additions & 0 deletions executor/wrapper/wrapperVMHooks.go

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

3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/multiversx/mx-chain-core-go v1.4.0
github.com/multiversx/mx-chain-crypto-go v1.3.0
github.com/multiversx/mx-chain-logger-go v1.1.0
github.com/multiversx/mx-chain-scenario-go v1.6.0
github.com/multiversx/mx-chain-scenario-go v1.7.0
github.com/multiversx/mx-chain-storage-go v1.1.0
github.com/multiversx/mx-chain-vm-common-go v1.6.0
github.com/multiversx/mx-components-big-int v1.1.0
Expand All @@ -36,6 +36,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/sys v0.2.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
Expand Down
5 changes: 3 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ github.com/multiversx/mx-chain-crypto-go v1.3.0 h1:0eK2bkDOMi8VbSPrB1/vGJSYT81IB
github.com/multiversx/mx-chain-crypto-go v1.3.0/go.mod h1:nPIkxxzyTP8IquWKds+22Q2OJ9W7LtusC7cAosz7ojM=
github.com/multiversx/mx-chain-logger-go v1.1.0 h1:97x84A6L4RfCa6YOx1HpAFxZp1cf/WI0Qh112whgZNM=
github.com/multiversx/mx-chain-logger-go v1.1.0/go.mod h1:K9XgiohLwOsNACETMNL0LItJMREuEvTH6NsoXWXWg7g=
github.com/multiversx/mx-chain-scenario-go v1.6.0 h1:cwDFuS1pSc4YXnfiKKDTEb+QDY4fulPQaiRgIebnKxI=
github.com/multiversx/mx-chain-scenario-go v1.6.0/go.mod h1:GrSYu1SnMvsIm9djUz1X13224HcvdY6Nb5KHNT3xZPA=
github.com/multiversx/mx-chain-scenario-go v1.7.0 h1:7hEuvLPDZw2xA7YlzrjORxIK4lTTT34QL6O06JiotWE=
github.com/multiversx/mx-chain-scenario-go v1.7.0/go.mod h1:GrSYu1SnMvsIm9djUz1X13224HcvdY6Nb5KHNT3xZPA=
github.com/multiversx/mx-chain-storage-go v1.1.0 h1:M1Y9DqMrJ62s7Zw31+cyuqsnPIvlG4jLBJl5WzeZLe8=
github.com/multiversx/mx-chain-storage-go v1.1.0/go.mod h1:o6Jm7cjfPmcc6XpyihYWrd6sx3sgqwurrunw3ZrfyxI=
github.com/multiversx/mx-chain-vm-common-go v1.6.0 h1:M2zmf/ptEINciWxYCPLIkwOMTvvzWjELYYB+0MMQ5Gw=
Expand Down Expand Up @@ -118,6 +118,7 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down
58 changes: 8 additions & 50 deletions integrationTests/json/scenariosFeatures_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package vmjsonintegrationtest

import (
"path/filepath"
"testing"
)

Expand All @@ -16,18 +15,6 @@ func TestRustAllocFeatures(t *testing.T) {
CheckNoError()
}

func TestRustBarnardFeatures(t *testing.T) {
// TODO: will get merged into basic-features after barnard mainnet release
if testing.Short() {
t.Skip("not a short test")
}

ScenariosTest(t).
Folder("features/barnard-features/scenarios").
Run().
CheckNoError()
}

func TestRustBasicFeaturesLatest(t *testing.T) {
if testing.Short() {
t.Skip("not a short test")
Expand All @@ -41,23 +28,6 @@ func TestRustBasicFeaturesLatest(t *testing.T) {
CheckNoError()
}

func TestRustBasicFeaturesBarnard(t *testing.T) {
if testing.Short() {
t.Skip("not a short test")
}

ScenariosTest(t).
Folder("features/basic-features/scenarios").
Exclude("features/basic-features/scenarios/storage_mapper_fungible_token.scen.json").
Exclude("features/basic-features/scenarios/get_shard_of_address.scen.json").
ReplacePath(
"../output/basic-features.mxsc.json",
filepath.Join(getTestRoot(), "features/basic-features/output/basic-features-barnard.mxsc.json"),
).
Run().
CheckNoError()
}

func TestRustBasicFeaturesNoSmallIntApi(t *testing.T) {
if testing.Short() {
t.Skip("not a short test")
Expand Down Expand Up @@ -125,26 +95,6 @@ func TestRustPayableFeatures(t *testing.T) {
CheckNoError()
}

func TestRustPayableFeaturesBarnard(t *testing.T) {
if testing.Short() {
t.Skip("not a short test")
}

// we run the exact same tests, but on a different compiled contract,
// this contract uses the new "managedGetAllTransfersCallValue" VM hook,
// which is only available in Barnard
// this will become the only test

ScenariosTest(t).
Folder("features/payable-features/scenarios").
ReplacePath(
"../output/payable-features.mxsc.json",
filepath.Join(getTestRoot(), "features/payable-features/output/payable-features-barnard.mxsc.json"),
).
Run().
CheckNoError()
}

func TestRustComposability(t *testing.T) {
ScenariosTest(t).
Folder("features/composability/scenarios").
Expand Down Expand Up @@ -181,3 +131,11 @@ func TestBalanceAfterGet(t *testing.T) {
Run().
CheckNoError()
}

func TestNFTDecode(t *testing.T) {
ScenariosTest(t).
Folder("features/composability/scenarios").
File("forwarder_nft_decode_complex_attributes.scen.json").
Run().
CheckNoError()
}
5 changes: 5 additions & 0 deletions mock/context/executorMockFunc.go

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

25 changes: 15 additions & 10 deletions mock/context/runtimeContextMock.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type RuntimeContextMock struct {
CallFunction string
VMType []byte
ReadOnlyFlag bool
UnsafeModeFlag bool
VerifyCode bool
CurrentBreakpointValue vmhost.BreakpointValue
PointsUsed uint64
Expand Down Expand Up @@ -52,7 +53,7 @@ func (r *RuntimeContextMock) GetVMExecutor() executor.Executor {
}

// ReplaceVMExecutor mocked method
func (context *RuntimeContextMock) ReplaceVMExecutor(vmExecutor executor.Executor) {
func (context *RuntimeContextMock) ReplaceVMExecutor(_ executor.Executor) {
}

// GetInstanceTracker mocked method
Expand Down Expand Up @@ -196,14 +197,8 @@ func (r *RuntimeContextMock) GetOriginalTxHash() []byte {
return r.OriginalTxHash
}

// ExtractCodeUpgradeFromArgs mocked method
func (r *RuntimeContextMock) ExtractCodeUpgradeFromArgs() ([]byte, []byte, error) {
arguments := r.VMInput.Arguments
if len(arguments) < 2 {
panic("ExtractCodeUpgradeFromArgs: bad test setup")
}

return r.VMInput.Arguments[0], r.VMInput.Arguments[1], nil
// RemoveCodeUpgradeFromArgs mocked method
func (r *RuntimeContextMock) RemoveCodeUpgradeFromArgs() {
}

// SignalExit mocked method
Expand Down Expand Up @@ -259,7 +254,7 @@ func (r *RuntimeContextMock) GetInstance() executor.Instance {
}

// GetWarmInstance mocked method
func (r *RuntimeContextMock) GetWarmInstance(codeHash []byte) (executor.Instance, bool) {
func (r *RuntimeContextMock) GetWarmInstance(_ []byte) (executor.Instance, bool) {
return nil, false
}

Expand Down Expand Up @@ -320,6 +315,16 @@ func (r *RuntimeContextMock) UseGasBoundedShouldFailExecution() bool {
return true
}

// IsUnsafeMode mocked method
func (r *RuntimeContextMock) IsUnsafeMode() bool {
return r.UnsafeModeFlag
}

// SetUnsafeMode mocked method
func (r *RuntimeContextMock) SetUnsafeMode(unsafeMode bool) {
r.UnsafeModeFlag = unsafeMode
}

// FailExecution mocked method
func (r *RuntimeContextMock) FailExecution(_ error) {
}
Expand Down
34 changes: 28 additions & 6 deletions mock/context/runtimeContextWrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type RuntimeContextWrapper struct {
// function that will be called by the corresponding RuntimeContext function implementation (by default this will call the same wrapped context function)
GetOriginalTxHashFunc func() []byte
// function that will be called by the corresponding RuntimeContext function implementation (by default this will call the same wrapped context function)
ExtractCodeUpgradeFromArgsFunc func() ([]byte, []byte, error)
RemoveCodeUpgradeFromArgsFunc func()
// function that will be called by the corresponding RuntimeContext function implementation (by default this will call the same wrapped context function)
SignalUserErrorFunc func(message string)
// function that will be called by the corresponding RuntimeContext function implementation (by default this will call the same wrapped context function)
Expand Down Expand Up @@ -72,6 +72,10 @@ type RuntimeContextWrapper struct {
// function that will be called by the corresponding RuntimeContext function implementation (by default this will call the same wrapped context function)
SetReadOnlyFunc func(readOnly bool)
// function that will be called by the corresponding RuntimeContext function implementation (by default this will call the same wrapped context function)
IsUnsafeModeFunc func() bool
// function that will be called by the corresponding RuntimeContext function implementation (by default this will call the same wrapped context function)
SetUnsafeModeFunc func(readOnly bool)
// function that will be called by the corresponding RuntimeContext function implementation (by default this will call the same wrapped context function)
StartWasmerInstanceFunc func(contract []byte, gasLimit uint64, newCode bool) error
// function that will be called by the corresponding RuntimeContext function implementation (by default this will call the same wrapped context function)
ClearWarmInstanceCacheFunc func()
Expand Down Expand Up @@ -184,8 +188,8 @@ func NewRuntimeContextWrapper(inputRuntimeContext *vmhost.RuntimeContext) *Runti
return runtimeWrapper.runtimeContext.GetOriginalTxHash()
}

runtimeWrapper.ExtractCodeUpgradeFromArgsFunc = func() ([]byte, []byte, error) {
return runtimeWrapper.runtimeContext.ExtractCodeUpgradeFromArgs()
runtimeWrapper.RemoveCodeUpgradeFromArgsFunc = func() {
runtimeWrapper.runtimeContext.RemoveCodeUpgradeFromArgs()
}

runtimeWrapper.SignalUserErrorFunc = func(message string) {
Expand Down Expand Up @@ -224,6 +228,14 @@ func NewRuntimeContextWrapper(inputRuntimeContext *vmhost.RuntimeContext) *Runti
runtimeWrapper.runtimeContext.SetReadOnly(readOnly)
}

runtimeWrapper.IsUnsafeModeFunc = func() bool {
return runtimeWrapper.runtimeContext.IsUnsafeMode()
}

runtimeWrapper.SetUnsafeModeFunc = func(unSafe bool) {
runtimeWrapper.runtimeContext.SetUnsafeMode(unSafe)
}

runtimeWrapper.StartWasmerInstanceFunc = func(contract []byte, gasLimit uint64, newCode bool) error {
return runtimeWrapper.runtimeContext.StartWasmerInstance(contract, gasLimit, newCode)
}
Expand Down Expand Up @@ -374,9 +386,9 @@ func (contextWrapper *RuntimeContextWrapper) GetOriginalTxHash() []byte {
return contextWrapper.GetOriginalTxHashFunc()
}

// ExtractCodeUpgradeFromArgs calls corresponding xxxFunc function, that by default in turn calls the original method of the wrapped RuntimeContext
func (contextWrapper *RuntimeContextWrapper) ExtractCodeUpgradeFromArgs() ([]byte, []byte, error) {
return contextWrapper.ExtractCodeUpgradeFromArgsFunc()
// RemoveCodeUpgradeFromArgs calls corresponding xxxFunc function, that by default in turn calls the original method of the wrapped RuntimeContext
func (contextWrapper *RuntimeContextWrapper) RemoveCodeUpgradeFromArgs() {
contextWrapper.RemoveCodeUpgradeFromArgsFunc()
}

// SignalUserError calls corresponding xxxFunc function, that by default in turn calls the original method of the wrapped RuntimeContext
Expand Down Expand Up @@ -429,6 +441,16 @@ func (contextWrapper *RuntimeContextWrapper) SetReadOnly(readOnly bool) {
contextWrapper.SetReadOnlyFunc(readOnly)
}

// IsUnsafeMode calls corresponding xxxFunc function, that by default in turn calls the original method of the wrapped RuntimeContext
func (contextWrapper *RuntimeContextWrapper) IsUnsafeMode() bool {
return contextWrapper.IsUnsafeModeFunc()
}

// SetUnsafeMode calls corresponding xxxFunc function, that by default in turn calls the original method of the wrapped RuntimeContext
func (contextWrapper *RuntimeContextWrapper) SetUnsafeMode(unsafeMode bool) {
contextWrapper.SetUnsafeModeFunc(unsafeMode)
}

// StartWasmerInstance calls corresponding xxxFunc function, that by default in turn calls the original method of the wrapped RuntimeContext
func (contextWrapper *RuntimeContextWrapper) StartWasmerInstance(contract []byte, gasLimit uint64, newCode bool) error {
return contextWrapper.StartWasmerInstanceFunc(contract, gasLimit, newCode)
Expand Down
6 changes: 5 additions & 1 deletion mock/context/vmHostStub.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package mock

import (
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/data/vm"
"github.com/multiversx/mx-chain-scenario-go/worldmock"
vmcommon "github.com/multiversx/mx-chain-vm-common-go"
"github.com/multiversx/mx-chain-vm-go/config"
"github.com/multiversx/mx-chain-vm-go/crypto"
Expand Down Expand Up @@ -165,7 +167,9 @@ func (vhs *VMHostStub) EnableEpochsHandler() vmhost.EnableEpochsHandler {
if vhs.EnableEpochsHandlerCalled != nil {
return vhs.EnableEpochsHandlerCalled()
}
return nil
return &worldmock.EnableEpochsHandlerStub{IsFlagEnabledCalled: func(flag core.EnableEpochFlag) bool {
return true
}}
}

// Async mocked method
Expand Down
10 changes: 9 additions & 1 deletion mock/contracts/deployerSimpleSC.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package contracts

import (
"errors"
vmcommon "github.com/multiversx/mx-chain-vm-common-go"
"github.com/multiversx/mx-chain-vm-go/vmhost"
"math/big"

mock "github.com/multiversx/mx-chain-vm-go/mock/context"
Expand Down Expand Up @@ -39,7 +42,12 @@ func DeployContractFromSourceMock(instanceMock *mock.InstanceMock, _ interface{}
)

if err != nil {
host.Runtime().FailExecution(err)
if errors.Is(err, vmhost.ErrNotEnoughGas) {
host.Output().SetReturnCode(vmcommon.OutOfGas)
} else {
host.Runtime().FailExecution(err)
}

return instance
}

Expand Down
Loading
Loading