2018-09-07 19:29:41 +03:00
|
|
|
::
|
2018-11-14 05:18:01 +03:00
|
|
|
:: there's a small state machine here that goes like this (happy path):
|
|
|
|
:: =/ wen ~
|
|
|
|
:: apex
|
|
|
|
:: -> [if =(~ wen)]
|
|
|
|
:: -> apex
|
|
|
|
:: [else]
|
|
|
|
:: -> wen=`(add now ~s10)
|
|
|
|
:: -> send-next-batch
|
|
|
|
:: [n times]
|
|
|
|
:: -> eth-send-raw-transaction
|
|
|
|
:: -> sigh-send
|
|
|
|
:: -> wait 30s in behn
|
|
|
|
:: -> wake-see
|
|
|
|
:: [n times]
|
|
|
|
:: -> wen=~
|
|
|
|
:: -> eth-get-transaction-receipt
|
|
|
|
:: -> sigh-see
|
|
|
|
:: -> apex
|
|
|
|
::
|
2018-09-07 19:29:41 +03:00
|
|
|
/+ ceremony
|
|
|
|
::
|
|
|
|
|%
|
|
|
|
++ state
|
|
|
|
$: txs=(list @ux)
|
2018-09-12 19:15:46 +03:00
|
|
|
see=(set @ux)
|
2018-11-14 05:18:01 +03:00
|
|
|
wen=(unit @da)
|
2018-09-07 19:29:41 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ move (pair bone card)
|
|
|
|
++ card
|
2018-11-09 00:25:20 +03:00
|
|
|
$% [%hiss wire ~ mark %hiss hiss:eyre]
|
2018-11-10 02:24:31 +03:00
|
|
|
[%info wire ship desk nori:clay]
|
2018-11-14 05:18:01 +03:00
|
|
|
[%rest wire @da]
|
2018-09-07 19:29:41 +03:00
|
|
|
[%wait wire @da]
|
|
|
|
==
|
|
|
|
--
|
|
|
|
::
|
|
|
|
|_ [bol=bowl:gall state]
|
|
|
|
::
|
2018-09-12 19:15:46 +03:00
|
|
|
++ this .
|
2018-11-14 05:18:01 +03:00
|
|
|
++ pretty-see (turn (sort (turn ~(tap in see) mug) lth) @p)
|
2018-09-12 19:15:46 +03:00
|
|
|
::
|
|
|
|
++ prep
|
|
|
|
|= old=(unit *)
|
2018-11-14 05:18:01 +03:00
|
|
|
?: ?=([~ * * ~ @da] old)
|
|
|
|
~& [%cancelling +>+>.old]
|
|
|
|
[[ost.bol %rest /see +>+>.old]~ ..prep]
|
2018-09-12 19:15:46 +03:00
|
|
|
[~ ..prep]
|
|
|
|
::
|
2018-11-10 02:24:31 +03:00
|
|
|
:: usage:
|
|
|
|
::
|
2018-11-15 05:05:08 +03:00
|
|
|
:: generate txs starting from nonce 0 on fake chain at 11 gwei
|
|
|
|
:: from address; store at path
|
|
|
|
:: :send-txs [%gen %/txs/eth-txs %fake 0 11 '0x0000000']
|
2018-11-10 02:24:31 +03:00
|
|
|
::
|
|
|
|
:: generate txs starting from nonce 0 on fake chain at 11 gwei;
|
|
|
|
:: store at path
|
2018-11-15 05:05:08 +03:00
|
|
|
:: :send-txs [%sign %/txs/txt %/txs/eth-txs %/pk/txt]
|
|
|
|
::
|
|
|
|
:: send all but first 50 txs from path
|
|
|
|
:: :send-txs [%send %/txs/txt 50]
|
2018-11-10 02:24:31 +03:00
|
|
|
::
|
2018-09-07 19:29:41 +03:00
|
|
|
++ poke-noun
|
2018-11-15 05:05:08 +03:00
|
|
|
|= $% $: %gen
|
|
|
|
pax=path
|
|
|
|
net=?(%fake %main %ropsten)
|
|
|
|
nonce=@ud
|
|
|
|
gas-price=@ud
|
|
|
|
addr=@t
|
|
|
|
==
|
|
|
|
[%sign out=path in=path key=path]
|
|
|
|
[%send pax=path skip=@ud]
|
2018-11-10 02:24:31 +03:00
|
|
|
==
|
2018-09-12 19:15:46 +03:00
|
|
|
^- [(list move) _this]
|
2018-11-15 05:05:08 +03:00
|
|
|
?- +<-
|
|
|
|
%gen
|
|
|
|
=/ addr (rash addr ;~(pfix (jest '0x') hex))
|
|
|
|
=/ tox (sequence:ceremony now.bol net gas-price nonce addr)
|
|
|
|
[[(write-file-transactions pax tox) ~] this]
|
|
|
|
::
|
|
|
|
%sign
|
|
|
|
=/ tox=(list cord) (sign:ceremony now.bol in key)
|
|
|
|
[[(write-file-wain out tox) ~] this]
|
|
|
|
::
|
|
|
|
%send
|
|
|
|
~& 'loading txs...'
|
|
|
|
=/ tox=(list cord) .^((list cord) %cx pax)
|
|
|
|
=. tox (slag skip tox)
|
|
|
|
=. txs
|
|
|
|
%+ turn tox
|
|
|
|
(cork trip tape-to-ux:ceremony)
|
|
|
|
~& [(lent txs) 'loaded txs']
|
|
|
|
apex
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ write-file-wain
|
2018-11-10 02:24:31 +03:00
|
|
|
|= [pax=path tox=(list cord)]
|
|
|
|
^- move
|
|
|
|
?> ?=([@ desk @ *] pax)
|
|
|
|
:* ost.bol
|
|
|
|
%info
|
|
|
|
(weld /write pax)
|
|
|
|
our.bol
|
|
|
|
i.t.pax
|
|
|
|
=- &+[t.t.t.pax -]~
|
|
|
|
=/ y .^(arch %cy pax)
|
|
|
|
?~ fil.y
|
|
|
|
ins+txt+!>(tox)
|
|
|
|
mut+txt+!>(tox)
|
|
|
|
==
|
|
|
|
::
|
2018-11-15 05:05:08 +03:00
|
|
|
++ write-file-transactions
|
2019-03-06 23:44:59 +03:00
|
|
|
|= [pax=path tox=(list transaction:ethereum)]
|
2018-11-15 05:05:08 +03:00
|
|
|
^- move
|
|
|
|
?> ?=([@ desk @ *] pax)
|
|
|
|
:* ost.bol
|
|
|
|
%info
|
|
|
|
(weld /write pax)
|
|
|
|
our.bol
|
|
|
|
i.t.pax
|
|
|
|
=- &+[t.t.t.pax -]~
|
|
|
|
=/ y .^(arch %cy pax)
|
|
|
|
?~ fil.y
|
|
|
|
ins+eth-txs+!>(tox)
|
|
|
|
mut+eth-txs+!>(tox)
|
|
|
|
==
|
|
|
|
::
|
2018-11-09 00:25:20 +03:00
|
|
|
++ fan-requests
|
|
|
|
|= [wir=wire nodes=(list [tag=@tas url=purl:eyre]) jon=json]
|
|
|
|
:: =- ~& [batch=((list ,[bone * wire]) (turn - |=(* [- +< +>-]:+<))) jon=jon] -
|
|
|
|
^- (list move)
|
|
|
|
%+ turn nodes
|
|
|
|
|= [tag=@tas url=purl:eyre]
|
2018-09-07 19:29:41 +03:00
|
|
|
^- move
|
|
|
|
:- ost.bol
|
2018-11-09 00:25:20 +03:00
|
|
|
:^ %hiss (weld wir ~[tag]) ~
|
2018-09-07 19:29:41 +03:00
|
|
|
:+ %json-rpc-response %hiss
|
2019-03-06 23:44:59 +03:00
|
|
|
(json-request:rpc:ethereum url jon)
|
2018-11-09 00:25:20 +03:00
|
|
|
::
|
|
|
|
++ batch-requests
|
2019-03-06 23:44:59 +03:00
|
|
|
|= [wir=wire req=(list [(unit @t) request:rpc:ethereum])]
|
2018-11-09 00:25:20 +03:00
|
|
|
^- (list move)
|
|
|
|
%^ fan-requests
|
|
|
|
wir
|
2018-11-14 21:53:53 +03:00
|
|
|
:~ => (need (de-purl:html 'http://localhost:8545'))
|
|
|
|
geth+.(p.p |)
|
|
|
|
::
|
|
|
|
=> (need (de-purl:html 'http://localhost:8555'))
|
|
|
|
parity+.(p.p |)
|
|
|
|
==
|
2019-03-06 23:44:59 +03:00
|
|
|
a+(turn req request-to-json:rpc:ethereum)
|
2018-09-12 19:15:46 +03:00
|
|
|
::
|
|
|
|
++ send-next-batch
|
|
|
|
^- [(list move) _this]
|
|
|
|
?: =(0 (lent txs))
|
|
|
|
~& 'all sent!'
|
2018-11-14 05:18:01 +03:00
|
|
|
[~ this(txs ~, see ~, wen ~)]
|
|
|
|
:: ~& send-next-batch=pretty-see
|
2018-11-09 03:57:21 +03:00
|
|
|
=/ new-count (sub 500 ~(wyt in see))
|
2018-11-14 05:18:01 +03:00
|
|
|
?: =(0 new-count)
|
|
|
|
~& %no-new-txs-yet
|
|
|
|
`this
|
2018-11-09 03:57:21 +03:00
|
|
|
:_ this(txs (slag new-count txs))
|
2018-09-18 00:04:25 +03:00
|
|
|
~& ['remaining txs: ' (lent txs)]
|
2018-11-09 03:57:21 +03:00
|
|
|
~& ['sending txs...' new-count]
|
2018-11-14 21:53:53 +03:00
|
|
|
%+ batch-requests /send
|
2018-11-09 03:57:21 +03:00
|
|
|
%+ turn (scag new-count txs)
|
2018-09-07 19:29:41 +03:00
|
|
|
|= tx=@ux
|
2018-11-14 05:18:01 +03:00
|
|
|
:- `(crip 'id-' (scot %ux (end 3 10 tx)) ~)
|
2018-09-07 19:29:41 +03:00
|
|
|
[%eth-send-raw-transaction tx]
|
2018-09-12 19:15:46 +03:00
|
|
|
::
|
|
|
|
++ sigh-json-rpc-response-send
|
2018-09-18 00:04:25 +03:00
|
|
|
|= [wir=wire res=response:rpc:jstd]
|
2018-09-12 19:15:46 +03:00
|
|
|
^- [(list move) _this]
|
2018-11-14 05:18:01 +03:00
|
|
|
?: ?=(%fail -.res)
|
|
|
|
~& %send-failed
|
2018-11-09 00:25:20 +03:00
|
|
|
`this
|
2018-09-12 19:15:46 +03:00
|
|
|
?> ?=(%batch -.res)
|
2018-11-14 05:18:01 +03:00
|
|
|
:: ~& sigh-send-a=pretty-see
|
2018-09-12 19:15:46 +03:00
|
|
|
=. see
|
2018-11-14 05:18:01 +03:00
|
|
|
%- ~(uni in see)
|
|
|
|
%- silt
|
|
|
|
^- (list @ux)
|
2018-10-18 00:56:10 +03:00
|
|
|
%+ murn bas.res
|
2018-09-18 00:04:25 +03:00
|
|
|
|= r=response:rpc:jstd
|
2018-10-18 00:56:10 +03:00
|
|
|
^- (unit @ux)
|
2018-09-12 19:15:46 +03:00
|
|
|
?: ?=(%error -.r)
|
2018-11-14 05:18:01 +03:00
|
|
|
?: ?| =('known transaction' (end 3 17 message.r))
|
|
|
|
=('Known transaction' (end 3 17 message.r))
|
|
|
|
=('Transaction with the same ' (end 3 26 message.r))
|
|
|
|
==
|
2018-11-09 00:25:20 +03:00
|
|
|
~& [%sent-a-known-transaction--skipping wir r]
|
2018-10-18 00:56:10 +03:00
|
|
|
~
|
|
|
|
?: =('Nonce too low' message.r)
|
|
|
|
~& %nonce-too-low--skipping
|
|
|
|
~
|
2018-09-12 19:15:46 +03:00
|
|
|
~| :- 'transaction send failed, game over'
|
|
|
|
[code.r message.r]
|
|
|
|
!!
|
|
|
|
?> ?=(%result -.r)
|
2018-10-18 01:12:11 +03:00
|
|
|
:- ~
|
2018-09-12 19:15:46 +03:00
|
|
|
%- tape-to-ux:ceremony
|
|
|
|
(sa:dejs:format res.r)
|
2018-11-14 05:18:01 +03:00
|
|
|
:: ~& sigh-send-b=pretty-see
|
|
|
|
`this
|
2018-09-12 19:15:46 +03:00
|
|
|
::
|
2018-11-14 05:18:01 +03:00
|
|
|
++ apex
|
2018-09-12 19:15:46 +03:00
|
|
|
^- [(list move) _this]
|
|
|
|
~& :_ ~(wyt in see)
|
|
|
|
'waiting for transaction confirms... '
|
2018-11-14 05:18:01 +03:00
|
|
|
?. =(~ wen) [~ this]
|
|
|
|
=. wen `(add now.bol ~s10)
|
|
|
|
:: ~& apex=[wen pretty-see]
|
|
|
|
=^ moves this send-next-batch
|
|
|
|
[[[ost.bol %wait /see (need wen)] moves] this]
|
2018-09-12 19:15:46 +03:00
|
|
|
::
|
|
|
|
++ wake-see
|
|
|
|
|= [wir=wire ~]
|
|
|
|
^- [(list move) _this]
|
2018-11-14 05:18:01 +03:00
|
|
|
=. wen ~
|
|
|
|
:: ~& wake-see=[wen pretty-see]
|
|
|
|
?: =(~ see)
|
|
|
|
apex
|
|
|
|
:_ this
|
2018-11-14 21:53:53 +03:00
|
|
|
%+ batch-requests /see
|
2018-11-14 05:18:01 +03:00
|
|
|
%+ turn ~(tap in see)
|
2018-09-12 19:15:46 +03:00
|
|
|
|= txh=@ux
|
2018-11-14 05:18:01 +03:00
|
|
|
:- `(crip 'see-0x' ((x-co:co 64) txh))
|
2018-09-12 19:15:46 +03:00
|
|
|
[%eth-get-transaction-receipt txh]
|
|
|
|
::
|
|
|
|
++ sigh-json-rpc-response-see
|
2018-09-18 00:04:25 +03:00
|
|
|
|= [wir=wire res=response:rpc:jstd]
|
2018-09-12 19:15:46 +03:00
|
|
|
^- [(list move) _this]
|
2018-11-14 05:18:01 +03:00
|
|
|
?: ?| ?=(%error -.res)
|
|
|
|
?=(%fail -.res)
|
|
|
|
==
|
|
|
|
~& [%bad-rpc-response--kicking res]
|
|
|
|
apex
|
|
|
|
:: `this
|
2018-09-12 19:15:46 +03:00
|
|
|
?> ?=(%batch -.res)
|
2018-11-14 05:18:01 +03:00
|
|
|
?: =(~ see)
|
|
|
|
apex
|
2018-10-11 02:59:04 +03:00
|
|
|
?: =(0 (lent bas.res))
|
|
|
|
::TODO node lost our txs?
|
2018-11-14 05:18:01 +03:00
|
|
|
~& [%txs-lost-tmp wir '!!']
|
|
|
|
apex
|
|
|
|
:: ~& sigh-see-a=pretty-see
|
2018-09-12 19:15:46 +03:00
|
|
|
=. see
|
2018-11-14 05:18:01 +03:00
|
|
|
%- ~(dif in see)
|
|
|
|
%- silt
|
|
|
|
^- (list @ux)
|
2018-09-12 19:15:46 +03:00
|
|
|
%+ murn bas.res
|
2018-09-18 00:04:25 +03:00
|
|
|
|= r=response:rpc:jstd
|
2018-09-12 19:15:46 +03:00
|
|
|
^- (unit @ux)
|
|
|
|
?< ?=(%batch -.r)
|
2018-11-09 00:25:20 +03:00
|
|
|
?< ?=(%fail -.r)
|
|
|
|
~| [id.r res]
|
|
|
|
=+ txh=(tape-to-ux:ceremony (trip (rsh 3 4 id.r)))
|
2018-11-14 05:18:01 +03:00
|
|
|
~& see-tx=[(@p (mug txh)) `@ux`txh]
|
|
|
|
=* done `txh
|
|
|
|
=* wait ~
|
2018-09-12 19:15:46 +03:00
|
|
|
?: ?=(%error -.r)
|
|
|
|
~& :- 'receipt fetch error'
|
|
|
|
[code.r message.r]
|
2018-09-18 00:04:25 +03:00
|
|
|
wait
|
|
|
|
?~ res.r wait
|
2018-09-12 19:15:46 +03:00
|
|
|
?> ?=(%o -.res.r)
|
2018-11-14 05:18:01 +03:00
|
|
|
=/ status
|
|
|
|
%- tape-to-ux:ceremony
|
|
|
|
%- sa:dejs:format
|
|
|
|
(~(got by p.res.r) 'status')
|
|
|
|
?: =(1 status)
|
2018-09-18 00:04:25 +03:00
|
|
|
done
|
2018-11-14 05:18:01 +03:00
|
|
|
~& [%see-bad-status status]
|
2018-09-18 00:04:25 +03:00
|
|
|
wait
|
2018-11-14 05:18:01 +03:00
|
|
|
:: ~& sigh-see-b=pretty-see
|
|
|
|
apex
|
2018-09-12 19:15:46 +03:00
|
|
|
::
|
|
|
|
++ sigh-tang
|
|
|
|
|= [wir=wire err=tang]
|
2018-11-14 05:18:01 +03:00
|
|
|
~& [%sigh-tang wir]
|
2018-09-12 19:15:46 +03:00
|
|
|
~& (slog err)
|
2018-11-14 05:18:01 +03:00
|
|
|
?: =(~ wen) [~ this]
|
|
|
|
=. wen `(add now.bol ~s10)
|
|
|
|
[[ost.bol %wait /see (need wen)]~ this]
|
2018-09-07 19:29:41 +03:00
|
|
|
--
|