Skip to content

Commit

Permalink
Merge branch 'main' into feature/review-stage
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Leshiy authored Jul 14, 2023
2 parents 04b78d9 + b03ff2b commit aa51549
Show file tree
Hide file tree
Showing 65 changed files with 1,730 additions and 113,782 deletions.
1 change: 0 additions & 1 deletion 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 book/src/07_web_api/openapi/core_backend_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,6 @@ components:
description: The public encryption key used. ONLY if required by the ballot type (private, cast-private).
required:
- chain_proposal_index
- group
- chain_voteplan_id
x-stoplight:
id: owvld2uvjjnty
Expand Down
5 changes: 0 additions & 5 deletions services/voting-node/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ docker:
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/*

# We should probably do this by mouting the file at runtime?
RUN mkdir -p /root/.ssh && \
echo "Host *\n\tStrictHostKeyChecking accept-new" >> /root/.ssh/config && \
chmod 644 /root/.ssh/config

# Set the working directory
WORKDIR /app

Expand Down
14 changes: 9 additions & 5 deletions services/voting-node/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ echo ">>> Starting entrypoint script..."

# Check if all required environment variables are set
REQUIRED_ENV=(
"DBSYNC_SSH_HOST_KEY"
"DBSYNC_SSH_PRIVKEY"
"DBSYNC_SSH_PUBKEY"
"EVENTDB_URL"
Expand Down Expand Up @@ -132,11 +133,14 @@ fi

# Setup dbsync SSH keys
echo ">>> Setting up dbsync SSH keys..."
mkdir -p /app/ssh
echo -n "${DBSYNC_SSH_PRIVKEY}" | base64 -d >/app/ssh/private
echo -n "${DBSYNC_SSH_PUBKEY}" | base64 -d >/app/ssh/public

export SSH_SNAPSHOT_TOOL_KEYFILE=/app/ssh/private
mkdir -p /root/.ssh
echo -n "${DBSYNC_SSH_PRIVKEY}" | base64 -d >/root/.ssh/id_snapshot
echo -n "${DBSYNC_SSH_PUBKEY}" | base64 -d >/root/.ssh/id_snapshot.pub
echo -n "${DBSYNC_SSH_HOST_KEY}" | base64 -d >/root/.ssh/known_hosts
chmod 0700 /root/.ssh
chmod 0600 /root/.ssh/*

export SSH_SNAPSHOT_TOOL_KEYFILE=/root/.ssh/id_snapshot

# Sleep if DEBUG_SLEEP is set
debug_sleep
Expand Down
2 changes: 1 addition & 1 deletion services/voting-node/poetry.lock

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

10 changes: 5 additions & 5 deletions services/voting-node/voting_node/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ async def snapshot_import(self, event_id: int):
# same format that the DBSync snapshot importer CLI expects.
network_ids = [id.strip() for id in os.environ["SNAPSHOT_NETWORK_IDS"].split(" ")]

if os.environ["SNAPSHOT_TOOL_SSH"] is not None:
snapshot_tool_path = os.environ["SSH_SNAPSHOT_TOOL_PATH"]
snapshot_tool_out_dir = os.environ["SSH_SNAPSHOT_TOOL_OUTPUT_DIR"]
keyfile_path = os.environ["SSH_SNAPSHOT_TOOL_KEYFILE"]
destination = os.environ["SSH_SNAPSHOT_TOOL_DESTINATION"]
if os.getenv("SNAPSHOT_TOOL_SSH") is not None:
snapshot_tool_path = os.getenv("SSH_SNAPSHOT_TOOL_PATH")
snapshot_tool_out_dir = os.getenv("SSH_SNAPSHOT_TOOL_OUTPUT_DIR")
keyfile_path = os.getenv("SSH_SNAPSHOT_TOOL_KEYFILE")
destination = os.getenv("SSH_SNAPSHOT_TOOL_DESTINATION")

if (
snapshot_tool_path is not None
Expand Down
5 changes: 4 additions & 1 deletion src/cat-data-service/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::{future::ready, net::SocketAddr, sync::Arc, time::Instant};
use tower_http::cors::{Any, CorsLayer};

mod health;
mod v0;
mod v1;

#[derive(thiserror::Error, Debug)]
Expand All @@ -30,9 +31,10 @@ pub struct ErrorMessage {

pub fn app(state: Arc<State>) -> Router {
// build our application with a route
let v0 = v0::v0(state.clone());
let v1 = v1::v1(state);
let health = health::health();
Router::new().nest("/api", v1).merge(health)
Router::new().nest("/api", v1.merge(v0)).merge(health)
}

fn metrics_app() -> Router {
Expand All @@ -44,6 +46,7 @@ fn cors_layer() -> CorsLayer {
CorsLayer::new()
.allow_methods([Method::GET, Method::POST])
.allow_origin(Any)
.allow_headers(Any)
}

async fn run_service(app: Router, addr: &SocketAddr, name: &str) -> Result<(), Error> {
Expand Down
10 changes: 4 additions & 6 deletions src/cat-data-service/src/service/v0/fund.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{
service::{handle_result, Error},
state::State,
types::SerdeType,
};
use axum::{routing::get, Router};
use event_db::types::vit_ss::fund::FundWithNext;
Expand All @@ -9,17 +10,14 @@ use std::sync::Arc;
pub fn fund(state: Arc<State>) -> Router {
Router::new().route(
"/fund",
get({
let state = state.clone();
move || async { handle_result(fund_exec(state).await) }
}),
get(|| async { handle_result(fund_exec(state).await) }),
)
}

async fn fund_exec(state: Arc<State>) -> Result<FundWithNext, Error> {
async fn fund_exec(state: Arc<State>) -> Result<SerdeType<FundWithNext>, Error> {
tracing::debug!("fund_query",);

let fund = state.event_db.get_fund().await?;
let fund = state.event_db.get_fund().await?.into();
Ok(fund)
}

Expand Down
4 changes: 2 additions & 2 deletions src/cat-data-service/src/service/v0/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;
use axum::Router;
use crate::state::State;
use axum::Router;
use std::sync::Arc;

mod fund;

Expand Down
12 changes: 9 additions & 3 deletions src/cat-data-service/src/service/v1/event/ballots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
types::SerdeType,
};
use axum::{extract::Path, routing::get, Router};
use event_db::types::event::{ballot::ObjectiveBallots, EventId};
use event_db::types::{ballot::ObjectiveBallots, event::EventId};
use std::sync::Arc;

pub fn ballots(state: Arc<State>) -> Router {
Expand All @@ -17,10 +17,16 @@ pub fn ballots(state: Arc<State>) -> Router {
async fn ballots_exec(
Path(SerdeType(event)): Path<SerdeType<EventId>>,
state: Arc<State>,
) -> Result<Vec<ObjectiveBallots>, Error> {
) -> Result<Vec<SerdeType<ObjectiveBallots>>, Error> {
tracing::debug!("ballots_query, event: {0}", event.0,);

let ballot = state.event_db.get_event_ballots(event).await?;
let ballot = state
.event_db
.get_event_ballots(event)
.await?
.into_iter()
.map(SerdeType)
.collect();
Ok(ballot)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
types::SerdeType,
};
use axum::{extract::Path, routing::get, Router};
use event_db::types::event::{ballot::ProposalBallot, objective::ObjectiveId, EventId};
use event_db::types::{ballot::ProposalBallot, event::EventId, objective::ObjectiveId};
use std::sync::Arc;

pub fn ballots(state: Arc<State>) -> Router {
Expand All @@ -20,7 +20,7 @@ async fn ballots_exec(
SerdeType<ObjectiveId>,
)>,
state: Arc<State>,
) -> Result<Vec<ProposalBallot>, Error> {
) -> Result<Vec<SerdeType<ProposalBallot>>, Error> {
tracing::debug!(
"ballots_query, event: {0}, objective: {1}",
event.0,
Expand All @@ -30,7 +30,10 @@ async fn ballots_exec(
let ballot = state
.event_db
.get_objective_ballots(event, objective)
.await?;
.await?
.into_iter()
.map(SerdeType)
.collect();
Ok(ballot)
}

Expand Down
2 changes: 1 addition & 1 deletion src/cat-data-service/src/service/v1/event/objective/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use axum::{
routing::get,
Router,
};
use event_db::types::event::{objective::Objective, voting_status::VotingStatus, EventId};
use event_db::types::{event::EventId, objective::Objective, voting_status::VotingStatus};
use std::sync::Arc;

mod ballots;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
types::SerdeType,
};
use axum::{extract::Path, routing::get, Router};
use event_db::types::event::{
ballot::Ballot, objective::ObjectiveId, proposal::ProposalId, EventId,
use event_db::types::{
ballot::Ballot, event::EventId, objective::ObjectiveId, proposal::ProposalId,
};
use std::sync::Arc;

Expand All @@ -23,7 +23,7 @@ async fn ballot_exec(
SerdeType<ProposalId>,
)>,
state: Arc<State>,
) -> Result<Ballot, Error> {
) -> Result<SerdeType<Ballot>, Error> {
tracing::debug!(
"ballot_query, event: {0}, objective: {1}, proposal: {2}",
event.0,
Expand All @@ -34,7 +34,8 @@ async fn ballot_exec(
let ballot = state
.event_db
.get_ballot(event, objective, proposal)
.await?;
.await?
.into();
Ok(ballot)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use axum::{
routing::get,
Router,
};
use event_db::types::event::{
use event_db::types::{
event::EventId,
objective::ObjectiveId,
proposal::{Proposal, ProposalId, ProposalSummary},
EventId,
};
use std::sync::Arc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use axum::{
routing::get,
Router,
};
use event_db::types::event::{
objective::ObjectiveId, proposal::ProposalId, review::AdvisorReview, EventId,
use event_db::types::{
event::EventId, objective::ObjectiveId, proposal::ProposalId, review::AdvisorReview,
};
use std::sync::Arc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use axum::{
routing::get,
Router,
};
use event_db::types::event::{objective::ObjectiveId, review::ReviewType, EventId};
use event_db::types::{event::EventId, objective::ObjectiveId, review::ReviewType};
use std::sync::Arc;

pub fn review_type(state: Arc<State>) -> Router {
Expand Down
Loading

0 comments on commit aa51549

Please sign in to comment.