Skip to content

Commit

Permalink
refactor: remove dead code
Browse files Browse the repository at this point in the history
The dispatcher doesn't use the history foldable because this code was
reimplemented in the authority-claimer service.
  • Loading branch information
gligneul committed Jan 29, 2024
1 parent ad1178a commit 1b3cef6
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 333 deletions.
33 changes: 15 additions & 18 deletions offchain/dispatcher/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
use eth_state_client_lib::StateServer;
use eth_state_fold_types::{Block, BlockStreamItem};
use rollups_events::DAppMetadata;
use std::sync::Arc;
use tokio_stream::StreamExt;
use tracing::{error, instrument, trace, warn};
use types::foldables::authority::rollups::{RollupsInitialState, RollupsState};
use types::foldables::{InputBox, InputBoxInitialState};

use crate::{
config::DispatcherConfig,
Expand Down Expand Up @@ -57,19 +58,15 @@ pub async fn start(
.into(),
);

let initial_state = RollupsInitialState {
history_address: config
.blockchain_config
.history_address
.clone()
.into_inner()
.into(),
input_box_address: config
.blockchain_config
.input_box_address
.clone()
.into_inner()
.into(),
let initial_state = InputBoxInitialState {
input_box_address: Arc::new(
config
.blockchain_config
.input_box_address
.clone()
.into_inner()
.into(),
),
};

trace!("Creating context");
Expand Down Expand Up @@ -136,10 +133,10 @@ async fn process_block(
block: &Block,

state_server: &impl StateServer<
InitialState = RollupsInitialState,
State = RollupsState,
InitialState = InputBoxInitialState,
State = InputBox,
>,
initial_state: &RollupsInitialState,
initial_state: &InputBoxInitialState,

context: &mut Context,
machine_driver: &mut MachineDriver,
Expand All @@ -155,7 +152,7 @@ async fn process_block(
// Drive machine
trace!("Reacting to state with `machine_driver`");
machine_driver
.react(context, &state.block, &state.state.input_box, broker)
.react(context, &state.block, &state.state, broker)
.await
.context(BrokerSnafu)?;

Expand Down
2 changes: 1 addition & 1 deletion offchain/dispatcher/src/drivers/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
};

use rollups_events::DAppMetadata;
use types::foldables::input_box::Input;
use types::foldables::Input;

#[derive(Debug)]
pub struct Context {
Expand Down
4 changes: 2 additions & 2 deletions offchain/dispatcher/src/drivers/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::Context;
use crate::machine::{rollups_broker::BrokerFacadeError, BrokerSend};

use eth_state_fold_types::{ethereum_types::Address, Block};
use types::foldables::input_box::{DAppInputBox, Input, InputBox};
use types::foldables::{DAppInputBox, Input, InputBox};

use tracing::{debug, instrument, trace};

Expand Down Expand Up @@ -234,7 +234,7 @@ mod tests {
rollup_status,
);
let machine_driver = MachineDriver::new(H160::random());
let dapp_input_box = types::foldables::input_box::DAppInputBox {
let dapp_input_box = types::foldables::DAppInputBox {
inputs: input_timestamps
.iter()
.map(|timestamp| Arc::new(mock::new_input(*timestamp)))
Expand Down
2 changes: 1 addition & 1 deletion offchain/dispatcher/src/drivers/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::{
ops::{Deref, DerefMut},
sync::{Arc, Mutex},
};
use types::foldables::input_box::{DAppInputBox, Input, InputBox};
use types::foldables::{DAppInputBox, Input, InputBox};

use crate::machine::{
rollups_broker::BrokerFacadeError, BrokerSend, BrokerStatus, RollupStatus,
Expand Down
2 changes: 1 addition & 1 deletion offchain/dispatcher/src/machine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pub mod rollups_broker;

use types::foldables::input_box::Input;
use types::foldables::Input;

use async_trait::async_trait;

Expand Down
4 changes: 2 additions & 2 deletions offchain/dispatcher/src/machine/rollups_broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rollups_events::{
RollupsAdvanceStateInput, RollupsData, RollupsInput, RollupsInputsStream,
INITIAL_ID,
};
use types::foldables::input_box::Input;
use types::foldables::Input;

use super::{BrokerSend, BrokerStatus, RollupStatus};

Expand Down Expand Up @@ -290,7 +290,7 @@ mod broker_facade_tests {
};
use test_fixtures::broker::BrokerFixture;
use testcontainers::clients::Cli;
use types::foldables::input_box::Input;
use types::foldables::Input;

use crate::machine::{
rollups_broker::BrokerFacadeError, BrokerSend, BrokerStatus,
Expand Down
4 changes: 2 additions & 2 deletions offchain/dispatcher/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rollups_events::DAppMetadata;
use snafu::{ensure, ResultExt};
use tokio_stream::{Stream, StreamExt};
use tonic::transport::Channel;
use types::foldables::authority::{RollupsInitialState, RollupsState};
use types::foldables::{InputBox, InputBoxInitialState};

use crate::{
config::DispatcherConfig,
Expand All @@ -28,7 +28,7 @@ const BUFFER_LEN: usize = 256;
pub async fn create_state_server(
config: &SCConfig,
) -> Result<
impl StateServer<InitialState = RollupsInitialState, State = RollupsState>
impl StateServer<InitialState = InputBoxInitialState, State = InputBox>
+ BlockServer,
DispatcherError,
> {
Expand Down
4 changes: 2 additions & 2 deletions offchain/state-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)
mod config;
use config::Config;
use types::foldables::authority::rollups::RollupsState;
use types::foldables::InputBox;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand All @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

log::log_service_start(&config, "State Server");

state_server::run_server::<RollupsState>(config.state_server_config)
state_server::run_server::<InputBox>(config.state_server_config)
.await
.map_err(|e| e.into())
}
File renamed without changes.
5 changes: 0 additions & 5 deletions offchain/types/src/foldables/authority/mod.rs

This file was deleted.

126 changes: 0 additions & 126 deletions offchain/types/src/foldables/authority/rollups.rs

This file was deleted.

Loading

0 comments on commit 1b3cef6

Please sign in to comment.