Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardoalt committed Feb 12, 2023
1 parent b3974ab commit d96b5bd
Show file tree
Hide file tree
Showing 41 changed files with 571 additions and 571 deletions.
347 changes: 174 additions & 173 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[workspace]
members = [
"trollup-api",
"trollup-config",
"trollup-prover",
"trollup-sequencer",
"trollup-types",
"trollup-wallet"
"fusion-api",
"fusion-config",
"fusion-prover",
"fusion-sequencer",
"fusion-types",
"fusion-wallet"
]
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Trollup - the simplest zkRollup
# Fusion - the simplest zkRollup

Trollup is an experimental Ethereum ZKRollup, created with the goal of being
Fusion is an experimental Ethereum ZKRollup, created with the goal of being
the simplest L2 that can be used in production. Users can make L2 transfers, as
well as enter/exit the L2 via the L1 contract (not yet implemented).

Trollup consists of an L2 sequencer, a ZK prover, and an L1 verifier smart
Fusion consists of an L2 sequencer, a ZK prover, and an L1 verifier smart
contract. The sequencer keeps track of the canonical L2 state, and receives
transactions to be included in L2 blocks. The prover takes these signed
transactions, the old state and the new state, and builds a Zero Knowledge
Expand All @@ -15,21 +15,21 @@ transactions, verifies them, and updates the L2 state root accordingly.

## Tool Suite

This repository contains the entire Trollup tool suite:
This repository contains the entire Fusion tool suite:

- `circuits`: the SNARK state and signature verification ZoKrates code.
- `trollup-prover`: the prover that takes a signed transaction and builds a ZKP of
- `fusion-prover`: the prover that takes a signed transaction and builds a ZKP of
state changes and signature.
- `trollup-sequencer`: the Trollup node. Receives L2 transactions via RPC, builds
- `fusion-sequencer`: the Fusion node. Receives L2 transactions via RPC, builds
blocks, and sends them for verification on L1.
- `l1-verifier`: the Trollup contracts deployed on L1. These contracts provide
- `l1-verifier`: the Fusion contracts deployed on L1. These contracts provide
block verification and canonical state root updates for L2 nodes.
- `trollup-wallet`: a simple CLI interface to sign/send Trollup transactions.
- `fusion-wallet`: a simple CLI interface to sign/send Fusion transactions.

## Cloning the repository

```
git clone --recurse-submodules https://github.com/trollup/trollup.git
git clone --recurse-submodules https://github.com/fusion/fusion.git
```

If you already cloned the repository without submodules, you can run the command below to initialize it:
Expand All @@ -39,7 +39,7 @@ git submodule update --init --recursive

## Dependencies

Trollup requires the following installed:
Fusion requires the following installed:
- [Rust](https://www.rust-lang.org/learn/get-started)
- [foundry](https://github.com/foundry-rs/foundry)
- [Zokrates](https://zokrates.github.io)
Expand All @@ -53,7 +53,7 @@ cd circuits && make

### Building the sequencer (has prover as dependency)
```
cargo build --release --bin trollup-sequencer
cargo build --release --bin fusion-sequencer
```

### Running
Expand Down Expand Up @@ -92,7 +92,7 @@ The used hash is Poseidon in order to be SNARK friendly.
Since we need to verify signatures inside zkSNARKs, we use EdDSA with the [Baby Jubjub Elliptic Curve](https://eips.ethereum.org/EIPS/eip-2494).
A public key (PK) consists of a curve point where `x` and `y` are elements of
the field used by Baby Jubjub. The PK can be compressed into 256 bits, a
Trollup address. This means that Trollup accounts are not compatible with
Fusion address. This means that Fusion accounts are not compatible with
Ethereum accounts.

## Execution
Expand Down
2 changes: 1 addition & 1 deletion circuits/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
all:
zokrates compile -i trollup.zok
zokrates compile -i fusion.zok

setup:
zokrates setup
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions trollup-api/Cargo.toml → fusion-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "trollup-api"
name = "fusion-api"
version = "0.1.0"
edition = "2021"

Expand All @@ -10,4 +10,4 @@ ethers-core = { git = "https://github.com/gakonst/ethers-rs" }
poseidon-rs = "0.0.8"
serde = "1.0.152"
tarpc = { version = "0.31", features = ["full"] }
trollup-types = { path = "../trollup-types" }
fusion-types = { path = "../fusion-types" }
4 changes: 2 additions & 2 deletions trollup-api/src/lib.rs → fusion-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use ethers_core::types::U256;
use fusion_types::{FromBabyJubjubPoint, PublicKey, ToBabyJubjubPoint, ToFr, ToU256};
use poseidon_rs::*;
use serde::{Deserialize, Serialize};
use trollup_types::{FromBabyJubjubPoint, PublicKey, ToBabyJubjubPoint, ToFr, ToU256};

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Tx {
Expand Down Expand Up @@ -76,7 +76,7 @@ pub struct SignedTx {
}

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

Expand Down
2 changes: 1 addition & 1 deletion trollup-config/Cargo.toml → fusion-config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "trollup-config"
name = "fusion-config"
version = "0.1.0"
edition = "2021"

Expand Down
4 changes: 2 additions & 2 deletions trollup-config/src/lib.rs → fusion-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct Config {
pub min_tx_block: usize,
pub socket_address: String,
pub socket_port: u16,
pub trollup_l1_contract: types::Address,
pub fusion_l1_contract: types::Address,
}

impl Config {
Expand All @@ -36,7 +36,7 @@ impl Default for Config {
min_tx_block: 1,
socket_address: "127.0.0.1".to_string(),
socket_port: 38171,
trollup_l1_contract: types::Address::default(),
fusion_l1_contract: types::Address::default(),
}
}
}
12 changes: 6 additions & 6 deletions trollup-prover/Cargo.toml → fusion-prover/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "trollup-prover"
name = "fusion-prover"
version = "0.1.0"
edition = "2021"

Expand All @@ -19,8 +19,8 @@ zokrates_ast = { git = "https://github.com/ZoKrates/ZoKrates", tag = "0.8.3" }
zokrates_field = { git = "https://github.com/ZoKrates/ZoKrates", tag = "0.8.3" }
zokrates_interpreter = { git = "https://github.com/ZoKrates/ZoKrates", tag = "0.8.3" }
zokrates_proof_systems = { git = "https://github.com/ZoKrates/ZoKrates", tag = "0.8.3" }
trollup-l1 = { path = "../l1-verifier/out/bindings" }
trollup-api = { path = "../trollup-api" }
trollup-config = { path = "../trollup-config" }
trollup-wallet = { path = "../trollup-wallet" }
trollup-types = { path = "../trollup-types" }
fusion-l1 = { path = "../l1-verifier/out/bindings" }
fusion-api = { path = "../fusion-api" }
fusion-config = { path = "../fusion-config" }
fusion-wallet = { path = "../fusion-wallet" }
fusion-types = { path = "../fusion-types" }
50 changes: 25 additions & 25 deletions trollup-prover/src/lib.rs → fusion-prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ pub mod state;
use crate::merkle_tree::ToBitmap;
use crate::state::{Account, State};

use trollup_api::*;
use trollup_config::*;
use trollup_l1::trollup;
use trollup_types::{FromBabyJubjubPoint, Point, PublicKey, ToBabyJubjubSignature, ToU256};
use fusion_api::*;
use fusion_config::*;
use fusion_l1::fusion;
use fusion_types::{FromBabyJubjubPoint, Point, PublicKey, ToBabyJubjubSignature, ToU256};

use bitmaps::Bitmap;

Expand Down Expand Up @@ -100,7 +100,7 @@ trait ToCircuitTx {
fn to_circuit_tx(&self) -> CircuitTx;
}

impl ToCircuitTx for trollup_api::SignedTx {
impl ToCircuitTx for fusion_api::SignedTx {
fn to_circuit_tx(&self) -> CircuitTx {
let sender_pk: PublicKey = self.tx.sender.into();
let to_pk: PublicKey = self.tx.to.into();
Expand All @@ -121,8 +121,8 @@ struct CircuitTxSignature {
s: U256,
}

impl From<trollup_api::SignedTx> for CircuitTxSignature {
fn from(tx: trollup_api::SignedTx) -> CircuitTxSignature {
impl From<fusion_api::SignedTx> for CircuitTxSignature {
fn from(tx: fusion_api::SignedTx) -> CircuitTxSignature {
let sig = tx.signature.to_babyjubjub_signature();
CircuitTxSignature {
r: Point::from_babyjubjub_point(&sig.r_b8),
Expand All @@ -136,10 +136,10 @@ pub struct Prover;
impl Prover {
pub fn prove(
config: &Config,
tx: &trollup_api::SignedTx,
tx: &fusion_api::SignedTx,
pre_state: &State,
post_state: &State,
) -> Result<trollup::TxProof, String> {
) -> Result<fusion::TxProof, String> {
let path = Path::new(&config.circuit_path);
let file = File::open(path)
.map_err(|why| format!("Could not open {}: {}", path.display(), why))?;
Expand All @@ -165,7 +165,7 @@ impl Prover {
.map_err(|why| format!("Could not read {}: {}", pk_path.display(), why))?;

let proof: Proof<Bn128Field, G16> = Ark::generate_proof(prog, witness, pk);
let ret = proof.to_trollup_l1_tx();
let ret = proof.to_fusion_l1_tx();

/*
let proof = serde_json::to_string_pretty(&TaggedProof::<Bn128Field, G16>::new(
Expand Down Expand Up @@ -232,28 +232,28 @@ impl Prover {
}
}

trait ToTrollupL1 {
fn to_trollup_l1_tx(&self) -> trollup::TxProof;
fn to_trollup_l1_proof(&self) -> trollup::Proof;
fn to_trollup_l1_input(&self) -> [U256; 18usize];
trait ToFusionL1 {
fn to_fusion_l1_tx(&self) -> fusion::TxProof;
fn to_fusion_l1_proof(&self) -> fusion::Proof;
fn to_fusion_l1_input(&self) -> [U256; 18usize];
}

impl ToTrollupL1 for Proof<Bn128Field, G16> {
fn to_trollup_l1_tx(&self) -> trollup::TxProof {
trollup::TxProof {
proof: self.to_trollup_l1_proof(),
input: self.to_trollup_l1_input().to_vec(),
impl ToFusionL1 for Proof<Bn128Field, G16> {
fn to_fusion_l1_tx(&self) -> fusion::TxProof {
fusion::TxProof {
proof: self.to_fusion_l1_proof(),
input: self.to_fusion_l1_input().to_vec(),
}
}

fn to_trollup_l1_proof(&self) -> trollup::Proof {
trollup::Proof {
a: trollup::G1Point {
fn to_fusion_l1_proof(&self) -> fusion::Proof {
fusion::Proof {
a: fusion::G1Point {
x: U256::from_str_radix(&self.proof.a.0[2..], 16).unwrap(),
y: U256::from_str_radix(&self.proof.a.1[2..], 16).unwrap(),
},
b: match &self.proof.b {
G2Affine::Fq2(f) => trollup::G2Point {
G2Affine::Fq2(f) => fusion::G2Point {
x: [
U256::from_str_radix(&f.0 .0[2..], 16).unwrap(),
U256::from_str_radix(&f.0 .1[2..], 16).unwrap(),
Expand All @@ -265,14 +265,14 @@ impl ToTrollupL1 for Proof<Bn128Field, G16> {
},
_ => panic!(),
},
c: trollup::G1Point {
c: fusion::G1Point {
x: U256::from_str_radix(&self.proof.c.0[2..], 16).unwrap(),
y: U256::from_str_radix(&self.proof.c.1[2..], 16).unwrap(),
},
}
}

fn to_trollup_l1_input(&self) -> [U256; 18usize] {
fn to_fusion_l1_input(&self) -> [U256; 18usize] {
assert_eq!(self.inputs.len(), 18);
self.inputs
.iter()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::merkle_tree::Hasher;
use ethers_core::types::U256;
use poseidon_rs::*;

use trollup_types::{ToFr, ToU256};
use fusion_types::{ToFr, ToU256};

pub fn poseidon(args: &[U256]) -> U256 {
Poseidon::new()
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions trollup-sequencer/Cargo.toml → fusion-sequencer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "trollup-sequencer"
name = "fusion-sequencer"
version = "0.1.0"
edition = "2021"

Expand All @@ -13,12 +13,12 @@ futures = "0.3.26"
log = "0.4.17"
tarpc = { version = "0.31", features = ["full"] }
tokio = { version = "1.25.0", features = ["macros", "sync"] }
trollup-l1 = { path = "../l1-verifier/out/bindings" }
trollup-api = { path = "../trollup-api" }
trollup-config = { path = "../trollup-config" }
trollup-prover = { path = "../trollup-prover" }
trollup-types = { path = "../trollup-types" }
trollup-wallet = { path = "../trollup-wallet" }
fusion-l1 = { path = "../l1-verifier/out/bindings" }
fusion-api = { path = "../fusion-api" }
fusion-config = { path = "../fusion-config" }
fusion-prover = { path = "../fusion-prover" }
fusion-types = { path = "../fusion-types" }
fusion-wallet = { path = "../fusion-wallet" }

[dev-dependencies]
anvil = { git = "https://github.com/foundry-rs/foundry" }
Expand Down
4 changes: 2 additions & 2 deletions trollup-sequencer/README.md → fusion-sequencer/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🧌🆙 sequencer
# Fusion Sequencer

A trollup sequencer implementation in Rust.
A Fusion sequencer implementation in Rust.

## Todo
- [X] Add signature to transactions
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions trollup-sequencer/src/main.rs → fusion-sequencer/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use tokio::sync::mpsc;

use trollup_api::*;
use trollup_config::Config;
use fusion_api::*;
use fusion_config::Config;

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

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = Config::from_file("../trollup.toml".to_string());
let config = Config::from_file("../fusion.toml".to_string());
let (sx, rx): (mpsc::Sender<SignedTx>, mpsc::Receiver<SignedTx>) = mpsc::channel(1024);

let socket_address = config.socket_address.to_string();
Expand Down
File renamed without changes.
Loading

0 comments on commit d96b5bd

Please sign in to comment.