Skip to content

Commit

Permalink
Run separate nodes in ci
Browse files Browse the repository at this point in the history
Signed-off-by: deniallugo <[email protected]>
  • Loading branch information
Deniallugo committed Dec 1, 2021
1 parent 5368abc commit 0e7273d
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 45 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ jobs:

- name: run-services
run: |
ci_run zk server &>server.log &
ci_run zk server core &>server.log &
ci_run zk server api &>api.log &
ci_run sleep 10
ci_run zk dummy-prover run &>dummy_prover.log &
ci_run sleep 100
Expand All @@ -133,6 +134,7 @@ jobs:
if: always()
run: |
ci_run cat server.log
ci_run cat api.log
ci_run cat dummy_prover.log
circuit-tests:
Expand Down
75 changes: 46 additions & 29 deletions core/bin/server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ pub enum Component {
RpcWebSocketApi,

EthSender,
Core,

WitnessGenerator,
ForcedExit,
Prometheus,

Core,
RejectedTaskCleaner,
}

Expand Down Expand Up @@ -142,11 +142,7 @@ async fn run_server(components: &ComponentsToRun) {
if components.0.iter().any(|c| {
matches!(
c,
Component::Core
| Component::RpcWebSocketApi
| Component::RpcApi
| Component::RestApi
| Component::EthSender
Component::RpcWebSocketApi | Component::RpcApi | Component::RestApi
)
}) {
let eth_client_config = ETHClientConfig::from_env();
Expand All @@ -161,28 +157,17 @@ async fn run_server(components: &ComponentsToRun) {

let gateway_watcher_config = GatewayWatcherConfig::from_env();

run_gateway_watcher_if_multiplexed(eth_gateway.clone(), &gateway_watcher_config)
.map(|task| tasks.push(task));
if let Some(task) =
run_gateway_watcher_if_multiplexed(eth_gateway.clone(), &gateway_watcher_config)
{
tasks.push(task);
}

let channel_size = 32768;

let (ticker_request_sender, ticker_request_receiver) = mpsc::channel(channel_size);
let chain_config = ChainConfig::from_env();

if components.0.contains(&Component::Core) {
let all_config = ZkSyncConfig::from_env();
tasks.append(
&mut run_core(
connection_pool.clone(),
&all_config,
stop_signal_sender.clone(),
eth_gateway.clone(),
)
.await
.unwrap(),
);
}

let max_blocks_to_aggregate = std::cmp::max(
chain_config.state_keeper.max_aggregated_blocks_to_commit,
chain_config.state_keeper.max_aggregated_blocks_to_execute,
Expand All @@ -200,7 +185,7 @@ async fn run_server(components: &ComponentsToRun) {
let (sign_check_sender, sign_check_receiver) = mpsc::channel(32768);

zksync_api::signature_checker::start_sign_checker_detached(
eth_gateway.clone(),
eth_gateway,
sign_check_receiver,
stop_signal_sender.clone(),
);
Expand Down Expand Up @@ -251,14 +236,46 @@ async fn run_server(components: &ComponentsToRun) {
private_config.url,
);
}
if components.0.contains(&Component::EthSender) {
// Run Ethereum sender actors.
vlog::info!("Starting the Ethereum sender actors");
let config = ETHSenderConfig::from_env();
tasks.push(run_eth_sender(connection_pool.clone(), eth_gateway, config));
}
}

if components.0.contains(&Component::EthSender) {
// Run Ethereum sender actors.
vlog::info!("Starting the Ethereum sender actors");
let eth_client_config = ETHClientConfig::from_env();
let eth_sender_config = ETHSenderConfig::from_env();
let contracts = ContractsConfig::from_env();
let eth_gateway = EthereumGateway::from_config(
&eth_client_config,
&eth_sender_config,
contracts.contract_addr,
);

tasks.push(run_eth_sender(
connection_pool.clone(),
eth_gateway,
eth_sender_config,
));
}

if components.0.contains(&Component::Core) {
let all_config = ZkSyncConfig::from_env();
let eth_gateway = EthereumGateway::from_config(
&all_config.eth_client,
&all_config.eth_sender,
all_config.contracts.contract_addr,
);

tasks.append(
&mut run_core(
connection_pool.clone(),
&all_config,
stop_signal_sender.clone(),
eth_gateway.clone(),
)
.await
.unwrap(),
);
}
if components.0.contains(&Component::WitnessGenerator) {
vlog::info!("Starting the Prover server actors");
let prover_api_config = ProverApiConfig::from_env();
Expand Down
12 changes: 2 additions & 10 deletions core/bin/zksync_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use futures::{channel::mpsc, future};
use tokio::task::JoinHandle;
use zksync_config::{ChainConfig, ZkSyncConfig};
use zksync_eth_client::EthereumGateway;
use zksync_gateway_watcher::run_gateway_watcher_if_multiplexed;
use zksync_storage::ConnectionPool;
use zksync_types::{tokens::get_genesis_token_list, Token, TokenId, TokenKind};

Expand Down Expand Up @@ -159,14 +158,11 @@ pub async fn run_core(
config.chain.state_keeper.block_chunk_sizes.clone(),
);

let gateway_watcher_task_opt =
run_gateway_watcher_if_multiplexed(eth_gateway.clone(), &config.gateway_watcher);

// Start token handler.
let token_handler_task = run_token_handler(
connection_pool.clone(),
eth_watch_req_sender.clone(),
config,
&config.token_handler,
);

// Start token handler.
Expand Down Expand Up @@ -196,7 +192,7 @@ pub async fn run_core(
config.api.private.clone(),
);

let mut task_futures = vec![
let task_futures = vec![
eth_watch_task,
state_keeper_task,
committer_task,
Expand All @@ -207,9 +203,5 @@ pub async fn run_core(
tx_event_emitter_task,
];

if let Some(task) = gateway_watcher_task_opt {
task_futures.push(task);
}

Ok(task_futures)
}
7 changes: 3 additions & 4 deletions core/bin/zksync_core/src/token_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use futures::{
};
use tokio::task::JoinHandle;
// Workspace uses
use zksync_config::{TokenHandlerConfig, ZkSyncConfig};
use zksync_config::TokenHandlerConfig;
use zksync_notifier::Notifier;
use zksync_storage::{tokens::StoreTokenError, ConnectionPool, StorageProcessor};
use zksync_types::{
Expand Down Expand Up @@ -234,12 +234,11 @@ impl TokenHandler {
pub fn run_token_handler(
db_pool: ConnectionPool,
eth_watch_req: mpsc::Sender<EthWatchRequest>,
config: &ZkSyncConfig,
config: &TokenHandlerConfig,
) -> JoinHandle<()> {
let config = config.clone();
tokio::spawn(async move {
let mut token_handler =
TokenHandler::new(db_pool, eth_watch_req, config.token_handler.clone()).await;
let mut token_handler = TokenHandler::new(db_pool, eth_watch_req, config.clone()).await;

token_handler.run().await
})
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/zk/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function web3Node() {

export async function apiNode() {
await utils.spawn(
'cargo run --bin zksync_server --release -- --components=web3-api,rest-api,rpc-api,rpc-websocket-api,prometheus'
'cargo run --bin zksync_server --release -- --components=web3-api,rest-api,rpc-api,rpc-websocket-api'
);
}

Expand Down

0 comments on commit 0e7273d

Please sign in to comment.