jael: add "eager" mode to avoid hitting nodes as much

This commit is contained in:
Philip Monk 2019-12-09 11:41:01 -08:00 committed by Jared Tobin
parent 15bd35301e
commit 18c3e7253b
No known key found for this signature in database
GPG Key ID: 0E4647D58F8A69E4
6 changed files with 100 additions and 29 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:04735cc4764f9a3e6c4fb5b046a6b9590664fe9f644578c58f3bc6acc911b723
size 9606039
oid sha256:3f516fece44715fff856766856ad61abf1b9164a0ba9f80f63f23da9d21df1cc
size 9617783

View File

@ -88,7 +88,8 @@
^- card:agent:gall
=/ args=vase !>
:* %watch /[dap]
url.state ~m5 launch:contracts:azimuth
url.state =(~ whos.state) ~m5
launch:contracts:azimuth
~[azimuth:contracts:azimuth]
(topics whos.state)
==

View File

@ -8,7 +8,7 @@
=> |%
+$ card card:agent:gall
+$ app-state
$: %2
$: %3
dogs=(map path watchdog)
==
::
@ -92,17 +92,52 @@
%- (slog leaf+"upgrading eth-watcher from %1" ~)
:_ old-state(- %2)
%+ turn ~(tap by dogs.old-state)
|= [=path dog=watchdog]
|= [=path dog=watchdog-1]
(wait-shortcut path now.bowl)
::
[cards-1 this(state ?>(?=(%2 -.old-state) old-state))]
=? old-state ?=(%2 -.old-state)
%- (slog leaf+"upgrading eth-watcher from %2" ~)
^- app-state
%= old-state
- %3
dogs
%- ~(run by dogs.old-state)
|= dog=watchdog-1
%= dog
-> [| ->.dog]
==
==
::
[cards-1 this(state ?>(?=(%3 -.old-state) old-state))]
::
+$ app-states
$%(app-state-0 app-state-1 app-state)
$%(app-state-0 app-state-1 app-state-2 app-state)
::
+$ app-state-2
$: %2
dogs=(map path watchdog-1)
==
::
+$ app-state-1
$: %1
dogs=(map path watchdog)
dogs=(map path watchdog-1)
==
::
+$ watchdog-1
$: config-1
running=(unit =tid:spider)
=number:block
=pending-logs
=history
blocks=(list block)
==
::
+$ config-1
$: url=@ta
refresh-rate=@dr
from=number:block
contracts=(list address:ethereum)
=topics
==
::
+$ app-state-0
@ -218,6 +253,9 @@
::
[%x %dogs ~]
``noun+!>(~(key by dogs.state))
::
[%x %dogs %configs ~]
``noun+!>((~(run by dogs.state) |=(=watchdog -.watchdog)))
==
::
++ on-agent

View File

@ -4,6 +4,7 @@
|%
+$ config
$: url=@ta
eager=?
refresh-rate=@dr
from=number:block
contracts=(list address:ethereum)

View File

@ -77,8 +77,11 @@
$% $: %a :: to %ames
$>(%plea task:able:ames) :: send request message
== ::
$: %g :: to self
$>(%deal task:able:gall) :: set ethereum source
$: %b :: to %behn
$>(%wait task:able:behn) :: set timer
== ::
$: %g :: to %gall
$>(%deal task:able:gall) :: talk to app
== ::
$: %j :: to self
$>(%listen task) :: set ethereum source
@ -91,11 +94,14 @@
:: ::
+$ sign :: in result $<-
$~ [%a %done ~] ::
$% $: %a
$% $: %a ::
$% $>(%boon gift:able:ames) :: message response
$>(%done gift:able:ames) :: message (n)ack
$>(%lost gift:able:ames) :: lost boon
== ==
== == ::
$: %b ::
$>(%wake gift:able:behn) ::
== ::
$: %g ::
$> $? %onto ::
%unto ::
@ -298,7 +304,7 @@
(~(gas by points) spon-points)
=. +>.$
%- curd =< abet
(public-keys:~(feel su hen our pki etn) %full points)
(public-keys:~(feel su hen our now pki etn) %full points)
::
:: start subscriptions
::
@ -310,16 +316,16 @@
?- (clan:title our)
%czar
%- curd =< abet
(sources:~(feel su hen our pki etn) ~ [%| %azimuth-tracker])
(sources:~(feel su hen our now pki etn) ~ [%| %azimuth-tracker])
::
*
=. +>.$
%- curd =< abet
%+ sources:~(feel su hen our pki etn)
%+ sources:~(feel su hen our now pki etn)
(silt (turn spon-points head))
[%| %azimuth-tracker]
%- curd =< abet
(sources:~(feel su hen our pki etn) ~ [%& (need spon-ship)])
(sources:~(feel su hen our now pki etn) ~ [%& (need spon-ship)])
==
::
=. moz
@ -388,7 +394,7 @@
%listen
~& [%jael-listen whos source]:tac
%- curd =< abet
(sources:~(feel su hen our pki etn) [whos source]:tac)
(sources:~(feel su hen our now pki etn) [whos source]:tac)
::
:: cancel all trackers from duct
:: {$nuke whos=(set ship)}
@ -420,7 +426,7 @@
::
%rekey
%- curd =< abet
(private-keys:~(feel su hen our pki etn) life.tac ring.tac)
(private-keys:~(feel su hen our now pki etn) life.tac ring.tac)
::
:: update private keys
::
@ -432,14 +438,14 @@
~& [%not-our-moon ship.tac]
+>.$
%- curd =< abet
(~(new-event su hen our pki etn) [ship udiff]:tac)
(~(new-event su hen our now pki etn) [ship udiff]:tac)
::
:: watch public keys
:: [%public-keys ships=(set ship)]
::
%public-keys
%- curd =< abet
(~(public-keys ~(feed su hen our pki etn) hen) ships.tac)
(~(public-keys ~(feed su hen our now pki etn) hen) ships.tac)
::
:: seen after breach
:: [%meet our=ship who=ship]
@ -475,7 +481,7 @@
:: {$private-keys $~}
::
%private-keys
(curd abet:~(private-keys ~(feed su hen our pki etn) hen))
(curd abet:~(private-keys ~(feed su hen our now pki etn) hen))
::
%wegh
%_ +>
@ -529,13 +535,26 @@
[%a %boon *]
=+ ;; [%public-keys-result =public-keys-result] payload.hin
%- curd =< abet
(public-keys:~(feel su hen our pki etn) public-keys-result)
(public-keys:~(feel su hen our now pki etn) public-keys-result)
::
[%a %lost *]
:: TODO: better error handling
::
~| %jael-ames-lost
!!
::
[%b %wake *]
?^ error.hin
%- %+ slog
leaf+"jael unable to resubscribe, run :azimuth-tracker|listen"
u.error.hin
+>.$
?> ?=([%breach @ ~] tea)
=/ =source-id (slav %ud i.t.tea)
=/ =source (~(got by sources.etn) source-id)
=/ ships (~(get ju ship-sources-reverse.etn) source-id)
%- curd =< abet
(sources:~(feel su hen our now pki etn) ships source)
::
[%g %onto *]
~& [%jael-onto tea hin]
@ -561,7 +580,7 @@
=* app i.tea
=/ =peer-sign ;;(peer-sign q.q.cage.p.+>.hin)
%- curd =< abet
(~(new-event su hen our pki etn) peer-sign)
(~(new-event su hen our now pki etn) peer-sign)
==
==
:: :: ++curd:of
@ -587,14 +606,15 @@
=| moz=(list move)
=| $: hen=duct
our=ship
now=@da
state-pki
state-eth-node
==
:: moz: moves in reverse order
:: pki: relative urbit state
::
=* pki ->+<
=* etn ->+>
=* pki ->+>-
=* etn ->+>+
|%
++ this-su .
:: :: ++abet:su
@ -811,9 +831,18 @@
?& ?=(^ point)
(gth rift.point.i.pointl rift.u.point)
==
=. ..feel
%+ public-keys-give
(subscribers-on-ship who.i.pointl)
[%breach who.i.pointl]
=/ sor (~(get by sources-reverse) %& who.i.pointl)
?~ sor
..feel
:: delay resubscribing because Ames is going to clear any
:: messages we send now.
::
(emit hen %pass /breach/(scot %ud u.sor) %b %wait now)
::
=. ..feel
%+ public-keys-give
(subscribers-on-ship who.i.pointl)

View File

@ -15,6 +15,8 @@
;< =latest=block bind:m (get-latest-block:ethio url.pup)
;< pup=watchpup bind:m (zoom pup number.id.latest-block)
=| vows=disavows
?. eager.pup
(pure:m !>([vows pup]))
|- ^- form:m
=* loop $
?: (gth number.pup number.id.latest-block)
@ -72,7 +74,7 @@
::
:: Zooming doesn't go forward one block at a time. As a
:: consequence, it cannot detect and handle reorgs. Only use it
:: at a safe distance -- 500 blocks ago is probably sufficient.
:: at a safe distance -- 100 blocks ago is probably sufficient.
::
++ zoom
|= [pup=watchpup =latest=number:block]