From db18c9a38d80c4e882f410fafca876679a8cffaa Mon Sep 17 00:00:00 2001 From: ccamel Date: Tue, 22 Oct 2024 09:57:59 +0200 Subject: [PATCH 1/7] refactor(logic)!: change Limits and GasPolicy properties to use uint64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The properties `max_size`, `max_result_count`, `max_user_output_size`, and `max_variables` in the `Limits` message, the properties `weighting_factor`, `default_predicate_cost` in the `GasPolicy` message, and `cost` in the `PredicateCost` message now use _uint64_ instead of `cosmossdk.io/math.Uint`. Similarly, the `limit` property in the `QueryServiceAskRequest` message has been updated to use _uint64_. The properties `weighting_factor`, `default_predicate_cost` and `cost` in the `GasPolicy` message now use _uint64_ instead of Additionally, querying with a _limit_ higher than _MaxResultCount_ no longer results in an error. This ensures that clients still receive results while automatically adhering to the API’s limits, providing a smooth and efficient user experience. --- docs/predicate/bech32_address_2.md | 14 +- docs/predicate/block_height_1.md | 4 +- docs/predicate/block_time_1.md | 4 +- docs/predicate/consult_1.md | 6 +- docs/predicate/current_output_1.md | 16 +- docs/predicate/open_3.md | 2 +- docs/predicate/open_4.md | 14 +- .../logic/{v1beta2 => v1beta3}/genesis.proto | 4 +- proto/logic/{v1beta2 => v1beta3}/params.proto | 57 +- proto/logic/{v1beta2 => v1beta3}/query.proto | 12 +- proto/logic/{v1beta2 => v1beta3}/tx.proto | 4 +- proto/logic/{v1beta2 => v1beta3}/types.proto | 2 +- x/logic/client/cli/query_ask.go | 5 +- x/logic/interpreter/interpreter.go | 11 +- .../keeper/features/bech32_address_2.feature | 34 +- .../keeper/features/block_height_1.feature | 4 +- x/logic/keeper/features/block_time_1.feature | 4 +- x/logic/keeper/features/consult_1.feature | 6 +- .../keeper/features/current_output_1.feature | 18 +- x/logic/keeper/features/open_3.feature | 2 +- x/logic/keeper/features/open_4.feature | 22 +- x/logic/keeper/features_test.go | 8 +- x/logic/keeper/grpc_query_ask.go | 19 +- x/logic/keeper/grpc_query_ask_test.go | 85 ++- x/logic/keeper/grpc_query_params_test.go | 9 +- x/logic/keeper/interpreter.go | 30 +- x/logic/predicate/bank_test.go | 2 +- x/logic/types/genesis.pb.go | 14 +- x/logic/types/params.go | 33 +- x/logic/types/params.pb.go | 496 +++++++----------- x/logic/types/params_test.go | 10 +- x/logic/types/query.pb.go | 160 +++--- x/logic/types/query.pb.gw.go | 2 +- x/logic/types/tx.pb.go | 26 +- x/logic/types/types.pb.go | 44 +- x/logic/util/prolog.go | 19 +- x/logic/wasm/types.go | 8 +- 37 files changed, 491 insertions(+), 719 deletions(-) rename proto/logic/{v1beta2 => v1beta3}/genesis.proto (83%) rename proto/logic/{v1beta2 => v1beta3}/params.proto (78%) rename proto/logic/{v1beta2 => v1beta3}/query.proto (91%) rename proto/logic/{v1beta2 => v1beta3}/tx.proto (95%) rename proto/logic/{v1beta2 => v1beta3}/types.proto (98%) diff --git a/docs/predicate/bech32_address_2.md b/docs/predicate/bech32_address_2.md index 1b3692412..23f93e8bf 100644 --- a/docs/predicate/bech32_address_2.md +++ b/docs/predicate/bech32_address_2.md @@ -43,7 +43,7 @@ bech32_address(Address, 'axone15wn30a9z4uc692s0kkx5fp5d4qfr3ac77gvjg4'). ``` yaml height: 42 -gas_used: 4140 +gas_used: 3612 answer: has_more: false variables: ["Address"] @@ -72,7 +72,7 @@ bech32_address(-(Hrp, Address), 'axone15wn30a9z4uc692s0kkx5fp5d4qfr3ac77gvjg4'). ``` yaml height: 42 -gas_used: 4140 +gas_used: 3612 answer: has_more: false variables: ["Hrp", "Address"] @@ -102,7 +102,7 @@ bech32_address(-(axone, Address), 'axone15wn30a9z4uc692s0kkx5fp5d4qfr3ac77gvjg4' ``` yaml height: 42 -gas_used: 4140 +gas_used: 3612 answer: has_more: false variables: ["Address"] @@ -129,7 +129,7 @@ bech32_address(-('axone', [163,167,23,244,162,175,49,162,170,15,181,141,68,134,1 ``` yaml height: 42 -gas_used: 4140 +gas_used: 3612 answer: has_more: false variables: ["Bech32"] @@ -162,7 +162,7 @@ axone_addr('axone1p8u47en82gmzfm259y6z93r9qe63l25d858vqu'). ``` yaml height: 42 -gas_used: 4141 +gas_used: 3613 answer: has_more: false results: @@ -188,7 +188,7 @@ bech32_address(Address, axoneincorrect). ``` yaml height: 42 -gas_used: 4140 +gas_used: 3612 answer: has_more: false variables: ["Address"] @@ -215,7 +215,7 @@ bech32_address(-('axone', X), foo(bar)). ``` yaml height: 42 -gas_used: 4140 +gas_used: 3612 answer: has_more: false variables: ["X"] diff --git a/docs/predicate/block_height_1.md b/docs/predicate/block_height_1.md index fbc397cd6..f82eaf4c3 100644 --- a/docs/predicate/block_height_1.md +++ b/docs/predicate/block_height_1.md @@ -44,7 +44,7 @@ block_height(Height). ``` yaml height: 100 -gas_used: 4140 +gas_used: 3612 answer: has_more: false variables: ["Height"] @@ -79,7 +79,7 @@ Height > 100. ``` yaml height: 101 -gas_used: 4141 +gas_used: 3613 answer: has_more: false variables: ["Height"] diff --git a/docs/predicate/block_time_1.md b/docs/predicate/block_time_1.md index 9f249bb31..967905056 100644 --- a/docs/predicate/block_time_1.md +++ b/docs/predicate/block_time_1.md @@ -44,7 +44,7 @@ block_time(Time). ``` yaml height: 42 -gas_used: 4140 +gas_used: 3612 answer: has_more: false variables: ["Time"] @@ -80,7 +80,7 @@ Time > 1709550216. ``` yaml height: 42 -gas_used: 4141 +gas_used: 3613 answer: has_more: false variables: ["Time"] diff --git a/docs/predicate/consult_1.md b/docs/predicate/consult_1.md index aa468d4c0..02b8bb355 100644 --- a/docs/predicate/consult_1.md +++ b/docs/predicate/consult_1.md @@ -65,7 +65,7 @@ hello(Who). ``` yaml height: 42 -gas_used: 4143 +gas_used: 3615 answer: has_more: false variables: ["Who"] @@ -129,7 +129,7 @@ response: | ``` yaml height: 42 -gas_used: 4142 +gas_used: 3614 answer: has_more: false variables: ["X"] @@ -194,7 +194,7 @@ source_file(File). ``` yaml height: 42 -gas_used: 4141 +gas_used: 3613 answer: has_more: false variables: ["File"] diff --git a/docs/predicate/current_output_1.md b/docs/predicate/current_output_1.md index d191562ba..908dc4369 100644 --- a/docs/predicate/current_output_1.md +++ b/docs/predicate/current_output_1.md @@ -37,7 +37,7 @@ Here are the steps of the scenario: ``` json { "limits": { - "max_user_output_size": "5" + "max_user_output_size": 5 } } ``` @@ -61,7 +61,7 @@ write_char_to_user_output(x). ``` yaml height: 42 -gas_used: 4241 +gas_used: 3680 answer: has_more: false variables: @@ -83,7 +83,7 @@ Here are the steps of the scenario: ``` json { "limits": { - "max_user_output_size": "15" + "max_user_output_size": 15 } } ``` @@ -108,7 +108,7 @@ log_message('Hello world!'). ``` yaml height: 42 -gas_used: 4276 +gas_used: 3682 answer: has_more: false variables: @@ -131,7 +131,7 @@ Here are the steps of the scenario: ``` json { "limits": { - "max_user_output_size": "5" + "max_user_output_size": 5 } } ``` @@ -155,7 +155,7 @@ log_message('Hello world!'). ``` yaml height: 42 -gas_used: 4242 +gas_used: 3681 answer: has_more: false variables: @@ -179,7 +179,7 @@ Here are the steps of the scenario: ``` json { "limits": { - "max_user_output_size": "5" + "max_user_output_size": 5 } } ``` @@ -205,7 +205,7 @@ log_message("Hello 🧙!"). ``` yaml height: 42 -gas_used: 4263 +gas_used: 3702 answer: has_more: false variables: diff --git a/docs/predicate/open_3.md b/docs/predicate/open_3.md index 2ab3cb54a..251ebf5ad 100644 --- a/docs/predicate/open_3.md +++ b/docs/predicate/open_3.md @@ -62,7 +62,7 @@ open( ``` yaml height: 42 -gas_used: 4141 +gas_used: 3613 answer: has_more: false variables: diff --git a/docs/predicate/open_4.md b/docs/predicate/open_4.md index e18a4616b..79a2e23c0 100644 --- a/docs/predicate/open_4.md +++ b/docs/predicate/open_4.md @@ -100,7 +100,7 @@ open(URI, read, _, []). ``` yaml height: 42 -gas_used: 4153 +gas_used: 3625 answer: has_more: false variables: ["URI"] @@ -152,7 +152,7 @@ read_resource('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08x ``` yaml height: 42 -gas_used: 4144 +gas_used: 3616 answer: has_more: false variables: ["Chars"] @@ -202,7 +202,7 @@ read_resource('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08x ``` yaml height: 42 -gas_used: 4144 +gas_used: 3616 answer: has_more: false variables: ["Chars"] @@ -229,7 +229,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t ``` yaml height: 42 -gas_used: 4140 +gas_used: 3612 answer: has_more: false variables: ["Stream"] @@ -255,7 +255,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t ``` yaml height: 42 -gas_used: 4140 +gas_used: 3612 answer: has_more: false variables: ["Stream"] @@ -281,7 +281,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t ``` yaml height: 42 -gas_used: 4140 +gas_used: 3612 answer: has_more: false variables: ["Stream"] @@ -306,7 +306,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t ``` yaml height: 42 -gas_used: 4140 +gas_used: 3612 answer: has_more: false variables: ["Stream"] diff --git a/proto/logic/v1beta2/genesis.proto b/proto/logic/v1beta3/genesis.proto similarity index 83% rename from proto/logic/v1beta2/genesis.proto rename to proto/logic/v1beta3/genesis.proto index 3dbcf5bd9..bd2fd548d 100644 --- a/proto/logic/v1beta2/genesis.proto +++ b/proto/logic/v1beta3/genesis.proto @@ -1,9 +1,9 @@ syntax = "proto3"; -package logic.v1beta2; +package logic.v1beta3; import "gogoproto/gogo.proto"; -import "logic/v1beta2/params.proto"; +import "logic/v1beta3/params.proto"; option go_package = "github.com/axone-protocol/axoned/x/logic/types"; diff --git a/proto/logic/v1beta2/params.proto b/proto/logic/v1beta3/params.proto similarity index 78% rename from proto/logic/v1beta2/params.proto rename to proto/logic/v1beta3/params.proto index 99dc29c95..b75957996 100644 --- a/proto/logic/v1beta2/params.proto +++ b/proto/logic/v1beta3/params.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package logic.v1beta2; +package logic.v1beta3; import "gogoproto/gogo.proto"; @@ -36,37 +36,21 @@ message Limits { option (gogoproto.goproto_stringer) = true; // max_size specifies the maximum size, in bytes, that is accepted for a program. - // nil value or 0 value remove size limitation. - string max_size = 3 [ - (gogoproto.moretags) = "yaml:\"max_size\"", - (gogoproto.customtype) = "cosmossdk.io/math.Uint", - (gogoproto.nullable) = true - ]; + // A value of 0 means that there is no limit on the size of the program. + uint64 max_size = 3 [(gogoproto.moretags) = "yaml:\"max_size\""]; // max_result_count specifies the maximum number of results that can be requested for a query. - // nil value or 0 value remove max result count limitation. - string max_result_count = 2 [ - (gogoproto.moretags) = "yaml:\"max_result_count\"", - (gogoproto.customtype) = "cosmossdk.io/math.Uint", - (gogoproto.nullable) = true - ]; + // A value of 0 means that there is no limit on the number of results. + uint64 max_result_count = 2 [(gogoproto.moretags) = "yaml:\"max_result_count\""]; // max_user_output_size specifies the maximum number of bytes to keep in the user output. If the user output exceeds // this size, the interpreter will overwrite the oldest bytes with the new ones to keep the size constant. - // nil value or 0 value means that no user output is used at all. - string max_user_output_size = 4 [ - (gogoproto.moretags) = "yaml:\"max_user_output_size\"", - (gogoproto.customtype) = "cosmossdk.io/math.Uint", - (gogoproto.nullable) = true - ]; + // A value of 0 means the user output is disabled. + uint64 max_user_output_size = 4 [(gogoproto.moretags) = "yaml:\"max_user_output_size\""]; // max_variables specifies the maximum number of variables that can be create by the interpreter. - // nil value or 0 value means that no limit is set. - string max_variables = 5 [ - (gogoproto.moretags) = "yaml:\"max_variables\"", - (gogoproto.customtype) = "cosmossdk.io/math.Uint", - (gogoproto.nullable) = true - ]; + // A value of 0 means that there is no limit on the number of variables. + uint64 max_variables = 5 [(gogoproto.moretags) = "yaml:\"max_variables\""]; } // Filter defines the parameters for filtering the set of strings which can designate anything. @@ -132,20 +116,12 @@ message Interpreter { message GasPolicy { // WeightingFactor is the factor that is applied to the unit cost of each predicate // to yield the gas value. - // If not provided or set to 0, the value is set to 1. - string weighting_factor = 1 [ - (gogoproto.moretags) = "yaml:\"weighting_factor\"", - (gogoproto.customtype) = "cosmossdk.io/math.Uint", - (gogoproto.nullable) = true - ]; + // If set to 0, the value considered is 1. + uint64 weighting_factor = 1 [ (gogoproto.moretags) = "yaml:\"weighting_factor\"" ]; // DefaultPredicateCost is the default unit cost of a predicate when not specified in the PredicateCosts list. - // If not provided or set to 0, the value is set to 1. - string default_predicate_cost = 2 [ - (gogoproto.moretags) = "yaml:\"default_predicate_cost\"", - (gogoproto.customtype) = "cosmossdk.io/math.Uint", - (gogoproto.nullable) = true - ]; + // If set to 0, the value considered is 1. + uint64 default_predicate_cost = 2 [ (gogoproto.moretags) = "yaml:\"default_predicate_cost\"" ]; // PredicateCosts is the list of predicates and their associated unit costs. repeated PredicateCost predicate_costs = 3 [ @@ -164,9 +140,6 @@ message PredicateCost { ]; // Cost is the unit cost of the predicate. - string cost = 2 [ - (gogoproto.moretags) = "yaml:\"cost\",omitempty", - (gogoproto.customtype) = "cosmossdk.io/math.Uint", - (gogoproto.nullable) = true - ]; + // If set to 0, the value considered is 1. + uint64 cost = 2 [ (gogoproto.moretags) = "yaml:\"cost\"" ]; } diff --git a/proto/logic/v1beta2/query.proto b/proto/logic/v1beta3/query.proto similarity index 91% rename from proto/logic/v1beta2/query.proto rename to proto/logic/v1beta3/query.proto index 2a97e7b76..9818de1e6 100644 --- a/proto/logic/v1beta2/query.proto +++ b/proto/logic/v1beta3/query.proto @@ -1,12 +1,12 @@ syntax = "proto3"; -package logic.v1beta2; +package logic.v1beta3; import "cosmos/query/v1/query.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "logic/v1beta2/params.proto"; -import "logic/v1beta2/types.proto"; +import "logic/v1beta3/params.proto"; +import "logic/v1beta3/types.proto"; option go_package = "github.com/axone-protocol/axoned/x/logic/types"; @@ -50,11 +50,7 @@ message QueryServiceAskRequest { // limit specifies the maximum number of solutions to be returned. This field is governed by // max_result_count, which defines the upper limit of results that may be requested per query. // If this field is not explicitly set, a default value of 1 is applied. - string limit = 3 [ - (gogoproto.moretags) = "yaml:\"limit\",omitempty", - (gogoproto.customtype) = "cosmossdk.io/math.Uint", - (gogoproto.nullable) = true - ]; + uint64 limit = 3 [(gogoproto.moretags) = "yaml:\"limit\",omitempty"]; } // QueryServiceAskResponse is response type for the QueryService/Ask RPC method. diff --git a/proto/logic/v1beta2/tx.proto b/proto/logic/v1beta3/tx.proto similarity index 95% rename from proto/logic/v1beta2/tx.proto rename to proto/logic/v1beta3/tx.proto index 83095e823..c7b157ebe 100644 --- a/proto/logic/v1beta2/tx.proto +++ b/proto/logic/v1beta3/tx.proto @@ -1,11 +1,11 @@ syntax = "proto3"; -package logic.v1beta2; +package logic.v1beta3; import "cosmos/msg/v1/msg.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; -import "logic/v1beta2/params.proto"; +import "logic/v1beta3/params.proto"; option go_package = "github.com/axone-protocol/axoned/x/logic/types"; diff --git a/proto/logic/v1beta2/types.proto b/proto/logic/v1beta3/types.proto similarity index 98% rename from proto/logic/v1beta2/types.proto rename to proto/logic/v1beta3/types.proto index 605c03245..09f5a6fb9 100644 --- a/proto/logic/v1beta2/types.proto +++ b/proto/logic/v1beta3/types.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package logic.v1beta2; +package logic.v1beta3; import "gogoproto/gogo.proto"; diff --git a/x/logic/client/cli/query_ask.go b/x/logic/client/cli/query_ask.go index a9fbc7191..9826e95c3 100644 --- a/x/logic/client/cli/query_ask.go +++ b/x/logic/client/cli/query_ask.go @@ -6,8 +6,6 @@ import ( "github.com/spf13/cobra" - sdkmath "cosmossdk.io/math" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/version" @@ -38,11 +36,10 @@ func CmdQueryAsk() *cobra.Command { query := args[0] queryClient := types.NewQueryServiceClient(clientCtx) - limit := sdkmath.NewUint(limit) res, err := queryClient.Ask(context.Background(), &types.QueryServiceAskRequest{ Program: program, Query: query, - Limit: &limit, + Limit: limit, }) if err != nil { return diff --git a/x/logic/interpreter/interpreter.go b/x/logic/interpreter/interpreter.go index 169760f29..d95437ae6 100644 --- a/x/logic/interpreter/interpreter.go +++ b/x/logic/interpreter/interpreter.go @@ -8,8 +8,6 @@ import ( "github.com/axone-protocol/prolog" "github.com/axone-protocol/prolog/engine" - - "cosmossdk.io/math" ) // Option is a function that configures an Interpreter. @@ -69,13 +67,10 @@ func WithFS(fs fs.FS) Option { } // WithMaxVariables configures the interpreter to use the specified maximum number of variables. -func WithMaxVariables(maxVariables *math.Uint) Option { +func WithMaxVariables(maxVariables uint64) Option { return func(i *prolog.Interpreter) error { - if maxVariables != nil { - i.SetMaxVariables(maxVariables.Uint64()) - } else { - i.SetMaxVariables(0) - } + i.SetMaxVariables(maxVariables) + return nil } } diff --git a/x/logic/keeper/features/bech32_address_2.feature b/x/logic/keeper/features/bech32_address_2.feature index ee31f978b..d3d657ace 100644 --- a/x/logic/keeper/features/bech32_address_2.feature +++ b/x/logic/keeper/features/bech32_address_2.feature @@ -16,7 +16,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Address"] @@ -39,7 +39,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Hrp", "Address"] @@ -63,7 +63,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Address"] @@ -84,7 +84,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Bech32"] @@ -109,7 +109,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4141 + gas_used: 3976 answer: has_more: false results: @@ -130,7 +130,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4141 + gas_used: 3976 answer: has_more: false results: @@ -146,7 +146,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false results: @@ -163,7 +163,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Hrp"] @@ -186,7 +186,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Address"] @@ -207,7 +207,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["X"] @@ -227,7 +227,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Bech32"] @@ -247,7 +247,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Bech32"] @@ -267,7 +267,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Bech32"] @@ -287,7 +287,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Bech32"] @@ -307,7 +307,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Bech32"] @@ -327,7 +327,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Address", "Bech32"] @@ -347,7 +347,7 @@ Feature: bech32_address/2 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Hrp", "Bech32"] diff --git a/x/logic/keeper/features/block_height_1.feature b/x/logic/keeper/features/block_height_1.feature index 562c2ff4a..c179cc329 100644 --- a/x/logic/keeper/features/block_height_1.feature +++ b/x/logic/keeper/features/block_height_1.feature @@ -16,7 +16,7 @@ Feature: block_height/1 Then the answer we get is: """ yaml height: 100 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Height"] @@ -43,7 +43,7 @@ Feature: block_height/1 Then the answer we get is: """ yaml height: 101 - gas_used: 4141 + gas_used: 3976 answer: has_more: false variables: ["Height"] diff --git a/x/logic/keeper/features/block_time_1.feature b/x/logic/keeper/features/block_time_1.feature index fdf139aec..dab2febfe 100644 --- a/x/logic/keeper/features/block_time_1.feature +++ b/x/logic/keeper/features/block_time_1.feature @@ -16,7 +16,7 @@ Feature: block_time/1 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Time"] @@ -44,7 +44,7 @@ Feature: block_time/1 Then the answer we get is: """ yaml height: 42 - gas_used: 4141 + gas_used: 3976 answer: has_more: false variables: ["Time"] diff --git a/x/logic/keeper/features/consult_1.feature b/x/logic/keeper/features/consult_1.feature index 801d38b68..9914d5cd5 100644 --- a/x/logic/keeper/features/consult_1.feature +++ b/x/logic/keeper/features/consult_1.feature @@ -34,7 +34,7 @@ Feature: consult/1 Then the answer we get is: """ yaml height: 42 - gas_used: 4143 + gas_used: 3978 answer: has_more: false variables: ["Who"] @@ -90,7 +90,7 @@ Feature: consult/1 Then the answer we get is: """ yaml height: 42 - gas_used: 4142 + gas_used: 3977 answer: has_more: false variables: ["X"] @@ -144,7 +144,7 @@ Feature: consult/1 Then the answer we get is: """ yaml height: 42 - gas_used: 4141 + gas_used: 3976 answer: has_more: false variables: ["File"] diff --git a/x/logic/keeper/features/current_output_1.feature b/x/logic/keeper/features/current_output_1.feature index 605862c15..a20ac9348 100644 --- a/x/logic/keeper/features/current_output_1.feature +++ b/x/logic/keeper/features/current_output_1.feature @@ -10,7 +10,7 @@ Feature: current_output/1 """ json { "limits": { - "max_user_output_size": "5" + "max_user_output_size": 5 } } """ @@ -28,7 +28,7 @@ Feature: current_output/1 Then the answer we get is: """ yaml height: 42 - gas_used: 4241 + gas_used: 4043 answer: has_more: false variables: @@ -47,7 +47,7 @@ Feature: current_output/1 """ json { "limits": { - "max_user_output_size": "15" + "max_user_output_size": 15 } } """ @@ -66,7 +66,7 @@ Feature: current_output/1 Then the answer we get is: """ yaml height: 42 - gas_used: 4276 + gas_used: 4045 answer: has_more: false variables: @@ -86,7 +86,7 @@ Feature: current_output/1 """ json { "limits": { - "max_user_output_size": "5" + "max_user_output_size": 5 } } """ @@ -104,7 +104,7 @@ Feature: current_output/1 Then the answer we get is: """ yaml height: 42 - gas_used: 4242 + gas_used: 4044 answer: has_more: false variables: @@ -125,7 +125,7 @@ Feature: current_output/1 """ json { "limits": { - "max_user_output_size": "5" + "max_user_output_size": 5 } } """ @@ -145,7 +145,7 @@ Feature: current_output/1 Then the answer we get is: """ yaml height: 42 - gas_used: 4263 + gas_used: 4065 answer: has_more: false variables: @@ -176,7 +176,7 @@ Feature: current_output/1 Then the answer we get is: """ yaml height: 42 - gas_used: 4721 + gas_used: 4556 answer: has_more: false variables: diff --git a/x/logic/keeper/features/open_3.feature b/x/logic/keeper/features/open_3.feature index 553e3c5ad..125e7f236 100644 --- a/x/logic/keeper/features/open_3.feature +++ b/x/logic/keeper/features/open_3.feature @@ -31,7 +31,7 @@ Feature: open/3 Then the answer we get is: """ yaml height: 42 - gas_used: 4141 + gas_used: 3976 answer: has_more: false variables: diff --git a/x/logic/keeper/features/open_4.feature b/x/logic/keeper/features/open_4.feature index 6dec237bf..21e42e174 100644 --- a/x/logic/keeper/features/open_4.feature +++ b/x/logic/keeper/features/open_4.feature @@ -43,7 +43,7 @@ Feature: open/4 Then the answer we get is: """ yaml height: 42 - gas_used: 4153 + gas_used: 3988 answer: has_more: false variables: ["URI"] @@ -86,7 +86,7 @@ Feature: open/4 Then the answer we get is: """ yaml height: 42 - gas_used: 4144 + gas_used: 3979 answer: has_more: false variables: ["Chars"] @@ -127,7 +127,7 @@ Feature: open/4 Then the answer we get is: """ yaml height: 42 - gas_used: 4144 + gas_used: 3979 answer: has_more: false variables: ["Chars"] @@ -149,7 +149,7 @@ Feature: open/4 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Stream"] @@ -170,7 +170,7 @@ Feature: open/4 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Stream"] @@ -191,7 +191,7 @@ Feature: open/4 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Stream"] @@ -212,7 +212,7 @@ Feature: open/4 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Stream"] @@ -232,7 +232,7 @@ Feature: open/4 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Stream"] @@ -251,7 +251,7 @@ Feature: open/4 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Stream"] @@ -270,7 +270,7 @@ Feature: open/4 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Resource", "Stream"] @@ -289,7 +289,7 @@ Feature: open/4 Then the answer we get is: """ yaml height: 42 - gas_used: 4140 + gas_used: 3975 answer: has_more: false variables: ["Mode", "Stream"] diff --git a/x/logic/keeper/features_test.go b/x/logic/keeper/features_test.go index aec6aa647..35cfb0126 100644 --- a/x/logic/keeper/features_test.go +++ b/x/logic/keeper/features_test.go @@ -21,7 +21,6 @@ import ( . "github.com/smartystreets/goconvey/convey" - sdkmath "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/baseapp" @@ -205,9 +204,7 @@ func whenTheQueryIsRun(ctx context.Context) error { func whenTheQueryIsRunLimitedToNSolutions(ctx context.Context, n int) error { request := testCaseFromContext(ctx).request - - limit := sdkmath.NewUint(uint64(n)) //nolint:gosec // disable G115 - request.Limit = &limit + request.Limit = uint64(n) //nolint:gosec // disable G115 testCaseFromContext(ctx).request = request @@ -319,8 +316,7 @@ func newQueryClient(ctx context.Context) (types.QueryServiceClient, error) { func logicKeeperParams() types.Params { params := types.DefaultParams() limits := params.Limits - maxResultCount := sdkmath.NewUint(10) - limits.MaxResultCount = &maxResultCount + limits.MaxResultCount = 10 params.Limits = limits return params } diff --git a/x/logic/keeper/grpc_query_ask.go b/x/logic/keeper/grpc_query_ask.go index 7c1e13e47..c9025897f 100644 --- a/x/logic/keeper/grpc_query_ask.go +++ b/x/logic/keeper/grpc_query_ask.go @@ -2,21 +2,16 @@ package keeper import ( goctx "context" - "math" errorsmod "cosmossdk.io/errors" - sdkmath "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/axone-protocol/axoned/v10/x/logic/meter" "github.com/axone-protocol/axoned/v10/x/logic/types" - "github.com/axone-protocol/axoned/v10/x/logic/util" ) -var defaultSolutionsLimit = sdkmath.OneUint() - func (k Keeper) Ask(ctx goctx.Context, req *types.QueryServiceAskRequest) (response *types.QueryServiceAskResponse, err error) { if req == nil { return nil, errorsmod.Wrap(types.InvalidArgument, "request is nil") @@ -47,20 +42,14 @@ func (k Keeper) Ask(ctx goctx.Context, req *types.QueryServiceAskRequest) (respo params, req.Program, req.Query, - util.DerefOrDefault(req.Limit, defaultSolutionsLimit)) + req.Limit) } func checkLimits(request *types.QueryServiceAskRequest, limits types.Limits) error { - size := sdkmath.NewUint(uint64(len(request.GetQuery()))) - maxSize := util.NonZeroOrDefaultUInt(limits.MaxSize, sdkmath.NewUint(math.MaxInt64)) - if size.GT(maxSize) { - return errorsmod.Wrapf(types.LimitExceeded, "query: %d > MaxSize: %d", size.Uint64(), maxSize.Uint64()) - } + size := uint64(len(request.GetQuery())) - resultCount := util.DerefOrDefault(request.Limit, defaultSolutionsLimit) - maxResultCount := util.NonZeroOrDefaultUInt(limits.MaxResultCount, sdkmath.NewUint(math.MaxInt64)) - if resultCount.GT(maxResultCount) { - return errorsmod.Wrapf(types.LimitExceeded, "query: %d > MaxResultCount: %d", resultCount.Uint64(), maxResultCount.Uint64()) + if limits.MaxSize != 0 && size > limits.MaxSize { + return errorsmod.Wrapf(types.LimitExceeded, "query: %d > MaxSize: %d", size, limits.MaxSize) } return nil diff --git a/x/logic/keeper/grpc_query_ask_test.go b/x/logic/keeper/grpc_query_ask_test.go index d90edfb78..e854e1c49 100644 --- a/x/logic/keeper/grpc_query_ask_test.go +++ b/x/logic/keeper/grpc_query_ask_test.go @@ -1,4 +1,3 @@ -//nolint:gocognit package keeper_test import ( @@ -11,7 +10,6 @@ import ( . "github.com/smartystreets/goconvey/convey" - sdkmath "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/baseapp" @@ -33,7 +31,7 @@ func TestGRPCAsk(t *testing.T) { cases := []struct { program string query string - limit int + limit uint64 maxResultCount uint64 maxSize uint64 predicateBlacklist []string @@ -117,7 +115,13 @@ func TestGRPCAsk(t *testing.T) { query: "father(bob, X).", limit: 2, maxResultCount: 1, - expectedError: "query: 2 > MaxResultCount: 1: limit exceeded", + expectedAnswer: &types.Answer{ + HasMore: true, + Variables: []string{"X"}, + Results: []types.Result{{Substitutions: []types.Substitution{{ + Variable: "X", Expression: "alice", + }}}}, + }, }, { program: "father(bob, alice). father(bob, john).", @@ -157,7 +161,7 @@ func TestGRPCAsk(t *testing.T) { predicateCosts: map[string]uint64{ "block_height/1": 10000, }, - expectedError: "out of gas: logic (11167/3000): limit exceeded", + expectedError: "out of gas: logic (11140/3000): limit exceeded", }, { program: "recursionOfDeath :- recursionOfDeath.", @@ -287,11 +291,11 @@ func TestGRPCAsk(t *testing.T) { }, { program: ` - foo(a1). - foo(a2). - foo(a3) :- throw(error(resource_error(foo))). - foo(a4). - `, + foo(a1). + foo(a2). + foo(a3) :- throw(error(resource_error(foo))). + foo(a4). + `, query: `foo(X).`, maxResultCount: 1, expectedAnswer: &types.Answer{ @@ -304,11 +308,11 @@ func TestGRPCAsk(t *testing.T) { }, { program: ` - foo(a1). - foo(a2). - foo(a3) :- throw(error(resource_error(foo))). - foo(a4). - `, + foo(a1). + foo(a2). + foo(a3) :- throw(error(resource_error(foo))). + foo(a4). + `, query: `foo(X).`, limit: 2, maxResultCount: 3, @@ -323,11 +327,11 @@ func TestGRPCAsk(t *testing.T) { }, { program: ` - foo(a1). - foo(a2). - foo(a3) :- throw(error(resource_error(foo))). - foo(a4). - `, + foo(a1). + foo(a2). + foo(a3) :- throw(error(resource_error(foo))). + foo(a4). + `, query: `foo(X).`, limit: 3, maxResultCount: 5, @@ -342,11 +346,11 @@ func TestGRPCAsk(t *testing.T) { }, { program: ` - foo(a1). - foo(a2). - foo(a3) :- throw(error(resource_error(foo))). - foo(a4). - `, + foo(a1). + foo(a2). + foo(a3) :- throw(error(resource_error(foo))). + foo(a4). + `, query: `foo(X).`, limit: 5, maxResultCount: 5, @@ -361,11 +365,11 @@ func TestGRPCAsk(t *testing.T) { }, { program: ` - foo(a1). - foo(a2). - foo(a3) :- throw(error(resource_error(foo))). - foo(a4). - `, + foo(a1). + foo(a2). + foo(a3) :- throw(error(resource_error(foo))). + foo(a4). + `, query: `foo(X).`, limit: 5, maxResultCount: 0, @@ -407,23 +411,21 @@ func TestGRPCAsk(t *testing.T) { func(_ gocontext.Context) fs.FS { return fsProvider }) - maxResultCount := sdkmath.NewUint(tc.maxResultCount) - maxSize := sdkmath.NewUint(tc.maxSize) + params := types.DefaultParams() - params.Limits.MaxResultCount = &maxResultCount - params.Limits.MaxSize = &maxSize - maxVariables := sdkmath.NewUint(tc.maxVariables) - params.Limits.MaxVariables = &maxVariables + params.Limits.MaxResultCount = tc.maxResultCount + params.Limits.MaxSize = tc.maxSize + params.Limits.MaxVariables = tc.maxVariables + if tc.predicateBlacklist != nil { params.Interpreter.PredicatesFilter.Blacklist = tc.predicateBlacklist } if tc.predicateCosts != nil { predicateCosts := make([]types.PredicateCost, 0, len(tc.predicateCosts)) for predicate, cost := range tc.predicateCosts { - cost := sdkmath.NewUint(cost) predicateCosts = append(predicateCosts, types.PredicateCost{ Predicate: predicate, - Cost: &cost, + Cost: cost, }) } params.GasPolicy.PredicateCosts = predicateCosts @@ -444,15 +446,10 @@ func TestGRPCAsk(t *testing.T) { queryClient := types.NewQueryServiceClient(queryHelper) - var limit *sdkmath.Uint - if tc.limit != 0 { - v := sdkmath.NewUint(uint64(tc.limit)) //nolint:gosec // disable G115 - limit = &v - } query := types.QueryServiceAskRequest{ Program: tc.program, Query: tc.query, - Limit: limit, + Limit: tc.limit, } Convey("when the grpc query ask is called", func() { diff --git a/x/logic/keeper/grpc_query_params_test.go b/x/logic/keeper/grpc_query_params_test.go index 7161b9025..f7a5cc682 100644 --- a/x/logic/keeper/grpc_query_params_test.go +++ b/x/logic/keeper/grpc_query_params_test.go @@ -10,7 +10,6 @@ import ( . "github.com/smartystreets/goconvey/convey" - "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/baseapp" @@ -40,10 +39,10 @@ func TestGRPCParams(t *testing.T) { types.WithVirtualFilesWhitelist([]string{"file2"}), ), types.NewLimits( - types.WithMaxSize(math.NewUint(2)), - types.WithMaxResultCount(math.NewUint(3)), - types.WithMaxUserOutputSize(math.NewUint(4)), - types.WithMaxVariables(math.NewUint(5)), + types.WithMaxSize(2), + types.WithMaxResultCount(3), + types.WithMaxUserOutputSize(4), + types.WithMaxVariables(5), ), ), }, diff --git a/x/logic/keeper/interpreter.go b/x/logic/keeper/interpreter.go index f186f6cc8..e94215493 100644 --- a/x/logic/keeper/interpreter.go +++ b/x/logic/keeper/interpreter.go @@ -12,7 +12,6 @@ import ( orderedmap "github.com/wk8/go-ordered-map/v2" errorsmod "cosmossdk.io/errors" - sdkmath "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -46,7 +45,7 @@ func (k Keeper) enhanceContext(ctx context.Context) context.Context { } func (k Keeper) execute( - ctx context.Context, params types.Params, program, query string, solutionsLimit sdkmath.Uint, + ctx context.Context, params types.Params, program, query string, solutionsLimit uint64, ) (*types.QueryServiceAskResponse, error) { ctx = k.enhanceContext(ctx) sdkCtx := sdk.UnwrapSDKContext(ctx) @@ -59,7 +58,7 @@ func (k Keeper) execute( return nil, errorsmod.Wrapf(types.InvalidArgument, "error compiling query: %v", err.Error()) } - answer, err := k.queryInterpreter(ctx, i, query, solutionsLimit) + answer, err := k.queryInterpreter(ctx, i, query, calculateSolutionLimit(solutionsLimit, params.GetLimits().MaxResultCount)) if err != nil { return nil, err } @@ -74,7 +73,7 @@ func (k Keeper) execute( // queryInterpreter executes the given query on the given interpreter and returns the answer. func (k Keeper) queryInterpreter( - ctx context.Context, i *prolog.Interpreter, query string, solutionsLimit sdkmath.Uint, + ctx context.Context, i *prolog.Interpreter, query string, solutionsLimit uint64, ) (*types.Answer, error) { return util.QueryInterpreter(ctx, i, query, solutionsLimit) } @@ -96,8 +95,8 @@ func (k Keeper) newInterpreter(ctx context.Context, params types.Params) (*prolo var userOutputBuffer writerStringer limits := params.GetLimits() - if limits.MaxUserOutputSize != nil && limits.MaxUserOutputSize.GT(sdkmath.ZeroUint()) { - userOutputBuffer = util.NewBoundedBufferMust(int(limits.MaxUserOutputSize.Uint64())) //nolint:gosec // disable G115 + if limits.MaxUserOutputSize > 0 { + userOutputBuffer = util.NewBoundedBufferMust(int(limits.MaxUserOutputSize)) //nolint:gosec // disable G115 } else { userOutputBuffer = new(strings.Builder) } @@ -160,7 +159,7 @@ func whitelistBlacklistHookFn(whitelist, blacklist []string) engine.HookFunc { // gasMeterHookFn returns a hook function that consumes gas based on the cost of the executed predicate. func gasMeterHookFn(ctx context.Context, gasPolicy types.GasPolicy) engine.HookFunc { sdkctx := sdk.UnwrapSDKContext(ctx) - gasMeter := meter.WithWeightedMeter(sdkctx.GasMeter(), nonNilNorZeroOrDefaultUint64(gasPolicy.WeightingFactor, defaultWeightFactor)) + gasMeter := meter.WithWeightedMeter(sdkctx.GasMeter(), lo.CoalesceOrEmpty(gasPolicy.WeightingFactor, defaultWeightFactor)) return func(opcode engine.Opcode, operand engine.Term, env *engine.Env) (err error) { if opcode != engine.OpCall { @@ -175,7 +174,7 @@ func gasMeterHookFn(ctx context.Context, gasPolicy types.GasPolicy) engine.HookF predicate := operandStringer.String() cost := lookupCost(predicate, - nonNilNorZeroOrDefaultUint64(gasPolicy.DefaultPredicateCost, defaultPredicateCost), + lo.CoalesceOrEmpty(gasPolicy.DefaultPredicateCost, defaultPredicateCost), gasPolicy.PredicateCosts) defer func() { @@ -203,19 +202,20 @@ func lookupCost(predicate string, defaultCost uint64, costs []types.PredicateCos for _, c := range costs { if prolog2.PredicateMatches(predicate)(c.Predicate) { - return nonNilNorZeroOrDefaultUint64(c.Cost, defaultCost) + return lo.CoalesceOrEmpty(c.Cost, defaultCost) } } return defaultCost } -// nonNilNorZeroOrDefaultUint64 returns the value of the given sdkmath.Uint if it is not nil and not zero, otherwise it returns the -// given default value. -func nonNilNorZeroOrDefaultUint64(v *sdkmath.Uint, defaultValue uint64) uint64 { - if v == nil || v.IsZero() { - return defaultValue +// calculateSolutionLimit returns the final number of solutions to be returned based on the given number of solutions and the +// maximum result count. +func calculateSolutionLimit(nbSolutions uint64, maxResultCount uint64) uint64 { + nbSolutions = max(nbSolutions, 1) + if maxResultCount == 0 { + return nbSolutions } - return v.Uint64() + return min(nbSolutions, maxResultCount) } diff --git a/x/logic/predicate/bank_test.go b/x/logic/predicate/bank_test.go index 39622b1fa..fef6c84a5 100644 --- a/x/logic/predicate/bank_test.go +++ b/x/logic/predicate/bank_test.go @@ -827,7 +827,7 @@ func TestAccount(t *testing.T) { So(err, ShouldBeNil) Convey("When the predicate is called", func() { - answer, err := util.QueryInterpreter(ctx, interpreter, tc.query, math.NewUint(5)) + answer, err := util.QueryInterpreter(ctx, interpreter, tc.query, 5) Convey("Then the error should be nil", func() { So(err, ShouldBeNil) diff --git a/x/logic/types/genesis.pb.go b/x/logic/types/genesis.pb.go index 0b2904e53..3763c596a 100644 --- a/x/logic/types/genesis.pb.go +++ b/x/logic/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: logic/v1beta2/genesis.proto +// source: logic/v1beta3/genesis.proto package types @@ -33,7 +33,7 @@ func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_712b71f2a5cb208f, []int{0} + return fileDescriptor_228475910faab904, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -70,15 +70,15 @@ func (m *GenesisState) GetParams() Params { } func init() { - proto.RegisterType((*GenesisState)(nil), "logic.v1beta2.GenesisState") + proto.RegisterType((*GenesisState)(nil), "logic.v1beta3.GenesisState") } -func init() { proto.RegisterFile("logic/v1beta2/genesis.proto", fileDescriptor_712b71f2a5cb208f) } +func init() { proto.RegisterFile("logic/v1beta3/genesis.proto", fileDescriptor_228475910faab904) } -var fileDescriptor_712b71f2a5cb208f = []byte{ +var fileDescriptor_228475910faab904 = []byte{ // 196 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xce, 0xc9, 0x4f, 0xcf, - 0x4c, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd2, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, + 0x4c, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd6, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x05, 0x4b, 0xea, 0x41, 0x25, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x32, 0xfa, 0x20, 0x16, 0x44, 0x91, 0x94, 0x14, 0xaa, 0x09, 0x05, 0x89, 0x45, 0x89, 0xb9, 0x50, 0x03, 0x94, 0x9c, 0xb9, 0x78, 0xdc, 0x21, 0x26, 0x06, 0x97, 0x24, @@ -88,7 +88,7 @@ var fileDescriptor_712b71f2a5cb208f = []byte{ 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x7a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x89, 0x15, 0xf9, 0x79, 0xa9, 0xba, 0x60, 0x6b, 0x93, 0xf3, 0x73, 0x20, 0xdc, 0x14, 0xfd, 0x0a, 0x7d, 0x88, 0xeb, 0x4a, 0x2a, 0x0b, 0x52, - 0x8b, 0x93, 0xd8, 0xc0, 0xd2, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1e, 0xa2, 0x99, 0xdd, + 0x8b, 0x93, 0xd8, 0xc0, 0xd2, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xab, 0xd3, 0x44, 0xb9, 0xf5, 0x00, 0x00, 0x00, } diff --git a/x/logic/types/params.go b/x/logic/types/params.go index 3248ff344..f8c4e6d87 100644 --- a/x/logic/types/params.go +++ b/x/logic/types/params.go @@ -3,8 +3,6 @@ package types import ( "fmt" "net/url" - - "cosmossdk.io/math" ) // Parameter store keys. @@ -15,9 +13,6 @@ var ( var ( DefaultPredicatesWhitelist = make([]string, 0) DefaultPredicatesBlacklist = make([]string, 0) - DefaultMaxSize = math.NewUint(uint64(5000)) - DefaultMaxResultCount = math.NewUint(uint64(1)) - DefaultMaxVariables = math.NewUint(uint64(100000)) ) // NewParams creates a new Params object. @@ -127,30 +122,30 @@ func validateInterpreter(i interface{}) error { type LimitsOption func(*Limits) // WithMaxSize sets the max size limits accepted for a prolog program. -func WithMaxSize(maxSize math.Uint) LimitsOption { +func WithMaxSize(maxSize uint64) LimitsOption { return func(i *Limits) { - i.MaxSize = &maxSize + i.MaxSize = maxSize } } // WithMaxResultCount sets the maximum number of results that can be requested for a query. -func WithMaxResultCount(maxResultCount math.Uint) LimitsOption { +func WithMaxResultCount(maxResultCount uint64) LimitsOption { return func(i *Limits) { - i.MaxResultCount = &maxResultCount + i.MaxResultCount = maxResultCount } } // WithMaxUserOutputSize specifies the maximum number of bytes to keep in the user output. -func WithMaxUserOutputSize(maxUserOutputSize math.Uint) LimitsOption { +func WithMaxUserOutputSize(maxUserOutputSize uint64) LimitsOption { return func(i *Limits) { - i.MaxUserOutputSize = &maxUserOutputSize + i.MaxUserOutputSize = maxUserOutputSize } } // WithMaxVariables sets the maximum number of variables that can be created by the interpreter. -func WithMaxVariables(maxVariables math.Uint) LimitsOption { +func WithMaxVariables(maxVariables uint64) LimitsOption { return func(i *Limits) { - i.MaxVariables = &maxVariables + i.MaxVariables = maxVariables } } @@ -161,18 +156,6 @@ func NewLimits(opts ...LimitsOption) Limits { opt(&l) } - if l.MaxSize == nil { - l.MaxSize = &DefaultMaxSize - } - - if l.MaxResultCount == nil { - l.MaxResultCount = &DefaultMaxResultCount - } - - if l.MaxVariables == nil { - l.MaxVariables = &DefaultMaxVariables - } - return l } diff --git a/x/logic/types/params.pb.go b/x/logic/types/params.pb.go index 9a4cb9d3c..2d061a362 100644 --- a/x/logic/types/params.pb.go +++ b/x/logic/types/params.pb.go @@ -1,10 +1,9 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: logic/v1beta2/params.proto +// source: logic/v1beta3/params.proto package types import ( - cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -39,7 +38,7 @@ type Params struct { func (m *Params) Reset() { *m = Params{} } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_3af0daa241de0fa3, []int{0} + return fileDescriptor_4697d60c461b684e, []int{0} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -92,25 +91,25 @@ func (m *Params) GetGasPolicy() GasPolicy { // Limits defines the limits of the logic module. type Limits struct { // max_size specifies the maximum size, in bytes, that is accepted for a program. - // nil value or 0 value remove size limitation. - MaxSize *cosmossdk_io_math.Uint `protobuf:"bytes,3,opt,name=max_size,json=maxSize,proto3,customtype=cosmossdk.io/math.Uint" json:"max_size,omitempty" yaml:"max_size"` + // A value of 0 means that there is no limit on the size of the program. + MaxSize uint64 `protobuf:"varint,3,opt,name=max_size,json=maxSize,proto3" json:"max_size,omitempty" yaml:"max_size"` // max_result_count specifies the maximum number of results that can be requested for a query. - // nil value or 0 value remove max result count limitation. - MaxResultCount *cosmossdk_io_math.Uint `protobuf:"bytes,2,opt,name=max_result_count,json=maxResultCount,proto3,customtype=cosmossdk.io/math.Uint" json:"max_result_count,omitempty" yaml:"max_result_count"` + // A value of 0 means that there is no limit on the number of results. + MaxResultCount uint64 `protobuf:"varint,2,opt,name=max_result_count,json=maxResultCount,proto3" json:"max_result_count,omitempty" yaml:"max_result_count"` // max_user_output_size specifies the maximum number of bytes to keep in the user output. If the user output exceeds // this size, the interpreter will overwrite the oldest bytes with the new ones to keep the size constant. - // nil value or 0 value means that no user output is used at all. - MaxUserOutputSize *cosmossdk_io_math.Uint `protobuf:"bytes,4,opt,name=max_user_output_size,json=maxUserOutputSize,proto3,customtype=cosmossdk.io/math.Uint" json:"max_user_output_size,omitempty" yaml:"max_user_output_size"` + // A value of 0 means the user output is disabled. + MaxUserOutputSize uint64 `protobuf:"varint,4,opt,name=max_user_output_size,json=maxUserOutputSize,proto3" json:"max_user_output_size,omitempty" yaml:"max_user_output_size"` // max_variables specifies the maximum number of variables that can be create by the interpreter. - // nil value or 0 value means that no limit is set. - MaxVariables *cosmossdk_io_math.Uint `protobuf:"bytes,5,opt,name=max_variables,json=maxVariables,proto3,customtype=cosmossdk.io/math.Uint" json:"max_variables,omitempty" yaml:"max_variables"` + // A value of 0 means that there is no limit on the number of variables. + MaxVariables uint64 `protobuf:"varint,5,opt,name=max_variables,json=maxVariables,proto3" json:"max_variables,omitempty" yaml:"max_variables"` } func (m *Limits) Reset() { *m = Limits{} } func (m *Limits) String() string { return proto.CompactTextString(m) } func (*Limits) ProtoMessage() {} func (*Limits) Descriptor() ([]byte, []int) { - return fileDescriptor_3af0daa241de0fa3, []int{1} + return fileDescriptor_4697d60c461b684e, []int{1} } func (m *Limits) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -139,6 +138,34 @@ func (m *Limits) XXX_DiscardUnknown() { var xxx_messageInfo_Limits proto.InternalMessageInfo +func (m *Limits) GetMaxSize() uint64 { + if m != nil { + return m.MaxSize + } + return 0 +} + +func (m *Limits) GetMaxResultCount() uint64 { + if m != nil { + return m.MaxResultCount + } + return 0 +} + +func (m *Limits) GetMaxUserOutputSize() uint64 { + if m != nil { + return m.MaxUserOutputSize + } + return 0 +} + +func (m *Limits) GetMaxVariables() uint64 { + if m != nil { + return m.MaxVariables + } + return 0 +} + // Filter defines the parameters for filtering the set of strings which can designate anything. // The filter is used to whitelist or blacklist strings. type Filter struct { @@ -156,7 +183,7 @@ func (m *Filter) Reset() { *m = Filter{} } func (m *Filter) String() string { return proto.CompactTextString(m) } func (*Filter) ProtoMessage() {} func (*Filter) Descriptor() ([]byte, []int) { - return fileDescriptor_3af0daa241de0fa3, []int{2} + return fileDescriptor_4697d60c461b684e, []int{2} } func (m *Filter) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -227,7 +254,7 @@ func (m *Interpreter) Reset() { *m = Interpreter{} } func (m *Interpreter) String() string { return proto.CompactTextString(m) } func (*Interpreter) ProtoMessage() {} func (*Interpreter) Descriptor() ([]byte, []int) { - return fileDescriptor_3af0daa241de0fa3, []int{3} + return fileDescriptor_4697d60c461b684e, []int{3} } func (m *Interpreter) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -283,11 +310,11 @@ func (m *Interpreter) GetVirtualFilesFilter() Filter { type GasPolicy struct { // WeightingFactor is the factor that is applied to the unit cost of each predicate // to yield the gas value. - // If not provided or set to 0, the value is set to 1. - WeightingFactor *cosmossdk_io_math.Uint `protobuf:"bytes,1,opt,name=weighting_factor,json=weightingFactor,proto3,customtype=cosmossdk.io/math.Uint" json:"weighting_factor,omitempty" yaml:"weighting_factor"` + // If set to 0, the value considered is 1. + WeightingFactor uint64 `protobuf:"varint,1,opt,name=weighting_factor,json=weightingFactor,proto3" json:"weighting_factor,omitempty" yaml:"weighting_factor"` // DefaultPredicateCost is the default unit cost of a predicate when not specified in the PredicateCosts list. - // If not provided or set to 0, the value is set to 1. - DefaultPredicateCost *cosmossdk_io_math.Uint `protobuf:"bytes,2,opt,name=default_predicate_cost,json=defaultPredicateCost,proto3,customtype=cosmossdk.io/math.Uint" json:"default_predicate_cost,omitempty" yaml:"default_predicate_cost"` + // If set to 0, the value considered is 1. + DefaultPredicateCost uint64 `protobuf:"varint,2,opt,name=default_predicate_cost,json=defaultPredicateCost,proto3" json:"default_predicate_cost,omitempty" yaml:"default_predicate_cost"` // PredicateCosts is the list of predicates and their associated unit costs. PredicateCosts []PredicateCost `protobuf:"bytes,3,rep,name=predicate_costs,json=predicateCosts,proto3" json:"predicate_costs" yaml:"predicate_cost"` } @@ -296,7 +323,7 @@ func (m *GasPolicy) Reset() { *m = GasPolicy{} } func (m *GasPolicy) String() string { return proto.CompactTextString(m) } func (*GasPolicy) ProtoMessage() {} func (*GasPolicy) Descriptor() ([]byte, []int) { - return fileDescriptor_3af0daa241de0fa3, []int{4} + return fileDescriptor_4697d60c461b684e, []int{4} } func (m *GasPolicy) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -325,6 +352,20 @@ func (m *GasPolicy) XXX_DiscardUnknown() { var xxx_messageInfo_GasPolicy proto.InternalMessageInfo +func (m *GasPolicy) GetWeightingFactor() uint64 { + if m != nil { + return m.WeightingFactor + } + return 0 +} + +func (m *GasPolicy) GetDefaultPredicateCost() uint64 { + if m != nil { + return m.DefaultPredicateCost + } + return 0 +} + func (m *GasPolicy) GetPredicateCosts() []PredicateCost { if m != nil { return m.PredicateCosts @@ -338,14 +379,15 @@ type PredicateCost struct { // If no arity is specified, the unit cost is applied to all predicates with the same name. Predicate string `protobuf:"bytes,1,opt,name=predicate,proto3" json:"predicate,omitempty" yaml:"predicate"` // Cost is the unit cost of the predicate. - Cost *cosmossdk_io_math.Uint `protobuf:"bytes,2,opt,name=cost,proto3,customtype=cosmossdk.io/math.Uint" json:"cost,omitempty" yaml:"cost",omitempty` + // If set to 0, the value considered is 1. + Cost uint64 `protobuf:"varint,2,opt,name=cost,proto3" json:"cost,omitempty" yaml:"cost"` } func (m *PredicateCost) Reset() { *m = PredicateCost{} } func (m *PredicateCost) String() string { return proto.CompactTextString(m) } func (*PredicateCost) ProtoMessage() {} func (*PredicateCost) Descriptor() ([]byte, []int) { - return fileDescriptor_3af0daa241de0fa3, []int{5} + return fileDescriptor_4697d60c461b684e, []int{5} } func (m *PredicateCost) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -381,67 +423,72 @@ func (m *PredicateCost) GetPredicate() string { return "" } +func (m *PredicateCost) GetCost() uint64 { + if m != nil { + return m.Cost + } + return 0 +} + func init() { - proto.RegisterType((*Params)(nil), "logic.v1beta2.Params") - proto.RegisterType((*Limits)(nil), "logic.v1beta2.Limits") - proto.RegisterType((*Filter)(nil), "logic.v1beta2.Filter") - proto.RegisterType((*Interpreter)(nil), "logic.v1beta2.Interpreter") - proto.RegisterType((*GasPolicy)(nil), "logic.v1beta2.GasPolicy") - proto.RegisterType((*PredicateCost)(nil), "logic.v1beta2.PredicateCost") -} - -func init() { proto.RegisterFile("logic/v1beta2/params.proto", fileDescriptor_3af0daa241de0fa3) } - -var fileDescriptor_3af0daa241de0fa3 = []byte{ - // 762 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xcf, 0x6a, 0xdb, 0x48, - 0x18, 0xb7, 0x6c, 0xaf, 0x77, 0x3d, 0x5e, 0x27, 0x8e, 0x70, 0xb2, 0x5a, 0xef, 0xc6, 0x36, 0x73, - 0xca, 0x61, 0x57, 0x26, 0x59, 0xc8, 0xb2, 0x81, 0xa5, 0xa0, 0x94, 0xb4, 0xa5, 0x81, 0x86, 0x29, - 0x29, 0xa5, 0x3d, 0x98, 0xb1, 0x3c, 0x91, 0x87, 0x48, 0x1e, 0xa1, 0x19, 0x25, 0x72, 0x8e, 0x7d, - 0x80, 0xd2, 0x43, 0x0f, 0x3d, 0xf4, 0xd0, 0xc7, 0xc9, 0xa9, 0xe4, 0x58, 0x7a, 0x30, 0x25, 0x79, - 0x83, 0x3c, 0x41, 0xd1, 0x8c, 0x2c, 0xd9, 0x6a, 0xc0, 0xe4, 0x26, 0x7d, 0xbf, 0xef, 0xf7, 0x47, - 0xdf, 0x7c, 0x83, 0x40, 0xcb, 0x65, 0x0e, 0xb5, 0x7b, 0x67, 0xdb, 0x03, 0x22, 0xf0, 0x4e, 0xcf, - 0xc7, 0x01, 0xf6, 0xb8, 0xe9, 0x07, 0x4c, 0x30, 0xbd, 0x2e, 0x31, 0x33, 0xc1, 0x5a, 0x4d, 0x87, - 0x39, 0x4c, 0x22, 0xbd, 0xf8, 0x49, 0x35, 0xc1, 0x37, 0x45, 0x50, 0x39, 0x92, 0x2c, 0xfd, 0x25, - 0xa8, 0xd1, 0xb1, 0x20, 0x81, 0x1f, 0x10, 0x41, 0x02, 0x43, 0xeb, 0x6a, 0x5b, 0xb5, 0x9d, 0x96, - 0xb9, 0xa0, 0x62, 0x3e, 0xc9, 0x3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0b, 0xaf, 0x4c, 0x87, 0x8a, 0x51, 0x38, 0x30, - 0x6d, 0xe6, 0xf5, 0x70, 0xc4, 0xc6, 0xe4, 0x6f, 0xf9, 0x23, 0xb1, 0x99, 0xab, 0x5e, 0x87, 0xbd, - 0xa8, 0xa7, 0x7e, 0x4a, 0x62, 0xe2, 0x13, 0x3e, 0xa8, 0x48, 0xf8, 0x9f, 0xef, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x53, 0x14, 0xc3, 0x1a, 0xaa, 0x06, 0x00, 0x00, + proto.RegisterType((*Params)(nil), "logic.v1beta3.Params") + proto.RegisterType((*Limits)(nil), "logic.v1beta3.Limits") + proto.RegisterType((*Filter)(nil), "logic.v1beta3.Filter") + proto.RegisterType((*Interpreter)(nil), "logic.v1beta3.Interpreter") + proto.RegisterType((*GasPolicy)(nil), "logic.v1beta3.GasPolicy") + proto.RegisterType((*PredicateCost)(nil), "logic.v1beta3.PredicateCost") +} + +func init() { proto.RegisterFile("logic/v1beta3/params.proto", fileDescriptor_4697d60c461b684e) } + +var fileDescriptor_4697d60c461b684e = []byte{ + // 722 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x6e, 0xd3, 0x4a, + 0x14, 0x8e, 0x93, 0xdc, 0xdc, 0x9b, 0xc9, 0x4d, 0x93, 0xfa, 0xa6, 0x17, 0x93, 0xd2, 0x38, 0x0c, + 0x9b, 0x6e, 0x48, 0x44, 0x2b, 0x75, 0x51, 0x89, 0x8d, 0x0b, 0x01, 0x24, 0x24, 0xa2, 0x41, 0xfc, + 0x88, 0x4d, 0x34, 0x71, 0xa6, 0xee, 0x08, 0x3b, 0x63, 0x79, 0x26, 0xad, 0xd3, 0x25, 0x4f, 0x80, + 0x58, 0x20, 0x16, 0x2c, 0x78, 0x9c, 0x2e, 0xbb, 0x64, 0x65, 0xa1, 0xf6, 0x0d, 0xfc, 0x04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xa3, 0xc8, 0x81, 0xdc, 0x58, 0x67, 0x06, 0x43, 0x94, 0x53, 0xf5, 0x07, 0xa0, 0xbc, 0xf4, 0xd5, + 0x8d, 0x38, 0x32, 0x6b, 0x8a, 0xae, 0xfa, 0x4a, 0xd0, 0x7a, 0x7e, 0x71, 0xd5, 0xd1, 0x2e, 0xaf, + 0x3a, 0xda, 0xaf, 0xab, 0x8e, 0xf6, 0xf9, 0xba, 0x53, 0xb8, 0xbc, 0xee, 0x14, 0x7e, 0x5e, 0x77, + 0x0a, 0x1f, 0x7a, 0x0e, 0x15, 0x27, 0xb3, 0x71, 0xcf, 0x66, 0x5e, 0x1f, 0x87, 0x6c, 0x4a, 0x1e, + 0xca, 0x7f, 0xad, 0xcd, 0x5c, 0xf5, 0x3a, 0xe9, 0x87, 0x7d, 0xf5, 0xdf, 0x16, 0x73, 0x9f, 0xf0, + 0x71, 0x45, 0xc2, 0xfb, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xf3, 0x73, 0xf6, 0x1b, 0xcd, 0x05, + 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -517,53 +564,25 @@ func (m *Limits) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.MaxVariables != nil { - { - size := m.MaxVariables.Size() - i -= size - if _, err := m.MaxVariables.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } + if m.MaxVariables != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxVariables)) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x28 } - if m.MaxUserOutputSize != nil { - { - size := m.MaxUserOutputSize.Size() - i -= size - if _, err := m.MaxUserOutputSize.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } + if m.MaxUserOutputSize != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxUserOutputSize)) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x20 } - if m.MaxSize != nil { - { - size := m.MaxSize.Size() - i -= size - if _, err := m.MaxSize.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } + if m.MaxSize != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxSize)) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x18 } - if m.MaxResultCount != nil { - { - size := m.MaxResultCount.Size() - i -= size - if _, err := m.MaxResultCount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } + if m.MaxResultCount != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxResultCount)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } return len(dAtA) - i, nil } @@ -693,29 +712,15 @@ func (m *GasPolicy) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x1a } } - if m.DefaultPredicateCost != nil { - { - size := m.DefaultPredicateCost.Size() - i -= size - if _, err := m.DefaultPredicateCost.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } + if m.DefaultPredicateCost != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.DefaultPredicateCost)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } - if m.WeightingFactor != nil { - { - size := m.WeightingFactor.Size() - i -= size - if _, err := m.WeightingFactor.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } + if m.WeightingFactor != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.WeightingFactor)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -740,17 +745,10 @@ func (m *PredicateCost) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Cost != nil { - { - size := m.Cost.Size() - i -= size - if _, err := m.Cost.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } + if m.Cost != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.Cost)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } if len(m.Predicate) > 0 { i -= len(m.Predicate) @@ -794,21 +792,17 @@ func (m *Limits) Size() (n int) { } var l int _ = l - if m.MaxResultCount != nil { - l = m.MaxResultCount.Size() - n += 1 + l + sovParams(uint64(l)) + if m.MaxResultCount != 0 { + n += 1 + sovParams(uint64(m.MaxResultCount)) } - if m.MaxSize != nil { - l = m.MaxSize.Size() - n += 1 + l + sovParams(uint64(l)) + if m.MaxSize != 0 { + n += 1 + sovParams(uint64(m.MaxSize)) } - if m.MaxUserOutputSize != nil { - l = m.MaxUserOutputSize.Size() - n += 1 + l + sovParams(uint64(l)) + if m.MaxUserOutputSize != 0 { + n += 1 + sovParams(uint64(m.MaxUserOutputSize)) } - if m.MaxVariables != nil { - l = m.MaxVariables.Size() - n += 1 + l + sovParams(uint64(l)) + if m.MaxVariables != 0 { + n += 1 + sovParams(uint64(m.MaxVariables)) } return n } @@ -857,13 +851,11 @@ func (m *GasPolicy) Size() (n int) { } var l int _ = l - if m.WeightingFactor != nil { - l = m.WeightingFactor.Size() - n += 1 + l + sovParams(uint64(l)) + if m.WeightingFactor != 0 { + n += 1 + sovParams(uint64(m.WeightingFactor)) } - if m.DefaultPredicateCost != nil { - l = m.DefaultPredicateCost.Size() - n += 1 + l + sovParams(uint64(l)) + if m.DefaultPredicateCost != 0 { + n += 1 + sovParams(uint64(m.DefaultPredicateCost)) } if len(m.PredicateCosts) > 0 { for _, e := range m.PredicateCosts { @@ -884,9 +876,8 @@ func (m *PredicateCost) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } - if m.Cost != nil { - l = m.Cost.Size() - n += 1 + l + sovParams(uint64(l)) + if m.Cost != 0 { + n += 1 + sovParams(uint64(m.Cost)) } return n } @@ -1076,10 +1067,10 @@ func (m *Limits) Unmarshal(dAtA []byte) error { } switch fieldNum { case 2: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MaxResultCount", wireType) } - var stringLen uint64 + m.MaxResultCount = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -1089,33 +1080,16 @@ func (m *Limits) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.MaxResultCount |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v cosmossdk_io_math.Uint - m.MaxResultCount = &v - if err := m.MaxResultCount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 3: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MaxSize", wireType) } - var stringLen uint64 + m.MaxSize = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -1125,33 +1099,16 @@ func (m *Limits) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.MaxSize |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v cosmossdk_io_math.Uint - m.MaxSize = &v - if err := m.MaxSize.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 4: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MaxUserOutputSize", wireType) } - var stringLen uint64 + m.MaxUserOutputSize = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -1161,33 +1118,16 @@ func (m *Limits) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.MaxUserOutputSize |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v cosmossdk_io_math.Uint - m.MaxUserOutputSize = &v - if err := m.MaxUserOutputSize.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 5: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MaxVariables", wireType) } - var stringLen uint64 + m.MaxVariables = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -1197,28 +1137,11 @@ func (m *Limits) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.MaxVariables |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v cosmossdk_io_math.Uint - m.MaxVariables = &v - if err := m.MaxVariables.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) @@ -1532,10 +1455,10 @@ func (m *GasPolicy) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field WeightingFactor", wireType) } - var stringLen uint64 + m.WeightingFactor = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -1545,33 +1468,16 @@ func (m *GasPolicy) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.WeightingFactor |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v cosmossdk_io_math.Uint - m.WeightingFactor = &v - if err := m.WeightingFactor.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 2: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field DefaultPredicateCost", wireType) } - var stringLen uint64 + m.DefaultPredicateCost = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -1581,28 +1487,11 @@ func (m *GasPolicy) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.DefaultPredicateCost |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v cosmossdk_io_math.Uint - m.DefaultPredicateCost = &v - if err := m.DefaultPredicateCost.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PredicateCosts", wireType) @@ -1720,10 +1609,10 @@ func (m *PredicateCost) Unmarshal(dAtA []byte) error { m.Predicate = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Cost", wireType) } - var stringLen uint64 + m.Cost = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -1733,28 +1622,11 @@ func (m *PredicateCost) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.Cost |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v cosmossdk_io_math.Uint - m.Cost = &v - if err := m.Cost.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/logic/types/params_test.go b/x/logic/types/params_test.go index f259ba575..4f52e055e 100644 --- a/x/logic/types/params_test.go +++ b/x/logic/types/params_test.go @@ -6,8 +6,6 @@ import ( . "github.com/smartystreets/goconvey/convey" - "cosmossdk.io/math" - "github.com/axone-protocol/axoned/v10/x/logic/types" ) @@ -36,10 +34,10 @@ func TestValidateParams(t *testing.T) { types.WithVirtualFilesWhitelist([]string{"file2"}), ), types.NewLimits( - types.WithMaxSize(math.NewUint(2)), - types.WithMaxResultCount(math.NewUint(3)), - types.WithMaxUserOutputSize(math.NewUint(4)), - types.WithMaxVariables(math.NewUint(5)), + types.WithMaxSize(2), + types.WithMaxResultCount(3), + types.WithMaxUserOutputSize(4), + types.WithMaxVariables(5), ), ), expectErr: false, diff --git a/x/logic/types/query.pb.go b/x/logic/types/query.pb.go index 3009b892d..0f18fbfa8 100644 --- a/x/logic/types/query.pb.go +++ b/x/logic/types/query.pb.go @@ -1,11 +1,10 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: logic/v1beta2/query.proto +// source: logic/v1beta3/query.proto package types import ( context "context" - cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" @@ -39,7 +38,7 @@ func (m *QueryServiceParamsRequest) Reset() { *m = QueryServiceParamsReq func (m *QueryServiceParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryServiceParamsRequest) ProtoMessage() {} func (*QueryServiceParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_008a54e610b23239, []int{0} + return fileDescriptor_6723436728da1441, []int{0} } func (m *QueryServiceParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -78,7 +77,7 @@ func (m *QueryServiceParamsResponse) Reset() { *m = QueryServiceParamsRe func (m *QueryServiceParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryServiceParamsResponse) ProtoMessage() {} func (*QueryServiceParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_008a54e610b23239, []int{1} + return fileDescriptor_6723436728da1441, []int{1} } func (m *QueryServiceParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -123,14 +122,14 @@ type QueryServiceAskRequest struct { // limit specifies the maximum number of solutions to be returned. This field is governed by // max_result_count, which defines the upper limit of results that may be requested per query. // If this field is not explicitly set, a default value of 1 is applied. - Limit *cosmossdk_io_math.Uint `protobuf:"bytes,3,opt,name=limit,proto3,customtype=cosmossdk.io/math.Uint" json:"limit,omitempty" yaml:"limit",omitempty` + Limit uint64 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty" yaml:"limit",omitempty` } func (m *QueryServiceAskRequest) Reset() { *m = QueryServiceAskRequest{} } func (m *QueryServiceAskRequest) String() string { return proto.CompactTextString(m) } func (*QueryServiceAskRequest) ProtoMessage() {} func (*QueryServiceAskRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_008a54e610b23239, []int{2} + return fileDescriptor_6723436728da1441, []int{2} } func (m *QueryServiceAskRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -173,6 +172,13 @@ func (m *QueryServiceAskRequest) GetQuery() string { return "" } +func (m *QueryServiceAskRequest) GetLimit() uint64 { + if m != nil { + return m.Limit + } + return 0 +} + // QueryServiceAskResponse is response type for the QueryService/Ask RPC method. type QueryServiceAskResponse struct { // height is the block height at which the query was executed. @@ -190,7 +196,7 @@ func (m *QueryServiceAskResponse) Reset() { *m = QueryServiceAskResponse func (m *QueryServiceAskResponse) String() string { return proto.CompactTextString(m) } func (*QueryServiceAskResponse) ProtoMessage() {} func (*QueryServiceAskResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_008a54e610b23239, []int{3} + return fileDescriptor_6723436728da1441, []int{3} } func (m *QueryServiceAskResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -248,53 +254,52 @@ func (m *QueryServiceAskResponse) GetUserOutput() string { } func init() { - proto.RegisterType((*QueryServiceParamsRequest)(nil), "logic.v1beta2.QueryServiceParamsRequest") - proto.RegisterType((*QueryServiceParamsResponse)(nil), "logic.v1beta2.QueryServiceParamsResponse") - proto.RegisterType((*QueryServiceAskRequest)(nil), "logic.v1beta2.QueryServiceAskRequest") - proto.RegisterType((*QueryServiceAskResponse)(nil), "logic.v1beta2.QueryServiceAskResponse") + proto.RegisterType((*QueryServiceParamsRequest)(nil), "logic.v1beta3.QueryServiceParamsRequest") + proto.RegisterType((*QueryServiceParamsResponse)(nil), "logic.v1beta3.QueryServiceParamsResponse") + proto.RegisterType((*QueryServiceAskRequest)(nil), "logic.v1beta3.QueryServiceAskRequest") + proto.RegisterType((*QueryServiceAskResponse)(nil), "logic.v1beta3.QueryServiceAskResponse") } -func init() { proto.RegisterFile("logic/v1beta2/query.proto", fileDescriptor_008a54e610b23239) } +func init() { proto.RegisterFile("logic/v1beta3/query.proto", fileDescriptor_6723436728da1441) } -var fileDescriptor_008a54e610b23239 = []byte{ - // 592 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x31, 0x6f, 0xd3, 0x40, - 0x18, 0xcd, 0xa5, 0x69, 0x80, 0x2b, 0x2c, 0x27, 0x68, 0x13, 0x27, 0xd8, 0x91, 0x51, 0x51, 0x41, - 0xd4, 0x6e, 0x53, 0x09, 0x55, 0xdd, 0x92, 0x09, 0x31, 0x14, 0x28, 0xea, 0xc2, 0x52, 0x5d, 0x92, - 0x93, 0x73, 0x8a, 0xed, 0x73, 0x7d, 0xe7, 0xd0, 0xac, 0xb0, 0xb0, 0x81, 0xc4, 0xc2, 0x82, 0xc4, - 0xc4, 0xcc, 0xcf, 0xc8, 0x58, 0x89, 0xa5, 0x62, 0xb0, 0x50, 0x82, 0xc4, 0xee, 0x5f, 0x80, 0x72, - 0xe7, 0x28, 0x76, 0x4b, 0x0b, 0x9b, 0xfd, 0xbd, 0xf7, 0xbe, 0xef, 0x7d, 0xef, 0xee, 0x60, 0xd5, - 0x65, 0x0e, 0xed, 0xda, 0xc3, 0xed, 0x0e, 0x11, 0xb8, 0x69, 0x1f, 0x47, 0x24, 0x1c, 0x59, 0x41, - 0xc8, 0x04, 0x43, 0xb7, 0x24, 0x64, 0xa5, 0x90, 0x56, 0xeb, 0x32, 0xee, 0x31, 0xae, 0x28, 0xf6, - 0x70, 0x3b, 0xcb, 0xd5, 0x6e, 0x3b, 0xcc, 0x61, 0xf2, 0xd3, 0x9e, 0x7d, 0xa5, 0xd5, 0xba, 0xc3, - 0x98, 0xe3, 0x12, 0x1b, 0x07, 0xd4, 0xc6, 0xbe, 0xcf, 0x04, 0x16, 0x94, 0xf9, 0x3c, 0x45, 0xb5, - 0xfc, 0xe8, 0x00, 0x87, 0xd8, 0x9b, 0x63, 0xe7, 0x6c, 0x89, 0x51, 0x40, 0x52, 0xc8, 0xac, 0xc1, - 0xea, 0x8b, 0xd9, 0xe4, 0x97, 0x24, 0x1c, 0xd2, 0x2e, 0x79, 0x2e, 0x65, 0x07, 0xe4, 0x38, 0x22, - 0x5c, 0x98, 0x2e, 0xd4, 0xfe, 0x06, 0xf2, 0x80, 0xf9, 0x9c, 0xa0, 0x7d, 0x58, 0x56, 0x53, 0x2a, - 0xa0, 0x01, 0x36, 0x56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 0xe1, 0x9d, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe7, 0x25, 0x50, 0x93, 0xb3, 0x04, 0x00, 0x00, +var fileDescriptor_6723436728da1441 = []byte{ + // 570 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xbf, 0x6f, 0xd3, 0x40, + 0x18, 0xcd, 0xa5, 0x21, 0xc0, 0x15, 0x96, 0x13, 0xb4, 0x89, 0x13, 0xec, 0xc8, 0xa8, 0x28, 0x20, + 0x6a, 0xb7, 0x8d, 0x84, 0x50, 0xb7, 0x64, 0x42, 0x0c, 0xfc, 0x28, 0x62, 0x61, 0xa9, 0x2e, 0xc9, + 0xe9, 0x62, 0xc5, 0xf6, 0xb9, 0xbe, 0x73, 0x68, 0x56, 0x58, 0xd8, 0x40, 0x62, 0x61, 0x41, 0x62, + 0x62, 0x66, 0xe6, 0x2f, 0xe8, 0x58, 0x89, 0x85, 0xc9, 0x42, 0x09, 0x12, 0x7b, 0xfe, 0x02, 0x94, + 0xbb, 0x8b, 0x62, 0xb7, 0xb4, 0x74, 0x3b, 0xbf, 0xf7, 0xbd, 0xef, 0x7b, 0xf7, 0xfc, 0x1d, 0xac, + 0xfa, 0x8c, 0x7a, 0x3d, 0x77, 0xb4, 0xdd, 0x25, 0x02, 0xb7, 0xdc, 0x83, 0x84, 0xc4, 0x63, 0x27, + 0x8a, 0x99, 0x60, 0xe8, 0xba, 0xa4, 0x1c, 0x4d, 0x19, 0xb5, 0x1e, 0xe3, 0x01, 0xe3, 0xaa, 0xc4, + 0x1d, 0x6d, 0x67, 0x6b, 0x8d, 0x1b, 0x94, 0x51, 0x26, 0x8f, 0xee, 0xfc, 0xa4, 0xd1, 0x3a, 0x65, + 0x8c, 0xfa, 0xc4, 0xc5, 0x91, 0xe7, 0xe2, 0x30, 0x64, 0x02, 0x0b, 0x8f, 0x85, 0x5c, 0xb3, 0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 0x98, 0x9a, 0x85, + 0xe3, 0xa9, 0x59, 0xf8, 0x39, 0x35, 0x0b, 0xaf, 0x1c, 0xea, 0x89, 0x41, 0xd2, 0x75, 0x7a, 0x2c, + 0x38, 0xa3, 0xcb, 0xa1, 0xee, 0x23, 0x1f, 0x78, 0xb7, 0x2c, 0xe9, 0xd6, 0xdf, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x4e, 0xb8, 0xd5, 0xf6, 0x95, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -327,7 +332,7 @@ func NewQueryServiceClient(cc grpc1.ClientConn) QueryServiceClient { func (c *queryServiceClient) Params(ctx context.Context, in *QueryServiceParamsRequest, opts ...grpc.CallOption) (*QueryServiceParamsResponse, error) { out := new(QueryServiceParamsResponse) - err := c.cc.Invoke(ctx, "/logic.v1beta2.QueryService/Params", in, out, opts...) + err := c.cc.Invoke(ctx, "/logic.v1beta3.QueryService/Params", in, out, opts...) if err != nil { return nil, err } @@ -336,7 +341,7 @@ func (c *queryServiceClient) Params(ctx context.Context, in *QueryServiceParamsR func (c *queryServiceClient) Ask(ctx context.Context, in *QueryServiceAskRequest, opts ...grpc.CallOption) (*QueryServiceAskResponse, error) { out := new(QueryServiceAskResponse) - err := c.cc.Invoke(ctx, "/logic.v1beta2.QueryService/Ask", in, out, opts...) + err := c.cc.Invoke(ctx, "/logic.v1beta3.QueryService/Ask", in, out, opts...) if err != nil { return nil, err } @@ -378,7 +383,7 @@ func _QueryService_Params_Handler(srv interface{}, ctx context.Context, dec func } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/logic.v1beta2.QueryService/Params", + FullMethod: "/logic.v1beta3.QueryService/Params", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServiceServer).Params(ctx, req.(*QueryServiceParamsRequest)) @@ -396,7 +401,7 @@ func _QueryService_Ask_Handler(srv interface{}, ctx context.Context, dec func(in } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/logic.v1beta2.QueryService/Ask", + FullMethod: "/logic.v1beta3.QueryService/Ask", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServiceServer).Ask(ctx, req.(*QueryServiceAskRequest)) @@ -405,7 +410,7 @@ func _QueryService_Ask_Handler(srv interface{}, ctx context.Context, dec func(in } var _QueryService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "logic.v1beta2.QueryService", + ServiceName: "logic.v1beta3.QueryService", HandlerType: (*QueryServiceServer)(nil), Methods: []grpc.MethodDesc{ { @@ -418,7 +423,7 @@ var _QueryService_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "logic/v1beta2/query.proto", + Metadata: "logic/v1beta3/query.proto", } func (m *QueryServiceParamsRequest) Marshal() (dAtA []byte, err error) { @@ -497,17 +502,10 @@ func (m *QueryServiceAskRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l - if m.Limit != nil { - { - size := m.Limit.Size() - i -= size - if _, err := m.Limit.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } + if m.Limit != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Limit)) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x18 } if len(m.Query) > 0 { i -= len(m.Query) @@ -623,9 +621,8 @@ func (m *QueryServiceAskRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.Limit != nil { - l = m.Limit.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.Limit != 0 { + n += 1 + sovQuery(uint64(m.Limit)) } return n } @@ -886,10 +883,10 @@ func (m *QueryServiceAskRequest) Unmarshal(dAtA []byte) error { m.Query = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) } - var stringLen uint64 + m.Limit = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -899,28 +896,11 @@ func (m *QueryServiceAskRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.Limit |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v cosmossdk_io_math.Uint - m.Limit = &v - if err := m.Limit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/logic/types/query.pb.gw.go b/x/logic/types/query.pb.gw.go index f0e2f11d8..df497135f 100644 --- a/x/logic/types/query.pb.gw.go +++ b/x/logic/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: logic/v1beta2/query.proto +// source: logic/v1beta3/query.proto /* Package types is a reverse proxy. diff --git a/x/logic/types/tx.pb.go b/x/logic/types/tx.pb.go index 599b1f509..598cac738 100644 --- a/x/logic/types/tx.pb.go +++ b/x/logic/types/tx.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: logic/v1beta2/tx.proto +// source: logic/v1beta3/tx.proto package types @@ -43,7 +43,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_19bfd5fc1a0735fe, []int{0} + return fileDescriptor_6530214348eac56c, []int{0} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -95,7 +95,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_19bfd5fc1a0735fe, []int{1} + return fileDescriptor_6530214348eac56c, []int{1} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -125,16 +125,16 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgUpdateParams)(nil), "logic.v1beta2.MsgUpdateParams") - proto.RegisterType((*MsgUpdateParamsResponse)(nil), "logic.v1beta2.MsgUpdateParamsResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "logic.v1beta3.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "logic.v1beta3.MsgUpdateParamsResponse") } -func init() { proto.RegisterFile("logic/v1beta2/tx.proto", fileDescriptor_19bfd5fc1a0735fe) } +func init() { proto.RegisterFile("logic/v1beta3/tx.proto", fileDescriptor_6530214348eac56c) } -var fileDescriptor_19bfd5fc1a0735fe = []byte{ +var fileDescriptor_6530214348eac56c = []byte{ // 320 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcb, 0xc9, 0x4f, 0xcf, - 0x4c, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd2, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, + 0x4c, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd6, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x05, 0x8b, 0xeb, 0x41, 0xc5, 0xa5, 0xc4, 0x93, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xf5, 0x73, 0x8b, 0xd3, 0xf5, 0xcb, 0x0c, 0x41, 0x14, 0x44, 0x9d, 0x94, 0x24, 0x44, 0x22, 0x1e, 0xcc, 0xd3, 0x87, 0x70, 0xa0, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x10, 0x71, 0x10, 0x0b, @@ -152,7 +152,7 @@ var fileDescriptor_19bfd5fc1a0735fe = []byte{ 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x27, 0x56, 0xe4, 0xe7, 0xa5, 0xea, 0x82, 0xc3, 0x30, 0x39, 0x3f, 0x07, 0xc2, 0x4d, 0xd1, 0xaf, 0xd0, 0x87, 0x04, 0x75, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, - 0x58, 0xda, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x06, 0xfc, 0x7f, 0xed, 0xf1, 0x01, 0x00, 0x00, + 0x58, 0xda, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xe0, 0x78, 0x3d, 0xc2, 0xf1, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -182,7 +182,7 @@ func NewMsgServiceClient(cc grpc1.ClientConn) MsgServiceClient { func (c *msgServiceClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, "/logic.v1beta2.MsgService/UpdateParams", in, out, opts...) + err := c.cc.Invoke(ctx, "/logic.v1beta3.MsgService/UpdateParams", in, out, opts...) if err != nil { return nil, err } @@ -218,7 +218,7 @@ func _MsgService_UpdateParams_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/logic.v1beta2.MsgService/UpdateParams", + FullMethod: "/logic.v1beta3.MsgService/UpdateParams", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServiceServer).UpdateParams(ctx, req.(*MsgUpdateParams)) @@ -227,7 +227,7 @@ func _MsgService_UpdateParams_Handler(srv interface{}, ctx context.Context, dec } var _MsgService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "logic.v1beta2.MsgService", + ServiceName: "logic.v1beta3.MsgService", HandlerType: (*MsgServiceServer)(nil), Methods: []grpc.MethodDesc{ { @@ -236,7 +236,7 @@ var _MsgService_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "logic/v1beta2/tx.proto", + Metadata: "logic/v1beta3/tx.proto", } func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { diff --git a/x/logic/types/types.pb.go b/x/logic/types/types.pb.go index a3c23e754..512ba9e82 100644 --- a/x/logic/types/types.pb.go +++ b/x/logic/types/types.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: logic/v1beta2/types.proto +// source: logic/v1beta3/types.proto package types @@ -35,7 +35,7 @@ func (m *Substitution) Reset() { *m = Substitution{} } func (m *Substitution) String() string { return proto.CompactTextString(m) } func (*Substitution) ProtoMessage() {} func (*Substitution) Descriptor() ([]byte, []int) { - return fileDescriptor_f3c73c95465ca7a8, []int{0} + return fileDescriptor_bb923dc1eb7aeeab, []int{0} } func (m *Substitution) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -90,7 +90,7 @@ func (m *Result) Reset() { *m = Result{} } func (m *Result) String() string { return proto.CompactTextString(m) } func (*Result) ProtoMessage() {} func (*Result) Descriptor() ([]byte, []int) { - return fileDescriptor_f3c73c95465ca7a8, []int{1} + return fileDescriptor_bb923dc1eb7aeeab, []int{1} } func (m *Result) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -147,7 +147,7 @@ func (m *Answer) Reset() { *m = Answer{} } func (m *Answer) String() string { return proto.CompactTextString(m) } func (*Answer) ProtoMessage() {} func (*Answer) Descriptor() ([]byte, []int) { - return fileDescriptor_f3c73c95465ca7a8, []int{2} + return fileDescriptor_bb923dc1eb7aeeab, []int{2} } func (m *Answer) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -198,18 +198,18 @@ func (m *Answer) GetResults() []Result { } func init() { - proto.RegisterType((*Substitution)(nil), "logic.v1beta2.Substitution") - proto.RegisterType((*Result)(nil), "logic.v1beta2.Result") - proto.RegisterType((*Answer)(nil), "logic.v1beta2.Answer") + proto.RegisterType((*Substitution)(nil), "logic.v1beta3.Substitution") + proto.RegisterType((*Result)(nil), "logic.v1beta3.Result") + proto.RegisterType((*Answer)(nil), "logic.v1beta3.Answer") } -func init() { proto.RegisterFile("logic/v1beta2/types.proto", fileDescriptor_f3c73c95465ca7a8) } +func init() { proto.RegisterFile("logic/v1beta3/types.proto", fileDescriptor_bb923dc1eb7aeeab) } -var fileDescriptor_f3c73c95465ca7a8 = []byte{ +var fileDescriptor_bb923dc1eb7aeeab = []byte{ // 411 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0xb1, 0xae, 0xd3, 0x30, 0x18, 0x85, 0xe3, 0xdb, 0x7b, 0x7b, 0x7b, 0x0d, 0x77, 0xb1, 0x00, 0xe5, 0xb6, 0xc2, 0x8e, 0x32, - 0xa0, 0x0e, 0x90, 0x88, 0xc2, 0x00, 0x15, 0x12, 0x22, 0x13, 0x0b, 0x03, 0x65, 0x63, 0x41, 0x49, + 0xa0, 0x0e, 0x90, 0x08, 0xca, 0x00, 0x15, 0x12, 0x22, 0x13, 0x0b, 0x03, 0x65, 0x63, 0x41, 0x49, 0xb1, 0x52, 0x4b, 0x49, 0x1c, 0xd9, 0x4e, 0x69, 0xdf, 0xa2, 0x23, 0x23, 0x6f, 0xc0, 0x6b, 0x74, 0xec, 0x08, 0x4b, 0x84, 0xda, 0x37, 0xc8, 0x13, 0xa0, 0xda, 0x29, 0x75, 0xd8, 0x92, 0x7c, 0xff, 0x39, 0xf9, 0xcf, 0xd1, 0x0f, 0xef, 0x32, 0x9e, 0xb2, 0x79, 0xb8, 0x7c, 0x9e, 0x50, 0x15, 0x4f, @@ -221,18 +221,18 @@ var fileDescriptor_f3c73c95465ca7a8 = []byte{ 0xc6, 0x0b, 0xf7, 0x42, 0x8b, 0x49, 0x53, 0x93, 0x91, 0x11, 0x9f, 0x99, 0x2d, 0xb7, 0x24, 0xd3, 0xcb, 0xef, 0x3f, 0x08, 0xf0, 0x7f, 0x02, 0xd8, 0x9f, 0x51, 0x59, 0x65, 0x0a, 0xbd, 0x84, 0x57, 0x54, 0x08, 0x2e, 0xdc, 0x2b, 0x6d, 0x86, 0xb7, 0x35, 0x01, 0x4d, 0x4d, 0x1e, 0xb5, 0x86, 0x47, - 0x64, 0x7b, 0x99, 0x61, 0xc4, 0xe0, 0xad, 0xb4, 0x22, 0x49, 0xf7, 0xc2, 0xeb, 0x8d, 0xef, 0x4d, - 0x46, 0x41, 0xa7, 0x90, 0xc0, 0x8e, 0x1d, 0x3d, 0xd9, 0xd6, 0xc4, 0x69, 0x6a, 0x82, 0x8d, 0x75, - 0x47, 0x6f, 0xff, 0xa2, 0xeb, 0xdc, 0x6e, 0xfc, 0x1b, 0xc0, 0xfe, 0xbb, 0x42, 0x7e, 0xa3, 0x02, - 0xbd, 0x82, 0x83, 0x45, 0x2c, 0xbf, 0xe4, 0x5c, 0x50, 0xdd, 0xc0, 0xc0, 0xae, 0xef, 0x44, 0x6c, - 0xc3, 0xeb, 0x45, 0x2c, 0x3f, 0x70, 0x41, 0xd1, 0x1b, 0x78, 0x73, 0x6a, 0x52, 0xba, 0x3d, 0xaf, - 0x77, 0xcc, 0xdb, 0xd4, 0x64, 0xd8, 0x6d, 0xbe, 0xb3, 0xcc, 0x59, 0x80, 0x3e, 0xc2, 0x6b, 0xa1, - 0x3b, 0x93, 0xee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0x08, 0xaf, 0x85, + 0xee, 0x4c, 0xba, 0x97, 0x3a, 0xed, 0xc3, 0xff, 0xd2, 0x9a, 0x46, 0x23, 0xaf, 0xcd, 0xe9, 0x1a, + 0xdb, 0x56, 0xd3, 0x59, 0xa8, 0xfd, 0x66, 0xb2, 0x45, 0xef, 0xb7, 0x7b, 0x0c, 0x76, 0x7b, 0x0c, + 0xfe, 0xec, 0x31, 0xd8, 0x1c, 0xb0, 0xb3, 0x3b, 0x60, 0xe7, 0xd7, 0x01, 0x3b, 0x9f, 0x83, 0x94, + 0xa9, 0x45, 0x95, 0x04, 0x73, 0x9e, 0x87, 0xf1, 0x8a, 0x17, 0xf4, 0x99, 0x3e, 0xa9, 0x39, 0xcf, + 0xcc, 0xeb, 0xd7, 0x70, 0x15, 0x9a, 0xeb, 0xd4, 0x57, 0x99, 0xf4, 0x35, 0x9e, 0xfc, 0x0d, 0x00, + 0x00, 0xff, 0xff, 0xbb, 0x60, 0x5d, 0x8c, 0xb3, 0x02, 0x00, 0x00, } func (m *Substitution) Marshal() (dAtA []byte, err error) { diff --git a/x/logic/util/prolog.go b/x/logic/util/prolog.go index 94c2c3567..90f20900b 100644 --- a/x/logic/util/prolog.go +++ b/x/logic/util/prolog.go @@ -10,7 +10,6 @@ import ( "github.com/samber/lo" errorsmod "cosmossdk.io/errors" - sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -25,7 +24,7 @@ const ( // //nolint:nestif,funlen func QueryInterpreter( - ctx context.Context, i *prolog.Interpreter, query string, solutionsLimit sdkmath.Uint, + ctx context.Context, i *prolog.Interpreter, query string, solutionsLimit uint64, ) (*types.Answer, error) { p := engine.NewParser(&i.VM, strings.NewReader(query)) t, err := p.Term() @@ -34,14 +33,14 @@ func QueryInterpreter( } var env *engine.Env - count := sdkmath.ZeroUint() - envs := make([]*engine.Env, 0, sdkmath.MinUint(solutionsLimit, sdkmath.NewUint(defaultEnvCap)).Uint64()) + count := uint64(0) + envs := make([]*engine.Env, 0, min(solutionsLimit, defaultEnvCap)) _, callErr := engine.Call(&i.VM, t, func(env *engine.Env) *engine.Promise { - if count.LT(solutionsLimit) { + if count < solutionsLimit { envs = append(envs, env) } - count = count.Incr() - return engine.Bool(count.GT(solutionsLimit)) + count++ + return engine.Bool(count > solutionsLimit) }, env).Force(ctx) vars := parsedVarsToVars(p.Vars) @@ -51,7 +50,7 @@ func QueryInterpreter( } if callErr != nil { - if sdkmath.NewUint(uint64(len(results))).LT(solutionsLimit) { + if uint64(len(results)) < solutionsLimit { // error is not part of the look-ahead and should be included in the solutions if errors.Is(callErr, types.LimitExceeded) { return nil, callErr @@ -80,12 +79,12 @@ func QueryInterpreter( results = append(results, types.Result{Error: callErr.Error()}) } else { // error is part of the look-ahead, so let's consider that there's one more solution - count = count.Incr() + count++ } } return &types.Answer{ - HasMore: count.GT(solutionsLimit), + HasMore: count > solutionsLimit, Variables: vars, Results: results, }, nil diff --git a/x/logic/wasm/types.go b/x/logic/wasm/types.go index cfb025f7b..aa14304fd 100644 --- a/x/logic/wasm/types.go +++ b/x/logic/wasm/types.go @@ -1,8 +1,6 @@ package wasm import ( - sdkmath "cosmossdk.io/math" - "github.com/axone-protocol/axoned/v10/x/logic/types" ) @@ -10,9 +8,9 @@ import ( // to keep control in case of eventual breaking change in the logic module definition, and to decouple the // serialization logic. type AskQuery struct { - Program string `json:"program"` - Query string `json:"query"` - Limit *sdkmath.Uint `json:"limit"` + Program string `json:"program"` + Query string `json:"query"` + Limit uint64 `json:"limit"` } // AskResponse implements the Ask query response JSON schema in a wasm custom query purpose, it redefines the existing From d3beec4124f56419b448173c06e016fc9480cd9a Mon Sep 17 00:00:00 2001 From: ccamel Date: Tue, 22 Oct 2024 10:16:57 +0200 Subject: [PATCH 2/7] chore(logic): sweep away unused code and polish style --- x/logic/fs/filtered/fs_test.go | 4 +-- x/logic/util/pointer.go | 32 +++++--------------- x/logic/util/pointer_test.go | 55 ---------------------------------- 3 files changed, 9 insertions(+), 82 deletions(-) diff --git a/x/logic/fs/filtered/fs_test.go b/x/logic/fs/filtered/fs_test.go index b4232ef54..0fcc370b4 100644 --- a/x/logic/fs/filtered/fs_test.go +++ b/x/logic/fs/filtered/fs_test.go @@ -98,7 +98,7 @@ func TestFilteredVFS(t *testing.T) { result, err := filteredFS.Open(tc.file) Convey("then the result should be as expected", func() { - if util.IsNil(tc.wantError) { + if lo.IsNil(tc.wantError) { So(err, ShouldBeNil) stat, _ := result.Stat() @@ -117,7 +117,7 @@ func TestFilteredVFS(t *testing.T) { result, err := filteredFS.ReadFile(tc.file) Convey("Then the result should be as expected", func() { - if util.IsNil(tc.wantError) { + if lo.IsNil(tc.wantError) { So(err, ShouldBeNil) So(result, ShouldResemble, content) } else { diff --git a/x/logic/util/pointer.go b/x/logic/util/pointer.go index bfc29541a..3edd09b4f 100644 --- a/x/logic/util/pointer.go +++ b/x/logic/util/pointer.go @@ -2,36 +2,18 @@ package util import ( "reflect" - - sdkmath "cosmossdk.io/math" ) -// DerefOrDefault returns the value of the pointer if it is not nil, otherwise returns the default value. -func DerefOrDefault[T any](ptr *T, defaultValue T) T { - if ptr != nil { - return *ptr - } - return defaultValue -} - // NonZeroOrDefault returns the value of the argument if it is not nil and not zero, otherwise returns the default value. func NonZeroOrDefault[T any](v, defaultValue T) T { - v1 := reflect.ValueOf(v) - if v1.IsValid() && !v1.IsZero() { - return v + if IsZero(v) { + return defaultValue } - return defaultValue + return v } -// NonZeroOrDefaultUInt returns the value of the argument if it is not nil and not zero, otherwise returns the default value. -func NonZeroOrDefaultUInt(v *sdkmath.Uint, defaultValue sdkmath.Uint) sdkmath.Uint { - if v != nil && !v.IsZero() { - return *v - } - return defaultValue -} - -// IsNil returns true if the given value is nil, false otherwise. -func IsNil(t any) bool { - return t == nil +// IsZero returns true if the argument is nil or zero. +func IsZero[T any](v T) bool { + v1 := reflect.ValueOf(v) + return !v1.IsValid() || v1.IsZero() } diff --git a/x/logic/util/pointer_test.go b/x/logic/util/pointer_test.go index 350b0cd57..10fe94499 100644 --- a/x/logic/util/pointer_test.go +++ b/x/logic/util/pointer_test.go @@ -5,34 +5,8 @@ import ( "testing" . "github.com/smartystreets/goconvey/convey" - - sdkmath "cosmossdk.io/math" ) -func TestDerefOrDefault(t *testing.T) { - Convey("Given a pointer to an int and a default int value", t, func() { - x := 5 - ptr := &x - defaultValue := 10 - - Convey("When the pointer is not nil", func() { - result := DerefOrDefault(ptr, defaultValue) - - Convey("The result should be the value pointed to by the pointer", func() { - So(result, ShouldEqual, x) - }) - }) - - Convey("When the pointer is nil", func() { - result := DerefOrDefault(nil, defaultValue) - - Convey("The result should be the default value", func() { - So(result, ShouldEqual, defaultValue) - }) - }) - }) -} - func TestNonZeroOrDefault(t *testing.T) { Convey("Given a value", t, func() { cases := []struct { @@ -55,32 +29,3 @@ func TestNonZeroOrDefault(t *testing.T) { } }) } - -func TestNonZeroOrDefaultUInt(t *testing.T) { - Convey("Given a value", t, func() { - cases := []struct { - v *sdkmath.Uint - defaultValue sdkmath.Uint - expected sdkmath.Uint - }{ - {nil, sdkmath.ZeroUint(), sdkmath.ZeroUint()}, - { - func() *sdkmath.Uint { u := sdkmath.ZeroUint(); return &u }(), - sdkmath.NewUint(10), - sdkmath.NewUint(10), - }, - { - func() *sdkmath.Uint { u := sdkmath.NewUint(1); return &u }(), - sdkmath.ZeroUint(), - sdkmath.NewUint(1), - }, - } - for _, tc := range cases { - Convey(fmt.Sprintf("When the value is %v", tc.v), func() { - Convey(fmt.Sprintf("Then the default value %v is returned", tc.defaultValue), func() { - So(NonZeroOrDefaultUInt(tc.v, tc.defaultValue), ShouldEqual, tc.expected) - }) - }) - } - }) -} From e251641d808f920cfd032180694bfe6c9d645e7f Mon Sep 17 00:00:00 2001 From: ccamel Date: Tue, 22 Oct 2024 21:00:56 +0200 Subject: [PATCH 3/7] docs(logic): generate documentation for v1beta3 version --- docs/command/axoned_tx_logic_update-params.md | 2 +- docs/predicate/bech32_address_2.md | 14 +- docs/predicate/block_height_1.md | 4 +- docs/predicate/block_time_1.md | 4 +- docs/predicate/consult_1.md | 6 +- docs/predicate/current_output_1.md | 8 +- docs/predicate/open_3.md | 2 +- docs/predicate/open_4.md | 14 +- docs/proto/logic.md | 148 +++++++++--------- 9 files changed, 101 insertions(+), 101 deletions(-) diff --git a/docs/command/axoned_tx_logic_update-params.md b/docs/command/axoned_tx_logic_update-params.md index 08bb8b69f..f584dbfca 100644 --- a/docs/command/axoned_tx_logic_update-params.md +++ b/docs/command/axoned_tx_logic_update-params.md @@ -30,7 +30,7 @@ axoned tx logic update-params [flags] --note string Note to add a description to the transaction (previously --memo) --offline Offline mode (does not allow any online functionality) -o, --output string Output format (text|json) (default "json") - --params logic.v1beta2.Params (json) + --params logic.v1beta3.Params (json) -s, --sequence uint The sequence number of the signing account (offline mode only) --sign-mode string Choose sign mode (direct|amino-json|direct-aux|textual), this is an advanced feature --timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height diff --git a/docs/predicate/bech32_address_2.md b/docs/predicate/bech32_address_2.md index 23f93e8bf..bfb46e2f3 100644 --- a/docs/predicate/bech32_address_2.md +++ b/docs/predicate/bech32_address_2.md @@ -43,7 +43,7 @@ bech32_address(Address, 'axone15wn30a9z4uc692s0kkx5fp5d4qfr3ac77gvjg4'). ``` yaml height: 42 -gas_used: 3612 +gas_used: 3975 answer: has_more: false variables: ["Address"] @@ -72,7 +72,7 @@ bech32_address(-(Hrp, Address), 'axone15wn30a9z4uc692s0kkx5fp5d4qfr3ac77gvjg4'). ``` yaml height: 42 -gas_used: 3612 +gas_used: 3975 answer: has_more: false variables: ["Hrp", "Address"] @@ -102,7 +102,7 @@ bech32_address(-(axone, Address), 'axone15wn30a9z4uc692s0kkx5fp5d4qfr3ac77gvjg4' ``` yaml height: 42 -gas_used: 3612 +gas_used: 3975 answer: has_more: false variables: ["Address"] @@ -129,7 +129,7 @@ bech32_address(-('axone', [163,167,23,244,162,175,49,162,170,15,181,141,68,134,1 ``` yaml height: 42 -gas_used: 3612 +gas_used: 3975 answer: has_more: false variables: ["Bech32"] @@ -162,7 +162,7 @@ axone_addr('axone1p8u47en82gmzfm259y6z93r9qe63l25d858vqu'). ``` yaml height: 42 -gas_used: 3613 +gas_used: 3976 answer: has_more: false results: @@ -188,7 +188,7 @@ bech32_address(Address, axoneincorrect). ``` yaml height: 42 -gas_used: 3612 +gas_used: 3975 answer: has_more: false variables: ["Address"] @@ -215,7 +215,7 @@ bech32_address(-('axone', X), foo(bar)). ``` yaml height: 42 -gas_used: 3612 +gas_used: 3975 answer: has_more: false variables: ["X"] diff --git a/docs/predicate/block_height_1.md b/docs/predicate/block_height_1.md index f82eaf4c3..99e55933b 100644 --- a/docs/predicate/block_height_1.md +++ b/docs/predicate/block_height_1.md @@ -44,7 +44,7 @@ block_height(Height). ``` yaml height: 100 -gas_used: 3612 +gas_used: 3975 answer: has_more: false variables: ["Height"] @@ -79,7 +79,7 @@ Height > 100. ``` yaml height: 101 -gas_used: 3613 +gas_used: 3976 answer: has_more: false variables: ["Height"] diff --git a/docs/predicate/block_time_1.md b/docs/predicate/block_time_1.md index 967905056..16a1cffe7 100644 --- a/docs/predicate/block_time_1.md +++ b/docs/predicate/block_time_1.md @@ -44,7 +44,7 @@ block_time(Time). ``` yaml height: 42 -gas_used: 3612 +gas_used: 3975 answer: has_more: false variables: ["Time"] @@ -80,7 +80,7 @@ Time > 1709550216. ``` yaml height: 42 -gas_used: 3613 +gas_used: 3976 answer: has_more: false variables: ["Time"] diff --git a/docs/predicate/consult_1.md b/docs/predicate/consult_1.md index 02b8bb355..a6087a806 100644 --- a/docs/predicate/consult_1.md +++ b/docs/predicate/consult_1.md @@ -65,7 +65,7 @@ hello(Who). ``` yaml height: 42 -gas_used: 3615 +gas_used: 3978 answer: has_more: false variables: ["Who"] @@ -129,7 +129,7 @@ response: | ``` yaml height: 42 -gas_used: 3614 +gas_used: 3977 answer: has_more: false variables: ["X"] @@ -194,7 +194,7 @@ source_file(File). ``` yaml height: 42 -gas_used: 3613 +gas_used: 3976 answer: has_more: false variables: ["File"] diff --git a/docs/predicate/current_output_1.md b/docs/predicate/current_output_1.md index 908dc4369..ff476678e 100644 --- a/docs/predicate/current_output_1.md +++ b/docs/predicate/current_output_1.md @@ -61,7 +61,7 @@ write_char_to_user_output(x). ``` yaml height: 42 -gas_used: 3680 +gas_used: 4043 answer: has_more: false variables: @@ -108,7 +108,7 @@ log_message('Hello world!'). ``` yaml height: 42 -gas_used: 3682 +gas_used: 4045 answer: has_more: false variables: @@ -155,7 +155,7 @@ log_message('Hello world!'). ``` yaml height: 42 -gas_used: 3681 +gas_used: 4044 answer: has_more: false variables: @@ -205,7 +205,7 @@ log_message("Hello 🧙!"). ``` yaml height: 42 -gas_used: 3702 +gas_used: 4065 answer: has_more: false variables: diff --git a/docs/predicate/open_3.md b/docs/predicate/open_3.md index 251ebf5ad..4b212d0b7 100644 --- a/docs/predicate/open_3.md +++ b/docs/predicate/open_3.md @@ -62,7 +62,7 @@ open( ``` yaml height: 42 -gas_used: 3613 +gas_used: 3976 answer: has_more: false variables: diff --git a/docs/predicate/open_4.md b/docs/predicate/open_4.md index 79a2e23c0..6915daeff 100644 --- a/docs/predicate/open_4.md +++ b/docs/predicate/open_4.md @@ -100,7 +100,7 @@ open(URI, read, _, []). ``` yaml height: 42 -gas_used: 3625 +gas_used: 3988 answer: has_more: false variables: ["URI"] @@ -152,7 +152,7 @@ read_resource('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08x ``` yaml height: 42 -gas_used: 3616 +gas_used: 3979 answer: has_more: false variables: ["Chars"] @@ -202,7 +202,7 @@ read_resource('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08x ``` yaml height: 42 -gas_used: 3616 +gas_used: 3979 answer: has_more: false variables: ["Chars"] @@ -229,7 +229,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t ``` yaml height: 42 -gas_used: 3612 +gas_used: 3975 answer: has_more: false variables: ["Stream"] @@ -255,7 +255,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t ``` yaml height: 42 -gas_used: 3612 +gas_used: 3975 answer: has_more: false variables: ["Stream"] @@ -281,7 +281,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t ``` yaml height: 42 -gas_used: 3612 +gas_used: 3975 answer: has_more: false variables: ["Stream"] @@ -306,7 +306,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t ``` yaml height: 42 -gas_used: 3612 +gas_used: 3975 answer: has_more: false variables: ["Stream"] diff --git a/docs/proto/logic.md b/docs/proto/logic.md index 9c00abc91..3e64f3b91 100644 --- a/docs/proto/logic.md +++ b/docs/proto/logic.md @@ -193,44 +193,44 @@ utilized within a query, or limiting the depth of the backtracking algorithm. ## Table of Contents -- [logic/v1beta2/params.proto](#logic/v1beta2/params.proto) - - [Filter](#logic.v1beta2.Filter) - - [GasPolicy](#logic.v1beta2.GasPolicy) - - [Interpreter](#logic.v1beta2.Interpreter) - - [Limits](#logic.v1beta2.Limits) - - [Params](#logic.v1beta2.Params) - - [PredicateCost](#logic.v1beta2.PredicateCost) +- [logic/v1beta3/params.proto](#logic/v1beta3/params.proto) + - [Filter](#logic.v1beta3.Filter) + - [GasPolicy](#logic.v1beta3.GasPolicy) + - [Interpreter](#logic.v1beta3.Interpreter) + - [Limits](#logic.v1beta3.Limits) + - [Params](#logic.v1beta3.Params) + - [PredicateCost](#logic.v1beta3.PredicateCost) -- [logic/v1beta2/genesis.proto](#logic/v1beta2/genesis.proto) - - [GenesisState](#logic.v1beta2.GenesisState) +- [logic/v1beta3/genesis.proto](#logic/v1beta3/genesis.proto) + - [GenesisState](#logic.v1beta3.GenesisState) -- [logic/v1beta2/types.proto](#logic/v1beta2/types.proto) - - [Answer](#logic.v1beta2.Answer) - - [Result](#logic.v1beta2.Result) - - [Substitution](#logic.v1beta2.Substitution) +- [logic/v1beta3/types.proto](#logic/v1beta3/types.proto) + - [Answer](#logic.v1beta3.Answer) + - [Result](#logic.v1beta3.Result) + - [Substitution](#logic.v1beta3.Substitution) -- [logic/v1beta2/query.proto](#logic/v1beta2/query.proto) - - [QueryServiceAskRequest](#logic.v1beta2.QueryServiceAskRequest) - - [QueryServiceAskResponse](#logic.v1beta2.QueryServiceAskResponse) - - [QueryServiceParamsRequest](#logic.v1beta2.QueryServiceParamsRequest) - - [QueryServiceParamsResponse](#logic.v1beta2.QueryServiceParamsResponse) +- [logic/v1beta3/query.proto](#logic/v1beta3/query.proto) + - [QueryServiceAskRequest](#logic.v1beta3.QueryServiceAskRequest) + - [QueryServiceAskResponse](#logic.v1beta3.QueryServiceAskResponse) + - [QueryServiceParamsRequest](#logic.v1beta3.QueryServiceParamsRequest) + - [QueryServiceParamsResponse](#logic.v1beta3.QueryServiceParamsResponse) - - [QueryService](#logic.v1beta2.QueryService) + - [QueryService](#logic.v1beta3.QueryService) -- [logic/v1beta2/tx.proto](#logic/v1beta2/tx.proto) - - [MsgUpdateParams](#logic.v1beta2.MsgUpdateParams) - - [MsgUpdateParamsResponse](#logic.v1beta2.MsgUpdateParamsResponse) +- [logic/v1beta3/tx.proto](#logic/v1beta3/tx.proto) + - [MsgUpdateParams](#logic.v1beta3.MsgUpdateParams) + - [MsgUpdateParamsResponse](#logic.v1beta3.MsgUpdateParamsResponse) - - [MsgService](#logic.v1beta2.MsgService) + - [MsgService](#logic.v1beta3.MsgService) - [Scalar Value Types](#scalar-value-types) - +

Top

-## logic/v1beta2/params.proto +## logic/v1beta3/params.proto - + ### Filter @@ -242,7 +242,7 @@ The filter is used to whitelist or blacklist strings. | `whitelist` | [string](#string) | repeated | whitelist specifies a list of strings that are allowed. If this field is not specified, all strings (in the context of the filter) are allowed. | | `blacklist` | [string](#string) | repeated | blacklist specifies a list of strings that are excluded from the set of allowed strings. If a string is included in both whitelist and blacklist, it will be excluded. This means that blacklisted strings prevails over whitelisted ones. If this field is not specified, no strings are excluded. | - + ### GasPolicy @@ -252,11 +252,11 @@ if not specified in the list, and a weighting factor that is applied to the unit | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `weighting_factor` | [string](#string) | | WeightingFactor is the factor that is applied to the unit cost of each predicate to yield the gas value. If not provided or set to 0, the value is set to 1. | -| `default_predicate_cost` | [string](#string) | | DefaultPredicateCost is the default unit cost of a predicate when not specified in the PredicateCosts list. If not provided or set to 0, the value is set to 1. | -| `predicate_costs` | [PredicateCost](#logic.v1beta2.PredicateCost) | repeated | PredicateCosts is the list of predicates and their associated unit costs. | +| `weighting_factor` | [uint64](#uint64) | | WeightingFactor is the factor that is applied to the unit cost of each predicate to yield the gas value. If set to 0, the value considered is 1. | +| `default_predicate_cost` | [uint64](#uint64) | | DefaultPredicateCost is the default unit cost of a predicate when not specified in the PredicateCosts list. If set to 0, the value considered is 1. | +| `predicate_costs` | [PredicateCost](#logic.v1beta3.PredicateCost) | repeated | PredicateCosts is the list of predicates and their associated unit costs. | - + ### Interpreter @@ -264,11 +264,11 @@ Interpreter defines the various parameters for the interpreter. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `predicates_filter` | [Filter](#logic.v1beta2.Filter) | | predicates_filter specifies the filter for the predicates that are allowed to be used by the interpreter. The filter is used to whitelist or blacklist predicates represented as `/[]`, for example: `findall/3`, or `call`. If a predicate name without arity is included in the filter, then all predicates with that name will be considered regardless of arity. For example, if `call` is included in the filter, then all predicates `call/1`, `call/2`, `call/3`... will be allowed. | +| `predicates_filter` | [Filter](#logic.v1beta3.Filter) | | predicates_filter specifies the filter for the predicates that are allowed to be used by the interpreter. The filter is used to whitelist or blacklist predicates represented as `/[]`, for example: `findall/3`, or `call`. If a predicate name without arity is included in the filter, then all predicates with that name will be considered regardless of arity. For example, if `call` is included in the filter, then all predicates `call/1`, `call/2`, `call/3`... will be allowed. | | `bootstrap` | [string](#string) | | bootstrap specifies the initial program to run when booting the logic interpreter. If not specified, the default boot sequence will be executed. | -| `virtual_files_filter` | [Filter](#logic.v1beta2.Filter) | | virtual_files_filter specifies the filter for the virtual files that are allowed to be used by the interpreter. The filter is used to whitelist or blacklist virtual files represented as URI, for example: `file:///path/to/file`, `cosmwasm:cw-storage:axone...?query=foo` The filter is applied to the components of the URI, for example: `file:///path/to/file` -> `file`, `/path/to/file` `cosmwasm:cw-storage:axone...?query=foo` -> `cosmwasm`, `cw-storage`, `axone...`, `query=foo` If a component is included in the filter, then all components with that name will be considered, starting from the beginning of the URI. For example, if `file` is included in the filter, then all URIs that start with `file` will be allowed, regardless of the rest of the components. But `file2` will not be allowed. If the component is not included in the filter, then the component is ignored and the next component is considered. | +| `virtual_files_filter` | [Filter](#logic.v1beta3.Filter) | | virtual_files_filter specifies the filter for the virtual files that are allowed to be used by the interpreter. The filter is used to whitelist or blacklist virtual files represented as URI, for example: `file:///path/to/file`, `cosmwasm:cw-storage:axone...?query=foo` The filter is applied to the components of the URI, for example: `file:///path/to/file` -> `file`, `/path/to/file` `cosmwasm:cw-storage:axone...?query=foo` -> `cosmwasm`, `cw-storage`, `axone...`, `query=foo` If a component is included in the filter, then all components with that name will be considered, starting from the beginning of the URI. For example, if `file` is included in the filter, then all URIs that start with `file` will be allowed, regardless of the rest of the components. But `file2` will not be allowed. If the component is not included in the filter, then the component is ignored and the next component is considered. | - + ### Limits @@ -276,12 +276,12 @@ Limits defines the limits of the logic module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `max_size` | [string](#string) | | max_size specifies the maximum size, in bytes, that is accepted for a program. nil value or 0 value remove size limitation. | -| `max_result_count` | [string](#string) | | max_result_count specifies the maximum number of results that can be requested for a query. nil value or 0 value remove max result count limitation. | -| `max_user_output_size` | [string](#string) | | max_user_output_size specifies the maximum number of bytes to keep in the user output. If the user output exceeds this size, the interpreter will overwrite the oldest bytes with the new ones to keep the size constant. nil value or 0 value means that no user output is used at all. | -| `max_variables` | [string](#string) | | max_variables specifies the maximum number of variables that can be create by the interpreter. nil value or 0 value means that no limit is set. | +| `max_size` | [uint64](#uint64) | | max_size specifies the maximum size, in bytes, that is accepted for a program. A value of 0 means that there is no limit on the size of the program. | +| `max_result_count` | [uint64](#uint64) | | max_result_count specifies the maximum number of results that can be requested for a query. A value of 0 means that there is no limit on the number of results. | +| `max_user_output_size` | [uint64](#uint64) | | max_user_output_size specifies the maximum number of bytes to keep in the user output. If the user output exceeds this size, the interpreter will overwrite the oldest bytes with the new ones to keep the size constant. A value of 0 means the user output is disabled. | +| `max_variables` | [uint64](#uint64) | | max_variables specifies the maximum number of variables that can be create by the interpreter. A value of 0 means that there is no limit on the number of variables. | - + ### Params @@ -289,11 +289,11 @@ Params defines all the configuration parameters of the "logic" module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `interpreter` | [Interpreter](#logic.v1beta2.Interpreter) | | Interpreter specifies the parameter for the logic interpreter. | -| `limits` | [Limits](#logic.v1beta2.Limits) | | Limits defines the limits of the logic module. The limits are used to prevent the interpreter from running for too long. If the interpreter runs for too long, the execution will be aborted. | -| `gas_policy` | [GasPolicy](#logic.v1beta2.GasPolicy) | | GasPolicy defines the parameters for calculating predicate invocation costs. | +| `interpreter` | [Interpreter](#logic.v1beta3.Interpreter) | | Interpreter specifies the parameter for the logic interpreter. | +| `limits` | [Limits](#logic.v1beta3.Limits) | | Limits defines the limits of the logic module. The limits are used to prevent the interpreter from running for too long. If the interpreter runs for too long, the execution will be aborted. | +| `gas_policy` | [GasPolicy](#logic.v1beta3.GasPolicy) | | GasPolicy defines the parameters for calculating predicate invocation costs. | - + ### PredicateCost @@ -302,7 +302,7 @@ PredicateCost defines the unit cost of a predicate during its invocation by the | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `predicate` | [string](#string) | | Predicate is the name of the predicate, optionally followed by its arity (e.g. "findall/3"). If no arity is specified, the unit cost is applied to all predicates with the same name. | -| `cost` | [string](#string) | | Cost is the unit cost of the predicate. | +| `cost` | [uint64](#uint64) | | Cost is the unit cost of the predicate. If set to 0, the value considered is 1. | [//]: # (end messages) @@ -312,12 +312,12 @@ PredicateCost defines the unit cost of a predicate during its invocation by the [//]: # (end services) - +

Top

-## logic/v1beta2/genesis.proto +## logic/v1beta3/genesis.proto - + ### GenesisState @@ -325,7 +325,7 @@ GenesisState defines the logic module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#logic.v1beta2.Params) | | The state parameters for the logic module. | +| `params` | [Params](#logic.v1beta3.Params) | | The state parameters for the logic module. | [//]: # (end messages) @@ -335,12 +335,12 @@ GenesisState defines the logic module's genesis state. [//]: # (end services) - +

Top

-## logic/v1beta2/types.proto +## logic/v1beta3/types.proto - + ### Answer @@ -350,9 +350,9 @@ Answer represents the answer to a logic query. | ----- | ---- | ----- | ----------- | | `has_more` | [bool](#bool) | | has_more specifies if there are more solutions than the ones returned. | | `variables` | [string](#string) | repeated | variables represent all the variables in the query. | -| `results` | [Result](#logic.v1beta2.Result) | repeated | results represent all the results of the query. | +| `results` | [Result](#logic.v1beta3.Result) | repeated | results represent all the results of the query. | - + ### Result @@ -361,9 +361,9 @@ Result represents the result of a query. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `error` | [string](#string) | | error specifies the error message if the query caused an error. | -| `substitutions` | [Substitution](#logic.v1beta2.Substitution) | repeated | substitutions represent all the substitutions made to the variables in the query to obtain the answer. | +| `substitutions` | [Substitution](#logic.v1beta3.Substitution) | repeated | substitutions represent all the substitutions made to the variables in the query to obtain the answer. | - + ### Substitution @@ -382,12 +382,12 @@ Substitution represents a substitution made to the variables in the query to obt [//]: # (end services) - +

Top

-## logic/v1beta2/query.proto +## logic/v1beta3/query.proto - + ### QueryServiceAskRequest @@ -397,9 +397,9 @@ QueryServiceAskRequest is request type for the QueryService/Ask RPC method. | ----- | ---- | ----- | ----------- | | `program` | [string](#string) | | program is the logic program to be queried. | | `query` | [string](#string) | | query is the query string to be executed. | -| `limit` | [string](#string) | | limit specifies the maximum number of solutions to be returned. This field is governed by max_result_count, which defines the upper limit of results that may be requested per query. If this field is not explicitly set, a default value of 1 is applied. | +| `limit` | [uint64](#uint64) | | limit specifies the maximum number of solutions to be returned. This field is governed by max_result_count, which defines the upper limit of results that may be requested per query. If this field is not explicitly set, a default value of 1 is applied. | - + ### QueryServiceAskResponse @@ -409,16 +409,16 @@ QueryServiceAskResponse is response type for the QueryService/Ask RPC method. | ----- | ---- | ----- | ----------- | | `height` | [uint64](#uint64) | | height is the block height at which the query was executed. | | `gas_used` | [uint64](#uint64) | | gas_used is the amount of gas used to execute the query. | -| `answer` | [Answer](#logic.v1beta2.Answer) | | answer is the answer to the query. | +| `answer` | [Answer](#logic.v1beta3.Answer) | | answer is the answer to the query. | | `user_output` | [string](#string) | | user_output is the output of the query execution, if any. the length of the output is limited by the max_query_output_size parameter. | - + ### QueryServiceParamsRequest QueryServiceParamsRequest is request type for the QueryService/Params RPC method. - + ### QueryServiceParamsResponse @@ -426,7 +426,7 @@ QueryServiceParamsResponse is response type for the QueryService/Params RPC meth | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#logic.v1beta2.Params) | | params holds all the parameters of this module. | +| `params` | [Params](#logic.v1beta3.Params) | | params holds all the parameters of this module. | [//]: # (end messages) @@ -434,7 +434,7 @@ QueryServiceParamsResponse is response type for the QueryService/Params RPC meth [//]: # (end HasExtensions) - + ### QueryService @@ -442,17 +442,17 @@ QueryService defines the gRPC querier service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Params` | [QueryServiceParamsRequest](#logic.v1beta2.QueryServiceParamsRequest) | [QueryServiceParamsResponse](#logic.v1beta2.QueryServiceParamsResponse) | Params queries all parameters for the logic module. | GET|/axone-protocol/axoned/logic/params| -| `Ask` | [QueryServiceAskRequest](#logic.v1beta2.QueryServiceAskRequest) | [QueryServiceAskResponse](#logic.v1beta2.QueryServiceAskResponse) | Ask executes a logic query and returns the solutions found. Since the query is without any side-effect, the query is not executed in the context of a transaction and no fee is charged for this, but the execution is constrained by the current limits configured in the module. | GET|/axone-protocol/axoned/logic/ask| +| `Params` | [QueryServiceParamsRequest](#logic.v1beta3.QueryServiceParamsRequest) | [QueryServiceParamsResponse](#logic.v1beta3.QueryServiceParamsResponse) | Params queries all parameters for the logic module. | GET|/axone-protocol/axoned/logic/params| +| `Ask` | [QueryServiceAskRequest](#logic.v1beta3.QueryServiceAskRequest) | [QueryServiceAskResponse](#logic.v1beta3.QueryServiceAskResponse) | Ask executes a logic query and returns the solutions found. Since the query is without any side-effect, the query is not executed in the context of a transaction and no fee is charged for this, but the execution is constrained by the current limits configured in the module. | GET|/axone-protocol/axoned/logic/ask| [//]: # (end services) - +

Top

-## logic/v1beta2/tx.proto +## logic/v1beta3/tx.proto - + ### MsgUpdateParams @@ -461,9 +461,9 @@ MsgUpdateParams defines a Msg for updating the x/logic module parameters. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `authority` | [string](#string) | | authority is the address of the governance account. | -| `params` | [Params](#logic.v1beta2.Params) | | params defines the x/logic parameters to update. NOTE: All parameters must be supplied. | +| `params` | [Params](#logic.v1beta3.Params) | | params defines the x/logic parameters to update. NOTE: All parameters must be supplied. | - + ### MsgUpdateParamsResponse @@ -476,7 +476,7 @@ MsgUpdateParams message. [//]: # (end HasExtensions) - + ### MsgService @@ -485,7 +485,7 @@ Do nothing for now as the service is without any side effects. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `UpdateParams` | [MsgUpdateParams](#logic.v1beta2.MsgUpdateParams) | [MsgUpdateParamsResponse](#logic.v1beta2.MsgUpdateParamsResponse) | UpdateParams defined a governance operation for updating the x/logic module parameters. The authority is hard-coded to the Cosmos SDK x/gov module account | | +| `UpdateParams` | [MsgUpdateParams](#logic.v1beta3.MsgUpdateParams) | [MsgUpdateParamsResponse](#logic.v1beta3.MsgUpdateParamsResponse) | UpdateParams defined a governance operation for updating the x/logic module parameters. The authority is hard-coded to the Cosmos SDK x/gov module account | | [//]: # (end services) From 84d6ead192fcad06169375355564242846054898 Mon Sep 17 00:00:00 2001 From: ccamel Date: Tue, 22 Oct 2024 21:36:46 +0200 Subject: [PATCH 4/7] test(logic): increase keeper test coverage --- x/logic/keeper/grpc_query_ask_test.go | 27 ++++++++++++++++++++++++ x/logic/keeper/grpc_query_params_test.go | 27 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/x/logic/keeper/grpc_query_ask_test.go b/x/logic/keeper/grpc_query_ask_test.go index e854e1c49..b7c636588 100644 --- a/x/logic/keeper/grpc_query_ask_test.go +++ b/x/logic/keeper/grpc_query_ask_test.go @@ -471,4 +471,31 @@ func TestGRPCAsk(t *testing.T) { }) } }) + + Convey("Given a keeper", t, func() { + encCfg := moduletestutil.MakeTestEncodingConfig(logic.AppModuleBasic{}) + key := storetypes.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) + + logicKeeper := keeper.NewKeeper( + encCfg.Codec, + encCfg.InterfaceRegistry, + key, + key, + authtypes.NewModuleAddress(govtypes.ModuleName), + nil, + nil, + nil, + nil) + + Convey("When the query ask is called with a nil query", func() { + response, err := logicKeeper.Ask(testCtx.Ctx, nil) + + Convey("Then it should return an error", func() { + So(err, ShouldNotBeNil) + So(err.Error(), ShouldEqual, "request is nil: invalid argument") + So(response, ShouldBeNil) + }) + }) + }) } diff --git a/x/logic/keeper/grpc_query_params_test.go b/x/logic/keeper/grpc_query_params_test.go index f7a5cc682..df3697361 100644 --- a/x/logic/keeper/grpc_query_params_test.go +++ b/x/logic/keeper/grpc_query_params_test.go @@ -96,4 +96,31 @@ func TestGRPCParams(t *testing.T) { }) } }) + + Convey("Given a keeper", t, func() { + encCfg := moduletestutil.MakeTestEncodingConfig(logic.AppModuleBasic{}) + key := storetypes.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) + + logicKeeper := keeper.NewKeeper( + encCfg.Codec, + encCfg.InterfaceRegistry, + key, + key, + authtypes.NewModuleAddress(govtypes.ModuleName), + nil, + nil, + nil, + nil) + + Convey("When the query params is called with a nil query", func() { + params, err := logicKeeper.Params(testCtx.Ctx, nil) + + Convey("Then it should return an error", func() { + So(err, ShouldNotBeNil) + So(err.Error(), ShouldEqual, "rpc error: code = InvalidArgument desc = invalid request") + So(params, ShouldBeNil) + }) + }) + }) } From ee6ec60c3df497b8c5e30293da528ea24ae25dc6 Mon Sep 17 00:00:00 2001 From: ccamel Date: Wed, 23 Oct 2024 12:05:53 +0200 Subject: [PATCH 5/7] build(project): fix chain-migration target (cosmovisor & co) --- Makefile | 48 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 4eed50ff0..8fc043f4d 100644 --- a/Makefile +++ b/Makefile @@ -236,7 +236,7 @@ chain-stop: ## Stop the blockchain @echo "${COLOR_CYAN} ✋️ Stopping chain ${COLOR_RESET}${CHAIN}${COLOR_CYAN} with configuration ${COLOR_YELLOW}${CHAIN_HOME}${COLOR_RESET}" @killall axoned -chain-upgrade: build ## Test the chain upgrade from the given FROM_VERSION to the given TO_VERSION. You can pass also the proposal json file on PROPOSAL var +chain-upgrade: build ## Test the chain upgrade from the given FROM_VERSION to the given TO_VERSION. @echo "${COLOR_CYAN} ⬆️ Upgrade the chain ${COLOR_RESET}${CHAIN}${COLOR_CYAN} from ${COLOR_YELLOW}${FROM_VERSION}${COLOR_RESET}${COLOR_CYAN} to ${COLOR_YELLOW}${TO_VERSION}${COLOR_RESET}" @killall cosmovisor || \ rm -rf ${TARGET_FOLDER}/${FROM_VERSION}; \ @@ -249,40 +249,31 @@ chain-upgrade: build ## Test the chain upgrade from the given FROM_VERSION to th echo $$BINARY_OLD; \ make chain-init CHAIN_BINARY=$$BINARY_OLD; \ \ - echo "${COLOR_CYAN} 👩‍🚀 Prepare cosmovisor ${COLOR_RESET}"; \ + echo "${COLOR_CYAN} 👩‍🚀 Preparing cosmovisor ${COLOR_RESET}"; \ export DAEMON_NAME=${DAEMON_NAME}; \ export DAEMON_HOME=${DAEMON_HOME}; \ \ - PROPOSAL=${PROPOSAL}; \ - if [[ ! -f "$$PROPOSAL" ]]; then \ - echo "${COLOR_CYAN} 👩‍🚀 No proposal given ${COLOR_RESET}"; \ - echo '{"messages": [{"@type": "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade","authority": "axone10d07y265gmmuvt4z0w9aw880jnsr700jh7kd2g","plan": {"name": "","time": "0001-01-01T00:00:00Z","height": "10","info": "","upgraded_client_state": null}}],"title": "Software update", "summary": "Update the binary", "metadata": "ipfs://CID","deposit": "1uaxone"}' | \ - jq --arg name "${TO_VERSION}" '.messages[].plan.name = $$name' > ${TARGET_FOLDER}/proposal.json; \ - PROPOSAL=${TARGET_FOLDER}/proposal.json; \ - fi; \ - cat <<< $$(jq '.app_state.gov.params.voting_period = "30s"' ${CHAIN_HOME}/config/genesis.json) > ${CHAIN_HOME}/config/genesis.json; \ + cat <<< $$(jq '.app_state.gov.params.voting_period = "20s"' ${CHAIN_HOME}/config/genesis.json) > ${CHAIN_HOME}/config/genesis.json; \ \ cosmovisor init $$BINARY_OLD; \ cosmovisor run start --moniker ${CHAIN_MONIKER} \ --home ${CHAIN_HOME} \ --log_level debug & \ - sleep 10;\ - $$BINARY_OLD tx gov submit-proposal $$PROPOSAL \ - --from validator \ - --yes \ - --home ${CHAIN_HOME} \ - --chain-id axone-${CHAIN} \ - --keyring-backend test \ - -b sync; \ - \ - sleep 5;\ - $$BINARY_OLD tx gov deposit 1 10000000uaxone \ - --from validator \ - --yes \ - --home ${CHAIN_HOME} \ - --chain-id axone-${CHAIN} \ - --keyring-backend test \ - -b sync; \ + sleep 10; \ + echo "${COLOR_CYAN} 🗳️ Submitting software-upgrade tx ${COLOR_RESET}"; \ + $$BINARY_OLD tx upgrade software-upgrade ${TO_VERSION}\ + --title "Axoned upgrade" \ + --summary "⬆️ Upgrade the chain from ${FROM_VERSION} to ${TO_VERSION}" \ + --upgrade-height 20 \ + --upgrade-info "{}" \ + --deposit 10000000uaxone \ + --no-validate \ + --yes \ + --from validator \ + --keyring-backend test \ + --chain-id axone-${CHAIN} \ + --home ${CHAIN_HOME}; \ + sleep 5;\ \ sleep 5;\ $$BINARY_OLD tx gov vote 1 yes \ @@ -290,8 +281,7 @@ chain-upgrade: build ## Test the chain upgrade from the given FROM_VERSION to th --yes \ --home ${CHAIN_HOME} \ --chain-id axone-${CHAIN} \ - --keyring-backend test \ - -b sync; \ + --keyring-backend test; \ mkdir -p ${DAEMON_HOME}/cosmovisor/upgrades/${TO_VERSION}/bin && cp ${CHAIN_BINARY} ${DAEMON_HOME}/cosmovisor/upgrades/${TO_VERSION}/bin; \ wait From da93e8146a2fe127d43a5f1f886e78b1b077b890 Mon Sep 17 00:00:00 2001 From: ccamel Date: Tue, 22 Oct 2024 20:57:03 +0200 Subject: [PATCH 6/7] feat(logic): implement chain migration to v11 --- app/app.go | 4 +- app/upgrades.go | 25 +- app/upgrades/v7/upgrade.go | 20 - go.mod | 1 + x/logic/keeper/migrations.go | 70 + x/logic/keeper/migrations_test.go | 166 ++ x/logic/legacy/v1beta2/types/genesis.pb.go | 322 ++++ x/logic/legacy/v1beta2/types/params.go | 7 + x/logic/legacy/v1beta2/types/params.pb.go | 1862 ++++++++++++++++++++ x/logic/legacy/v1beta2/types/query.pb.go | 1184 +++++++++++++ x/logic/legacy/v1beta2/types/tx.pb.go | 594 +++++++ x/logic/legacy/v1beta2/types/types.pb.go | 901 ++++++++++ x/logic/module.go | 6 +- 13 files changed, 5132 insertions(+), 30 deletions(-) delete mode 100644 app/upgrades/v7/upgrade.go create mode 100644 x/logic/keeper/migrations.go create mode 100644 x/logic/keeper/migrations_test.go create mode 100644 x/logic/legacy/v1beta2/types/genesis.pb.go create mode 100644 x/logic/legacy/v1beta2/types/params.go create mode 100644 x/logic/legacy/v1beta2/types/params.pb.go create mode 100644 x/logic/legacy/v1beta2/types/query.pb.go create mode 100644 x/logic/legacy/v1beta2/types/tx.pb.go create mode 100644 x/logic/legacy/v1beta2/types/types.pb.go diff --git a/app/app.go b/app/app.go index 2a9eba086..310edeabd 100644 --- a/app/app.go +++ b/app/app.go @@ -814,9 +814,9 @@ func New( panic(err) } - // RegisterUpgradeHandlers is used for registering any on-chain upgrades. + // registerUpgradeHandlers is used for registering any on-chain upgrades. // Make sure it's called after `app.ModuleManager` and `app.configurator` are set. - app.RegisterUpgradeHandlers() + app.registerUpgradeHandlers() autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.ModuleManager.Modules)) reflectionSvc, err := runtimeservices.NewReflectionService() diff --git a/app/upgrades.go b/app/upgrades.go index bb5d1657a..ea8b1c4da 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -1,17 +1,28 @@ package app import ( + "context" "fmt" - v7 "github.com/axone-protocol/axoned/v10/app/upgrades/v7" + upgradetypes "cosmossdk.io/x/upgrade/types" + + "github.com/cosmos/cosmos-sdk/types/module" ) -// RegisterUpgradeHandlers registers the chain upgrade handlers. -func (app *App) RegisterUpgradeHandlers() { - app.UpgradeKeeper.SetUpgradeHandler( - v7.UpgradeName, - v7.CreateUpgradeHandler(app.ModuleManager, app.configurator), - ) +var upgrades = []string{ + "v11.0.0", +} + +// registerUpgradeHandlers registers the chain upgrade handlers. +func (app *App) registerUpgradeHandlers() { + for _, upgrade := range upgrades { + app.UpgradeKeeper.SetUpgradeHandler( + upgrade, + func(ctx context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + return app.ModuleManager.RunMigrations(ctx, app.configurator, vm) + }, + ) + } upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { diff --git a/app/upgrades/v7/upgrade.go b/app/upgrades/v7/upgrade.go deleted file mode 100644 index 036d8346f..000000000 --- a/app/upgrades/v7/upgrade.go +++ /dev/null @@ -1,20 +0,0 @@ -package v7 - -import ( - "context" - - upgradetypes "cosmossdk.io/x/upgrade/types" - - "github.com/cosmos/cosmos-sdk/types/module" -) - -var UpgradeName = "v7.0.0" - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, -) upgradetypes.UpgradeHandler { - return func(ctx context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { - return mm.RunMigrations(ctx, configurator, vm) - } -} diff --git a/go.mod b/go.mod index 54128f91c..b64fa3fbb 100644 --- a/go.mod +++ b/go.mod @@ -41,6 +41,7 @@ require ( github.com/huandu/xstrings v1.5.0 github.com/hyperledger/aries-framework-go v0.3.2 github.com/ignite/cli v0.27.2 + github.com/jinzhu/copier v0.3.5 github.com/muesli/reflow v0.3.0 github.com/nuts-foundation/go-did v0.15.0 github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f diff --git a/x/logic/keeper/migrations.go b/x/logic/keeper/migrations.go new file mode 100644 index 000000000..4750ef830 --- /dev/null +++ b/x/logic/keeper/migrations.go @@ -0,0 +1,70 @@ +package keeper + +import ( + "github.com/jinzhu/copier" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + v1beta2types "github.com/axone-protocol/axoned/v10/x/logic/legacy/v1beta2/types" + "github.com/axone-protocol/axoned/v10/x/logic/types" +) + +func MigrateStoreV3ToV4(k Keeper) module.MigrationHandler { + getParams := func(ctx sdk.Context) (params v1beta2types.Params, err error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKey) + if bz == nil { + return params, nil + } + err = k.cdc.Unmarshal(bz, ¶ms) + + return params, err + } + + return func(ctx sdk.Context) error { + paramsFrom, err := getParams(ctx) + if err != nil { + return err + } + + var paramsTo types.Params + + // Interpreter + if err := copier.Copy(¶msTo.Interpreter, paramsFrom.Interpreter); err != nil { + return err + } + + // Limits + if v := paramsFrom.Limits.MaxSize; v != nil { + paramsTo.Limits.MaxSize = v.Uint64() + } + if v := paramsFrom.Limits.MaxResultCount; v != nil { + paramsTo.Limits.MaxResultCount = v.Uint64() + } + if v := paramsFrom.Limits.MaxUserOutputSize; v != nil { + paramsTo.Limits.MaxUserOutputSize = v.Uint64() + } + if v := paramsFrom.Limits.MaxVariables; v != nil { + paramsTo.Limits.MaxVariables = v.Uint64() + } + + // GasPolicy + if v := paramsFrom.GasPolicy.WeightingFactor; v != nil { + paramsTo.GasPolicy.WeightingFactor = v.Uint64() + } + if v := paramsFrom.GasPolicy.DefaultPredicateCost; v != nil { + paramsTo.GasPolicy.DefaultPredicateCost = v.Uint64() + } + if v := paramsFrom.GasPolicy.PredicateCosts; v != nil { + for _, pc := range v { + paramsTo.GasPolicy.PredicateCosts = append(paramsTo.GasPolicy.PredicateCosts, types.PredicateCost{ + Predicate: pc.Predicate, + Cost: pc.Cost.Uint64(), + }) + } + } + + return k.SetParams(ctx, paramsTo) + } +} diff --git a/x/logic/keeper/migrations_test.go b/x/logic/keeper/migrations_test.go new file mode 100644 index 000000000..d6f69f401 --- /dev/null +++ b/x/logic/keeper/migrations_test.go @@ -0,0 +1,166 @@ +package keeper_test + +import ( + gocontext "context" + "fmt" + "io/fs" + "testing" + + "github.com/golang/mock/gomock" + "github.com/samber/lo" + + . "github.com/smartystreets/goconvey/convey" + + sdkmath "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" + + "github.com/cosmos/cosmos-sdk/testutil" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/axone-protocol/axoned/v10/x/logic" + "github.com/axone-protocol/axoned/v10/x/logic/keeper" + v1beta2types "github.com/axone-protocol/axoned/v10/x/logic/legacy/v1beta2/types" + logictestutil "github.com/axone-protocol/axoned/v10/x/logic/testutil" + "github.com/axone-protocol/axoned/v10/x/logic/types" +) + +func TestMigrateStoreV10ToV11(t *testing.T) { + Convey("Given a test cases", t, func() { + cases := []struct { + params v1beta2types.Params + expect types.Params + }{ + { + params: v1beta2types.Params{ + Interpreter: v1beta2types.Interpreter{ + PredicatesFilter: v1beta2types.Filter{}, + Bootstrap: "", + VirtualFilesFilter: v1beta2types.Filter{}, + }, + GasPolicy: v1beta2types.GasPolicy{}, + Limits: v1beta2types.Limits{}, + }, + expect: types.Params{ + Interpreter: types.Interpreter{ + PredicatesFilter: types.Filter{}, + Bootstrap: "", + VirtualFilesFilter: types.Filter{}, + }, + GasPolicy: types.GasPolicy{}, + Limits: types.Limits{}, + }, + }, + { + params: v1beta2types.Params{ + Interpreter: v1beta2types.Interpreter{ + PredicatesFilter: v1beta2types.Filter{ + Whitelist: []string{"foo/1", "bar/2"}, + Blacklist: []string{"baz/3"}, + }, + Bootstrap: "foo(bar).", + VirtualFilesFilter: v1beta2types.Filter{ + Whitelist: []string{"foo://bar"}, + Blacklist: []string{"bar://baz"}, + }, + }, + GasPolicy: v1beta2types.GasPolicy{ + WeightingFactor: lo.ToPtr(sdkmath.NewUint(42)), + DefaultPredicateCost: lo.ToPtr(sdkmath.NewUint(66)), + PredicateCosts: []v1beta2types.PredicateCost{ + { + Predicate: "foo/1", + Cost: lo.ToPtr(sdkmath.NewUint(99)), + }, + }, + }, + Limits: v1beta2types.Limits{ + MaxSize: lo.ToPtr(sdkmath.NewUint(100)), + MaxResultCount: lo.ToPtr(sdkmath.NewUint(10)), + MaxUserOutputSize: lo.ToPtr(sdkmath.NewUint(50)), + MaxVariables: lo.ToPtr(sdkmath.NewUint(5)), + }, + }, + expect: types.Params{ + Interpreter: types.Interpreter{ + PredicatesFilter: types.Filter{ + Whitelist: []string{"foo/1", "bar/2"}, + Blacklist: []string{"baz/3"}, + }, + Bootstrap: "foo(bar).", + VirtualFilesFilter: types.Filter{ + Whitelist: []string{"foo://bar"}, + Blacklist: []string{"bar://baz"}, + }, + }, + GasPolicy: types.GasPolicy{ + WeightingFactor: 42, + DefaultPredicateCost: 66, + PredicateCosts: []types.PredicateCost{ + { + Predicate: "foo/1", + Cost: 99, + }, + }, + }, + Limits: types.Limits{ + MaxSize: 100, + MaxResultCount: 10, + MaxUserOutputSize: 50, + MaxVariables: 5, + }, + }, + }, + } + for nc, tc := range cases { + Convey(fmt.Sprintf("Given a mocked logic keeper for test case %d", nc), func() { + encCfg := moduletestutil.MakeTestEncodingConfig(logic.AppModuleBasic{}) + key := storetypes.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) + + ctrl := gomock.NewController(t) + accountKeeper := logictestutil.NewMockAccountKeeper(ctrl) + authQueryService := logictestutil.NewMockAuthQueryService(ctrl) + bankKeeper := logictestutil.NewMockBankKeeper(ctrl) + fsProvider := logictestutil.NewMockFS(ctrl) + + logicKeeper := keeper.NewKeeper( + encCfg.Codec, + encCfg.InterfaceRegistry, + key, + key, + authtypes.NewModuleAddress(govtypes.ModuleName), + accountKeeper, + authQueryService, + bankKeeper, + func(_ gocontext.Context) fs.FS { + return fsProvider + }) + So(logicKeeper, ShouldNotBeNil) + + Convey("Given a store with v10 params", func() { + store := testCtx.Ctx.KVStore(key) + bz, err := encCfg.Codec.Marshal(&tc.params) + So(err, ShouldBeNil) + + store.Set(types.ParamsKey, bz) + + Convey("When migrating store from v10 to v11", func() { + migrateHandler := keeper.MigrateStoreV3ToV4(*logicKeeper) + So(migrateHandler, ShouldNotBeNil) + + err := migrateHandler(testCtx.Ctx) + So(err, ShouldBeNil) + + Convey("Then the store should have the expected v11 params", func() { + params := logicKeeper.GetParams(testCtx.Ctx) + So(err, ShouldBeNil) + So(params, ShouldResemble, tc.expect) + }) + }) + }) + }) + } + }) +} diff --git a/x/logic/legacy/v1beta2/types/genesis.pb.go b/x/logic/legacy/v1beta2/types/genesis.pb.go new file mode 100644 index 000000000..0b2904e53 --- /dev/null +++ b/x/logic/legacy/v1beta2/types/genesis.pb.go @@ -0,0 +1,322 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: logic/v1beta2/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the logic module's genesis state. +type GenesisState struct { + // The state parameters for the logic module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_712b71f2a5cb208f, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "logic.v1beta2.GenesisState") +} + +func init() { proto.RegisterFile("logic/v1beta2/genesis.proto", fileDescriptor_712b71f2a5cb208f) } + +var fileDescriptor_712b71f2a5cb208f = []byte{ + // 196 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xce, 0xc9, 0x4f, 0xcf, + 0x4c, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd2, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, + 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x05, 0x4b, 0xea, 0x41, 0x25, 0xa5, 0x44, + 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x32, 0xfa, 0x20, 0x16, 0x44, 0x91, 0x94, 0x14, 0xaa, 0x09, 0x05, + 0x89, 0x45, 0x89, 0xb9, 0x50, 0x03, 0x94, 0x9c, 0xb9, 0x78, 0xdc, 0x21, 0x26, 0x06, 0x97, 0x24, + 0x96, 0xa4, 0x0a, 0x19, 0x73, 0xb1, 0x41, 0xe4, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x44, + 0xf5, 0x50, 0x6c, 0xd0, 0x0b, 0x00, 0x4b, 0x3a, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x04, 0x55, + 0xea, 0xe4, 0x71, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, + 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x7a, 0xe9, 0x99, + 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x89, 0x15, 0xf9, 0x79, 0xa9, 0xba, 0x60, + 0x6b, 0x93, 0xf3, 0x73, 0x20, 0xdc, 0x14, 0xfd, 0x0a, 0x7d, 0x88, 0xeb, 0x4a, 0x2a, 0x0b, 0x52, + 0x8b, 0x93, 0xd8, 0xc0, 0xd2, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1e, 0xa2, 0x99, 0xdd, + 0xf5, 0x00, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/logic/legacy/v1beta2/types/params.go b/x/logic/legacy/v1beta2/types/params.go new file mode 100644 index 000000000..4b9f756bb --- /dev/null +++ b/x/logic/legacy/v1beta2/types/params.go @@ -0,0 +1,7 @@ +package types + +// String implements the Stringer interface. +func (p Params) String() string { + return p.Interpreter.String() + "\n" + + p.Limits.String() +} diff --git a/x/logic/legacy/v1beta2/types/params.pb.go b/x/logic/legacy/v1beta2/types/params.pb.go new file mode 100644 index 000000000..9a4cb9d3c --- /dev/null +++ b/x/logic/legacy/v1beta2/types/params.pb.go @@ -0,0 +1,1862 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: logic/v1beta2/params.proto + +package types + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines all the configuration parameters of the "logic" module. +type Params struct { + // Interpreter specifies the parameter for the logic interpreter. + Interpreter Interpreter `protobuf:"bytes,1,opt,name=interpreter,proto3" json:"interpreter" yaml:"interpreter"` + // Limits defines the limits of the logic module. + // The limits are used to prevent the interpreter from running for too long. + // If the interpreter runs for too long, the execution will be aborted. + Limits Limits `protobuf:"bytes,2,opt,name=limits,proto3" json:"limits" yaml:"limits"` + // GasPolicy defines the parameters for calculating predicate invocation costs. + GasPolicy GasPolicy `protobuf:"bytes,3,opt,name=gas_policy,json=gasPolicy,proto3" json:"gas_policy" yaml:"gas_policy"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_3af0daa241de0fa3, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetInterpreter() Interpreter { + if m != nil { + return m.Interpreter + } + return Interpreter{} +} + +func (m *Params) GetLimits() Limits { + if m != nil { + return m.Limits + } + return Limits{} +} + +func (m *Params) GetGasPolicy() GasPolicy { + if m != nil { + return m.GasPolicy + } + return GasPolicy{} +} + +// Limits defines the limits of the logic module. +type Limits struct { + // max_size specifies the maximum size, in bytes, that is accepted for a program. + // nil value or 0 value remove size limitation. + MaxSize *cosmossdk_io_math.Uint `protobuf:"bytes,3,opt,name=max_size,json=maxSize,proto3,customtype=cosmossdk.io/math.Uint" json:"max_size,omitempty" yaml:"max_size"` + // max_result_count specifies the maximum number of results that can be requested for a query. + // nil value or 0 value remove max result count limitation. + MaxResultCount *cosmossdk_io_math.Uint `protobuf:"bytes,2,opt,name=max_result_count,json=maxResultCount,proto3,customtype=cosmossdk.io/math.Uint" json:"max_result_count,omitempty" yaml:"max_result_count"` + // max_user_output_size specifies the maximum number of bytes to keep in the user output. If the user output exceeds + // this size, the interpreter will overwrite the oldest bytes with the new ones to keep the size constant. + // nil value or 0 value means that no user output is used at all. + MaxUserOutputSize *cosmossdk_io_math.Uint `protobuf:"bytes,4,opt,name=max_user_output_size,json=maxUserOutputSize,proto3,customtype=cosmossdk.io/math.Uint" json:"max_user_output_size,omitempty" yaml:"max_user_output_size"` + // max_variables specifies the maximum number of variables that can be create by the interpreter. + // nil value or 0 value means that no limit is set. + MaxVariables *cosmossdk_io_math.Uint `protobuf:"bytes,5,opt,name=max_variables,json=maxVariables,proto3,customtype=cosmossdk.io/math.Uint" json:"max_variables,omitempty" yaml:"max_variables"` +} + +func (m *Limits) Reset() { *m = Limits{} } +func (m *Limits) String() string { return proto.CompactTextString(m) } +func (*Limits) ProtoMessage() {} +func (*Limits) Descriptor() ([]byte, []int) { + return fileDescriptor_3af0daa241de0fa3, []int{1} +} +func (m *Limits) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Limits) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Limits.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Limits) XXX_Merge(src proto.Message) { + xxx_messageInfo_Limits.Merge(m, src) +} +func (m *Limits) XXX_Size() int { + return m.Size() +} +func (m *Limits) XXX_DiscardUnknown() { + xxx_messageInfo_Limits.DiscardUnknown(m) +} + +var xxx_messageInfo_Limits proto.InternalMessageInfo + +// Filter defines the parameters for filtering the set of strings which can designate anything. +// The filter is used to whitelist or blacklist strings. +type Filter struct { + // whitelist specifies a list of strings that are allowed. + // If this field is not specified, all strings (in the context of the filter) are allowed. + Whitelist []string `protobuf:"bytes,1,rep,name=whitelist,proto3" json:"whitelist,omitempty" yaml:"whitelist"` + // blacklist specifies a list of strings that are excluded from the set of allowed strings. + // If a string is included in both whitelist and blacklist, it will be excluded. This means that + // blacklisted strings prevails over whitelisted ones. + // If this field is not specified, no strings are excluded. + Blacklist []string `protobuf:"bytes,2,rep,name=blacklist,proto3" json:"blacklist,omitempty" yaml:"blacklist"` +} + +func (m *Filter) Reset() { *m = Filter{} } +func (m *Filter) String() string { return proto.CompactTextString(m) } +func (*Filter) ProtoMessage() {} +func (*Filter) Descriptor() ([]byte, []int) { + return fileDescriptor_3af0daa241de0fa3, []int{2} +} +func (m *Filter) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Filter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Filter.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Filter) XXX_Merge(src proto.Message) { + xxx_messageInfo_Filter.Merge(m, src) +} +func (m *Filter) XXX_Size() int { + return m.Size() +} +func (m *Filter) XXX_DiscardUnknown() { + xxx_messageInfo_Filter.DiscardUnknown(m) +} + +var xxx_messageInfo_Filter proto.InternalMessageInfo + +func (m *Filter) GetWhitelist() []string { + if m != nil { + return m.Whitelist + } + return nil +} + +func (m *Filter) GetBlacklist() []string { + if m != nil { + return m.Blacklist + } + return nil +} + +// Interpreter defines the various parameters for the interpreter. +type Interpreter struct { + // predicates_filter specifies the filter for the predicates that are allowed to be used by the interpreter. + // The filter is used to whitelist or blacklist predicates represented as `/[]`, for example: + // `findall/3`, or `call`. If a predicate name without arity is included in the filter, then all predicates with that + // name will be considered regardless of arity. For example, if `call` is included in the filter, then all predicates + // `call/1`, `call/2`, `call/3`... will be allowed. + PredicatesFilter Filter `protobuf:"bytes,1,opt,name=predicates_filter,json=predicatesFilter,proto3" json:"predicates_filter" yaml:"predicates_filter"` + // bootstrap specifies the initial program to run when booting the logic interpreter. + // If not specified, the default boot sequence will be executed. + Bootstrap string `protobuf:"bytes,3,opt,name=bootstrap,proto3" json:"bootstrap,omitempty" yaml:"bootstrap"` + // virtual_files_filter specifies the filter for the virtual files that are allowed to be used by the interpreter. + // The filter is used to whitelist or blacklist virtual files represented as URI, for example: + // `file:///path/to/file`, `cosmwasm:cw-storage:axone...?query=foo` + // The filter is applied to the components of the URI, for example: + // `file:///path/to/file` -> `file`, `/path/to/file` + // `cosmwasm:cw-storage:axone...?query=foo` -> `cosmwasm`, `cw-storage`, `axone...`, `query=foo` + // If a component is included in the filter, then all components with that name will be considered, starting from the + // beginning of the URI. For example, if `file` is included in the filter, then all URIs that start with `file` will be + // allowed, regardless of the rest of the components. But `file2` will not be allowed. + // If the component is not included in the filter, then the component is ignored and the next component is considered. + VirtualFilesFilter Filter `protobuf:"bytes,4,opt,name=virtual_files_filter,json=virtualFilesFilter,proto3" json:"virtual_files_filter" yaml:"filesystem_filter"` +} + +func (m *Interpreter) Reset() { *m = Interpreter{} } +func (m *Interpreter) String() string { return proto.CompactTextString(m) } +func (*Interpreter) ProtoMessage() {} +func (*Interpreter) Descriptor() ([]byte, []int) { + return fileDescriptor_3af0daa241de0fa3, []int{3} +} +func (m *Interpreter) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Interpreter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Interpreter.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Interpreter) XXX_Merge(src proto.Message) { + xxx_messageInfo_Interpreter.Merge(m, src) +} +func (m *Interpreter) XXX_Size() int { + return m.Size() +} +func (m *Interpreter) XXX_DiscardUnknown() { + xxx_messageInfo_Interpreter.DiscardUnknown(m) +} + +var xxx_messageInfo_Interpreter proto.InternalMessageInfo + +func (m *Interpreter) GetPredicatesFilter() Filter { + if m != nil { + return m.PredicatesFilter + } + return Filter{} +} + +func (m *Interpreter) GetBootstrap() string { + if m != nil { + return m.Bootstrap + } + return "" +} + +func (m *Interpreter) GetVirtualFilesFilter() Filter { + if m != nil { + return m.VirtualFilesFilter + } + return Filter{} +} + +// GasPolicy defines the policy for calculating predicate invocation costs and the resulting gas consumption. +// The gas policy is defined as a list of predicates and their associated unit costs, a default unit cost for predicates +// if not specified in the list, and a weighting factor that is applied to the unit cost of each predicate to yield. +type GasPolicy struct { + // WeightingFactor is the factor that is applied to the unit cost of each predicate + // to yield the gas value. + // If not provided or set to 0, the value is set to 1. + WeightingFactor *cosmossdk_io_math.Uint `protobuf:"bytes,1,opt,name=weighting_factor,json=weightingFactor,proto3,customtype=cosmossdk.io/math.Uint" json:"weighting_factor,omitempty" yaml:"weighting_factor"` + // DefaultPredicateCost is the default unit cost of a predicate when not specified in the PredicateCosts list. + // If not provided or set to 0, the value is set to 1. + DefaultPredicateCost *cosmossdk_io_math.Uint `protobuf:"bytes,2,opt,name=default_predicate_cost,json=defaultPredicateCost,proto3,customtype=cosmossdk.io/math.Uint" json:"default_predicate_cost,omitempty" yaml:"default_predicate_cost"` + // PredicateCosts is the list of predicates and their associated unit costs. + PredicateCosts []PredicateCost `protobuf:"bytes,3,rep,name=predicate_costs,json=predicateCosts,proto3" json:"predicate_costs" yaml:"predicate_cost"` +} + +func (m *GasPolicy) Reset() { *m = GasPolicy{} } +func (m *GasPolicy) String() string { return proto.CompactTextString(m) } +func (*GasPolicy) ProtoMessage() {} +func (*GasPolicy) Descriptor() ([]byte, []int) { + return fileDescriptor_3af0daa241de0fa3, []int{4} +} +func (m *GasPolicy) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GasPolicy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GasPolicy.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GasPolicy) XXX_Merge(src proto.Message) { + xxx_messageInfo_GasPolicy.Merge(m, src) +} +func (m *GasPolicy) XXX_Size() int { + return m.Size() +} +func (m *GasPolicy) XXX_DiscardUnknown() { + xxx_messageInfo_GasPolicy.DiscardUnknown(m) +} + +var xxx_messageInfo_GasPolicy proto.InternalMessageInfo + +func (m *GasPolicy) GetPredicateCosts() []PredicateCost { + if m != nil { + return m.PredicateCosts + } + return nil +} + +// PredicateCost defines the unit cost of a predicate during its invocation by the interpreter. +type PredicateCost struct { + // Predicate is the name of the predicate, optionally followed by its arity (e.g. "findall/3"). + // If no arity is specified, the unit cost is applied to all predicates with the same name. + Predicate string `protobuf:"bytes,1,opt,name=predicate,proto3" json:"predicate,omitempty" yaml:"predicate"` + // Cost is the unit cost of the predicate. + Cost *cosmossdk_io_math.Uint `protobuf:"bytes,2,opt,name=cost,proto3,customtype=cosmossdk.io/math.Uint" json:"cost,omitempty" yaml:"cost",omitempty` +} + +func (m *PredicateCost) Reset() { *m = PredicateCost{} } +func (m *PredicateCost) String() string { return proto.CompactTextString(m) } +func (*PredicateCost) ProtoMessage() {} +func (*PredicateCost) Descriptor() ([]byte, []int) { + return fileDescriptor_3af0daa241de0fa3, []int{5} +} +func (m *PredicateCost) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PredicateCost) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PredicateCost.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PredicateCost) XXX_Merge(src proto.Message) { + xxx_messageInfo_PredicateCost.Merge(m, src) +} +func (m *PredicateCost) XXX_Size() int { + return m.Size() +} +func (m *PredicateCost) XXX_DiscardUnknown() { + xxx_messageInfo_PredicateCost.DiscardUnknown(m) +} + +var xxx_messageInfo_PredicateCost proto.InternalMessageInfo + +func (m *PredicateCost) GetPredicate() string { + if m != nil { + return m.Predicate + } + return "" +} + +func init() { + proto.RegisterType((*Params)(nil), "logic.v1beta2.Params") + proto.RegisterType((*Limits)(nil), "logic.v1beta2.Limits") + proto.RegisterType((*Filter)(nil), "logic.v1beta2.Filter") + proto.RegisterType((*Interpreter)(nil), "logic.v1beta2.Interpreter") + proto.RegisterType((*GasPolicy)(nil), "logic.v1beta2.GasPolicy") + proto.RegisterType((*PredicateCost)(nil), "logic.v1beta2.PredicateCost") +} + +func init() { proto.RegisterFile("logic/v1beta2/params.proto", fileDescriptor_3af0daa241de0fa3) } + +var fileDescriptor_3af0daa241de0fa3 = []byte{ + // 762 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xcf, 0x6a, 0xdb, 0x48, + 0x18, 0xb7, 0x6c, 0xaf, 0x77, 0x3d, 0x5e, 0x27, 0x8e, 0x70, 0xb2, 0x5a, 0xef, 0xc6, 0x36, 0x73, + 0xca, 0x61, 0x57, 0x26, 0x59, 0xc8, 0xb2, 0x81, 0xa5, 0xa0, 0x94, 0xb4, 0xa5, 0x81, 0x86, 0x29, + 0x29, 0xa5, 0x3d, 0x98, 0xb1, 0x3c, 0x91, 0x87, 0x48, 0x1e, 0xa1, 0x19, 0x25, 0x72, 0x8e, 0x7d, + 0x80, 0xd2, 0x43, 0x0f, 0x3d, 0xf4, 0xd0, 0xc7, 0xc9, 0xa9, 0xe4, 0x58, 0x7a, 0x30, 0x25, 0x79, + 0x83, 0x3c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 0xb9, 0xb1, 0x2e, 0xd0, 0xac, 0xcd, 0x64, 0xba, 0xeb, 0xb9, 0xe3, + 0x4f, 0xbc, 0x56, 0xfc, 0xf9, 0x6e, 0x0e, 0xdf, 0x6b, 0xa0, 0xbe, 0xe8, 0xbb, 0x0b, 0xaa, 0x69, + 0x4f, 0x32, 0xcd, 0xdc, 0x2e, 0xa4, 0x30, 0x44, 0x59, 0xab, 0xfe, 0x14, 0x94, 0xe7, 0x86, 0xf2, + 0xef, 0xd2, 0xa1, 0x24, 0x01, 0x65, 0xac, 0xbf, 0x98, 0x47, 0x05, 0xf1, 0x7c, 0x31, 0x41, 0x52, + 0xc4, 0x7a, 0x7c, 0x79, 0xdd, 0xd6, 0xae, 0xae, 0xdb, 0xda, 0xb7, 0xeb, 0xb6, 0xf6, 0xee, 0xa6, + 0x5d, 0xb8, 0xba, 0x69, 0x17, 0xbe, 0xdc, 0xb4, 0x0b, 0xaf, 0x4c, 0x87, 0x8a, 0x51, 0x38, 0x30, + 0x6d, 0xe6, 0xf5, 0x70, 0xc4, 0xc6, 0xe4, 0x6f, 0xf9, 0x23, 0xb1, 0x99, 0xab, 0x5e, 0x87, 0xbd, + 0xa8, 0xa7, 0x7e, 0x4a, 0x62, 0xe2, 0x13, 0x3e, 0xa8, 0x48, 0xf8, 0x9f, 0xef, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x53, 0x14, 0xc3, 0x1a, 0xaa, 0x06, 0x00, 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.GasPolicy.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.Limits.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Interpreter.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Limits) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Limits) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Limits) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MaxVariables != nil { + { + size := m.MaxVariables.Size() + i -= size + if _, err := m.MaxVariables.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if m.MaxUserOutputSize != nil { + { + size := m.MaxUserOutputSize.Size() + i -= size + if _, err := m.MaxUserOutputSize.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.MaxSize != nil { + { + size := m.MaxSize.Size() + i -= size + if _, err := m.MaxSize.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.MaxResultCount != nil { + { + size := m.MaxResultCount.Size() + i -= size + if _, err := m.MaxResultCount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} + +func (m *Filter) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Filter) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Filter) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Blacklist) > 0 { + for iNdEx := len(m.Blacklist) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Blacklist[iNdEx]) + copy(dAtA[i:], m.Blacklist[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.Blacklist[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Whitelist) > 0 { + for iNdEx := len(m.Whitelist) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Whitelist[iNdEx]) + copy(dAtA[i:], m.Whitelist[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.Whitelist[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *Interpreter) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Interpreter) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Interpreter) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.VirtualFilesFilter.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.Bootstrap) > 0 { + i -= len(m.Bootstrap) + copy(dAtA[i:], m.Bootstrap) + i = encodeVarintParams(dAtA, i, uint64(len(m.Bootstrap))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.PredicatesFilter.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *GasPolicy) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GasPolicy) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GasPolicy) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PredicateCosts) > 0 { + for iNdEx := len(m.PredicateCosts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PredicateCosts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.DefaultPredicateCost != nil { + { + size := m.DefaultPredicateCost.Size() + i -= size + if _, err := m.DefaultPredicateCost.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.WeightingFactor != nil { + { + size := m.WeightingFactor.Size() + i -= size + if _, err := m.WeightingFactor.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PredicateCost) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PredicateCost) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PredicateCost) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Cost != nil { + { + size := m.Cost.Size() + i -= size + if _, err := m.Cost.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Predicate) > 0 { + i -= len(m.Predicate) + copy(dAtA[i:], m.Predicate) + i = encodeVarintParams(dAtA, i, uint64(len(m.Predicate))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Interpreter.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.Limits.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.GasPolicy.Size() + n += 1 + l + sovParams(uint64(l)) + return n +} + +func (m *Limits) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MaxResultCount != nil { + l = m.MaxResultCount.Size() + n += 1 + l + sovParams(uint64(l)) + } + if m.MaxSize != nil { + l = m.MaxSize.Size() + n += 1 + l + sovParams(uint64(l)) + } + if m.MaxUserOutputSize != nil { + l = m.MaxUserOutputSize.Size() + n += 1 + l + sovParams(uint64(l)) + } + if m.MaxVariables != nil { + l = m.MaxVariables.Size() + n += 1 + l + sovParams(uint64(l)) + } + return n +} + +func (m *Filter) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Whitelist) > 0 { + for _, s := range m.Whitelist { + l = len(s) + n += 1 + l + sovParams(uint64(l)) + } + } + if len(m.Blacklist) > 0 { + for _, s := range m.Blacklist { + l = len(s) + n += 1 + l + sovParams(uint64(l)) + } + } + return n +} + +func (m *Interpreter) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.PredicatesFilter.Size() + n += 1 + l + sovParams(uint64(l)) + l = len(m.Bootstrap) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = m.VirtualFilesFilter.Size() + n += 1 + l + sovParams(uint64(l)) + return n +} + +func (m *GasPolicy) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.WeightingFactor != nil { + l = m.WeightingFactor.Size() + n += 1 + l + sovParams(uint64(l)) + } + if m.DefaultPredicateCost != nil { + l = m.DefaultPredicateCost.Size() + n += 1 + l + sovParams(uint64(l)) + } + if len(m.PredicateCosts) > 0 { + for _, e := range m.PredicateCosts { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + return n +} + +func (m *PredicateCost) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Predicate) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + if m.Cost != nil { + l = m.Cost.Size() + n += 1 + l + sovParams(uint64(l)) + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Interpreter", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Interpreter.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Limits", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Limits.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GasPolicy", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.GasPolicy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Limits) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Limits: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Limits: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxResultCount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v cosmossdk_io_math.Uint + m.MaxResultCount = &v + if err := m.MaxResultCount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxSize", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v cosmossdk_io_math.Uint + m.MaxSize = &v + if err := m.MaxSize.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxUserOutputSize", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v cosmossdk_io_math.Uint + m.MaxUserOutputSize = &v + if err := m.MaxUserOutputSize.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxVariables", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v cosmossdk_io_math.Uint + m.MaxVariables = &v + if err := m.MaxVariables.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Filter) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Filter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Filter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Whitelist", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Whitelist = append(m.Whitelist, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Blacklist", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Blacklist = append(m.Blacklist, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Interpreter) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Interpreter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Interpreter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PredicatesFilter", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PredicatesFilter.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bootstrap", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bootstrap = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VirtualFilesFilter", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.VirtualFilesFilter.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GasPolicy) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GasPolicy: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GasPolicy: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WeightingFactor", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v cosmossdk_io_math.Uint + m.WeightingFactor = &v + if err := m.WeightingFactor.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DefaultPredicateCost", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v cosmossdk_io_math.Uint + m.DefaultPredicateCost = &v + if err := m.DefaultPredicateCost.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PredicateCosts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PredicateCosts = append(m.PredicateCosts, PredicateCost{}) + if err := m.PredicateCosts[len(m.PredicateCosts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PredicateCost) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PredicateCost: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PredicateCost: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Predicate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Predicate = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cost", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v cosmossdk_io_math.Uint + m.Cost = &v + if err := m.Cost.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/logic/legacy/v1beta2/types/query.pb.go b/x/logic/legacy/v1beta2/types/query.pb.go new file mode 100644 index 000000000..3009b892d --- /dev/null +++ b/x/logic/legacy/v1beta2/types/query.pb.go @@ -0,0 +1,1184 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: logic/v1beta2/query.proto + +package types + +import ( + context "context" + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryServiceParamsRequest is request type for the QueryService/Params RPC method. +type QueryServiceParamsRequest struct { +} + +func (m *QueryServiceParamsRequest) Reset() { *m = QueryServiceParamsRequest{} } +func (m *QueryServiceParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryServiceParamsRequest) ProtoMessage() {} +func (*QueryServiceParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_008a54e610b23239, []int{0} +} +func (m *QueryServiceParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryServiceParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryServiceParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryServiceParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryServiceParamsRequest.Merge(m, src) +} +func (m *QueryServiceParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryServiceParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryServiceParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryServiceParamsRequest proto.InternalMessageInfo + +// QueryServiceParamsResponse is response type for the QueryService/Params RPC method. +type QueryServiceParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params" yaml:"params",omitempty` +} + +func (m *QueryServiceParamsResponse) Reset() { *m = QueryServiceParamsResponse{} } +func (m *QueryServiceParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryServiceParamsResponse) ProtoMessage() {} +func (*QueryServiceParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_008a54e610b23239, []int{1} +} +func (m *QueryServiceParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryServiceParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryServiceParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryServiceParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryServiceParamsResponse.Merge(m, src) +} +func (m *QueryServiceParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryServiceParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryServiceParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryServiceParamsResponse proto.InternalMessageInfo + +func (m *QueryServiceParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// QueryServiceAskRequest is request type for the QueryService/Ask RPC method. +type QueryServiceAskRequest struct { + // program is the logic program to be queried. + Program string `protobuf:"bytes,1,opt,name=program,proto3" json:"program,omitempty" yaml:"program",omitempty` + // query is the query string to be executed. + Query string `protobuf:"bytes,2,opt,name=query,proto3" json:"query,omitempty" yaml:"query",omitempty` + // limit specifies the maximum number of solutions to be returned. This field is governed by + // max_result_count, which defines the upper limit of results that may be requested per query. + // If this field is not explicitly set, a default value of 1 is applied. + Limit *cosmossdk_io_math.Uint `protobuf:"bytes,3,opt,name=limit,proto3,customtype=cosmossdk.io/math.Uint" json:"limit,omitempty" yaml:"limit",omitempty` +} + +func (m *QueryServiceAskRequest) Reset() { *m = QueryServiceAskRequest{} } +func (m *QueryServiceAskRequest) String() string { return proto.CompactTextString(m) } +func (*QueryServiceAskRequest) ProtoMessage() {} +func (*QueryServiceAskRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_008a54e610b23239, []int{2} +} +func (m *QueryServiceAskRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryServiceAskRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryServiceAskRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryServiceAskRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryServiceAskRequest.Merge(m, src) +} +func (m *QueryServiceAskRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryServiceAskRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryServiceAskRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryServiceAskRequest proto.InternalMessageInfo + +func (m *QueryServiceAskRequest) GetProgram() string { + if m != nil { + return m.Program + } + return "" +} + +func (m *QueryServiceAskRequest) GetQuery() string { + if m != nil { + return m.Query + } + return "" +} + +// QueryServiceAskResponse is response type for the QueryService/Ask RPC method. +type QueryServiceAskResponse struct { + // height is the block height at which the query was executed. + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty" yaml:"height",omitempty` + // gas_used is the amount of gas used to execute the query. + GasUsed uint64 `protobuf:"varint,2,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty" yaml:"gas_used",omitempty` + // answer is the answer to the query. + Answer *Answer `protobuf:"bytes,3,opt,name=answer,proto3" json:"answer,omitempty" yaml:"answer",omitempty` + // user_output is the output of the query execution, if any. + // the length of the output is limited by the max_query_output_size parameter. + UserOutput string `protobuf:"bytes,4,opt,name=user_output,json=userOutput,proto3" json:"user_output,omitempty" yaml:"user_output",omitempty` +} + +func (m *QueryServiceAskResponse) Reset() { *m = QueryServiceAskResponse{} } +func (m *QueryServiceAskResponse) String() string { return proto.CompactTextString(m) } +func (*QueryServiceAskResponse) ProtoMessage() {} +func (*QueryServiceAskResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_008a54e610b23239, []int{3} +} +func (m *QueryServiceAskResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryServiceAskResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryServiceAskResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryServiceAskResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryServiceAskResponse.Merge(m, src) +} +func (m *QueryServiceAskResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryServiceAskResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryServiceAskResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryServiceAskResponse proto.InternalMessageInfo + +func (m *QueryServiceAskResponse) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *QueryServiceAskResponse) GetGasUsed() uint64 { + if m != nil { + return m.GasUsed + } + return 0 +} + +func (m *QueryServiceAskResponse) GetAnswer() *Answer { + if m != nil { + return m.Answer + } + return nil +} + +func (m *QueryServiceAskResponse) GetUserOutput() string { + if m != nil { + return m.UserOutput + } + return "" +} + +func init() { + proto.RegisterType((*QueryServiceParamsRequest)(nil), "logic.v1beta2.QueryServiceParamsRequest") + proto.RegisterType((*QueryServiceParamsResponse)(nil), "logic.v1beta2.QueryServiceParamsResponse") + proto.RegisterType((*QueryServiceAskRequest)(nil), "logic.v1beta2.QueryServiceAskRequest") + proto.RegisterType((*QueryServiceAskResponse)(nil), "logic.v1beta2.QueryServiceAskResponse") +} + +func init() { proto.RegisterFile("logic/v1beta2/query.proto", fileDescriptor_008a54e610b23239) } + +var fileDescriptor_008a54e610b23239 = []byte{ + // 592 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x31, 0x6f, 0xd3, 0x40, + 0x18, 0xcd, 0xa5, 0x69, 0x80, 0x2b, 0x2c, 0x27, 0x68, 0x13, 0x27, 0xd8, 0x91, 0x51, 0x51, 0x41, + 0xd4, 0x6e, 0x53, 0x09, 0x55, 0xdd, 0x92, 0x09, 0x31, 0x14, 0x28, 0xea, 0xc2, 0x52, 0x5d, 0x92, + 0x93, 0x73, 0x8a, 0xed, 0x73, 0x7d, 0xe7, 0xd0, 0xac, 0xb0, 0xb0, 0x81, 0xc4, 0xc2, 0x82, 0xc4, + 0xc4, 0xcc, 0xcf, 0xc8, 0x58, 0x89, 0xa5, 0x62, 0xb0, 0x50, 0x82, 0xc4, 0xee, 0x5f, 0x80, 0x72, + 0xe7, 0x28, 0x76, 0x4b, 0x0b, 0x9b, 0xfd, 0xbd, 0xf7, 0xbe, 0xef, 0x7d, 0xef, 0xee, 0x60, 0xd5, + 0x65, 0x0e, 0xed, 0xda, 0xc3, 0xed, 0x0e, 0x11, 0xb8, 0x69, 0x1f, 0x47, 0x24, 0x1c, 0x59, 0x41, + 0xc8, 0x04, 0x43, 0xb7, 0x24, 0x64, 0xa5, 0x90, 0x56, 0xeb, 0x32, 0xee, 0x31, 0xae, 0x28, 0xf6, + 0x70, 0x3b, 0xcb, 0xd5, 0x6e, 0x3b, 0xcc, 0x61, 0xf2, 0xd3, 0x9e, 0x7d, 0xa5, 0xd5, 0xba, 0xc3, + 0x98, 0xe3, 0x12, 0x1b, 0x07, 0xd4, 0xc6, 0xbe, 0xcf, 0x04, 0x16, 0x94, 0xf9, 0x3c, 0x45, 0xb5, + 0xfc, 0xe8, 0x00, 0x87, 0xd8, 0x9b, 0x63, 0xe7, 0x6c, 0x89, 0x51, 0x40, 0x52, 0xc8, 0xac, 0xc1, + 0xea, 0x8b, 0xd9, 0xe4, 0x97, 0x24, 0x1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c, 0x98, 0xea, 0x85, 0xd3, 0xa9, 0x5e, 0x38, 0x9b, 0xea, 0x85, 0x57, 0x96, 0x43, + 0x45, 0x3f, 0xea, 0x58, 0x5d, 0xe6, 0x5d, 0xd2, 0xe5, 0x24, 0xed, 0x23, 0x9f, 0x7f, 0xa7, 0x2c, + 0xe1, 0x9d, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe7, 0x25, 0x50, 0x93, 0xb3, 0x04, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryServiceClient is the client API for QueryService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryServiceClient interface { + // Params queries all parameters for the logic module. + Params(ctx context.Context, in *QueryServiceParamsRequest, opts ...grpc.CallOption) (*QueryServiceParamsResponse, error) + // Ask executes a logic query and returns the solutions found. + // Since the query is without any side-effect, the query is not executed in the context of a transaction and no fee + // is charged for this, but the execution is constrained by the current limits configured in the module. + Ask(ctx context.Context, in *QueryServiceAskRequest, opts ...grpc.CallOption) (*QueryServiceAskResponse, error) +} + +type queryServiceClient struct { + cc grpc1.ClientConn +} + +func NewQueryServiceClient(cc grpc1.ClientConn) QueryServiceClient { + return &queryServiceClient{cc} +} + +func (c *queryServiceClient) Params(ctx context.Context, in *QueryServiceParamsRequest, opts ...grpc.CallOption) (*QueryServiceParamsResponse, error) { + out := new(QueryServiceParamsResponse) + err := c.cc.Invoke(ctx, "/logic.v1beta2.QueryService/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryServiceClient) Ask(ctx context.Context, in *QueryServiceAskRequest, opts ...grpc.CallOption) (*QueryServiceAskResponse, error) { + out := new(QueryServiceAskResponse) + err := c.cc.Invoke(ctx, "/logic.v1beta2.QueryService/Ask", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServiceServer is the server API for QueryService service. +type QueryServiceServer interface { + // Params queries all parameters for the logic module. + Params(context.Context, *QueryServiceParamsRequest) (*QueryServiceParamsResponse, error) + // Ask executes a logic query and returns the solutions found. + // Since the query is without any side-effect, the query is not executed in the context of a transaction and no fee + // is charged for this, but the execution is constrained by the current limits configured in the module. + Ask(context.Context, *QueryServiceAskRequest) (*QueryServiceAskResponse, error) +} + +// UnimplementedQueryServiceServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServiceServer struct { +} + +func (*UnimplementedQueryServiceServer) Params(ctx context.Context, req *QueryServiceParamsRequest) (*QueryServiceParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServiceServer) Ask(ctx context.Context, req *QueryServiceAskRequest) (*QueryServiceAskResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Ask not implemented") +} + +func RegisterQueryServiceServer(s grpc1.Server, srv QueryServiceServer) { + s.RegisterService(&_QueryService_serviceDesc, srv) +} + +func _QueryService_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryServiceParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServiceServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/logic.v1beta2.QueryService/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServiceServer).Params(ctx, req.(*QueryServiceParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _QueryService_Ask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryServiceAskRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServiceServer).Ask(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/logic.v1beta2.QueryService/Ask", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServiceServer).Ask(ctx, req.(*QueryServiceAskRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _QueryService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "logic.v1beta2.QueryService", + HandlerType: (*QueryServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _QueryService_Params_Handler, + }, + { + MethodName: "Ask", + Handler: _QueryService_Ask_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "logic/v1beta2/query.proto", +} + +func (m *QueryServiceParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryServiceParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryServiceParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryServiceParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryServiceParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryServiceParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryServiceAskRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryServiceAskRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryServiceAskRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Limit != nil { + { + size := m.Limit.Size() + i -= size + if _, err := m.Limit.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.Query) > 0 { + i -= len(m.Query) + copy(dAtA[i:], m.Query) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Query))) + i-- + dAtA[i] = 0x12 + } + if len(m.Program) > 0 { + i -= len(m.Program) + copy(dAtA[i:], m.Program) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Program))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryServiceAskResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryServiceAskResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryServiceAskResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.UserOutput) > 0 { + i -= len(m.UserOutput) + copy(dAtA[i:], m.UserOutput) + i = encodeVarintQuery(dAtA, i, uint64(len(m.UserOutput))) + i-- + dAtA[i] = 0x22 + } + if m.Answer != nil { + { + size, err := m.Answer.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.GasUsed != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.GasUsed)) + i-- + dAtA[i] = 0x10 + } + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryServiceParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryServiceParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryServiceAskRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Program) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Query) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Limit != nil { + l = m.Limit.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryServiceAskResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + if m.GasUsed != 0 { + n += 1 + sovQuery(uint64(m.GasUsed)) + } + if m.Answer != nil { + l = m.Answer.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.UserOutput) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryServiceParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryServiceParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryServiceParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryServiceParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryServiceParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryServiceParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryServiceAskRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryServiceAskRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryServiceAskRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Program", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Program = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Query = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v cosmossdk_io_math.Uint + m.Limit = &v + if err := m.Limit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryServiceAskResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryServiceAskResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryServiceAskResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasUsed", wireType) + } + m.GasUsed = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasUsed |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Answer", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Answer == nil { + m.Answer = &Answer{} + } + if err := m.Answer.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserOutput", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UserOutput = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/logic/legacy/v1beta2/types/tx.pb.go b/x/logic/legacy/v1beta2/types/tx.pb.go new file mode 100644 index 000000000..599b1f509 --- /dev/null +++ b/x/logic/legacy/v1beta2/types/tx.pb.go @@ -0,0 +1,594 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: logic/v1beta2/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgUpdateParams defines a Msg for updating the x/logic module parameters. +type MsgUpdateParams struct { + // authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the x/logic parameters to update. + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_19bfd5fc1a0735fe, []int{0} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_19bfd5fc1a0735fe, []int{1} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgUpdateParams)(nil), "logic.v1beta2.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "logic.v1beta2.MsgUpdateParamsResponse") +} + +func init() { proto.RegisterFile("logic/v1beta2/tx.proto", fileDescriptor_19bfd5fc1a0735fe) } + +var fileDescriptor_19bfd5fc1a0735fe = []byte{ + // 320 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcb, 0xc9, 0x4f, 0xcf, + 0x4c, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd2, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, + 0x2f, 0xc9, 0x17, 0xe2, 0x05, 0x8b, 0xeb, 0x41, 0xc5, 0xa5, 0xc4, 0x93, 0xf3, 0x8b, 0x73, 0xf3, + 0x8b, 0xf5, 0x73, 0x8b, 0xd3, 0xf5, 0xcb, 0x0c, 0x41, 0x14, 0x44, 0x9d, 0x94, 0x24, 0x44, 0x22, + 0x1e, 0xcc, 0xd3, 0x87, 0x70, 0xa0, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x10, 0x71, 0x10, 0x0b, + 0x2a, 0x2a, 0x85, 0x6a, 0x61, 0x41, 0x62, 0x51, 0x62, 0x2e, 0x54, 0x87, 0x52, 0x1f, 0x23, 0x17, + 0xbf, 0x6f, 0x71, 0x7a, 0x68, 0x41, 0x4a, 0x62, 0x49, 0x6a, 0x00, 0x58, 0x46, 0xc8, 0x8c, 0x8b, + 0x33, 0xb1, 0xb4, 0x24, 0x23, 0xbf, 0x28, 0xb3, 0xa4, 0x52, 0x82, 0x51, 0x81, 0x51, 0x83, 0xd3, + 0x49, 0xe2, 0xd2, 0x16, 0x5d, 0x11, 0xa8, 0x55, 0x8e, 0x29, 0x29, 0x45, 0xa9, 0xc5, 0xc5, 0xc1, + 0x25, 0x45, 0x99, 0x79, 0xe9, 0x41, 0x08, 0xa5, 0x42, 0xc6, 0x5c, 0x6c, 0x10, 0xb3, 0x25, 0x98, + 0x14, 0x18, 0x35, 0xb8, 0x8d, 0x44, 0xf5, 0x50, 0x7c, 0xa4, 0x07, 0x31, 0xde, 0x89, 0xe5, 0xc4, + 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x52, 0x2b, 0xbe, 0xa6, 0xe7, 0x1b, 0xb4, 0x10, 0x86, 0x28, 0x49, + 0x72, 0x89, 0xa3, 0xb9, 0x27, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0xd5, 0x28, 0x85, 0x8b, + 0xcb, 0xb7, 0x38, 0x3d, 0x38, 0xb5, 0xa8, 0x2c, 0x33, 0x39, 0x55, 0x28, 0x8c, 0x8b, 0x07, 0xc5, + 0xd5, 0x72, 0x68, 0xb6, 0xa1, 0x99, 0x22, 0xa5, 0x86, 0x5f, 0x1e, 0x66, 0x8b, 0x93, 0xc7, 0x89, + 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, + 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, + 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x27, 0x56, 0xe4, 0xe7, 0xa5, 0xea, 0x82, 0xc3, 0x30, 0x39, 0x3f, + 0x07, 0xc2, 0x4d, 0xd1, 0xaf, 0xd0, 0x87, 0x04, 0x75, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, + 0x58, 0xda, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x06, 0xfc, 0x7f, 0xed, 0xf1, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgServiceClient is the client API for MsgService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgServiceClient interface { + // UpdateParams defined a governance operation for updating the x/logic module parameters. + // The authority is hard-coded to the Cosmos SDK x/gov module account + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) +} + +type msgServiceClient struct { + cc grpc1.ClientConn +} + +func NewMsgServiceClient(cc grpc1.ClientConn) MsgServiceClient { + return &msgServiceClient{cc} +} + +func (c *msgServiceClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/logic.v1beta2.MsgService/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServiceServer is the server API for MsgService service. +type MsgServiceServer interface { + // UpdateParams defined a governance operation for updating the x/logic module parameters. + // The authority is hard-coded to the Cosmos SDK x/gov module account + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) +} + +// UnimplementedMsgServiceServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServiceServer struct { +} + +func (*UnimplementedMsgServiceServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} + +func RegisterMsgServiceServer(s grpc1.Server, srv MsgServiceServer) { + s.RegisterService(&_MsgService_serviceDesc, srv) +} + +func _MsgService_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServiceServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/logic.v1beta2.MsgService/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServiceServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +var _MsgService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "logic.v1beta2.MsgService", + HandlerType: (*MsgServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateParams", + Handler: _MsgService_UpdateParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "logic/v1beta2/tx.proto", +} + +func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/logic/legacy/v1beta2/types/types.pb.go b/x/logic/legacy/v1beta2/types/types.pb.go new file mode 100644 index 000000000..a3c23e754 --- /dev/null +++ b/x/logic/legacy/v1beta2/types/types.pb.go @@ -0,0 +1,901 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: logic/v1beta2/types.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Substitution represents a substitution made to the variables in the query to obtain the answer. +type Substitution struct { + // variable is the name of the variable. + Variable string `protobuf:"bytes,1,opt,name=variable,proto3" json:"variable,omitempty" yaml:"variable",omitempty` + // expression is the value substituted for the variable, represented directly as a Prolog term (e.g., atom, number, compound). + Expression string `protobuf:"bytes,2,opt,name=expression,proto3" json:"expression,omitempty" yaml:"expression",omitempty` +} + +func (m *Substitution) Reset() { *m = Substitution{} } +func (m *Substitution) String() string { return proto.CompactTextString(m) } +func (*Substitution) ProtoMessage() {} +func (*Substitution) Descriptor() ([]byte, []int) { + return fileDescriptor_f3c73c95465ca7a8, []int{0} +} +func (m *Substitution) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Substitution) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Substitution.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Substitution) XXX_Merge(src proto.Message) { + xxx_messageInfo_Substitution.Merge(m, src) +} +func (m *Substitution) XXX_Size() int { + return m.Size() +} +func (m *Substitution) XXX_DiscardUnknown() { + xxx_messageInfo_Substitution.DiscardUnknown(m) +} + +var xxx_messageInfo_Substitution proto.InternalMessageInfo + +func (m *Substitution) GetVariable() string { + if m != nil { + return m.Variable + } + return "" +} + +func (m *Substitution) GetExpression() string { + if m != nil { + return m.Expression + } + return "" +} + +// Result represents the result of a query. +type Result struct { + // error specifies the error message if the query caused an error. + Error string `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty" yaml:"error",omitempty` + // substitutions represent all the substitutions made to the variables in the query to obtain the answer. + Substitutions []Substitution `protobuf:"bytes,2,rep,name=substitutions,proto3" json:"substitutions" yaml:"substitutions",omitempty` +} + +func (m *Result) Reset() { *m = Result{} } +func (m *Result) String() string { return proto.CompactTextString(m) } +func (*Result) ProtoMessage() {} +func (*Result) Descriptor() ([]byte, []int) { + return fileDescriptor_f3c73c95465ca7a8, []int{1} +} +func (m *Result) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Result) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Result.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Result) XXX_Merge(src proto.Message) { + xxx_messageInfo_Result.Merge(m, src) +} +func (m *Result) XXX_Size() int { + return m.Size() +} +func (m *Result) XXX_DiscardUnknown() { + xxx_messageInfo_Result.DiscardUnknown(m) +} + +var xxx_messageInfo_Result proto.InternalMessageInfo + +func (m *Result) GetError() string { + if m != nil { + return m.Error + } + return "" +} + +func (m *Result) GetSubstitutions() []Substitution { + if m != nil { + return m.Substitutions + } + return nil +} + +// Answer represents the answer to a logic query. +type Answer struct { + // has_more specifies if there are more solutions than the ones returned. + HasMore bool `protobuf:"varint,2,opt,name=has_more,json=hasMore,proto3" json:"has_more,omitempty" yaml:"has_more",omitempty` + // variables represent all the variables in the query. + Variables []string `protobuf:"bytes,3,rep,name=variables,proto3" json:"variables,omitempty" yaml:"variables",omitempty` + // results represent all the results of the query. + Results []Result `protobuf:"bytes,4,rep,name=results,proto3" json:"results" yaml:"results",omitempty` +} + +func (m *Answer) Reset() { *m = Answer{} } +func (m *Answer) String() string { return proto.CompactTextString(m) } +func (*Answer) ProtoMessage() {} +func (*Answer) Descriptor() ([]byte, []int) { + return fileDescriptor_f3c73c95465ca7a8, []int{2} +} +func (m *Answer) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Answer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Answer.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Answer) XXX_Merge(src proto.Message) { + xxx_messageInfo_Answer.Merge(m, src) +} +func (m *Answer) XXX_Size() int { + return m.Size() +} +func (m *Answer) XXX_DiscardUnknown() { + xxx_messageInfo_Answer.DiscardUnknown(m) +} + +var xxx_messageInfo_Answer proto.InternalMessageInfo + +func (m *Answer) GetHasMore() bool { + if m != nil { + return m.HasMore + } + return false +} + +func (m *Answer) GetVariables() []string { + if m != nil { + return m.Variables + } + return nil +} + +func (m *Answer) GetResults() []Result { + if m != nil { + return m.Results + } + return nil +} + +func init() { + proto.RegisterType((*Substitution)(nil), "logic.v1beta2.Substitution") + proto.RegisterType((*Result)(nil), "logic.v1beta2.Result") + proto.RegisterType((*Answer)(nil), "logic.v1beta2.Answer") +} + +func init() { proto.RegisterFile("logic/v1beta2/types.proto", fileDescriptor_f3c73c95465ca7a8) } + +var fileDescriptor_f3c73c95465ca7a8 = []byte{ + // 411 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0xb1, 0xae, 0xd3, 0x30, + 0x18, 0x85, 0xe3, 0xdb, 0x7b, 0x7b, 0x7b, 0x0d, 0x77, 0xb1, 0x00, 0xe5, 0xb6, 0xc2, 0x8e, 0x32, + 0xa0, 0x0e, 0x90, 0x88, 0xc2, 0x00, 0x15, 0x12, 0x22, 0x13, 0x0b, 0x03, 0x65, 0x63, 0x41, 0x49, + 0xb1, 0x52, 0x4b, 0x49, 0x1c, 0xd9, 0x4e, 0x69, 0xdf, 0xa2, 0x23, 0x23, 0x6f, 0xc0, 0x6b, 0x74, + 0xec, 0x08, 0x4b, 0x84, 0xda, 0x37, 0xc8, 0x13, 0xa0, 0xda, 0x29, 0x75, 0xd8, 0x92, 0x7c, 0xff, + 0x39, 0xf9, 0xcf, 0xd1, 0x0f, 0xef, 0x32, 0x9e, 0xb2, 0x79, 0xb8, 0x7c, 0x9e, 0x50, 0x15, 0x4f, + 0x42, 0xb5, 0x2e, 0xa9, 0x0c, 0x4a, 0xc1, 0x15, 0x47, 0xb7, 0x1a, 0x05, 0x2d, 0x1a, 0x3e, 0x48, + 0x79, 0xca, 0x35, 0x09, 0x8f, 0x4f, 0x66, 0xc8, 0xdf, 0x00, 0x78, 0xff, 0x53, 0x95, 0x48, 0xc5, + 0x54, 0xa5, 0x18, 0x2f, 0xd0, 0x6b, 0x38, 0x58, 0xc6, 0x82, 0xc5, 0x49, 0x46, 0x5d, 0xe0, 0x81, + 0xf1, 0x4d, 0xf4, 0xb8, 0xa9, 0xc9, 0xdd, 0x3a, 0xce, 0xb3, 0xa9, 0x7f,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, 0xd5, 0x74, 0x16, 0x6a, 0xbf, 0x99, 0x6c, 0xd1, 0xfb, 0xed, 0x1e, 0x83, 0xdd, 0x1e, 0x83, + 0x3f, 0x7b, 0x0c, 0x36, 0x07, 0xec, 0xec, 0x0e, 0xd8, 0xf9, 0x75, 0xc0, 0xce, 0xe7, 0x20, 0x65, + 0x6a, 0x51, 0x25, 0xc1, 0x9c, 0xe7, 0x61, 0xbc, 0xe2, 0x05, 0x7d, 0xa6, 0x4f, 0x6a, 0xce, 0x33, + 0xf3, 0xfa, 0x35, 0x5c, 0x85, 0xe6, 0x3a, 0xf5, 0x55, 0x26, 0x7d, 0x8d, 0x5f, 0xfc, 0x0d, 0x00, + 0x00, 0xff, 0xff, 0x01, 0xe7, 0x0f, 0xdf, 0xb3, 0x02, 0x00, 0x00, +} + +func (m *Substitution) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Substitution) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Substitution) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Expression) > 0 { + i -= len(m.Expression) + copy(dAtA[i:], m.Expression) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Expression))) + i-- + dAtA[i] = 0x12 + } + if len(m.Variable) > 0 { + i -= len(m.Variable) + copy(dAtA[i:], m.Variable) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Variable))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Result) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Result) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Result) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Error) > 0 { + i -= len(m.Error) + copy(dAtA[i:], m.Error) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Error))) + i-- + dAtA[i] = 0x2a + } + if len(m.Substitutions) > 0 { + for iNdEx := len(m.Substitutions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Substitutions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + return len(dAtA) - i, nil +} + +func (m *Answer) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Answer) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Answer) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Results) > 0 { + for iNdEx := len(m.Results) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Results[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Variables) > 0 { + for iNdEx := len(m.Variables) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Variables[iNdEx]) + copy(dAtA[i:], m.Variables[iNdEx]) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Variables[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if m.HasMore { + i-- + if m.HasMore { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + return len(dAtA) - i, nil +} + +func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { + offset -= sovTypes(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Substitution) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Variable) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Expression) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *Result) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Substitutions) > 0 { + for _, e := range m.Substitutions { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + l = len(m.Error) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *Answer) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.HasMore { + n += 2 + } + if len(m.Variables) > 0 { + for _, s := range m.Variables { + l = len(s) + n += 1 + l + sovTypes(uint64(l)) + } + } + if len(m.Results) > 0 { + for _, e := range m.Results { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func sovTypes(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTypes(x uint64) (n int) { + return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Substitution) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Substitution: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Substitution: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Variable", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Variable = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expression", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Expression = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Result) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Result: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Result: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Substitutions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Substitutions = append(m.Substitutions, Substitution{}) + if err := m.Substitutions[len(m.Substitutions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Error = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Answer) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Answer: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Answer: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field HasMore", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.HasMore = bool(v != 0) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Variables", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Variables = append(m.Variables, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Results", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Results = append(m.Results, Result{}) + if err := m.Results[len(m.Results)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTypes(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTypes + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTypes + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTypes + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/logic/module.go b/x/logic/module.go index 1ae088462..f135e71aa 100644 --- a/x/logic/module.go +++ b/x/logic/module.go @@ -124,6 +124,10 @@ func (am AppModule) IsAppModule() {} func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServiceServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServiceServer(cfg.QueryServer(), am.keeper) + + if err := cfg.RegisterMigration(types.ModuleName, 3, keeper.MigrateStoreV3ToV4(am.keeper)); err != nil { + panic(err) + } } // InitGenesis performs the module's genesis initialization. It returns no validator updates. @@ -143,7 +147,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw // ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each // consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1. -func (AppModule) ConsensusVersion() uint64 { return 3 } +func (AppModule) ConsensusVersion() uint64 { return 4 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block. func (am AppModule) BeginBlock(_ context.Context) error { From 6146f2007528092db5f4c89b9e9702ebb9e980b2 Mon Sep 17 00:00:00 2001 From: ccamel Date: Wed, 23 Oct 2024 16:57:44 +0200 Subject: [PATCH 7/7] feat(logic): generate default values for the interpreter in genesis file --- x/logic/keeper/grpc_query_params_test.go | 25 +++++++++++ x/logic/types/params.go | 57 ++++++++++++++++++++---- x/logic/types/params_test.go | 6 +++ 3 files changed, 79 insertions(+), 9 deletions(-) diff --git a/x/logic/keeper/grpc_query_params_test.go b/x/logic/keeper/grpc_query_params_test.go index df3697361..2cafb9f84 100644 --- a/x/logic/keeper/grpc_query_params_test.go +++ b/x/logic/keeper/grpc_query_params_test.go @@ -44,6 +44,31 @@ func TestGRPCParams(t *testing.T) { types.WithMaxUserOutputSize(4), types.WithMaxVariables(5), ), + types.GasPolicy{}, + ), + }, + { + params: types.NewParams( + types.NewInterpreter( + types.WithBootstrap("bootstrap"), + types.WithPredicatesBlacklist([]string{"halt/1"}), + types.WithPredicatesWhitelist([]string{"source_file/1"}), + types.WithVirtualFilesBlacklist([]string{"file1"}), + types.WithVirtualFilesWhitelist([]string{"file2"}), + ), + types.NewLimits( + types.WithMaxSize(2), + types.WithMaxResultCount(3), + types.WithMaxUserOutputSize(4), + types.WithMaxVariables(5), + ), + types.GasPolicy{ + WeightingFactor: 2, + DefaultPredicateCost: 1, + PredicateCosts: []types.PredicateCost{ + {Predicate: "foo", Cost: 1}, + }, + }, ), }, } diff --git a/x/logic/types/params.go b/x/logic/types/params.go index f8c4e6d87..5cb56ec23 100644 --- a/x/logic/types/params.go +++ b/x/logic/types/params.go @@ -10,22 +10,27 @@ var ( ParamsKey = []byte("Params") ) -var ( - DefaultPredicatesWhitelist = make([]string, 0) - DefaultPredicatesBlacklist = make([]string, 0) -) - // NewParams creates a new Params object. -func NewParams(interpreter Interpreter, limits Limits) Params { +func NewParams(interpreter Interpreter, limits Limits, gasPolicy GasPolicy) Params { return Params{ Interpreter: interpreter, Limits: limits, + GasPolicy: gasPolicy, } } // DefaultParams returns a default set of parameters. func DefaultParams() Params { - return NewParams(NewInterpreter(), NewLimits()) + return NewParams( + NewInterpreter(), + NewLimits( + WithMaxSize(5000), + WithMaxResultCount(3), + WithMaxVariables(100000)), + NewGasPolicy( + WithWeightingFactor(1), + WithDefaultPredicateCost(1)), + ) } // Validate validates the set of params. @@ -50,11 +55,11 @@ func NewInterpreter(opts ...InterpreterOption) Interpreter { } if i.PredicatesFilter.Whitelist == nil { - i.PredicatesFilter.Whitelist = DefaultPredicatesWhitelist + i.PredicatesFilter.Whitelist = []string{} } if i.PredicatesFilter.Blacklist == nil { - i.PredicatesFilter.Blacklist = DefaultPredicatesBlacklist + i.PredicatesFilter.Blacklist = []string{} } return i @@ -168,3 +173,37 @@ func validateLimits(i interface{}) error { // TODO: Validate limits params. return nil } + +// GasPolicyOption is a functional option for configuring the GasPolicy. +type GasPolicyOption func(*GasPolicy) + +// WithWeightingFactor sets the weighting factor. +func WithWeightingFactor(weightingFactor uint64) GasPolicyOption { + return func(i *GasPolicy) { + i.WeightingFactor = weightingFactor + } +} + +// WithDefaultPredicateCost sets the default cost of a predicate. +func WithDefaultPredicateCost(defaultPredicateCost uint64) GasPolicyOption { + return func(i *GasPolicy) { + i.DefaultPredicateCost = defaultPredicateCost + } +} + +// WithPredicateCosts sets the cost of a predicate. +func WithPredicateCosts(predicateCosts []PredicateCost) GasPolicyOption { + return func(i *GasPolicy) { + i.PredicateCosts = predicateCosts + } +} + +// NewGasPolicy creates a new GasPolicy object. +func NewGasPolicy(opts ...GasPolicyOption) GasPolicy { + g := GasPolicy{} + for _, opt := range opts { + opt(&g) + } + + return g +} diff --git a/x/logic/types/params_test.go b/x/logic/types/params_test.go index 4f52e055e..cab683d1c 100644 --- a/x/logic/types/params_test.go +++ b/x/logic/types/params_test.go @@ -39,6 +39,10 @@ func TestValidateParams(t *testing.T) { types.WithMaxUserOutputSize(4), types.WithMaxVariables(5), ), + types.GasPolicy{ + WeightingFactor: 2, + DefaultPredicateCost: 1, + }, ), expectErr: false, err: nil, @@ -50,6 +54,7 @@ func TestValidateParams(t *testing.T) { types.WithVirtualFilesBlacklist([]string{"https://foo{bar/"}), ), types.NewLimits(), + types.GasPolicy{}, ), expectErr: true, err: fmt.Errorf("invalid virtual file in blacklist: https://foo{bar/"), @@ -61,6 +66,7 @@ func TestValidateParams(t *testing.T) { types.WithVirtualFilesWhitelist([]string{"https://foo{bar/"}), ), types.NewLimits(), + types.GasPolicy{}, ), expectErr: true, err: fmt.Errorf("invalid virtual file in whitelist: https://foo{bar/"),