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

runtime/src/enclave_rpc: Simplify RPC context #5555

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

peternose
Copy link
Contributor

@peternose peternose commented Feb 13, 2024

Trying to remove cloning of identity, consensus verifier and other data for every RPC request and just pass all these parameters in a constructor. The final code should look like this:

// Init all components.
let secrets = Secrets::new(identity, consensus_verifier, ...);
let churp = Churp::new(identity, consensus_verifier, ...);

// Register methods.
rpc_dispatcher.add_methods(secrets.methods());
rpc_dispatcher.add_methods(churp.methods());
fn secure_rpc_method(&self, ctx: &RpcContext, req: &Request) ->  Result<Response>
fn insecure_rpc_method(&self, req: &Request) ->  Result<Response>
fn local_rpc_method(&self, req: &Request) ->  Result<Response>

Open for suggestions and improvements.

Thinking out loud: In the future, we could also consider refactoring runtime startup via start_runtime, splitting it into two parts: initialization and start. The first method could return a new struct Runtime, which would provide access to identity, consensus verifier, RPC dispatcher, protocol, etc., to other methods, such as the key manager initialization method. This approach
could eliminate the need for PreInitState and PostInitState, and maybe allow us to have non-static variables in the key manager.

Copy link

netlify bot commented Feb 13, 2024

Deploy Preview for oasisprotocol-oasis-core canceled.

Name Link
🔨 Latest commit 91de8b4
🔍 Latest deploy log https://app.netlify.com/sites/oasisprotocol-oasis-core/deploys/65cb5cc3d406a000077dabc1

@peternose peternose marked this pull request as ready for review February 13, 2024 11:47
Copy link

codecov bot commented Feb 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (00e2494) 66.26% compared to head (0fcf9c9) 66.29%.
Report is 1 commits behind head on master.

❗ Current head 0fcf9c9 differs from pull request most recent head 91de8b4. Consider uploading reports for the commit 91de8b4 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5555      +/-   ##
==========================================
+ Coverage   66.26%   66.29%   +0.02%     
==========================================
  Files         546      546              
  Lines       56861    56861              
==========================================
+ Hits        37679    37694      +15     
+ Misses      14740    14738       -2     
+ Partials     4442     4429      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

The RPC context now contains only essential data for secure RPC methods.
Identity, consensus verifier, and storage have been removed and are now
available to methods responsible for master and ephemeral secrets after
initialization.
@peternose peternose force-pushed the peternose/internal/enclave-rpc-ctx branch from 0fcf9c9 to 91de8b4 Compare February 13, 2024 12:12
@peternose peternose enabled auto-merge February 13, 2024 12:51
@peternose peternose merged commit c9ca776 into master Feb 13, 2024
3 of 5 checks passed
@peternose peternose deleted the peternose/internal/enclave-rpc-ctx branch February 13, 2024 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants