Skip to content

Commit

Permalink
chore: set config pointers for size validation
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed Jul 9, 2024
1 parent 3d00b26 commit 107c6c8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod compiler_version;
pub mod config;
pub mod errors;
pub mod gateway;
pub mod pointers;
pub mod rpc_objects;
pub mod rpc_state_reader;
pub mod state_reader;
Expand Down
43 changes: 43 additions & 0 deletions crates/gateway/src/pointers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/// Deal with config pointers.
use std::sync::OnceLock;

use papyrus_config::dumping::ser_pointer_target_param;
use papyrus_config::{ParamPath, SerializedParam};

type ConfigPointers = Vec<((ParamPath, SerializedParam), Vec<ParamPath>)>;

const MAX_BYTECODE_SIZE: usize = 50_000;
const MAX_RAW_CLASS_SIZE: usize = 1_000_000;

pub fn config_pointers() -> ConfigPointers {
static CONFIG_POINTERS: OnceLock<ConfigPointers> = OnceLock::new();
CONFIG_POINTERS
.get_or_init(|| {
vec![
(
ser_pointer_target_param(
"max_bytecode_size",
&MAX_BYTECODE_SIZE,
"The maximum bytecode size allowed for a contract.",
),
vec![
"gateway_config.stateless_tx_validator_config.max_bytecode_size".to_owned(),
"gateway_config.gateway_compiler_config.max_bytecode_size".to_owned(),
],
),
(
ser_pointer_target_param(
"max_raw_class_size",
&MAX_RAW_CLASS_SIZE,
"The maximum raw class size allowed for a contract.",
),
vec![
"gateway_config.stateless_tx_validator_config.max_raw_class_size"
.to_owned(),
"gateway_config.gateway_compiler_config.max_raw_class_size".to_owned(),
],
),
]
})
.to_vec()
}

0 comments on commit 107c6c8

Please sign in to comment.