mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-28 11:40:11 +03:00
refactors |dawn (pre-boot validation)
adds comments, fixes moons, simplifies product type
This commit is contained in:
parent
535ab6e90b
commit
d9fa9a75c4
@ -1 +1 @@
|
||||
6e77aa110aa3776fed386f5bd8cf3a17d5c7e1bc
|
||||
f939b63ccae3bdf9040944858da4b1c2ccb04d45
|
@ -8009,46 +8009,66 @@
|
||||
::
|
||||
++ veri
|
||||
|= [=seed:able:jael =hull:constitution:ethe =live]
|
||||
^- $% [%& seed:able:jael (unit ship)]
|
||||
[%| rank:title @tas]
|
||||
==
|
||||
^- (each sponsor=(unit ship) error=term)
|
||||
=/ rac (clan:title who.seed)
|
||||
=/ cub (nol:nu:crub:crypto key.seed)
|
||||
?- rac
|
||||
%pawn
|
||||
:: a comet address is the fingerprint of the keypair
|
||||
::
|
||||
?. =(who.seed `@`fig:ex:cub)
|
||||
[%| rac %key-mismatch]
|
||||
[%| %key-mismatch]
|
||||
:: a comet can never be breached
|
||||
::
|
||||
?^ live
|
||||
[%| rac %already-booted]
|
||||
[%| %already-booted]
|
||||
:: a comet can never be re-keyed
|
||||
::
|
||||
?. ?=(%1 lyf.seed)
|
||||
[%| rac %invalid-life]
|
||||
[%& seed ~]
|
||||
[%| %invalid-life]
|
||||
[%& ~]
|
||||
::
|
||||
%earl
|
||||
:: a moon must be signed by the parent
|
||||
::
|
||||
?~ sig.seed
|
||||
[%| rac %missing-sig]
|
||||
[%| %missing-sig]
|
||||
:: the parent must be launched
|
||||
::
|
||||
?~ net.hull
|
||||
[%| rac %parent-not-keyed]
|
||||
=/ loy (com:nu:crub:crypto pass.u.net.hull)
|
||||
=/ hax (shaf %earl (sham lyf.seed pub:ex:cub))
|
||||
[%| %parent-not-keyed]
|
||||
=/ loy (com:nu:crub:crypto pass.u.net.hull)
|
||||
=/ hax (shaf %earl (sham who.seed lyf.seed pub:ex:cub))
|
||||
:: the signature must be valid
|
||||
::
|
||||
?. =((some hax) (sure:as:loy u.sig.seed))
|
||||
[%| rac %invalid-sig]
|
||||
:: XX revisit for rekey
|
||||
[%| %invalid-sig]
|
||||
:: XX revisit for rekey
|
||||
::
|
||||
?^ live
|
||||
[%| rac %already-booted]
|
||||
[%& seed ~]
|
||||
[%| %already-booted]
|
||||
[%& ~]
|
||||
::
|
||||
*
|
||||
:: on-chain ships must be launched
|
||||
::
|
||||
?~ net.hull
|
||||
[%| rac %not-keyed]
|
||||
[%| %not-keyed]
|
||||
:: boot keys must match the contract
|
||||
::
|
||||
?. =(pub:ex:cub pass.u.net.hull)
|
||||
[%| rac %key-mismatch]
|
||||
[%| %key-mismatch]
|
||||
:: the boot life must be greater than and discontinuous with
|
||||
:: the last seen life (per the sponsor)
|
||||
::
|
||||
?: ?& ?=(^ live)
|
||||
?| ?=(%| breach.u.live)
|
||||
(lte life.u.net.hull life.u.live)
|
||||
== ==
|
||||
[%| rac %already-booted]
|
||||
[%& seed sponsor.u.net.hull]
|
||||
[%| %already-booted]
|
||||
:: produce the sponsor for vere
|
||||
::
|
||||
[%& sponsor.u.net.hull]
|
||||
==
|
||||
--
|
||||
-- ::
|
||||
|
@ -153,30 +153,30 @@
|
||||
++ test-veri-good
|
||||
=/ sed [~zod 1 sec ~]
|
||||
%+ expect-eq
|
||||
!> [%& sed `~zod]
|
||||
!> [%& `~zod]
|
||||
!> (veri:dawn sed hul ~)
|
||||
::
|
||||
++ test-veri-not-spawned
|
||||
=/ sed [~zod 1 sec ~]
|
||||
%+ expect-eq
|
||||
!> [%| %czar %not-keyed]
|
||||
!> [%| %not-keyed]
|
||||
!> (veri:dawn sed =>(hul .(net ~)) ~)
|
||||
::
|
||||
++ test-veri-wrong-key
|
||||
=/ sed [~zod 1 sec:ex:(pit:nu:crub:crypto 24 %foo) ~]
|
||||
%+ expect-eq
|
||||
!> [%| %czar %key-mismatch]
|
||||
!> [%| %key-mismatch]
|
||||
!> (veri:dawn sed hul ~)
|
||||
::
|
||||
++ test-veri-already-booted
|
||||
=/ sed [~zod 1 sec ~]
|
||||
;: weld
|
||||
%+ expect-eq
|
||||
!> [%| %czar %already-booted]
|
||||
!> [%| %already-booted]
|
||||
!> (veri:dawn sed hul `[1 |])
|
||||
::
|
||||
%+ expect-eq
|
||||
!> [%| %czar %already-booted]
|
||||
!> [%| %already-booted]
|
||||
!> (veri:dawn sed hul `[2 &])
|
||||
==
|
||||
::
|
||||
@ -186,10 +186,10 @@
|
||||
=/ sed
|
||||
=/ sig
|
||||
%- sign:as:(nol:nu:crub:crypto sec)
|
||||
(shaf %earl (sham 1 pub:ex:cub))
|
||||
(shaf %earl (sham who 1 pub:ex:cub))
|
||||
[who 1 sec:ex:cub `sig]
|
||||
%+ expect-eq
|
||||
!> [%& sed ~]
|
||||
!> [%& ~]
|
||||
!> (veri:dawn sed hul ~)
|
||||
::
|
||||
++ test-veri-earl-missing-sig
|
||||
@ -198,7 +198,7 @@
|
||||
=/ sed
|
||||
[who 1 sec:ex:cub ~]
|
||||
%+ expect-eq
|
||||
!> [%| %earl %missing-sig]
|
||||
!> [%| %missing-sig]
|
||||
!> (veri:dawn sed hul ~)
|
||||
::
|
||||
++ test-veri-earl-parent-not-keyed
|
||||
@ -207,10 +207,10 @@
|
||||
=/ sed
|
||||
=/ sig
|
||||
%- sign:as:(nol:nu:crub:crypto sec)
|
||||
(shaf %earl (sham 1 pub:ex:cub))
|
||||
(shaf %earl (sham who 1 pub:ex:cub))
|
||||
[who 1 sec:ex:cub `sig]
|
||||
%+ expect-eq
|
||||
!> [%| %earl %parent-not-keyed]
|
||||
!> [%| %parent-not-keyed]
|
||||
!> (veri:dawn sed =>(hul .(net ~)) ~)
|
||||
::
|
||||
++ test-veri-earl-invalid-sig
|
||||
@ -220,19 +220,19 @@
|
||||
=/ sed
|
||||
=/ sig
|
||||
%- sign:as:cub
|
||||
(shaf %earl (sham 1 pub:ex:cub))
|
||||
(shaf %earl (sham who 1 pub:ex:cub))
|
||||
[who 1 sec:ex:cub `sig]
|
||||
%+ expect-eq
|
||||
!> [%| %earl %invalid-sig]
|
||||
!> [%| %invalid-sig]
|
||||
!> (veri:dawn sed hul ~)
|
||||
::
|
||||
=/ sed
|
||||
=/ sig
|
||||
%- sign:as:(nol:nu:crub:crypto sec)
|
||||
(shaf %earl (sham 2 pub:ex:cub))
|
||||
(shaf %earl (sham who 2 pub:ex:cub))
|
||||
[who 1 sec:ex:cub `sig]
|
||||
%+ expect-eq
|
||||
!> [%| %earl %invalid-sig]
|
||||
!> [%| %invalid-sig]
|
||||
!> (veri:dawn sed hul ~)
|
||||
==
|
||||
::
|
||||
@ -242,10 +242,10 @@
|
||||
=/ sed
|
||||
=/ sig
|
||||
%- sign:as:(nol:nu:crub:crypto sec)
|
||||
(shaf %earl (sham 1 pub:ex:cub))
|
||||
(shaf %earl (sham who 1 pub:ex:cub))
|
||||
[who 1 sec:ex:cub `sig]
|
||||
%+ expect-eq
|
||||
!> [%| %earl %already-booted]
|
||||
!> [%| %already-booted]
|
||||
!> (veri:dawn sed hul `[1 |])
|
||||
::
|
||||
++ test-veri-pawn-good
|
||||
@ -253,7 +253,7 @@
|
||||
=/ who=ship `@`fig:ex:cub
|
||||
=/ sed [who 1 sec:ex:cub ~]
|
||||
%+ expect-eq
|
||||
!> [%& sed ~]
|
||||
!> [%& ~]
|
||||
!> (veri:dawn sed *hull:constitution:ethe ~)
|
||||
::
|
||||
++ test-veri-pawn-key-mismatch
|
||||
@ -261,7 +261,7 @@
|
||||
=/ who=ship `@`fig:ex:cub
|
||||
=/ sed [who 1 sec:ex:(pit:nu:crub:crypto 24 %bar) ~]
|
||||
%+ expect-eq
|
||||
!> [%| %pawn %key-mismatch]
|
||||
!> [%| %key-mismatch]
|
||||
!> (veri:dawn sed *hull:constitution:ethe ~)
|
||||
::
|
||||
++ test-veri-pawn-invalid-life
|
||||
@ -269,7 +269,7 @@
|
||||
=/ who=ship `@`fig:ex:cub
|
||||
=/ sed [who 2 sec:ex:cub ~]
|
||||
%+ expect-eq
|
||||
!> [%| %pawn %invalid-life]
|
||||
!> [%| %invalid-life]
|
||||
!> (veri:dawn sed *hull:constitution:ethe ~)
|
||||
::
|
||||
++ test-veri-pawn-already-booted
|
||||
@ -277,6 +277,6 @@
|
||||
=/ who=ship `@`fig:ex:cub
|
||||
=/ sed [who 1 sec:ex:cub ~]
|
||||
%+ expect-eq
|
||||
!> [%| %pawn %already-booted]
|
||||
!> [%| %already-booted]
|
||||
!> (veri:dawn sed *hull:constitution:ethe `[1 |])
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user