From 679b38138db016fbf84e5d7e1347e70ae8b19c9a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 23 Aug 2022 10:37:01 -0400 Subject: [PATCH] ames: prevent larval stage from possibly clobbering adult state --- pkg/arvo/sys/vane/ames.hoon | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 80141f2ef5..a218d89de4 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -854,6 +854,7 @@ ++ take ^take -- |% + ++ larval-core . :: +call: handle request $task :: ++ call @@ -866,7 +867,7 @@ ~|(%ames-larval-call-dud (mean tang.u.dud)) :: before processing events, make sure we have state loaded :: - =^ molt-moves adult-gate molt + =^ molt-moves larval-core molt :: ?: &(!=(~ unix-duct.ames-state.adult-gate) =(~ queued-events)) =^ moves adult-gate (call:adult-core duct dud task) @@ -900,7 +901,7 @@ ?^ dud ~|(%ames-larval-take-dud (mean tang.u.dud)) :: - =^ molt-moves adult-gate molt + =^ molt-moves larval-core molt :: ?: &(!=(~ unix-duct.ames-state.adult-gate) =(~ queued-events)) =^ moves adult-gate (take:adult-core wire duct dud sign) @@ -908,17 +909,9 @@ [(weld molt-moves moves) adult-gate] :: enqueue event if not a larval drainage timer :: - =? queued-events !=(/larva wire) - (~(put to queued-events) %take wire duct sign) - :: start drainage timer if have regressed from adult ames - :: - ?: ?& !=(/larva wire) - ?=(^ cached-state) - == - [[duct %pass /larva %b %wait now]~ larval-gate] - :: XX what to do with errors? - :: - ?. =(/larva wire) [~ larval-gate] + ?. =(/larva wire) + =. queued-events (~(put to queued-events) %take wire duct sign) + [~ larval-gate] :: larval event drainage timer; pop and process a queued event :: ?. ?=([%behn %wake *] sign) @@ -1058,8 +1051,8 @@ :: +molt: re-evolve to adult-ames :: ++ molt - ^- (quip move _adult-gate) - ?~ cached-state [~ adult-gate] + ^- (quip move _larval-core) + ?~ cached-state [~ larval-core] ~> %slog.0^leaf/"ames: molt" =? u.cached-state ?=(%5 -.u.cached-state) 6+(state-5-to-6:load:adult-core +.u.cached-state) @@ -1072,7 +1065,7 @@ 8+(state-7-to-8:load:adult-core +.u.cached-state) ?> ?=(%8 -.u.cached-state) =. ames-state.adult-gate +.u.cached-state - [moz adult-gate] + [moz larval-core(cached-state ~)] -- :: adult ames, after metamorphosis from larva ::