mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 08:32:39 +03:00
naive: add ethereum signing address to aggregator sending map
This commit is contained in:
parent
4642ece88f
commit
943eee1db6
@ -31,13 +31,16 @@
|
|||||||
$: %0
|
$: %0
|
||||||
:: pending: the next l2 txs to be sent
|
:: pending: the next l2 txs to be sent
|
||||||
:: sending: the l2 txs currently sending/awaiting l2 confirmation
|
:: sending: the l2 txs currently sending/awaiting l2 confirmation
|
||||||
::TODO should maybe key by [address nonce] instead. same for wires
|
|
||||||
:: finding: raw-tx-hash reverse lookup for sending map
|
:: finding: raw-tx-hash reverse lookup for sending map
|
||||||
:: next-nonce: next l1 nonce to use
|
:: next-nonce: next l1 nonce to use
|
||||||
:: nas: cached naive state
|
:: nas: cached naive state
|
||||||
::
|
::
|
||||||
pending=(list pend-tx)
|
pending=(list pend-tx)
|
||||||
sending=(map nonce:naive [next-gas-price=@ud txs=(list raw-tx:naive)])
|
::
|
||||||
|
$= sending
|
||||||
|
%+ map l1-tx-pointer
|
||||||
|
[next-gas-price=@ud txs=(list raw-tx:naive)]
|
||||||
|
::
|
||||||
finding=(map keccak $?(%confirmed %failed l1-tx-pointer))
|
finding=(map keccak $?(%confirmed %failed l1-tx-pointer))
|
||||||
next-nonce=@ud
|
next-nonce=@ud
|
||||||
nas=^state:naive
|
nas=^state:naive
|
||||||
@ -198,13 +201,13 @@
|
|||||||
^- (quip card _this)
|
^- (quip card _this)
|
||||||
|^
|
|^
|
||||||
?+ wire (on-agent:def wire sign)
|
?+ wire (on-agent:def wire sign)
|
||||||
[%send @t *] (process-send-batch i.t.wire sign)
|
[%send @t @t *] (process-send-batch i.t.wire i.t.t.wire sign)
|
||||||
[%azimuth ~] (process-azimuth-update sign)
|
[%azimuth ~] (process-azimuth-update sign)
|
||||||
[%nonce ~] (process-nonce sign)
|
[%nonce ~] (process-nonce sign)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ process-send-batch
|
++ process-send-batch
|
||||||
|= [nonce=@t =sign:agent:gall]
|
|= [address=@t nonce=@t =sign:agent:gall]
|
||||||
^- (quip card _this)
|
^- (quip card _this)
|
||||||
?- -.sign
|
?- -.sign
|
||||||
%poke-ack
|
%poke-ack
|
||||||
@ -231,13 +234,19 @@
|
|||||||
=+ !<([=term =tang] q.cage.sign)
|
=+ !<([=term =tang] q.cage.sign)
|
||||||
%- (slog leaf+"{(trip dap.bowl)} failed" leaf+<term> tang)
|
%- (slog leaf+"{(trip dap.bowl)} failed" leaf+<term> tang)
|
||||||
=^ cards state
|
=^ cards state
|
||||||
(on-batch-result:do (rash nonce dem) %.n^'thread failed')
|
%^ on-batch-result:do
|
||||||
|
q:(need (de:base16:mimes:html address))
|
||||||
|
(rash nonce dem)
|
||||||
|
%.n^'thread failed'
|
||||||
[cards this]
|
[cards this]
|
||||||
::
|
::
|
||||||
%thread-done
|
%thread-done
|
||||||
=+ !<(result=(each @ud @t) q.cage.sign)
|
=+ !<(result=(each @ud @t) q.cage.sign)
|
||||||
=^ cards state
|
=^ cards state
|
||||||
(on-batch-result:do (rash nonce dem) result)
|
%^ on-batch-result:do
|
||||||
|
q:(need (de:base16:mimes:html address))
|
||||||
|
(rash nonce dem)
|
||||||
|
result
|
||||||
[cards this]
|
[cards this]
|
||||||
==
|
==
|
||||||
==
|
==
|
||||||
@ -344,6 +353,13 @@
|
|||||||
^- @ux
|
^- @ux
|
||||||
(hash-tx raw.raw-tx)
|
(hash-tx raw.raw-tx)
|
||||||
::
|
::
|
||||||
|
++ hex-to-cord
|
||||||
|
|= h=@ux
|
||||||
|
^- @t
|
||||||
|
%- crip
|
||||||
|
=- ((x-co:co (mul 2 p)) q)
|
||||||
|
(as-octs:mimes:html h)
|
||||||
|
::
|
||||||
++ part-tx-to-full
|
++ part-tx-to-full
|
||||||
|= =part-tx
|
|= =part-tx
|
||||||
^- [octs tx:naive]
|
^- [octs tx:naive]
|
||||||
@ -463,6 +479,11 @@
|
|||||||
%cancel
|
%cancel
|
||||||
!! ::TODO
|
!! ::TODO
|
||||||
==
|
==
|
||||||
|
:: TODO: move address to state?
|
||||||
|
::
|
||||||
|
++ get-address
|
||||||
|
^- address:ethereum
|
||||||
|
(address-from-prv:key:ethereum pk)
|
||||||
:: +take-tx: accept submitted l2 tx into the :pending list
|
:: +take-tx: accept submitted l2 tx into the :pending list
|
||||||
::TODO rewrite
|
::TODO rewrite
|
||||||
::
|
::
|
||||||
@ -491,7 +512,8 @@
|
|||||||
next-nonce +(next-nonce)
|
next-nonce +(next-nonce)
|
||||||
::
|
::
|
||||||
sending
|
sending
|
||||||
%+ ~(put by sending) nonce
|
%+ ~(put by sending)
|
||||||
|
[get-address nonce]
|
||||||
[0 (turn pending tail)]
|
[0 (turn pending tail)]
|
||||||
::
|
::
|
||||||
finding
|
finding
|
||||||
@ -500,7 +522,7 @@
|
|||||||
|= [* =raw-tx:naive]
|
|= [* =raw-tx:naive]
|
||||||
[(hash-raw-tx raw-tx) (get-l1-pointer tx.raw-tx nas)]
|
[(hash-raw-tx raw-tx) (get-l1-pointer tx.raw-tx nas)]
|
||||||
==
|
==
|
||||||
[(send-roll nonce) state]
|
[(send-roll get-address nonce) state]
|
||||||
[[set-timer cards] state]
|
[[set-timer cards] state]
|
||||||
:: +get-nonce: retrieves the latest nonce
|
:: +get-nonce: retrieves the latest nonce
|
||||||
::
|
::
|
||||||
@ -512,18 +534,18 @@
|
|||||||
:: +send-roll: start thread to submit roll from :sending to l1
|
:: +send-roll: start thread to submit roll from :sending to l1
|
||||||
::
|
::
|
||||||
++ send-roll
|
++ send-roll
|
||||||
|= nonce=@ud
|
|= [=address:ethereum nonce=@ud]
|
||||||
^- (list card)
|
^- (list card)
|
||||||
:: if this nonce isn't in the sending queue anymore, it's done
|
:: if this nonce isn't in the sending queue anymore, it's done
|
||||||
::
|
::
|
||||||
?. (~(has by sending) nonce)
|
?. (~(has by sending) [address nonce])
|
||||||
~? lverb [dap.bowl %done-sending nonce]
|
~? lverb [dap.bowl %done-sending [address nonce]]
|
||||||
~
|
~
|
||||||
:: start the thread, passing in the l2 txs to use
|
:: start the thread, passing in the l2 txs to use
|
||||||
::
|
::
|
||||||
::TODO should go ahead and set resend timer in case thread hangs, or nah?
|
::TODO should go ahead and set resend timer in case thread hangs, or nah?
|
||||||
%+ start-thread:spider
|
%+ start-thread:spider
|
||||||
/send/(scot %ud nonce)
|
/send/(hex-to-cord address)/(scot %ud nonce)
|
||||||
:- %aggregator-send
|
:- %aggregator-send
|
||||||
!> ^- rpc-send-roll
|
!> ^- rpc-send-roll
|
||||||
:* endpoint
|
:* endpoint
|
||||||
@ -531,17 +553,17 @@
|
|||||||
chain-id
|
chain-id
|
||||||
pk
|
pk
|
||||||
nonce
|
nonce
|
||||||
(~(got by sending) nonce)
|
(~(got by sending) [address nonce])
|
||||||
==
|
==
|
||||||
:: +on-batch-result: await resend after thread success or failure
|
:: +on-batch-result: await resend after thread success or failure
|
||||||
::
|
::
|
||||||
++ on-batch-result
|
++ on-batch-result
|
||||||
|= [nonce=@ud result=(each @ud @t)]
|
|= [=address:ethereum nonce=@ud result=(each @ud @t)]
|
||||||
^- (quip card _state)
|
^- (quip card _state)
|
||||||
:: update gas price for this tx in state
|
:: update gas price for this tx in state
|
||||||
::
|
::
|
||||||
=? sending ?=(%& -.result)
|
=? sending ?=(%& -.result)
|
||||||
%+ ~(jab by sending) nonce
|
%+ ~(jab by sending) [address nonce]
|
||||||
(cork tail (lead p.result))
|
(cork tail (lead p.result))
|
||||||
:: print error if there was one
|
:: print error if there was one
|
||||||
::
|
::
|
||||||
@ -549,7 +571,10 @@
|
|||||||
:: resend the l1 tx in five minutes
|
:: resend the l1 tx in five minutes
|
||||||
::
|
::
|
||||||
:_ state
|
:_ state
|
||||||
[(wait:b:sys /resend/(scot %ud nonce) (add resend-time now.bowl))]~
|
:_ ~
|
||||||
|
%+ wait:b:sys
|
||||||
|
/resend/(hex-to-cord address)/(scot %ud nonce)
|
||||||
|
(add resend-time now.bowl)
|
||||||
:: +on-naive-diff: process l2 tx confirmations
|
:: +on-naive-diff: process l2 tx confirmations
|
||||||
::
|
::
|
||||||
++ on-naive-diff
|
++ on-naive-diff
|
||||||
@ -570,7 +595,7 @@
|
|||||||
:: remove the tx from the sending map
|
:: remove the tx from the sending map
|
||||||
::
|
::
|
||||||
=. sending
|
=. sending
|
||||||
?~ sen=(~(get by sending) nonce)
|
?~ sen=(~(get by sending) [get-address nonce])
|
||||||
~& [dap.bowl %weird-double-remove]
|
~& [dap.bowl %weird-double-remove]
|
||||||
sending
|
sending
|
||||||
?~ nin=(find [raw-tx.diff]~ txs.u.sen)
|
?~ nin=(find [raw-tx.diff]~ txs.u.sen)
|
||||||
@ -578,9 +603,9 @@
|
|||||||
sending
|
sending
|
||||||
=. txs.u.sen (oust [u.nin 1] txs.u.sen)
|
=. txs.u.sen (oust [u.nin 1] txs.u.sen)
|
||||||
?~ txs.u.sen
|
?~ txs.u.sen
|
||||||
~? lverb [dap.bowl %done-with-nonce nonce]
|
~? lverb [dap.bowl %done-with-nonce [get-address nonce]]
|
||||||
(~(del by sending) nonce)
|
(~(del by sending) [get-address nonce])
|
||||||
(~(put by sending) nonce u.sen)
|
(~(put by sending) [get-address nonce] u.sen)
|
||||||
:: update the finding map with the new status
|
:: update the finding map with the new status
|
||||||
::
|
::
|
||||||
=. finding
|
=. finding
|
||||||
|
Loading…
Reference in New Issue
Block a user