Skip to content

Commit

Permalink
feat: use gateway config in mempool config
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed May 21, 2024
1 parent a60cc4b commit 0ff40fa
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 28 deletions.
2 changes: 1 addition & 1 deletion crates/gateway/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam};
use serde::{Deserialize, Serialize};
use validator::Validate;

#[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)]
#[derive(Clone, Debug, Default, Serialize, Deserialize, Validate, PartialEq)]
pub struct GatewayConfig {
pub network_config: GatewayNetworkConfig,
pub stateless_transaction_validator_config: StatelessTransactionValidatorConfig,
Expand Down
14 changes: 11 additions & 3 deletions crates/mempool_node/src/config/config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use papyrus_config::loading::load_and_process_config;
use papyrus_config::presentation::get_config_presentation;
use papyrus_config::validators::ParsedValidationErrors;
use papyrus_config::{SerializationType, SerializedContent, SerializedParam};
use starknet_gateway::config::{GatewayNetworkConfig, StatelessTransactionValidatorConfig};
use validator::Validate;

use crate::config::{
node_command, ComponentConfig, ComponentExecutionConfig, GatewayNetworkConfig,
MempoolNodeConfig,
node_command, ComponentConfig, ComponentExecutionConfig, GatewayConfig, MempoolNodeConfig,
};

const TEST_FILES_FOLDER: &str = "./src/test_files";
Expand All @@ -33,7 +33,15 @@ fn test_valid_config() {
gateway_component: ComponentExecutionConfig { execute: true },
mempool_component: ComponentExecutionConfig { execute: false },
},
gateway_config: GatewayNetworkConfig { ip: "0.0.0.0".parse().unwrap(), port: 8080 },
gateway_config: GatewayConfig {
network_config: GatewayNetworkConfig { ip: "0.0.0.0".parse().unwrap(), port: 8080 },
stateless_transaction_validator_config: StatelessTransactionValidatorConfig {
validate_non_zero_l1_gas_fee: true,
validate_non_zero_l2_gas_fee: false,
max_calldata_length: 10,
max_signature_length: 2,
},
},
};
let loaded_config = get_config_file(CONFIG_FILE).unwrap();

Expand Down
4 changes: 2 additions & 2 deletions crates/mempool_node/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig
use papyrus_config::loading::load_and_process_config;
use papyrus_config::{ConfigError, ParamPath, ParamPrivacyInput, SerializedParam};
use serde::{Deserialize, Serialize};
use starknet_gateway::config::GatewayNetworkConfig;
use starknet_gateway::config::GatewayConfig;
use validator::{Validate, ValidationError};

use crate::version::VERSION_FULL;
Expand Down Expand Up @@ -77,7 +77,7 @@ pub struct MempoolNodeConfig {
#[validate]
pub components: ComponentConfig,
#[validate]
pub gateway_config: GatewayNetworkConfig,
pub gateway_config: GatewayConfig,
}

impl SerializeConfig for MempoolNodeConfig {
Expand Down
63 changes: 41 additions & 22 deletions crates/mempool_node/src/test_files/mempool_node_config.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,42 @@
{
"components.gateway_component.execute": {
"description": "The component execution flag.",
"value": true,
"privacy": "Public"
},
"components.mempool_component.execute": {
"description": "The component execution flag.",
"value": false,
"privacy": "Public"
},
"gateway_config.ip": {
"description": "The gateway server ip.",
"value": "0.0.0.0",
"privacy": "Public"
},
"gateway_config.port": {
"description": "The gateway server port.",
"value": 8080,
"privacy": "Public"
}
}

"components.gateway_component.execute": {
"description": "The component execution flag.",
"privacy": "Public",
"value": true
},
"components.mempool_component.execute": {
"description": "The component execution flag.",
"privacy": "Public",
"value": false
},
"gateway_config.network_config.ip": {
"description": "The gateway server ip.",
"privacy": "Public",
"value": "0.0.0.0"
},
"gateway_config.network_config.port": {
"description": "The gateway server port.",
"privacy": "Public",
"value": 8080
},
"gateway_config.stateless_transaction_validator_config.max_calldata_length": {
"description": "Validates that a transaction has signature length less than or equal to this value.",
"privacy": "Public",
"value": 10
},
"gateway_config.stateless_transaction_validator_config.max_signature_length": {
"description": "Validates that a transaction has calldata length less than or equal to this value.",
"privacy": "Public",
"value": 2
},
"gateway_config.stateless_transaction_validator_config.validate_non_zero_l1_gas_fee": {
"description": "If true, validates that a transaction has non-zero L1 resource bounds.",
"privacy": "Public",
"value": true
},
"gateway_config.stateless_transaction_validator_config.validate_non_zero_l2_gas_fee": {
"description": "If true, validates that a transaction has non-zero L2 resource bounds.",
"privacy": "Public",
"value": false
}
}

0 comments on commit 0ff40fa

Please sign in to comment.