Skip to content

BM-613: Use postgres by default in the broker #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/broker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ risc0-ethereum-contracts = { workspace = true, features = ["unstable"] }
risc0-zkvm = { workspace = true, features = ["std", "client"] }
serde = { workspace = true }
serde_json = { workspace = true }
sqlx = { workspace = true, features = [ "sqlite", "runtime-tokio", "json", "migrate", "macros" ] }
sqlx = { workspace = true, features = [ "postgres", "runtime-tokio-native-tls", "sqlite", "runtime-tokio", "json", "migrate", "macros" ] }
tempfile = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "fs"] }
Expand Down
39 changes: 39 additions & 0 deletions crates/broker/migrations/postgres/1_broker.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
-- Postgres requires us to create the enum before using it as a column type
-- as it does not store enums as strings internally as sqlite does
CREATE TYPE order_status AS ENUM (
'New',
'Pricing',
'Locking',
'Locked',
'Proving',
'PendingAgg',
'Aggregating',
'PendingSubmission',
'Done',
'Failed',
'Skipped'
);

CREATE TYPE batch_status AS ENUM (
'Aggregating',
'PendingCompression',
'Complete',
'PendingSubmission',
'Submitted',
'Failed'
);

CREATE TABLE orders (
id TEXT PRIMARY KEY,
data JSONB
);

CREATE TABLE batches (
id BIGSERIAL PRIMARY KEY,
data JSONB
);

CREATE TABLE last_block (
id INTEGER PRIMARY KEY,
block TEXT
)
2 changes: 1 addition & 1 deletion crates/broker/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ mod tests {
use super::*;
use crate::{
chain_monitor::ChainMonitorService,
db::SqliteDb,
db::{DBPoolManager, SqliteDb},
now_timestamp,
provers::{encode_input, MockProver, Prover},
BatchStatus, Order, OrderStatus,
Expand Down
1 change: 1 addition & 0 deletions crates/broker/src/db/fuzz_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::sync::Arc;
use tempfile::NamedTempFile;
use tokio::runtime::Builder;

use crate::db::DBPoolManager;
use crate::{db::AggregationOrder, AggregationState, Order, OrderStatus};

use super::{BrokerDb, SqliteDb};
Expand Down
Loading
Loading