naive: clean up updating predicted state

This commit is contained in:
yosoyubik 2021-06-24 16:56:32 +02:00
parent d03d710796
commit 8ea0ee004e

View File

@ -262,8 +262,8 @@
[%predict ~] [%predict ~]
?+ +<.sign-arvo (on-arvo:def wire sign-arvo) ?+ +<.sign-arvo (on-arvo:def wire sign-arvo)
%wake %wake
=^ pending pre (predicted-state:do canonical-state:do) :- ~
[~ this(pending pending, flush &)] this(flush &, pre (predicted-state canonical-state):do)
== ==
:: ::
[%resend @ @ ~] [%resend @ @ ~]
@ -351,14 +351,12 @@
[cards this] [cards this]
:: ::
%naive-state %naive-state
~& > %received-naive-state
:- ~
:: cache naive state, received upon innitializing subscription :: cache naive state, received upon innitializing subscription
:: this assumes that /app/azimuth has already processed eth data
:: ::
~& > %get-naive-state this(pre (predicted-state:do !<(^state:naive q.cage.sign)))
:: this assumes that %azimuth has already processed eth data
::
=^ pending pre
(predicted-state:do !<(^state:naive q.cage.sign))
[~ this(pending pending)]
== ==
== ==
:: ::
@ -451,7 +449,7 @@
%don [(gen-tx-octs:lib +.part-tx) +.part-tx] %don [(gen-tx-octs:lib +.part-tx) +.part-tx]
%ful +.part-tx %ful +.part-tx
== ==
:: +canonical-state: load current l2 state instead :: +canonical-state: load current l2 state from /app/azimuth
:: ::
++ canonical-state ++ canonical-state
.^ ^state:naive .^ ^state:naive
@ -468,11 +466,13 @@
:: ::
++ predicted-state ++ predicted-state
|= nas=^state:naive |= nas=^state:naive
^- [_pending _nas] ^+ nas
|^ |^
=^ new-sending nas apply-sending =^ sending nas apply-sending
=. sending new-sending =^ pending nas (update-txs pending %pending)
(update-txs pending %pending) =. sending.state sending
=. pending.state pending
nas
:: ::
++ apply-sending ++ apply-sending
=| valid=_sending =| valid=_sending
@ -496,6 +496,7 @@
=/ valid=_txs ~ =/ valid=_txs ~
|- ^+ [valid nas] |- ^+ [valid nas]
?~ txs [valid nas] ?~ txs [valid nas]
::
=* tx i.txs =* tx i.txs
=^ gud=? nas (try-apply nas [force raw-tx]:tx) =^ gud=? nas (try-apply nas [force raw-tx]:tx)
=? valid gud (snoc valid tx) =? valid gud (snoc valid tx)
@ -519,10 +520,8 @@
?. (verify-sig-and-nonce:naive verifier:lib chain-t nas raw-tx) ?. (verify-sig-and-nonce:naive verifier:lib chain-t nas raw-tx)
~& [%verify-sig-and-nonce %failed] ~& [%verify-sig-and-nonce %failed]
[force nas] [force nas]
::
=^ * points.nas =^ * points.nas
(increment-nonce:naive nas from.tx.raw-tx) (increment-nonce:naive nas from.tx.raw-tx)
::
?~ nex=(receive-tx:naive nas tx.raw-tx) ?~ nex=(receive-tx:naive nas tx.raw-tx)
[force nas] [force nas]
[& +.u.nex] [& +.u.nex]
@ -661,8 +660,7 @@
:: ::
++ on-timer ++ on-timer
^- (quip card _state) ^- (quip card _state)
=^ new-pending pre (predicted-state canonical-state) =. pre (predicted-state canonical-state)
=. pending new-pending
=^ cards state =^ cards state
?: =(~ pending) [~ state] ?: =(~ pending) [~ state]
?~ next-nonce ?~ next-nonce