-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Key image store service and server for router/store system (#2954)
* Ledger enclave support for router and store (#2896) * Pulling changes in from milliec/ledger-router-dev * Run cargo fmt * Making requested changes and clarifications to Fog ledger router comments. * Additional comment fixes * Fix CI lint * PR feedback nits Co-authored-by: Andrew Wygle <andrew@mobilecoin.com> * Fog Ledger Router Admin service * Sort itertools properly in Cargo.toml * Key Image Router Server + Binary * Update router config for parameterized retries * Changes due to rebase * normalize naming - ledger router, key image store * Linting fixes * Accept code review suggestions * Updates for GRPCIO 0.12 * Remove some unwraps in ledger_router binary * Pulling changes in from milliec/ledger-router-dev * Making requested changes and clarifications to Fog ledger router comments. * PR feedback nits * Key Image Router Service * Update fog/ledger/server/src/key_image_router_service.rs Co-authored-by: Nick Santana <nick@mobilecoin.com> * Address PR feedback around logging and comments. * Parameterize allowed number of retries for query loop * Fog Ledger Router Admin service * Sort itertools properly in Cargo.toml * Key Image Router Server + Binary * Key image store changes pulled in from milliec/ledger-router-dev * Cargo fmt * Run clippy * Sort itertools properly in Cargo.toml * Rebase and update to match current fog ledger router branch * Remove unused dependencies in fog-ledger-server Co-authored-by: Nick Santana <nick@mobilecoin.com> * Apply suggestions - Remove unused deps Co-authored-by: Nick Santana <nick@mobilecoin.com> * Apply suggestions from comments Applying suggestions from @nick-mobilecoin's review Co-authored-by: Nick Santana <nick@mobilecoin.com> * Resolving some code quality issues in direct_key_image_store_check() * Cargo fmt * key image server and key image service moved to router server and router service * Apply suggestions from code review Co-authored-by: Sam Dealy <33067698+samdealy@users.noreply.github.com> Co-authored-by: Nick Santana <nick@mobilecoin.com> --------- Co-authored-by: Andrew Wygle <andrew@mobilecoin.com> Co-authored-by: Nick Santana <nick@mobilecoin.com> Co-authored-by: Sam Dealy <33067698+samdealy@users.noreply.github.com>
- Loading branch information
1 parent
5796d4d
commit 5640688
Showing
9 changed files
with
842 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright (c) 2018-2022 The MobileCoin Foundation | ||
|
||
use clap::Parser; | ||
use grpcio::{RpcStatus, RpcStatusCode}; | ||
use mc_common::{logger::log, time::SystemTimeProvider}; | ||
use mc_fog_ledger_enclave::{LedgerSgxEnclave, ENCLAVE_FILE}; | ||
use mc_fog_ledger_server::{KeyImageStoreServer, LedgerStoreConfig}; | ||
use mc_ledger_db::LedgerDB; | ||
use mc_util_grpc::AdminServer; | ||
use mc_watcher::watcher_db::WatcherDB; | ||
|
||
use std::{env, sync::Arc}; | ||
|
||
fn main() { | ||
let (logger, _global_logger_guard) = | ||
mc_common::logger::create_app_logger(mc_common::logger::o!()); | ||
mc_common::setup_panic_handler(); | ||
let config = LedgerStoreConfig::parse(); | ||
|
||
let enclave_path = env::current_exe() | ||
.expect("Could not get the path of our executable") | ||
.with_file_name(ENCLAVE_FILE); | ||
log::info!( | ||
logger, | ||
"enclave path {}, responder ID {}", | ||
enclave_path | ||
.to_str() | ||
.expect("enclave path is not valid UTF-8"), | ||
&config.client_responder_id | ||
); | ||
let enclave = LedgerSgxEnclave::new( | ||
enclave_path, | ||
&config.client_responder_id, | ||
config.omap_capacity, | ||
logger.clone(), | ||
); | ||
|
||
//Get our ledger connection started. | ||
let db = LedgerDB::open(&config.ledger_db).expect("Could not read ledger DB"); | ||
let watcher = | ||
WatcherDB::open_ro(&config.watcher_db, logger.clone()).expect("Could not open watcher DB"); | ||
|
||
let mut store_server = KeyImageStoreServer::new_from_config( | ||
config.clone(), | ||
enclave, | ||
db, | ||
watcher, | ||
SystemTimeProvider::default(), | ||
logger.clone(), | ||
); | ||
store_server.start(); | ||
|
||
//Initialize the admin api | ||
let config2 = config.clone(); | ||
let get_config_json = Arc::new(move || { | ||
serde_json::to_string(&config2) | ||
.map_err(|err| RpcStatus::with_message(RpcStatusCode::INTERNAL, format!("{err:?}"))) | ||
}); | ||
let _admin_server = config.admin_listen_uri.as_ref().map(|admin_listen_uri| { | ||
AdminServer::start( | ||
None, | ||
admin_listen_uri, | ||
"Fog Ledger".to_owned(), | ||
config.client_responder_id.to_string(), | ||
Some(get_config_json), | ||
logger, | ||
) | ||
.expect("Failed starting admin server") | ||
}); | ||
|
||
loop { | ||
std::thread::sleep(std::time::Duration::from_millis(1000)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.