Skip to content

Commit

Permalink
everything compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardoalt committed May 4, 2024
1 parent ca34370 commit 58ca788
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 49 deletions.
52 changes: 34 additions & 18 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ resolver = "2"
members = [
"fusion-api",
"fusion-config",
"fusion-poseidon",
"fusion-prover",
"fusion-rpc",
"fusion-state",
"fusion-sequencer",
"fusion-types", "fusion-poseidon",
"fusion-types",
]

default-members = ["fusion-sequencer"]
Expand Down
9 changes: 1 addition & 8 deletions fusion-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,12 @@ pub fn hash_tx(tx: &Tx) -> U256 {
fusion_poseidon::poseidon_sponge(&[tx.kind.to_u256(), sender_addr, to_addr, tx.nonce, tx.value])
}

//#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SignedTx {
pub tx: Tx,
pub signature: String,
}

/*
#[tarpc::service]
pub trait FusionRPC {
async fn submit_transaction(tx: SignedTx) -> Result<(), String>;
}
*/

#[cfg(test)]
mod test {
use super::*;
Expand Down
2 changes: 0 additions & 2 deletions fusion-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name = "fusion-config"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ethers-core = { version = "2" }
serde = "1.0.152"
Expand Down
8 changes: 8 additions & 0 deletions fusion-rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "fusion-rpc"
version = "0.1.0"
edition = "2021"

[dependencies]
fusion-api = { path = "../fusion-api" }
tarpc = { version = "0.31", features = ["full"] }
6 changes: 6 additions & 0 deletions fusion-rpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use fusion_api::SignedTx;

#[tarpc::service]
pub trait FusionRPC {
async fn submit_transaction(tx: SignedTx) -> Result<(), String>;
}
4 changes: 2 additions & 2 deletions fusion-sequencer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ ethers = { version = "2" }
futures = "0.3.26"
log = "0.4.17"
tarpc = { version = "0.31", features = ["full"] }
tokio = { version = "1.25.0", features = ["macros", "sync"] }
tokio = { version = "1.25.0", features = ["macros", "sync", "rt-multi-thread"] }
#fusion-l1 = { path = "../l1-verifier/out/bindings" }
fusion-api = { path = "../fusion-api" }
fusion-config = { path = "../fusion-config" }
fusion-prover = { path = "../fusion-prover" }
fusion-rpc = { path = "../fusion-rpc" }
fusion-state= { path = "../fusion-state" }
fusion-types = { path = "../fusion-types" }

#serde_cbor = { version = "0.11.2", default-features = false, features = ["std"] }
serde_cbor = { version = "0.11.2" }

[dev-dependencies]
Expand Down
10 changes: 2 additions & 8 deletions fusion-sequencer/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
use tokio::sync::mpsc;

use fusion_api::*;
use fusion_types::*;
use fusion_config::Config;
use fusion_types::*;

use fusion_sequencer::sequencer::*;
use fusion_sequencer::server::*;

use fusion_state::{State, apply_tx};
use fusion_state::{apply_tx, State};

use ruint::aliases::U256;

fn main() {
state_update_test();
}

fn state_update_test() {
let pre_state = State::default();

Expand All @@ -31,7 +27,6 @@ fn state_update_test() {
let _ = fusion_prover::prove(&tx, &pre_state, &post_state);
}

/*
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = Config::from_file("../fusion.toml".to_string());
Expand All @@ -46,4 +41,3 @@ async fn main() -> anyhow::Result<()> {

run_sequencer(&config, rx).await
}
*/
12 changes: 6 additions & 6 deletions fusion-sequencer/src/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ async fn request_proof(
tx: SignedTx,
pre_state: State,
post_state: State,
//) -> anyhow::Result<fusion::TxProof, String> {
//) -> anyhow::Result<fusion::TxProof, String> {
) -> anyhow::Result<(), String> {
Ok(())
}

/*
pub async fn run_sequencer(
config: &Config,
mut rx: mpsc::Receiver<SignedTx>,
Expand All @@ -40,11 +39,11 @@ pub async fn run_sequencer(
let mempool = init_mempool(db_path);

let mut state = State::default();
let l1_contract = init_l1(config).await.unwrap();
//let l1_contract = init_l1(config).await.unwrap();

while let Some(tx) = rx.recv().await {
let current_root = l1_contract.root().call().await.unwrap();
println!("Current root is {current_root}");
//let current_root = l1_contract.root().call().await.unwrap();
//println!("Current root is {current_root}");

{
let mut unlocked_mempool = mempool.lock().unwrap();
Expand Down Expand Up @@ -91,12 +90,14 @@ pub async fn run_sequencer(
Err(e) => println!("Could not generate proof: {e}"),
Ok(proof) => {
println!("Submiting block");
/*
l1_contract
.submit_block([proof])
.gas(1000000)
.send()
.await
.unwrap();
*/
println!("Block sent!");
}
};
Expand All @@ -105,7 +106,6 @@ pub async fn run_sequencer(

Ok(())
}
*/

fn validate_tx(state: &State, tx: &SignedTx) -> anyhow::Result<()> {
verify_tx_signature(tx)?;
Expand Down
5 changes: 1 addition & 4 deletions fusion-sequencer/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use fusion_api::*;
use fusion_rpc::*;

use futures::{future, prelude::*};
use tarpc::{
Expand All @@ -14,7 +15,6 @@ use std::net::{IpAddr, SocketAddr};
#[derive(Clone)]
struct FusionServer(SocketAddr, mpsc::Sender<SignedTx>);

/*
#[tarpc::server]
impl FusionRPC for FusionServer {
async fn submit_transaction(
Expand All @@ -26,9 +26,7 @@ impl FusionRPC for FusionServer {
Ok(())
}
}
*/

/*
pub async fn run_server(sx: mpsc::Sender<SignedTx>, addr: String, port: u16) -> anyhow::Result<()> {
let mut listener = tarpc::serde_transport::tcp::listen(
&(IpAddr::V4(addr.parse().unwrap()), port),
Expand All @@ -54,4 +52,3 @@ pub async fn run_server(sx: mpsc::Sender<SignedTx>, addr: String, port: u16) ->

Ok(())
}
*/

0 comments on commit 58ca788

Please sign in to comment.