-
Notifications
You must be signed in to change notification settings - Fork 45
Make mu-ra and untrusted worker url queriable #595
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
Merged
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
c132ad7
extract request_keys() to separate file
haerdib 9583224
remove providr input, add dummy getter function
haerdib fbc5b36
add node_api worker_for_shard call
haerdib b96a829
fix error message
haerdib 52b7094
add primitives cache and rpc call
haerdib 0c87e08
fix tests
haerdib a5c043d
add primitives-cache to workspace
haerdib 62937ce
fix unit tests
haerdib 0d5f61d
remove obsolete .yml provider from request-keys cmd
haerdib ddf2868
remove provider_addr from CI py scripts
haerdib 8ce4a90
fix reported worker address
haerdib b0f0798
improve usability of rpc-client
haerdib c1b8307
make it work
haerdib 189bf5f
fix rebase error
haerdib 84dc22b
add some delay
haerdib b6b3990
update local setup script
haerdib 8096a96
remove ugly async worker url, replace with enclave getter function
haerdib 7f40e56
some steps towards a working exmaple..
haerdib 349f1fb
add peer_updater
haerdib ecd32d8
fix unit test
haerdib 9d29823
fix some test clippy warnings
haerdib 521c668
fix function name
haerdib 001b467
fix client mu ra url
haerdib 1071f5e
fix comment
haerdib fc84695
fix comment
haerdib 8ca3df9
rename state_sync to appropriate request keys
haerdib b4484ae
fix comments and add missing _size to untrusted_worker_addr
haerdib cd21720
update cargo.lock after rebase
haerdib 376d99e
fix typos
haerdib ee5d8d0
rename store_peers to set_peers
haerdib 723a72c
fix comment
haerdib a842de9
move set_primitives to primitves cache repository
haerdib a94987c
return read guard instead of primittves clone
haerdib 0966f1e
rename config worker_rpc_port to trusted_worker_port
haerdib 8afa53f
remove obsolete Error enum from request_keys.rs
haerdib 547638a
fix unit tests
haerdib 8ac6b2e
move thread spawning back into watch fn
haerdib cd2e7a9
rename worker-rpc-port to trusted-worker-port
haerdib 44082be
readd external worker address
haerdib 396d768
fix unit tests
haerdib 0a0d501
fix unit test
haerdib 09dc4ed
add external addresses, optional port input and unit tests
haerdib 7200956
update test names
haerdib 89ba374
[cli.yml] update shorts
haerdib 16c5f21
fix local setup configs
haerdib 8844c29
change untrusted worker port to w
haerdib File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,34 @@ | ||
| [package] | ||
| name = "itp-primitives-cache" | ||
| version = "0.8.0" | ||
| authors = ["Integritee AG <hello@integritee.network>"] | ||
| edition = "2018" | ||
| resolver = "2" | ||
|
|
||
|
|
||
| [features] | ||
| default = ["std"] | ||
| std = [ | ||
| "log/std", | ||
| "thiserror", | ||
| ] | ||
| sgx = [ | ||
| "sgx_tstd", | ||
| "thiserror_sgx", | ||
| ] | ||
|
|
||
| [dependencies] | ||
| # sgx dependencies | ||
| sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } | ||
|
|
||
| # local dependencies | ||
|
|
||
| # sgx enabled external libraries | ||
| thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } | ||
|
|
||
| # std compatible external libraries (make sure these versions match with the sgx-enabled ones above) | ||
| thiserror = { version = "1.0", optional = true } | ||
|
|
||
| # no-std dependencies | ||
| log = { version = "0.4", default-features = false } | ||
| lazy_static = { version = "1.1.0", features = ["spin_no_std"] } |
This file contains hidden or 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,31 @@ | ||
| /* | ||
| Copyright 2021 Integritee AG and Supercomputing Systems AG | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
|
|
||
| */ | ||
|
|
||
| #[cfg(all(not(feature = "std"), feature = "sgx"))] | ||
| use crate::sgx_reexport_prelude::*; | ||
|
|
||
| use std::boxed::Box; | ||
|
|
||
| pub type Result<T> = core::result::Result<T, Error>; | ||
|
|
||
| #[derive(Debug, thiserror::Error)] | ||
| pub enum Error { | ||
| #[error("Primitives lock is poisoned")] | ||
| LockPoisoning, | ||
| #[error(transparent)] | ||
| Other(#[from] Box<dyn std::error::Error + Sync + Send + 'static>), | ||
| } |
This file contains hidden or 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,120 @@ | ||
| /* | ||
| Copyright 2021 Integritee AG and Supercomputing Systems AG | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
|
|
||
| */ | ||
|
|
||
| //! Stores all primitives of the enclave that do need to be accessed often, but are | ||
| //! not be frequently mutated, such as keys and server urls. | ||
| //! | ||
| //! TODO: For now only the mu-ra server and untrusted wokrer url is stored here. Keys and such could also be stored here. | ||
|
|
||
| #![cfg_attr(not(feature = "std"), no_std)] | ||
| #![feature(assert_matches)] | ||
|
|
||
| #[cfg(all(feature = "std", feature = "sgx"))] | ||
| compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); | ||
|
|
||
| #[cfg(all(not(feature = "std"), feature = "sgx"))] | ||
| extern crate sgx_tstd as std; | ||
|
|
||
| // Re-export module to properly feature gate sgx and regular std environment. | ||
| #[cfg(all(not(feature = "std"), feature = "sgx"))] | ||
| pub mod sgx_reexport_prelude { | ||
| pub use thiserror_sgx as thiserror; | ||
| } | ||
|
|
||
| #[cfg(feature = "std")] | ||
| use std::sync::RwLockReadGuard; | ||
| #[cfg(feature = "std")] | ||
| use std::sync::RwLockWriteGuard; | ||
|
|
||
| #[cfg(all(not(feature = "std"), feature = "sgx"))] | ||
| use std::sync::SgxRwLockReadGuard as RwLockReadGuard; | ||
| #[cfg(all(not(feature = "std"), feature = "sgx"))] | ||
| use std::sync::SgxRwLockWriteGuard as RwLockWriteGuard; | ||
|
|
||
| use crate::error::Result; | ||
| use lazy_static::lazy_static; | ||
| use std::{ | ||
| string::{String, ToString}, | ||
| sync::Arc, | ||
| }; | ||
|
|
||
| pub use primitives_cache::PrimitivesCache; | ||
|
|
||
| lazy_static! { | ||
| /// Global instance of the primitves cache. | ||
| /// | ||
| /// Concurrent access is managed internally, using RW locks. | ||
| pub static ref GLOBAL_PRIMITIVES_CACHE: Arc<PrimitivesCache> = Default::default(); | ||
| } | ||
|
|
||
| pub mod error; | ||
| pub mod primitives_cache; | ||
|
|
||
| #[derive(Default, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] | ||
| pub struct Primitives { | ||
| mu_ra_url: String, | ||
| untrusted_worker_url: String, | ||
| } | ||
|
|
||
| impl Primitives { | ||
| pub fn new(mu_ra_url: &str, untrusted_worker_url: &str) -> Primitives { | ||
| Primitives { | ||
| mu_ra_url: mu_ra_url.to_string(), | ||
| untrusted_worker_url: untrusted_worker_url.to_string(), | ||
| } | ||
| } | ||
|
|
||
| pub fn mu_ra_url(&self) -> &str { | ||
| &self.mu_ra_url | ||
| } | ||
|
|
||
| pub fn untrusted_worker_url(&self) -> &str { | ||
| &self.untrusted_worker_url | ||
| } | ||
| } | ||
|
|
||
| /// Trait to mutate the primitives. | ||
| /// | ||
| /// Used in a combination of loading a lock and then writing the updated | ||
| /// value back, returning the lock again. | ||
| pub trait MutatePrimitives { | ||
| fn load_for_mutation(&self) -> Result<RwLockWriteGuard<'_, Primitives>>; | ||
| } | ||
|
|
||
| /// Trait to get the primitives. | ||
| pub trait GetPrimitives { | ||
| /// Returns a clone of the full Primitives struct. | ||
| fn get_primitives(&self) -> Result<RwLockReadGuard<Primitives>>; | ||
|
|
||
| fn get_mu_ra_url(&self) -> Result<String>; | ||
|
|
||
| fn get_untrusted_worker_url(&self) -> Result<String>; | ||
| } | ||
|
|
||
| // Helper function to set primitives of a given cache. | ||
| pub fn set_primitives<E: MutatePrimitives>( | ||
| cache: &E, | ||
| mu_ra_url: &str, | ||
| untrusted_worker_url: &str, | ||
| ) -> Result<()> { | ||
| let primitives = Primitives::new(mu_ra_url, untrusted_worker_url); | ||
| let mut rw_lock = cache.load_for_mutation()?; | ||
|
|
||
| *rw_lock = primitives; | ||
|
|
||
| Ok(()) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.