Skip to content

Commit

Permalink
Merge pull request #1062 from scrtlabs/lior-change-recursion-limit-to-10
Browse files Browse the repository at this point in the history
Change query depth limit from 5 to 10
  • Loading branch information
liorbond authored Aug 7, 2022
2 parents 5246942 + 9d58c88 commit bfb28f4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cosmwasm/enclaves/shared/utils/src/recursion_depth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::cell::Cell;

use enclave_ffi_types::EnclaveError;

const RECURSION_LIMIT: u8 = 5;
const RECURSION_LIMIT: u8 = 10;

thread_local! {
/// This counter tracks the recursion depth of queries,
Expand Down
6 changes: 3 additions & 3 deletions x/compute/internal/keeper/secret_contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ func TestQueryRecursionLimitEnforcedInQueries(t *testing.T) {
_, _, addr, _, err := initHelper(t, keeper, ctx, codeID, walletA, privKeyA, `{"nop":{}}`, true, testContract.IsCosmWasmV1, defaultGasForTests)
require.Empty(t, err)

data, err := queryHelper(t, keeper, ctx, addr, fmt.Sprintf(`{"send_external_query_recursion_limit":{"to":"%s","code_hash":"%s", "depth":1}}`, addr.String(), codeHash), true, testContract.IsCosmWasmV1, defaultGasForTests)
data, err := queryHelper(t, keeper, ctx, addr, fmt.Sprintf(`{"send_external_query_recursion_limit":{"to":"%s","code_hash":"%s", "depth":1}}`, addr.String(), codeHash), true, testContract.IsCosmWasmV1, 2*defaultGasForTests)

require.NotEmpty(t, data)
require.Equal(t, data, "\"Recursion limit was correctly enforced\"")
Expand All @@ -1764,7 +1764,7 @@ func TestQueryRecursionLimitEnforcedInHandles(t *testing.T) {
_, _, addr, _, err := initHelper(t, keeper, ctx, codeID, walletA, privKeyA, `{"nop":{}}`, true, testContract.IsCosmWasmV1, defaultGasForTests)
require.Empty(t, err)

_, _, data, _, _, err := execHelper(t, keeper, ctx, addr, walletA, privKeyA, fmt.Sprintf(`{"send_external_query_recursion_limit":{"to":"%s","code_hash":"%s", "depth":1}}`, addr.String(), codeHash), true, testContract.IsCosmWasmV1, defaultGasForTests, 0)
_, _, data, _, _, err := execHelper(t, keeper, ctx, addr, walletA, privKeyA, fmt.Sprintf(`{"send_external_query_recursion_limit":{"to":"%s","code_hash":"%s", "depth":1}}`, addr.String(), codeHash), true, testContract.IsCosmWasmV1, 2*defaultGasForTests, 0)

require.NotEmpty(t, data)
require.Equal(t, string(data), "\"Recursion limit was correctly enforced\"")
Expand All @@ -1784,7 +1784,7 @@ func TestQueryRecursionLimitEnforcedInInits(t *testing.T) {
require.Empty(t, err)

// Initialize the contract that will be running the test
_, _, addr, events, err := initHelper(t, keeper, ctx, codeID, walletA, privKeyA, fmt.Sprintf(`{"send_external_query_recursion_limit":{"to":"%s","code_hash":"%s", "depth":1}}`, addr.String(), codeHash), true, testContract.IsCosmWasmV1, defaultGasForTests)
_, _, addr, events, err := initHelper(t, keeper, ctx, codeID, walletA, privKeyA, fmt.Sprintf(`{"send_external_query_recursion_limit":{"to":"%s","code_hash":"%s", "depth":1}}`, addr.String(), codeHash), true, testContract.IsCosmWasmV1, 2*defaultGasForTests)
require.Empty(t, err)

require.Nil(t, err.GenericErr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1286,8 +1286,8 @@ fn send_external_query_recursion_limit<S: Storage, A: Api, Q: Querier>(
),
}));

// 5 is the current recursion limit.
if depth != 5 {
// 10 is the current recursion limit.
if depth != 10 {
result
} else {
match result {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2002,8 +2002,8 @@ fn send_external_query_recursion_limit(
),
}));

// 5 is the current recursion limit.
if depth != 5 {
// 10 is the current recursion limit.
if depth != 10 {
result
} else {
match result {
Expand Down

0 comments on commit bfb28f4

Please sign in to comment.