Merge pull request #795 from urbit/jael-continuity

Constitution + jael updates
This commit is contained in:
Fang 2018-08-30 02:44:05 +02:00 committed by GitHub
commit 15ee6ba31d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 111 additions and 57 deletions

View File

@ -61,7 +61,7 @@
== ::
$= puk :: public keys (pubs)
$: yen=(jug ship duct) :: trackers
kyz=(map ship (map life pass)) :: public key versions
kyz=(map ship public) :: public key state
== ::
$= eth :: ethereum (vent)
::TODO the subscribers here never hear dns or hul...
@ -706,6 +706,13 @@
%- curd =< abet
(~(pubs ~(feed su our.tac urb sub etn) hen) who.tac)
::
:: seen after breach
:: [%meet our=ship who=ship]
::
%meet
%+ cure our.tac
[[%meet who.tac]~ urb]
::
:: watch private keys
:: {$vein $~}
::
@ -866,6 +873,7 @@
+>
?- -.i.hab
%ethe (file can.i.hab)
%meet (meet +.i.hab)
%rite (paid +.i.hab)
==
==
@ -900,11 +908,10 @@
++ pubs
|= who=ship
%_ ..feed
moz =/ zen (~(get by kyz.puk) who)
?~ zen moz
=/ lyf (roll ~(tap in ~(key by u.zen)) max)
?: =(0 lyf) moz
[[hen %give %pubs lyf u.zen] moz]
moz =/ pub (~(get by kyz.puk) who)
?~ pub moz
?: =(0 life.u.pub) moz
[[hen %give %pubs u.pub] moz]
yen.puk (~(put ju yen.puk) who hen)
==
:: :: ++vein:feed:su
@ -933,33 +940,25 @@
|%
:: :: ++pubs:feel:su
++ pubs :: kick public keys
|= kez=(map ship (map life pass))
=/ kes ~(tap by kez)
:: puz: new public key states
|= puz=(map ship public)
=/ pus ~(tap by puz)
::
:: process change for each ship separately
::
|- ^+ ..feel
?~ kes ..feel
=; fel $(kes t.kes, ..feel fel)
=* who p.i.kes
=* kyn q.i.kes
=/ lyf (roll ~(tap in ~(key by kyn)) max)
::
:: build new public key store
::
=+ %+ ~(put by kyz.puk) who
=- (~(uni by -) kyn)
(fall (~(get by kyz.puk) who) ~)
?~ pus ..feel
=; fel $(pus t.pus, ..feel fel)
=* who p.i.pus
=* pub q.i.pus
::
:: update public key store and notify subscribers
:: of the change
:: of the new state
::
:: XX we're sending a map here, but it only contains the update
:: send full key history? or use [%pubs =life =pass]
::
%+ exec(kyz.puk -)
~& [%sending-pubs-about who]
%+ exec(kyz.puk (~(put by kyz.puk) who pub))
(~(get ju yen.puk) who)
[%give %pubs lyf kyn]
[%give %pubs pub]
:: :: ++vein:feel:su
++ vein :: kick private keys
^+ ..feel
@ -1063,36 +1062,62 @@
::
?. (~(exists up mor.del) %jewel) +>
vein:feel
::
++ file
:: :: ++meet:su
++ meet :: seen after breach
|= who=ship
^+ +>
=+ ~| [%met-unknown-ship who]
(~(got by kyz.puk) who)
(pubs:feel [[who -(live &)] ~ ~])
:: :: ++file:su
++ file :: process event logs
::TODO whenever we add subscriptions for data,
:: outsource the updating of relevant state
:: to a ++feel arm.
|= [new=? evs=logs]
^+ +>
=? +> new
::TODO should we be mutating state here,
:: or better to move this into ++vent:feel?
+>(dns.eth *dnses, hul.eth ~, kyz.puk ~)
=? +> |(new !=(0 ~(wyt by evs)))
%- vent:feel
?:(new &+evs |+evs)
::
=+ vez=(order-events:ez ~(tap by evs))
=| kyz=(map ship (map life pass))
=| kyz=(map ship public)
|^ ?~ vez (pubs:feel kyz)
=^ kyn ..file (file-event i.vez)
$(vez t.vez, kyz kyn)
::
++ get-public
|= who=ship
^- public
%+ fall (~(get by kyz) who)
::NOTE we can only do this because ++pubs:feel
:: sends out entire new state, rather than
:: just the processed changes.
%+ fall (~(get by kyz.puk) who)
%*(. *public live |)
::
++ file-keys
|= [who=ship =life =pass]
^+ kyz
=/ zen (fall (~(get by kyz) who) ~)
=/ pub (~(get by zen) life)
?~ pub
%+ ~(put by kyz)
who
(~(put by zen) life pass)
~| [%key-mismatch who life]
?>(=(u.pub pass) kyz)
=/ pub (get-public who)
=/ puk (~(get by pubs.pub) life)
?^ puk
:: key known, nothing changes
~| [%key-mismatch who life]
?>(=(u.puk pass) kyz)
%+ ~(put by kyz) who
:+ live.pub
(max life life.pub)
(~(put by pubs.pub) life pass)
::
++ file-discontinuity
|= who=ship
=+ (get-public who)
(~(put by kyz) who -(live |))
::
++ file-event
|= [wer=event-id dif=diff-constitution]
@ -1117,19 +1142,19 @@
|= [who=ship dif=diff-hull]
^+ [kyz ..file]
=- ::TODO =; with just the type
:- ?~ kez kyz
(file-keys who u.kez)
:- ?: ?=(%& -.new)
(file-keys who p.new)
?: p.new kyz
(file-discontinuity who)
..file(hul.eth (~(put by hul.eth) who hel))
^- [hel=hull kez=(unit (pair life pass))]
:: hel: updated hull
:: new: new keypair or "kept continuity?" (yes is no-op)
^- [hel=hull new=(each (pair life pass) ?)]
=+ hul=(fall (~(get by hul.eth) who) *hull)
::
:: if new, first dif must be %full
:: XX review, requirement seems obsolete
::
:: ?> |((~(has by hul.eth) who) ?=(%full -.dif))
::
:: sanity checks, should never fail if we operate correctly
::
~| %diff-order-insanity
?> ?+ -.dif &
%spawned ?> ?=(^ kid.hul)
!(~(has in spawned.u.kid.hul) who.dif)
@ -1139,14 +1164,16 @@
=(new.dif +(continuity-number.u.net.hul))
==
::
:: apply hull changes, catch key changes
:: apply hull changes, catch continuity and key changes
::
:- (apply-hull-diff hul dif)
?+ -.dif ~
%keys `[life pass]:dif
%full ?~ net.new.dif ~
::TODO do we want/need to do a diff-check
`[life pass]:u.net.new.dif
=* nop |+& :: no-op
?+ -.dif nop
%continuity |+|
%keys &+[life pass]:dif
%full ?~ net.new.dif nop
::TODO do we want/need to do a diff-check
&+[life pass]:u.net.new.dif
==
::
++ file-dns
@ -1488,9 +1515,11 @@
::
:: +| filter-results
::
:: +wake: kick polling
:: +wake: kick polling, unless we changed source
::
++ wake poll-filter
++ wake
?. ?=(%| -.source) .
poll-filter
::
:: +sigh: parse rpc response and process it
::

View File

@ -398,6 +398,16 @@
0xcfe3.69b7.197e.7f0c.f067.93ae.2472.a9b1.
3583.fecb.ed2f.78df.a14d.1f10.796b.847c
::
:: ChangedManager(address,address)
++ changed-manager
0x73cd.9f21.dac5.ada0.0bce.c622.ae57.b362.
3d62.867a.0104.48a4.fa99.19b1.af37.8de7
::
:: ChangedDelegate(address,address)
++ changed-delegate
0x3aca.0f3b.26ca.e754.a743.7b18.4417.8ce6.
07f2.1ca0.cbed.955e.0621.96d3.3c91.de6c
::
:: ChangedDns(string,string,string)
++ changed-dns
0xfafd.04ad.e1da.ae2e.1fdb.0fc1.cc6a.899f.
@ -1972,6 +1982,7 @@
logs :: | new events
++ change :: urbit change
$% [%ethe can=chain] :: on-chain change
[%meet who=ship] :: meet in new era
$: %rite :: rights change
rex/ship :: issuer
pal/ship :: issued to
@ -1979,7 +1990,7 @@
== == ::
++ gift :: out result <-$
$% [%mack p=(unit tang)] :: message n/ack
[%pubs =life pubs=(map life pass)] :: public keys
[%pubs public] :: public keys
{$vest p/tally} :: balance update
[%vein =life vein=(map life ring)] :: private keys
{$vine p/(list change)} :: all raw changes
@ -1993,6 +2004,11 @@
[%a %want p=sock q=path r=*] :: send message
[%j %vent-result p=chain] :: tmp workaround
== ::
++ public :: public key state
$: live=? :: seen in current era
life=life :: current key number
pubs=(map life pass) :: pubkeys by number
== ::
++ remote :: remote notification
%+ each safe :: &/addition
safe :: |/replacement
@ -2017,6 +2033,7 @@
::TODO %next for generating/putting new private key
[%nuke ~] :: cancel tracker from
[%pubs our=ship who=ship] :: view public keys
[%meet our=ship who=ship] :: met after breach
[%vein our=ship] :: view signing keys
[%vent our=ship] :: view ethereum events
[%vest our=ship] :: view public balance
@ -7655,7 +7672,6 @@
`[who %escape `wer]
::
?: =(event.log escape-canceled)
::TODO verify this is safe, topics are 2 uints
=/ who=@ (decode-topics topics.log ~[%uint])
`[who %escape ~]
::
@ -7690,9 +7706,18 @@
(decode-topics topics.log ~[%uint %address])
`[who %transfer-proxy tox]
::
::NOTE 0x8be0...57e0 is Owneable's OwnershipTransferred(address,address).
:: changed-dns is handled separately since it doesn't affect hulls.
~& [%unimplemented-event event.log]
~? ?!
?| =(event.log changed-manager)
::
=(event.log changed-delegate)
::
:: contract owner changed
.= event.log
:: OwnershipTransferred(address,address)
0x8be0.079c.5316.5914.1344.cd1f.d0a4.f284.
1949.7f97.22a3.daaf.e3b4.186f.6b64.57e0
==
[%unimplemented-event event.log]
~
::
++ apply-hull-diff