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

jael: give new private key to subscribers on %keys new-event #5532

Merged
merged 39 commits into from Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
144065c
roller-rpc: add %get-remaining-quota
yosoyubik Nov 22, 2021
528a046
roller: add to state ship allowance and next-slice
yosoyubik Nov 23, 2021
2e94a0d
azimuth, dice: simplify index update
yosoyubik Nov 24, 2021
8c8aef9
dice: include nas when rolling over tx-effects
yosoyubik Nov 25, 2021
d5c4459
roller: refactor and clean up
yosoyubik Nov 28, 2021
ad16155
azimuth: load azimuth state from state snapshot
yosoyubik Dec 3, 2021
d08ab43
lull: skip rift/life printf when booting
yosoyubik Dec 6, 2021
81eb6ae
pill: add azimuth snapshot
yosoyubik Dec 7, 2021
0833ee9
azimuth: only print number of points during init
yosoyubik Dec 7, 2021
33852ea
roller: support private keys with leading 0x
yosoyubik Dec 7, 2021
28dacad
Merge branch 'roller/quota-left' into naive/snapshot
yosoyubik Dec 7, 2021
463ca6e
roller: set default quota to 25
yosoyubik Dec 8, 2021
1e912d1
Merge branch 'roller/quota-left' into naive/snapshot
yosoyubik Dec 8, 2021
37adba1
various: update to new udiff:point type
yosoyubik Dec 8, 2021
cce1469
azimuth: update log message
yosoyubik Dec 8, 2021
fb2c078
pill: load azimuth snapshot as mime in file-ovum
yosoyubik Dec 9, 2021
4384f19
azimuth: use ship as prefix for loading snapshot log
yosoyubik Dec 9, 2021
ae05bbf
roller: don't crash if nonce not in queue
yosoyubik Dec 9, 2021
c467d5a
Merge branch 'roller/quota-left' into naive/snapshot
yosoyubik Dec 9, 2021
f6ff4f1
roller: add utilities for handling low-gas batches
yosoyubik Dec 10, 2021
fd2ff95
roller: fix refuel generator
yosoyubik Dec 10, 2021
f6dca03
pill: restore solid pill
yosoyubik Dec 10, 2021
8601b13
azimuth: remove unused import in snapshot mark
yosoyubik Dec 10, 2021
92c498c
Merge branch 'naive/snapshot' into roller/gas-price
yosoyubik Dec 10, 2021
0c7ada2
roller: fix response parsing from gasoracle
yosoyubik Dec 13, 2021
4724c32
pill: load azimuth snapshot file with mime mark
yosoyubik Dec 14, 2021
d1a04c7
Merge branch 'naive/snapshot' into roller/gas-price
yosoyubik Dec 14, 2021
fc540bf
roller: handle sending malformed batches
yosoyubik Dec 14, 2021
1b278ce
dice: dont print %failed logs in tx-effects
yosoyubik Dec 14, 2021
d0309ab
roller: get suggested gas price only for mainnet
yosoyubik Dec 14, 2021
5d4a410
roller: don't set :frequency timer on commit
yosoyubik Dec 14, 2021
1bda134
azimuth: update /app/azimuth snapshot
yosoyubik Dec 15, 2021
8df443b
azimuth: remove eth-logs
yosoyubik Jan 6, 2022
1950736
azimuth: update snapshot at block 13.958.653
yosoyubik Jan 7, 2022
583d5f5
azimuth: process snapshot on-load
yosoyubik Jan 7, 2022
8535563
jael: give private key to subscribers on keys diff
yosoyubik Jan 8, 2022
fccf99e
jael: refactor new-event for %keys diff
yosoyubik Jan 8, 2022
d71074e
pill: update solid
yosoyubik Jan 8, 2022
432d967
jael: don't put conflicting this-su in the subject
yosoyubik Jan 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/solid.pill
Git LFS file not shown
4 changes: 2 additions & 2 deletions pkg/arvo/app/azimuth-tracker.hoon
Expand Up @@ -54,13 +54,13 @@
?: =(broke-continuity i.topics.event-log)
=/ who=@ (decode-topics t.topics.event-log ~[%uint])
=/ num=@ (decode-results data.event-log ~[%uint])
`[who id %rift num]
`[who id %rift num %.n]
?: =(changed-keys i.topics.event-log)
=/ who=@ (decode-topics t.topics.event-log ~[%uint])
=/ [enc=octs aut=octs sut=@ud rev=@ud]
%+ decode-results data.event-log
~[[%bytes-n 32] [%bytes-n 32] %uint %uint]
`[who id %keys rev sut (pass-from-eth:azimuth enc aut sut)]
`[who id %keys [rev sut (pass-from-eth:azimuth enc aut sut)] %.n]
?: =(lost-sponsor i.topics.event-log)
=/ [who=@ pos=@]
(decode-topics t.topics.event-log ~[%uint %uint])
Expand Down
198 changes: 113 additions & 85 deletions pkg/arvo/app/azimuth.hoon
Expand Up @@ -7,24 +7,21 @@
verb,
dbug
:: Generally don't update the snapshot until we have clay tombstoning.
:: To update, run:
:: =e -build-file %/lib/ethereum/hoon
:: =l .^((list event-log:rpc:e) %gx /=azimuth=/logs/noun)
:: */app/azimuth/logs/eth-logs &eth-logs l
::
/* snap %eth-logs /app/azimuth/logs/eth-logs
/* snap %azimuth-snapshot /app/azimuth/version-0/azimuth-snapshot
:: To update, run from dojo:
:: -azimuth-snap-state %default 'version-0'
::
=/ last-snap :: maybe just use the last one?
%+ roll `(list event-log:rpc:ethereum)`snap ::~
|= [log=event-log:rpc:ethereum last=@ud]
?~ mined.log
last
(max block-number.u.mined.log last)
:: 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
$: %2
$: %4
url=@ta
=net
whos=(set ship)
Expand Down Expand Up @@ -62,8 +59,14 @@
::
++ on-init
^- (quip card _this)
=/ points=@ud ~(wyt by points.nas.snap)
%- %- slog
[leaf+"ship: loading azimuth snapshot ({<points>} points)"]~
::
=: net.state %default
logs.state snap
nas.state nas.snap
own.state owners.snap
spo.state sponsors.snap
url.state 'http://eth-mainnet.urbit.org:8545'
==
:_ this
Expand All @@ -89,18 +92,49 @@
?. ?=(%1 -.old-state)
`old-state
%- %- slog :_ ~
leaf+"azimuth: loading snapshot with {<(lent logs.old-state)>} events"
leaf+"ship: loading snapshot with {<(lent logs.old-state)>} events"
=. +.state +.old-state
=^ cards state
(%*(run-logs do nas.state *^state:naive) logs.state)
[(jael-update:do (to-udiffs:do cards)) state]
?> ?=(%2 -.old-state)
[cards-1 this(state old-state)]
=^ cards-2 old-state
?. ?=(%2 -.old-state)
`old-state
~& > '%azimuth: updating to state 3'
=. +.state +.old-state
:: replace naive state and indices with snapshot
::
=: nas.state nas.snap
own.state owners.snap
spo.state sponsors.snap
logs.state ~
:: TODO: shouldn't be needed but have seen eth-watcher
:: threads use a url='' if this is not used
::
url.state 'http://eth-mainnet.urbit.org:8545'
==
=/ 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)
:_ [%3 +.state]
%+ weld
(jael-update:do snap-cards)
:: start getting new logs after the last id:block in the snapshot
::
start:do
=^ cards-3 old-state
?. ?=(%3 -.old-state) [cards-2 old-state]
:_ old-state(- %4)
~& > '%azimuth: updating to state 4'
[%pass /resend-pk %arvo %j %resend ~]^cards-2
?> ?=(%4 -.old-state)
[cards-3 this(state old-state)]
::
++ app-states $%(state-0 state-1 app-state)
++ app-states $%(state-0 state-1-2-3 app-state)
::
+$ state-1
$: %1
+$ state-1-2-3
$: ?(%1 %2 %3)
url=@ta
=net
whos=(set ship)
Expand All @@ -126,12 +160,13 @@
^- (quip card _this)
?: =(%noun mark)
?+ q.vase !!
::
%rerun
~& [%rerunning (lent logs.state)]
=. points.nas.state ~
=. own.state ~
=^ * state (run-logs:do logs.state)
`this
=/ points=@ud ~(wyt by points.nas.state)
~& > "rerunning ({<points>} points)"
=/ =udiffs:point
(run-state:do (last-block-id:dice logs.state) points.nas.state)
[(jael-update:do udiffs) this]
::
%resub
:_ this :_ ~
Expand All @@ -140,13 +175,12 @@
==
::
%resnap
=. logs.state snap
$(mark %noun, vase !>(%rerun))
=: nas.state nas.snap
own.state owners.snap
spo.state sponsors.snap
==
`this
==
?: =(%eth-logs mark)
=+ !<(logs=(list event-log:rpc:ethereum) vase)
=. logs.state logs
$(mark %noun, vase !>(%rerun))
::
?. ?=(%azimuth-poke mark)
(on-poke:def mark vase)
Expand All @@ -159,12 +193,12 @@
:: TODO: only wipe out state when switching networks?
:: ?: =(net.state net.poke)
:: [~ this]
=: nas.state *^state:naive
=: nas.state ?:(?=(%default net.poke) nas.snap *^state:naive)
own.state ?:(?=(%default net.poke) owners.snap ~)
spo.state ?:(?=(%default net.poke) sponsors.snap ~)
net.state net.poke
url.state url.poke
own.state ~
spo.state ~
logs.state ?:(?=(%default net.poke) snap ~)
logs.state ~
==
[start:do this]
==
Expand All @@ -188,11 +222,13 @@
:: Slow to recalculate all the diffs, but this is necessary to make
:: sure Jael gets the updates from the snapshot
::
=/ points=@ud ~(wyt by points.nas.state)
%- %- slog :_ ~
leaf+"azimuth: loading snapshot with {<(lent logs.state)>} events"
=^ snap-cards state
(%*(run-logs do nas.state *^state:naive) logs.state)
[(weld (jael-update:do (to-udiffs:do snap-cards)) start:do) this]
:- %leaf
"ship: processing azimuth snapshot ({<points>} points)"
=/ snap-cards=udiffs:point
(%*(run-state do logs.state ~) id.snap points.nas.state)
[(weld (jael-update:do snap-cards) start:do) this]
::
++ on-leave on-leave:def
++ on-peek
Expand Down Expand Up @@ -237,9 +273,13 @@
%history (welp logs.state loglist.diff)
%logs (welp logs.state loglist.diff)
==
=? nas.state ?=(%history -.diff) *^state:naive
=^ effects state (run-logs:do loglist.diff)
:: doing :azimuth|watch caused a l2-sig-fail when using the eth-log
:: snapshot because we were not updating nas with the saved logs.
::
:: now (L: 189) nas.state is loaded with the contents of the snapshot,
:: if we are on the %default network.
::
=^ effects state (run-logs:do loglist.diff)
:_ this
%+ weld
(event-update:do effects)
Expand Down Expand Up @@ -287,16 +327,27 @@
^- (list ?(@ux (list @ux)))
~
::
++ data-to-hex
|= data=@t
?~ data *@ux
?: =(data '0x') *@ux
(hex-to-num:ethereum data)
++ run-state
|= [=id:block =points:naive]
::%- road |. :: count memory usage in a separate road
^- =udiffs:point
%- flop
%+ roll (tap:orp:dice points)
|= [[=ship naive-point=point:naive] =udiffs:point]
=, naive-point
=/ =pass
(pass-from-eth:azimuth [32^crypt 32^auth suite]:keys.net)
^- (list [@p udiff:point])
:* [ship id %rift rift.net %.y]
[ship id %keys [life.keys.net suite.keys.net pass] %.y]
[ship id %spon ?:(has.sponsor.net `who.sponsor.net ~)]
udiffs
==
::
++ run-logs
|= [logs=(list event-log:rpc:ethereum)]
^- (quip tagged-diff _state)
=+ net=(get-network net.state)
=+ net=(get-network:dice net.state)
=| effects=(list tagged-diff)
!. :: saves 700MB replaying snapshot
=- =/ res (mule -)
Expand All @@ -309,40 +360,29 @@
[(flop effects) state]
?~ mined.i.logs
$(logs t.logs)
=/ [raw-effects=effects:naive new-nas=_nas.state]
=+ cache=nas.state
=^ raw-effects nas.state
=/ =^input:naive
:- block-number.u.mined.i.logs
?: =(azimuth.net address.i.logs)
=/ data (data-to-hex data.i.logs)
=/ data (data-to-hex:dice data.i.logs)
=/ =event-log:naive
[address.i.logs data topics.i.logs]
[%log event-log]
?~ input.u.mined.i.logs
[%bat *@]
[%bat u.input.u.mined.i.logs]
(%*(. naive lac |) verifier chain-id.net nas.state input)
:: TODO: move to /lib/dice ?
:: TODO: make index update optional?
::
=/ [new-own=_own.state new-spo=_spo.state]
=< [own spo]
?. =(azimuth.net address.i.logs)
%: apply-effects:dice
chain-id.net
raw-effects
nas.state
own.state
spo.state
==
%: update-indices:dice
raw-effects
nas.state
new-nas
own.state
spo.state
==
=: nas.state new-nas
own.state new-own
spo.state new-spo
=/ =indices [own spo]:state
=. indices
?: =(naive.net address.i.logs)
(tx-effects:dice chain-id.net raw-effects cache indices)
=< indices
(point-effects:dice raw-effects points.cache points.nas.state indices)
=: own.state own.indices
spo.state spo.indices
==
=/ effects-1
=/ =id:block [block-hash block-number]:u.mined.i.logs
Expand All @@ -358,12 +398,12 @@
^- (unit [=ship =udiff:point])
?. ?=(%point +<.tag) ~
?+ +>+<.tag ~
%rift `[ship.tag id.tag %rift rift.tag]
%rift `[ship.tag id.tag %rift rift.tag %.n]
%sponsor `[ship.tag id.tag %spon sponsor.tag]
%keys
=/ =pass
(pass-from-eth:azimuth 32^crypt.keys.tag 32^auth.keys.tag suite.keys.tag)
`[ship.tag id.tag %keys life.keys.tag suite.keys.tag pass]
`[ship.tag id.tag %keys [life.keys.tag suite.keys.tag pass] %.n]
==
::
++ jael-update
Expand Down Expand Up @@ -391,26 +431,14 @@
^- card
[%give %fact ~[/event] %naive-diffs !>(+.tag)]
::
++ get-network
|= =net
^- [azimuth=@ux naive=@ux chain-id=@ launch=@]
=< [azimuth naive chain-id launch]
=, azimuth
?- net
%mainnet mainnet-contracts
%ropsten ropsten-contracts
%local local-contracts
%default contracts
==
::
++ start
^- (list card)
=+ net=(get-network net.state)
=+ net=(get-network:dice net.state)
=/ args=vase !>
:+ %watch /[dap.bowl]
^- config:eth-watcher
:* url.state =(%czar (clan:title our.bowl)) refresh ~h30
(max launch.net ?:(=(net.state %default) last-snap 0))
(max launch.net ?:(=(net.state %default) +(last-snap) 0))
~[azimuth.net]
~[naive.net]
(topics whos.state)
Expand Down
Binary file removed pkg/arvo/app/azimuth/logs.eth-logs
Binary file not shown.
Binary file added pkg/arvo/app/azimuth/version-0.azimuth-snapshot
Binary file not shown.