Skip to content

Commit

Permalink
separate s3 clients for sns requests and chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
eaypek-tfh committed Jan 12, 2025
1 parent 26fa82f commit 103fccb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 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:05d4b8bf587826573163c6ef5d6145a2a12cf9f2"
image: "ghcr.io/worldcoin/iris-mpc:7f73890c1ed490294517cc74951bbfc688e7cc57"

environment: stage
replicaCount: 1
Expand Down
2 changes: 1 addition & 1 deletion iris-mpc-store/src/s3_importer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const SINGLE_ELEMENT_SIZE: usize = IRIS_CODE_LENGTH * mem::size_of::<u16>() * 2
+ MASK_CODE_LENGTH * mem::size_of::<u16>() * 2
+ mem::size_of::<u32>(); // 75 KB

const MAX_RANGE_SIZE: usize = 200; // Download chunks in sub-chunks of 100 elements = 7.5 MB
const MAX_RANGE_SIZE: usize = 200; // Download chunks in sub-chunks of 200 elements = 15 MB

pub struct S3StoredIris {
#[allow(dead_code)]
Expand Down
21 changes: 14 additions & 7 deletions iris-mpc/src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,11 @@ async fn server_main(config: Config) -> eyre::Result<()> {
));
shutdown_handler.wait_for_shutdown_signal().await;

let shares_bucket_host = format!("{}.s3.{}.amazonaws.com", config.shares_bucket_name, "eu-central-1");
let shares_bucket_ips = resolve_export_bucket_ips(shares_bucket_host);
let db_chunks_bucket_host = format!(
"{}.s3.{}.amazonaws.com",
config.db_chunks_bucket_name, REGION
);
let db_chunks_bucket_ips = resolve_export_bucket_ips(db_chunks_bucket_host);
// Load batch_size config
*CURRENT_BATCH_SIZE.lock().unwrap() = config.max_batch_size;
let max_sync_lookback: usize = config.max_batch_size * 2;
Expand All @@ -776,18 +779,22 @@ async fn server_main(config: Config) -> eyre::Result<()> {
let sns_client = SNSClient::new(&shared_config);

// Increase S3 retries to 5
let static_resolver = StaticResolver::new(shares_bucket_ips.await?);
let client = HyperClientBuilder::new()
let static_resolver = StaticResolver::new(db_chunks_bucket_ips.await?);
let http_client = HyperClientBuilder::new()
.crypto_mode(CryptoMode::Ring)
.build_with_resolver(static_resolver);

let retry_config = RetryConfig::standard().with_max_attempts(5);
let s3_config = S3ConfigBuilder::from(&shared_config)
.retry_config(retry_config.clone())
.build();
let db_chunks_s3_config = S3ConfigBuilder::from(&shared_config)
.retry_config(retry_config)
.http_client(client)
.http_client(http_client)
.build();

let s3_client = Arc::new(S3Client::from_conf(s3_config));
let s3_client_clone = Arc::clone(&s3_client);
let db_chunks_s3_client = Arc::new(S3Client::from_conf(db_chunks_s3_config));
let shares_encryption_key_pair =
match SharesEncryptionKeyPairs::from_storage(config.clone()).await {
Ok(key_pair) => key_pair,
Expand Down Expand Up @@ -1129,7 +1136,7 @@ async fn server_main(config: Config) -> eyre::Result<()> {
"Initialize iris db: Loading from DB (parallelism: {})",
parallelism
);
let s3_store = S3Store::new(s3_client_clone, db_chunks_bucket_name);
let s3_store = S3Store::new(db_chunks_s3_client, db_chunks_bucket_name);
tokio::runtime::Handle::current().block_on(async {
let mut stream = match config.enable_s3_importer {
true => {
Expand Down

0 comments on commit 103fccb

Please sign in to comment.