Skip to content

Commit

Permalink
Merge branch 'master' into merge-master-rc1.7.next1-20-08-2024
Browse files Browse the repository at this point in the history
# Conflicts:
#	vmhost/contexts/storage.go
#	vmhost/flags.go
#	vmhost/hostCore/host.go
#	vmhost/vmhooks/cryptoei.go
  • Loading branch information
sasurobert committed Aug 20, 2024
2 parents 80062df + fe09132 commit c9deb92
Show file tree
Hide file tree
Showing 32 changed files with 1,651 additions and 504 deletions.
25 changes: 25 additions & 0 deletions integrationTests/json/scenariosAdderLog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,35 @@ HasFunction(init): true
CallFunction(init):
VM hook begin: CheckNoPayment()
GetPointsUsed: 3
GetPointsUsed: 3
SetPointsUsed: 103
VM hook end: CheckNoPayment()
VM hook begin: GetNumArguments()
GetPointsUsed: 110
GetPointsUsed: 110
SetPointsUsed: 210
VM hook end: GetNumArguments()
VM hook begin: BigIntGetUnsignedArgument(0, -101)
GetPointsUsed: 249
GetPointsUsed: 249
SetPointsUsed: 1249
VM hook end: BigIntGetUnsignedArgument(0, -101)
VM hook begin: MBufferSetBytes(-102, 131097, 3)
GetPointsUsed: 1289
GetPointsUsed: 1289
SetPointsUsed: 3289
GetPointsUsed: 3289
GetPointsUsed: 3289
SetPointsUsed: 6289
VM hook end: MBufferSetBytes(-102, 131097, 3)
VM hook begin: MBufferFromBigIntUnsigned(-103, -101)
GetPointsUsed: 6333
GetPointsUsed: 6333
SetPointsUsed: 10333
VM hook end: MBufferFromBigIntUnsigned(-103, -101)
VM hook begin: MBufferStorageStore(-102, -103)
GetPointsUsed: 10345
GetPointsUsed: 10345
SetPointsUsed: 85345
GetPointsUsed: 85345
GetPointsUsed: 85345
Expand All @@ -57,33 +64,41 @@ HasFunction(getSum): true
CallFunction(getSum):
VM hook begin: CheckNoPayment()
GetPointsUsed: 3
GetPointsUsed: 3
SetPointsUsed: 103
VM hook end: CheckNoPayment()
VM hook begin: GetNumArguments()
GetPointsUsed: 110
GetPointsUsed: 110
SetPointsUsed: 210
VM hook end: GetNumArguments()
VM hook begin: MBufferSetBytes(-101, 131097, 3)
GetPointsUsed: 250
GetPointsUsed: 250
SetPointsUsed: 2250
GetPointsUsed: 2250
GetPointsUsed: 2250
SetPointsUsed: 5250
VM hook end: MBufferSetBytes(-101, 131097, 3)
VM hook begin: MBufferStorageLoad(-101, -102)
GetPointsUsed: 5291
GetPointsUsed: 5291
SetPointsUsed: 6291
GetPointsUsed: 6291
GetPointsUsed: 6291
SetPointsUsed: 21578
VM hook end: MBufferStorageLoad(-101, -102)
VM hook begin: MBufferToBigIntUnsigned(-102, -103)
GetPointsUsed: 21611
GetPointsUsed: 21611
SetPointsUsed: 25611
VM hook end: MBufferToBigIntUnsigned(-102, -103)
VM hook begin: BigIntFinishUnsigned(-103)
GetPointsUsed: 25622
GetPointsUsed: 25622
SetPointsUsed: 26622
GetPointsUsed: 26622
GetPointsUsed: 26622
SetPointsUsed: 36622
VM hook end: BigIntFinishUnsigned(-103)
GetPointsUsed: 36624
Expand All @@ -102,43 +117,53 @@ HasFunction(add): true
CallFunction(add):
VM hook begin: CheckNoPayment()
GetPointsUsed: 3
GetPointsUsed: 3
SetPointsUsed: 103
VM hook end: CheckNoPayment()
VM hook begin: GetNumArguments()
GetPointsUsed: 110
GetPointsUsed: 110
SetPointsUsed: 210
VM hook end: GetNumArguments()
VM hook begin: BigIntGetUnsignedArgument(0, -101)
GetPointsUsed: 249
GetPointsUsed: 249
SetPointsUsed: 1249
VM hook end: BigIntGetUnsignedArgument(0, -101)
VM hook begin: MBufferSetBytes(-102, 131097, 3)
GetPointsUsed: 1289
GetPointsUsed: 1289
SetPointsUsed: 3289
GetPointsUsed: 3289
GetPointsUsed: 3289
SetPointsUsed: 6289
VM hook end: MBufferSetBytes(-102, 131097, 3)
VM hook begin: MBufferStorageLoad(-102, -103)
GetPointsUsed: 6333
GetPointsUsed: 6333
SetPointsUsed: 7333
GetPointsUsed: 7333
GetPointsUsed: 7333
SetPointsUsed: 22620
VM hook end: MBufferStorageLoad(-102, -103)
VM hook begin: MBufferToBigIntUnsigned(-103, -104)
GetPointsUsed: 22653
GetPointsUsed: 22653
SetPointsUsed: 26653
VM hook end: MBufferToBigIntUnsigned(-103, -104)
VM hook begin: BigIntAdd(-104, -104, -101)
GetPointsUsed: 26673
GetPointsUsed: 26673
SetPointsUsed: 28673
VM hook end: BigIntAdd(-104, -104, -101)
VM hook begin: MBufferFromBigIntUnsigned(-105, -104)
GetPointsUsed: 28712
GetPointsUsed: 28712
SetPointsUsed: 32712
VM hook end: MBufferFromBigIntUnsigned(-105, -104)
VM hook begin: MBufferStorageStore(-102, -105)
GetPointsUsed: 32724
GetPointsUsed: 32724
SetPointsUsed: 107724
GetPointsUsed: 107724
GetPointsUsed: 107724
Expand Down
15 changes: 7 additions & 8 deletions mock/context/meteringContextMock.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (m *MeteringContextMock) GasSchedule() *config.GasCost {
}

// UseGas mocked method
func (m *MeteringContextMock) UseGas(gas uint64) {
func (m *MeteringContextMock) useGas(gas uint64) {
if gas > m.GasLeftMock {
m.GasLeftMock = 0
return
Expand All @@ -59,12 +59,6 @@ func (m *MeteringContextMock) UseGas(gas uint64) {
m.GasLeftMock -= gas
}

// UseAndTraceGas mocked method
func (m *MeteringContextMock) UseAndTraceGas(_ uint64) {}

// UseGasAndAddTracedGas mocked method
func (m *MeteringContextMock) UseGasAndAddTracedGas(_ string, _ uint64) {}

// UseGasBoundedAndAddTracedGas -
func (m *MeteringContextMock) UseGasBoundedAndAddTracedGas(_ string, _ uint64) error {
return nil
Expand Down Expand Up @@ -151,6 +145,11 @@ func (m *MeteringContextMock) DeductGasIfAsyncStep() error {
return m.Err
}

// UseGasForContractInit mocked method
func (m *MeteringContextMock) UseGasForContractInit(gasToUse uint64) {
m.useGas(gasToUse)
}

// UseGasBounded mocked method
func (m *MeteringContextMock) UseGasBounded(gas uint64) error {
if m.Err != nil {
Expand All @@ -159,7 +158,7 @@ func (m *MeteringContextMock) UseGasBounded(gas uint64) error {
if m.GasLeft() <= gas {
return vmhost.ErrNotEnoughGas
}
m.UseGas(gas)
m.useGas(gas)
return nil
}

Expand Down
5 changes: 5 additions & 0 deletions mock/context/runtimeContextMock.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ func (r *RuntimeContextMock) ManagedMapAPIErrorShouldFailExecution() bool {
return r.FailManagedMapAPI
}

// UseGasBoundedShouldFailExecution mocked method
func (r *RuntimeContextMock) UseGasBoundedShouldFailExecution() bool {
return true
}

// FailExecution mocked method
func (r *RuntimeContextMock) FailExecution(_ error) {
}
Expand Down
5 changes: 5 additions & 0 deletions mock/context/runtimeContextWrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,11 @@ func (contextWrapper *RuntimeContextWrapper) ManagedMapAPIErrorShouldFailExecuti
return contextWrapper.runtimeContext.ManagedMapAPIErrorShouldFailExecution()
}

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

// GetVMExecutor calls corresponding xxxFunc function, that by default in turn calls the original method of the wrapped RuntimeContext
func (contextWrapper *RuntimeContextWrapper) GetVMExecutor() executor.Executor {
return contextWrapper.GetVMExecutorFunc()
Expand Down
2 changes: 1 addition & 1 deletion mock/contracts/asyncChildSC.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TransferToAsyncParentOnCallbackChildMock(instanceMock *mock.InstanceMock, c
host := instanceMock.Host
instance := mock.GetMockInstance(host)

host.Metering().UseGas(testConfig.GasUsedByChild)
_ = host.Metering().UseGasBounded(testConfig.GasUsedByChild)

runtime := host.Runtime()
output := host.Output()
Expand Down
4 changes: 2 additions & 2 deletions mock/contracts/directSimpleSC.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func ExecOnDestCtxSingleCallParentMock(instanceMock *mock.InstanceMock, config i
testConfig := config.(*test.TestConfig)
host := instanceMock.Host
instance := mock.GetMockInstance(host)
host.Metering().UseGas(testConfig.GasUsedByParent)
_ = host.Metering().UseGasBounded(testConfig.GasUsedByParent)

arguments := host.Runtime().Arguments()
if len(arguments) < 2 {
Expand Down Expand Up @@ -287,7 +287,7 @@ func esdtTransferToParentMock(instanceMock *mock.InstanceMock, config interface{
testConfig := config.(*test.TestConfig)
host := instanceMock.Host
instance := mock.GetMockInstance(host)
host.Metering().UseGas(testConfig.GasUsedByChild)
_ = host.Metering().UseGasBounded(testConfig.GasUsedByChild)

switch behavior {
case esdtOnCallbackSuccess:
Expand Down
2 changes: 1 addition & 1 deletion mock/contracts/gasMismatchParent.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func GasMismatchAsyncCallParentMock(instanceMock *mock.InstanceMock, _ interface
valueHandle := managedTypes.NewBigIntFromInt64(0)
functionHandle := managedTypes.NewManagedBufferFromBytes([]byte("gasMismatchChild"))
argumentsHandle := managedTypes.NewManagedBuffer()
managedTypes.WriteManagedVecOfManagedBuffers([][]byte{}, argumentsHandle)
_ = managedTypes.WriteManagedVecOfManagedBuffers([][]byte{}, argumentsHandle)

vmhooks.ManagedAsyncCallWithHost(
host,
Expand Down
4 changes: 2 additions & 2 deletions mock/contracts/transferAndExecuteSC.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TransferAndExecute(instanceMock *mock.InstanceMock, config interface{}) {
host := instanceMock.Host
instance := mock.GetMockInstance(host)

host.Metering().UseGas(testConfig.GasUsedByParent)
_ = host.Metering().UseGasBounded(testConfig.GasUsedByParent)

arguments := host.Runtime().Arguments()
noOfTransfers := int(big.NewInt(0).SetBytes(arguments[0]).Int64())
Expand All @@ -50,7 +50,7 @@ func TransferEGLDToParent(instanceMock *mock.InstanceMock, config interface{}) {
host := instanceMock.Host
instance := mock.GetMockInstance(host)

host.Metering().UseGas(testConfig.GasUsedByChild)
_ = host.Metering().UseGasBounded(testConfig.GasUsedByChild)

vmhooks.TransferValueExecuteWithTypedArgs(host,
test.ParentAddress,
Expand Down
Loading

0 comments on commit c9deb92

Please sign in to comment.