Skip to content

Commit

Permalink
chore: rename max_raw_class_size to max_contract_class_object_size (#355
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ArniStarkware authored Aug 15, 2024
1 parent 6e7b138 commit e783edf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config/mempool/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,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
Expand Down
8 changes: 4 additions & 4 deletions crates/gateway/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,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,
}
Expand All @@ -85,7 +85,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 },
}
Expand Down Expand Up @@ -120,8 +120,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,
),
Expand Down
4 changes: 2 additions & 2 deletions crates/gateway/src/stateless_transaction_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,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,
});
}

Expand Down
8 changes: 4 additions & 4 deletions crates/gateway/src/stateless_transaction_validator_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -301,10 +301,10 @@ fn test_declare_sierra_version_sucsses(#[case] sierra_program: Vec<Felt>) {

#[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
},
};
Expand All @@ -321,7 +321,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)
)
}

Expand Down

0 comments on commit e783edf

Please sign in to comment.