From 70dca74103c6ee97be6f2b1a5866b89cd7bc1c7f Mon Sep 17 00:00:00 2001 From: Lucas Willems Date: Sun, 28 Apr 2024 14:05:47 +0200 Subject: [PATCH 1/5] Add timeout parameter to ScenarioVMHostBuilder --- scenario/vmBuilder.go | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/scenario/vmBuilder.go b/scenario/vmBuilder.go index d30c35cb0..9cbf7e73f 100644 --- a/scenario/vmBuilder.go +++ b/scenario/vmBuilder.go @@ -21,17 +21,22 @@ var _ scenexec.VMBuilder = (*ScenarioVMHostBuilder)(nil) // DefaultVMType is the VM type argument we use in tests. var DefaultVMType = []byte{5, 0} +// DefaultTimeOutForSCExecutionInMilliseconds is the mainnet timeout. +var DefaultTimeOutForSCExecutionInMilliseconds = 10000 + // VMTestExecutor parses, interprets and executes both .test.json tests and .scen.json scenarios with VM. type ScenarioVMHostBuilder struct { - OverrideVMExecutor executor.ExecutorAbstractFactory - VMType []byte + OverrideVMExecutor executor.ExecutorAbstractFactory + VMType []byte + TimeOutForSCExecutionInMilliseconds uint32 } // NewScenarioVMHostBuilder creates a default ScenarioVMHostBuilder. func NewScenarioVMHostBuilder() *ScenarioVMHostBuilder { return &ScenarioVMHostBuilder{ - OverrideVMExecutor: nil, - VMType: DefaultVMType, + OverrideVMExecutor: nil, + VMType: DefaultVMType, + TimeOutForSCExecutionInMilliseconds: DefaultTimeOutForSCExecutionInMilliseconds } } @@ -78,17 +83,19 @@ func (svb *ScenarioVMHostBuilder) NewVM( return hostCore.NewVMHost( world, &vmhost.VMHostParameters{ - VMType: svb.VMType, - OverrideVMExecutor: svb.OverrideVMExecutor, - BlockGasLimit: blockGasLimit, - GasSchedule: gasSchedule, - BuiltInFuncContainer: world.BuiltinFuncs.Container, - ProtectedKeyPrefix: []byte(core.ProtectedKeyPrefix), - ESDTTransferParser: esdtTransferParser, - EpochNotifier: &mock.EpochNotifierStub{}, - EnableEpochsHandler: world.EnableEpochsHandler, - WasmerSIGSEGVPassthrough: false, - Hasher: worldmock.DefaultHasher, + VMType: svb.VMType, + OverrideVMExecutor: svb.OverrideVMExecutor, + BlockGasLimit: blockGasLimit, + GasSchedule: gasSchedule, + BuiltInFuncContainer: world.BuiltinFuncs.Container, + ProtectedKeyPrefix: []byte(core.ProtectedKeyPrefix), + ESDTTransferParser: esdtTransferParser, + EpochNotifier: &mock.EpochNotifierStub{}, + EnableEpochsHandler: world.EnableEpochsHandler, + WasmerSIGSEGVPassthrough: false, + Hasher: worldmock.DefaultHasher, + TimeOutForSCExecutionInMilliseconds: svb.TimeOutForSCExecutionInMilliseconds, + }) } From 22e7b7c893e99dddc3d164e131ac9f236d403dcf Mon Sep 17 00:00:00 2001 From: Lucas Willems Date: Sun, 28 Apr 2024 14:15:40 +0200 Subject: [PATCH 2/5] Update vmBuilder.go --- scenario/vmBuilder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scenario/vmBuilder.go b/scenario/vmBuilder.go index 9cbf7e73f..b065fe76e 100644 --- a/scenario/vmBuilder.go +++ b/scenario/vmBuilder.go @@ -22,7 +22,7 @@ var _ scenexec.VMBuilder = (*ScenarioVMHostBuilder)(nil) var DefaultVMType = []byte{5, 0} // DefaultTimeOutForSCExecutionInMilliseconds is the mainnet timeout. -var DefaultTimeOutForSCExecutionInMilliseconds = 10000 +var DefaultTimeOutForSCExecutionInMilliseconds uint32 = 10000 // VMTestExecutor parses, interprets and executes both .test.json tests and .scen.json scenarios with VM. type ScenarioVMHostBuilder struct { From dd3c70fde384f916c4d47ce44aba70794716247c Mon Sep 17 00:00:00 2001 From: Lucas Willems Date: Sun, 28 Apr 2024 14:16:18 +0200 Subject: [PATCH 3/5] Update vmBuilder.go --- scenario/vmBuilder.go | 1 - 1 file changed, 1 deletion(-) diff --git a/scenario/vmBuilder.go b/scenario/vmBuilder.go index b065fe76e..e3d89f705 100644 --- a/scenario/vmBuilder.go +++ b/scenario/vmBuilder.go @@ -95,7 +95,6 @@ func (svb *ScenarioVMHostBuilder) NewVM( WasmerSIGSEGVPassthrough: false, Hasher: worldmock.DefaultHasher, TimeOutForSCExecutionInMilliseconds: svb.TimeOutForSCExecutionInMilliseconds, - }) } From 2d7f3b0dbc59644c224c25ebd08e8ce5902d91b7 Mon Sep 17 00:00:00 2001 From: Lucas Willems Date: Sun, 28 Apr 2024 14:42:02 +0200 Subject: [PATCH 4/5] Update vmBuilder.go --- scenario/vmBuilder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scenario/vmBuilder.go b/scenario/vmBuilder.go index e3d89f705..88110feca 100644 --- a/scenario/vmBuilder.go +++ b/scenario/vmBuilder.go @@ -36,7 +36,7 @@ func NewScenarioVMHostBuilder() *ScenarioVMHostBuilder { return &ScenarioVMHostBuilder{ OverrideVMExecutor: nil, VMType: DefaultVMType, - TimeOutForSCExecutionInMilliseconds: DefaultTimeOutForSCExecutionInMilliseconds + TimeOutForSCExecutionInMilliseconds: DefaultTimeOutForSCExecutionInMilliseconds, } } From 5fbcb08daa90d6574992c7a8df0ee26e451ad0d9 Mon Sep 17 00:00:00 2001 From: Lucas Willems Date: Mon, 3 Jun 2024 21:07:13 +0200 Subject: [PATCH 5/5] Update vmBuilder.go --- scenario/vmBuilder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scenario/vmBuilder.go b/scenario/vmBuilder.go index 93050bdc6..47f896851 100644 --- a/scenario/vmBuilder.go +++ b/scenario/vmBuilder.go @@ -95,7 +95,7 @@ func (svb *ScenarioVMHostBuilder) NewVM( WasmerSIGSEGVPassthrough: false, Hasher: worldmock.DefaultHasher, MapOpcodeAddressIsAllowed: map[string]map[string]struct{}{}, - TimeOutForSCExecutionInMilliseconds: svb.TimeOutForSCExecutionInMilliseconds, + TimeOutForSCExecutionInMilliseconds: svb.TimeOutForSCExecutionInMilliseconds, }) }