naive: l2 csv get naive effects

passing the event log to naive.hoon and harvesting the diffs
This commit is contained in:
drbeefsupreme 2022-03-17 14:13:54 -04:00
parent bce1c9fe2a
commit 5171ec367a
No known key found for this signature in database
GPG Key ID: B70D5683DE7F9EFC

View File

@ -16,17 +16,24 @@
:: ::
:: TODO: change block maps to ordered maps :: TODO: change block maps to ordered maps
:: ::
/- spider /- dice,
spider
:: ::
/+ dice, /+ dice,
ethereum, ethereum,
ethio, ethio,
naive, naive,
naive-tx=naive-transactions,
*strandio *strandio
:: ::
:: imports most recent downloaded logs :: imports most recent downloaded logs
::/* logs %eth-logs /app/azimuth/logs/eth-logs ::/* logs %eth-logs /app/azimuth/logs/eth-logs
::/* logs %eth-logs /app/azimuth/tid/eth-logs ::/* logs %eth-logs /app/azimuth/tid/eth-logs
::
:: 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
::
=, strand=strand:spider =, strand=strand:spider
=, jael =, jael
:: ::
@ -79,16 +86,23 @@
=/ logs (scag 50 logs) :: to make debugging faster =/ logs (scag 50 logs) :: to make debugging faster
=/ [naive-contract=address chain-id=@] =/ [naive-contract=address chain-id=@]
[naive chain-id]:(get-network:dice net) [naive chain-id]:(get-network:dice net)
=/ snap=snap-state:dice snap
::
=/ l2-logs=events (filter-l2 logs naive-contract) =/ l2-logs=events (filter-l2 logs naive-contract)
%- %- slog :_ ~ %- %- slog :_ ~
leaf+"processing {<net>} ethereum logs with {<(lent logs)>} total events, of which {<(lent l2-logs)>} are l2 events" leaf+"processing {<net>} ethereum logs with {<(lent logs)>} total events, of which {<(lent l2-logs)>} are l2 events"
=/ blocks=(list blocknum) (get-block-numbers l2-logs) =/ blocks=(list blocknum) (get-block-numbers l2-logs)
=/ tx-hashes=(list keccak) (get-tx-hashes l2-logs) =/ tx-hashes=(list keccak) (get-tx-hashes l2-logs)
=/ block-jar=(jar blocknum keccak) (block-tx-jar l2-logs) =/ block-jar=(jar blocknum keccak) (block-tx-jar l2-logs)
;< timestamps=(map blocknum @da) bind:m (get-timestamps blocks) ;< timestamps=(map blocknum @da) bind:m
;< tx-data=(map keccak [gas=@ud sender=address]) bind:m (get-tx-data tx-hashes) (get-timestamps blocks)
;< tx-data=(map keccak [gas=@ud sender=address]) bind:m
(get-tx-data tx-hashes)
=/ rolls-by-block=(jar blocknum [roll-hash=keccak effects:naive])
(run-logs-from-state nas.snap logs net naive-contract chain-id)
=/ rolling (collate-roll-data blocks block-jar timestamps tx-data) =/ rolling (collate-roll-data blocks block-jar timestamps tx-data)
(pure:m !>(rolling)) ::
(pure:m !>(rolls-by-block))
:: ::
++ collate-roll-data ++ collate-roll-data
|= $: blocks=(list blocknum) |= $: blocks=(list blocknum)
@ -193,29 +207,49 @@
?> ?=(%o -.json) ?> ?=(%o -.json)
(~(got by p.json) 'timestamp') (~(got by p.json) 'timestamp')
-- --
:: TODO: make this return a list of processed events ++ get-roll-data ~
:: along with gas costs and timestamps :: :: passes L2 rolls into naive.hoon to get the transactions stored within
:: |- :: ::
:: ?~ events ++ run-logs-from-state
:: 'no events!' |= $: nas=^state:naive
:: =/ log=event-log:rpc:ethereum i.events logs=events
:: ?~ mined.log =net
:: 'empty log!' naive-contract=address
:: =/ =^input:naive chain-id=@ud
:: :- block-number.u.mined.log ==
:: ?. =(naive-contract address.log) =| out=(jar blocknum [roll-hash=keccak effects:naive])
:: :- %log ^+ out
:: [address.log (data-to-hex:dice data.log) topics.log] :: We need to run the state transitions to see what the individual
:: ?~ input.u.mined.log :: transactions were, as well as whether they succeeded or failed.
:: ~& > 'empty L2 transaction' ::
:: [%bat *@] %- %- slog :_ ~
:: [%bat u.input.u.mined.log] leaf+"processing state transitions beginning from stored snapshot"
:: ?: ?=(%log +<.input) ::
:: $(events t.events) |-
:: $(events t.events) ?~ logs out
:: ?~ l2-logs =/ log=event-log:rpc:ethereum i.logs
:: (pure:m !>(net)) ?~ mined.log
:: (pure:m !>(blocks)) ~& >> 'empty log!'
$(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)
out :: skip L1 logs
(~(add ja out) block [transaction-hash.u.mined.log effects])
==
::
:: ::
++ filter-l2 ++ filter-l2
|= [logs=events naive-contract=address] ^- events |= [logs=events naive-contract=address] ^- events