Skip to content

Commit

Permalink
Revert "Merge pull request #728 from EspressoSystems/ab/sqlite-support"
Browse files Browse the repository at this point in the history
This reverts commit 970d3c3, reversing
changes made to 7074bee.
  • Loading branch information
imabdulbasit committed Dec 4, 2024
1 parent 7f053f9 commit 2f8742e
Show file tree
Hide file tree
Showing 23 changed files with 376 additions and 761 deletions.
64 changes: 18 additions & 46 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ on:
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
env:
RUST_LOG: info
steps:
- uses: styfle/cancel-workflow-action@0.12.1
name: Cancel Outdated Builds
with:
all_but_latest: true
access_token: ${{ github.token }}

- uses: actions/checkout@v4
name: Checkout Repository

Expand All @@ -34,12 +36,21 @@ jobs:

# Run Clippy on all targets. The lint workflow doesn't run Clippy on tests, because the tests
# don't compile with all combinations of features.
- name: Clippy(all-features)
- name: Clippy
run: cargo clippy --workspace --all-features --all-targets -- -D warnings

- name: Clippy(no-storage)
run: cargo clippy --workspace --features no-storage --all-targets -- -D warnings
# Install nextest
- name: Install Nextest
run: cargo install cargo-nextest

- name: Test
run: |
cargo nextest run --workspace --release --all-features
timeout-minutes: 60

- name: Doc Test
run: cargo test --release --all-features --doc

- name: Generate Documentation
run: |
cargo doc --no-deps --lib --release --all-features
Expand All @@ -52,42 +63,3 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./target/doc
cname: tide-disco.docs.espressosys.com
test-sqlite:
runs-on: ubuntu-latest
env:
RUST_LOG: info
steps:
- uses: actions/checkout@v4
name: Checkout Repository

- uses: Swatinem/rust-cache@v2
name: Enable Rust Caching

# Install nextest
- name: Install Nextest
run: cargo install cargo-nextest

- name: Test
run: |
cargo nextest run --workspace --release --all-features
timeout-minutes: 60

test-postgres:
runs-on: ubuntu-latest
env:
RUST_LOG: info
steps:
- uses: actions/checkout@v4
name: Checkout Repository

- uses: Swatinem/rust-cache@v2
name: Enable Rust Caching

# Install nextest
- name: Install Nextest
run: cargo install cargo-nextest

- name: Test
run: |
cargo nextest run --workspace --release --features "no-storage, testing"
timeout-minutes: 60
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ lcov.info

/vsc

/.vscode

# for sqlite databases created during the tests
/tmp
/.vscode
5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ license = "GPL-3.0-or-later"
[features]
default = ["file-system-data-source", "metrics-data-source", "sql-data-source"]

# Enables support for an embedded SQLite database instead of PostgreSQL.
# Ideal for lightweight nodes that benefit from pruning and merklized state storage,
# offering advantages over file system storage.
embedded-db = []

# Enable the availability data source backed by the local file system.
file-system-data-source = ["atomic_store"]

Expand Down
23 changes: 9 additions & 14 deletions examples/simple-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,15 @@ async fn init_db() -> Db {
}

#[cfg(not(target_os = "windows"))]
async fn init_data_source(#[allow(unused_variables)] db: &Db) -> DataSource {
let mut cfg = data_source::sql::Config::default();

#[cfg(not(feature = "embedded-db"))]
{
cfg = cfg.host(db.host()).port(db.port());
}

#[cfg(feature = "embedded-db")]
{
cfg = cfg.db_path(db.path());
}

cfg.connect(Default::default()).await.unwrap()
async fn init_data_source(db: &Db) -> DataSource {
data_source::sql::Config::default()
.user("postgres")
.password("password")
.host(db.host())
.port(db.port())
.connect(Default::default())
.await
.unwrap()
}

#[cfg(target_os = "windows")]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 0 additions & 5 deletions migrations/postgres/V400__rename_transaction_table.sql

This file was deleted.

76 changes: 0 additions & 76 deletions migrations/sqlite/V100__init_schema.sql

This file was deleted.

5 changes: 0 additions & 5 deletions migrations/sqlite/V200__create_aggregates_table.sql

This file was deleted.

25 changes: 5 additions & 20 deletions src/data_source/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ pub use anyhow::Error;
use hotshot_types::traits::node_implementation::NodeType;
pub use refinery::Migration;

pub use sql::Transaction;
pub use sql::{Config, Transaction};

pub type Builder<Types, Provider> = fetching::Builder<Types, SqlStorage, Provider>;

pub type Config = sql::Config;

impl Config {
/// Connect to the database with this config.
pub async fn connect<Types, P: AvailabilityProvider<Types>>(
Expand Down Expand Up @@ -80,11 +78,9 @@ impl Config {
///
/// ## Initialization
///
/// When creating a PostgreSQL [`SqlDataSource`], the caller can use [`Config`] to specify the host, user, and
/// database for the connection. If the `embedded-db` feature is enabled, the caller can instead specify the
/// file path for an SQLite database.
/// As such, [`SqlDataSource`] is not very opinionated about how the
/// database instance is set up. The administrator must simply ensure that there is a database
/// When creating a [`SqlDataSource`], the caller can use [`Config`] to specify the host, user, and
/// database to connect to. As such, [`SqlDataSource`] is not very opinionated about how the
/// Postgres instance is set up. The administrator must simply ensure that there is a database
/// dedicated to the [`SqlDataSource`] and a user with appropriate permissions (all on `SCHEMA` and
/// all on `DATABASE`) over that database.
///
Expand All @@ -100,29 +96,18 @@ impl Config {
/// GRANT ALL ON DATABASE hotshot_query_service TO hotshot_user WITH GRANT OPTION;
/// ```
///
/// For SQLite, simply provide the file path, and the file will be created if it does not already exist.
///
/// One could then connect to this database with the following [`Config`] for postgres:
/// One could then connect to this database with the following [`Config`]:
///
/// ```
/// # use hotshot_query_service::data_source::sql::Config;
/// #[cfg(not(feature= "embedded-db"))]
/// Config::default()
/// .host("postgres.database.hostname")
/// .database("hotshot_query_service")
/// .user("hotshot_user")
/// .password("password")
/// # ;
/// ```
/// Or, if the `embedded-db` feature is enabled, configure it as follows for SQLite:
///
/// ```
/// # use hotshot_query_service::data_source::sql::Config;
/// #[cfg(feature= "embedded-db")]
/// Config::default()
/// .db_path("temp.db".into())
/// # ;
/// ```
/// ## Resetting
///
/// In general, resetting the database when necessary is left up to the administrator. However, for
Expand Down
Loading

0 comments on commit 2f8742e

Please sign in to comment.