2022-03-15 21:40:41 +03:00
|
|
|
:: This thread grabs the latest Ethereum logs and produces a csv file
|
|
|
|
:: containing the following data on L2 transactions:
|
|
|
|
::
|
|
|
|
:: - block number
|
|
|
|
:: - timestamp
|
|
|
|
:: - roller address
|
|
|
|
:: - roll hash
|
|
|
|
:: - tx hash
|
|
|
|
:: - sending ship
|
|
|
|
:: - sending proxy
|
|
|
|
:: - nonce
|
|
|
|
:: - gas price
|
|
|
|
:: - length of input data
|
|
|
|
:: - success or failure
|
|
|
|
:: - function name
|
|
|
|
::
|
2022-03-23 00:15:07 +03:00
|
|
|
:: A lot of the data-scrounging here is stuff that %roller already keeps track
|
|
|
|
:: of. We could just scry it from there, but then this thread needs to be run
|
|
|
|
:: on the roller ship. So we rebuild the list of historical transactions
|
|
|
|
:: ourselves so that this can run from any ship.
|
|
|
|
::
|
2022-03-16 02:11:54 +03:00
|
|
|
:: TODO: change block maps to ordered maps
|
|
|
|
::
|
2022-03-17 21:13:54 +03:00
|
|
|
/- dice,
|
|
|
|
spider
|
2022-03-15 21:40:41 +03:00
|
|
|
::
|
|
|
|
/+ dice,
|
|
|
|
ethereum,
|
|
|
|
ethio,
|
|
|
|
naive,
|
2022-03-17 21:13:54 +03:00
|
|
|
naive-tx=naive-transactions,
|
2022-03-15 21:40:41 +03:00
|
|
|
*strandio
|
|
|
|
::
|
|
|
|
:: imports most recent downloaded logs
|
|
|
|
::/* logs %eth-logs /app/azimuth/logs/eth-logs
|
|
|
|
::/* logs %eth-logs /app/azimuth/tid/eth-logs
|
2022-03-17 21:13:54 +03:00
|
|
|
::
|
|
|
|
:: starting snapshot. this may not be the right starting point once we have
|
|
|
|
:: clay tombstoning and the snapshot may be updated
|
|
|
|
/* snap %azimuth-snapshot /app/azimuth/version-0/azimuth-snapshot
|
|
|
|
::
|
2022-03-15 21:40:41 +03:00
|
|
|
=, strand=strand:spider
|
|
|
|
=, jael
|
|
|
|
::
|
|
|
|
:: takes in the network to use. note that this filters logs for transactions to
|
|
|
|
:: the appropriate contract address - this won't get you e.g. ropsten logs if
|
|
|
|
:: you run it with net=%ropsten on a mainnet ship
|
|
|
|
::
|
|
|
|
^- thread:spider
|
|
|
|
=< process-logs
|
|
|
|
=>
|
|
|
|
|%
|
|
|
|
:: imported logs is cast as $events
|
2022-03-23 00:15:07 +03:00
|
|
|
+$ events (list event-log:rpc:ethereum)
|
2022-03-17 19:23:00 +03:00
|
|
|
+$ address address:naive :: @ux
|
2022-03-17 19:51:54 +03:00
|
|
|
+$ keccak @ux :: used for transaction and roll hashes
|
2022-03-17 19:23:00 +03:00
|
|
|
+$ blocknum number:block :: @udblocknumber
|
2022-03-15 21:40:41 +03:00
|
|
|
::
|
2022-03-23 00:15:07 +03:00
|
|
|
+$ net net:dice ::?(%mainnet %ropsten %local %default)
|
2022-03-15 21:40:41 +03:00
|
|
|
::
|
2022-03-23 00:15:07 +03:00
|
|
|
+$ block-map %+ map blocknum
|
|
|
|
[timestamp=@da rolls=(map keccak [[gas=@ud sender=address] =effects:naive])]
|
2022-03-16 02:11:54 +03:00
|
|
|
::
|
2022-03-23 00:15:07 +03:00
|
|
|
+$ action $? %transfer-point
|
|
|
|
%spawn
|
|
|
|
%configure-keys
|
|
|
|
%escape
|
|
|
|
%cancel-escape
|
|
|
|
%adopt
|
|
|
|
%reject
|
|
|
|
%detach
|
|
|
|
%set-management-proxy
|
|
|
|
%set-spawn-proxy
|
|
|
|
%set-transfer-proxy
|
|
|
|
==
|
2022-03-15 21:40:41 +03:00
|
|
|
::
|
2022-03-23 00:15:07 +03:00
|
|
|
+$ tx-data $: block=blocknum
|
|
|
|
timestamp=@da
|
|
|
|
roller=address
|
|
|
|
roll-hash=keccak
|
|
|
|
tx-hash=keccak
|
|
|
|
sender=ship
|
|
|
|
proxy=proxy:naive
|
|
|
|
nonce=nonce:naive
|
|
|
|
gas=@ud
|
|
|
|
length=@
|
|
|
|
suc=?
|
|
|
|
=action
|
|
|
|
==
|
2022-03-16 00:34:00 +03:00
|
|
|
::++ node-url 'http://eth-mainnet.urbit.org:8545'
|
|
|
|
++ node-url 'https://mainnet.infura.io/v3/13a985885cd243cc886062ad2f345e16' :: infura free tier node
|
2022-03-15 21:40:41 +03:00
|
|
|
--
|
2022-03-16 02:11:54 +03:00
|
|
|
::
|
2022-03-15 21:40:41 +03:00
|
|
|
|%
|
|
|
|
++ process-logs
|
|
|
|
|= arg=vase
|
|
|
|
=+ !<([~ =net] arg)
|
|
|
|
=/ m (strand ,vase)
|
|
|
|
^- form:m
|
|
|
|
;< logs=events bind:m (scry events /gx/azimuth/logs/noun)
|
2022-03-16 01:09:07 +03:00
|
|
|
=/ logs (scag 50 logs) :: to make debugging faster
|
2022-03-17 19:23:00 +03:00
|
|
|
=/ [naive-contract=address chain-id=@]
|
2022-03-15 21:40:41 +03:00
|
|
|
[naive chain-id]:(get-network:dice net)
|
2022-03-17 21:13:54 +03:00
|
|
|
=/ snap=snap-state:dice snap
|
|
|
|
::
|
2022-03-15 21:40:41 +03:00
|
|
|
=/ l2-logs=events (filter-l2 logs naive-contract)
|
|
|
|
%- %- slog :_ ~
|
|
|
|
leaf+"processing {<net>} ethereum logs with {<(lent logs)>} total events, of which {<(lent l2-logs)>} are l2 events"
|
2022-03-17 21:13:54 +03:00
|
|
|
=/ blocks=(list blocknum) (get-block-numbers l2-logs)
|
|
|
|
=/ tx-hashes=(list keccak) (get-tx-hashes l2-logs)
|
2022-03-17 19:51:54 +03:00
|
|
|
=/ block-jar=(jar blocknum keccak) (block-tx-jar l2-logs)
|
2022-03-17 21:13:54 +03:00
|
|
|
;< timestamps=(map blocknum @da) bind:m
|
|
|
|
(get-timestamps blocks)
|
|
|
|
;< tx-data=(map keccak [gas=@ud sender=address]) bind:m
|
|
|
|
(get-tx-data tx-hashes)
|
2022-03-18 00:16:09 +03:00
|
|
|
=/ rolls-map=(map blocknum (map keccak effects:naive))
|
|
|
|
(run-logs-from-state-map nas.snap logs net naive-contract chain-id)
|
2022-03-23 00:15:07 +03:00
|
|
|
=/ rolling=block-map (collate-roll-data blocks block-jar rolls-map timestamps tx-data)
|
|
|
|
=/ flat (flatten-data rolling)
|
2022-03-23 01:04:34 +03:00
|
|
|
=/ csv=(list cord) (make-csv flat)
|
|
|
|
;< ~ bind:m (export-csv csv)
|
2022-03-17 21:13:54 +03:00
|
|
|
::
|
2022-03-23 01:04:34 +03:00
|
|
|
(pure:m !>(csv))
|
2022-03-16 03:05:25 +03:00
|
|
|
::
|
|
|
|
++ collate-roll-data
|
2022-03-17 19:23:00 +03:00
|
|
|
|= $: blocks=(list blocknum)
|
2022-03-17 19:51:54 +03:00
|
|
|
block-jar=(jar blocknum keccak)
|
2022-03-18 00:16:09 +03:00
|
|
|
rolls-map=(map blocknum (map keccak effects:naive))
|
2022-03-17 19:23:00 +03:00
|
|
|
timestamps=(map blocknum @da)
|
2022-03-17 19:51:54 +03:00
|
|
|
tx-data=(map keccak [gas=@ud sender=address])
|
2022-03-16 03:05:25 +03:00
|
|
|
==
|
2022-03-23 00:15:07 +03:00
|
|
|
:: =| $= block-map
|
|
|
|
:: %+ map blocknum
|
|
|
|
:: [timestamp=@da rolls=(map keccak [[gas=@ud sender=address] =effects:naive])]
|
|
|
|
=| =block-map
|
2022-03-18 00:16:09 +03:00
|
|
|
^+ block-map
|
2022-03-16 03:05:25 +03:00
|
|
|
|-
|
|
|
|
?~ blocks block-map
|
2022-03-18 00:16:09 +03:00
|
|
|
=/ block=blocknum i.blocks
|
|
|
|
=/ tx-hashes=(list keccak) (~(get ja block-jar) block)
|
|
|
|
=/ rolls=(map keccak [[gas=@ud sender=address] =effects:naive])
|
|
|
|
%- ~(gas by *(map keccak [[gas=@ud sender=address] =effects:naive]))
|
2022-03-16 03:05:25 +03:00
|
|
|
%+ turn tx-hashes
|
2022-03-18 00:16:09 +03:00
|
|
|
|= txh=keccak
|
|
|
|
:- txh
|
|
|
|
[(~(got by tx-data) txh) (~(got by (~(got by rolls-map) block)) txh)]
|
2022-03-16 03:05:25 +03:00
|
|
|
%= $
|
|
|
|
blocks t.blocks
|
2022-03-18 00:16:09 +03:00
|
|
|
block-map %+ ~(put by block-map) block
|
|
|
|
[(~(got by timestamps) block) rolls]
|
2022-03-16 03:05:25 +03:00
|
|
|
==
|
2022-03-16 00:34:00 +03:00
|
|
|
::
|
2022-03-23 00:15:07 +03:00
|
|
|
++ flatten-data
|
|
|
|
|= =block-map
|
|
|
|
=| tx-list=(list tx-data)
|
|
|
|
^+ tx-list
|
|
|
|
=/ blocks=(list blocknum) ~(tap in ~(key by block-map))
|
|
|
|
:: recurse through each block, getting the rolls submitted in that block,
|
|
|
|
:: their timestamp, and the gas price of that roll
|
|
|
|
|- ^- (list tx-data)
|
|
|
|
?~ blocks tx-list
|
|
|
|
=/ block=blocknum i.blocks
|
2022-03-23 01:04:34 +03:00
|
|
|
=/ bor (~(got by block-map) block)
|
2022-03-23 00:15:07 +03:00
|
|
|
=/ roll-list=(list keccak)
|
2022-03-23 01:04:34 +03:00
|
|
|
~(tap in ~(key by rolls.bor))
|
2022-03-23 00:15:07 +03:00
|
|
|
=| block-tx-list=(list tx-data)
|
|
|
|
:: recurse through each roll, getting the transaction data from the effects
|
|
|
|
|-
|
|
|
|
?~ roll-list
|
|
|
|
%= ^$
|
|
|
|
blocks t.blocks
|
|
|
|
tx-list (welp tx-list block-tx-list)
|
|
|
|
==
|
|
|
|
=/ roll-hash=keccak i.roll-list
|
|
|
|
=/ roll=[[gas=@ud sender=address] =effects:naive]
|
2022-03-23 01:04:34 +03:00
|
|
|
(~(got by rolls.bor) roll-hash)
|
2022-03-23 00:15:07 +03:00
|
|
|
:: recurse through the list of effects, building up transaction data as we
|
|
|
|
:: go. there's a choice here to use the effects, or the submitted
|
|
|
|
:: raw-tx. the effects include whether or not a transaction failed,
|
|
|
|
:: which is important data not a part of the submitted raw-tx. we
|
|
|
|
:: could determine this ourselves, but we build the effects anyways when
|
|
|
|
:: computing the state transitions, so we may as well use them.
|
|
|
|
::
|
|
|
|
:: an individual transaction results in up to 3 diffs: a %nonce, a %tx, and
|
|
|
|
:: a %point. they always appear in this order. successful transactions
|
|
|
|
:: always have all 3, while failed transactions only have %nonce and %tx.
|
|
|
|
:: note that the nonce listed is always the expected nonce - we can't know
|
|
|
|
:: what nonce was actually submitted without the private key of the signer.
|
|
|
|
=| roll-tx-list=(list tx-data)
|
|
|
|
=| nonce-and-tx=[_| _|]
|
2022-03-23 01:04:34 +03:00
|
|
|
=/ =tx-data :* block timestamp.bor sender.roll roll-hash *keccak
|
|
|
|
*ship *proxy:naive *nonce:naive gas.roll *@ | *action
|
2022-03-23 00:15:07 +03:00
|
|
|
==
|
|
|
|
|-
|
|
|
|
:: if we've gotten both the %nonce and %tx diff from a transaction, add the
|
|
|
|
:: tx-data to the list of tx for the roll
|
|
|
|
?: =([& &] nonce-and-tx)
|
|
|
|
%= $ :: should this be %_ ?
|
|
|
|
roll-tx-list (snoc roll-tx-list tx-data)
|
|
|
|
nonce-and-tx [| |]
|
|
|
|
tx-data *_tx-data :: reset tx-data
|
|
|
|
==
|
|
|
|
:: if we've finished looping through the effects, add the tx list from the
|
|
|
|
:: roll to the list of tx for the block
|
|
|
|
::
|
|
|
|
?~ effects.roll
|
|
|
|
%= ^$
|
|
|
|
roll-list t.roll-list
|
|
|
|
block-tx-list (welp block-tx-list roll-tx-list)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
=/ =diff:naive i.effects.roll
|
|
|
|
?+ diff
|
|
|
|
$(effects.roll t.effects.roll) :: we ignore %operator, %dns, and %point diffs
|
|
|
|
::
|
|
|
|
[%nonce *]
|
|
|
|
%= $
|
|
|
|
-.nonce-and-tx &
|
|
|
|
nonce.tx-data nonce.diff
|
|
|
|
sender.tx-data ship.diff
|
|
|
|
proxy.tx-data proxy.diff
|
|
|
|
effects.roll t.effects.roll
|
|
|
|
==
|
|
|
|
::
|
|
|
|
:: the conditional here is to ensure that a %tx diff is from
|
|
|
|
:: the same submitted tx as the nonce that should have come
|
|
|
|
:: before it. this should never happen, but maybe you need
|
|
|
|
:: to flop effects to get things in the right order. this also
|
|
|
|
:: isn't perfect - the tx could be from the same ship and proxy
|
|
|
|
:: but different nonce.
|
|
|
|
[%tx *]
|
|
|
|
?. ?& =(sender.tx-data ship.from.tx.raw-tx.diff)
|
|
|
|
=(proxy.tx-data proxy.from.tx.raw-tx.diff)
|
|
|
|
==
|
|
|
|
~& >> '%tx associated to a different ship than %nonce!'
|
|
|
|
!!
|
|
|
|
%= $
|
2022-03-23 01:04:34 +03:00
|
|
|
+.nonce-and-tx &
|
|
|
|
effects.roll t.effects.roll
|
|
|
|
length.tx-data -.raw.raw-tx.diff
|
2022-03-23 00:15:07 +03:00
|
|
|
tx-hash.tx-data (hash-raw-tx:naive-tx raw-tx.diff)
|
2022-03-23 01:04:34 +03:00
|
|
|
action.tx-data +<.tx.raw-tx.diff
|
|
|
|
suc.tx-data ?~ err.diff & |
|
2022-03-23 00:15:07 +03:00
|
|
|
==
|
|
|
|
==
|
|
|
|
::
|
2022-03-23 01:04:34 +03:00
|
|
|
++ export-csv
|
|
|
|
|= in=(list cord)
|
|
|
|
=/ m (strand ,~)
|
|
|
|
^- form:m
|
|
|
|
;< =bowl:spider bind:m get-bowl
|
|
|
|
=- (send-raw-card %pass / %arvo %c %info -)
|
|
|
|
%+ foal:space:userlib
|
|
|
|
/(scot %p our.bowl)/base/(scot %da now.bowl)/naive-exports/csv/txt
|
|
|
|
[%txt !>(in)]
|
|
|
|
::
|
|
|
|
++ make-csv
|
|
|
|
:: Takes in rolls-map and makes it suitable to be saved as a csv
|
|
|
|
|= in=(list tx-data)
|
|
|
|
^- (list cord)
|
|
|
|
:- %- crip
|
|
|
|
;: weld
|
|
|
|
"block number,"
|
|
|
|
"timestamp,"
|
|
|
|
"roller addres,"
|
|
|
|
"roll hash,"
|
|
|
|
"tx hash,"
|
|
|
|
"sending ship,"
|
|
|
|
"sending proxy,"
|
|
|
|
"nonce,"
|
|
|
|
"gas price,"
|
|
|
|
"length of input data,"
|
|
|
|
"success or failure,"
|
|
|
|
"function name"
|
|
|
|
==
|
|
|
|
%+ turn in
|
|
|
|
|= =tx-data
|
|
|
|
%- crip
|
|
|
|
;: weld
|
|
|
|
(scow %ux block.tx-data) ","
|
|
|
|
(scow %da timestamp.tx-data) ","
|
|
|
|
(scow %ux roller.tx-data) ","
|
|
|
|
(scow %ux roll-hash.tx-data) ","
|
|
|
|
(scow %ux tx-hash.tx-data) ","
|
|
|
|
(scow %p sender.tx-data) ","
|
|
|
|
(scow %tas proxy.tx-data) ","
|
|
|
|
(scow %ud nonce.tx-data) ","
|
|
|
|
(scow %ud gas.tx-data) ","
|
|
|
|
(scow %$ length.tx-data) ","
|
|
|
|
(scow %f suc.tx-data) ","
|
|
|
|
(scow %tas action.tx-data)
|
|
|
|
==
|
2022-03-23 00:15:07 +03:00
|
|
|
::
|
2022-03-16 03:19:33 +03:00
|
|
|
++ get-tx-data
|
|
|
|
:: retrieves transaction receipts for rolls, extracting the gas cost and sender
|
2022-03-17 19:51:54 +03:00
|
|
|
|= tx-hashes=(list keccak)
|
|
|
|
=/ m (strand ,(map keccak [gas=@ud sender=address]))
|
2022-03-16 00:34:00 +03:00
|
|
|
^- form:m
|
2022-03-17 19:51:54 +03:00
|
|
|
=| out=(map keccak [gas=@ud sender=address])
|
2022-03-16 00:34:00 +03:00
|
|
|
|^ ^- form:m
|
|
|
|
=* loop $
|
|
|
|
?: =(~ tx-hashes) (pure:m out)
|
|
|
|
;< res=(list [@t json]) bind:m
|
|
|
|
(request-receipts (scag 100 tx-hashes))
|
|
|
|
%_ loop
|
2022-03-16 02:11:54 +03:00
|
|
|
out (~(gas by out) (parse-results res))
|
2022-03-16 00:34:00 +03:00
|
|
|
tx-hashes (slag 100 tx-hashes)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ request-receipts
|
2022-03-17 19:51:54 +03:00
|
|
|
|= tx-hashes=(list keccak)
|
2022-03-16 00:34:00 +03:00
|
|
|
%+ request-batch-rpc-strict:ethio node-url
|
|
|
|
%+ turn tx-hashes
|
2022-03-17 19:51:54 +03:00
|
|
|
|= txh=keccak
|
2022-03-16 00:34:00 +03:00
|
|
|
^- [(unit @t) request:rpc:ethereum]
|
|
|
|
:- `(crip '0' 'x' ((x-co:co 64) txh))
|
|
|
|
[%eth-get-transaction-receipt txh]
|
|
|
|
::
|
2022-03-16 01:09:07 +03:00
|
|
|
++ parse-results
|
|
|
|
|= res=(list [@t json])
|
2022-03-17 19:51:54 +03:00
|
|
|
^- (list [txh=keccak [gas=@ud sender=address]])
|
2022-03-16 01:09:07 +03:00
|
|
|
%+ turn res
|
|
|
|
|= [id=@t =json]
|
2022-03-17 19:51:54 +03:00
|
|
|
^- [txh=keccak [gas=@ud sender=address]]
|
2022-03-16 01:09:07 +03:00
|
|
|
:- (hex-to-num:ethereum id)
|
2022-03-16 03:19:33 +03:00
|
|
|
:- %- parse-hex-result:rpc:ethereum
|
|
|
|
~| json
|
|
|
|
?> ?=(%o -.json)
|
|
|
|
(~(got by p.json) 'gasUsed') :: returns the amount of gas used, not gas price
|
2022-03-16 01:09:07 +03:00
|
|
|
%- parse-hex-result:rpc:ethereum
|
|
|
|
~| json
|
|
|
|
?> ?=(%o -.json)
|
2022-03-16 03:19:33 +03:00
|
|
|
(~(got by p.json) 'from')
|
2022-03-16 00:34:00 +03:00
|
|
|
--
|
2022-03-15 21:40:41 +03:00
|
|
|
::
|
|
|
|
++ get-timestamps
|
|
|
|
:: TODO: would be better to call the eth-get-timestamps thread directly
|
|
|
|
:: rather than copy and paste the code for it here
|
2022-03-17 19:23:00 +03:00
|
|
|
|= blocks=(list blocknum)
|
|
|
|
=/ m (strand ,(map blocknum @da))
|
2022-03-15 21:40:41 +03:00
|
|
|
^- form:m
|
2022-03-17 19:23:00 +03:00
|
|
|
=| out=(map blocknum @da)
|
2022-03-15 21:40:41 +03:00
|
|
|
|^ ^- form:m
|
|
|
|
=* loop $
|
|
|
|
?: =(~ blocks) (pure:m out)
|
|
|
|
;< res=(list [@t json]) bind:m
|
|
|
|
(request-blocks (scag 100 blocks))
|
|
|
|
%_ loop
|
2022-03-16 02:11:54 +03:00
|
|
|
out (~(gas by out) (parse-results res))
|
2022-03-15 21:40:41 +03:00
|
|
|
blocks (slag 100 blocks)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ request-blocks
|
2022-03-17 19:23:00 +03:00
|
|
|
|= blocks=(list blocknum)
|
2022-03-15 21:40:41 +03:00
|
|
|
%+ request-batch-rpc-strict:ethio node-url
|
|
|
|
%+ turn blocks
|
2022-03-17 19:23:00 +03:00
|
|
|
|= block=blocknum
|
2022-03-15 21:40:41 +03:00
|
|
|
^- [(unit @t) request:rpc:ethereum]
|
|
|
|
:- `(scot %ud block)
|
|
|
|
[%eth-get-block-by-number block |]
|
|
|
|
::
|
|
|
|
++ parse-results
|
|
|
|
|= res=(list [@t json])
|
2022-03-17 19:23:00 +03:00
|
|
|
^- (list [blocknum @da])
|
2022-03-15 21:40:41 +03:00
|
|
|
%+ turn res
|
|
|
|
|= [id=@t =json]
|
2022-03-17 19:23:00 +03:00
|
|
|
^- [blocknum @da]
|
2022-03-15 21:40:41 +03:00
|
|
|
:- (slav %ud id)
|
|
|
|
%- from-unix:chrono:userlib
|
|
|
|
%- parse-hex-result:rpc:ethereum
|
|
|
|
~| json
|
|
|
|
?> ?=(%o -.json)
|
|
|
|
(~(got by p.json) 'timestamp')
|
|
|
|
--
|
2022-03-23 00:15:07 +03:00
|
|
|
::
|
2022-03-18 00:16:09 +03:00
|
|
|
++ run-logs-from-state-map
|
2022-03-17 21:13:54 +03:00
|
|
|
|= $: nas=^state:naive
|
|
|
|
logs=events
|
|
|
|
=net
|
|
|
|
naive-contract=address
|
|
|
|
chain-id=@ud
|
|
|
|
==
|
2022-03-18 00:16:09 +03:00
|
|
|
=| out=(map blocknum (map keccak effects:naive))
|
2022-03-17 21:13:54 +03:00
|
|
|
^+ out
|
|
|
|
:: We need to run the state transitions to see what the individual
|
|
|
|
:: transactions were, as well as whether they succeeded or failed.
|
|
|
|
::
|
|
|
|
%- %- slog :_ ~
|
|
|
|
leaf+"processing state transitions beginning from stored snapshot"
|
|
|
|
::
|
|
|
|
|-
|
|
|
|
?~ logs out
|
|
|
|
=/ log=event-log:rpc:ethereum i.logs
|
|
|
|
?~ mined.log
|
2022-03-18 00:16:09 +03:00
|
|
|
~& >> 'empty log'
|
2022-03-17 21:13:54 +03:00
|
|
|
$(logs t.logs)
|
|
|
|
=/ block=blocknum block-number.u.mined.log
|
|
|
|
=/ =^input:naive
|
|
|
|
:- block
|
|
|
|
?. =(naive-contract address.log)
|
|
|
|
:- %log
|
|
|
|
[address.log (data-to-hex:dice data.log) topics.log]
|
|
|
|
?~ input.u.mined.log
|
|
|
|
~& >> 'empty L2 transaction'
|
|
|
|
[%bat *@]
|
|
|
|
[%bat u.input.u.mined.log]
|
|
|
|
=^ =effects:naive nas
|
|
|
|
(%*(. naive lac |) verifier:naive-tx chain-id nas input)
|
|
|
|
%= $
|
|
|
|
logs t.logs
|
|
|
|
out ?. =(%bat +<.input)
|
2022-03-18 00:16:09 +03:00
|
|
|
out :: skip L1 logs
|
|
|
|
:: there's probably a better way to do this
|
|
|
|
=/ cur-map=(unit (map keccak effects:naive))
|
|
|
|
(~(get by out) block)
|
|
|
|
?~ cur-map
|
|
|
|
%+ ~(put by out) block
|
|
|
|
^- (map keccak effects:naive)
|
|
|
|
(my [[transaction-hash.u.mined.log effects]~])
|
|
|
|
=. u.cur-map
|
|
|
|
(~(put by u.cur-map) transaction-hash.u.mined.log effects)
|
|
|
|
(~(put by out) block u.cur-map)
|
2022-03-17 21:13:54 +03:00
|
|
|
==
|
2022-03-15 21:40:41 +03:00
|
|
|
::
|
|
|
|
++ filter-l2
|
2022-03-17 19:23:00 +03:00
|
|
|
|= [logs=events naive-contract=address] ^- events
|
2022-03-15 22:11:32 +03:00
|
|
|
%+ skim logs
|
|
|
|
|= log=event-log:rpc:ethereum ^- ?
|
|
|
|
?~ mined.log %.n
|
|
|
|
=(naive-contract address.log)
|
2022-03-15 21:40:41 +03:00
|
|
|
::
|
2022-03-16 02:11:54 +03:00
|
|
|
++ block-tx-jar
|
2022-03-17 19:51:54 +03:00
|
|
|
|= logs=events ^- (jar blocknum keccak)
|
|
|
|
=| block-jar=(jar blocknum keccak)
|
2022-03-16 02:11:54 +03:00
|
|
|
|-
|
|
|
|
?~ logs block-jar
|
|
|
|
:: shouldn't crash since +filter-l2 already checks if mined.log is empty
|
|
|
|
=+ (need mined.i.logs)
|
|
|
|
%= $
|
|
|
|
logs t.logs
|
|
|
|
block-jar (~(add ja block-jar) [block-number transaction-hash]:-)
|
|
|
|
==
|
|
|
|
::
|
2022-03-15 21:40:41 +03:00
|
|
|
++ get-block-numbers
|
2022-03-17 19:23:00 +03:00
|
|
|
|= logs=events ^- (list blocknum)
|
2022-03-15 22:09:46 +03:00
|
|
|
%+ turn logs
|
|
|
|
|= log=event-log:rpc:ethereum
|
|
|
|
:: shouldn't crash since +filter-l2 already checks if mined.log is empty
|
2022-03-16 00:34:00 +03:00
|
|
|
block-number:(need mined.log)
|
|
|
|
::
|
|
|
|
++ get-tx-hashes
|
2022-03-17 19:51:54 +03:00
|
|
|
|= logs=events ^- (list keccak)
|
2022-03-16 00:34:00 +03:00
|
|
|
%+ turn logs
|
|
|
|
|= log=event-log:rpc:ethereum
|
|
|
|
:: shouldn't crash since +filter-l2 already checks if mined.log is empty
|
|
|
|
transaction-hash:(need mined.log)
|
2022-03-15 21:40:41 +03:00
|
|
|
--
|