Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Fog Ledger Router #3312

Merged
merged 143 commits into from
Apr 24, 2023
Merged
Changes from 1 commit
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
c22781a
Fix Fog View Connection Cargo.toml dependencies
samdealy Jul 13, 2022
262eea6
Implement create_multi_view_query_data API for Fog View Router (#2115)
samdealy Jun 14, 2022
d4a7a61
Implement MultiViewStoreQuery API for Fog View (#2133)
samdealy Jun 23, 2022
ed6cd60
Implement enclave APIs that facilitate Fog View Router dynamic store …
samdealy Jul 8, 2022
c801436
Remove duplicate wasi files
samdealy Jul 13, 2022
d6b4d59
Re-add older wasi version
samdealy Jul 13, 2022
cc7d8be
Implement query / dynamic shard component discovery in Fog View Route…
samdealy Jul 15, 2022
84017c7
Split Fog View API into Client-facing and Store (Fog Router) APIs (#2…
samdealy Jul 19, 2022
7366bee
Create helper methods to obliviously collate shard responses (#2252)
samdealy Aug 10, 2022
01104d2
Collate shard response in constant time (obliviously) (#2250)
samdealy Aug 10, 2022
e3039f7
Implement epoch sharding via trait (#2350)
samdealy Aug 10, 2022
290bb5b
Use sharding strategy to tell view what blocks to process (#2351)
samdealy Aug 12, 2022
3a33948
Return minimum highest processed block to client (#2387)
samdealy Aug 12, 2022
f8fb892
Add config option for sharding strategy (#2352)
samdealy Aug 13, 2022
a329df2
Add readiness API to ShardingStrategy (#2353)
samdealy Aug 30, 2022
7989e7e
Add report fetching logic to FVR (#2454)
samdealy Aug 30, 2022
3ba7998
Fix responder ID usage in FVR (#2446)
samdealy Aug 31, 2022
f4d0ff7
Create different types of View Servers for store and client-facing (#…
samdealy Sep 1, 2022
2149b65
Messages for noise protocol exchanges with explicit nonces (#2461)
Sep 2, 2022
71e4bcd
Minor DRY cleanups around sessions and auth messages (#2462)
Sep 2, 2022
fa685ca
Update FVR client for integration test (#2448)
samdealy Sep 2, 2022
c59c8a4
Create gRPC FogViewRouterAdminAPI (#2360)
samdealy Sep 7, 2022
045270c
Create FogViewRouterAdminUri (#2361)
samdealy Sep 7, 2022
856128e
update cargo lock
samdealy Sep 13, 2022
789ffb8
Sealed messages for clients with backends (#2449)
awygle Sep 14, 2022
53ee79c
Implement shard management API sans auth (#2354)
samdealy Sep 14, 2022
0d0a4a1
Re-apply 2463. (#2547)
Sep 21, 2022
2c7845b
Re-apply PR #2473 (was accidentally removed) (#2548)
Sep 21, 2022
42a425a
Add inbound frontend connection support crypto-ake-enclave (#2549)
Sep 28, 2022
f1eee8a
Make constants and comments slightly friendlier/more consistent (#2550)
Sep 28, 2022
e253d13
fix cargo lock
samdealy Sep 28, 2022
3072986
Sort deps
samdealy Sep 28, 2022
027189e
Fix cargo lock files
samdealy Sep 30, 2022
2a01478
Spurious commit to trigger CI
samdealy Sep 30, 2022
8100f96
Remove `get_nonce` from NonceSession, rename `peek_nonce`->`nonce` (#…
awygle Oct 3, 2022
52e5fb6
Replace client with nonce paradigm for backends (#2625)
samdealy Oct 3, 2022
0ef6ef3
Modify MVQ to use NonceMessage (#2617)
samdealy Oct 5, 2022
1982d80
Merge master
samdealy Oct 5, 2022
a1b2bae
Fix fog conformance OOM failure by reducing `frontends` allocation (#…
samdealy Oct 6, 2022
96beb05
Create query_backend enclave methods (#2627)
samdealy Oct 8, 2022
2ae2565
Implement nonce based auth for Fog View Store (#2653)
samdealy Oct 11, 2022
51e2f40
Close gRPC channel when client is dropped (#2692)
samdealy Oct 11, 2022
a76ae5e
Close gRPC channel when client is dropped (#2694)
samdealy Oct 12, 2022
b493bf4
Create fog view router test utils (#2698)
samdealy Oct 14, 2022
31f2bd9
Add block range to MVQ response (#2720)
samdealy Oct 19, 2022
a310ba3
Update BlockTracker to use ShardingStrategy (#2711)
samdealy Oct 19, 2022
508443c
Create MVQ internal type (#2721)
samdealy Oct 19, 2022
fb8b136
Implement new highest processed block count logic (#2722)
samdealy Oct 19, 2022
b979c78
Set block-related data more accurately (#2726)
samdealy Oct 21, 2022
0526f2d
Create Fog View Router integration test (#2375)
samdealy Oct 24, 2022
f13b617
Calculate last known block txo count and add tests (#2766)
samdealy Oct 26, 2022
91f18ba
Collate remaining QueryResponse fields (#2781)
samdealy Nov 2, 2022
45222b7
Clean up response creation (#2783)
samdealy Nov 2, 2022
b446019
Merge master
samdealy Nov 7, 2022
37f6699
Make query batch logic compatible with sharding strategy (#2845)
samdealy Nov 14, 2022
caa4a37
Re-submit 2803 (#2866)
samdealy Nov 14, 2022
39f9060
Make FVR integration test more complex (#2804)
samdealy Nov 14, 2022
83105b3
Add unary apis to FogViewRouter (#2839)
samdealy Nov 15, 2022
ec3fea3
Merge branch 'master' into feature/fog-view-router
samdealy Nov 28, 2022
83f0f00
Account for epochs in block tracker highest processed block count log…
samdealy Nov 29, 2022
0c0e74b
Incorporate missed blocks into calculation for highest processed bloc…
samdealy Nov 29, 2022
4d13d24
Fix blank query sealing issue (#2904)
samdealy Dec 1, 2022
eea10fd
Remove FogViewApi from FogViewService (#2852)
samdealy Dec 2, 2022
864092d
Rename tests (#2905)
samdealy Dec 2, 2022
2b52ce5
Create InternalTxOutSearchResult (#2880)
samdealy Dec 16, 2022
7cb27dc
Fix response processing loop logic (#2946)
samdealy Dec 16, 2022
f32748f
Implement prometheus metrics for FVR (#2976)
samdealy Jan 9, 2023
5ba23ca
fix: bump postgresql chart version
aweis89 Jan 10, 2023
199bcac
fix: update scheme
aweis89 Jan 10, 2023
fd52c2d
Implement optelemetry tracing for FVR (#2979)
samdealy Jan 10, 2023
da78cd3
Merge master
samdealy Jan 11, 2023
c89f398
Merge master
samdealy Jan 12, 2023
151b934
Fix lock files
samdealy Jan 12, 2023
bed11dc
Ensure shards provide correct blocks (#2981)
samdealy Jan 13, 2023
fa3fe5f
Merge branch 'master' into feature/fog-view-router
samdealy Feb 2, 2023
09374b5
Merge branch 'master' into feature/fog-view-router
samdealy Feb 2, 2023
4c91f1a
Merge branch 'master' into feature/fog-view-router
samdealy Feb 3, 2023
1a70ffd
Merge branch 'master' into feature/fog-view-router
samdealy Feb 3, 2023
a87e64d
Make Fog View Store return externally-addressable URI to Router (#3081)
samdealy Feb 6, 2023
db728a5
Fix e_tx_out_store (#3082)
samdealy Feb 7, 2023
f059730
Merge branch 'master' into feature/fog-view-router
samdealy Feb 7, 2023
4d85726
Merge branch 'master' into feature/fog-view-router
samdealy Feb 8, 2023
2a83307
Make find_record constant time (#3097)
samdealy Feb 9, 2023
5acf879
Merge branch 'master' into feature/fog-view-router
samdealy Feb 9, 2023
ddae9b2
Merge branch 'master' into feature/fog-view-router
samdealy Feb 10, 2023
d851ac7
Merge branch 'master' into feature/fog-view-router
samdealy Feb 15, 2023
8450dd1
Merge branch 'master' into feature/fog-view-router
samdealy Feb 15, 2023
84adb6a
Improve error logging for epoch sharding parsing (#3141)
samdealy Feb 21, 2023
c72955f
Make shard uris delimiter be a comma (#3142)
samdealy Feb 21, 2023
ff7c49e
Merge branch 'master' into feature/fog-view-router
samdealy Feb 21, 2023
42367f2
Merge branch 'master' into feature/fog-view-router
samdealy Feb 23, 2023
9f23f5b
Add uri logging
samdealy Feb 27, 2023
46da66e
Add uri logging
samdealy Feb 27, 2023
4cdbf71
Merge branch 'master' into feature/fog-view-router
samdealy Mar 17, 2023
4cf66b9
Fix deps
samdealy Mar 15, 2023
4a8f2d7
Remove custom readiness check
samdealy Feb 23, 2023
2bb14a9
Fix bad merge
samdealy Mar 17, 2023
16dc1eb
Merge branch 'master' into feature/fog-view-router
samdealy Mar 22, 2023
5b53ed1
Merge branch 'master' into feature/fog-view-router
samdealy Mar 23, 2023
391d2b9
Merge branch 'master' into feature/fog-view-router
samdealy Mar 24, 2023
afb3779
Merge branch 'master' into feature/fog-view-router
samdealy Mar 27, 2023
77b2da1
Merge branch 'master' into feature/fog-view-router
samdealy Mar 29, 2023
0c82d6a
Use mc-rand
samdealy Mar 29, 2023
747f000
Re-add edl dep
samdealy Mar 29, 2023
4d8954b
Re-add all deps taken out by merge
samdealy Mar 29, 2023
56808e2
Update pem in mc-fog-view-server
samdealy Mar 29, 2023
039d4b4
Update cargo lock
samdealy Mar 29, 2023
9441857
Merge branch 'master' into feature/fog-view-router
samdealy Apr 17, 2023
12ba8fc
Update Cargo.lock
samdealy Apr 17, 2023
15099e3
Implement Nick's suggestions
samdealy Apr 18, 2023
283a4cb
Fix modified test
samdealy Apr 18, 2023
3a63e44
Merge branch 'master' into feature/fog-view-router
samdealy Apr 20, 2023
ebfff7a
Fix lint
samdealy Apr 20, 2023
bcd23ef
Add MC_SHARDING_STRATEGY env var
samdealy Apr 21, 2023
27c0901
Pull in protobuf changes from milliec/ledger-router-dev (#2889)
NotGyro Dec 7, 2022
e55d642
Ledger enclave support for router and store (#2896)
NotGyro Dec 14, 2022
cab7272
URIs for Fog Ledger Router (#2897)
awygle Dec 14, 2022
07a4c20
Protobuf conversion functions for Fog Ledger Router (#2891)
awygle Dec 14, 2022
d8965ca
Key Image Router Service (#2898)
awygle Jan 3, 2023
44b095e
Oblivious collation of key image store responses (#2913)
awygle Jan 9, 2023
908782d
Fog Ledger Router Admin service (#2920)
awygle Jan 9, 2023
381832d
Update to use local SVC_COUNTERS
awygle Jan 17, 2023
c8c6673
Key Image Router Server + Binary (#2921)
awygle Jan 24, 2023
dfe738a
Key image store service and server for router/store system (#2954)
NotGyro Feb 7, 2023
38a6033
Implement Sharding Strategy (#2873)
awygle Feb 9, 2023
cd90439
Implement non-KeyImage Functionality for Fog Ledger Router (#3084)
awygle Feb 9, 2023
a19363a
Porting existing Fog Ledger tests to Router (#3138)
awygle Feb 27, 2023
2275c3e
Test key image retrieval via unary API on the router (#3163)
NotGyro Feb 28, 2023
640c497
Fix up Clippy issues from new Rust version
awygle Mar 1, 2023
a3385ff
Make Fog Ledger Store return externally-addressable URI to Router (#3…
awygle Mar 2, 2023
a99be82
Port fog local network and conformance tests to use ledger router (#3…
awygle Mar 2, 2023
37ce735
Fog Ledger Router integration test (#3188)
awygle Mar 17, 2023
538c78c
Remove client-facing API from key-image store (#3217)
NotGyro Mar 20, 2023
fa9ced2
Optelemetry tracing for FLR (#3264)
NotGyro Mar 21, 2023
81ea818
Process all blocks, but only add our blocks to the ORAM (#3203) (#3262)
awygle Mar 23, 2023
08019e7
Prometheus metrics for FLR (#3267)
NotGyro Mar 23, 2023
3081b9d
Post-rebase cleanups
awygle Mar 28, 2023
eda00fb
Use default readiness check for FLR
awygle Mar 29, 2023
c476076
Remove mc-crypto-rand from FLR branch
awygle Apr 11, 2023
45ca0b4
Address PR feedback
awygle Apr 20, 2023
b521939
Clean up Cargo.locks
awygle Apr 20, 2023
fee2eb8
Add MC_SHARDING_STRATEGY
awygle Apr 21, 2023
6447985
Merge branch 'master' into feature/fog-ledger-router
awygle Apr 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* Apply suggestions - Remove unused deps

Co-authored-by: Nick Santana <[email protected]>

* Apply suggestions from comments

Applying suggestions from @nick-mobilecoin's review

Co-authored-by: Nick Santana <[email protected]>

* 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 <[email protected]>
Co-authored-by: Nick Santana <[email protected]>

---------

Co-authored-by: Andrew Wygle <[email protected]>
Co-authored-by: Nick Santana <[email protected]>
Co-authored-by: Sam Dealy <[email protected]>
4 people committed Apr 21, 2023
commit dfe738ab720c4d49d3b691558ab879078de6537b
5 changes: 5 additions & 0 deletions Cargo.lock

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

9 changes: 9 additions & 0 deletions fog/ledger/server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -19,6 +19,10 @@ path = "src/bin/main.rs"
name = "ledger_router"
path = "src/bin/router.rs"

[[bin]]
name = "key_image_store"
path = "src/bin/key_image_store.rs"

[dependencies]
mc-attest-api = { path = "../../../attest/api" }
mc-attest-core = { path = "../../../attest/core" }
@@ -72,9 +76,11 @@ mc-util-build-sgx = { path = "../../../util/build/sgx" }
# mobilecoin
mc-account-keys = { path = "../../../account-keys" }
mc-api = { path = "../../../api" }
mc-attest-ake = { path = "../../../attest/ake" }
mc-blockchain-test-utils = { path = "../../../blockchain/test-utils" }
mc-common = { path = "../../../common", features = ["loggers"] }
mc-crypto-keys = { path = "../../../crypto/keys" }
mc-crypto-rand = { path = "../../../crypto/rand" }
mc-util-test-helper = { path = "../../../util/test-helper" }
mc-util-uri = { path = "../../../util/uri" }

@@ -86,3 +92,6 @@ mc-fog-test-infra = { path = "../../test_infra" }

# third-party
tempfile = "3.4"
aes-gcm = "0.10.1"
sha2 = "0.10"
tempdir = "0.3"
74 changes: 74 additions & 0 deletions fog/ledger/server/src/bin/key_image_store.rs
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));
}
}
84 changes: 81 additions & 3 deletions fog/ledger/server/src/config.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
use clap::Parser;
use mc_attest_core::ProviderId;
use mc_common::ResponderId;
use mc_fog_uri::FogLedgerUri;
use mc_fog_uri::{FogLedgerUri, KeyImageStoreUri};
use mc_util_parse::parse_duration_in_seconds;
use mc_util_uri::AdminUri;
use serde::Serialize;
@@ -96,8 +96,8 @@ pub struct LedgerRouterConfig {
#[clap(long, env = "MC_ADMIN_LISTEN_URI")]
pub admin_listen_uri: AdminUri,

/// Number of query attempts with no forward progress before reporting an
/// error.
/// Number of query attempts with no forward progress
/// before reporting an error.
#[clap(long, default_value = "3")]
pub query_retries: usize,

@@ -115,3 +115,81 @@ pub struct LedgerRouterConfig {
#[clap(long, default_value = "1048576", env = "MC_OMAP_CAPACITY")]
pub omap_capacity: u64,
}

/// Configuration parameters for the Fog Ledger Store service.
#[derive(Clone, Parser, Serialize)]
#[clap(version)]
pub struct LedgerStoreConfig {
/// The chain id of the network we are a part of
#[clap(long, env = "MC_CHAIN_ID")]
pub chain_id: String,

/// The ID with which to respond to client attestation requests.
///
/// This ID needs to match the host:port clients use in their URI when
/// referencing this node.
#[clap(long, env = "MC_CLIENT_RESPONDER_ID")]
pub client_responder_id: ResponderId,

/// gRPC listening URI for client requests.
#[clap(long, env = "MC_CLIENT_LISTEN_URI")]
pub client_listen_uri: KeyImageStoreUri,

/// Path to ledger db (lmdb)
#[clap(long, value_parser(clap::value_parser!(PathBuf)), env = "MC_LEDGER_DB")]
pub ledger_db: PathBuf,

/// Path to watcher db (lmdb) - includes block timestamps
#[clap(long, value_parser(clap::value_parser!(PathBuf)), env = "MC_WATCHER_DB")]
pub watcher_db: PathBuf,

/// IAS Api Key.
#[clap(long, env = "MC_IAS_API_KEY")]
pub ias_api_key: String,

/// IAS Service Provider ID.
#[clap(long, env = "MC_IAS_SPID")]
pub ias_spid: ProviderId,

/// Optional admin listening URI.
#[clap(long, env = "MC_ADMIN_LISTEN_URI")]
pub admin_listen_uri: Option<AdminUri>,

/// Enables authenticating client requests using Authorization tokens using
/// the provided hex-encoded 32 bytes shared secret.
#[clap(long, value_parser = mc_util_parse::parse_hex::<[u8; 32]>, env = "MC_CLIENT_AUTH_TOKEN_SECRET")]
pub client_auth_token_secret: Option<[u8; 32]>,

/// Maximal client authentication token lifetime, in seconds (only relevant
/// when --client-auth-token-secret is used. Defaults to 86400 - 24
/// hours).
#[clap(long, default_value = "86400", value_parser = parse_duration_in_seconds, env = "MC_CLIENT_AUTH_TOKEN_MAX_LIFETIME")]
pub client_auth_token_max_lifetime: Duration,

/// The capacity to build the OMAP (ORAM hash table) with.
/// About 75% of this capacity can be used.
/// The hash table will overflow when there are more Keyimages than this,
/// and the server will have to be restarted with a larger number.
///
/// Note: At time of writing, the hash table will be allocated to use all
/// available SGX EPC memory, and then beyond that it will be allocated on
/// the heap in the untrusted side. Once the needed capacity exceeds RAM,
/// you will either get killed by OOM killer, or it will start being swapped
/// to disk by linux kernel.
#[clap(long, default_value = "1048576", env = "MC_OMAP_CAPACITY")]
pub omap_capacity: u64,
}

/// Uri for any node in the key image store system.
/// Old-style single-node servers and routers are both referred to with
/// a KeyImageClientListenUri::ClientFacing(FogLedgerUri), whereas ledger
/// store shard Uris will be KeyImageClientListenUri::Store(KeyImageStoreUri).
#[derive(Clone, Serialize)]
pub enum KeyImageClientListenUri {
/// URI used by the KeyImageStoreServer when fulfilling direct client
/// requests.
ClientFacing(FogLedgerUri),
/// URI used by the KeyImageStoreServer when fulfilling Fog Ledger Router
/// requests.
Store(KeyImageStoreUri),
}
Loading