mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-30 18:31:36 +03:00
naive: l2 csv factor out %eth-get-timestamps
requires child threads to be working
This commit is contained in:
parent
4a403a676d
commit
efca5bfedc
@ -110,13 +110,16 @@
|
|||||||
::
|
::
|
||||||
=/ =rolls-map
|
=/ =rolls-map
|
||||||
(compute-effects nas.snap events net naive-contract chain-id)
|
(compute-effects nas.snap events net naive-contract chain-id)
|
||||||
:: I think this should work, but child threads seem to be broken
|
%- %- slog :_ ~
|
||||||
:: ;< =thread-result bind:m
|
leaf+"getting timestamps from ethereum node"
|
||||||
:: %+ await-thread
|
;< =thread-result bind:m
|
||||||
:: %eth-get-timestamps
|
%+ await-thread %eth-get-timestamps
|
||||||
:: !>([node-url ~(tap in ~(key by rolls-map))])
|
!>([node-url ~(tap in ~(key by rolls-map))])
|
||||||
;< timestamps=(map blocknum @da) bind:m
|
=/ timestamps %- ~(gas by *(map blocknum @da))
|
||||||
(get-timestamps node-url ~(tap in ~(key by rolls-map)))
|
?- thread-result
|
||||||
|
[%.y *] ;;((list [@ud @da]) q.p.thread-result)
|
||||||
|
[%.n *] ~| '%eth-get-timestamps failed' !!
|
||||||
|
==
|
||||||
;< roll-receipts=(map keccak [gas=@ud sender=address]) bind:m
|
;< roll-receipts=(map keccak [gas=@ud sender=address]) bind:m
|
||||||
(get-roll-receipts node-url (get-roll-hashes rolls-map))
|
(get-roll-receipts node-url (get-roll-hashes rolls-map))
|
||||||
=/ csv=(list cord)
|
=/ csv=(list cord)
|
||||||
@ -293,50 +296,6 @@
|
|||||||
|= a=(map keccak effects:naive)
|
|= a=(map keccak effects:naive)
|
||||||
~(tap in ~(key by a))
|
~(tap in ~(key by a))
|
||||||
::
|
::
|
||||||
:: +get-timestamps retrieves the timestamps for a list of block numbers
|
|
||||||
++ get-timestamps
|
|
||||||
:: TODO: would be better to call the eth-get-timestamps thread directly
|
|
||||||
:: rather than copy and paste the code for it here, but child threads seem
|
|
||||||
:: to be broken.
|
|
||||||
|= [node-url=@t blocks=(list blocknum)]
|
|
||||||
%- %- slog :_ ~
|
|
||||||
leaf+"getting timestamps from ethereum node"
|
|
||||||
=/ m (strand ,(map blocknum @da))
|
|
||||||
^- form:m
|
|
||||||
=| out=(map blocknum @da)
|
|
||||||
|^ ^- form:m
|
|
||||||
=* loop $
|
|
||||||
?: =(~ blocks) (pure:m out)
|
|
||||||
;< res=(list [@t json]) bind:m
|
|
||||||
(request-blocks (scag 100 blocks) node-url)
|
|
||||||
%_ loop
|
|
||||||
out (~(gas by out) (parse-results res))
|
|
||||||
blocks (slag 100 blocks)
|
|
||||||
==
|
|
||||||
::
|
|
||||||
++ request-blocks
|
|
||||||
|= [blocks=(list blocknum) node-url=@t]
|
|
||||||
%+ request-batch-rpc-strict:ethio node-url
|
|
||||||
%+ turn blocks
|
|
||||||
|= block=blocknum
|
|
||||||
^- [(unit @t) request:rpc:ethereum]
|
|
||||||
:- `(scot %ud block)
|
|
||||||
[%eth-get-block-by-number block |]
|
|
||||||
::
|
|
||||||
++ parse-results
|
|
||||||
|= res=(list [@t json])
|
|
||||||
^- (list [blocknum @da])
|
|
||||||
%+ turn res
|
|
||||||
|= [id=@t =json]
|
|
||||||
^- [blocknum @da]
|
|
||||||
:- (slav %ud id)
|
|
||||||
%- from-unix:chrono:userlib
|
|
||||||
%- parse-hex-result:rpc:ethereum
|
|
||||||
~| json
|
|
||||||
?> ?=(%o -.json)
|
|
||||||
(~(got by p.json) 'timestamp')
|
|
||||||
--
|
|
||||||
::
|
|
||||||
:: +compute-effects calls +naive to compute the state transitions for all
|
:: +compute-effects calls +naive to compute the state transitions for all
|
||||||
:: logs, but it returns a map that only has the effects for L2 transactions,
|
:: logs, but it returns a map that only has the effects for L2 transactions,
|
||||||
:: leaving out L1 transactions. we need to compute all of them in order to
|
:: leaving out L1 transactions. we need to compute all of them in order to
|
||||||
|
Loading…
Reference in New Issue
Block a user