Skip to content

Commit

Permalink
chore(gateway): move compiler config to gateway component
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed Aug 12, 2024
1 parent 6a16afc commit 12c79b6
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions config/mempool/default_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"compiler_config.max_bytecode_size": {
"description": "Limitation of contract bytecode size.",
"privacy": "Public",
"value": 81920
},
"components.gateway.component_type": {
"description": "The component type.",
"privacy": "Public",
Expand Down Expand Up @@ -89,11 +94,6 @@
"privacy": "Public",
"value": 3
},
"gateway_config.compiler_config.max_bytecode_size": {
"description": "Limitation of contract bytecode size.",
"privacy": "Public",
"value": 81920
},
"gateway_config.network_config.ip": {
"description": "The gateway server ip.",
"privacy": "Public",
Expand Down
3 changes: 0 additions & 3 deletions crates/gateway/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ 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::Nonce;
use starknet_sierra_compile::config::SierraToCasmCompilationConfig;
use starknet_types_core::felt::Felt;
use validator::Validate;

Expand All @@ -17,7 +16,6 @@ pub struct GatewayConfig {
pub network_config: GatewayNetworkConfig,
pub stateless_tx_validator_config: StatelessTransactionValidatorConfig,
pub stateful_tx_validator_config: StatefulTransactionValidatorConfig,
pub compiler_config: SierraToCasmCompilationConfig,
}

impl SerializeConfig for GatewayConfig {
Expand All @@ -32,7 +30,6 @@ impl SerializeConfig for GatewayConfig {
self.stateful_tx_validator_config.dump(),
"stateful_tx_validator_config",
),
append_sub_config_name(self.compiler_config.dump(), "compiler_config"),
]
.into_iter()
.flatten()
Expand Down
4 changes: 3 additions & 1 deletion crates/gateway/src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use starknet_api::transaction::TransactionHash;
use starknet_mempool_infra::component_runner::{ComponentStartError, ComponentStarter};
use starknet_mempool_types::communication::SharedMempoolClient;
use starknet_mempool_types::mempool_types::{Account, AccountState, MempoolInput};
use starknet_sierra_compile::config::SierraToCasmCompilationConfig;
use tracing::{info, instrument};

use crate::compilation::GatewayCompiler;
Expand Down Expand Up @@ -151,10 +152,11 @@ fn process_tx(
pub fn create_gateway(
config: GatewayConfig,
rpc_state_reader_config: RpcStateReaderConfig,
compiler_config: SierraToCasmCompilationConfig,
mempool_client: SharedMempoolClient,
) -> Gateway {
let state_reader_factory = Arc::new(RpcStateReaderFactory { config: rpc_state_reader_config });
let gateway_compiler = GatewayCompiler::new_cairo_lang_compiler(config.compiler_config);
let gateway_compiler = GatewayCompiler::new_cairo_lang_compiler(compiler_config);

Gateway::new(config, state_reader_factory, gateway_compiler, mempool_client)
}
Expand Down
1 change: 1 addition & 0 deletions crates/mempool_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ starknet_gateway.workspace = true
starknet_mempool.workspace = true
starknet_mempool_infra.workspace = true
starknet_mempool_types.workspace = true
starknet_sierra_compile.workspace = true
tokio.workspace = true
tracing.workspace = true
validator.workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/mempool_node/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn create_components(config: &MempoolNodeConfig, clients: &MempoolNodeClient
Some(create_gateway(
config.gateway_config.clone(),
config.rpc_state_reader_config.clone(),
config.compiler_config,
mempool_client,
))
} else {
Expand Down
4 changes: 4 additions & 0 deletions crates/mempool_node/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use starknet_mempool_infra::component_definitions::{
LocalComponentCommunicationConfig,
RemoteComponentCommunicationConfig,
};
use starknet_sierra_compile::config::SierraToCasmCompilationConfig;
use validator::{Validate, ValidationError};

use crate::version::VERSION_FULL;
Expand Down Expand Up @@ -200,6 +201,8 @@ pub struct MempoolNodeConfig {
pub gateway_config: GatewayConfig,
#[validate]
pub rpc_state_reader_config: RpcStateReaderConfig,
#[validate]
pub compiler_config: SierraToCasmCompilationConfig,
}

impl SerializeConfig for MempoolNodeConfig {
Expand All @@ -209,6 +212,7 @@ impl SerializeConfig for MempoolNodeConfig {
append_sub_config_name(self.components.dump(), "components"),
append_sub_config_name(self.gateway_config.dump(), "gateway_config"),
append_sub_config_name(self.rpc_state_reader_config.dump(), "rpc_state_reader_config"),
append_sub_config_name(self.compiler_config.dump(), "compiler_config"),
];

sub_configs.into_iter().flatten().collect()
Expand Down
8 changes: 1 addition & 7 deletions crates/tests-integration/src/integration_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ async fn create_gateway_config() -> GatewayConfig {
let socket = get_available_socket().await;
let network_config = GatewayNetworkConfig { ip: socket.ip(), port: socket.port() };
let stateful_tx_validator_config = StatefulTransactionValidatorConfig::create_for_testing();
let gateway_compiler_config = Default::default();

GatewayConfig {
network_config,
stateless_tx_validator_config,
stateful_tx_validator_config,
compiler_config: gateway_compiler_config,
}
GatewayConfig { network_config, stateless_tx_validator_config, stateful_tx_validator_config }
}

pub async fn create_config(rpc_server_addr: SocketAddr) -> MempoolNodeConfig {
Expand Down

0 comments on commit 12c79b6

Please sign in to comment.