Skip to content

Commit

Permalink
Bump Versions, Change Ledger Loading, Update Proposal Schema (#8)
Browse files Browse the repository at this point in the history
Co-authored-by: John Marcou <[email protected]>
  • Loading branch information
harrysolovay and johnmarcou authored Sep 6, 2024
1 parent 6403df8 commit 0953aa8
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 57 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ DB_PORT=5432
DB_NAME=db
DATABASE_URL=postgresql://granola:[email protected]:5432/db

BUCKET_NAME="673156464838-mina-staking-ledgers"

# [REQUIRED] - the connection URL for the archive database.
# ARCHIVE_DATABASE_URL=postgresql://granola:[email protected]:5432/db

Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
},
"editor.formatOnSave": true
}
86 changes: 84 additions & 2 deletions server/Cargo.lock

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

7 changes: 5 additions & 2 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "mina-ocv-server"
version = "0.3.0"
version = "0.4.0"
edition = "2021"

[dependencies]
# Core dependencies
axum = { version = "0.6.4", features = ["tower-log"] }
bs58 = {version = "0.4.0", features = ["check"]}
bs58 = { version = "0.4.0", features = ["check"] }
diesel = { version = "2.0.3", features = ["postgres", "r2d2", "numeric"] }
diesel-derive-enum = { version = "2.0.0", features = ["postgres"] }
clap = { version = "4.1.4", features = ["derive", "env"] }
Expand All @@ -27,3 +27,6 @@ bytes = "1.4.0"
futures-util = "0.3"
rust_decimal = "1.28.0"
r2d2 = "0.8.10"
flate2 = "1.0.33"
tar = "0.4.41"
bigdecimal = "0.4.5"
58 changes: 50 additions & 8 deletions server/migrations/2023-08-20-211633_add_initial_schema/up.sql
Original file line number Diff line number Diff line change
@@ -1,23 +1,65 @@
-- Your SQL goes here

CREATE TYPE proposal_version AS ENUM ('V1', 'V2');
CREATE TYPE proposal_category AS ENUM ('Core', 'Networking', 'Interface', 'ERC', 'Cryptography');

CREATE TYPE proposal_category AS ENUM (
'Core',
'Networking',
'Interface',
'ERC',
'Cryptography'
);
CREATE TABLE mina_proposals (
id SERIAL PRIMARY KEY,
key TEXT NOT NULL UNIQUE,
start_time BIGINT NOT NULL,
end_time BIGINT NOT NULL,
epoch BIGINT NOT NULL,
ledger_hash TEXT,
category proposal_category NOT NULL,
version proposal_version NOT NULL DEFAULT 'V2',
title TEXT NOT NULL,
description TEXT NOT NULL,
url TEXT NOT NULL
);

CREATE INDEX mina_proposals_key_idx ON mina_proposals (key);

INSERT INTO mina_proposals VALUES (1, 'MIP1', 1672848000000, 1673685000000, 'jxQXzUkst2L9Ma9g9YQ3kfpgB5v5Znr1vrYb1mupakc5y7T89H8', 'Core', 'V1', 'Remove supercharged rewards', 'Removing the short-term incentive of supercharged rewards.', 'https://github.com/MinaProtocol/MIPs/blob/main/MIPS/mip-remove-supercharged-rewards.md');
INSERT INTO mina_proposals VALUES (3, 'MIP3', 1684562400000, 1685253600000, 'jw8dXuUqXVgd6NvmpryGmFLnRv1176oozHAro8gMFwj8yuvhBeS', 'Cryptography', 'V2', 'Kimchi, a new proof system', 'Kimchi is an update to the proof system currently used by Mina.', 'https://github.com/MinaProtocol/MIPs/blob/main/MIPS/mip-kimchi.md');
INSERT INTO mina_proposals VALUES (4, 'MIP4', 1684562400000, 1685253600000, 'jw8dXuUqXVgd6NvmpryGmFLnRv1176oozHAro8gMFwj8yuvhBeS', 'Core', 'V2', 'Easier zkApp programmability on mainnet', 'Adding programmable smart contracts (zkApps) to the Mina protocol.', 'https://github.com/MinaProtocol/MIPs/blob/main/MIPS/mip-zkapps.md')
INSERT INTO mina_proposals
VALUES (
1,
'MIP1',
1672848000000,
1673685000000,
46,
'jxQXzUkst2L9Ma9g9YQ3kfpgB5v5Znr1vrYb1mupakc5y7T89H8',
'Core',
'V1',
'Remove supercharged rewards',
'Removing the short-term incentive of supercharged rewards.',
'https://github.com/MinaProtocol/MIPs/blob/main/MIPS/mip-remove-supercharged-rewards.md'
);
INSERT INTO mina_proposals
VALUES (
3,
'MIP3',
1684562400000,
1685253600000,
55,
'jw8dXuUqXVgd6NvmpryGmFLnRv1176oozHAro8gMFwj8yuvhBeS',
'Cryptography',
'V2',
'Kimchi, a new proof system',
'Kimchi is an update to the proof system currently used by Mina.',
'https://github.com/MinaProtocol/MIPs/blob/main/MIPS/mip-kimchi.md'
);
INSERT INTO mina_proposals
VALUES (
4,
'MIP4',
1684562400000,
1685253600000,
55,
'jw8dXuUqXVgd6NvmpryGmFLnRv1176oozHAro8gMFwj8yuvhBeS',
'Core',
'V2',
'Easier zkApp programmability on mainnet',
'Adding programmable smart contracts (zkApps) to the Mina protocol.',
'https://github.com/MinaProtocol/MIPs/blob/main/MIPS/mip-zkapps.md'
)
10 changes: 7 additions & 3 deletions server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ pub(crate) struct Context {
pub(crate) cache: Arc<CacheManager>,
pub(crate) conn_manager: Arc<DBConnectionManager>,
pub(crate) network: NetworkConfig,
pub(crate) ledger_storage_path: Option<String>,
pub(crate) ledger_storage_path: String,
pub(crate) bucket_name: String,
}

#[derive(Clone, Copy, Parser, ValueEnum, Debug)]
Expand Down Expand Up @@ -54,9 +55,12 @@ pub(crate) struct Config {
/// Origins allowed to make cross-site requests.
#[clap(long, env = "SERVER_ALLOWED_ORIGINS", value_parser = parse_allowed_origins )]
pub(crate) allowed_origins: HashSet<String>,
/// Override ledger storage location.
/// Set the name of the bucket containing the ledgers
#[clap(long, env)]
pub(crate) ledger_storage_path: Option<String>,
pub(crate) bucket_name: String,
/// Path to store the ledgers
#[clap(long, env, default_value = "/tmp/ledgers")]
pub(crate) ledger_storage_path: String,
}

#[allow(clippy::unnecessary_wraps)]
Expand Down
3 changes: 2 additions & 1 deletion server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tokio::signal;
use tower::ServiceBuilder;
use tower_http::trace::TraceLayer;

use crate::config::{Context, Config};
use crate::config::{Config, Context};
use crate::database::{cache::CacheManager, DBConnectionManager};
use crate::prelude::*;
use crate::routes::Build;
Expand Down Expand Up @@ -47,6 +47,7 @@ async fn main() -> Result<()> {
conn_manager: Arc::new(conn_manager),
network: config.mina_network,
ledger_storage_path: config.ledger_storage_path,
bucket_name: config.bucket_name,
})),
);

Expand Down
1 change: 1 addition & 0 deletions server/src/models/diesel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub(crate) struct MinaProposal {
pub(crate) key: String,
pub(crate) start_time: i64,
pub(crate) end_time: i64,
pub(crate) epoch: i64,
pub(crate) ledger_hash: Option<String>,
pub(crate) category: ProposalCategory,
pub(crate) version: ProposalVersion,
Expand Down
Loading

0 comments on commit 0953aa8

Please sign in to comment.