From 723ed8788d84dd4a809384f9e0da738458aefaff Mon Sep 17 00:00:00 2001 From: Arni Hod Date: Mon, 8 Jul 2024 14:15:12 +0300 Subject: [PATCH] chore: align config with python gateway --- config/default_config.json | 12 ++++++------ crates/gateway/src/config.rs | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/config/default_config.json b/config/default_config.json index b13bce9b3..42fa1ecad 100644 --- a/config/default_config.json +++ b/config/default_config.json @@ -35,19 +35,19 @@ "value": "0x0" }, "gateway_config.stateful_tx_validator_config.max_nonce_for_validation_skip": { - "description": "The maximum nonce for which the validation is skipped.", + "description": "Maximum nonce for which the validation is skipped.", "privacy": "Public", - "value": "0x0" + "value": "0x1" }, "gateway_config.stateful_tx_validator_config.max_recursion_depth": { - "description": "The maximum recursion depth allowed in a transaction.", + "description": "Maximum recursion depth for nested calls during blockifier validation.", "privacy": "Public", - "value": 0 + "value": 50 }, "gateway_config.stateful_tx_validator_config.validate_max_n_steps": { - "description": "The maximum number of steps the validation function is allowed to take.", + "description": "Maximum number of steps the validation function is allowed to take.", "privacy": "Public", - "value": 0 + "value": 1000000 }, "gateway_config.stateless_tx_validator_config.max_bytecode_size": { "description": "Limitation of contract bytecode size.", diff --git a/crates/gateway/src/config.rs b/crates/gateway/src/config.rs index 396fc70d1..8817b69eb 100644 --- a/crates/gateway/src/config.rs +++ b/crates/gateway/src/config.rs @@ -6,6 +6,7 @@ use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use starknet_api::core::{ChainId, ContractAddress, Nonce}; +use starknet_types_core::felt::Felt; use validator::Validate; use crate::compiler_version::VersionId; @@ -236,7 +237,7 @@ impl SerializeConfig for ChainInfoConfig { } } -#[derive(Clone, Debug, Default, Serialize, Deserialize, Validate, PartialEq)] +#[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)] pub struct StatefulTransactionValidatorConfig { pub max_nonce_for_validation_skip: Nonce, pub validate_max_n_steps: u32, @@ -244,25 +245,36 @@ pub struct StatefulTransactionValidatorConfig { pub chain_info: ChainInfoConfig, } +impl Default for StatefulTransactionValidatorConfig { + fn default() -> Self { + StatefulTransactionValidatorConfig { + max_nonce_for_validation_skip: Nonce(Felt::ONE), + validate_max_n_steps: 1_000_000, + max_recursion_depth: 50, + chain_info: ChainInfoConfig::default(), + } + } +} + impl SerializeConfig for StatefulTransactionValidatorConfig { fn dump(&self) -> BTreeMap { let members = BTreeMap::from_iter([ ser_param( "max_nonce_for_validation_skip", &self.max_nonce_for_validation_skip, - "The maximum nonce for which the validation is skipped.", + "Maximum nonce for which the validation is skipped.", ParamPrivacyInput::Public, ), ser_param( "validate_max_n_steps", &self.validate_max_n_steps, - "The maximum number of steps the validation function is allowed to take.", + "Maximum number of steps the validation function is allowed to take.", ParamPrivacyInput::Public, ), ser_param( "max_recursion_depth", &self.max_recursion_depth, - "The maximum recursion depth allowed in a transaction.", + "Maximum recursion depth for nested calls during blockifier validation.", ParamPrivacyInput::Public, ), ]);