Merge remote-tracking branch 'origin/philip/naive' into naive/roller

This commit is contained in:
yosoyubik 2021-09-27 16:29:12 +02:00
parent a7ff010768
commit f243500068
6 changed files with 745 additions and 785 deletions

View File

@ -223,6 +223,7 @@
$(logs t.logs) $(logs t.logs)
=/ [raw-effects=effects:naive new-nas=_nas.state] =/ [raw-effects=effects:naive new-nas=_nas.state]
=/ =^input:naive =/ =^input:naive
:- block-number.u.mined.i.logs
?: =(azimuth.net address.i.logs) ?: =(azimuth.net address.i.logs)
=/ data (data-to-hex data.i.logs) =/ data (data-to-hex data.i.logs)
=/ =event-log:naive =/ =event-log:naive

View File

@ -605,7 +605,7 @@
^- [octs tx:naive] ^- [octs tx:naive]
?- -.part-tx ?- -.part-tx
%raw %raw
?~ batch=(parse-raw-tx:naive q.raw.part-tx) ?~ batch=(parse-raw-tx:naive 0 q.raw.part-tx)
~& %parse-failed ~& %parse-failed
:: TODO: maybe return a unit if parsing fails? :: TODO: maybe return a unit if parsing fails?
:: ::

View File

@ -1,17 +1,5 @@
:: TODO: secp needs to not crash the process when you give it a bad /+ tiny
:: v/recid. See #4797 => => tiny
::
:: TODO: check if spawning is gated on "link"ing. It is on L1, but we
:: shouldn't do that here.
::
:: TODO: make sure you can spawn with the spawn proxy after on domain
:: %spawn
::
:: TODO: make sure that if we've already been deposited to L2, no
:: further L1 logs count except detach.
::
/+ std
=> => std
:: Laconic bit :: Laconic bit
:: ::
=| lac=? =| lac=?
@ -20,8 +8,6 @@
|% |%
:: Transfers on L1 to this address count as depositing to L2 :: Transfers on L1 to this address count as depositing to L2
:: ::
:: 0x1234567890123456789012345678901234567890
::
++ deposit-address 0x1111.1111.1111.1111.1111.1111.1111.1111.1111.1111 ++ deposit-address 0x1111.1111.1111.1111.1111.1111.1111.1111.1111.1111
++ log-names ++ log-names
|% |%
@ -192,9 +178,10 @@
topics=(lest @ux) topics=(lest @ux)
== ==
+$ input +$ input
$: block=@ud
$% [%bat batch=@] $% [%bat batch=@]
[%log =event-log] [%log =event-log]
== == ==
:: ECDSA verifier. :: ECDSA verifier.
:: ::
:: Must keccak `dat` and recover the ethereum address which signed. :: Must keccak `dat` and recover the ethereum address which signed.
@ -215,39 +202,34 @@
++ parse-roll ++ parse-roll
|= batch=@ |= batch=@
=| =roll =| =roll
=| pos=@ud
=/ las (met 0 batch)
|- ^+ roll |- ^+ roll
?~ batch ?: (gte pos las)
(flop roll) (flop roll)
=/ parse-result (parse-raw-tx batch) =/ parse-result (parse-raw-tx pos batch)
:: Parsing failed, abort batch :: Parsing failed, abort batch
:: ::
?~ parse-result ?~ parse-result
(debug %parse-failed ~) (debug %parse-failed ~)
=^ =raw-tx batch u.parse-result =^ =raw-tx pos u.parse-result
$(roll [raw-tx roll]) $(roll [raw-tx roll])
:: ::
:: TODO: change batch to be a cursor to avoid allocating atoms
::
++ parse-raw-tx ++ parse-raw-tx
|= batch=@ |= [pos=@ud batch=@]
^- (unit [raw-tx rest=@]) ^- (unit [raw-tx pos=@ud])
=/ batch [len=0 rest=batch]
|^ |^
=^ sig batch (take 3 65) =^ sig pos (take 3 65)
=. len.batch 0 =/ res=(unit [=tx pos=@ud]) parse-tx
=/ orig-batch rest.batch ?~ res ~
=/ res=(unit [=tx batch=_batch]) parse-tx =/ dif (sub pos.u.res pos)
?~ res =/ len =>((dvr dif 8) ?>(=(0 q) p))
~ :- ~ :_ pos.u.res
:- ~ :_ rest.batch.u.res [sig [len (cut 0 [pos dif] batch)] tx.u.res]
=/ len-bytes
?> =(0 (mod len.batch.u.res 8))
(div len.batch.u.res 8)
[sig [len-bytes (end [0 len.batch.u.res] orig-batch)] tx.u.res]
:: ::
++ parse-tx ++ parse-tx
^- (unit [tx _batch]) ^- (unit [tx pos=@ud])
=^ from-proxy=@ batch (take 0 3) =^ from-proxy=@ pos (take 0 3)
?. ?=(?(%0 %1 %2 %3 %4) from-proxy) (debug %bad-proxy ~) ?. ?=(?(%0 %1 %2 %3 %4) from-proxy) (debug %bad-proxy ~)
=/ =proxy =/ =proxy
?- from-proxy ?- from-proxy
@ -257,68 +239,65 @@
%3 %vote %3 %vote
%4 %transfer %4 %transfer
== ==
=^ pad batch (take 0 5) =^ pad pos (take 0 5)
=^ from-ship=ship batch (take 3 4) =^ from-ship=ship pos (take 3 4)
=- ?~ res =- ?~ res
~ ~
`[[[from-ship proxy] skim-tx.u.res] batch.u.res] `[[[from-ship proxy] skim-tx.u.res] pos.u.res]
^- res=(unit [=skim-tx =_batch]) ^- res=(unit [=skim-tx pos=@ud])
=^ op batch (take 0 7) =^ op pos (take 0 7)
?+ op ~>(%slog.[0 %strange-opcode] ~) ?+ op ~>(%slog.[0 %strange-opcode] ~)
%0 %0
=^ reset=@ batch (take 0) =^ reset=@ pos (take 0)
=^ =address batch (take 3 20) =^ =address pos (take 3 20)
`[[%transfer-point address =(0 reset)] batch] `[[%transfer-point address =(0 reset)] pos]
:: ::
%1 %1
=^ pad=@ batch (take 0) =^ pad=@ pos (take 0)
=^ =ship batch (take 3 4) =^ =ship pos (take 3 4)
=^ =address batch (take 3 20) =^ =address pos (take 3 20)
`[[%spawn ship address] batch] `[[%spawn ship address] pos]
:: ::
%2 %2
=^ breach=@ batch (take 0) =^ breach=@ pos (take 0)
=^ encrypt=@ batch (take 3 32) =^ encrypt=@ pos (take 3 32)
=^ auth=@ batch (take 3 32) =^ auth=@ pos (take 3 32)
=^ crypto-suite=@ batch (take 3 4) =^ crypto-suite=@ pos (take 3 4)
`[[%configure-keys encrypt auth crypto-suite =(0 breach)] batch] `[[%configure-keys encrypt auth crypto-suite =(0 breach)] pos]
:: ::
%3 =^(res batch take-escape `[[%escape res] batch]) %3 =^(res pos take-ship `[[%escape res] pos])
%4 =^(res batch take-escape `[[%cancel-escape res] batch]) %4 =^(res pos take-ship `[[%cancel-escape res] pos])
%5 =^(res batch take-escape `[[%adopt res] batch]) %5 =^(res pos take-ship `[[%adopt res] pos])
%6 =^(res batch take-escape `[[%reject res] batch]) %6 =^(res pos take-ship `[[%reject res] pos])
%7 =^(res batch take-escape `[[%detach res] batch]) %7 =^(res pos take-ship `[[%detach res] pos])
%8 %8 =^(res pos take-address `[[%set-management-proxy res] pos])
=^(res batch take-ship-address `[[%set-management-proxy res] batch]) %9 =^(res pos take-address `[[%set-spawn-proxy res] pos])
:: %10 =^(res pos take-address `[[%set-transfer-proxy res] pos])
%9 =^(res batch take-ship-address `[[%set-spawn-proxy res] batch])
%10 =^(res batch take-ship-address `[[%set-transfer-proxy res] batch])
== ==
:: ::
:: Take a bite :: Take a bite
:: ::
++ take ++ take
|= =bite |= =bite
^- [@ _batch] ^- [@ @ud]
:- (end bite +.batch) =/ =step
:- %+ add -.batch
?@ bite (bex bite) ?@ bite (bex bite)
(mul step.bite (bex bloq.bite)) (mul step.bite (bex bloq.bite))
(rsh bite +.batch) [(cut 0 [pos step] batch) (add pos step)]
:: Encode ship and address :: Encode ship and address
:: ::
++ take-ship-address ++ take-address
^- [address _batch] ^- [address @ud]
=^ pad=@ batch (take 0) =^ pad=@ pos (take 0)
=^ =address batch (take 3 20) =^ =address pos (take 3 20)
[address batch] [address pos]
:: Encode escape-related txs :: Encode escape-related txs
:: ::
++ take-escape ++ take-ship
^- [ship _batch] ^- [ship @ud]
=^ pad=@ batch (take 0) =^ pad=@ pos (take 0)
=^ other=ship batch (take 3 4) =^ other=ship pos (take 3 4)
[other batch] [other pos]
-- --
:: ::
++ proxy-from-point ++ proxy-from-point
@ -402,10 +381,12 @@
:: ::
++ ud-to-ascii ++ ud-to-ascii
|= n=@ud |= n=@ud
^- @t ?~ n '0'
?~ n =| l=(list @)
*@t |- ^- @t
(cat 3 $(n (div n 10)) (add '0' (mod n 10))) ?~ n (rep 3 l)
=+ (dvr n 10)
$(n p, l [(add '0' q) l])
:: ::
++ ship-rank ++ ship-rank
|= =ship |= =ship
@ -469,7 +450,7 @@
=/ words (rip 8 data.log) =/ words (rip 8 data.log)
:: This is only true if each domain is <= 32 bytes :: This is only true if each domain is <= 32 bytes
:: ::
?> ?=([c=@ @ b=@ @ a=@ @ @ @ @ ~] words) ?. ?=([c=@ @ b=@ @ a=@ @ @ @ @ ~] words) `state
=* one &5.words =* one &5.words
=* two &3.words =* two &3.words
=* tri &1.words =* tri &1.words
@ -802,7 +783,6 @@
:: Assert one-level-down :: Assert one-level-down
:: ::
?. =(+((ship-rank parent)) (ship-rank ship)) (debug %bad-rank ~) ?. =(+((ship-rank parent)) (ship-rank ship)) (debug %bad-rank ~)
:: TODO check spawnlimit
:: ::
=/ [=effects new-point=point] =/ [=effects new-point=point]
=/ point=(unit point) (get-point state ship) =/ point=(unit point) (get-point state ship)
@ -816,8 +796,6 @@
=(to address.spawn-proxy.own.u.parent-point) =(to address.spawn-proxy.own.u.parent-point)
== ==
== ==
:: TODO: use get-point or duplicate sponsor logic
::
:- ~[[%point ship %dominion %l2] [%point ship %owner to]] :- ~[[%point ship %dominion %l2] [%point ship %owner to]]
u.point(address.owner.own to) u.point(address.owner.own to)
:: Else spawn to parent and set transfer proxy :: Else spawn to parent and set transfer proxy
@ -863,7 +841,7 @@
(debug %bad-rank ~) (debug %bad-rank ~)
:: ::
:+ ~ [%point ship %escape `parent]~ :+ ~ [%point ship %escape `parent]~
point(escape.net `parent) :: TODO: omitting a lot of source material? point(escape.net `parent)
:: ::
++ process-cancel-escape ++ process-cancel-escape
|= [=point parent=ship] |= [=point parent=ship]
@ -877,8 +855,6 @@
++ process-adopt ++ process-adopt
|= [=point =ship] |= [=point =ship]
=* parent ship.from.tx =* parent ship.from.tx
:: TODO: assert child/parent on L2?
::
?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx)) ?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
(debug %bad-permission ~) (debug %bad-permission ~)
:: ::
@ -939,7 +915,7 @@
:: ::
|= [=verifier chain-id=@ud =state =input] |= [=verifier chain-id=@ud =state =input]
^- [effects ^state] ^- [effects ^state]
?: ?=(%log -.input) ?: ?=(%log +<.input)
:: Received log from L1 transaction :: Received log from L1 transaction
:: ::
(receive-log state event-log.input) (receive-log state event-log.input)

View File

@ -82,6 +82,12 @@
?: (lth a b) c ?: (lth a b) c
$(a (sub a b), c +(c)) $(a (sub a b), c +(c))
:: ::
++ dvr :: divide w/remainder
~/ %dvr
|: [a=`@`1 b=`@`1]
^- [p=@ q=@]
[(div a b) (mod a b)]
::
++ mod :: modulus ++ mod :: modulus
~/ %mod ~/ %mod
|: [a=`@`1 b=`@`1] |: [a=`@`1 b=`@`1]
@ -210,15 +216,10 @@
(add (lsh [a (met a b)] c) b) (add (lsh [a (met a b)] c) b)
:: ::
++ cut :: slice ++ cut :: slice
~/ %cut :: TODO: jet ~/ %cut
|= [a=bloq [b=step c=step] d=@] |= [a=bloq [b=step c=step] d=@]
(end [a c] (rsh [a b] d)) (end [a c] (rsh [a b] d))
:: ::
++ dad :: concatenate fixed
~/ %dad
|= [=bite a=@ b=@]
(add a (lsh bite b))
::
++ can :: assemble ++ can :: assemble
~/ %can ~/ %can
|= [a=bloq b=(list [p=step q=@])] |= [a=bloq b=(list [p=step q=@])]

File diff suppressed because it is too large Load Diff

View File

@ -2101,6 +2101,7 @@ u3j_core _a50_d[] =
{ { "add", 7, _140_one_add_a, 0, _140_one_add_ha }, { { "add", 7, _140_one_add_a, 0, _140_one_add_ha },
{ "dec", 7, _140_one_dec_a, 0, _140_one_dec_ha }, { "dec", 7, _140_one_dec_a, 0, _140_one_dec_ha },
{ "div", 7, _140_one_div_a, 0, _140_one_div_ha }, { "div", 7, _140_one_div_a, 0, _140_one_div_ha },
{ "dvr", 7, _140_one_dvr_a, 0, _140_one_dvr_ha },
{ "gte", 7, _140_one_gte_a, 0, _140_one_gte_ha }, { "gte", 7, _140_one_gte_a, 0, _140_one_gte_ha },
{ "gth", 7, _140_one_gth_a, 0, _140_one_gth_ha }, { "gth", 7, _140_one_gth_a, 0, _140_one_gth_ha },
{ "lte", 7, _140_one_lte_a, 0, _140_one_lte_ha }, { "lte", 7, _140_one_lte_a, 0, _140_one_lte_ha },
@ -2113,6 +2114,7 @@ u3j_core _a50_d[] =
{ "cat", 7, _140_two_cat_a, 0, _140_two_cat_ha }, { "cat", 7, _140_two_cat_a, 0, _140_two_cat_ha },
{ "can", 7, _140_two_can_a, 0, _140_two_can_ha }, { "can", 7, _140_two_can_a, 0, _140_two_can_ha },
{ "con", 7, _140_two_con_a, 0, _140_two_con_ha }, { "con", 7, _140_two_con_a, 0, _140_two_con_ha },
{ "cut", 7, _140_two_cut_a, 0, _140_two_cut_ha },
{ "dis", 7, _140_two_dis_a, 0, _140_two_dis_ha }, { "dis", 7, _140_two_dis_a, 0, _140_two_dis_ha },
{ "dor", 7, _140_two_dor_a, 0, _140_two_dor_ha }, { "dor", 7, _140_two_dor_a, 0, _140_two_dor_ha },
{ "end", 7, _140_two_end_a, 0, _140_two_end_ha }, { "end", 7, _140_two_end_a, 0, _140_two_end_ha },