From 212b5879fd3ffb48a8fde175e4805d96157051d0 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Wed, 21 Aug 2019 22:28:31 -0700 Subject: [PATCH] dawn.c: produce full sponsor chain keys --- bin/ivory.pill | 4 +- bin/solid.pill | 4 +- pkg/arvo/sys/zuse.hoon | 42 +++++++++++------ pkg/urbit/vere/dawn.c | 105 ++++++++++++++++++++++++++--------------- 4 files changed, 98 insertions(+), 57 deletions(-) diff --git a/bin/ivory.pill b/bin/ivory.pill index 616264ee1..5f78e1dfd 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6e828e89f4e6f2b39d4d8d62101f9c052253cdfa4e91abb8682678acd796f999 -size 4707549 +oid sha256:43fe5bd4c7437c027eba746f6d04e03ce39372f06429a66d1fe4839de331196f +size 4955047 diff --git a/bin/solid.pill b/bin/solid.pill index 43723134b..dae07e4d0 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c6ca3b56982d9ff6c1fb5b42b94c2d9e689436f364b90f08c3e96a52961ddb5e -size 12486405 +oid sha256:8e28039e2f563abd8eadd42e3e3fcff3a8d66aea8809caaa2cbf6427ed57176b +size 12588345 diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 0f1588e7a..e319faa03 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -8978,7 +8978,7 @@ :: ++ veri |= [=seed:able:jael =point:azimuth =live] - ^- (each sponsor=ship error=term) + ^- (unit error=term) =/ rac (clan:title who.seed) =/ cub (nol:nu:crub:crypto key.seed) ?- rac @@ -8986,39 +8986,35 @@ :: a comet address is the fingerprint of the keypair :: ?. =(who.seed `@`fig:ex:cub) - [%| %key-mismatch] + `%key-mismatch :: a comet can never be breached :: ?^ live - [%| %already-booted] + `%already-booted :: a comet can never be re-keyed :: ?. ?=(%1 lyf.seed) - [%| %invalid-life] - [%& (^sein:title who.seed)] + `%invalid-life + ~ :: %earl - :: the parent must be launched - :: - ?~ net.point - [%| %parent-not-keyed] - [%& (^sein:title who.seed)] + ~ :: * :: on-chain ships must be launched :: ?~ net.point - [%| %not-keyed] + `%not-keyed =* net u.net.point :: boot keys must match the contract :: ?. =(pub:ex:cub pass.net) ~& [%key-mismatch pub:ex:cub pass.net] - [%| %key-mismatch] + `%key-mismatch :: life must match the contract :: ?. =(lyf.seed life.net) - [%| %life-mismatch] + `%life-mismatch :: the boot life must be greater than and discontinuous with :: the last seen life (per the sponsor) :: @@ -9026,12 +9022,28 @@ ?| ?=(%| breach.u.live) (lte life.net life.u.live) == == - [%| %already-booted] + `%already-booted :: produce the sponsor for vere :: ~? !has.sponsor.net [%no-sponsorship-guarantees-from who.sponsor.net] - [%& who.sponsor.net] + ~ + == + :: +sponsor:dawn: retreive sponsor from point + :: + ++ sponsor + |= [who=ship =point:azimuth] + ^- (each ship error=term) + ?- (clan:title who) + %pawn [%& (^sein:title who)] + %earl [%& (^sein:title who)] + %czar [%& (^sein:title who)] + * + ?~ net.point + [%| %not-booted] + ?. has.sponsor.u.net.point + [%| %no-sponsor] + [%& who.sponsor.u.net.point] == -- -- :: diff --git a/pkg/urbit/vere/dawn.c b/pkg/urbit/vere/dawn.c index e059a03ab..d567f1e5f 100644 --- a/pkg/urbit/vere/dawn.c +++ b/pkg/urbit/vere/dawn.c @@ -295,6 +295,25 @@ _dawn_turf(c3_c* dns_c) return tuf; } +/* _dawn_sponsor(): retrieve sponsor from point +*/ +static u3_noun +_dawn_sponsor(u3_noun who, u3_noun rac, u3_noun pot) +{ + u3_noun uni = u3dc("sponsor:dawn", u3k(who), u3k(pot)); + + if ( c3n == u3h(uni) ) { + _dawn_fail(who, rac, uni); + return u3_none; + } + + u3_noun pos = u3k(u3t(uni)); + + u3z(who); u3z(rac); u3z(pot); u3z(uni); + + return pos; +} + /* u3_dawn_vent(): validated boot event */ u3_noun @@ -302,7 +321,7 @@ u3_dawn_vent(u3_noun seed) { u3_noun url, bok, pos, pon, zar, tuf; - u3_noun ship = u3h(seed); + u3_noun ship = u3k(u3h(seed)); u3_noun rank = u3do("clan:title", u3k(ship)); url = _dawn_purl(rank); @@ -336,27 +355,15 @@ u3_dawn_vent(u3_noun seed) // pot = u3v_wish("*point:azimuth"); } + else if ( c3__earl == rank ) { + pot = u3v_wish("*point:azimuth"); + } else { u3_noun who; - if ( c3__earl == rank ) { - who = u3do("^sein:title", u3k(ship)); - - { - u3_noun seg = u3dc("scot", 'p', u3k(who)); - c3_c* seg_c = u3r_string(seg); - - u3l_log("boot: retrieving %s's public keys (for %s)\r\n", - seg_c, u3_Host.ops_u.who_c); - free(seg_c); - u3z(seg); - } - } - else { - who = u3k(ship); - u3l_log("boot: retrieving %s's public keys\r\n", - u3_Host.ops_u.who_c); - } + who = u3k(ship); + u3l_log("boot: retrieving %s's public keys\r\n", + u3_Host.ops_u.who_c); { u3_noun oct = u3dc("point:give:dawn", u3k(bok), u3k(who)); @@ -382,21 +389,18 @@ u3_dawn_vent(u3_noun seed) // u3_noun sas = u3dt("veri:dawn", u3k(seed), u3k(pot), u3k(liv)); - if ( c3n == u3h(sas) ) { + if ( u3_nul != sas ) { // bails, won't return _dawn_fail(ship, rank, sas); return u3_none; } - // ship: sponsor - // produced by +veri:dawn to avoid coupling to +point structure - // XX reconsider - // - pos = u3k(u3t(sas)); - - u3z(pot); u3z(liv); u3z(sas); + u3l_log("boot: getting sponsor\r\n"); + pos = _dawn_sponsor(u3k(ship), u3k(rank), u3k(pot)); + u3z(pot); u3z(liv); } + // (map ship [=life =pass]): galaxy table // { @@ -426,22 +430,47 @@ u3_dawn_vent(u3_noun seed) u3z(oct); u3z(fut); } - { - u3l_log("boot: retrieving sponsor keys\r\n"); + pon = u3_nul; + while (c3__czar != rank) { + u3_noun son; + // print message + // + { + u3_noun who = u3dc("scot", 'p', u3k(pos)); + c3_c* who_c = u3r_string(who); + u3l_log("boot: retrieving keys for sponsor %s\r\n", who_c); + u3z(who); + free(who_c); + } - u3_noun oct = u3dc("point:give:dawn", u3k(bok), u3k(pos)); - u3_noun luh = _dawn_eth_rpc(url_c, u3k(oct)); + // retrieve +point:azimuth of pos (sponsor of ship) + // + { + u3_noun oct = u3dc("point:give:dawn", u3k(bok), u3k(pos)); + u3_noun luh = _dawn_eth_rpc(url_c, u3k(oct)); - pon = _dawn_need_unit(u3dc("point:take:dawn", u3k(pos), u3k(luh)), - "boot: failed to retrieve sponsor keys"); - pon = u3nc(pos, pon); - u3z(oct); u3z(luh); + son = _dawn_need_unit(u3dc("point:take:dawn", u3k(pos), u3k(luh)), + "boot: failed to retrieve sponsor keys"); + + // append to sponsor chain list + // + pon = u3nc(u3nc(u3k(pos), u3k(son)), pon); + u3z(oct); u3z(luh); + } + + // find next sponsor + // + u3z(ship); u3z(rank); + ship = pos; + rank = u3do("clan:title", u3k(ship)); + pos = _dawn_sponsor(u3k(ship), u3k(rank), u3k(son)); + + u3z(son); } + u3z(rank); u3z(pos); u3z(ship); - u3z(rank); - - // [%dawn seed sponsor galaxies domains block eth-url snap] + // [%dawn seed sponsors galaxies domains block eth-url snap] // return u3nc(c3__dawn, u3nq(seed, pon, zar, u3nt(tuf, bok, url))); }