Merge branch 'next/arvo' into m/recork-slower

This commit is contained in:
fang 2022-09-06 22:16:41 +02:00 committed by GitHub
commit 36dd2f8ace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 956 additions and 110 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:cab0dd267cc5c17eb0d0164e876556ae7975fd5db59a738d741ecd767cca8594
size 8760359
oid sha256:b604b45df0496baf94ac38145c3fc8d4fa9429ae02b49b33a7af4e32ad770db4
size 5896517

View File

@ -6,22 +6,16 @@
default-agent,
verb,
dbug
:: Generally don't update the snapshot until we have clay tombstoning.
::
/* snap %azimuth-snapshot /app/azimuth/version-0/azimuth-snapshot
:: To update, run from dojo:
:: -azimuth-snap-state %default 'version-0'
::
:: To recreate from a full list of logs (at /app/azimuth/logs/eth-logs):
:: -azimuth-snap-logs %default 'version-0'
::
=/ snap=snap-state snap
=/ last-snap=@ number.id.snap
::
=, jael
|%
+$ app-state
$: %6
$: %7
url=@ta
=net
refresh=_~m5
@ -30,10 +24,14 @@
own=owners
spo=sponsors
logs=(list =event-log:rpc:ethereum)
sap=snap-state
==
::
+$ poke-data
$% :: %listen
$% :: %load: load snapshot
::
[%load snap=snap-state]
:: %listen
::
[%listen whos=(list ship) =source:jael]
:: %watch: configure node url and network
@ -75,14 +73,18 @@
==
::
++ init-timer
|= =bowl:gall
|= at=@da
^- card
[%pass /init %arvo %b %wait now.bowl]
[%pass /init %arvo %b %wait at]
::
++ start-log-retrieval
|= [=ship args=vase]
^- card
[%pass /wa %agent [ship %eth-watcher] %poke %eth-watcher-poke args]
::
++ start-azimuth-load
^- card
[%pass /al %arvo %k %fard %base %azimuth-load %noun !>(~)]
--
::
=<
@ -92,22 +94,10 @@
def ~(. (default-agent this %|) bowl)
::
++ on-init
^- (quip card _this)
=/ points=@ud ~(wyt by points.nas.snap)
%- %- slog
[leaf+"ship: loading azimuth snapshot ({<points>} points)"]~
::
=: net.state %default
nas.state nas.snap
own.state owners.snap
spo.state sponsors.snap
url.state 'http://eth-mainnet.urbit.org:8545'
==
:_ this
?: .^(? %j /(scot %p our.bowl)/fake/(scot %da now.bowl))
~
~[(nuke-azimuth-tracker bowl) (init-timer bowl)]
::
~[(init-timer now.bowl)]
++ on-save !>(state)
++ on-load
|= old=vase
@ -122,7 +112,7 @@
`old-state
%- %- slog :_ ~
leaf+"ship: loading snapshot with {<(lent logs.old-state)>} events"
=. +.state +:(state-5-to-6 old-state)
=. +.state +:(state-6-to-7 (state-5-to-6 old-state))
=^ cards state
(%*(run-logs do nas.state *^state:naive) logs.state)
[(jael-update:do (to-udiffs:do cards)) state]
@ -130,12 +120,12 @@
?. ?=(%2 -.old-state)
`old-state
~& > '%azimuth: updating to state 3'
=. +.state +:(state-5-to-6 old-state)
=. +.state +:(state-6-to-7 (state-5-to-6 old-state))
:: replace naive state and indices with snapshot
::
=: nas.state nas.snap
own.state owners.snap
spo.state sponsors.snap
=: nas.state nas.sap.state
own.state owners.sap.state
spo.state sponsors.sap.state
logs.state ~
:: TODO: shouldn't be needed but have seen eth-watcher
:: threads use a url='' if this is not used
@ -144,8 +134,8 @@
==
=/ points=@ud ~(wyt by points.nas.state)
%- %- slog :_ ~
leaf+"ship: processing azimuth snapshot ({<points>} points)"
=/ snap-cards=udiffs:point (run-state:do id.snap points.nas.state)
leaf+"ship: processing azimuth snapshot (~{<points>} points)"
=/ snap-cards=udiffs:point (run-state:do id.sap.state points.nas.state)
:_ [%3 url net whos nas own spo logs]:state
%+ weld
(jael-update:do snap-cards)
@ -160,22 +150,30 @@
=^ cards-4 old-state
?. ?=(%4 -.old-state) [cards-3 old-state]
=^ cards this
%- %*(. on-poke +.state.this +:(state-5-to-6 old-state))
%- %*(. on-poke +.state.this +:(state-6-to-7 (state-5-to-6 old-state)))
[%azimuth-poke !>([%watch [url net]:old-state])]
~& > '%azimuth: updating to state 5'
[cards [%5 url net whos nas own spo logs]:state.this]
=? old-state ?=(%5 -.old-state)
(state-5-to-6 old-state)
?> ?=(%6 -.old-state)
=? old-state ?=(%6 -.old-state)
(state-6-to-7 old-state)
?> ?=(%7 -.old-state)
[cards-4 this(state old-state)]
::
++ app-states $%(state-0 state-1-2-3-4-5 app-state)
::
++ state-5-to-6
|= state-1-2-3-4-5
^- app-state
[%6 url net ~m5 whos nas own spo logs]
++ app-states $%(state-0 state-1-2-3-4-5 state-6 app-state)
::
+$ state-6
$: %6
url=@ta
=net
refresh=_~m5
whos=(set ship)
nas=^state:naive
own=owners
spo=sponsors
logs=(list =event-log:rpc:ethereum)
==
+$ state-1-2-3-4-5
$: ?(%1 %2 %3 %4 %5)
url=@ta
@ -196,6 +194,15 @@
own=owners
logs=(list =event-log:rpc:ethereum)
==
++ state-5-to-6
|= state-1-2-3-4-5
^- state-6
[%6 url net ~m5 whos nas own spo logs]
::
++ state-6-to-7
|= state-6
^- app-state
[%7 url net refresh whos nas own spo logs *snap-state]
--
::
++ on-poke
@ -219,9 +226,9 @@
[(subscribe-to-eth-watcher bowl)]~
::
%resnap
=: nas.state nas.snap
own.state owners.snap
spo.state sponsors.snap
=: nas.state nas.sap.state
own.state owners.sap.state
spo.state sponsors.sap.state
==
`this
==
@ -229,7 +236,23 @@
?. ?=(%azimuth-poke mark)
(on-poke:def mark vase)
=+ !<(poke=poke-data vase)
|-
?- -.poke
%load
=/ points=@ud ~(wyt by points.nas.snap.poke)
%- %- slog
[leaf+"ship: loading azimuth snapshot ({<points>} points)"]~
::
=: net.state %default
nas.state nas.snap.poke
own.state owners.snap.poke
spo.state sponsors.snap.poke
url.state 'http://eth-mainnet.urbit.org:8545'
sap.state snap.poke
logs.state ~
==
$(poke [%kick ~])
::
%listen
[[(listen-to-azimuth (silt whos.poke) source.poke)]~ this]
::
@ -237,8 +260,8 @@
=/ last-block=@
?^ logs.state
number:(last-block-id:dice logs.state)
~& >> %no-logs-in-azimuth-state
last-snap
:: ~& >> %no-logs-in-azimuth-state
number.id.sap.state
=+ [our=(scot %p our.bowl) now=(scot %da now.bowl)]
=+ .^(dudes=(set [dude:gall ?]) %ge our %base now /)
=/ running=? (~(has in dudes) [%eth-watcher &])
@ -246,12 +269,14 @@
|((~(has in dudes) [%eth-watcher &]) (~(has in dudes) [%eth-watcher |]))
:_ this
=/ cards=(list card)
:- :: %jael will re-subscribe to get all azimuth diffs
::
(listen-to-azimuth ~ [%| dap.bowl])
:: we poke eth-watcher to retrieve logs from the latest we have
?: installed
~
:: reinstall %base desk
::
%*(start do last-snap last-block)
=+ spo=(sein:title [our now our]:bowl)
~& >> re-installing-base-from+spo
=/ fresh=[desk ship desk] [%base spo %kids]
[%pass /fresh %agent [our.bowl %hood] %poke kiln-install+!>(fresh)]~
=? cards !running
:: restart %eth-watcher
::
@ -259,30 +284,29 @@
=/ rein=[desk rein] [%base %.y [%eth-watcher ~ ~] ~]
:_ cards
[%pass /rein %agent [our.bowl %hood] %poke kiln-rein+!>(rein)]
=? cards !installed
:: reinstall %base desk
=. cards
:: we poke eth-watcher to retrieve logs from the latest we have
::
=+ spo=(sein:title [our now our]:bowl)
~& >> re-installing-base-from+spo
=/ fresh=[desk ship desk] [%base spo %kids]
:_ cards
[%pass /fresh %agent [our.bowl %hood] %poke kiln-install+!>(fresh)]
:: resubscribe if we somehow get unsubscribed from eth-watcher
::
?: (~(has by wex.bowl) [/eth-watcher our.bowl %eth-watcher])
cards
~& >> %resubscribing-to-eth-watcher
[(subscribe-to-eth-watcher bowl) cards]
(weld %*(start do number.id.sap.state last-block) cards)
=? cards !(~(has by wex.bowl) [/eth-watcher our.bowl %eth-watcher])
:: resubscribe if we somehow get unsubscribed from eth-watcher
::
[(subscribe-to-eth-watcher bowl) cards]
=. cards
:: %jael will re-subscribe to get all azimuth diffs
::
[(listen-to-azimuth ~ [%| dap.bowl]) cards]
(flop cards)
::
%watch
=: nas.state ?:(?=(%default net.poke) nas.snap *^state:naive)
own.state ?:(?=(%default net.poke) owners.snap ~)
spo.state ?:(?=(%default net.poke) sponsors.snap ~)
=: nas.state ?:(?=(%default net.poke) nas.sap.state *^state:naive)
own.state ?:(?=(%default net.poke) owners.sap.state ~)
spo.state ?:(?=(%default net.poke) sponsors.sap.state ~)
net.state net.poke
url.state url.poke
logs.state ~
==
[start:do this]
`this
==
::
++ on-watch
@ -309,7 +333,7 @@
:- %leaf
"ship: processing azimuth snapshot ({<points>} points)"
=/ snap-cards=udiffs:point
(%*(run-state do logs.state ~) id.snap points.nas.state)
(%*(run-state do logs.state ~) id.sap.state points.nas.state)
[(weld (jael-update:do snap-cards) start:do) this]
::
++ on-leave on-leave:def
@ -318,13 +342,14 @@
^- (unit (unit cage))
|^
?+ path (on-peek:def path)
[%x %logs ~] ``noun+!>(logs.state)
[%x %nas ~] ``noun+!>(nas.state)
[%x %dns ~] ``noun+!>(dns.nas.state)
[%x %own ~] ``noun+!>(own.state)
[%x %spo ~] ``noun+!>(spo.state)
[%x %refresh ~] ``atom+!>(refresh.state)
[%x %point @ ~] ``noun+(point i.t.t.path)
[%x %logs ~] ``noun+!>(logs.state)
[%x %nas ~] ``noun+!>(nas.state)
[%x %dns ~] ``noun+!>(dns.nas.state)
[%x %own ~] ``noun+!>(own.state)
[%x %spo ~] ``noun+!>(spo.state)
[%x %refresh ~] ``atom+!>(refresh.state)
[%x %point @ ~] ``noun+(point i.t.t.path)
[%x %last-snap ~] ``noun+!>(sap.state)
==
::
++ point
@ -369,19 +394,24 @@
::
++ on-arvo
|= [=wire =sign-arvo]
?: &(=(/al wire) ?=(%arow +<.sign-arvo))
?- -.p.sign-arvo
%& `this
%|
%- (slog 'loading azimuth snapshot failed! still trying' p.p.sign-arvo)
[~[(init-timer (add ~s10 now.bowl))] this]
==
?. &(=(/init wire) ?=(%wake +<.sign-arvo))
(on-arvo:def wire sign-arvo)
?^ error.sign-arvo
%- (slog 'azimuth: failed to initialize!' ~)
`this
:_ this
~[(subscribe-to-eth-watcher bowl) (listen-to-azimuth ~ [%| dap.bowl])]
~[start-azimuth-load]
::
++ on-fail on-fail:def
--
|_ =bowl:gall
:: TODO: maybe flop the endianness here so metamask signs it in normal
:: order?
::
++ verifier
^- ^verifier:naive
@ -514,7 +544,7 @@
:+ %watch /[dap.bowl]
^- config:eth-watcher
:* url.state =(%czar (clan:title our.bowl)) refresh.state ~h30
(max launch.net ?:(=(net.state %default) +(last-snap) 0))
(max launch.net ?:(=(net.state %default) +(number.id.sap.state) 0))
~
~[azimuth.net]
~[naive.net]

View File

@ -469,6 +469,10 @@
[~ this(dogs.state (~(put by dogs.state) path u.dog(running ~)))]
::
%thread-done
:: if empty, that means we cancelled this thread
::
?: =(*vase q.cage.sign)
`this
=+ !<([vows=disavows pup=watchpup] q.cage.sign)
=. u.dog
%_ u.dog

View File

@ -1,5 +0,0 @@
:: Kick azimuth
::
:- %say
|= *
[%azimuth-poke %kick ~]

View File

@ -0,0 +1,203 @@
/+ *test, test-pub, test-sub
/= ames-raw /sys/vane/ames
/= gall-raw /sys/vane/gall
::
=/ ames-bunt (ames-raw ~zod)
=/ gall-bunt (gall-raw ~zod)
:: basic helpers
::
|%
++ make-gall
|= =ship
=/ gall-pupa (gall-raw ship)
=/ gall-core (gall-pupa now=~1111.1.1 eny=`@`0xdead.beef scry=*roof)
=+ [out adult]=(call:gall-core duct=~[/init] dud=~ task=[%init ~])
adult
::
++ ames-nec-bud
:: create ~nec
::
=/ nec (ames-raw ~nec)
=. now.nec ~1111.1.1
=. eny.nec 0xdead.beef
=. life.ames-state.nec 2
=. rof.nec |=(* ``[%noun !>(*(list turf))])
=. crypto-core.ames-state.nec (pit:nu:crub:crypto 512 (shaz 'nec'))
=/ nec-pub pub:ex:crypto-core.ames-state.nec
=/ nec-sec sec:ex:crypto-core.ames-state.nec
:: create ~bud
::
=/ bud (ames-raw ~bud)
=. now.bud ~1111.1.1
=. eny.bud 0xbeef.dead
=. life.ames-state.bud 3
=. rof.bud |=(* ``[%noun !>(*(list turf))])
=. crypto-core.ames-state.bud (pit:nu:crub:crypto 512 (shaz 'bud'))
=/ bud-pub pub:ex:crypto-core.ames-state.bud
=/ bud-sec sec:ex:crypto-core.ames-state.bud
::
=/ nec-sym (derive-symmetric-key:ames-raw bud-pub nec-sec)
=/ bud-sym (derive-symmetric-key:ames-raw nec-pub bud-sec)
?> =(nec-sym bud-sym)
:: tell ~nec about ~bud
::
=. peers.ames-state.nec
%+ ~(put by peers.ames-state.nec) ~bud
=| =peer-state:ames
=. -.peer-state
:* symmetric-key=bud-sym
life=3
rift=0
public-key=bud-pub
sponsor=~bud
==
=. route.peer-state `[direct=%.y `lane:ames`[%& ~bud]]
[%known peer-state]
:: tell ~bud about ~nec
::
=. peers.ames-state.bud
%+ ~(put by peers.ames-state.bud) ~nec
=| =peer-state:ames
=. -.peer-state
:* symmetric-key=nec-sym
life=2
rift=0
public-key=nec-pub
sponsor=~nec
==
=. route.peer-state `[direct=%.y `lane:ames`[%& ~nec]]
[%known peer-state]
:: metamorphose
::
=> .(nec +:(call:(nec) ~[//unix] ~ %born ~))
=> .(bud +:(call:(bud) ~[//unix] ~ %born ~))
::
[nec=nec bud=bud]
--
:: forward-declare to avoid repeated metamorphoses
=/ gall-adult (make-gall ~zod)
=/ ames-adult nec:ames-nec-bud
:: main core
::
|%
+$ gall-gate _gall-adult
+$ ames-gate _ames-adult
::
++ nec-bud
=/ a ames-nec-bud
=/ gall-nec (make-gall ~nec)
=. gall-nec (load-agent ~nec gall-nec %sub test-sub)
=/ gall-bud (make-gall ~bud)
=. gall-bud (load-agent ~bud gall-bud %pub test-pub)
:* nec=[ames=nec.a gall=gall-nec]
bud=[ames=bud.a gall=gall-bud]
==
:: +gall-check-call: run gall task, assert produces expected-moves
::
++ gall-check-call
|= $: =gall-gate
[now=@da eny=@ =roof]
[=duct task=(hobo task:gall)]
expected-moves=(list move:gall-bunt)
==
^- [tang ^gall-gate]
=/ gall-core (gall-gate now eny roof)
=^ moves gall-gate (call:gall-core duct dud=~ task)
[(expect-eq !>(expected-moves) !>(moves)) gall-gate]
::
++ gall-call
|= [=gall-gate =duct task=(hobo task:gall) =roof]
%. [duct dud=~ task]
call:(gall-gate now=~1111.1.1 eny=`@`0xdead.beef roof)
:: +gall-check-take: run gall sign, assert produces expected-moves
::
++ gall-check-take
|= $: =gall-gate
[now=@da eny=@ =roof]
[=wire =duct =sign-arvo]
expected-moves=(list move:gall-bunt)
==
^- [tang ^gall-gate]
=/ gall-core (gall-gate now eny roof)
=^ moves gall-gate (take:gall-core wire duct dud=~ sign-arvo)
[(expect-eq !>(expected-moves) !>(moves)) gall-gate]
::
++ gall-take
|= [=gall-gate =wire =duct =sign-arvo =roof]
%. [wire duct dud=~ sign-arvo]
take:(gall-gate now=~1111.1.1 eny=`@`0xdead.beef roof)
:: +ames-check-call: run gall task, assert produces expected-moves
::
++ ames-check-call
|= $: =ames-gate
[now=@da eny=@ =roof]
[=duct task=(hobo task:ames)]
expected-moves=(list move:ames-bunt)
==
^- [tang ^ames-gate]
=/ ames-core (ames-gate now eny roof)
=^ moves ames-gate (call:ames-core duct dud=~ task)
[(expect-eq !>(expected-moves) !>(moves)) ames-gate]
::
++ ames-call
|= [=ames-gate =duct task=(hobo task:ames) =roof]
%. [duct dud=~ task]
call:(ames-gate now=~1111.1.1 eny=`@`0xdead.beef roof)
:: +ames: run ames sign, assert produces expected-moves
::
++ ames-check-take
|= $: =ames-gate
[now=@da eny=@ =roof]
[=wire =duct =sign:ames-bunt]
expected-moves=(list move:ames-bunt)
==
^- [tang ^ames-gate]
=/ ames-core (ames-gate now eny roof)
=^ moves ames-gate (take:ames-core wire duct dud=~ sign)
[(expect-eq !>(expected-moves) !>(moves)) ames-gate]
::
++ ames-scry-peer
|= $: =ames-gate
[now=@da eny=@ =roof]
our=ship
her=ship
==
^- peer-state:ames
=- ?>(?=(%known -<) ->)
!< ship-state:ames
=< q
%- need %- need
%- scry:(ames-gate now eny roof)
[~ %x [[our %$ da+now] /peers/(scot %p her)]]
::
++ gall-scry-nonce
|= $: =gall-gate
[now=@da eny=@ =roof]
our=ship
=dude:gall
sub=[=ship =term =wire]
==
^- @ud
!< @ud
=< q
%- need %- need
%- scry:(gall-gate now eny roof)
[~ %n [[our dude da+now] [(scot %p ship.sub) [term wire]:sub]]]
::
++ load-agent
|= [=ship =gall-gate =dude:gall =agent:gall]
=^ * gall-gate
(gall-call gall-gate ~[/jolt] [%jolt %base dude] *roof)
=^ * gall-gate
=/ =sign-arvo
:+ %clay %writ
`[[%a da+~1111.1.1 %base] /app/[dude]/hoon vase+!>(!>(agent))]
%: gall-take
gall-gate
/sys/cor/[dude]/(scot %p ship)/base/(scot %da ~1111.1.1)
~[/jolt]
sign-arvo
*roof
==
gall-gate
--

View File

@ -0,0 +1,36 @@
/+ default-agent, verb, dbug
::
=| state=~
%- agent:dbug
%+ verb &
^- agent:gall
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
::
++ on-poke
|= [=mark =vase]
(on-poke:def +<)
::
++ on-watch
|= =path
`this
::
++ on-agent
|= [=wire =sign:agent:gall]
(on-agent:def +<)
::
++ on-fail
|= [=term =tang]
(mean ':pub +on-fail' term tang)
::
++ on-leave
|= =path
`this
::
++ on-init `this
++ on-save !>(state)
++ on-load |=(old=vase `this(state !<(_state old)))
++ on-arvo on-arvo:def
++ on-peek on-peek:def
--

View File

@ -0,0 +1,47 @@
/+ default-agent, verb, dbug
::
=| state=~
%- agent:dbug
%+ verb &
^- agent:gall
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
::
++ on-poke
|= [=mark =vase]
=+ !<(=ship vase)
:_ this
?+ mark !!
%leave [%pass /sub-foo/(scot %p ship) %agent [ship %pub] %leave ~]~
%watch [%pass /sub-foo/(scot %p ship) %agent [ship %pub] %watch /foo]~
==
::
++ on-watch
|= =path
(on-watch:def +<)
::
++ on-agent
|= [=wire =sign:agent:gall]
=/ =ship (slav %p &2.wire)
?+ -.sign !!
%fact `this
%watch-ack `this
%kick
[[%pass /sub-foo/(scot %p ship) %agent [ship %pub] %watch /foo]~ this]
==
::
++ on-fail
|= [=term =tang]
(mean ':sub +on-fail' term tang)
::
++ on-leave
|= =path
`this
::
++ on-init `this
++ on-save !>(state)
++ on-load |=(old=vase `this(state !<(_state old)))
++ on-arvo on-arvo:def
++ on-peek on-peek:def
--

View File

@ -7,6 +7,7 @@
+$ owners (jug owner ship)
+$ sponsors (map ship [residents=(set ship) requests=(set ship)])
+$ history (map address:ethereum (tree hist-tx))
+$ events (list event-log:rpc:ethereum)
+$ net ?(%mainnet %ropsten %local %default)
+$ snap-state [%0 =id:block:jael nas=^state:naive =owners =sponsors]
::

View File

@ -1801,7 +1801,7 @@
:: if we haven't received an attestation, ask again
::
?^ error
%- (slog leaf+"ames: attestation timer failed: {<u.error>}" ~)
%- (slog 'ames: attestation timer failed' u.error)
event-core
?~ ship=`(unit @p)`(slaw %p i.t.wire)
%- (slog leaf+"ames: got timer for strange wire: {<wire>}" ~)
@ -1828,6 +1828,10 @@
::
=. event-core
(emit duct %pass /recork %b %wait `@da`(add now ~d1))
::
?^ error
%- (slog 'ames: recork timer failed' u.error)
event-core
:: recork up to one bone per peer
::
=/ pez ~(tap by peers.ames-state)

View File

@ -306,28 +306,6 @@
%^ poke-watch hen %azimuth
%+ fall node.tac
(need (de-purl:html 'http://eth-mainnet.urbit.org:8545'))
=. +>.$
:: get everything from /app/azimuth because jael subscriptions
:: seem to be flaky for now
::
?: &
%- curd =< abet
(sources:~(feel su hen now pki etn) ~ [%| %azimuth])
::
?- (clan:title our)
%czar
%- curd =< abet
(sources:~(feel su hen now pki etn) ~ [%| %azimuth])
::
*
=. +>.$
%- curd =< abet
%+ sources:~(feel su hen now pki etn)
(silt (turn spon-points head))
[%| %azimuth]
%- curd =< abet
(sources:~(feel su hen now pki etn) ~ [%& (need spon-ship)])
==
::
=. moz
%+ weld moz
@ -391,7 +369,7 @@
:: [%listen whos=(set ship) =source]
::
%listen
~& [%jael-listen whos source]:tac
:: %- (slog leaf+"jael: listen {<whos.tac>} {<source.tac>}" ~)
%- curd =< abet
(sources:~(feel su hen now pki etn) [whos source]:tac)
::

View File

@ -0,0 +1,15 @@
/- spider, *dice
/+ strand, strandio, naive, dice
=, strand=strand:spider
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
=/ url=tape
?~ lur=!<((unit tape) arg)
"https://bootstrap.urbit.org/mainnet.azimuth-snapshot"
u.lur
;< =cord bind:m (fetch-cord:strandio url)
=+ ;;(snap=snap-state (cue cord))
;< ~ bind:m (poke-our:strandio %azimuth %azimuth-poke !>([%load snap]))
(pure:m !>(~))

504
pkg/arvo/tests/sys/grq.hoon Normal file
View File

@ -0,0 +1,504 @@
:: test gall subscription nonce incrementation and ames flow killing
::
/+ *test, v=test-ames-gall
|%
++ test-watch
%- run-chain
|. :- %|
=+ nec-bud:v
:: uncomment to turn on verbose debug output
::=^ * ames.nec
:: (ames-call:v ames.nec ~[/none] [%spew ~[%msg %snd %rcv %odd]] *roof)
::=^ * ames.bud
:: (ames-call:v ames.bud ~[/none] [%spew ~[%msg %snd %rcv %odd]] *roof)
:: poke %sub to tell it to subscribe
=/ =task:gall [%deal [~nec ~nec] %sub %poke watch+!>(~bud)]
=^ t1 gall.nec
%: gall-check-call:v gall.nec
[~1111.1.1 0xdead.beef *roof]
[~[/foo] task]
:~ :- ~[/foo] [%give %unto %poke-ack ~]
:- ~[/init]
:* %pass /use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud
[%g %deal [~nec ~bud] %pub %watch /foo]
== ==
==
:- t1 |. :- %|
:: handle gall passing the %watch to itself, which passes to ames
=^ t2 gall.nec
%: gall-check-call:v gall.nec
[~1111.1.1 0xdead.beef *roof]
:- ~[/use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud /init]
[%deal [~nec ~bud] %pub %watch /foo]
:~ :- ~[/init] [%pass /sys/lag %a %heed ~bud]
:- ~[/init] [%pass /sys/era %j %public-keys (sy ~bud ~)]
:- ~[/use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud /init]
[%pass /sys/way/~bud/pub %a %plea ~bud %g /ge/pub [%0 %s /foo]]
==
==
:- t2 |. :- %|
:: subscriber ames handles %plea from gall, gives a packet to vere
=^ t3 ames.nec
%: ames-check-call:v ames.nec
[~1111.1.1 0xdead.beef *roof]
:- :~ /sys/way/~bud/pub
/use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud
/init
==
[%plea ~bud %g /ge/pub [%0 %s /foo]]
:~ :- ~[//unix]
:* %give %send [%& ~bud]
0xae59.5b29.277b.22c1.20b7.a8db.9086.46df.31bd.f9bc.
2633.7300.17d4.f5fc.8be5.8bfe.5c9d.36d9.2ea1.7cb3.
8a00.0200.0132.8fd4.f000
==
:- ~[/ames] [%pass /pump/~bud/0 %b %wait ~1111.1.1..00.00.01]
==
==
:- t3 |. :- %|
:: publisher ames hears %watch, passes to gall
=^ t4 ames.bud
%: ames-check-call:v ames.bud
[~1111.1.2 0xbeef.dead *roof]
:- ~[//unix]
:* %hear [%& ~nec]
0xae59.5b29.277b.22c1.20b7.a8db.9086.46df.31bd.f9bc.
2633.7300.17d4.f5fc.8be5.8bfe.5c9d.36d9.2ea1.7cb3.
8a00.0200.0132.8fd4.f000
==
:~ :- ~[//unix] [%pass /qos %d %flog %text "; ~nec is your neighbor"]
:- ~[//unix]
[%pass /bone/~nec/0/1 %g %plea ~nec %g /ge/pub [%0 %s /foo]]
==
==
:- t4 |. :- %|
:: publisher gall hears %watch from ames, passes to itself
=^ t5 gall.bud
%: gall-check-call:v gall.bud
[~1111.1.2 0xbeef.dead *roof]
:- ~[/bone/~nec/0/1 //unix]
[%plea ~nec %g /ge/pub [%0 %s /foo]]
:~ :- ~[/init] [%pass /sys/lag %a %heed ~nec]
:- ~[/init] [%pass /sys/era %j %public-keys (sy ~nec ~)]
:- ~[/bone/~nec/0/1 //unix]
[%pass /sys/req/~nec/pub %g %deal [~nec ~bud] %pub %watch /foo]
==
==
:- t5 |. :- %|
:: publisher gall runs %pub with %watch, gives ack to itself
=^ t6 gall.bud
%: gall-check-call:v gall.bud
[~1111.1.2 0xbeef.dead *roof]
:- ~[/sys/req/~nec/pub /bone/~nec/0/1 //unix]
[%deal [~nec ~bud] %pub %watch /foo]
:~ :- ~[/sys/req/~nec/pub /bone/~nec/0/1 //unix]
[%give %unto %watch-ack ~]
==
==
:- t6 |. :- %|
:: gall gives ack to ames
=^ t7 gall.bud
%: gall-check-take:v gall.bud
[~1111.1.2 0xbeef.dead *roof]
:+ /sys/req/~nec/pub ~[/bone/~nec/0/1 //unix]
[%gall %unto %watch-ack ~]
:~ :- ~[/bone/~nec/0/1 //unix] [%give %done ~]
==
==
:- t7 |. :- %|
:: publisher ames hears ack from gall, sends over the network
=^ t8 ames.bud
%: ames-check-take:v ames.bud
[~1111.1.2 0xbeef.dead *roof]
:+ /bone/~nec/0/1 ~[//unix]
[%gall %done ~]
:~ :- ~[//unix]
:* %give %send [%& ~nec]
0x2.0219.8100.0485.5530.3c88.9068.3cc6.484e.
2d9d.076e.6d00.0100.0223.9ae9.5000
== ==
==
:- t8 |. :- %|
:: subscriber ames hears watch-ack packet, gives to gall
=^ t9 ames.nec
%: ames-check-call:v ames.nec
[~1111.1.3 0xdead.beef *roof]
:- ~[//unix]
:* %hear [%& ~bud]
0x2.0219.8100.0485.5530.3c88.9068.3cc6.484e.
2d9d.076e.6d00.0100.0223.9ae9.5000
==
:~ :- ~[//unix] [%pass /qos %d %flog %text "; ~bud is your neighbor"]
:- :~ /sys/way/~bud/pub
/use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud
/init
==
[%give %done ~]
:- ~[/ames] [%pass /pump/~bud/0 %b %rest ~1111.1.1..00.00.01]
==
==
:- t9 |. :- %|
:: gall gives %done to itself
=^ t10 gall.nec
%: gall-check-take:v gall.nec
[~1111.1.3 0xdead.beef *roof]
:+ /sys/way/~bud/pub
~[/use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud /init]
[%ames %done ~]
:~ :- ~[/use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud /init]
[%give %unto %watch-ack ~]
==
==
:- t10 |. :- %|
:: gall gives watch-ack to itself
=^ t11 gall.nec
%: gall-check-take:v gall.nec
[~1111.1.3 0xdead.beef *roof]
:+ /use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud
~[/init]
[%gall %unto %watch-ack ~]
~
==
:- t11 |. :- %|
:: start the clog and kick process; give clog to publisher gall
=^ t12 gall.bud
%: gall-check-take:v gall.bud
[~1111.1.4 0xbeef.dead *roof]
:+ /sys/lag ~[/init]
[%ames %clog ~nec]
:~ :- ~[/sys/req/~nec/pub /bone/~nec/0/1 //unix]
[%give %unto %kick ~]
==
==
:- t12 |. :- %|
:: gall gives %kick %boon to ames
=^ t13 gall.bud
%: gall-check-take:v gall.bud
[~1111.1.4 0xbeef.dead *roof]
:+ /sys/req/~nec/pub ~[/bone/~nec/0/1 //unix]
[%gall %unto %kick ~]
:~ :- ~[/bone/~nec/0/1 //unix] [%give %boon %x ~]
==
==
:- t13 |. :- %|
:: ames gives kick over the network
=^ t14 ames.bud
%: ames-check-take:v ames.bud
[~1111.1.4 0xbeef.dead *roof]
:+ /bone/~nec/0/1 ~[//unix]
[%gall %boon %x ~]
:~ :- ~[//unix]
:* %give %send [%& ~nec]
0xa1fc.cd35.c730.9a00.07e0.90a2.f87c.3657.935e.
4ca0.801d.3ddc.d400.0100.0223.bc18.1000
==
:- ~[/ames] [%pass /pump/~nec/1 %b %wait ~1111.1.4..00.00.01]
==
==
:- t14 |. :- %|
:: subscriber ames receives kick, gives to gall and gives ack to unix
=^ t15 ames.nec
%: ames-check-call:v ames.nec
[~1111.1.5 0xdead.beef *roof]
:- ~[//unix]
:* %hear [%& ~bud]
0xa1fc.cd35.c730.9a00.07e0.90a2.f87c.3657.935e.
4ca0.801d.3ddc.d400.0100.0223.bc18.1000
==
:~ :- :~ /sys/way/~bud/pub
/use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud
/init
==
[%give %boon %x ~]
:- ~[//unix]
:* %give %send [%& ~bud]
0xfe.e208.da00.0491.bf7f.9594.2ddc.0948.
9de0.3906.b678.6e00.0200.0132.e55d.5000
== ==
==
:- t15 |. :- %|
:: subscriber gall receives kick %boon from ames, gives to self
=^ t16 gall.nec
%: gall-check-take:v gall.nec
[~1111.1.5 0xdead.beef *roof]
:+ /sys/way/~bud/pub
~[/use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud /init]
[%ames %boon %x ~]
:~ :- ~[/use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud /init]
[%give %unto %kick ~]
:- ~[/use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud /init]
[%pass /sys/way/~bud/pub %a %cork ~bud]
==
==
:: subscriber gall receives %kick from itself
=^ t17 gall.nec
%: gall-check-take:v gall.nec
[~1111.1.5 0xdead.beef *roof]
:+ /use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud
~[/init]
[%gall %unto %kick ~]
:~ :- ~[/init]
:* %pass /use/sub/0w1.d6Isf/out/~bud/pub/2/sub-foo/~bud
[%g %deal [~nec ~bud] %pub %watch /foo]
== ==
==
:- t17 |. :- %|
:: gall receives %deal %watch from itself, passes to ames
=^ t18 gall.nec
%: gall-check-call:v gall.nec
[~1111.1.5 0xdead.beef *roof]
:- ~[/use/sub/0w1.d6Isf/out/~bud/pub/2/sub-foo/~bud /init]
[%deal [~nec ~bud] %pub %watch /foo]
:~ :- ~[/use/sub/0w1.d6Isf/out/~bud/pub/2/sub-foo/~bud /init]
[%pass /sys/way/~bud/pub %a %plea ~bud %g /ge/pub [%0 %s /foo]]
==
==
:- t18 |. :- %|
:: subscriber ames sends new %watch
=^ t19 ames.nec
%: ames-check-call:v ames.nec
[~1111.1.5 0xdead.beef *roof]
:- :~ /sys/way/~bud/pub
/use/sub/0w1.d6Isf/out/~bud/pub/2/sub-foo/~bud
/init
==
[%plea ~bud %g /ge/pub [%0 %s /foo]]
:~ :- ~[//unix]
:* %give %send [%& ~bud]
0xfe.9174.6d7c.e042.4ea7.cf3c.08da.3acf.68ec.3bd1.1f2c.abfe.f500.
1897.c42e.a3ec.2159.86d6.e2f1.b344.9d06.b600.0200.0132.ebe7.8800
==
:- ~[/ames] [%pass /pump/~bud/4 %b %wait ~1111.1.5..00.00.01]
==
==
:- t19 |. :- %|
:: subscriber ames sends %cork
=^ t20 ames.nec
%: ames-check-call:v ames.nec
[~1111.1.5 0xdead.beef *roof]
:- :~ /sys/way/~bud/pub
/use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud
/init
==
[%cork ~bud]
:~ :- ~[//unix]
:* %give %send [%& ~bud]
0xb.130c.ab37.ca24.49cd.aecb.23ba.70f1.6f1c.4d00.124e.c9a5.
3413.3843.d81c.47c4.7040.6e62.3700.0200.0132.e1ab.9000
==
:- ~[/ames] [%pass /pump/~bud/0 %b %wait ~1111.1.5..00.02.00]
==
==
:: publisher ames hears %kick ack
:- t20 |. :- %|
=^ t21 ames.bud
%: ames-check-call:v ames.bud
[~1111.1.6 0xbeef.dead *roof]
:- ~[//unix]
:* %hear [%& ~nec]
0xfe.e208.da00.0491.bf7f.9594.2ddc.0948.
9de0.3906.b678.6e00.0200.0132.e55d.5000
==
:~ :- ~[/ames] [%pass /pump/~nec/1 %b %rest ~1111.1.4..00.00.01]
==
==
:: publisher ames hears new %watch
:- t21 |. :- %|
=^ t22 ames.bud
%: ames-check-call:v ames.bud
[~1111.1.7 0xbeef.dead *roof]
:- ~[//unix]
:* %hear [%& ~nec]
0xfe.9174.6d7c.e042.4ea7.cf3c.08da.3acf.68ec.3bd1.1f2c.abfe.f500.
1897.c42e.a3ec.2159.86d6.e2f1.b344.9d06.b600.0200.0132.ebe7.8800
==
:~ :- ~[//unix]
[%pass /bone/~nec/0/5 %g %plea ~nec %g /ge/pub [%0 %s /foo]]
==
==
:: publisher gall hears new %watch, passes to self
:- t22 |. :- %|
=^ t23 gall.bud
%: gall-check-call:v gall.bud
[~1111.1.7 0xbeef.dead *roof]
:- ~[/bone/~nec/0/5 //unix]
[%plea ~nec %g /ge/pub [%0 %s /foo]]
:~ :- ~[/bone/~nec/0/5 //unix]
[%pass /sys/req/~nec/pub %g %deal [~nec ~bud] %pub %watch /foo]
==
==
:: publisher gall runs :pub's +on-watch, gives ack to self
:- t23 |. :- %|
=^ t24 gall.bud
%: gall-check-call:v gall.bud
[~1111.1.7 0xbeef.dead *roof]
:- ~[/sys/req/~nec/pub /bone/~nec/0/5 //unix]
[%deal [~nec ~bud] %pub %watch /foo]
:~ :- ~[/sys/req/~nec/pub /bone/~nec/0/5 //unix]
[%give %unto %watch-ack ~]
==
==
:: publisher gall hears %watch-ack, gives to ames
:- t24 |. :- %|
=^ t25 gall.bud
%: gall-check-take:v gall.bud
[~1111.1.7 0xbeef.dead *roof]
:+ /sys/req/~nec/pub ~[/bone/~nec/0/5 //unix]
[%gall %unto %watch-ack ~]
:~ :- ~[/bone/~nec/0/5 //unix] [%give %done ~]
==
==
:: publisher ames hears done from gall, sends over the network
:- t25 |. :- %|
=^ t26 ames.bud
%: ames-check-take:v ames.bud
[~1111.1.7 0xbeef.dead *roof]
:+ /bone/~nec/0/5 ~[//unix]
[%gall %done ~]
:~ :- ~[//unix]
:* %give %send [%& ~nec]
0x5f5.c27c.c400.0587.8b0d.0a5d.eb8e.39fa.
49f4.4848.bfa6.f600.0100.0223.c98c.8800
== ==
==
:: publisher ames hears %cork, passes to itself
:- t26 |. :- %|
=^ t27 ames.bud
%: ames-check-call:v ames.bud
[~1111.1.8 0xbeef.dead *roof]
:- ~[//unix]
:* %hear [%& ~nec]
0xb.130c.ab37.ca24.49cd.aecb.23ba.70f1.6f1c.4d00.124e.c9a5.
3413.3843.d81c.47c4.7040.6e62.3700.0200.0132.e1ab.9000
==
:~ :- ~[//unix] [%pass /bone/~nec/0/1 %a %plea ~nec [%a /close ~]]
==
==
:- t27 |. :- %|
:: publisher ames hear cork plea from self, give %done to self
=^ t28 ames.bud
%: ames-check-call:v ames.bud
[~1111.1.8 0xbeef.dead *roof]
:- ~[/bone/~nec/0/1 //unix]
[%plea ~nec [%a /close ~]]
:~ :- ~[/bone/~nec/0/1 //unix] [%give %done ~]
==
==
:: publisher ames hears cork done from self, sends ack packet
:- t28 |. :- %|
=^ t29 ames.bud
%: ames-check-take:v ames.bud
[~1111.1.8 0xbeef.dead *roof]
:+ /bone/~nec/0/1
~[//unix]
[%ames %done ~]
:~ :- ~[//unix]
:* %give %send [%& ~nec]
0x5f.f966.8e00.0449.bdec.9006.c7e5.1237.
1d87.53fe.d7bb.ad00.0100.0223.c6a8.5800
== ==
==
:: subscriber ames hears %watch-ack, gives to gall
:- t29 |. :- %|
=^ t30 ames.nec
%: ames-check-call:v ames.nec
[~1111.1.9 0xdead.beef *roof]
:- ~[//unix]
:* %hear [%& ~bud]
0x5f5.c27c.c400.0587.8b0d.0a5d.eb8e.39fa.
49f4.4848.bfa6.f600.0100.0223.c98c.8800
==
:~ :- :~ /sys/way/~bud/pub
/use/sub/0w1.d6Isf/out/~bud/pub/2/sub-foo/~bud
/init
==
[%give %done ~]
:- ~[/ames] [%pass /pump/~bud/4 %b %rest ~1111.1.5..00.00.01]
==
==
:: subscriber gall hears new %watch-ack from ames, gives to self
:- t30 |. :- %|
=^ t31 gall.nec
%: gall-check-take:v gall.nec
[~1111.1.9 0xdead.beef *roof]
:+ /sys/way/~bud/pub
:~ /use/sub/0w1.d6Isf/out/~bud/pub/2/sub-foo/~bud
/init
==
[%ames %done ~]
:~ :- :~ /use/sub/0w1.d6Isf/out/~bud/pub/2/sub-foo/~bud
/init
==
[%give %unto %watch-ack ~]
==
==
:: subscriber gall hears new %watch-ack from self, tells :sub
:- t31 |. :- %|
=^ t32 gall.nec
%: gall-check-take:v gall.nec
[~1111.1.9 0xdead.beef *roof]
:+ /use/sub/0w1.d6Isf/out/~bud/pub/2/sub-foo/~bud
~[/init]
[%gall %unto %watch-ack ~]
~
==
:: subscriber ames hears %cork ack
:- t32 |. :- %|
=^ t33 ames.nec
%: ames-check-call:v ames.nec
[~1111.1.10 0xdead.beef *roof]
:- ~[//unix]
:* %hear [%& ~bud]
0x5f.f966.8e00.0449.bdec.9006.c7e5.1237.
1d87.53fe.d7bb.ad00.0100.0223.c6a8.5800
==
:~ :- :~ /sys/way/~bud/pub
/use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud
/init
==
[%give %done ~]
:- ~[/ames] [%pass /pump/~bud/0 %b %rest ~1111.1.5..00.02.00]
==
==
:: subscriber gall hears %cork ack from ames
:- t33 |. :- %|
=^ t34 gall.nec
%: gall-check-take:v gall.nec
[~1111.1.10 0xdead.beef *roof]
:+ /sys/way/~bud/pub
:~ /use/sub/0w1.d6Isf/out/~bud/pub/1/sub-foo/~bud
/init
==
[%ames %done ~]
~
==
:- t34 |. :- %&
;: weld
%+ expect-eq
!> (sy 0 ~)
!> =< corked
%: ames-scry-peer:v
ames.nec
[~1111.1.10 0xdead.beef *roof]
[~nec ~bud]
==
::
%+ expect-eq
!> (sy 1 ~)
!> =< corked
%: ames-scry-peer:v
ames.bud
[~1111.1.8 0xbeef.dead *roof]
[~bud ~nec]
==
::
%+ expect-eq
!> 2
!> %: gall-scry-nonce:v
gall.nec
[~1111.1.10 0xdead.beef *roof]
~nec %sub
[~bud %pub /sub-foo/~bud]
==
==
--

View File

@ -433,7 +433,6 @@
%- pure:m
?~ full-file.client-response ''
q.data.u.full-file.client-response
::
++ fetch-cord
|= url=tape

View File

@ -38,7 +38,37 @@
=/ b (mule a)
?- -.b
%| ~
%& [leaf+"expected failure - succeeded" ~]
%& ['expected failure - succeeded' ~]
==
:: +expect-runs: kicks a trap, expecting success; returns trace on failure
::
++ expect-success
|= a=(trap)
^- tang
=/ b (mule a)
?- -.b
%& ~
%| ['expected success - failed' p.b]
==
:: $test-chain: a sequence of tests to be run
::
+$ test-chain
$_
|?
?: =(0 0)
[%& p=*tang]
[%| p=[tang=*tang next=^?(..$)]]
:: +run-chain: run a sequence of tests, stopping at first failure
::
++ run-chain
|= seq=test-chain
^- tang
=/ res $:seq
?- -.res
%& p.res
%| ?. =(~ tang.p.res)
tang.p.res
$(seq next.p.res)
==
:: +category: prepends a name to an error result; passes successes unchanged
::