Skip to content

Commit 0b11c0a

Browse files
committed
remove DevolvableSandbox trait
Signed-off-by: Jorge Prendes <[email protected]>
1 parent 0b21dea commit 0b11c0a

File tree

3 files changed

+9
-38
lines changed

3 files changed

+9
-38
lines changed

src/hyperlight_host/src/sandbox/initialized_multi_use.rs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ use crate::hypervisor::{Hypervisor, InterruptHandle};
3535
use crate::mem::ptr::RawPtr;
3636
use crate::mem::shared_mem::HostSharedMemory;
3737
use crate::metrics::maybe_time_and_emit_guest_call;
38-
use crate::sandbox_state::sandbox::{DevolvableSandbox, EvolvableSandbox, Sandbox};
39-
use crate::sandbox_state::transition::{MultiUseContextCallback, Noop};
38+
use crate::sandbox_state::sandbox::{EvolvableSandbox, Sandbox};
39+
use crate::sandbox_state::transition::MultiUseContextCallback;
4040
use crate::{HyperlightError, Result};
4141

4242
/// A sandbox that supports being used Multiple times.
@@ -279,25 +279,6 @@ impl std::fmt::Debug for MultiUseSandbox {
279279
}
280280
}
281281

282-
impl DevolvableSandbox<MultiUseSandbox, MultiUseSandbox, Noop<MultiUseSandbox, MultiUseSandbox>>
283-
for MultiUseSandbox
284-
{
285-
/// Consume `self` and move it back to a `MultiUseSandbox` with previous state.
286-
///
287-
/// The purpose of this function is to allow multiple states to be associated with a single MultiUseSandbox.
288-
///
289-
/// An implementation such as HyperlightJs or HyperlightWasm can use this to call guest functions to load JS or WASM code and then evolve the sandbox causing state to be captured.
290-
/// The new MultiUseSandbox can then be used to call guest functions to execute the loaded code.
291-
/// The devolve can be used to return the MultiUseSandbox to the state before the code was loaded. Thus avoiding initialisation overhead
292-
#[instrument(err(Debug), skip_all, parent = Span::current(), level = "Trace")]
293-
fn devolve(mut self, _tsn: Noop<MultiUseSandbox, MultiUseSandbox>) -> Result<MultiUseSandbox> {
294-
self.mem_mgr
295-
.unwrap_mgr_mut()
296-
.pop_and_restore_state_from_snapshot()?;
297-
Ok(self)
298-
}
299-
}
300-
301282
impl<'a, F>
302283
EvolvableSandbox<
303284
MultiUseSandbox,

src/hyperlight_host/src/sandbox_state/sandbox.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ use crate::{Result, new_error};
3030
/// into a next state. That "next state" may in turn know how to roll back
3131
/// to the root node.
3232
///
33-
/// These transitions are expressed as `EvolvableSandbox` and
34-
/// `DevolvableSandbox` implementations any `Sandbox` implementation can
35-
/// opt into.
33+
/// These transitions are expressed as `EvolvableSandbox` implementations
34+
/// any `Sandbox` implementation can opt into.
3635
pub trait Sandbox: Sized + Debug {
3736
/// Check to ensure the current stack cookie matches the one that
3837
/// was selected when the stack was constructed.
@@ -70,11 +69,3 @@ pub trait EvolvableSandbox<Cur: Sandbox, Next: Sandbox, T: TransitionMetadata<Cu
7069
/// Evolve `Self` to `Next` providing Metadata.
7170
fn evolve(self, tsn: T) -> Result<Next>;
7271
}
73-
74-
/// A `Sandbox` that knows how to roll back to a "previous" `Sandbox`
75-
pub trait DevolvableSandbox<Cur: Sandbox, Prev: Sandbox, T: TransitionMetadata<Cur, Prev>>:
76-
Sandbox
77-
{
78-
/// Devolve `Self` to `Prev` providing Metadata.
79-
fn devolve(self, tsn: T) -> Result<Prev>;
80-
}

src/hyperlight_host/src/sandbox_state/transition.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ use super::sandbox::Sandbox;
2222
use crate::Result;
2323
use crate::func::call_ctx::MultiUseGuestCallContext;
2424

25-
/// Metadata about an evolution or devolution. Any `Sandbox` implementation
26-
/// that also implements `EvolvableSandbox` or `DevolvableSandbox`
27-
/// can decide the following things in a type-safe way:
25+
/// Metadata about an evolution. Any `Sandbox` implementation
26+
/// that also implements `EvolvableSandbox` can decide the following
27+
/// things in a type-safe way:
2828
///
2929
/// 1. That transition is possible
3030
/// 2. That transition requires a specific kind of metadata
@@ -40,8 +40,7 @@ use crate::func::call_ctx::MultiUseGuestCallContext;
4040
/// ```
4141
///
4242
/// ...then you can define a metadata-free evolve transition between
43-
/// `MySandbox1` and `MySandbox2`, and a devolve transition that requires
44-
/// a callback between `MySandbox2` and `MySandbox` as follows:
43+
/// `MySandbox1` and `MySandbox2` as follows:
4544
///
4645
/// ```ignore
4746
/// impl EvolvableSandbox<
@@ -65,7 +64,7 @@ pub trait TransitionMetadata<Cur: Sandbox, Next: Sandbox> {}
6564

6665
/// Transition metadata that contains and does nothing. `Noop` is a
6766
/// placeholder when you want to implement an `EvolvableSandbox`
68-
/// or `DevolvableSandbox` that needs no additional metadata to succeed.
67+
/// that needs no additional metadata to succeed.
6968
///
7069
/// Construct one of these by using the `default()` method.
7170
pub struct Noop<Cur: Sandbox, Next: Sandbox> {

0 commit comments

Comments
 (0)