shrub/pkg/arvo/lib/naive.hoon

698 lines
20 KiB
Plaintext
Raw Normal View History

:: 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
2021-03-28 05:08:17 +03:00
:: - Enforce that only ownership key can set spawn proxy to rollup.
:: maybe not though
:: - 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-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?
::
:: 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 04:07:21 +03:00
:: TODO: is it possible to spawn directly to the deposit address? if
:: so, should we find its parent's owner to control it?
::
:: TODO: should we add any protection in the L1 contracts that you
:: don't deposit from a contract?
::
2021-03-18 23:32:32 +03:00
:: TODO: check operator anywhere you check for owner
::
:: TODO: batch tx type to reduce signatures
::
:: TODO: how to implement claims on L2?
::
:: TODO: on L1, when depositing, clear proxies (maybe require reset)
::
2021-04-01 04:17:37 +03:00
/+ std
=> std
:: 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
2021-03-18 23:32:32 +03:00
spawn-proxy=address
2021-03-18 02:42:39 +03:00
==
::
:: networking
::
$= net
$: =life
=pass
2021-03-18 23:32:32 +03:00
rift=@ud
2021-03-18 02:42:39 +03:00
sponsor=[has=? who=@p]
escape=(unit @p)
==
==
::
2021-03-18 23:32:32 +03:00
:: TODO: add effects for all changes
::
2021-03-18 02:42:39 +03:00
++ diff
2021-03-18 23:32:32 +03:00
$: =ship
$% [%rift =rift]
[%keys =life crypto-suite=@ud =pass]
[%spon sponsor=(unit @p)]
== ==
2021-03-18 02:42:39 +03:00
::
+$ state
$: =points
=operators
dns=(list @t)
==
2021-03-18 02:42:39 +03:00
+$ points (map ship point)
+$ operators (jug address address)
2021-03-18 23:32:32 +03:00
+$ effects (list diff)
+$ tx
$% [%transfer-point =ship =address reset=?]
[%spawn =ship =address]
[%configure-keys =ship encrypt=@ auth=@ crypto-suite=@ breach=?]
[%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]
[%set-management-proxy =ship =address]
[%set-spawn-proxy =ship =address]
[%set-voting-proxy =ship =address]
[%set-transfer-proxy =ship =address]
==
::
2021-04-01 04:17:37 +03:00
+$ event-log
$: address=@ux
data=@t
topics=(lest @ux)
==
+$ input
2021-03-18 02:42:39 +03:00
$% [%bat batch=@]
2021-04-01 04:17:37 +03:00
[%log =event-log]
2021-03-18 02:42:39 +03:00
==
2021-03-18 03:27:30 +03:00
:: ECDSA verifier
2021-03-18 02:42:39 +03:00
::
2021-03-28 05:08:17 +03:00
+$ verifier $-([dat=@ v=@ r=@ s=@] (unit address))
--
::
|%
++ parse-batch
2021-03-28 05:08:17 +03:00
|= [=verifier batch=@]
^- (list [address tx])
=| txs=(list [address tx])
|- ^- (list [address tx])
?~ batch
(flop txs)
=/ parse-result (parse-tx batch verifier)
:: Parsing failed, abort batch
::
?~ parse-result
~
=^ signed=(unit [signer=address =tx]) batch u.parse-result
:: Signature failed, skip transaction
::
?~ signed
2021-03-28 05:08:17 +03:00
$
[u.signed $(txs [u.signed txs])]
2021-03-28 05:08:17 +03:00
::
:: TODO: change batch to be a cursor to avoid allocating atoms
::
++ parse-tx
|= [batch=@ =verifier]
^- (unit [(unit [address tx]) rest=@])
2021-03-28 05:08:17 +03:00
=/ batch [len=0 rest=batch]
|^
=^ sig batch (take 3 65)
2021-03-18 02:42:39 +03:00
=/ signed-batch +.batch
=- ?~ res
~
:- ~
=/ signer=(unit address)
(verify-tx sig (end [0 len.u.res] signed-batch))
2021-03-28 05:08:17 +03:00
?~ signer
[~ rest.u.res]
[`[u.signer tx.u.res] rest.u.res]
^- res=(unit [=tx [len=@ rest=@]])
=^ op batch (take 0 7)
?+ op ~>(%slog.%strange-opcode ~)
%0
2021-03-18 02:42:39 +03:00
=^ reset=@ batch (take 0)
=^ =ship batch (take 3 4)
=^ =address batch (take 3 20)
`[[%transfer-point ship address =(0 reset)] batch]
::
%1 =^(res batch take-ship-address `[[%spawn res] batch])
%2
2021-03-18 02:42:39 +03:00
=^ breach=@ batch (take 0)
=^ =ship batch (take 3 4)
=^ encrypt=@ batch (take 3 32)
=^ auth=@ batch (take 3 32)
=^ crypto-suite=@ batch (take 3 4)
`[[%configure-keys ship encrypt auth crypto-suite =(0 breach)] batch]
2021-03-18 02:42:39 +03:00
::
%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])
==
::
:: Take a bite
::
++ take
|= =bite
^- [@ _batch]
2021-03-18 02:42:39 +03:00
:- (end bite +.batch)
:- %+ add -.batch
?@ bite (bex bite)
(mul step.bite (bex bloq.bite))
2021-03-18 02:42:39 +03:00
(rsh bite +.batch)
:: Encode ship and address
::
++ take-ship-address
^- [[ship address] _batch]
2021-03-18 02:42:39 +03:00
=^ pad=@ batch (take 0)
=^ =ship batch (take 3 4)
=^ =address batch (take 3 20)
2021-03-18 02:42:39 +03:00
[[ship address] batch]
:: Encode escape-related txs
::
++ take-escape
^- [[ship ship] _batch]
2021-03-18 02:42:39 +03:00
=^ pad=@ batch (take 0)
=^ 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
::
++ verify-tx
2021-03-18 02:42:39 +03:00
|= [sig=@ txdata=@]
2021-03-28 05:08:17 +03:00
^- (unit address)
|^
=^ v sig (take 3)
=^ r sig (take 3 32)
=^ s sig (take 3 32)
(verifier txdata v r s)
::
++ take
|= =bite
[(end bite sig) (rsh bite sig)]
--
--
::
2021-04-01 04:17:37 +03:00
++ ship-rank
|= =ship
2021-04-01 04:17:37 +03:00
^- ?(%0 %1 %2 %3 %4)
?: (lth ship 0x100) %0
?: (lth ship 0x1.0000) %1
?: (lth ship 0x1.0000.0000) %2
?: (lth ship 0x1.0000.0000.0000.0000) %3
%4
::
++ sein :: autoboss
|= who=ship
^- ship
=/ mir (ship-rank who)
?- mir
%0 who
%1 (end 3 who)
%2 (end 4 who)
%3 (end 5 who)
%4 (end 4 who)
==
::
++ 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))
2021-03-18 23:32:32 +03:00
(cat 8 0 0) :: TODO: fix
2021-03-18 02:42:39 +03:00
(cat 8 q.aut q.enc)
::
++ get-point
|= [=state =ship]
^- (unit point)
=/ existing (~(get by points.state) ship)
?^ existing
`u.existing
?+ (ship-rank ship) ~>(%slog.%strange-point ~)
%0 `%*(. *point dominion %l1)
?(%1 %2)
=/ existing-parent $(ship (sein ship))
?~ existing-parent ~
:- ~
%* . *point
dominion
?- dominion.u.existing-parent
2021-03-18 02:42:39 +03:00
%l1 %l1
%l2 %l2
%spawn %l2
==
==
==
--
|%
2021-03-17 04:25:27 +03:00
:: Receive log from L1 transaction
::
2021-03-17 04:25:27 +03:00
++ receive-log
2021-04-01 04:17:37 +03:00
|= [=state log=event-log]
2021-03-18 23:32:32 +03:00
^- [effects ^state]
=* log-name i.topics.log
?: =(log-name ^~((hash-log-name 'ChangedDns(string,string,string)')))
?> ?=(~ t.topics.log)
=/ words (rip 8 data.log)
2021-03-18 23:32:32 +03:00
?> ?=([c=@ @ b=@ @ a=@ @ @ @ @ ~] words) :: TODO: not always true
=* one &5.words
=* two &3.words
2021-03-18 23:32:32 +03:00
=* tri &1.words
2021-04-01 04:17:37 +03:00
`state(dns (turn ~[one two tri] |=(a=@ (swp 3 a))))
::
?: =(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
=* operator i.t.t.topics.log
2021-03-28 05:08:17 +03:00
=/ approved !=(0 data.log)
=- `state(operators -)
?: approved
2021-03-17 04:25:27 +03:00
(~(put ju operators.state) owner operator)
(~(del ju operators.state) owner operator)
::
:: 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.
::
2021-03-28 05:08:17 +03:00
:: TODO: cast in =* instead of after
::
?> ?=([@ *] t.topics.log)
2021-03-28 05:08:17 +03:00
=* ship=@ i.t.topics.log
=/ the-point (get-point state ship)
?> ?=(^ the-point)
=* point u.the-point
2021-03-28 05:08:17 +03:00
=- [effects state(points (~(put by points.state) ship new-point))]
2021-03-18 02:42:39 +03:00
^- [=effects new-point=^point]
::
?: =(log-name ^~((hash-log-name 'ChangedSpawnProxy(uint32,address)')))
?> ?=(%l1 -.point)
?> ?=([@ ~] t.t.topics.log)
=* to i.t.t.topics.log
2021-03-18 23:32:32 +03:00
:: Depositing to L2 is represented by a spawn proxy change on L1,
:: but it doesn't change the actual spawn proxy.
::
:- ~
2021-03-18 23:32:32 +03:00
?: =(deposit-address to)
point(dominion %spawn)
point(spawn-proxy.own to)
::
:: 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)
2021-03-28 05:08:17 +03:00
=* rift=@ data.log
:- [ship %rift rift]~
point(rift.net rift)
::
=/ 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)
2021-03-18 23:32:32 +03:00
?> ?=([@ @ @ @ ~] words) :: TODO: reverse order?
2021-03-28 05:08:17 +03:00
=* 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-28 05:08:17 +03:00
:- [ship %keys life crypto-suite pass]~
2021-03-18 02:42:39 +03:00
point(life.net life, pass.net pass)
::
?: =(log-name ^~((hash-log-name 'EscapeAccepted(uint32,uint32)')))
?> ?=([@ ~] t.t.topics.log)
2021-03-28 05:08:17 +03:00
=* parent=@ i.t.t.topics.log
:- [ship %spon `parent]~
point(escape.net ~, sponsor.net [%& parent])
::
?: =(log-name ^~((hash-log-name 'LostSponsor(uint32,uint32)')))
?> ?=([@ ~] t.t.topics.log)
=* parent i.t.t.topics.log
2021-03-28 05:08:17 +03:00
:- [ship %spon ~]~
2021-03-18 02:42:39 +03:00
point(has.sponsor.net %|)
::
:: The rest do not produce effects
::
:- ~
::
?: =(log-name ^~((hash-log-name 'EscapeRequested(uint32,uint32)')))
?> ?=([@ ~] t.t.topics.log)
2021-03-28 05:08:17 +03:00
=* parent=@ i.t.t.topics.log
point(escape.net `parent)
::
?: =(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 ~)
::
?: =(log-name ^~((hash-log-name 'OwnerChanged(uint32,address)')))
?> ?=([@ ~] t.t.topics.log)
=* to i.t.t.topics.log
2021-03-18 23:32:32 +03:00
:: Depositing to L2 is represented by an ownership change on L1,
:: but it doesn't change who actually owns the ship.
::
?: =(deposit-address to)
2021-03-18 02:42:39 +03:00
point(dominion %l2)
point(owner.own to)
::
2021-03-18 02:42:39 +03:00
?: =(log-name ^~((hash-log-name 'ChangedTransferProxy(uint32,address)')))
?> ?=([@ ~] 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)
=* to i.t.t.topics.log
point(voting-proxy.own to)
::
2021-04-01 04:17:37 +03:00
~> %slog.%unknown-log
2021-03-18 23:32:32 +03:00
point :: TODO: crash?
2021-03-17 04:25:27 +03:00
::
:: Receive batch of L2 transactions
::
++ receive-batch
2021-03-28 05:08:17 +03:00
|= [=verifier =state batch=@]
=/ txs=(list [signer=address =tx]) (parse-batch verifier batch)
|- ^- [effects ^state]
?~ txs
[~ state]
2021-04-01 04:17:37 +03:00
=^ effects-1 state
=/ tx-result=(unit [effects ^state]) (receive-tx state i.txs)
?~ tx-result
`state
u.tx-result
=^ 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
|^
^- (unit [effects ^state])
2021-03-18 02:42:39 +03:00
?- -.tx
%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
|* [fun=$-([ship point *] (unit [effects point])) =ship rest=*]
^- (unit [effects ^state])
2021-03-17 04:25:27 +03:00
=/ point (get-point state ship)
?~ point ~
?> ?=(%l2 -.u.point)
=/ res=(unit [=effects new-point=^point]) (fun ship u.point rest)
?~ res
~
`[effects.u.res state(points (~(put by points.state) ship new-point.u.res))]
2021-03-17 04:25:27 +03:00
::
++ w-point
|* [fun=$-([ship point *] (unit point)) =ship rest=*]
^- (unit [effects ^state])
2021-03-17 04:25:27 +03:00
=/ point (get-point state ship)
?~ point ~
?> ?=(%l2 -.u.point)
=/ new-point=(unit ^point) (fun ship u.point rest)
?~ new-point
~
``state(points (~(put by points.state) ship u.new-point))
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 signer is owner or transfer prxoy
::
?. ?| =(owner.own.point signer)
2021-03-17 04:25:27 +03:00
=(transfer-proxy.own.point signer)
==
~
2021-03-17 04:25:27 +03:00
:: Execute transfer
::
=: owner.own.point to
transfer-proxy.own.point *address
==
:: Execute reset if requested
::
?. reset
`point
2021-03-17 04:25:27 +03:00
::
2021-03-18 02:42:39 +03:00
=? net.point (gth life.net.point 0)
2021-03-18 23:32:32 +03:00
[+(life) 0 +(rift) sponsor escape]:net.point
=. own.point [owner.own.point *address *address *address *address]
`point
2021-03-17 04:25:27 +03:00
::
++ process-spawn
|= [=ship to=address]
^- (unit [effects ^state])
2021-04-01 04:17:37 +03:00
=/ parent=^ship (sein ship)
2021-03-17 04:25:27 +03:00
:: Assert parent is on L2
::
=/ parent-point (get-point state parent)
?~ parent-point ~
?. ?=(?(%l2 %spawn) -.u.parent-point) ~
2021-03-17 04:25:27 +03:00
:: Assert signer is owner or spawn proxy
::
?. ?| =(owner.own.u.parent-point signer)
=(spawn-proxy.own.u.parent-point signer)
2021-03-17 04:25:27 +03:00
==
~
2021-03-17 04:25:27 +03:00
:: Assert child not already spawned
::
:: TODO: verify this means the ship exists on neither L1 nor L2
::
?: (~(has by points.state) ship) ~
2021-03-17 04:25:27 +03:00
:: Assert one-level-down
::
?. =(+((ship-rank parent)) (ship-rank ship)) ~
2021-03-17 04:25:27 +03:00
:: 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
2021-03-28 05:08:17 +03:00
dominion %l2
owner.own owner.own.u.parent-point
2021-03-17 04:25:27 +03:00
transfer-proxy.own to
==
``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)
2021-03-17 04:25:27 +03:00
=(management-proxy.own.point signer)
==
~
2021-03-17 04:25:27 +03:00
::
2021-03-18 23:32:32 +03:00
=^ rift-effects rift.net.point
?. breach
`rift.net.point
[[ship %rift +(rift.net.point)]~ +(rift.net.point)]
2021-03-17 04:25:27 +03:00
::
=/ =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
2021-03-18 23:32:32 +03:00
?: =(pass.net.point pass) :: TODO: check will always be true
2021-03-17 04:25:27 +03:00
~
[ship %keys life.net.point crypto-suite pass]~
::
`[(welp rift-effects keys-effects) point]
2021-03-17 04:25:27 +03:00
::
++ process-escape
2021-03-18 02:42:39 +03:00
|= [=ship =point parent=ship]
?. ?| =(owner.own.point signer)
2021-03-17 04:25:27 +03:00
=(management-proxy.own.point signer)
==
~
2021-03-17 04:25:27 +03:00
:: TODO: don't allow "peer escape"?
2021-03-18 23:32:32 +03:00
::
?. =(+((ship-rank parent)) (ship-rank ship)) ~
2021-03-17 04:25:27 +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]
?. ?| =(owner.own.point signer)
2021-03-17 04:25:27 +03:00
=(management-proxy.own.point signer)
==
~
2021-03-17 04:25:27 +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?
?~ parent-point ~
2021-03-17 04:25:27 +03:00
::
?. ?| =(owner.own.u.parent-point signer)
=(management-proxy.own.u.parent-point signer)
2021-03-17 04:25:27 +03:00
==
~
2021-03-17 04:25:27 +03:00
::
?. =(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?
?~ parent-point ~
2021-03-17 04:25:27 +03:00
::
?. ?| =(owner.own.u.parent-point signer)
=(management-proxy.own.u.parent-point signer)
2021-03-17 04:25:27 +03:00
==
~
2021-03-17 04:25:27 +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?
?~ parent-point ~
2021-03-17 04:25:27 +03:00
::
?. ?| =(owner.own.u.parent-point signer)
=(management-proxy.own.u.parent-point signer)
2021-03-17 04:25:27 +03:00
==
~
2021-03-17 04:25:27 +03:00
::
:+ ~ [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]
?. ?| =(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-17 04:25:27 +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]
?. ?| =(owner.own.point signer)
2021-03-18 23:32:32 +03:00
=(spawn-proxy.own.point signer)
2021-03-17 04:25:27 +03:00
==
~
2021-03-17 04:25:27 +03:00
::
`point(spawn-proxy.own address)
2021-03-17 04:25:27 +03:00
::
++ process-set-voting-proxy
2021-03-18 02:42:39 +03:00
|= [=ship =point =address]
?. ?| =(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-17 04:25:27 +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]
?. ?| =(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-17 04:25:27 +03:00
::
`point(transfer-proxy.own address)
2021-03-17 04:25:27 +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
::
2021-03-18 03:27:30 +03:00
|= [=verifier =state =input]
2021-03-18 02:42:39 +03:00
^- [effects ^state]
?: ?=(%log -.input)
:: Received log from L1 transaction
::
(receive-log state event-log.input)
2021-03-28 05:08:17 +03:00
:: Received L2 batch
::
2021-03-28 05:08:17 +03:00
(receive-batch verifier state batch.input)