2021-03-16 06:49:51 +03:00
|
|
|
:: L1 contract changes:
|
|
|
|
:: - Enforce that once spawn proxy is set to deposit address, it can't
|
|
|
|
:: switched back
|
|
|
|
:: - Enforce that once spawn proxy is set to deposit address, you can't
|
|
|
|
:: spawn children
|
|
|
|
:: - Possibly the same for approveForAll
|
|
|
|
:: - Enforce that only ownership key can set spawn proxy to rollup
|
|
|
|
:: - Disallow depositing galaxy to L2
|
|
|
|
::
|
|
|
|
:: TODO: maybe split out a generic "modify state" core, and have both
|
|
|
|
:: L1 and L2 transactions reduce to that? Would need to see what that
|
|
|
|
:: looks like for L2 transactions, since they need to assert various
|
|
|
|
:: things, but maybe those reduce to just asserting the signer is
|
|
|
|
:: correct? Also need to handle depositing and managing l1 vs l2 to
|
|
|
|
:: some extent.
|
|
|
|
::
|
|
|
|
:: TODO: can an L1 star adopt an L2 planet? It's not obvious how --
|
|
|
|
:: maybe they need to adopt as an L2 transaction? That sounds right I
|
2021-03-17 04:25:27 +03:00
|
|
|
:: think. Can an L2 star adopt an L1 planet? I guess, but L1 wouldn't
|
|
|
|
:: know about it. Should L1 check whether the escape target is on L2
|
|
|
|
:: for some reason?
|
2021-03-16 06:49:51 +03:00
|
|
|
::
|
|
|
|
:: TODO: make kid and net in point not a unit
|
|
|
|
::
|
2021-03-17 04:25:27 +03:00
|
|
|
:: TODO: consider the implications of having two operator lists, on L1
|
|
|
|
:: and L2. Are they the same list, or different?
|
|
|
|
::
|
|
|
|
:: TODO: should we emit all the events azimuth.sol does? might be
|
|
|
|
:: convenient for tracking edges?
|
|
|
|
::
|
|
|
|
:: TODO: decide about adopt/reject/detach. right now i add specifying
|
|
|
|
:: the parent because it feels safer and cleaner, at the cost of four
|
|
|
|
:: bytes. without specifying the parent, are there race conditions
|
|
|
|
:: involving multiple possible sponsors owned/managed by the same
|
|
|
|
:: address?
|
|
|
|
::
|
2021-03-17 05:41:43 +03:00
|
|
|
:: TODO: add nonces to txs. how to keep track of them? need replay
|
|
|
|
:: protection. maybe we can add nonces to ships instead of addresses?
|
|
|
|
:: Then what about operators?
|
|
|
|
::
|
|
|
|
:: TODO: if sig fails to verify, skip instead of crashing
|
|
|
|
::
|
2021-03-18 02:42:39 +03:00
|
|
|
/+ ethereum
|
2021-03-16 06:49:51 +03:00
|
|
|
:: Constants
|
|
|
|
::
|
|
|
|
|%
|
|
|
|
:: Transfers on L1 to this address count as depositing to L2
|
|
|
|
::
|
|
|
|
++ deposit-address 0x1234.5678.9012.3456.7890.1234.5678.9012.3456.7890
|
|
|
|
--
|
|
|
|
:: Types
|
|
|
|
|%
|
2021-03-18 02:42:39 +03:00
|
|
|
:: ethereum address, 20 bytes.
|
|
|
|
::
|
|
|
|
+$ address @ux
|
|
|
|
++ point
|
|
|
|
$: :: domain
|
|
|
|
::
|
|
|
|
dominion=?(%l1 %l2 %spawn)
|
|
|
|
::
|
|
|
|
:: ownership
|
|
|
|
::
|
|
|
|
$= own
|
|
|
|
$: owner=address
|
|
|
|
management-proxy=address
|
|
|
|
voting-proxy=address
|
|
|
|
transfer-proxy=address
|
|
|
|
==
|
|
|
|
::
|
|
|
|
:: networking
|
|
|
|
::
|
|
|
|
$= net
|
|
|
|
$: =life
|
|
|
|
=pass
|
|
|
|
continuity-number=@ud
|
|
|
|
sponsor=[has=? who=@p]
|
|
|
|
escape=(unit @p)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
:: spawning
|
|
|
|
::
|
|
|
|
$= kid
|
|
|
|
$: spawn-proxy=address
|
|
|
|
spawned=(set @p)
|
|
|
|
==
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ diff
|
|
|
|
$% [%rift =rift]
|
|
|
|
[%keys =life crypto-suite=@ud =pass]
|
|
|
|
[%spon sponsor=(unit @p)]
|
|
|
|
==
|
|
|
|
::
|
2021-03-16 06:49:51 +03:00
|
|
|
+$ state
|
|
|
|
$: =points
|
|
|
|
=operators
|
|
|
|
dns=(list @t)
|
|
|
|
==
|
2021-03-18 02:42:39 +03:00
|
|
|
+$ points (map ship point)
|
2021-03-16 06:49:51 +03:00
|
|
|
+$ operators (jug address address)
|
2021-03-18 02:42:39 +03:00
|
|
|
+$ effects (list [ship diff])
|
2021-03-16 06:49:51 +03:00
|
|
|
+$ tx
|
|
|
|
$% [%transfer-point =ship =address reset=?]
|
|
|
|
[%spawn =ship =address]
|
2021-03-17 04:25:27 +03:00
|
|
|
[%set-dns-domains primary=@t secondary=@t tertiary=@t]
|
2021-03-17 05:41:43 +03:00
|
|
|
[%set-operator operator=address add=?]
|
|
|
|
[%configure-keys =ship encrypt=@ auth=@ crypto-suite=@ breach=?]
|
2021-03-16 06:49:51 +03:00
|
|
|
[%escape =ship parent=ship]
|
|
|
|
[%cancel-escape =ship parent=ship]
|
2021-03-17 04:25:27 +03:00
|
|
|
[%adopt =ship parent=ship]
|
|
|
|
[%reject =ship parent=ship]
|
|
|
|
[%detach =ship parent=ship]
|
2021-03-16 06:49:51 +03:00
|
|
|
[%set-management-proxy =ship =address]
|
|
|
|
[%set-spawn-proxy =ship =address]
|
|
|
|
[%set-voting-proxy =ship =address]
|
|
|
|
[%set-transfer-proxy =ship =address]
|
|
|
|
==
|
2021-03-17 05:41:43 +03:00
|
|
|
::
|
2021-03-16 06:49:51 +03:00
|
|
|
+$ input
|
2021-03-18 02:42:39 +03:00
|
|
|
$% [%bat batch=@]
|
|
|
|
[%log =event-log:rpc:ethereum]
|
|
|
|
==
|
|
|
|
::
|
2021-03-16 06:49:51 +03:00
|
|
|
+$ verifier $-([dat=@ v=@ r=@ s=@] pub=@)
|
|
|
|
--
|
|
|
|
::
|
|
|
|
|%
|
2021-03-17 05:41:43 +03:00
|
|
|
++ parse-batch
|
2021-03-18 02:42:39 +03:00
|
|
|
|= [batch=@ =verifier]
|
2021-03-17 05:41:43 +03:00
|
|
|
^- (list [address tx])
|
|
|
|
?~ batch
|
|
|
|
~
|
2021-03-18 02:42:39 +03:00
|
|
|
=^ [signer=address =tx] batch (parse-tx batch verifier)
|
2021-03-17 05:41:43 +03:00
|
|
|
[[signer tx] $]
|
2021-03-16 06:49:51 +03:00
|
|
|
::
|
|
|
|
++ parse-tx
|
2021-03-17 05:41:43 +03:00
|
|
|
|= [batch=@ =verifier]
|
|
|
|
^- [[address tx] rest=@]
|
|
|
|
=/ batch [0 batch]
|
|
|
|
|^
|
|
|
|
=^ sig batch (take 3 65)
|
2021-03-18 02:42:39 +03:00
|
|
|
=/ signed-batch +.batch
|
2021-03-17 05:41:43 +03:00
|
|
|
=- =/ signer=address
|
2021-03-18 02:42:39 +03:00
|
|
|
(verify-tx sig (end [0 len] signed-batch))
|
2021-03-17 05:41:43 +03:00
|
|
|
[[signer tx] rest]
|
|
|
|
^- [=tx [len=@ rest=@]]
|
|
|
|
=^ op batch (take 0 7)
|
2021-03-18 02:42:39 +03:00
|
|
|
?+ op ~|([%strange-opcode op] !!)
|
2021-03-16 06:49:51 +03:00
|
|
|
%0
|
2021-03-18 02:42:39 +03:00
|
|
|
=^ reset=@ batch (take 0)
|
2021-03-17 05:41:43 +03:00
|
|
|
=^ =ship batch (take 3 4)
|
|
|
|
=^ =address batch (take 3 20)
|
2021-03-18 02:42:39 +03:00
|
|
|
[[%transfer-point ship address (,? reset)] batch]
|
2021-03-17 05:41:43 +03:00
|
|
|
::
|
2021-03-18 02:42:39 +03:00
|
|
|
%1 =^(res batch take-ship-address [[%spawn res] batch])
|
2021-03-17 05:41:43 +03:00
|
|
|
%2
|
2021-03-18 02:42:39 +03:00
|
|
|
=^ breach=@ batch (take 0)
|
2021-03-17 05:41:43 +03:00
|
|
|
=^ =ship batch (take 3 4)
|
|
|
|
=^ encrypt=@ batch (take 3 32)
|
|
|
|
=^ auth=@ batch (take 3 32)
|
|
|
|
=^ crypto-suite=@ batch (take 3 4)
|
2021-03-18 02:42:39 +03:00
|
|
|
[[%configure-keys ship encrypt auth crypto-suite (,? breach)] batch]
|
|
|
|
::
|
|
|
|
%3 =^(res batch take-escape [[%escape res] batch])
|
|
|
|
%4 =^(res batch take-escape [[%cancel-escape res] batch])
|
|
|
|
%5 =^(res batch take-escape [[%adopt res] batch])
|
|
|
|
%6 =^(res batch take-escape [[%reject res] batch])
|
|
|
|
%7 =^(res batch take-escape [[%detach res] batch])
|
|
|
|
%8 =^(res batch take-ship-address [[%set-management-proxy res] batch])
|
|
|
|
%9 =^(res batch take-ship-address [[%set-spawn-proxy res] batch])
|
|
|
|
%10 =^(res batch take-ship-address [[%set-voting-proxy res] batch])
|
|
|
|
%11 =^(res batch take-ship-address [[%set-transfer-proxy res] batch])
|
2021-03-17 05:41:43 +03:00
|
|
|
%12
|
2021-03-18 02:42:39 +03:00
|
|
|
=^ pad=@ batch (take 0)
|
2021-03-17 05:41:43 +03:00
|
|
|
=^ primary=@t batch take-string
|
|
|
|
=^ secondary=@t batch take-string
|
|
|
|
=^ tertiary=@t batch take-string
|
2021-03-18 02:42:39 +03:00
|
|
|
[[%set-dns-domains primary secondary tertiary] batch]
|
2021-03-17 05:41:43 +03:00
|
|
|
::
|
|
|
|
%13
|
2021-03-18 02:42:39 +03:00
|
|
|
=^ add=@ batch (take 0)
|
2021-03-17 05:41:43 +03:00
|
|
|
=^ =address batch (take 3 20)
|
2021-03-18 02:42:39 +03:00
|
|
|
[[%set-operator address (,? add)] batch]
|
2021-03-16 06:49:51 +03:00
|
|
|
==
|
2021-03-17 05:41:43 +03:00
|
|
|
::
|
|
|
|
:: Take a bite
|
|
|
|
::
|
|
|
|
++ take
|
|
|
|
|= =bite
|
|
|
|
^- [@ _batch]
|
2021-03-18 02:42:39 +03:00
|
|
|
:- (end bite +.batch)
|
|
|
|
:- %+ add -.batch
|
|
|
|
?@ bite (bex bite)
|
2021-03-17 05:41:43 +03:00
|
|
|
(mul step.bite (bex bloq.bite))
|
2021-03-18 02:42:39 +03:00
|
|
|
(rsh bite +.batch)
|
2021-03-17 05:41:43 +03:00
|
|
|
:: Dumb encoding of strings up to 255 bytes
|
|
|
|
::
|
|
|
|
++ take-string
|
|
|
|
^- [string=@t _batch]
|
|
|
|
=^ len=@ batch (take 3)
|
2021-03-18 02:42:39 +03:00
|
|
|
(take 3 len)
|
2021-03-17 05:41:43 +03:00
|
|
|
:: Encode ship and address
|
|
|
|
::
|
|
|
|
++ take-ship-address
|
|
|
|
^- [[ship address] _batch]
|
2021-03-18 02:42:39 +03:00
|
|
|
=^ pad=@ batch (take 0)
|
2021-03-17 05:41:43 +03:00
|
|
|
=^ =ship batch (take 3 4)
|
|
|
|
=^ =address batch (take 3 20)
|
2021-03-18 02:42:39 +03:00
|
|
|
[[ship address] batch]
|
2021-03-17 05:41:43 +03:00
|
|
|
:: Encode escape-related txs
|
|
|
|
::
|
|
|
|
++ take-escape
|
|
|
|
^- [[ship ship] _batch]
|
2021-03-18 02:42:39 +03:00
|
|
|
=^ pad=@ batch (take 0)
|
2021-03-17 05:41:43 +03:00
|
|
|
=^ child=ship batch (take 3 4)
|
|
|
|
=^ parent=ship batch (take 3 4)
|
2021-03-18 02:42:39 +03:00
|
|
|
[[child parent] batch]
|
|
|
|
:: Verify signature and produce signer address
|
2021-03-17 05:41:43 +03:00
|
|
|
::
|
|
|
|
++ verify-tx
|
2021-03-18 02:42:39 +03:00
|
|
|
|= [sig=@ txdata=@]
|
2021-03-17 05:41:43 +03:00
|
|
|
^- address
|
|
|
|
|^
|
|
|
|
=^ v sig (take 3)
|
|
|
|
=^ r sig (take 3 32)
|
|
|
|
=^ s sig (take 3 32)
|
|
|
|
%- address-from-pub:key:ethereum
|
|
|
|
(verifier txdata v r s)
|
|
|
|
::
|
|
|
|
++ take
|
|
|
|
|= =bite
|
|
|
|
[(end bite sig) (rsh bite sig)]
|
|
|
|
--
|
|
|
|
--
|
2021-03-16 06:49:51 +03:00
|
|
|
::
|
|
|
|
++ get-point-size
|
|
|
|
|= =ship
|
|
|
|
^- @
|
|
|
|
?: (lth ship 0x100) 0
|
2021-03-18 02:42:39 +03:00
|
|
|
?: (lth ship 0x1.0000) 1
|
2021-03-16 06:49:51 +03:00
|
|
|
2
|
|
|
|
::
|
|
|
|
++ hash-log-name
|
|
|
|
|= name=@t
|
|
|
|
^- @ux
|
2021-03-18 02:42:39 +03:00
|
|
|
(keccak-256:keccak:crypto (as-octs:mimes:html name))
|
|
|
|
::
|
|
|
|
++ pass-from-eth
|
|
|
|
|= [enc=octs aut=octs sut=@ud]
|
|
|
|
^- pass
|
|
|
|
%^ cat 3 'b'
|
|
|
|
?. &(=(1 sut) =(p.enc 32) =(p.aut 32))
|
|
|
|
(cat 8 0 0)
|
|
|
|
(cat 8 q.aut q.enc)
|
2021-03-16 06:49:51 +03:00
|
|
|
::
|
|
|
|
++ get-point
|
|
|
|
|= [=state =ship]
|
2021-03-18 02:42:39 +03:00
|
|
|
^- point
|
2021-03-16 06:49:51 +03:00
|
|
|
=/ existing (~(get by points.state) ship)
|
|
|
|
?^ existing
|
|
|
|
u.existing
|
2021-03-18 02:42:39 +03:00
|
|
|
%* . *point
|
|
|
|
dominion
|
|
|
|
?+ (clan:title ship) ~|(%strange-point !!)
|
|
|
|
%czar %l1
|
|
|
|
?(%king %duke)
|
|
|
|
=/ existing-parent $(ship (^sein:title ship))
|
|
|
|
?- dominion.existing-parent
|
|
|
|
%l1 %l1
|
|
|
|
%l2 %l2
|
|
|
|
%spawn %l2
|
|
|
|
==
|
2021-03-16 06:49:51 +03:00
|
|
|
==
|
|
|
|
==
|
|
|
|
--
|
|
|
|
|%
|
2021-03-17 04:25:27 +03:00
|
|
|
:: Receive log from L1 transaction
|
2021-03-16 06:49:51 +03:00
|
|
|
::
|
2021-03-17 04:25:27 +03:00
|
|
|
++ receive-log
|
2021-03-17 05:41:43 +03:00
|
|
|
|= [=state log=event-log:rpc:ethereum]
|
2021-03-18 02:42:39 +03:00
|
|
|
^- [(list [ship diff]) ^state]
|
2021-03-16 06:49:51 +03:00
|
|
|
=* log-name i.topics.log
|
|
|
|
?: =(log-name ^~((hash-log-name 'ChangedDns(string,string,string)')))
|
|
|
|
?> ?=(~ t.topics.log)
|
|
|
|
=/ words (rip 8 data.log)
|
|
|
|
?> ?=([a=@ @ b=@ @ c=@ @ @ @ @ ~] words)
|
|
|
|
=* one &1.words
|
|
|
|
=* two &3.words
|
|
|
|
=* tri &5.words
|
2021-03-17 04:25:27 +03:00
|
|
|
`state(dns (turn ~[one two tri] (cury swp 3)))
|
2021-03-16 06:49:51 +03:00
|
|
|
::
|
|
|
|
?: =(log-name ^~((hash-log-name 'ApprovalForAll(address,address,bool)')))
|
|
|
|
?> ?=([@ @ ~] t.topics.log)
|
2021-03-17 04:25:27 +03:00
|
|
|
=* owner i.t.topics.log
|
2021-03-16 06:49:51 +03:00
|
|
|
=* operator i.t.t.topics.log
|
2021-03-18 02:42:39 +03:00
|
|
|
=/ approved !(,? data.log)
|
2021-03-16 06:49:51 +03:00
|
|
|
=- `state(operators -)
|
|
|
|
?: approved
|
2021-03-17 04:25:27 +03:00
|
|
|
(~(put ju operators.state) owner operator)
|
|
|
|
(~(del ju operators.state) owner operator)
|
2021-03-16 06:49:51 +03:00
|
|
|
::
|
|
|
|
:: The rest of the logs modify a particular ship, specified in the
|
|
|
|
:: second topic. We fetch it, and insert the modification back into
|
|
|
|
:: our state.
|
|
|
|
::
|
|
|
|
?> ?=([@ *] t.topics.log)
|
|
|
|
=* ship i.t.topics.log
|
2021-03-18 02:42:39 +03:00
|
|
|
=/ point (get-point state `@`ship)
|
|
|
|
=- [effects state(points (~(put by points.state) `@`ship new-point))]
|
|
|
|
^- [=effects new-point=^point]
|
2021-03-16 06:49:51 +03:00
|
|
|
::
|
|
|
|
?: =(log-name ^~((hash-log-name 'ChangedSpawnProxy(uint32,address)')))
|
|
|
|
?> ?=(%l1 -.point)
|
|
|
|
?> ?=([@ ~] t.t.topics.log)
|
|
|
|
=* to i.t.t.topics.log
|
|
|
|
:- ~
|
|
|
|
?. =(deposit-address to)
|
|
|
|
point(spawn-proxy.kid to)
|
|
|
|
point(dominion %spawn)
|
|
|
|
::
|
|
|
|
:: The rest can be done by any ship on L1, even if their spawn proxy
|
|
|
|
:: is set to L2
|
|
|
|
::
|
|
|
|
?< ?=(%l2 -.point)
|
|
|
|
::
|
|
|
|
?: =(log-name ^~((hash-log-name 'BrokeContinuity(uint32,uint32)')))
|
|
|
|
?> ?=(~ t.t.topics.log)
|
|
|
|
=* rift data.log
|
2021-03-18 02:42:39 +03:00
|
|
|
:- [`@`ship %rift `@`rift]~
|
|
|
|
point(continuity-number.net `@`rift)
|
2021-03-16 06:49:51 +03:00
|
|
|
::
|
|
|
|
=/ changed-keys-hash
|
|
|
|
^~((hash-log-name 'ChangedKeys(uint32,bytes32,bytes32,uint32,uint32)'))
|
|
|
|
?: =(log-name changed-keys-hash)
|
|
|
|
?> ?=(~ t.t.topics.log)
|
|
|
|
=/ words (rip 8 data.log)
|
|
|
|
?> ?=([@ @ @ @ ~] words)
|
|
|
|
=* encryption i.words
|
|
|
|
=* authentication i.t.words
|
|
|
|
=* crypto-suite i.t.t.words :: TODO: store in state, or add to pass
|
|
|
|
=* life i.t.t.t.words
|
|
|
|
=/ =pass (pass-from-eth 32^encryption 32^authentication crypto-suite)
|
2021-03-18 02:42:39 +03:00
|
|
|
:- [`@`ship %keys life crypto-suite pass]~
|
|
|
|
point(life.net life, pass.net pass)
|
2021-03-16 06:49:51 +03:00
|
|
|
::
|
|
|
|
?: =(log-name ^~((hash-log-name 'EscapeAccepted(uint32,uint32)')))
|
|
|
|
?> ?=([@ ~] t.t.topics.log)
|
|
|
|
=* parent i.t.t.topics.log
|
2021-03-18 02:42:39 +03:00
|
|
|
:- [`@`ship %spon ``@`parent]~
|
|
|
|
point(escape.net ~, sponsor.net [%& `@`parent])
|
2021-03-16 06:49:51 +03:00
|
|
|
::
|
|
|
|
?: =(log-name ^~((hash-log-name 'LostSponsor(uint32,uint32)')))
|
|
|
|
?> ?=([@ ~] t.t.topics.log)
|
|
|
|
=* parent i.t.t.topics.log
|
2021-03-18 02:42:39 +03:00
|
|
|
:- [`@`ship %spon ~]~
|
|
|
|
point(has.sponsor.net %|)
|
2021-03-16 06:49:51 +03:00
|
|
|
::
|
|
|
|
:: The rest do not produce effects
|
|
|
|
::
|
|
|
|
:- ~
|
|
|
|
::
|
|
|
|
?: =(log-name ^~((hash-log-name 'EscapeRequested(uint32,uint32)')))
|
|
|
|
?> ?=([@ ~] t.t.topics.log)
|
|
|
|
=* parent i.t.t.topics.log
|
2021-03-18 02:42:39 +03:00
|
|
|
point(escape.net ``@`parent)
|
2021-03-16 06:49:51 +03:00
|
|
|
::
|
|
|
|
?: =(log-name ^~((hash-log-name 'EscapeCanceled(uint32,uint32)')))
|
|
|
|
?> ?=([@ ~] t.t.topics.log)
|
|
|
|
=* parent i.t.t.topics.log
|
2021-03-18 02:42:39 +03:00
|
|
|
point(escape.net ~)
|
2021-03-16 06:49:51 +03:00
|
|
|
::
|
|
|
|
?: =(log-name ^~((hash-log-name 'OwnerChanged(uint32,address)')))
|
|
|
|
?> ?=([@ ~] t.t.topics.log)
|
|
|
|
=* to i.t.t.topics.log
|
|
|
|
::
|
|
|
|
?: =(deposit-address to)
|
2021-03-18 02:42:39 +03:00
|
|
|
point(dominion %l2)
|
|
|
|
point(owner.own to)
|
2021-03-16 06:49:51 +03:00
|
|
|
::
|
2021-03-18 02:42:39 +03:00
|
|
|
?: =(log-name ^~((hash-log-name 'ChangedTransferProxy(uint32,address)')))
|
2021-03-16 06:49:51 +03:00
|
|
|
?> ?=([@ ~] t.t.topics.log)
|
|
|
|
=* to i.t.t.topics.log
|
|
|
|
point(transfer-proxy.own to)
|
|
|
|
::
|
|
|
|
?: =(log-name ^~((hash-log-name 'ChangedManagementProxy(uint32,address)')))
|
|
|
|
?> ?=([@ ~] t.t.topics.log)
|
|
|
|
=* to i.t.t.topics.log
|
|
|
|
point(management-proxy.own to)
|
|
|
|
::
|
2021-03-18 02:42:39 +03:00
|
|
|
?: =(log-name ^~((hash-log-name 'ChangedVotingProxy(uint32,address)')))
|
|
|
|
?> ?=([@ ~] t.t.topics.log)
|
2021-03-16 06:49:51 +03:00
|
|
|
=* to i.t.t.topics.log
|
|
|
|
point(voting-proxy.own to)
|
|
|
|
::
|
|
|
|
~| [%unknown-log log]
|
2021-03-17 05:41:43 +03:00
|
|
|
!!
|
2021-03-17 04:25:27 +03:00
|
|
|
::
|
|
|
|
:: Receive batch of L2 transactions
|
|
|
|
::
|
|
|
|
++ receive-batch
|
2021-03-18 02:42:39 +03:00
|
|
|
|= [=state batch=@ =verifier]
|
|
|
|
=/ txs=(list [signer=address =tx]) (parse-batch batch verifier)
|
2021-03-17 05:41:43 +03:00
|
|
|
|- ^- [effects ^state]
|
|
|
|
?~ txs
|
|
|
|
[~ state]
|
|
|
|
=^ effects-1 state (receive-tx state signer.i.txs tx.i.txs)
|
|
|
|
=^ effects-2 state $(txs t.txs)
|
|
|
|
[(welp effects-1 effects-2) state]
|
|
|
|
::
|
|
|
|
:: Receive an individual L2 transaction
|
|
|
|
::
|
|
|
|
++ receive-tx
|
2021-03-18 02:42:39 +03:00
|
|
|
|= [=state signer=address =tx]
|
2021-03-17 04:25:27 +03:00
|
|
|
|^
|
2021-03-18 02:42:39 +03:00
|
|
|
^- [effects ^state]
|
|
|
|
?- -.tx
|
2021-03-17 04:25:27 +03:00
|
|
|
%set-dns-domains (process-set-dns-domains +.tx)
|
|
|
|
%set-operator (process-set-operator +.tx)
|
2021-03-17 05:41:43 +03:00
|
|
|
%spawn (process-spawn +.tx)
|
|
|
|
%transfer-point (w-point process-transfer-point +.tx)
|
2021-03-17 04:25:27 +03:00
|
|
|
%configure-keys (w-point-fx process-configure-keys +.tx)
|
|
|
|
%escape (w-point process-escape +.tx)
|
|
|
|
%cancel-escape (w-point process-cancel-escape +.tx)
|
|
|
|
%adopt (w-point-fx process-adopt +.tx)
|
|
|
|
%reject (w-point process-reject +.tx)
|
|
|
|
%detach (w-point-fx process-detach +.tx)
|
|
|
|
%set-management-proxy (w-point process-set-management-proxy +.tx)
|
|
|
|
%set-spawn-proxy (w-point process-set-spawn-proxy +.tx)
|
|
|
|
%set-voting-proxy (w-point process-set-voting-proxy +.tx)
|
|
|
|
%set-transfer-proxy (w-point process-set-transfer-proxy +.tx)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ w-point-fx
|
2021-03-18 02:42:39 +03:00
|
|
|
|* [fun=$-([ship point *] [effects point]) =ship rest=*]
|
2021-03-17 04:25:27 +03:00
|
|
|
^- [effects ^state]
|
|
|
|
=/ point (get-point state ship)
|
|
|
|
?> ?=(%l2 -.point)
|
2021-03-18 02:42:39 +03:00
|
|
|
=/ [=effects new-point=^point] (fun ship point rest)
|
|
|
|
[effects state(points (~(put by points.state) ship new-point))]
|
2021-03-17 04:25:27 +03:00
|
|
|
::
|
|
|
|
++ w-point
|
2021-03-18 02:42:39 +03:00
|
|
|
|* [fun=$-([ship point *] point) =ship rest=*]
|
2021-03-17 04:25:27 +03:00
|
|
|
^- [effects ^state]
|
|
|
|
=/ point (get-point state ship)
|
|
|
|
?> ?=(%l2 -.point)
|
2021-03-18 02:42:39 +03:00
|
|
|
=/ new-point (fun ship point rest)
|
|
|
|
`state(points (~(put by points.state) ship new-point))
|
2021-03-17 04:25:27 +03:00
|
|
|
::
|
2021-03-17 05:41:43 +03:00
|
|
|
++ process-set-dns-domains
|
|
|
|
|= [primary=@t secondary=@t tertiary=@t]
|
|
|
|
?> =(signer 0x0) :: TODO: who?
|
|
|
|
`state(dns ~[primary secondary tertiary])
|
|
|
|
::
|
|
|
|
++ process-set-operator
|
|
|
|
|= [operator=address add=?]
|
|
|
|
=- `state(operators -)
|
|
|
|
?< =(0x0 operator)
|
|
|
|
?: add
|
|
|
|
(~(put ju operators.state) signer operator)
|
|
|
|
(~(del ju operators.state) signer operator)
|
|
|
|
::
|
2021-03-17 04:25:27 +03:00
|
|
|
++ process-transfer-point
|
2021-03-18 02:42:39 +03:00
|
|
|
|= [=ship =point to=address reset=?]
|
2021-03-17 04:25:27 +03:00
|
|
|
:: Assert ship is on L2
|
|
|
|
::
|
|
|
|
:: Assert signer is owner or transfer prxoy
|
|
|
|
::
|
|
|
|
?> ?| =(owner.own.point signer)
|
|
|
|
=(transfer-proxy.own.point signer)
|
|
|
|
==
|
|
|
|
:: Execute transfer
|
|
|
|
::
|
|
|
|
=: owner.own.point to
|
|
|
|
transfer-proxy.own.point *address
|
|
|
|
==
|
|
|
|
:: Execute reset if requested
|
|
|
|
::
|
|
|
|
?. reset
|
|
|
|
point
|
|
|
|
::
|
2021-03-18 02:42:39 +03:00
|
|
|
=? net.point (gth life.net.point 0)
|
|
|
|
[+(life) 0 +(continuity-number) sponsor escape]:net.point
|
2021-03-17 04:25:27 +03:00
|
|
|
=. own.point [owner.own.point *address *address *address]
|
|
|
|
=. spawn-proxy.kid.point *address
|
|
|
|
point
|
|
|
|
::
|
|
|
|
++ process-spawn
|
|
|
|
|= [=ship to=address]
|
2021-03-18 02:42:39 +03:00
|
|
|
^- [effects ^state]
|
2021-03-17 04:25:27 +03:00
|
|
|
=/ parent=^ship (^sein:title ship)
|
|
|
|
:: Assert parent is on L2
|
|
|
|
::
|
|
|
|
=/ parent-point (get-point state parent)
|
|
|
|
?> ?=(?(%l2 %spawn) -.parent-point)
|
|
|
|
:: Assert signer is owner or spawn proxy
|
|
|
|
::
|
|
|
|
?> ?| =(owner.own.parent-point signer)
|
|
|
|
=(spawn-proxy.kid.parent-point signer)
|
|
|
|
==
|
|
|
|
:: Assert child not already spawned
|
|
|
|
::
|
|
|
|
:: TODO: verify this means the ship exists on neither L1 nor L2
|
|
|
|
::
|
|
|
|
?< (~(has by points.state) ship)
|
|
|
|
:: Assert one-level-down
|
|
|
|
::
|
|
|
|
?> =(+((get-point-size parent)) (get-point-size ship))
|
|
|
|
:: TODO check spawnlimit
|
|
|
|
::
|
|
|
|
=. points.state
|
2021-03-18 02:42:39 +03:00
|
|
|
%+ ~(put by points.state) ship
|
2021-03-17 04:25:27 +03:00
|
|
|
?: =(to signer)
|
|
|
|
:: If spawning to self, just do it
|
|
|
|
::
|
2021-03-18 02:42:39 +03:00
|
|
|
%* . *point
|
|
|
|
dominion %l2
|
2021-03-17 04:25:27 +03:00
|
|
|
owner.own to
|
|
|
|
==
|
|
|
|
:: Else spawn to parent and set transfer proxy
|
|
|
|
::
|
2021-03-18 02:42:39 +03:00
|
|
|
%* . *point
|
|
|
|
dominion %l2
|
2021-03-17 04:25:27 +03:00
|
|
|
owner.own owner.own.parent-point
|
|
|
|
transfer-proxy.own to
|
|
|
|
==
|
2021-03-18 02:42:39 +03:00
|
|
|
`state
|
2021-03-17 04:25:27 +03:00
|
|
|
::
|
|
|
|
++ process-configure-keys
|
2021-03-18 02:42:39 +03:00
|
|
|
|= [=ship =point encrypt=@ auth=@ crypto-suite=@ breach=?]
|
2021-03-17 04:25:27 +03:00
|
|
|
::
|
|
|
|
?> ?| =(owner.own.point signer)
|
|
|
|
=(management-proxy.own.point signer)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
=? continuity-number.net.point breach +(continuity-number.net.point)
|
|
|
|
=/ rift-effects ?:(breach [ship %rift continuity-number.net.point]~ ~)
|
|
|
|
::
|
|
|
|
=/ =pass (pass-from-eth 32^encrypt 32^auth crypto-suite)
|
|
|
|
=? net.point !=(pass.net.point pass) :: TODO: check crypto-suite
|
|
|
|
net.point(life +(life.net.point), pass pass)
|
|
|
|
=/ keys-effects
|
|
|
|
?: =(pass.net.point pass)
|
|
|
|
~
|
|
|
|
[ship %keys life.net.point crypto-suite pass]~
|
|
|
|
::
|
|
|
|
[(welp rift-effects keys-effects) point]
|
|
|
|
::
|
|
|
|
++ process-escape
|
2021-03-18 02:42:39 +03:00
|
|
|
|= [=ship =point parent=ship]
|
2021-03-17 04:25:27 +03:00
|
|
|
?> ?| =(owner.own.point signer)
|
|
|
|
=(management-proxy.own.point signer)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
:: TODO: don't allow "peer escape"?
|
|
|
|
?> =(+((get-point-size parent)) (get-point-size ship))
|
|
|
|
::
|
2021-03-18 02:42:39 +03:00
|
|
|
point(escape.net `parent) :: TODO: omitting a lot of source material?
|
2021-03-17 04:25:27 +03:00
|
|
|
::
|
|
|
|
++ process-cancel-escape
|
2021-03-18 02:42:39 +03:00
|
|
|
|= [=ship =point parent=ship]
|
2021-03-17 04:25:27 +03:00
|
|
|
?> ?| =(owner.own.point signer)
|
|
|
|
=(management-proxy.own.point signer)
|
|
|
|
==
|
|
|
|
::
|
2021-03-18 02:42:39 +03:00
|
|
|
point(escape.net ~)
|
2021-03-17 04:25:27 +03:00
|
|
|
::
|
|
|
|
++ process-adopt
|
2021-03-18 02:42:39 +03:00
|
|
|
|= [=ship =point parent=ship]
|
2021-03-17 04:25:27 +03:00
|
|
|
=/ parent-point (get-point state parent) :: TODO: assert child/parent on L2?
|
|
|
|
::
|
|
|
|
?> ?| =(owner.own.parent-point signer)
|
|
|
|
=(management-proxy.own.parent-point signer)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
?> =(escape.net.point `ship)
|
|
|
|
:- [ship %spon `parent]~
|
2021-03-18 02:42:39 +03:00
|
|
|
point(escape.net ~, sponsor.net [%& parent])
|
2021-03-17 04:25:27 +03:00
|
|
|
::
|
|
|
|
++ process-reject
|
2021-03-18 02:42:39 +03:00
|
|
|
|= [=ship =point parent=ship]
|
2021-03-17 04:25:27 +03:00
|
|
|
=/ parent-point (get-point state parent) :: TODO: assert child/parent on L2?
|
|
|
|
::
|
|
|
|
?> ?| =(owner.own.parent-point signer)
|
|
|
|
=(management-proxy.own.parent-point signer)
|
|
|
|
==
|
|
|
|
::
|
2021-03-18 02:42:39 +03:00
|
|
|
point(escape.net ~)
|
2021-03-17 04:25:27 +03:00
|
|
|
::
|
|
|
|
++ process-detach
|
2021-03-18 02:42:39 +03:00
|
|
|
|= [=ship =point parent=ship]
|
2021-03-17 04:25:27 +03:00
|
|
|
=/ parent-point (get-point state parent) :: TODO: assert child/parent on L2?
|
|
|
|
::
|
|
|
|
?> ?| =(owner.own.parent-point signer)
|
|
|
|
=(management-proxy.own.parent-point signer)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
:- [ship %spon ~]~
|
2021-03-18 02:42:39 +03:00
|
|
|
point(has.sponsor.net %|)
|
2021-03-17 04:25:27 +03:00
|
|
|
::
|
|
|
|
++ process-set-management-proxy
|
2021-03-18 02:42:39 +03:00
|
|
|
|= [=ship =point =address]
|
2021-03-17 04:25:27 +03:00
|
|
|
?> ?| =(owner.own.point signer)
|
2021-03-18 02:42:39 +03:00
|
|
|
=(management-proxy.own.point signer)
|
2021-03-17 04:25:27 +03:00
|
|
|
==
|
|
|
|
::
|
2021-03-18 02:42:39 +03:00
|
|
|
point(management-proxy.own address)
|
2021-03-17 04:25:27 +03:00
|
|
|
::
|
|
|
|
++ process-set-spawn-proxy
|
2021-03-18 02:42:39 +03:00
|
|
|
|= [=ship =point =address]
|
2021-03-17 04:25:27 +03:00
|
|
|
?> ?| =(owner.own.point signer)
|
2021-03-18 02:42:39 +03:00
|
|
|
=(spawn-proxy.kid.point signer)
|
2021-03-17 04:25:27 +03:00
|
|
|
==
|
|
|
|
::
|
2021-03-18 02:42:39 +03:00
|
|
|
point(spawn-proxy.kid address)
|
2021-03-17 04:25:27 +03:00
|
|
|
::
|
|
|
|
++ process-set-voting-proxy
|
2021-03-18 02:42:39 +03:00
|
|
|
|= [=ship =point =address]
|
2021-03-17 04:25:27 +03:00
|
|
|
?> ?| =(owner.own.point signer)
|
2021-03-18 02:42:39 +03:00
|
|
|
=(voting-proxy.own.point signer)
|
2021-03-17 04:25:27 +03:00
|
|
|
==
|
|
|
|
::
|
2021-03-18 02:42:39 +03:00
|
|
|
point(voting-proxy.own address)
|
2021-03-17 04:25:27 +03:00
|
|
|
::
|
|
|
|
++ process-set-transfer-proxy
|
2021-03-18 02:42:39 +03:00
|
|
|
|= [=ship =point =address]
|
2021-03-17 04:25:27 +03:00
|
|
|
?> ?| =(owner.own.point signer)
|
2021-03-18 02:42:39 +03:00
|
|
|
=(transfer-proxy.own.point signer)
|
2021-03-17 04:25:27 +03:00
|
|
|
==
|
|
|
|
::
|
2021-03-18 02:42:39 +03:00
|
|
|
point(transfer-proxy.own address)
|
2021-03-17 04:25:27 +03:00
|
|
|
--
|
2021-03-16 06:49:51 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
:: State transition function
|
|
|
|
::
|
|
|
|
:: TODO: wrap in mule to no-op instead of crash? perhaps that's better
|
|
|
|
:: as part of the spec? it's not a clear part of the nock spec, though
|
|
|
|
::
|
|
|
|
|= [=input =state =verifier]
|
2021-03-18 02:42:39 +03:00
|
|
|
^- [effects ^state]
|
2021-03-16 06:49:51 +03:00
|
|
|
?: ?=(%log -.input)
|
|
|
|
:: Received log from L1 transaction
|
|
|
|
::
|
2021-03-17 05:41:43 +03:00
|
|
|
(receive-log state event-log.input)
|
2021-03-16 06:49:51 +03:00
|
|
|
:: Received batch
|
|
|
|
::
|
2021-03-18 02:42:39 +03:00
|
|
|
(receive-batch state batch.input verifier)
|