Skip to content

Commit

Permalink
chore: align config with python gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed Jul 10, 2024
1 parent f81d8a4 commit 723ed87
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
12 changes: 6 additions & 6 deletions config/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
20 changes: 16 additions & 4 deletions crates/gateway/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -236,33 +237,44 @@ 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,
pub max_recursion_depth: usize,
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<ParamPath, SerializedParam> {
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,
),
]);
Expand Down

0 comments on commit 723ed87

Please sign in to comment.