Skip to content

Commit

Permalink
fix(en): run MainNodeFeeParamsFetcher in API component (#1988)
Browse files Browse the repository at this point in the history
## What ❔

Runs `MainNodeFeeParamsFetcher` in `run_api`.
Removes it from `run_core`.

## Why ❔

En's core doesn't use `MainNodeFeeParamsFetcher`. API uses it. API
operated normally only if Core and Api are launched in the same process
which is not true for distributed nodes. The PR fixes it

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zk fmt` and `zk lint`.
- [ ] Spellcheck has been run via `zk spellcheck`.
  • Loading branch information
perekopskiy authored May 20, 2024
1 parent 3d98072 commit b62677e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions core/bin/external_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ async fn run_core(
task_handles: &mut Vec<JoinHandle<anyhow::Result<()>>>,
app_health: &AppHealthCheck,
stop_receiver: watch::Receiver<bool>,
fee_params_fetcher: Arc<MainNodeFeeParamsFetcher>,
singleton_pool_builder: &ConnectionPoolBuilder<Core>,
) -> anyhow::Result<SyncState> {
// Create components.
Expand Down Expand Up @@ -311,8 +310,6 @@ async fn run_core(
}

let sk_handle = task::spawn(state_keeper.run());
let fee_params_fetcher_handle =
tokio::spawn(fee_params_fetcher.clone().run(stop_receiver.clone()));
let remote_diamond_proxy_addr = config.remote.diamond_proxy_addr;
let diamond_proxy_addr = if let Some(addr) = config.optional.contracts_diamond_proxy_addr {
anyhow::ensure!(
Expand Down Expand Up @@ -377,7 +374,6 @@ async fn run_core(

task_handles.extend([
sk_handle,
fee_params_fetcher_handle,
consistency_checker_handle,
commitment_generator_handle,
updater_handle,
Expand Down Expand Up @@ -432,6 +428,10 @@ async fn run_api(
stop_receiver.clone(),
)));

let fee_params_fetcher_handle =
tokio::spawn(fee_params_fetcher.clone().run(stop_receiver.clone()));
task_handles.push(fee_params_fetcher_handle);

let tx_sender_builder =
TxSenderBuilder::new(config.into(), connection_pool.clone(), Arc::new(tx_proxy));

Expand Down Expand Up @@ -632,8 +632,6 @@ async fn init_tasks(
task_handles.push(tokio::spawn(fetcher.run(stop_receiver.clone())));
}

let fee_params_fetcher = Arc::new(MainNodeFeeParamsFetcher::new(main_node_client.clone()));

let sync_state = if components.contains(&Component::Core) {
run_core(
config,
Expand All @@ -643,7 +641,6 @@ async fn init_tasks(
task_handles,
app_health,
stop_receiver.clone(),
fee_params_fetcher.clone(),
&singleton_pool_builder,
)
.await?
Expand All @@ -660,6 +657,7 @@ async fn init_tasks(
};

if components.contains(&Component::HttpApi) || components.contains(&Component::WsApi) {
let fee_params_fetcher = Arc::new(MainNodeFeeParamsFetcher::new(main_node_client.clone()));
run_api(
task_handles,
config,
Expand Down

0 comments on commit b62677e

Please sign in to comment.