From e1088e1e55b2374bb2c3c32d6cb27ad7e1c67897 Mon Sep 17 00:00:00 2001 From: Sidnym Ladrut Date: Mon, 8 Jan 2024 18:52:06 +0000 Subject: [PATCH 1/3] patch many minor issues with 'vitals/connection-check.hoon' thread * skip sponsor checks for galaxies (avoids a crash in /app/vitals/hoon) * mark peers unknown to %ames as %dead (avoids a crash in /ax/peers/...) * change thread input from @p to (unit @p) (allow calling from dojo) --- desk/app/vitals.hoon | 4 ++-- desk/ted/vitals/connection-check.hoon | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/desk/app/vitals.hoon b/desk/app/vitals.hoon index c536cfbf..42ef1f65 100644 --- a/desk/app/vitals.hoon +++ b/desk/app/vitals.hoon @@ -138,7 +138,7 @@ %landscape %vitals-connection-check %noun - !>(ship) + !>((some ship)) == ?: ?=(%pending -.status.u.stat) cor @@ -153,7 +153,7 @@ %landscape %vitals-connection-check %noun - !>(ship) + !>((some ship)) == :: :: public pokes diff --git a/desk/ted/vitals/connection-check.hoon b/desk/ted/vitals/connection-check.hoon index 3705f717..e856cff3 100644 --- a/desk/ted/vitals/connection-check.hoon +++ b/desk/ted/vitals/connection-check.hoon @@ -10,7 +10,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<(target=ship arg) +=+ !<([~ target=ship] arg) ;< our=@p bind:m get-our:io |^ :: early exit; check if we have live path to target @@ -33,7 +33,13 @@ :: set pending to %trying-local ;< ~ bind:m (update-status [%trying-local ~]) :: check if we can contact our own galaxy - ;< gqos=qos:ames bind:m (scry:io qos:ames ~[%gx %vitals %galaxy %vitals-qos]) + ;< gqos=qos:ames + bind:m + =/ mm (strand ,qos:ames) + ^- form:mm + ?: ?=(%czar (clan:title our)) + (pure:mm [%live *@da]) + (scry:io qos:ames ~[%gx %vitals %galaxy %vitals-qos]) ?. ?=(%live -.gqos) (post-result [%no-our-galaxy last-contact.gqos]) :: set pending to %trying-target @@ -104,12 +110,15 @@ ^- update:vitals [target now %pending pending] ++ get-qos - |= =ship + |= peer=ship =/ m (strand ,qos:ames) ^- form:m - ;< state=ship-state:ames - bind:m - (scry:io ship-state:ames ~[%ax %$ %peers (scot %p ship)]) + ;< peers=(map ship ?(%alien %known)) bind:m + (scry:io (map ship ?(%alien %known)) ~[%ax %$ %peers]) + ?. (~(has by peers) peer) + (pure:m [%dead *@da]) + ;< state=ship-state:ames bind:m + (scry:io ship-state:ames ~[%ax %$ %peers (scot %p peer)]) (pure:m (simplify-qos:lib-vitals state)) ++ galaxy-down |= galaxy=ship From b57ce3a7d9b753881af6816f1c09d906611f98c7 Mon Sep 17 00:00:00 2001 From: Sidnym Ladrut Date: Wed, 17 Jan 2024 20:37:18 +0000 Subject: [PATCH 2/3] update vitals infra to return most positive qos instead of crashing in edge cases --- desk/app/vitals.hoon | 7 +------ desk/lib/vitals.hoon | 9 +++++++++ desk/ted/vitals/connection-check.hoon | 16 ++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/desk/app/vitals.hoon b/desk/app/vitals.hoon index 42ef1f65..8d164937 100644 --- a/desk/app/vitals.hoon +++ b/desk/app/vitals.hoon @@ -160,10 +160,7 @@ :: %ship =+ !<(=ship vase) - ?< =(our ship) - ?< =(~ (find ~[our] (saxo:title our now ship))) - ?. ?=([%live *] (scry-qos:lib our now ship)) - !! + ?> ?=([%live *] (scry-qos:lib our now ship)) cor == ++ watch @@ -187,14 +184,12 @@ ?+ path [~ ~] :: [%x %sponsor ~] - ?< ?=(%czar (clan:title our)) %- some %- some :- %vitals-qos !> (scry-qos:lib our now (sein:title our now our)) :: [%x %galaxy ~] - ?< ?=(%czar (clan:title our)) %- some %- some :- %vitals-qos diff --git a/desk/lib/vitals.hoon b/desk/lib/vitals.hoon index d17d2ba9..da7489c8 100644 --- a/desk/lib/vitals.hoon +++ b/desk/lib/vitals.hoon @@ -11,6 +11,15 @@ ++ scry-qos |= [=ship =time peer=ship] ^- qos:ames + :: a ship is not guaranteed by %ames to know itself, so we fake it + ?: =(ship peer) + [%live time] + :: .^(* %ax /=//=/peers/[peer]) crashes if the peer is unknown, so we + :: check the source map beforehand and fake an %unborn if we can see + :: a crash coming + =/ peers .^((map ^ship ?(%alien %known)) ~[%ax %$ %peers]) + ?. (~(has by peers) peer) + [%unborn time] %- simplify-qos .^ ship-state:ames %ax diff --git a/desk/ted/vitals/connection-check.hoon b/desk/ted/vitals/connection-check.hoon index e856cff3..b1e25972 100644 --- a/desk/ted/vitals/connection-check.hoon +++ b/desk/ted/vitals/connection-check.hoon @@ -12,9 +12,9 @@ ^- form:m =+ !<([~ target=ship] arg) ;< our=@p bind:m get-our:io +;< now=@da bind:m get-time:io |^ :: early exit; check if we have live path to target - ;< now=@da bind:m get-time:io ;< tqos=qos:ames bind:m (get-qos target) ?: ?& ?=(%live -.tqos) (gth last-contact.tqos (sub now info-timeout:vitals)) @@ -33,13 +33,7 @@ :: set pending to %trying-local ;< ~ bind:m (update-status [%trying-local ~]) :: check if we can contact our own galaxy - ;< gqos=qos:ames - bind:m - =/ mm (strand ,qos:ames) - ^- form:mm - ?: ?=(%czar (clan:title our)) - (pure:mm [%live *@da]) - (scry:io qos:ames ~[%gx %vitals %galaxy %vitals-qos]) + ;< gqos=qos:ames bind:m (scry:io qos:ames ~[%gx %vitals %galaxy %vitals-qos]) ?. ?=(%live -.gqos) (post-result [%no-our-galaxy last-contact.gqos]) :: set pending to %trying-target @@ -102,21 +96,23 @@ |= =pending:vitals =/ m (strand ,~) ^- form:m - ;< now=@da bind:m get-time:io %+ poke-our:io %vitals :- %update-status !> ^- update:vitals [target now %pending pending] +:: thread version of +scry-qos in /=landscape=/lib/vitals/hoon ++ get-qos |= peer=ship =/ m (strand ,qos:ames) ^- form:m + ?: =(our peer) + (pure:m [%live now]) ;< peers=(map ship ?(%alien %known)) bind:m (scry:io (map ship ?(%alien %known)) ~[%ax %$ %peers]) ?. (~(has by peers) peer) - (pure:m [%dead *@da]) + (pure:m [%unborn now]) ;< state=ship-state:ames bind:m (scry:io ship-state:ames ~[%ax %$ %peers (scot %p peer)]) (pure:m (simplify-qos:lib-vitals state)) From cc3384c4221bc95fc57301cadfe2036ff29b5623 Mon Sep 17 00:00:00 2001 From: Sidnym Ladrut Date: Tue, 23 Jan 2024 02:55:35 +0000 Subject: [PATCH 3/3] improve time accuracy of vitals thread reports; fix bug in /lib/vitals/hoon scry path --- desk/lib/vitals.hoon | 17 +++++------------ desk/ted/vitals/connection-check.hoon | 4 +++- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/desk/lib/vitals.hoon b/desk/lib/vitals.hoon index da7489c8..8e1d916e 100644 --- a/desk/lib/vitals.hoon +++ b/desk/lib/vitals.hoon @@ -14,20 +14,13 @@ :: a ship is not guaranteed by %ames to know itself, so we fake it ?: =(ship peer) [%live time] - :: .^(* %ax /=//=/peers/[peer]) crashes if the peer is unknown, so we + :: .^(* /ax/=//=/peers/[peer]) crashes if the peer is unknown, so we :: check the source map beforehand and fake an %unborn if we can see :: a crash coming - =/ peers .^((map ^ship ?(%alien %known)) ~[%ax %$ %peers]) + =/ ames-peers=path /ax/(scot %p ship)//(scot %da time)/peers + =/ peers .^((map ^ship ?(%alien %known)) ames-peers) ?. (~(has by peers) peer) [%unborn time] - %- simplify-qos - .^ ship-state:ames - %ax - (scot %p ship) - %$ - (scot %da time) - %peers - (scot %p peer) - ~ - == + =/ pqos .^(ship-state:ames (snoc ames-peers (scot %p peer))) + (simplify-qos pqos) -- diff --git a/desk/ted/vitals/connection-check.hoon b/desk/ted/vitals/connection-check.hoon index b1e25972..7550c644 100644 --- a/desk/ted/vitals/connection-check.hoon +++ b/desk/ted/vitals/connection-check.hoon @@ -12,10 +12,10 @@ ^- form:m =+ !<([~ target=ship] arg) ;< our=@p bind:m get-our:io -;< now=@da bind:m get-time:io |^ :: early exit; check if we have live path to target ;< tqos=qos:ames bind:m (get-qos target) + ;< now=@da bind:m get-time:io ?: ?& ?=(%live -.tqos) (gth last-contact.tqos (sub now info-timeout:vitals)) == @@ -96,6 +96,7 @@ |= =pending:vitals =/ m (strand ,~) ^- form:m + ;< now=@da bind:m get-time:io %+ poke-our:io %vitals :- %update-status @@ -107,6 +108,7 @@ |= peer=ship =/ m (strand ,qos:ames) ^- form:m + ;< now=@da bind:m get-time:io ?: =(our peer) (pure:m [%live now]) ;< peers=(map ship ?(%alien %known)) bind:m