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

Managed Buffer <-> small int conversions VM hooks #852

Merged
merged 9 commits into from
Jul 26, 2024
4 changes: 4 additions & 0 deletions config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@
MBufferToBigIntSigned = 10
MBufferFromBigIntUnsigned = 10
MBufferFromBigIntSigned = 10
MBufferToSmallIntUnsigned = 10
MBufferToSmallIntSigned = 10
MBufferFromSmallIntUnsigned = 10
MBufferFromSmallIntSigned = 10
MBufferToBigFloat = 10
MBufferFromBigFloat = 10
MBufferStorageStore = 10
Expand Down
46 changes: 25 additions & 21 deletions config/gasCost.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type BaseOpsAPICost struct {
DeleteFromReturnData uint64
GetCodeMetadata uint64
IsBuiltinFunction uint64
IsReservedFunctionName uint64
IsReservedFunctionName uint64
}

// DynamicStorageLoadCostCoefficients holds the signed coefficients of the func that will compute the gas cost
Expand Down Expand Up @@ -198,26 +198,30 @@ type CryptoAPICost struct {

// ManagedBufferAPICost defines the managed buffer operations gas cost config structure
type ManagedBufferAPICost struct {
MBufferNew uint64
MBufferNewFromBytes uint64
MBufferGetLength uint64
MBufferGetBytes uint64
MBufferGetByteSlice uint64
MBufferCopyByteSlice uint64
MBufferSetBytes uint64
MBufferAppend uint64
MBufferAppendBytes uint64
MBufferToBigIntUnsigned uint64
MBufferToBigIntSigned uint64
MBufferFromBigIntUnsigned uint64
MBufferFromBigIntSigned uint64
MBufferToBigFloat uint64
MBufferFromBigFloat uint64
MBufferStorageStore uint64
MBufferStorageLoad uint64
MBufferGetArgument uint64
MBufferFinish uint64
MBufferSetRandom uint64
MBufferNew uint64
MBufferNewFromBytes uint64
MBufferGetLength uint64
MBufferGetBytes uint64
MBufferGetByteSlice uint64
MBufferCopyByteSlice uint64
MBufferSetBytes uint64
MBufferAppend uint64
MBufferAppendBytes uint64
MBufferToBigIntUnsigned uint64
MBufferToBigIntSigned uint64
MBufferFromBigIntUnsigned uint64
MBufferFromBigIntSigned uint64
MBufferToSmallIntUnsigned uint64
MBufferToSmallIntSigned uint64
MBufferFromSmallIntUnsigned uint64
MBufferFromSmallIntSigned uint64
MBufferToBigFloat uint64
MBufferFromBigFloat uint64
MBufferStorageStore uint64
MBufferStorageLoad uint64
MBufferGetArgument uint64
MBufferFinish uint64
MBufferSetRandom uint64
}

// ManagedMapAPICost defines the managed map operations gas cost config structure
Expand Down
4 changes: 4 additions & 0 deletions config/gasSchedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ func FillGasMapManagedBufferAPICosts(value uint64) map[string]uint64 {
gasMap["MBufferAppend"] = value
gasMap["MBufferAppendBytes"] = value
gasMap["MBufferToBigIntUnsigned"] = value
gasMap["MBufferToSmallIntUnsigned"] = value
gasMap["MBufferToSmallIntSigned"] = value
gasMap["MBufferFromSmallIntUnsigned"] = value
gasMap["MBufferFromSmallIntSigned"] = value
gasMap["MBufferToBigIntSigned"] = value
gasMap["MBufferFromBigIntUnsigned"] = value
gasMap["MBufferFromBigIntSigned"] = value
Expand Down
4 changes: 4 additions & 0 deletions executor/vmHooks.go

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

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

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

4 changes: 4 additions & 0 deletions mock/context/executorMockFunc.go

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

14 changes: 11 additions & 3 deletions scenario/gasSchedules/gasScheduleEmbedGenerated.go

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

4 changes: 4 additions & 0 deletions scenario/gasSchedules/gasScheduleV3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@
MBufferToBigIntSigned = 10000
MBufferFromBigIntUnsigned = 4000
MBufferFromBigIntSigned = 10000
MBufferToSmallIntUnsigned = 4000
MBufferToSmallIntSigned = 10000
MBufferFromSmallIntUnsigned = 4000
MBufferFromSmallIntSigned = 10000
MBufferToBigFloat = 2000
MBufferFromBigFloat = 2000
MBufferStorageStore = 75000
Expand Down
4 changes: 4 additions & 0 deletions scenario/gasSchedules/gasScheduleV4.toml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@
MBufferToBigIntSigned = 5000
MBufferFromBigIntUnsigned = 2000
MBufferFromBigIntSigned = 5000
MBufferToSmallIntUnsigned = 2000
MBufferToSmallIntSigned = 5000
MBufferFromSmallIntUnsigned = 2000
MBufferFromSmallIntSigned = 5000
MBufferToBigFloat = 2000
MBufferFromBigFloat = 2000
MBufferStorageStore = 75000
Expand Down
Loading
Loading