Conversation
murerfel
left a comment
There was a problem hiding this comment.
Comments to explain the changes
| #![cfg_attr(not(feature = "std"), no_std)] | ||
|
|
||
| #[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; | ||
|
|
||
| use codec::{Decode, Encode}; | ||
|
|
||
| #[derive(Encode, Decode)] | ||
| pub enum EnclaveMetric { | ||
| SetSidechainBlockHeight(u64), | ||
| TopPoolSizeSet(u64), | ||
| TopPoolSizeIncrement, | ||
| TopPoolSizeDecrement, | ||
| } |
There was a problem hiding this comment.
Just a small crate for the data model to hold metrics information that can be passed from the enclave -> untrusted service.
| pub static GLOBAL_RPC_AUTHOR_COMPONENT: ComponentContainer<EnclaveRpcAuthor> = | ||
| ComponentContainer::new(); |
There was a problem hiding this comment.
Initializing this component was done in the sidechain crate until now - but since we have to pass in the o-call API now too, I decided to move it here into the enclave-runtime with the rest of all the global components.
dea9b22 to
6ecccd0
Compare
do not use mut api reference to modify signer. create a new api for new signer.
6ecccd0 to
dc5d3b1
Compare
without the flag, the metrics server does not run
clangenb
left a comment
There was a problem hiding this comment.
Looks very cool. I only have one question.
| api.signer = signer_orig; | ||
| Ok(()) | ||
| } | ||
|
|
There was a problem hiding this comment.
Nice, main.rs is constantly shrinking.
| let metrics_route = warp::path!("metrics").and_then(move || { | ||
| let handler_clone = metrics_handler.clone(); | ||
| async move { handler_clone.handle_metrics().await } | ||
| }); |
There was a problem hiding this comment.
I have problems understanding this code. Why do we need the nested move?
There was a problem hiding this comment.
This took me 3 hours to figure out - and I still cannot say I understand it fully myself 🙈
First we create a lambda, into which we move the handler, that is the easy part to understand. But then every request needs its own instance of a request handler, and this is the only way I was able to make that work (it implements Fn and not only FnOnce, which would be the case if you didn't have the clone() like on line 52.
The second async move is required to move the handler clone into the async block, without the move it cannot be guaranteed that the handler clone lives long enough for the future to complete.
There was a problem hiding this comment.
Ok, interesting. Well, to me it seems like you did understand the problematic here. 😄
haerdib
left a comment
There was a problem hiding this comment.
Looks good, some small comments :)
Integrate the prometheus service client as described in #611
warphttp server to serve the metrics as a http resource (/metrics) on a configurable portCloses #611