Skip to content

Commit

Permalink
change folder name
Browse files Browse the repository at this point in the history
  • Loading branch information
eaypek-tfh committed Dec 9, 2024
1 parent 6441ec3 commit 24f69a4
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion deploy/stage/common-values-iris-mpc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: "ghcr.io/worldcoin/iris-mpc:c712190e6a1da6b3253edd6166bf76168294c177"
image: "ghcr.io/worldcoin/iris-mpc:cc22ea8600dcf6fd165f365bdbcd1852a91cbed6"

environment: stage
replicaCount: 1
Expand Down
3 changes: 3 additions & 0 deletions deploy/stage/smpcv2-0-stage/values-iris-mpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ env:
- name: SMPC__DB_CHUNKS_BUCKET_NAME
value: "iris-mpc-db-exporter-store-node-0-stage-eu-north-1"

- name: SMPC__DB_CHUNKS_FOLDER_NAME
value: "binary_output_4k"

- name: SMPC__CLEAR_DB_BEFORE_INIT
value: "true"

Expand Down
3 changes: 3 additions & 0 deletions deploy/stage/smpcv2-1-stage/values-iris-mpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ env:
- name: SMPC__DB_CHUNKS_BUCKET_NAME
value: "iris-mpc-db-exporter-store-node-1-stage-eu-north-1"

- name: SMPC__DB_CHUNKS_FOLDER_NAME
value: "binary_output_4k"

- name: SMPC__CLEAR_DB_BEFORE_INIT
value: "true"

Expand Down
3 changes: 3 additions & 0 deletions deploy/stage/smpcv2-2-stage/values-iris-mpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ env:
- name: SMPC__DB_CHUNKS_BUCKET_NAME
value: "iris-mpc-db-exporter-store-node-2-stage-eu-north-1"

- name: SMPC__DB_CHUNKS_FOLDER_NAME
value: "binary_output_4k"

- name: SMPC__CLEAR_DB_BEFORE_INIT
value: "true"

Expand Down
3 changes: 3 additions & 0 deletions iris-mpc-common/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ pub struct Config {
/// updated during the DB export to S3
#[serde(default = "default_db_load_safety_overlap_seconds")]
pub db_load_safety_overlap_seconds: i64,

#[serde(default)]
pub db_chunks_folder_name: String,
}

fn default_load_chunks_parallelism() -> usize {
Expand Down
2 changes: 1 addition & 1 deletion iris-mpc-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub use s3_importer::{fetch_and_parse_chunks, last_snapshot_timestamp, ObjectSto
use sqlx::{
migrate::Migrator, postgres::PgPoolOptions, Executor, PgPool, Postgres, Row, Transaction,
};
use std::{ops::DerefMut, pin::Pin, u32};
use std::{ops::DerefMut, pin::Pin};

const APP_NAME: &str = "SMPC";
const MAX_CONNECTIONS: u32 = 100;
Expand Down
11 changes: 8 additions & 3 deletions iris-mpc-store/src/s3_importer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,20 @@ impl ObjectStore for S3Store {
}
}

pub async fn last_snapshot_timestamp(store: &impl ObjectStore) -> eyre::Result<i64> {
pub async fn last_snapshot_timestamp(
store: &impl ObjectStore,
folder_name: String,
) -> eyre::Result<i64> {
tracing::info!("Looking for last snapshot time in folder: {}", folder_name);
let start_path = format!("{}/", folder_name);
store
.list_objects()
.await?
.into_iter()
.filter(|f| f.starts_with("output/") && f.ends_with(".timestamp"))
.filter(|f| f.starts_with(start_path.as_str()) && f.ends_with(".timestamp"))
.filter_map(|f| {
f.replace(".timestamp", "")
.replace("output/", "")
.replace(start_path.as_str(), "")
.parse::<i64>()
.ok()
})
Expand Down
9 changes: 8 additions & 1 deletion iris-mpc/src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,7 @@ async fn server_main(config: Config) -> eyre::Result<()> {

let load_chunks_parallelism = config.load_chunks_parallelism;
let db_chunks_bucket_name = config.db_chunks_bucket_name.clone();
let db_chunks_folder_name = config.db_chunks_folder_name.clone();

let (tx, rx) = oneshot::channel();
background_tasks.spawn_blocking(move || {
Expand Down Expand Up @@ -984,9 +985,15 @@ async fn server_main(config: Config) -> eyre::Result<()> {
let s3_store = S3Store::new(s3_client_clone, db_chunks_bucket_name);
tokio::runtime::Handle::current().block_on(async {
// First fetch last snapshot from S3
let last_snapshot_timestamp = last_snapshot_timestamp(&s3_store).await?;
let last_snapshot_timestamp =
last_snapshot_timestamp(&s3_store, db_chunks_folder_name).await?;
let min_last_modified_at =
last_snapshot_timestamp - config.db_load_safety_overlap_seconds;
tracing::info!(
"Last snapshot timestamp: {}, min_last_modified_at: {}",
last_snapshot_timestamp,
min_last_modified_at
);
let stream_s3 = fetch_and_parse_chunks(&s3_store, load_chunks_parallelism)
.await
.map(|result| result.map(IrisSource::S3))
Expand Down

0 comments on commit 24f69a4

Please sign in to comment.