mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-03 02:35:52 +03:00
roller: clean up
This commit is contained in:
parent
31e5dd206d
commit
d559ad35bc
@ -73,7 +73,8 @@
|
||||
chain-id=@
|
||||
==
|
||||
::
|
||||
+$ init [nas=^state:naive own=owners]
|
||||
+$ init [nas=^state:naive own=owners]
|
||||
::
|
||||
+$ config
|
||||
$% [%frequency frequency=@dr]
|
||||
[%setkey pk=@]
|
||||
@ -82,14 +83,13 @@
|
||||
==
|
||||
::
|
||||
+$ action
|
||||
$% :: we need to include the address here so pending txs show up
|
||||
$% :: we need to include the address in submit so pending txs show up
|
||||
:: in the tx history, but because users can send the wrong
|
||||
:: address, in +update-tx:predicted state, we just replace
|
||||
:: address, in +apply-tx:predicted state, we just replace
|
||||
:: the provided address, with the one used when the message was signed;
|
||||
::
|
||||
:: we need to do it there to know the correct nonce that the signed
|
||||
:: message should have included.
|
||||
:: note: currently turned off (extract-address is giving the wrong address)
|
||||
::
|
||||
[%submit force=? =address:naive sig=@ tx=part-tx]
|
||||
[%cancel sig=@ keccak=@ =l2-tx =ship]
|
||||
@ -159,6 +159,7 @@
|
||||
:: /x/point/[~ship] -> %noun point:naive
|
||||
:: /x/points/[0xadd.ress] -> %noun (list [ship point:naive])
|
||||
:: /x/config -> %noun config
|
||||
:: /x/chain-id -> %atom @
|
||||
::
|
||||
++ on-peek
|
||||
|= =path
|
||||
@ -483,7 +484,7 @@
|
||||
%don [(gen-tx-octs:lib +.part-tx) +.part-tx]
|
||||
%ful +.part-tx
|
||||
==
|
||||
:: +canonical-state: load current l2 state from /app/azimuth
|
||||
:: +canonical-state: current l2 state from /app/azimuth
|
||||
::
|
||||
++ canonical-state
|
||||
.^ ^state:naive
|
||||
@ -493,7 +494,7 @@
|
||||
(scot %da now.bowl)
|
||||
/nas/noun
|
||||
==
|
||||
:: +canonical-owners: load current azimuth point ownership
|
||||
:: +canonical-owners: current azimuth point ownership
|
||||
::
|
||||
++ canonical-owners
|
||||
.^ owners
|
||||
@ -505,8 +506,8 @@
|
||||
==
|
||||
:: +predicted-state
|
||||
::
|
||||
:: derives predicted state from pending/sending txs and
|
||||
:: canonical state, discarding invalid txs in the process.
|
||||
:: derives predicted state from applying pending/sending txs to
|
||||
:: the canonical state, discarding invalid txs in the process.
|
||||
::
|
||||
++ predicted-state
|
||||
|= nas=^state:naive
|
||||
@ -514,11 +515,11 @@
|
||||
=. pre.state nas
|
||||
|^
|
||||
=^ nes state apply-sending
|
||||
=^ nep state (update-txs pending %pending)
|
||||
%_ state
|
||||
sending nes
|
||||
pending nep
|
||||
==
|
||||
=^ nep state apply-pending
|
||||
state(sending nes, pending nep)
|
||||
::
|
||||
++ apply-pending
|
||||
(apply-txs pending %pending)
|
||||
::
|
||||
++ apply-sending
|
||||
=| valid=_sending
|
||||
@ -529,7 +530,7 @@
|
||||
=* key p.i.sending
|
||||
=* val q.i.sending
|
||||
=^ new-valid state
|
||||
%+ update-txs
|
||||
%+ apply-txs
|
||||
(turn txs.val |=(=raw-tx:naive [| 0x0 raw-tx]))
|
||||
%sending
|
||||
=. valid
|
||||
@ -537,7 +538,7 @@
|
||||
val(txs (turn new-valid (cork tail tail)))
|
||||
$(sending t.sending)
|
||||
::
|
||||
++ update-txs
|
||||
++ apply-txs
|
||||
|= [txs=(list pend-tx) type=?(%pending %sending)]
|
||||
=/ valid=_txs ~
|
||||
=| local=(set keccak)
|
||||
@ -565,8 +566,8 @@
|
||||
(~(put by finding.state) [hash %failed])
|
||||
=? history.state !gud
|
||||
=/ =roller-tx
|
||||
[ship [type ~] hash (l2-tx +<.tx.raw-tx)]
|
||||
%. [address.tx roller-tx(status [%failed ~])]
|
||||
[ship type hash (l2-tx +<.tx.raw-tx)]
|
||||
%. [address.tx roller-tx(status %failed)]
|
||||
~(put ju (~(del ju history.state) address.tx roller-tx))
|
||||
$(txs t.txs, local (~(put in local) hash))
|
||||
::
|
||||
@ -658,7 +659,7 @@
|
||||
::
|
||||
=. history
|
||||
%+ ~(del ju history) u.addr
|
||||
[ship [%pending ~] keccak l2-tx]
|
||||
[ship %pending keccak l2-tx]
|
||||
=. pending
|
||||
%+ skip pending
|
||||
|= pend-tx
|
||||
@ -682,7 +683,7 @@
|
||||
:: =? history not-sent
|
||||
=. history
|
||||
%+ ~(put ju history) address
|
||||
[ship.from.tx.raw-tx [%pending ~] hash (l2-tx +<.tx.raw-tx)]
|
||||
[ship.from.tx.raw-tx %pending hash (l2-tx +<.tx.raw-tx)]
|
||||
=? transfers =(%transfer-point (l2-tx +<.tx.raw-tx))
|
||||
(~(put by transfers) ship.from.tx.raw-tx address)
|
||||
:: ?. not-sent ~& "skip" [~ state]
|
||||
@ -729,12 +730,12 @@
|
||||
|= [pend-tx hist=_history]
|
||||
=/ tx=roller-tx
|
||||
:^ ship.from.tx.raw-tx
|
||||
[%pending ~]
|
||||
%pending
|
||||
(hash-raw-tx:lib raw-tx)
|
||||
(l2-tx +<.tx.raw-tx)
|
||||
%+ ~(put ju (~(del ju hist) address tx))
|
||||
address
|
||||
tx(status [%sending ~])
|
||||
tx(status %sending)
|
||||
==
|
||||
[(send-roll get-address nonce) state]
|
||||
=^ card next-batch set-timer
|
||||
@ -842,7 +843,7 @@
|
||||
::
|
||||
=. history
|
||||
=/ l2-tx (l2-tx +<.tx.raw-tx.diff)
|
||||
=/ tx=roller-tx [ship [%sending ~] keccak l2-tx]
|
||||
=/ tx=roller-tx [ship %sending keccak l2-tx]
|
||||
?~ addr=(get-l1-address tx.raw-tx.diff pre)
|
||||
history
|
||||
=/ =address:ethereum
|
||||
@ -854,7 +855,7 @@
|
||||
%+ ~(put ju (~(del ju history) address tx))
|
||||
address
|
||||
%_ tx
|
||||
status ?~(err.diff [%confirmed ~] [%failed ~])
|
||||
status ?~(err.diff %confirmed %failed)
|
||||
==
|
||||
:_ state(derive-p ?:(derive-p | derive-p))
|
||||
?. derive-p ~
|
||||
|
@ -77,7 +77,7 @@
|
||||
::
|
||||
++ run-logs
|
||||
|= [state=app-state logs=(list event-log:rpc:ethereum)]
|
||||
^- [(list tagged-diff) _state]
|
||||
^- (quip tagged-diff _state)
|
||||
=/ [contract=@ux * chain-id=@ *] (get-network net)
|
||||
?~ logs
|
||||
`state
|
||||
@ -342,14 +342,7 @@
|
||||
%logs (welp logs.state loglist.diff)
|
||||
==
|
||||
=? nas.state ?=(%history -.diff) *^state:naive
|
||||
=^ effects state
|
||||
=; nas=^state:naive
|
||||
(run-logs state(nas nas) loglist.diff)
|
||||
?- -.diff
|
||||
:: %history *^state:naive
|
||||
%history nas.state
|
||||
%logs nas.state
|
||||
==
|
||||
=^ effects state (run-logs state loglist.diff)
|
||||
::
|
||||
:_ this
|
||||
%+ weld
|
||||
|
@ -189,17 +189,16 @@
|
||||
^- json
|
||||
%- pairs
|
||||
:~ ['force' b+force]
|
||||
['address' s+(crip "0x{((x-co:co 20) address)}")]
|
||||
(en-address address)
|
||||
::
|
||||
:- 'rawTx'
|
||||
%- pairs
|
||||
:~ ['tx' (tx:to-json tx.raw-tx)]
|
||||
::
|
||||
:+ 'sig' %s
|
||||
%- crip
|
||||
"0x{((x-co:co (met 3 sig.raw-tx)) sig.raw-tx)}"
|
||||
['sig' (hex (as-octs:mimes:html sig.raw-tx))]
|
||||
== ==
|
||||
::
|
||||
++ en-address |=(a=@ux address+(hex 20 a))
|
||||
::
|
||||
++ tx
|
||||
|= =tx:naive
|
||||
^- json
|
||||
@ -235,7 +234,6 @@
|
||||
== ==
|
||||
::
|
||||
++ en-ship |=(s=@p ship+(ship s))
|
||||
++ en-address |=(a=@ux address+s+(crip "0x{((x-co:co 20) a)}"))
|
||||
++ en-spawn |=([s=@p a=@ux] ~[(en-ship s) (en-address a)])
|
||||
++ en-transfer |=([a=@ux r=?] ~[(en-address a) reset+b+r])
|
||||
++ en-keys
|
||||
@ -261,8 +259,8 @@
|
||||
|= roller-tx
|
||||
^- json
|
||||
%- pairs
|
||||
:~ ['status' s+status.status]
|
||||
['hash' s+(crip "0x{((x-co:co 20) hash)}")]
|
||||
:~ ['status' s+status]
|
||||
['hash' (hex (as-octs:mimes:html hash))]
|
||||
['type' s+type]
|
||||
==
|
||||
::
|
||||
@ -325,7 +323,7 @@
|
||||
|= [=address:naive =nonce:naive]
|
||||
^- json
|
||||
%- pairs
|
||||
:~ ['address' s+(crip "0x{((x-co:co 20) address)}")]
|
||||
:~ (en-address address)
|
||||
['nonce' (numb nonce)]
|
||||
==
|
||||
::
|
||||
@ -334,10 +332,10 @@
|
||||
^- json
|
||||
:- %a
|
||||
%+ turn children
|
||||
|= [child=@p addr=@ux]
|
||||
|= [child=@p address=@ux]
|
||||
%- pairs
|
||||
:~ ['ship' (ship child)]
|
||||
['address' s+(crip "0x{((x-co:co 20) addr)}")]
|
||||
(en-address address)
|
||||
==
|
||||
::
|
||||
++ tx-status |=(=^tx-status ^-(json s+status.tx-status))
|
||||
@ -349,9 +347,14 @@
|
||||
:~ ['nextBatch' (time next-batch)]
|
||||
['frequency' (numb (div frequency ~s1))]
|
||||
['refreshTime' (numb (div refresh-time ~s1))]
|
||||
['contract' s+(crip "0x{((x-co:co 20) contract)}")]
|
||||
['contract' (hex 20 contract)]
|
||||
['chainId' (numb chain-id)]
|
||||
==
|
||||
::
|
||||
++ hex
|
||||
|= [p=@ q=@]
|
||||
^- json
|
||||
s+(crip "0x{((x-co:co p) q)}")
|
||||
--
|
||||
::
|
||||
++ to-hex
|
||||
@ -367,11 +370,6 @@
|
||||
=((lent ~(tap by params)) 4)
|
||||
--
|
||||
::
|
||||
++ l2-hash
|
||||
|= =keccak
|
||||
^- json
|
||||
s+(crip "0x{((x-co:co 20) keccak)}")
|
||||
::
|
||||
++ build-l2-tx
|
||||
|= [=l2-tx from=[@p proxy:naive] params=(map @t json)]
|
||||
^- (unit tx:naive)
|
||||
@ -479,8 +477,8 @@
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
=/ tx=(unit tx:naive) (build-l2-tx action u.from params)
|
||||
?~ tx [~ ~(parse error:json-rpc id)]
|
||||
=/ =keccak (hash-tx:lib (gen-tx-octs:lib u.tx))
|
||||
:_ [%result id (l2-hash:to-json keccak)]
|
||||
=+ (gen-tx-octs:lib u.tx)
|
||||
:_ [%result id (hex:to-json p (hash-tx:lib p q))]
|
||||
%- some
|
||||
aggregator-action+!>([%submit | u.addr u.sig %don tx])
|
||||
::
|
||||
@ -573,7 +571,6 @@
|
||||
=/ tx=(unit tx:naive) (build-l2-tx u.l2-tx u.from params)
|
||||
?~ tx ~(parse error:json-rpc id)
|
||||
:+ %result id
|
||||
%- l2-hash:to-json
|
||||
%- hash-tx:lib
|
||||
=- (hex:to-json p (hash-tx:lib p q))
|
||||
(unsigned-tx:lib u.nonce chain-id (gen-tx-octs:lib u.tx))
|
||||
--
|
||||
|
@ -15,8 +15,11 @@
|
||||
::
|
||||
+$ keccak @ux
|
||||
::
|
||||
+$ status
|
||||
?(%unknown %pending %sending %confirmed %failed)
|
||||
::
|
||||
+$ tx-status
|
||||
$: status=?(%unknown %pending %sending %confirmed %failed)
|
||||
$: =status
|
||||
pointer=(unit l1-tx-pointer)
|
||||
==
|
||||
::
|
||||
@ -41,7 +44,7 @@
|
||||
::
|
||||
:: TODO: add submission time?
|
||||
::
|
||||
+$ roller-tx [=ship status=tx-status hash=keccak type=l2-tx]
|
||||
+$ roller-tx [=ship =status hash=keccak type=l2-tx]
|
||||
::
|
||||
+$ pend-tx [force=? =address:naive =raw-tx:naive]
|
||||
::
|
||||
|
@ -1,6 +1,6 @@
|
||||
:: aggregator/send: send rollup tx
|
||||
::
|
||||
/- rpc=json-rpc, *aggregator
|
||||
/- rpc=json-rpc, *dice
|
||||
/+ naive, ethereum, ethio, strandio
|
||||
::
|
||||
::
|
||||
|
Loading…
Reference in New Issue
Block a user