-
Notifications
You must be signed in to change notification settings - Fork 113
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
Invoke Testing extension through ExtensionHandle
#2660
Invoke Testing extension through ExtensionHandle
#2660
Conversation
oak_functions/loader/src/lookup.rs
Outdated
@@ -109,7 +109,7 @@ where | |||
Ok(extension_result) | |||
} | |||
|
|||
fn get_metadata(&self) -> (String, wasmi::Signature) { | |||
fn get_metadata(&self) -> (String, wasmi::Signature, ExtensionHandle) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be worth defining a struct rather than using a tuple with 3 elements to improve clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, that's true! Instead of adding a struct, I added a new get_handle
function to the trait. I believe we'll remove get_metadata
eventually, so that makes more sense.
oak_functions/loader/src/server.rs
Outdated
let handle: ExtensionHandle = | ||
ExtensionHandle::from_i32(handle).expect("Fail to parse handle."); | ||
|
||
// Quick solution following impelementation of invoking an extension in `invoke_index`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am unsure what the intention of this comment is. Does it mean this is a temporary solution that will be replaced with something better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, updated comment. Thank you!
// Then we get the extension which has the given handle by looking at the values of the | ||
// extension_indices. | ||
let extension = extensions_indices | ||
.iter_mut() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is a mutable iterator needed? It seems weird that this requires taking the extension indicices and then putting them back when nothing seems to be actually mutated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because extension.invoke(self, ...)
in line 369 needs a mutable WasmState
and extension_indices
are part of WasmState
.
With #2664 we can simplify this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. I guess part of the weirdness it that an Option
is used rather than a RefCell
to implement interior mutability, but this is preexisting so can be fixed later as part of #2664 and other refactoring.
oak_functions/loader/src/lookup.rs
Outdated
@@ -109,7 +109,7 @@ where | |||
Ok(extension_result) | |||
} | |||
|
|||
fn get_metadata(&self) -> (String, wasmi::Signature) { | |||
fn get_metadata(&self) -> (String, wasmi::Signature, ExtensionHandle) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
oak_functions/loader/src/testing.rs
Outdated
let request_len: AbiPointerOffset = args.nth_checked(1)?; | ||
let response_ptr_ptr: AbiPointer = args.nth_checked(2)?; | ||
let response_len_ptr: AbiPointer = args.nth_checked(3)?; | ||
// We still read the args after the ExtensionHandle at position 0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add let _handle = args.nth_checked(0);
for consistency and future proof.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
oak_functions/loader/src/lookup.rs
Outdated
@@ -109,7 +109,7 @@ where | |||
Ok(extension_result) | |||
} | |||
|
|||
fn get_metadata(&self) -> (String, wasmi::Signature) { | |||
fn get_metadata(&self) -> (String, wasmi::Signature, ExtensionHandle) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, that's true! Instead of adding a struct, I added a new get_handle
function to the trait. I believe we'll remove get_metadata
eventually, so that makes more sense.
oak_functions/loader/src/server.rs
Outdated
let handle: ExtensionHandle = | ||
ExtensionHandle::from_i32(handle).expect("Fail to parse handle."); | ||
|
||
// Quick solution following impelementation of invoking an extension in `invoke_index`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, updated comment. Thank you!
// Then we get the extension which has the given handle by looking at the values of the | ||
// extension_indices. | ||
let extension = extensions_indices | ||
.iter_mut() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because extension.invoke(self, ...)
in line 369 needs a mutable WasmState
and extension_indices
are part of WasmState
.
With #2664 we can simplify this.
oak_functions/loader/src/testing.rs
Outdated
let request_len: AbiPointerOffset = args.nth_checked(1)?; | ||
let response_ptr_ptr: AbiPointer = args.nth_checked(2)?; | ||
let response_len_ptr: AbiPointer = args.nth_checked(3)?; | ||
// We still read the args after the ExtensionHandle at position 0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
oak_functions/loader/src/server.rs
Outdated
let handle: ExtensionHandle = | ||
ExtensionHandle::from_i32(handle).expect("Fail to parse handle."); | ||
|
||
// TODO(#2664) Quick solution following impelementation of invoking an extension in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think a :
is required after the TODO().
// Then we get the extension which has the given handle by looking at the values of the | ||
// extension_indices. | ||
let extension = extensions_indices | ||
.iter_mut() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. I guess part of the weirdness it that an Option
is used rather than a RefCell
to implement interior mutability, but this is preexisting so can be fixed later as part of #2664 and other refactoring.
455299c
to
d294575
Compare
Reproducibility Index:
Reproducibility Index diff: diff --git a/reproducibility_index b/reproducibility_index
index f6358ab..a7663eb 100644
--- a/reproducibility_index
+++ b/reproducibility_index
@@ -1,2 +1,2 @@
-96fb21e31e8cf9b36cfa3a60d9755b30b0032f4e232e322341b9f731879c6471 ./target/x86_64-unknown-linux-musl/release/oak_functions_loader_base
-b9fd6e9df8799c1d2465bcfcaecb4c6e5df266e1488700135112f9080be138aa ./target/x86_64-unknown-linux-musl/release/oak_functions_loader_unsafe
+d4b7228fb9f2bdb5a85593815a44be6ac8ab9e745c8352869a8bd7e815b18a92 ./target/x86_64-unknown-linux-musl/release/oak_functions_loader_base
+969ca18c94fbd6e9b852ede7819a893194228316b49d09dc315e02a35cb88d93 ./target/x86_64-unknown-linux-musl/release/oak_functions_loader_unsafe
|
ExtensionHandle
andget_handle()
for every extension