-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tornado Cash: Fix sources, lowercase and improve materialization strategy #1460
Changes from all commits
bed9de8
f707c2e
6fbecf5
1e9f8ae
326dbcf
bccaa5d
c2f497b
861dba2
c449a7e
5d81c41
edc1780
66f0bf3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,8 @@ FROM | |
SELECT tc.evt_block_time AS block_time | ||
, '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' AS currency_contract | ||
, 'ETH' AS currency_symbol | ||
, 'Ethereum' AS blockchain | ||
, 'Classic' AS tornado_version | ||
, 'ethereum' AS blockchain | ||
, 'classic' AS tornado_version | ||
, et.from AS depositor | ||
, tc.contract_address AS contract_address | ||
, CASE WHEN tc.contract_address='0x12d66f87a04a9e220743712ce6d9bb1b5616b8fc' THEN 0.1 | ||
|
@@ -29,19 +29,19 @@ FROM | |
, tc.evt_index | ||
, TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date | ||
FROM {{ source('tornado_cash_ethereum','eth_evt_Deposit') }} tc | ||
LEFT JOIN {{ source('ethereum','transactions_0006') }} et | ||
INNER JOIN {{ source('ethereum','transactions') }} et | ||
ON et.hash=tc.evt_tx_hash | ||
{% if not is_incremental() %} | ||
AND et.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_ethereum','eth_evt_Deposit') }}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't comment on the actual line but line 32 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i believe that source was used specifically for performance reasons, but agreed to revert back if we're comfortable with new performance enhancement changes (could then also remove from source file) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That issue has been resolved now (since last week). We shouldn't refer to these ever though because they can (and will) change without warning. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @soispoke can you update this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jeff-dude Done |
||
{% endif %} | ||
{% if is_incremental() %} | ||
AND et.block_time >= (select max(block_time) from {{ this }}) | ||
AND et.block_time >= date_trunc("day", now() - interval '1 week') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added this common check to review doc, but many existing queries from v1 will have left joins to look out for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are cases where you'd want to do a left join as I discovered here. But generally it seems like it should be inner. |
||
{% endif %} | ||
{% if not is_incremental() %} | ||
WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_ethereum','eth_evt_Deposit') }}) | ||
{% endif %} | ||
{% if is_incremental() %} | ||
WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) | ||
WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') | ||
{% endif %} | ||
|
||
UNION | ||
|
@@ -94,8 +94,8 @@ FROM | |
WHEN tc.contract_address='0x610b717796ad172b316836ac95a2ffad065ceab4' THEN 'WBTC' | ||
WHEN tc.contract_address='0xbb93e510bbcd0b7beb5a853875f9ec60275cf498' THEN 'WBTC' | ||
END AS currency_symbol | ||
, 'Ethereum' AS blockchain | ||
, 'Classic' AS tornado_version | ||
, 'ethereum' AS blockchain | ||
, 'classic' AS tornado_version | ||
, et.from AS depositor | ||
, tc.contract_address AS contract_address | ||
, CASE WHEN tc.contract_address='0xd4b88df4d29f5cedd6857912842cff3b20c8cfa3' THEN 100 | ||
|
@@ -126,19 +126,19 @@ FROM | |
, tc.evt_index | ||
, TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date | ||
FROM {{ source('tornado_cash_ethereum','erc20_evt_Deposit') }} tc | ||
LEFT JOIN {{ source('ethereum','transactions_0006') }} et | ||
INNER JOIN {{ source('ethereum','transactions') }} et | ||
ON et.hash=tc.evt_tx_hash | ||
{% if not is_incremental() %} | ||
AND et.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_ethereum','erc20_evt_Deposit') }}) | ||
{% endif %} | ||
{% if is_incremental() %} | ||
AND et.block_time >= (select max(block_time) from {{ this }}) | ||
AND et.block_time >= date_trunc("day", now() - interval '1 week') | ||
{% endif %} | ||
{% if not is_incremental() %} | ||
WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_ethereum','erc20_evt_Deposit') }}) | ||
{% endif %} | ||
{% if is_incremental() %} | ||
WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) | ||
WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') | ||
{% endif %} | ||
|
||
UNION | ||
|
@@ -147,8 +147,8 @@ FROM | |
SELECT tc.evt_block_time AS block_time | ||
, '0xb8c77482e45f1f44de1745f52c74426c631bdd52' AS currency_contract | ||
, 'BNB' AS currency_symbol | ||
, 'BNB' AS blockchain | ||
, 'Classic' AS tornado_version | ||
, 'bnb' AS blockchain | ||
, 'classic' AS tornado_version | ||
, bt.from AS depositor | ||
, tc.contract_address AS contract_address | ||
, CASE WHEN tc.contract_address='0x84443cfd09a48af6ef360c6976c5392ac5023a1f' THEN 0.1 | ||
|
@@ -161,19 +161,19 @@ FROM | |
, tc.evt_index | ||
, TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date | ||
FROM {{ source('tornado_cash_bnb','TornadoCashBNB_evt_Deposit') }} tc | ||
LEFT JOIN {{ source('bnb','transactions') }} bt | ||
INNER JOIN {{ source('bnb','transactions') }} bt | ||
ON bt.hash=tc.evt_tx_hash | ||
{% if not is_incremental() %} | ||
AND bt.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_bnb','TornadoCashBNB_evt_Deposit') }}) | ||
{% endif %} | ||
{% if is_incremental() %} | ||
AND bt.block_time >= (select max(block_time) from {{ this }}) | ||
AND bt.block_time >= date_trunc("day", now() - interval '1 week') | ||
{% endif %} | ||
{% if not is_incremental() %} | ||
WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_bnb','TornadoCashBNB_evt_Deposit') }}) | ||
{% endif %} | ||
{% if is_incremental() %} | ||
WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) | ||
WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') | ||
{% endif %} | ||
|
||
UNION | ||
|
@@ -182,8 +182,8 @@ FROM | |
SELECT tc.evt_block_time AS block_time | ||
, '0x6b175474e89094c44da98b954eedeac495271d0f' AS currency_contract | ||
, 'xDAI' AS currency_symbol | ||
, 'Gnosis' AS blockchain | ||
, 'Classic' AS tornado_version | ||
, 'gnosis' AS blockchain | ||
, 'classic' AS tornado_version | ||
, gt.from AS depositor | ||
, tc.contract_address AS contract_address | ||
, CASE WHEN tc.contract_address='0x1e34a77868e19a6647b1f2f47b51ed72dede95dd' THEN 100 | ||
|
@@ -196,19 +196,19 @@ FROM | |
, tc.evt_index | ||
, TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date | ||
FROM {{ source('tornado_cash_gnosis','eth_evt_Deposit') }} tc | ||
LEFT JOIN {{ source('gnosis','transactions') }} gt | ||
INNER JOIN {{ source('gnosis','transactions') }} gt | ||
ON gt.hash=tc.evt_tx_hash | ||
{% if not is_incremental() %} | ||
AND gt.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_gnosis','eth_evt_Deposit') }}) | ||
{% endif %} | ||
{% if is_incremental() %} | ||
AND gt.block_time >= (select max(block_time) from {{ this }}) | ||
AND gt.block_time >= date_trunc("day", now() - interval '1 week') | ||
{% endif %} | ||
{% if not is_incremental() %} | ||
WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_gnosis','eth_evt_Deposit') }}) | ||
{% endif %} | ||
{% if is_incremental() %} | ||
WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) | ||
WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') | ||
{% endif %} | ||
|
||
UNION | ||
|
@@ -217,8 +217,8 @@ FROM | |
SELECT tc.evt_block_time AS block_time | ||
, '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' AS currency_contract | ||
, 'ETH' AS currency_symbol | ||
, 'Optimism' AS blockchain | ||
, 'Classic' AS tornado_version | ||
, 'optimism' AS blockchain | ||
, 'classic' AS tornado_version | ||
, ot.from AS depositor | ||
, tc.contract_address AS contract_address | ||
, CASE WHEN tc.contract_address='0x84443cfd09a48af6ef360c6976c5392ac5023a1f' THEN 0.1 | ||
|
@@ -231,19 +231,19 @@ FROM | |
, tc.evt_index | ||
, TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date | ||
FROM {{ source('tornado_cash_optimism','ETHTornado_evt_Deposit') }} tc | ||
LEFT JOIN {{ source('optimism','transactions') }} ot | ||
INNER JOIN {{ source('optimism','transactions') }} ot | ||
ON ot.hash=tc.evt_tx_hash | ||
{% if not is_incremental() %} | ||
AND ot.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_optimism','ETHTornado_evt_Deposit') }}) | ||
{% endif %} | ||
{% if is_incremental() %} | ||
AND ot.block_time >= (select max(block_time) from {{ this }}) | ||
AND ot.block_time >= date_trunc("day", now() - interval '1 week') | ||
{% endif %} | ||
{% if not is_incremental() %} | ||
WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_optimism','ETHTornado_evt_Deposit') }}) | ||
{% endif %} | ||
{% if is_incremental() %} | ||
WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) | ||
WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') | ||
{% endif %} | ||
|
||
UNION | ||
|
@@ -252,8 +252,8 @@ FROM | |
SELECT tc.evt_block_time AS block_time | ||
, '0x85f138bfEE4ef8e540890CFb48F620571d67Eda3' AS currency_contract | ||
, 'AVAX' AS currency_symbol | ||
, 'Avalanche' AS blockchain | ||
, 'Classic' AS tornado_version | ||
, 'avalanche_c' AS blockchain | ||
, 'classic' AS tornado_version | ||
, at.from AS depositor | ||
, tc.contract_address AS contract_address | ||
, CASE WHEN tc.contract_address='0x330bdfade01ee9bf63c209ee33102dd334618e0a' THEN 10 | ||
|
@@ -265,19 +265,19 @@ FROM | |
, tc.evt_index | ||
, TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date | ||
FROM {{ source('tornado_cash_avalanche_c','ETHTornado_evt_Deposit') }} tc | ||
LEFT JOIN {{ source('avalanche_c','transactions') }} at | ||
INNER JOIN {{ source('avalanche_c','transactions') }} at | ||
ON at.hash=tc.evt_tx_hash | ||
{% if not is_incremental() %} | ||
AND at.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_avalanche_c','ETHTornado_evt_Deposit') }}) | ||
{% endif %} | ||
{% if is_incremental() %} | ||
AND at.block_time >= (select max(block_time) from {{ this }}) | ||
AND at.block_time >= date_trunc("day", now() - interval '1 week') | ||
{% endif %} | ||
{% if not is_incremental() %} | ||
WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_avalanche_c','ETHTornado_evt_Deposit') }}) | ||
{% endif %} | ||
{% if is_incremental() %} | ||
WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) | ||
WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') | ||
{% endif %} | ||
|
||
UNION | ||
|
@@ -286,8 +286,8 @@ FROM | |
SELECT tc.evt_block_time AS block_time | ||
, '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' AS currency_contract | ||
, 'ETH' AS currency_symbol | ||
, 'Arbitrum' AS blockchain | ||
, 'Classic' AS tornado_version | ||
, 'arbitrum' AS blockchain | ||
, 'classic' AS tornado_version | ||
, at.from AS depositor | ||
, tc.contract_address AS contract_address | ||
, CASE WHEN tc.contract_address='0x84443cfd09a48af6ef360c6976c5392ac5023a1f' THEN 0.1 | ||
|
@@ -300,18 +300,18 @@ FROM | |
, tc.evt_index | ||
, TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date | ||
FROM {{ source('tornado_cash_arbitrum','ETHTornado_evt_Deposit') }} tc | ||
LEFT JOIN {{ source('arbitrum','transactions') }} at | ||
INNER JOIN {{ source('arbitrum','transactions') }} at | ||
ON at.hash=tc.evt_tx_hash | ||
{% if not is_incremental() %} | ||
AND at.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_arbitrum','ETHTornado_evt_Deposit') }}) | ||
{% endif %} | ||
{% if is_incremental() %} | ||
AND at.block_time >= (select max(block_time) from {{ this }}) | ||
AND at.block_time >= date_trunc("day", now() - interval '1 week') | ||
{% endif %} | ||
{% if not is_incremental() %} | ||
WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_arbitrum','ETHTornado_evt_Deposit') }}) | ||
{% endif %} | ||
{% if is_incremental() %} | ||
WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) | ||
WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') | ||
{% endif %} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@soispoke looks like this one didn't get updated back to 'table'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was fixed here https://github.com/duneanalytics/spellbook/pull/1475/files#diff-89d8392c4db5b996c368bef69b027f7ccd442b9135924630007065e3a1d5569cR590