Skip to content

Commit

Permalink
refactor(logic)!: change Limits and GasPolicy properties to use uint64
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ccamel committed Oct 23, 2024
1 parent 8dc2746 commit db18c9a
Show file tree
Hide file tree
Showing 37 changed files with 491 additions and 719 deletions.
14 changes: 7 additions & 7 deletions docs/predicate/bech32_address_2.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bech32_address(Address, 'axone15wn30a9z4uc692s0kkx5fp5d4qfr3ac77gvjg4').

``` yaml
height: 42
gas_used: 4140
gas_used: 3612
answer:
has_more: false
variables: ["Address"]
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -102,7 +102,7 @@ bech32_address(-(axone, Address), 'axone15wn30a9z4uc692s0kkx5fp5d4qfr3ac77gvjg4'

``` yaml
height: 42
gas_used: 4140
gas_used: 3612
answer:
has_more: false
variables: ["Address"]
Expand All @@ -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"]
Expand Down Expand Up @@ -162,7 +162,7 @@ axone_addr('axone1p8u47en82gmzfm259y6z93r9qe63l25d858vqu').

``` yaml
height: 42
gas_used: 4141
gas_used: 3613
answer:
has_more: false
results:
Expand All @@ -188,7 +188,7 @@ bech32_address(Address, axoneincorrect).

``` yaml
height: 42
gas_used: 4140
gas_used: 3612
answer:
has_more: false
variables: ["Address"]
Expand All @@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions docs/predicate/block_height_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ block_height(Height).

``` yaml
height: 100
gas_used: 4140
gas_used: 3612
answer:
has_more: false
variables: ["Height"]
Expand Down Expand Up @@ -79,7 +79,7 @@ Height > 100.

``` yaml
height: 101
gas_used: 4141
gas_used: 3613
answer:
has_more: false
variables: ["Height"]
Expand Down
4 changes: 2 additions & 2 deletions docs/predicate/block_time_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ block_time(Time).

``` yaml
height: 42
gas_used: 4140
gas_used: 3612
answer:
has_more: false
variables: ["Time"]
Expand Down Expand Up @@ -80,7 +80,7 @@ Time > 1709550216.

``` yaml
height: 42
gas_used: 4141
gas_used: 3613
answer:
has_more: false
variables: ["Time"]
Expand Down
6 changes: 3 additions & 3 deletions docs/predicate/consult_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ hello(Who).

``` yaml
height: 42
gas_used: 4143
gas_used: 3615
answer:
has_more: false
variables: ["Who"]
Expand Down Expand Up @@ -129,7 +129,7 @@ response: |

``` yaml
height: 42
gas_used: 4142
gas_used: 3614
answer:
has_more: false
variables: ["X"]
Expand Down Expand Up @@ -194,7 +194,7 @@ source_file(File).

``` yaml
height: 42
gas_used: 4141
gas_used: 3613
answer:
has_more: false
variables: ["File"]
Expand Down
16 changes: 8 additions & 8 deletions docs/predicate/current_output_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Here are the steps of the scenario:
``` json
{
"limits": {
"max_user_output_size": "5"
"max_user_output_size": 5
}
}
```
Expand All @@ -61,7 +61,7 @@ write_char_to_user_output(x).

``` yaml
height: 42
gas_used: 4241
gas_used: 3680
answer:
has_more: false
variables:
Expand All @@ -83,7 +83,7 @@ Here are the steps of the scenario:
``` json
{
"limits": {
"max_user_output_size": "15"
"max_user_output_size": 15
}
}
```
Expand All @@ -108,7 +108,7 @@ log_message('Hello world!').

``` yaml
height: 42
gas_used: 4276
gas_used: 3682
answer:
has_more: false
variables:
Expand All @@ -131,7 +131,7 @@ Here are the steps of the scenario:
``` json
{
"limits": {
"max_user_output_size": "5"
"max_user_output_size": 5
}
}
```
Expand All @@ -155,7 +155,7 @@ log_message('Hello world!').

``` yaml
height: 42
gas_used: 4242
gas_used: 3681
answer:
has_more: false
variables:
Expand All @@ -179,7 +179,7 @@ Here are the steps of the scenario:
``` json
{
"limits": {
"max_user_output_size": "5"
"max_user_output_size": 5
}
}
```
Expand All @@ -205,7 +205,7 @@ log_message("Hello 🧙!").

``` yaml
height: 42
gas_used: 4263
gas_used: 3702
answer:
has_more: false
variables:
Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/open_3.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ open(

``` yaml
height: 42
gas_used: 4141
gas_used: 3613
answer:
has_more: false
variables:
Expand Down
14 changes: 7 additions & 7 deletions docs/predicate/open_4.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ open(URI, read, _, []).

``` yaml
height: 42
gas_used: 4153
gas_used: 3625
answer:
has_more: false
variables: ["URI"]
Expand Down Expand Up @@ -152,7 +152,7 @@ read_resource('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08x

``` yaml
height: 42
gas_used: 4144
gas_used: 3616
answer:
has_more: false
variables: ["Chars"]
Expand Down Expand Up @@ -202,7 +202,7 @@ read_resource('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08x

``` yaml
height: 42
gas_used: 4144
gas_used: 3616
answer:
has_more: false
variables: ["Chars"]
Expand All @@ -229,7 +229,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t

``` yaml
height: 42
gas_used: 4140
gas_used: 3612
answer:
has_more: false
variables: ["Stream"]
Expand All @@ -255,7 +255,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t

``` yaml
height: 42
gas_used: 4140
gas_used: 3612
answer:
has_more: false
variables: ["Stream"]
Expand All @@ -281,7 +281,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t

``` yaml
height: 42
gas_used: 4140
gas_used: 3612
answer:
has_more: false
variables: ["Stream"]
Expand All @@ -306,7 +306,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t

``` yaml
height: 42
gas_used: 4140
gas_used: 3612
answer:
has_more: false
variables: ["Stream"]
Expand Down
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package logic.v1beta2;
package logic.v1beta3;

import "gogoproto/gogo.proto";

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 [
Expand All @@ -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\"" ];
}
Loading

0 comments on commit db18c9a

Please sign in to comment.