diff --git a/docs/predicate/bech32_address_2.md b/docs/predicate/bech32_address_2.md
index 4416ce5f..a213ad73 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: 3876
+gas_used: 4140
answer:
has_more: false
variables: ["Address"]
@@ -72,7 +72,7 @@ bech32_address(-(Hrp, Address), 'axone15wn30a9z4uc692s0kkx5fp5d4qfr3ac77gvjg4').
``` yaml
height: 42
-gas_used: 3876
+gas_used: 4140
answer:
has_more: false
variables: ["Hrp", "Address"]
@@ -102,7 +102,7 @@ bech32_address(-(axone, Address), 'axone15wn30a9z4uc692s0kkx5fp5d4qfr3ac77gvjg4'
``` yaml
height: 42
-gas_used: 3876
+gas_used: 4140
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: 3876
+gas_used: 4140
answer:
has_more: false
variables: ["Bech32"]
@@ -162,7 +162,7 @@ axone_addr('axone1p8u47en82gmzfm259y6z93r9qe63l25d858vqu').
``` yaml
height: 42
-gas_used: 3876
+gas_used: 4140
answer:
has_more: false
results:
@@ -188,7 +188,7 @@ bech32_address(Address, axoneincorrect).
``` yaml
height: 42
-gas_used: 3876
+gas_used: 4140
answer:
has_more: false
variables: ["Address"]
@@ -215,7 +215,7 @@ bech32_address(-('axone', X), foo(bar)).
``` yaml
height: 42
-gas_used: 3876
+gas_used: 4140
answer:
has_more: false
variables: ["X"]
diff --git a/docs/predicate/block_height_1.md b/docs/predicate/block_height_1.md
index 9699df38..55167b86 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: 3876
+gas_used: 4140
answer:
has_more: false
variables: ["Height"]
@@ -79,7 +79,7 @@ Height > 100.
``` yaml
height: 101
-gas_used: 3877
+gas_used: 4141
answer:
has_more: false
variables: ["Height"]
diff --git a/docs/predicate/block_time_1.md b/docs/predicate/block_time_1.md
index 2a048b6a..a6fe13e8 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: 3876
+gas_used: 4140
answer:
has_more: false
variables: ["Time"]
@@ -80,7 +80,7 @@ Time > 1709550216.
``` yaml
height: 42
-gas_used: 3877
+gas_used: 4141
answer:
has_more: false
variables: ["Time"]
diff --git a/docs/predicate/consult_1.md b/docs/predicate/consult_1.md
index 3a1129c3..030e5753 100644
--- a/docs/predicate/consult_1.md
+++ b/docs/predicate/consult_1.md
@@ -65,7 +65,7 @@ hello(Who).
``` yaml
height: 42
-gas_used: 3878
+gas_used: 4142
answer:
has_more: false
variables: ["Who"]
@@ -129,7 +129,7 @@ response: |
``` yaml
height: 42
-gas_used: 3877
+gas_used: 4141
answer:
has_more: false
variables: ["X"]
@@ -194,7 +194,7 @@ source_file(File).
``` yaml
height: 42
-gas_used: 3877
+gas_used: 4141
answer:
has_more: false
variables: ["File"]
diff --git a/docs/predicate/current_output_1.md b/docs/predicate/current_output_1.md
index 250f274d..2ba280f0 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: 3976
+gas_used: 4240
answer:
has_more: false
variables:
@@ -108,7 +108,7 @@ log_message('Hello world!').
``` yaml
height: 42
-gas_used: 4010
+gas_used: 4274
answer:
has_more: false
variables:
@@ -155,7 +155,7 @@ log_message('Hello world!').
``` yaml
height: 42
-gas_used: 3976
+gas_used: 4240
answer:
has_more: false
variables:
@@ -205,7 +205,7 @@ log_message("Hello 🧙!").
``` yaml
height: 42
-gas_used: 3990
+gas_used: 4254
answer:
has_more: false
variables:
diff --git a/docs/predicate/open_3.md b/docs/predicate/open_3.md
index dd6677e3..5d5d5a0f 100644
--- a/docs/predicate/open_3.md
+++ b/docs/predicate/open_3.md
@@ -62,7 +62,7 @@ open(
``` yaml
height: 42
-gas_used: 3877
+gas_used: 4141
answer:
has_more: false
variables:
diff --git a/docs/predicate/open_4.md b/docs/predicate/open_4.md
index 241bf3ba..a9fd1262 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: 3882
+gas_used: 4146
answer:
has_more: false
variables: ["URI"]
@@ -152,7 +152,7 @@ read_resource('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08x
``` yaml
height: 42
-gas_used: 3878
+gas_used: 4142
answer:
has_more: false
variables: ["Chars"]
@@ -202,7 +202,7 @@ read_resource('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08x
``` yaml
height: 42
-gas_used: 3878
+gas_used: 4142
answer:
has_more: false
variables: ["Chars"]
@@ -229,7 +229,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t
``` yaml
height: 42
-gas_used: 3876
+gas_used: 4140
answer:
has_more: false
variables: ["Stream"]
@@ -255,7 +255,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t
``` yaml
height: 42
-gas_used: 3876
+gas_used: 4140
answer:
has_more: false
variables: ["Stream"]
@@ -281,7 +281,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t
``` yaml
height: 42
-gas_used: 3876
+gas_used: 4140
answer:
has_more: false
variables: ["Stream"]
@@ -306,7 +306,7 @@ open('cosmwasm:storage:axone15ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3t
``` yaml
height: 42
-gas_used: 3876
+gas_used: 4140
answer:
has_more: false
variables: ["Stream"]
diff --git a/docs/proto/logic.md b/docs/proto/logic.md
index 85558ad0..92b3fb88 100644
--- a/docs/proto/logic.md
+++ b/docs/proto/logic.md
@@ -279,6 +279,7 @@ Limits defines the limits of the logic module.
| `max_size` | [string](#string) | | max_size specifies the maximum size, in bytes, that is accepted for a program. nil 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 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. |
diff --git a/go.mod b/go.mod
index 9be12320..7a7598b8 100644
--- a/go.mod
+++ b/go.mod
@@ -54,6 +54,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
+ github.com/wk8/go-ordered-map/v2 v2.1.8
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0
golang.org/x/net v0.24.0
google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2
@@ -73,6 +74,10 @@ replace (
// Fix upstream GHSA-h395-qcrw-5vmq and GHSA-3vp4-m3rf-835h vulnerabilities.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0
+
+ // Use cutom fork of prolog interpreter
+ github.com/ichiban/prolog => github.com/axone-protocol/prolog v1.0.0
+
// replace broken goleveldb
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)
@@ -96,6 +101,7 @@ require (
github.com/VictoriaMetrics/fastcache v1.5.7 // indirect
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/aws/aws-sdk-go v1.44.224 // indirect
+ github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
@@ -103,6 +109,7 @@ require (
github.com/btcsuite/btcd v0.22.0-beta // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce // indirect
+ github.com/buger/jsonparser v1.1.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
@@ -110,6 +117,7 @@ require (
github.com/chzyer/readline v1.5.1 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
+ github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v1.1.0 // indirect
@@ -216,6 +224,7 @@ require (
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.8.14 // indirect
github.com/magiconair/properties v1.8.7 // indirect
+ github.com/mailru/easyjson v0.7.7 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
diff --git a/go.sum b/go.sum
index 7169140e..699a2e04 100644
--- a/go.sum
+++ b/go.sum
@@ -294,6 +294,10 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX
github.com/aws/aws-sdk-go v1.44.224 h1:09CiaaF35nRmxrzWZ2uRq5v6Ghg/d2RiPjZnSgtt+RQ=
github.com/aws/aws-sdk-go v1.44.224/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
+github.com/axone-protocol/prolog v1.0.0 h1:CASA1QrPOWhYox8YUStML33rekoA/7Gnp/ldDPZqCTA=
+github.com/axone-protocol/prolog v1.0.0/go.mod h1:lbZPekEi6qr5WX29GgEmhZlTxUkeWeiJ8cZZRq8qjAE=
+github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
+github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
@@ -326,6 +330,8 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY=
github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE=
+github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
+github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.8.0 h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA=
@@ -377,6 +383,8 @@ github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWH
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E=
github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw=
+github.com/cockroachdb/apd/v3 v3.2.1 h1:U+8j7t0axsIgvQUqthuNm82HIrYXodOV2iWLWtEaIwg=
+github.com/cockroachdb/apd/v3 v3.2.1/go.mod h1:klXJcjp+FffLTHlhIG69tezTDvdP065naDsHzKhYSqc=
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4=
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU=
@@ -832,8 +840,6 @@ github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSAS
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
-github.com/ichiban/prolog v1.2.0 h1:DrwolRMxdzI3126nCSpyxJtK4OVVqmbu7XpGhy8phXs=
-github.com/ichiban/prolog v1.2.0/go.mod h1:RmvNfGaSktvEVZ7nmpn0gkWa5u0Y3zQcK0G+Pl+ul+s=
github.com/ignite/cli v0.27.2 h1:NFzZqQrt8vhRQeStSvAMhpq65ag+lEAVP5ulw7cu3Y4=
github.com/ignite/cli v0.27.2/go.mod h1:7uaYQQ07tyOBiVAlRYAcZk2g/Y1vtgU0J09oPNntR4E=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
@@ -861,6 +867,7 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC
github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U=
github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
+github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
@@ -931,6 +938,8 @@ github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0Q
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
+github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
+github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA=
github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg=
github.com/matryer/is v1.3.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
@@ -1269,6 +1278,8 @@ github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
+github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
+github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg=
github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
diff --git a/proto/logic/v1beta2/params.proto b/proto/logic/v1beta2/params.proto
index ac5cf81b..8193b207 100644
--- a/proto/logic/v1beta2/params.proto
+++ b/proto/logic/v1beta2/params.proto
@@ -59,6 +59,14 @@ message Limits {
(gogoproto.customtype) = "cosmossdk.io/math.Uint",
(gogoproto.nullable) = true
];
+
+ // 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
+ ];
}
// Filter defines the parameters for filtering the set of strings which can designate anything.
diff --git a/x/logic/interpreter/interpreter.go b/x/logic/interpreter/interpreter.go
index eaabf567..91bae510 100644
--- a/x/logic/interpreter/interpreter.go
+++ b/x/logic/interpreter/interpreter.go
@@ -8,6 +8,8 @@ import (
"github.com/ichiban/prolog"
"github.com/ichiban/prolog/engine"
+
+ "cosmossdk.io/math"
)
// Option is a function that configures an Interpreter.
@@ -68,17 +70,28 @@ func WithFS(fs fs.FS) Option {
}
}
+func WithMaxVariables(maxVariables *math.Uint) Option {
+ return func(i *prolog.Interpreter) error {
+ if maxVariables != nil {
+ i.SetMaxVariables(maxVariables.Uint64())
+ } else {
+ i.SetMaxVariables(0)
+ }
+ return nil
+ }
+}
+
// New creates a new prolog.Interpreter with the specified options.
func New(
opts ...Option,
) (*prolog.Interpreter, error) {
- var i prolog.Interpreter
+ i := prolog.NewEmpty()
for _, opt := range opts {
- if err := opt(&i); err != nil {
+ if err := opt(i); err != nil {
return nil, err
}
}
- return &i, nil
+ return i, nil
}
diff --git a/x/logic/interpreter/registry.go b/x/logic/interpreter/registry.go
index 50af563a..6b5da221 100644
--- a/x/logic/interpreter/registry.go
+++ b/x/logic/interpreter/registry.go
@@ -7,125 +7,128 @@ import (
"github.com/ichiban/prolog"
"github.com/ichiban/prolog/engine"
+ orderedmap "github.com/wk8/go-ordered-map/v2"
"github.com/axone-protocol/axoned/v8/x/logic/predicate"
)
// registry is a map from predicate names (in the form of "atom/arity") to predicates functions.
-var registry = map[string]any{
- "call/1": engine.Call,
- "catch/3": engine.Catch,
- "throw/1": engine.Throw,
- "=/2": engine.Unify,
- "unify_with_occurs_check/2": engine.UnifyWithOccursCheck,
- "subsumes_term/2": engine.SubsumesTerm,
- "var/1": engine.TypeVar,
- "atom/1": engine.TypeAtom,
- "integer/1": engine.TypeInteger,
- "float/1": engine.TypeFloat,
- "compound/1": engine.TypeCompound,
- "acyclic_term/1": engine.AcyclicTerm,
- "compare/3": engine.Compare,
- "sort/2": engine.Sort,
- "keysort/2": engine.KeySort,
- "functor/3": engine.Functor,
- "arg/3": engine.Arg,
- "=../2": engine.Univ,
- "copy_term/2": engine.CopyTerm,
- "term_variables/2": engine.TermVariables,
- "is/2": engine.Is,
- "=:=/2": engine.Equal,
- "=\\=/2": engine.NotEqual,
- "2": engine.LessThan,
- "=2": engine.LessThanOrEqual,
- ">/2": engine.GreaterThan,
- ">=/2": engine.GreaterThanOrEqual,
- "clause/2": engine.Clause,
- "current_predicate/1": engine.CurrentPredicate,
- "asserta/1": engine.Asserta,
- "assertz/1": engine.Assertz,
- "retract/1": engine.Retract,
- "abolish/1": engine.Abolish,
- "findall/3": engine.FindAll,
- "bagof/3": engine.BagOf,
- "setof/3": engine.SetOf,
- "current_input/1": engine.CurrentInput,
- "current_output/1": predicate.CurrentOutput,
- "set_input/1": engine.SetInput,
- "set_output/1": engine.SetOutput,
- "open/4": predicate.Open,
- "open/3": predicate.Open3,
- "close/2": engine.Close,
- "flush_output/1": engine.FlushOutput,
- "stream_property/2": engine.StreamProperty,
- "set_stream_position/2": engine.SetStreamPosition,
- "get_char/2": engine.GetChar,
- "peek_char/2": engine.PeekChar,
- "put_char/2": engine.PutChar,
- "get_byte/2": engine.GetByte,
- "peek_byte/2": engine.PeekByte,
- "put_byte/2": engine.PutByte,
- "read_term/3": engine.ReadTerm,
- "write_term/3": engine.WriteTerm,
- "op/3": engine.Op,
- "current_op/3": engine.CurrentOp,
- "char_conversion/2": engine.CharConversion,
- "current_char_conversion/2": engine.CurrentCharConversion,
- `\+/1`: engine.Negate,
- "repeat/0": engine.Repeat,
- "call/2": engine.Call1,
- "call/3": engine.Call2,
- "call/4": engine.Call3,
- "call/5": engine.Call4,
- "call/6": engine.Call5,
- "call/7": engine.Call6,
- "call/8": engine.Call7,
- "atom_length/2": engine.AtomLength,
- "atom_concat/3": engine.AtomConcat,
- "sub_atom/5": engine.SubAtom,
- "atom_chars/2": engine.AtomChars,
- "atom_codes/2": engine.AtomCodes,
- "char_code/2": engine.CharCode,
- "number_chars/2": engine.NumberChars,
- "number_codes/2": engine.NumberCodes,
- "set_prolog_flag/2": engine.SetPrologFlag,
- "current_prolog_flag/2": engine.CurrentPrologFlag,
- "halt/1": engine.Halt,
- "consult/1": predicate.Consult,
- "phrase/3": engine.Phrase,
- "expand_term/2": engine.ExpandTerm,
- "append/3": engine.Append,
- "length/2": engine.Length,
- "between/3": engine.Between,
- "succ/2": engine.Succ,
- "nth0/3": engine.Nth0,
- "nth1/3": engine.Nth1,
- "call_nth/2": engine.CallNth,
- "chain_id/1": predicate.ChainID,
- "block_height/1": predicate.BlockHeight,
- "block_time/1": predicate.BlockTime,
- "bank_balances/2": predicate.BankBalances,
- "bank_spendable_balances/2": predicate.BankSpendableBalances,
- "bank_locked_balances/2": predicate.BankLockedBalances,
- "did_components/2": predicate.DIDComponents,
- "crypto_data_hash/3": predicate.CryptoDataHash,
- "hex_bytes/2": predicate.HexBytes,
- "bech32_address/2": predicate.Bech32Address,
- "source_file/1": predicate.SourceFile,
- "json_prolog/2": predicate.JSONProlog,
- "uri_encoded/3": predicate.URIEncoded,
- "read_string/3": predicate.ReadString,
- "eddsa_verify/4": predicate.EDDSAVerify,
- "ecdsa_verify/4": predicate.ECDSAVerify,
- "string_bytes/3": predicate.StringBytes,
-}
+var registry = orderedmap.New[string, any](
+ orderedmap.WithInitialData[string, any]([]orderedmap.Pair[string, any]{
+ {Key: "call/1", Value: engine.Call},
+ {Key: "catch/3", Value: engine.Catch},
+ {Key: "throw/1", Value: engine.Throw},
+ {Key: "=/2", Value: engine.Unify},
+ {Key: "unify_with_occurs_check/2", Value: engine.UnifyWithOccursCheck},
+ {Key: "subsumes_term/2", Value: engine.SubsumesTerm},
+ {Key: "var/1", Value: engine.TypeVar},
+ {Key: "atom/1", Value: engine.TypeAtom},
+ {Key: "integer/1", Value: engine.TypeInteger},
+ {Key: "float/1", Value: engine.TypeFloat},
+ {Key: "compound/1", Value: engine.TypeCompound},
+ {Key: "acyclic_term/1", Value: engine.AcyclicTerm},
+ {Key: "compare/3", Value: engine.Compare},
+ {Key: "sort/2", Value: engine.Sort},
+ {Key: "keysort/2", Value: engine.KeySort},
+ {Key: "functor/3", Value: engine.Functor},
+ {Key: "arg/3", Value: engine.Arg},
+ {Key: "=../2", Value: engine.Univ},
+ {Key: "copy_term/2", Value: engine.CopyTerm},
+ {Key: "term_variables/2", Value: engine.TermVariables},
+ {Key: "is/2", Value: engine.Is},
+ {Key: "=:=/2", Value: engine.Equal},
+ {Key: "=\\=/2", Value: engine.NotEqual},
+ {Key: "2", Value: engine.LessThan},
+ {Key: "=2", Value: engine.LessThanOrEqual},
+ {Key: ">/2", Value: engine.GreaterThan},
+ {Key: ">=/2", Value: engine.GreaterThanOrEqual},
+ {Key: "clause/2", Value: engine.Clause},
+ {Key: "current_predicate/1", Value: engine.CurrentPredicate},
+ {Key: "asserta/1", Value: engine.Asserta},
+ {Key: "assertz/1", Value: engine.Assertz},
+ {Key: "retract/1", Value: engine.Retract},
+ {Key: "abolish/1", Value: engine.Abolish},
+ {Key: "findall/3", Value: engine.FindAll},
+ {Key: "bagof/3", Value: engine.BagOf},
+ {Key: "setof/3", Value: engine.SetOf},
+ {Key: "current_input/1", Value: engine.CurrentInput},
+ {Key: "current_output/1", Value: predicate.CurrentOutput},
+ {Key: "set_input/1", Value: engine.SetInput},
+ {Key: "set_output/1", Value: engine.SetOutput},
+ {Key: "open/4", Value: predicate.Open},
+ {Key: "open/3", Value: predicate.Open3},
+ {Key: "close/2", Value: engine.Close},
+ {Key: "flush_output/1", Value: engine.FlushOutput},
+ {Key: "stream_property/2", Value: engine.StreamProperty},
+ {Key: "set_stream_position/2", Value: engine.SetStreamPosition},
+ {Key: "get_char/2", Value: engine.GetChar},
+ {Key: "peek_char/2", Value: engine.PeekChar},
+ {Key: "put_char/2", Value: engine.PutChar},
+ {Key: "get_byte/2", Value: engine.GetByte},
+ {Key: "peek_byte/2", Value: engine.PeekByte},
+ {Key: "put_byte/2", Value: engine.PutByte},
+ {Key: "read_term/3", Value: engine.ReadTerm},
+ {Key: "write_term/3", Value: engine.WriteTerm},
+ {Key: "op/3", Value: engine.Op},
+ {Key: "current_op/3", Value: engine.CurrentOp},
+ {Key: "char_conversion/2", Value: engine.CharConversion},
+ {Key: "current_char_conversion/2", Value: engine.CurrentCharConversion},
+ {Key: "\\+/1", Value: engine.Negate},
+ {Key: "repeat/0", Value: engine.Repeat},
+ {Key: "call/2", Value: engine.Call1},
+ {Key: "call/3", Value: engine.Call2},
+ {Key: "call/4", Value: engine.Call3},
+ {Key: "call/5", Value: engine.Call4},
+ {Key: "call/6", Value: engine.Call5},
+ {Key: "call/7", Value: engine.Call6},
+ {Key: "call/8", Value: engine.Call7},
+ {Key: "atom_length/2", Value: engine.AtomLength},
+ {Key: "atom_concat/3", Value: engine.AtomConcat},
+ {Key: "sub_atom/5", Value: engine.SubAtom},
+ {Key: "atom_chars/2", Value: engine.AtomChars},
+ {Key: "atom_codes/2", Value: engine.AtomCodes},
+ {Key: "char_code/2", Value: engine.CharCode},
+ {Key: "number_chars/2", Value: engine.NumberChars},
+ {Key: "number_codes/2", Value: engine.NumberCodes},
+ {Key: "set_prolog_flag/2", Value: engine.SetPrologFlag},
+ {Key: "current_prolog_flag/2", Value: engine.CurrentPrologFlag},
+ {Key: "halt/1", Value: engine.Halt},
+ {Key: "consult/1", Value: predicate.Consult},
+ {Key: "phrase/3", Value: engine.Phrase},
+ {Key: "expand_term/2", Value: engine.ExpandTerm},
+ {Key: "append/3", Value: engine.Append},
+ {Key: "length/2", Value: engine.Length},
+ {Key: "between/3", Value: engine.Between},
+ {Key: "succ/2", Value: engine.Succ},
+ {Key: "nth0/3", Value: engine.Nth0},
+ {Key: "nth1/3", Value: engine.Nth1},
+ {Key: "call_nth/2", Value: engine.CallNth},
+ {Key: "chain_id/1", Value: predicate.ChainID},
+ {Key: "block_height/1", Value: predicate.BlockHeight},
+ {Key: "block_time/1", Value: predicate.BlockTime},
+ {Key: "bank_balances/2", Value: predicate.BankBalances},
+ {Key: "bank_spendable_balances/2", Value: predicate.BankSpendableBalances},
+ {Key: "bank_locked_balances/2", Value: predicate.BankLockedBalances},
+ {Key: "did_components/2", Value: predicate.DIDComponents},
+ {Key: "crypto_data_hash/3", Value: predicate.CryptoDataHash},
+ {Key: "hex_bytes/2", Value: predicate.HexBytes},
+ {Key: "bech32_address/2", Value: predicate.Bech32Address},
+ {Key: "source_file/1", Value: predicate.SourceFile},
+ {Key: "json_prolog/2", Value: predicate.JSONProlog},
+ {Key: "uri_encoded/3", Value: predicate.URIEncoded},
+ {Key: "read_string/3", Value: predicate.ReadString},
+ {Key: "eddsa_verify/4", Value: predicate.EDDSAVerify},
+ {Key: "ecdsa_verify/4", Value: predicate.ECDSAVerify},
+ {Key: "string_bytes/3", Value: predicate.StringBytes},
+ }...),
+)
// RegistryNames is the list of the predicate names in the Registry.
var RegistryNames = func() []string {
- names := make([]string, 0, len(registry))
+ names := make([]string, 0, registry.Len())
- for name := range registry {
- names = append(names, name)
+ for name := registry.Oldest(); name != nil; name = name.Next() {
+ names = append(names, name.Key)
}
return names
}()
@@ -140,7 +143,7 @@ type Hook = func(functor string) func(env *engine.Env) error
//
//nolint:lll
func Register(i *prolog.Interpreter, name string, hook Hook) error {
- if p, ok := registry[name]; ok {
+ if p, ok := registry.Get(name); ok {
parts := strings.Split(name, "/")
if len(parts) == 2 {
atom := engine.NewAtom(parts[0])
diff --git a/x/logic/keeper/features/bech32_address_2.feature b/x/logic/keeper/features/bech32_address_2.feature
index 053c911b..f2672993 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: 3876
+ gas_used: 4140
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: 3876
+ gas_used: 4140
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: 3876
+ gas_used: 4140
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: 3876
+ gas_used: 4140
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: 3876
+ gas_used: 4140
answer:
has_more: false
results:
@@ -130,7 +130,7 @@ Feature: bech32_address/2
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3876
+ gas_used: 4140
answer:
has_more: false
results:
@@ -146,7 +146,7 @@ Feature: bech32_address/2
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3876
+ gas_used: 4140
answer:
has_more: false
results:
@@ -163,7 +163,7 @@ Feature: bech32_address/2
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3876
+ gas_used: 4140
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: 3876
+ gas_used: 4140
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: 3876
+ gas_used: 4140
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: 3876
+ gas_used: 4140
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: 3876
+ gas_used: 4140
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: 3876
+ gas_used: 4140
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: 3876
+ gas_used: 4140
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: 3876
+ gas_used: 4140
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: 3876
+ gas_used: 4140
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: 3876
+ gas_used: 4140
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 f1f2d271..562c2ff4 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: 3876
+ gas_used: 4140
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: 3877
+ gas_used: 4141
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 ae35c9e6..fdf139ae 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: 3876
+ gas_used: 4140
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: 3877
+ gas_used: 4141
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 27ac3ef8..05b95d85 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: 3878
+ gas_used: 4142
answer:
has_more: false
variables: ["Who"]
@@ -90,7 +90,7 @@ Feature: consult/1
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3877
+ gas_used: 4141
answer:
has_more: false
variables: ["X"]
@@ -144,7 +144,7 @@ Feature: consult/1
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3877
+ gas_used: 4141
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 1468a9b0..bbf9ffa3 100644
--- a/x/logic/keeper/features/current_output_1.feature
+++ b/x/logic/keeper/features/current_output_1.feature
@@ -28,7 +28,7 @@ Feature: current_output/1
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3976
+ gas_used: 4240
answer:
has_more: false
variables:
@@ -66,7 +66,7 @@ Feature: current_output/1
Then the answer we get is:
""" yaml
height: 42
- gas_used: 4010
+ gas_used: 4274
answer:
has_more: false
variables:
@@ -104,7 +104,7 @@ Feature: current_output/1
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3976
+ gas_used: 4240
answer:
has_more: false
variables:
@@ -145,7 +145,7 @@ Feature: current_output/1
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3990
+ gas_used: 4254
answer:
has_more: false
variables:
@@ -176,7 +176,7 @@ Feature: current_output/1
Then the answer we get is:
""" yaml
height: 42
- gas_used: 4261
+ gas_used: 4525
answer:
has_more: false
variables:
diff --git a/x/logic/keeper/features/open_3.feature b/x/logic/keeper/features/open_3.feature
index d9e52e3d..553e3c5a 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: 3877
+ gas_used: 4141
answer:
has_more: false
variables:
diff --git a/x/logic/keeper/features/open_4.feature b/x/logic/keeper/features/open_4.feature
index b59f6ff1..6438b31e 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: 3882
+ gas_used: 4146
answer:
has_more: false
variables: ["URI"]
@@ -86,7 +86,7 @@ Feature: open/4
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3878
+ gas_used: 4142
answer:
has_more: false
variables: ["Chars"]
@@ -127,7 +127,7 @@ Feature: open/4
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3878
+ gas_used: 4142
answer:
has_more: false
variables: ["Chars"]
@@ -149,7 +149,7 @@ Feature: open/4
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3876
+ gas_used: 4140
answer:
has_more: false
variables: ["Stream"]
@@ -170,7 +170,7 @@ Feature: open/4
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3876
+ gas_used: 4140
answer:
has_more: false
variables: ["Stream"]
@@ -191,7 +191,7 @@ Feature: open/4
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3876
+ gas_used: 4140
answer:
has_more: false
variables: ["Stream"]
@@ -212,7 +212,7 @@ Feature: open/4
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3876
+ gas_used: 4140
answer:
has_more: false
variables: ["Stream"]
@@ -232,7 +232,7 @@ Feature: open/4
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3876
+ gas_used: 4140
answer:
has_more: false
variables: ["Stream"]
@@ -251,7 +251,7 @@ Feature: open/4
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3876
+ gas_used: 4140
answer:
has_more: false
variables: ["Stream"]
@@ -270,7 +270,7 @@ Feature: open/4
Then the answer we get is:
""" yaml
height: 42
- gas_used: 3876
+ gas_used: 4140
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: 3876
+ gas_used: 4140
answer:
has_more: false
variables: ["Mode", "Stream"]
diff --git a/x/logic/keeper/grpc_query_ask_test.go b/x/logic/keeper/grpc_query_ask_test.go
index 360c594b..18da07b3 100644
--- a/x/logic/keeper/grpc_query_ask_test.go
+++ b/x/logic/keeper/grpc_query_ask_test.go
@@ -40,6 +40,7 @@ func TestGRPCAsk(t *testing.T) {
maxSize int
predicateBlacklist []string
maxGas uint64
+ maxVariables uint64
predicateCosts map[string]uint64
expectedAnswer *types.Answer
expectedError string
@@ -143,7 +144,7 @@ func TestGRPCAsk(t *testing.T) {
{
query: "bank_balances(X, Y).",
maxGas: 3000,
- expectedError: "out of gas: logic (3093/3000): limit exceeded",
+ expectedError: "out of gas: logic (3102/3000): limit exceeded",
},
{
query: "block_height(X).",
@@ -151,7 +152,12 @@ 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 (11176/3000): limit exceeded",
+ },
+ {
+ query: "length(List, 100000).",
+ maxVariables: 1000,
+ expectedError: "maximum number of variables reached: limit exceeded",
},
{
program: "father(bob, 'élodie').",
@@ -351,6 +357,8 @@ foo(a4).
params := types.DefaultParams()
params.Limits.MaxResultCount = &maxResultCount
params.Limits.MaxSize = &maxSize
+ maxVariables := sdkmath.NewUint(tc.maxVariables)
+ params.Limits.MaxVariables = &maxVariables
if tc.predicateBlacklist != nil {
params.Interpreter.PredicatesFilter.Blacklist = tc.predicateBlacklist
}
diff --git a/x/logic/keeper/grpc_query_params_test.go b/x/logic/keeper/grpc_query_params_test.go
index 032da10a..653ec393 100644
--- a/x/logic/keeper/grpc_query_params_test.go
+++ b/x/logic/keeper/grpc_query_params_test.go
@@ -43,6 +43,7 @@ func TestGRPCParams(t *testing.T) {
types.WithMaxSize(math.NewUint(2)),
types.WithMaxResultCount(math.NewUint(3)),
types.WithMaxUserOutputSize(math.NewUint(4)),
+ types.WithMaxVariables(math.NewUint(5)),
),
),
},
diff --git a/x/logic/keeper/interpreter.go b/x/logic/keeper/interpreter.go
index 189e5dc8..5e2fbf65 100644
--- a/x/logic/keeper/interpreter.go
+++ b/x/logic/keeper/interpreter.go
@@ -133,6 +133,7 @@ func (k Keeper) newInterpreter(ctx context.Context, params types.Params) (*prolo
interpreter.WithBootstrap(ctx, util.NonZeroOrDefault(interpreterParams.GetBootstrap(), bootstrap.Bootstrap())),
interpreter.WithFS(filtered.NewFS(k.fsProvider(ctx), whitelistUrls, blacklistUrls)),
interpreter.WithUserOutputWriter(userOutputBuffer),
+ interpreter.WithMaxVariables(limits.MaxVariables),
}
i, err := interpreter.New(options...)
diff --git a/x/logic/prolog/tuple.go b/x/logic/prolog/tuple.go
index c7d41903..3fca4574 100644
--- a/x/logic/prolog/tuple.go
+++ b/x/logic/prolog/tuple.go
@@ -4,5 +4,5 @@ import "github.com/ichiban/prolog/engine"
// Tuple is a predicate which unifies the given term with a tuple of the given arity.
func Tuple(args ...engine.Term) engine.Term {
- return engine.Atom(0).Apply(args...)
+ return engine.Atom("").Apply(args...)
}
diff --git a/x/logic/types/params.go b/x/logic/types/params.go
index 16ce83ee..3248ff34 100644
--- a/x/logic/types/params.go
+++ b/x/logic/types/params.go
@@ -17,6 +17,7 @@ var (
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.
@@ -146,6 +147,13 @@ func WithMaxUserOutputSize(maxUserOutputSize math.Uint) LimitsOption {
}
}
+// WithMaxVariables sets the maximum number of variables that can be created by the interpreter.
+func WithMaxVariables(maxVariables math.Uint) LimitsOption {
+ return func(i *Limits) {
+ i.MaxVariables = &maxVariables
+ }
+}
+
// NewLimits creates a new Limits object.
func NewLimits(opts ...LimitsOption) Limits {
l := Limits{}
@@ -161,6 +169,10 @@ func NewLimits(opts ...LimitsOption) Limits {
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 c7bf7a3e..047a45d6 100644
--- a/x/logic/types/params.pb.go
+++ b/x/logic/types/params.pb.go
@@ -101,6 +101,9 @@ type Limits struct {
// 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{} }
@@ -390,53 +393,55 @@ func init() {
func init() { proto.RegisterFile("logic/v1beta2/params.proto", fileDescriptor_3af0daa241de0fa3) }
var fileDescriptor_3af0daa241de0fa3 = []byte{
- // 732 bytes of a gzipped FileDescriptorProto
+ // 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, 0xe3, 0x5d, 0x8f, 0x49, 0xe2, 0x0c, 0x4e, 0x56, 0xeb, 0xdd, 0xd8, 0x66, 0x4e,
- 0x39, 0xec, 0xca, 0x24, 0x0b, 0x59, 0x1a, 0x28, 0x05, 0xa5, 0xa4, 0x2d, 0x0d, 0x34, 0x4c, 0x09,
- 0x94, 0x5e, 0xcc, 0x58, 0x9e, 0xc8, 0x43, 0x24, 0x8f, 0xd0, 0x8c, 0x12, 0x3b, 0xc7, 0x3e, 0x41,
- 0x0f, 0x3d, 0xf4, 0xd0, 0x43, 0x5f, 0xa1, 0x6f, 0x91, 0x53, 0xc9, 0xb1, 0xf4, 0x60, 0x4a, 0xf2,
- 0x06, 0x79, 0x82, 0xa2, 0x19, 0x59, 0xb2, 0xd5, 0x80, 0xc9, 0x6d, 0xfc, 0xfd, 0xbe, 0xdf, 0x9f,
- 0xf9, 0xe6, 0xb3, 0x0d, 0x9a, 0x1e, 0x77, 0x99, 0xd3, 0x3d, 0xdf, 0xe9, 0x53, 0x49, 0x76, 0xbb,
- 0x01, 0x09, 0x89, 0x2f, 0xac, 0x20, 0xe4, 0x92, 0xc3, 0x15, 0x85, 0x59, 0x09, 0xd6, 0x6c, 0xb8,
- 0xdc, 0xe5, 0x0a, 0xe9, 0xc6, 0x27, 0xdd, 0x84, 0xde, 0x15, 0x41, 0xe5, 0x58, 0xb1, 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, 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) {
@@ -512,6 +517,18 @@ 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))
+ }
+ i--
+ dAtA[i] = 0x2a
+ }
if m.MaxUserOutputSize != nil {
{
size := m.MaxUserOutputSize.Size()
@@ -789,6 +806,10 @@ func (m *Limits) Size() (n int) {
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
}
@@ -1162,6 +1183,42 @@ func (m *Limits) Unmarshal(dAtA []byte) error {
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:])
diff --git a/x/logic/types/params_test.go b/x/logic/types/params_test.go
index a1791a84..b4ba1cf8 100644
--- a/x/logic/types/params_test.go
+++ b/x/logic/types/params_test.go
@@ -39,6 +39,7 @@ func TestValidateParams(t *testing.T) {
types.WithMaxSize(math.NewUint(2)),
types.WithMaxResultCount(math.NewUint(3)),
types.WithMaxUserOutputSize(math.NewUint(4)),
+ types.WithMaxVariables(math.NewUint(5)),
),
),
expectErr: false,
diff --git a/x/logic/util/prolog.go b/x/logic/util/prolog.go
index 05807bfe..5d521068 100644
--- a/x/logic/util/prolog.go
+++ b/x/logic/util/prolog.go
@@ -54,16 +54,18 @@ func QueryInterpreter(
// error is not part of the look-ahead and should be included in the solutions
sdkCtx := sdk.UnwrapSDKContext(ctx)
+ var panicErr engine.PanicError
switch {
case errors.Is(callErr, types.LimitExceeded):
return nil, callErr
+ case errors.As(callErr, &panicErr) && errors.Is(panicErr.OriginErr, engine.ErrMaxVariables):
+ return nil, errorsmod.Wrapf(types.LimitExceeded, panicErr.OriginErr.Error())
case sdkCtx.GasMeter().IsOutOfGas():
return nil, errorsmod.Wrapf(
types.LimitExceeded, "out of gas: %s <%s> (%d/%d)",
types.ModuleName, callErr.Error(), sdkCtx.GasMeter().GasConsumed(), sdkCtx.GasMeter().Limit())
- default:
- results = append(results, types.Result{Error: callErr.Error()})
}
+ 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()