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

wrapper: soft load state, add details to prints #135

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified apps/choo/bootstrap/choo.jam
Binary file not shown.
19 changes: 16 additions & 3 deletions apps/choo/bootstrap/kernel.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,29 @@
::
::
++ load
|= arg=versioned-state
|= old=versioned-state
^- choo-state
?+ -.arg ~& >> %no-upgrade arg
::
:: We do not use the result of the soft because
:: clamming (trap vase) overwrites the contents
:: with the bunt resulting in the honc and the build
:: artifacts being replaced with *(trap vase).
::
?~ ((soft versioned-state) old)
~& "choo: +load old state does not nest under versioned-state"
!!
?- -.old
%0
~& >> %upgrade-0-to-1
:* %1
cached-hoon.arg
cached-hoon.old
*build-cache
*parse-cache
==
::
%1
~& >> %no-upgrade
old
==
::
:: +peek: external inspect
Expand Down
2 changes: 1 addition & 1 deletion apps/choo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ pub async fn initialize_(
arbitrary: bool,
boot_cli: BootCli,
) -> Result<crown::nockapp::NockApp, Error> {
let mut nockapp = boot::setup(KERNEL_JAM, Some(boot_cli.clone()), &[], "choo")?;
boot::init_default_tracing(&boot_cli.clone());
let mut nockapp = boot::setup(KERNEL_JAM, Some(boot_cli.clone()), &[], "choo")?;
let mut slab = NounSlab::new();
let hoon_cord = Atom::from_value(&mut slab, HOON_TXT).unwrap().as_noun();
let bootstrap_poke = T(&mut slab, &[D(tas!(b"boot")), hoon_cord]);
Expand Down
15 changes: 9 additions & 6 deletions apps/hoon-deps/lib/wrapper.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$_ ^|
|_ outer-state
++ load
|~ arg=*
|~ arg=outer-state
**
++ peek
|~ arg=path
Expand All @@ -32,9 +32,9 @@
::
+$ fort
$_ ^|
|_ state=inner-state
|_ state=inner
++ load
|~ arg=inner-state
|~ arg=inner
*inner-state
++ peek
|~ arg=path
Expand All @@ -52,9 +52,12 @@
|_ outer=outer-state
+* inner-fort ~(. inner internal.outer)
++ load
|= arg=outer-state
=/ new-internal (load:inner-fort internal.arg)
..load(internal.outer new-internal)
|= old=outer-state
?+ -.old ~&("+load: invalid old state" !!)
%0
=/ new-internal (load:inner-fort internal.old)
..load(internal.outer new-internal)
==
::
++ peek
|= arg=path
Expand Down
Binary file modified apps/http-app/bootstrap/http.jam
Binary file not shown.
2 changes: 1 addition & 1 deletion apps/http-app/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ struct TestCli {
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let cli = TestCli::parse();
debug!("KERNEL_JAM len: {:?}", KERNEL_JAM.to_vec().len());
let mut http_app = boot::setup(KERNEL_JAM, Some(cli.boot.clone()), &[], "choo")?;
boot::init_default_tracing(&cli.boot.clone());
let mut http_app = boot::setup(KERNEL_JAM, Some(cli.boot.clone()), &[], "choo")?;
http_app.add_io_driver(crown::http_driver()).await;

http_app.run().await.expect("Failed to run app");
Expand Down
12 changes: 9 additions & 3 deletions apps/test-app/bootstrap/kernel.hoon
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/+ *wrapper
=>
|%
+$ versioned-state
$% test-state
==
+$ test-state [%0 val=@]
++ moat (keep test-state)
+$ cause ?(%inc %inc-exit)
Expand All @@ -18,9 +21,12 @@
:: +load: upgrade from previous state
::
++ load
|= arg=test-state
~& >> "load"
arg
|= old=test-state
~& "test-app: load"
?~ ((soft versioned-state) old)
~& "test-app: +load old state does not nest under versioned-state"
!!
old
::
:: +peek: external inspect
::
Expand Down
Binary file modified apps/test-app/bootstrap/test-ker.jam
Binary file not shown.
2 changes: 1 addition & 1 deletion apps/test-app/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ struct TestCli {
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let cli = TestCli::parse();
debug!("KERNEL_JAM len: {:?}", KERNEL_JAM.to_vec().len());
let mut test_app = boot::setup(KERNEL_JAM, Some(cli.boot.clone()), &[], "test")?;
boot::init_default_tracing(&cli.boot.clone());
let mut test_app = boot::setup(KERNEL_JAM, Some(cli.boot.clone()), &[], "test")?;
let poke = if cli.exit {
D(tas!(b"inc-exit"))
} else {
Expand Down
17 changes: 10 additions & 7 deletions crown/src/kernel/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,6 @@ impl Serf {
.as_ref()
.map_or_else(|| SNAPSHOT_VERSION, |snapshot| snapshot.version);

let mut hasher = Hasher::new();
hasher.update(kernel_bytes);
let mut ker_hash = hasher.finalize();

let mut arvo = {
let kernel_trap = Noun::cue_bytes_slice(&mut context.stack, kernel_bytes)
.expect("invalid kernel jam");
Expand All @@ -557,12 +553,19 @@ impl Serf {
arvo
};

let mut hasher = Hasher::new();
hasher.update(kernel_bytes);
let ker_hash = hasher.finalize();

if let Some(checkpoint) = checkpoint {
if ker_hash != checkpoint.ker_hash {
info!("Kernel hash mismatch, upgrading kernel");
ker_hash = checkpoint.ker_hash;
info!(
"Kernel hash mismatch, upgrading kernel: {:?} -> {:?}",
checkpoint.ker_hash, ker_hash
);
}
arvo = Serf::load(&mut context, arvo, checkpoint.ker_state).unwrap();
arvo =
Serf::load(&mut context, arvo, checkpoint.ker_state).expect("Failed to load state");
}

let mut serf = Self {
Expand Down
4 changes: 3 additions & 1 deletion crown/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ pub use drivers::exit::exit as exit_driver;
pub use drivers::file::file as file_driver;
pub use drivers::http::http as http_driver;
pub use drivers::markdown::markdown as markdown_driver;
pub use drivers::npc::{npc_client as npc_client_driver, npc_listener as npc_listener_driver};
pub use drivers::npc::{
npc_client as npc_client_driver, npc_listener as npc_listener_driver, NpcWire,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expose NpcWire for outside use

};
pub use drivers::one_punch::one_punch_man as one_punch_driver;
pub use drivers::timer::make_timer_driver as timer_driver;

Expand Down
Loading