Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change query depth limit from 5 to 10 #1062

Merged
merged 1 commit into from
Aug 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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