Skip to content

Commit

Permalink
fix: fix github CI
Browse files Browse the repository at this point in the history
  • Loading branch information
captainlee1024 committed Apr 21, 2024
1 parent 1f4b651 commit 2a311b5
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 171 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- name: Install Dependencies
run: sudo apt install protobuf-compiler
- name: Cargo test
run: cargo test --release --verbose

Expand Down
20 changes: 0 additions & 20 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ reth-blockchain-tree = { git = "https://github.com/0xEigenLabs/reth", package =

# Database
reth-libmdbx = { git = "https://github.com/0xEigenLabs/reth", package = "reth-libmdbx", rev = "8cffebd72" }
kvdb-memorydb = "0.13.0"

#reth-payload-builder = { path = "../reth/crates/payload/builder" }
#reth-basic-payload-builder = { path = "../reth/crates/payload/basic" }
Expand Down
2 changes: 1 addition & 1 deletion src/da/ethereum/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
//!

60 changes: 0 additions & 60 deletions src/db/db_utils/libmdbx.rs
Original file line number Diff line number Diff line change
@@ -1,61 +1 @@
use reth_libmdbx::*;
use db::Database as EigenDB;
use crate::db;

pub struct Bd(Database);

impl EigenDB for Bd {
fn get(&self, key: &[u8]) -> Option<Vec<u8>> {
self.0.get(key).unwrap()
}

fn put(&mut self, key: Vec<u8>, value: Vec<u8>) {
self.0.put(key, value).unwrap()
}

fn del(&mut self, key: Vec<u8>) {
self.0.del(key).unwrap()
}

fn commit(&mut self, transaction: db::Transaction) {
for change in transaction.0 {
match change {
db::ChangeOpt::Put(key, value) => self.put(key, value),
db::ChangeOpt::Del(key) => self.del(key),
}
}
}
}

#[cfg(test)]
mod tests {
use super::*;

fn test_open() {
let dir = "/tmp/eigen-reth2";
let env = Environment::builder()
.open(std::path::Path::new(dir))
.unwrap();
let txn = env.begin_rw_txn().unwrap();
let db = txn.open_db(None).unwrap();
txn.put(db.dbi(), b"key1", b"val1", WriteFlags::empty())
.unwrap();
txn.put(db.dbi(), b"key2", b"val2", WriteFlags::empty())
.unwrap();
txn.put(db.dbi(), b"key3", b"val3", WriteFlags::empty())
.unwrap();
txn.commit().unwrap();

let txn = env.begin_rw_txn().unwrap();
let db = txn.open_db(None).unwrap();
assert_eq!(txn.get(db.dbi(), b"key1").unwrap(), Some(*b"val1"));
assert_eq!(txn.get(db.dbi(), b"key2").unwrap(), Some(*b"val2"));
assert_eq!(txn.get(db.dbi(), b"key3").unwrap(), Some(*b"val3"));
assert_eq!(txn.get::<()>(db.dbi(), b"key").unwrap(), None);

txn.del(db.dbi(), b"key1", None).unwrap();
assert_eq!(txn.get::<()>(db.dbi(), b"key1").unwrap(), None);
txn.commit().unwrap();
}

}
19 changes: 19 additions & 0 deletions src/db/db_utils/mem.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use crate::db::Database as EigenDB;
use std::collections::HashMap;

#[derive(Default)]
pub struct Db(HashMap<Vec<u8>, Vec<u8>>);

impl EigenDB for Db {
fn get(&self, key: &[u8]) -> Option<Vec<u8>> {
self.0.get(key).cloned()
}

fn put(&mut self, key: Vec<u8>, value: Vec<u8>) {
self.0.insert(key, value);
}

fn del(&mut self, key: Vec<u8>) -> Option<Vec<u8>> {
self.0.remove(&key)
}
}
34 changes: 0 additions & 34 deletions src/db/db_utils/memory_kvdb.rs

This file was deleted.

37 changes: 17 additions & 20 deletions src/db/db_utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
mod memory_kvdb;
mod libmdbx;
// TODO: Fix me
#![allow(dead_code)]

use std::path::PathBuf;
mod libmdbx;
mod mem;

use db::Database as EigenDB;
use crate::db;
use db::Database as EigenDB;

pub(crate) enum DBConfig {
/// memory kv-database
Memory,
/// libmdbx database
MDBX {
Mdbx {
/// Path to the mdbx database
path: PathBuf,
// path: String,
// path: PathBuf,
path: String,
},
}

// TODO:


pub(crate) fn open_db(config: &DBConfig) -> Result<EigenDB, ()> {

pub(crate) fn open_db(config: &DBConfig) -> Result<Box<dyn EigenDB>, ()> {
match config {
DBConfig::Memory => open_memory_db(),
DBConfig::Mdbx { .. } => {
unimplemented!("open_mdbx_db")
}
}
}


fn open_mdbx_db(path: &PathBuf) -> Result<EigenDB, ()> {
let db = libmdbx::Database::open(path);
Ok(EigenDB::MDBX(db))
fn open_memory_db() -> Result<Box<dyn EigenDB>, ()> {
Ok(Box::new(mem::Db::default()))
}

//
// fn open_memory_db() -> Result<EigenDB, ()> {
// }
33 changes: 5 additions & 28 deletions src/db/mod.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,13 @@
// TODO: Fix me
#![allow(dead_code)]

mod data_availability_db;
mod db_utils;

/// TODO: we need a trait to abstract the database operations in order to support multiple databases?
pub enum ChangeOpt {
Put(Vec<u8>, Vec<u8>),
Del(Vec<u8>),
}

pub struct Transaction(pub Vec<ChangeOpt>);

impl Transaction {
pub fn new() -> Self {
Transaction(Vec::new())
}

pub fn put(&mut self, key: Vec<u8>, value: Vec<u8>) {
self.0.push(ChangeOpt::Put(key, value));
}

pub fn del(&mut self, key: Vec<u8>) {
self.0.push(ChangeOpt::Del(key));
}
}
/// TODO: we need a trait to abstract the database operations in order to support multiple databases
pub trait Database {
fn get(&self, key: &[u8]) -> Option<Vec<u8>>;
fn put(&mut self, key: Vec<u8>, value: Vec<u8>);
fn del(&mut self, key: Vec<u8>);
fn commit(&mut self, transaction: Transaction);
fn del(&mut self, key: Vec<u8>) -> Option<Vec<u8>>;
}
/// key prefixes for different databases
pub(crate) mod columns{
pub const NUM_COLUMNS: u8 = 0;
}
16 changes: 12 additions & 4 deletions src/prover/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
//! the proof generation request to proof network;
//! 2) Keep polling if the task is finished.
//! 3) If the task is finished, update the status into proof database, hence the extended RPC module will fetch this and return it to SDK.
// TODO: Fix me
#![allow(dead_code)]

use crate::prover::provider::prover_service::prover_request::RequestType;
use crate::prover::provider::prover_service::prover_response::ResponseType;
use crate::prover::provider::prover_service::prover_service_client::ProverServiceClient;
use crate::prover::provider::prover_service::{
Batch, GenAggregatedProofRequest, GenBatchProofRequest, GenFinalProofRequest,
ProofResultStatus, ProverRequest, ProverResponse,
ProofResultStatus, ProverRequest,
};
use tokio::sync::mpsc;
use tokio::sync::mpsc::{Receiver, Sender};
Expand Down Expand Up @@ -58,7 +60,7 @@ pub struct ProveSMT {
/// the endpoint to communicate with the prover
endpoint: ProverEndpoint,

///
/// used to receive response from the endpoint
response_receiver: Receiver<ResponseType>,
}

Expand Down Expand Up @@ -113,7 +115,7 @@ impl ProveSMT {
loop {
self.step = match &self.step {
ProveStep::Start => {
let batch = self.current_batch.unwrap().clone();
let batch = self.current_batch.unwrap();
ProveStep::Batch(batch)
}

Expand Down Expand Up @@ -209,9 +211,15 @@ impl ProveSMT {
{
ProveStep::End
} else {
// TODO: return error
log::error!(
"gen final proof failed, error: {:?}",
gen_final_proof_response.error_message
);
ProveStep::End
}
} else {
log::error!("gen final proof failed, no response");
ProveStep::End
}
}
Expand Down Expand Up @@ -252,7 +260,7 @@ pub struct ProverEndpoint {
/// listen to the stop signal, and stop the endpoint loop
stop_endpoint_rx: Receiver<()>,

///
/// used to send response to the ProveSMT
response_sender: Sender<ResponseType>,
}

Expand Down
4 changes: 1 addition & 3 deletions src/settlement/ethereum/client.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
//!
//!
//!

0 comments on commit 2a311b5

Please sign in to comment.