From 26f3acccf2fd0ca3c0b7df732a141b9e98c828a4 Mon Sep 17 00:00:00 2001 From: Arni Hod Date: Wed, 7 Aug 2024 14:57:28 +0300 Subject: [PATCH] chore: rename max_raw_class_size to max_contract_class_object_size --- config/mempool/default_config.json | 2 +- crates/gateway/src/config.rs | 8 ++++---- crates/gateway/src/stateless_transaction_validator.rs | 4 ++-- .../gateway/src/stateless_transaction_validator_test.rs | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/config/mempool/default_config.json b/config/mempool/default_config.json index 9d1722e344b..47cdf86e5ba 100644 --- a/config/mempool/default_config.json +++ b/config/mempool/default_config.json @@ -64,7 +64,7 @@ "privacy": "Public", "value": 4000 }, - "gateway_config.stateless_tx_validator_config.max_raw_class_size": { + "gateway_config.stateless_tx_validator_config.max_contract_class_object_size": { "description": "Limitation of contract class object size.", "privacy": "Public", "value": 4089446 diff --git a/crates/gateway/src/config.rs b/crates/gateway/src/config.rs index a7f1ba36bd9..7c6d6270dff 100644 --- a/crates/gateway/src/config.rs +++ b/crates/gateway/src/config.rs @@ -76,7 +76,7 @@ pub struct StatelessTransactionValidatorConfig { pub max_signature_length: usize, // Declare txs specific config. - pub max_raw_class_size: usize, + pub max_contract_class_object_size: usize, pub min_sierra_version: VersionId, pub max_sierra_version: VersionId, } @@ -88,7 +88,7 @@ impl Default for StatelessTransactionValidatorConfig { validate_non_zero_l2_gas_fee: false, max_calldata_length: 4000, max_signature_length: 4000, - max_raw_class_size: 4089446, + max_contract_class_object_size: 4089446, min_sierra_version: VersionId { major: 1, minor: 1, patch: 0 }, max_sierra_version: VersionId { major: 1, minor: 5, patch: usize::MAX }, } @@ -123,8 +123,8 @@ impl SerializeConfig for StatelessTransactionValidatorConfig { ParamPrivacyInput::Public, ), ser_param( - "max_raw_class_size", - &self.max_raw_class_size, + "max_contract_class_object_size", + &self.max_contract_class_object_size, "Limitation of contract class object size.", ParamPrivacyInput::Public, ), diff --git a/crates/gateway/src/stateless_transaction_validator.rs b/crates/gateway/src/stateless_transaction_validator.rs index 800d88931b2..823f305c13c 100644 --- a/crates/gateway/src/stateless_transaction_validator.rs +++ b/crates/gateway/src/stateless_transaction_validator.rs @@ -143,10 +143,10 @@ impl StatelessTransactionValidator { let contract_class_object_size = serde_json::to_string(&contract_class) .expect("Unexpected error serializing contract class.") .len(); - if contract_class_object_size > self.config.max_raw_class_size { + if contract_class_object_size > self.config.max_contract_class_object_size { return Err(StatelessTransactionValidatorError::ContractClassObjectSizeTooLarge { contract_class_object_size, - max_contract_class_object_size: self.config.max_raw_class_size, + max_contract_class_object_size: self.config.max_contract_class_object_size, }); } diff --git a/crates/gateway/src/stateless_transaction_validator_test.rs b/crates/gateway/src/stateless_transaction_validator_test.rs index 1fedae98184..742175c008c 100644 --- a/crates/gateway/src/stateless_transaction_validator_test.rs +++ b/crates/gateway/src/stateless_transaction_validator_test.rs @@ -36,7 +36,7 @@ const DEFAULT_VALIDATOR_CONFIG_FOR_TESTING: StatelessTransactionValidatorConfig validate_non_zero_l2_gas_fee: false, max_calldata_length: 1, max_signature_length: 1, - max_raw_class_size: 100000, + max_contract_class_object_size: 100000, min_sierra_version: MIN_SIERRA_VERSION, max_sierra_version: MAX_SIERRA_VERSION, }; @@ -289,10 +289,10 @@ fn test_declare_sierra_version_sucsses(#[case] sierra_program: Vec) { #[test] fn test_declare_contract_class_size_too_long() { - let config_max_raw_class_size = 100; // Some arbitrary value, which will fail the test. + let config_max_contract_class_object_size = 100; // Some arbitrary value, which will fail the test. let tx_validator = StatelessTransactionValidator { config: StatelessTransactionValidatorConfig { - max_raw_class_size: config_max_raw_class_size, + max_contract_class_object_size: config_max_contract_class_object_size, ..DEFAULT_VALIDATOR_CONFIG_FOR_TESTING }, }; @@ -307,7 +307,7 @@ fn test_declare_contract_class_size_too_long() { contract_class_object_size, max_contract_class_object_size } if ( contract_class_object_size, max_contract_class_object_size - ) == (contract_class_length, config_max_raw_class_size) + ) == (contract_class_length, config_max_contract_class_object_size) ) }