Skip to content

Commit

Permalink
feat(logic): change type of limit params as *Uint allowing nil value
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeneux committed Jan 4, 2023
1 parent c6b66b3 commit a8f5a60
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 85 deletions.
21 changes: 18 additions & 3 deletions proto/logic/v1beta/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,28 @@ message Limits {
// max_gas specifies the maximum amount of computing power, measured in "gas," that is allowed to be consumed when
// executing a request by the interpreter. The interpreter calculates the gas consumption based on the number and type
// of operations that are executed, as well as, in some cases, the complexity of the processed data.
uint64 max_gas = 1 [(gogoproto.moretags) = "yaml:\"max_gas\",omitempty"];
// nil value remove max gas limitation.
string max_gas = 1 [
(gogoproto.moretags) = "yaml:\"max_gas\",omitempty",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint",
(gogoproto.nullable) = true
];

// max_size specifies the maximum size, in bytes, that is accepted for a program.
uint32 max_size = 3 [(gogoproto.moretags) = "yaml:\"max_size\""];
// nil value remove size limitation.
string max_size = 3 [
(gogoproto.moretags) = "yaml:\"max_size\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint",
(gogoproto.nullable) = true
];

// max_result_count specifies the maximum number of results that can be requested for a query.
uint32 max_result_count = 2 [(gogoproto.moretags) = "yaml:\"max_result_count\""];
// nil value remove max result count limitation.
string max_result_count = 2 [
(gogoproto.moretags) = "yaml:\"max_result_count\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint",
(gogoproto.nullable) = true
];
}

// Interpreter defines the various parameters for the interpreter.
Expand Down
11 changes: 6 additions & 5 deletions x/logic/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package types
import (
"fmt"

"cosmossdk.io/math"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)

Expand All @@ -17,9 +18,9 @@ var (
var (
DefaultRegisteredPredicates = make([]string, 0)
DefaultBootstrap = ""
DefaultMaxGas = uint64(100)
DefaultMaxSize = uint32(5000)
DefaultMaxResultCount = uint32(1)
DefaultMaxGas = math.NewUint(uint64(100))
DefaultMaxSize = math.NewUint(uint64(5000))
DefaultMaxResultCount = math.NewUint(uint64(1))
)

// ParamKeyTable the param key table for launch module.
Expand Down Expand Up @@ -90,7 +91,7 @@ func validateInterpreter(i interface{}) error {
}

// NewLimits creates a new Limits object.
func NewLimits(maxGas uint64, maxSize, maxResultCount uint32) Limits {
func NewLimits(maxGas, maxSize, maxResultCount *math.Uint) Limits {
return Limits{
MaxGas: maxGas,
MaxSize: maxSize,
Expand All @@ -100,7 +101,7 @@ func NewLimits(maxGas uint64, maxSize, maxResultCount uint32) Limits {

// DefaultLimits return a Limits object with default params.
func DefaultLimits() Limits {
return NewLimits(DefaultMaxGas, DefaultMaxSize, DefaultMaxResultCount)
return NewLimits(&DefaultMaxGas, &DefaultMaxSize, &DefaultMaxResultCount)
}

func validateLimits(i interface{}) error {
Expand Down
214 changes: 137 additions & 77 deletions x/logic/types/params.pb.go

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

0 comments on commit a8f5a60

Please sign in to comment.