Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master rc1.7.next1 20 08 2024 #869

Merged
merged 29 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5b30d71
refactoring gasUsage
sasurobert Aug 8, 2024
b088682
refactoring gasUsage
sasurobert Aug 8, 2024
1434970
refactoring gasUsage
sasurobert Aug 8, 2024
e0948dd
refactoring gasUsage
sasurobert Aug 8, 2024
085968e
refactoring gasUsage
sasurobert Aug 8, 2024
e661aca
fixes after refactor
sasurobert Aug 8, 2024
12aee59
fixes after refactor
sasurobert Aug 8, 2024
a5630ad
fixes after refactor
sasurobert Aug 8, 2024
6e8dd5e
fixes after refactor
sasurobert Aug 8, 2024
f8c5044
fixing tests
sasurobert Aug 8, 2024
13d98fc
fixing code after refactor
sasurobert Aug 8, 2024
2beb764
fixes after review
sasurobert Aug 8, 2024
c196977
set use gas on context even in case of error.
sasurobert Aug 8, 2024
1dc7505
fixes after review and fixes after tests
sasurobert Aug 12, 2024
5957d55
adding new flag
sasurobert Aug 12, 2024
adc3bd3
backward compatibility
sasurobert Aug 13, 2024
901dedb
debugging
sasurobert Aug 13, 2024
31c6a6a
debugging and fix
sasurobert Aug 13, 2024
6e516e2
debugging and fix
sasurobert Aug 14, 2024
6b440d4
more backward compatibility
sasurobert Aug 14, 2024
d8547b7
debug
sasurobert Aug 14, 2024
a06f25e
delete debug
sasurobert Aug 14, 2024
f5c5080
fix and debug
sasurobert Aug 14, 2024
1ccc655
delete debug line
sasurobert Aug 15, 2024
fe09132
Merge commit from fork
iulianpascalau Aug 19, 2024
c9deb92
Merge branch 'master' into merge-master-rc1.7.next1-20-08-2024
sasurobert Aug 20, 2024
50984af
fixing after merge
sasurobert Aug 20, 2024
7527911
fixing after merge
sasurobert Aug 20, 2024
d0ef01a
Merge branch 'rc/v1.7.next1' into merge-master-rc1.7.next1-20-08-2024
sasurobert Aug 21, 2024
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
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
Loading