Skip to content
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

Merged

Conversation

soispoke
Copy link
Contributor

@soispoke soispoke commented Aug 30, 2022

Brief comments on the purpose of your changes:

For Dune Engine V2
I've checked that:

  • I tested the query on dune.com after compiling the model with dbt compile (compiled queries are written to the target directory)
  • I used "refs" to reference other models in this repo and "sources" to reference raw or decoded tables
  • if adding a new model, I added a test
  • the filename is unique and ends with .sql
  • each sql file is a select statement and has only one view, table or function defined
  • column names are lowercase_snake_cased

When you are ready for a review, tag duneanalytics/data-experience. We will re-open your forked pull request as an internal pull request. Then your spells will run in dbt and the logs will be avaiable in Github Actions DBT Slim CI. This job will only run the models and tests changed by your PR compared to the production project.

@height
Copy link

height bot commented Aug 30, 2022

This pull request has been linked to 1 task:

💡Tip: Add "Close T-15760" to the pull request title or description, to a commit message, or in a comment to mark this task as "Done" when the pull request is merged.

@soispoke soispoke mentioned this pull request Aug 30, 2022
6 tasks
@@ -35,13 +35,13 @@ FROM
AND et.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_ethereum','eth_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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the LEFT JOIN above be an INNER JOIN instead? And then you could drop the where filter below.

Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@@ -35,13 +35,13 @@ FROM
AND et.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_ethereum','eth_evt_Deposit') }})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't comment on the actual line but line 32 source('ethereum','transactions_0006') should be source('ethereum','transactions').

Copy link
Member

Choose a reason for hiding this comment

The 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)

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soispoke can you update this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeff-dude Done

@hildobby
Copy link
Collaborator

Discussed this in DMs with @jeff-dude, imo naming should be consistent across the board and since avalanche_c is avalanche's default blockchain name, all abstractions should also stick with it for consistency, don't you guys think?

PS: Apologies for not changing the names myself when doing the first tornado cash PR, I will make sure to be careful on names being lowercase going forward!

Copy link
Contributor Author

@soispoke soispoke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mades some small changes regarding lowercasing blockchains and moving from avalanche to avalanche_c for consistency

@@ -560,17 +560,17 @@ ALTER TABLE airdrop_optimism.addresses SET TBLPROPERTIES ('dune.public'='true',
{% endset %}

{% set tornado_cash_deposits %}
ALTER TABLE tornado_cash.deposits SET TBLPROPERTIES ('dune.public'='true',
'dune.data_explorer.blockchains'='["ethereum", "bnb", "avalanche", "gnosis", "optimism", "arbitrum"]',
ALTER VIEW tornado_cash.deposits SET TBLPROPERTIES ('dune.public'='true',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't these both be 'table'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right they should, pushed a fix

@@ -35,13 +35,13 @@ FROM
AND et.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_ethereum','eth_evt_Deposit') }})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soispoke can you update this?

@jeff-dude
Copy link
Member

to @aalan3 point, should we use this PR to update all joins to base tables as inner join?

Copy link
Contributor Author

@soispoke soispoke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeff-dude Done, updated all joins with base tables

@soispoke
Copy link
Contributor Author

soispoke commented Sep 1, 2022

Thanks !

@soispoke soispoke merged commit b6adb5e into main Sep 1, 2022
@jeff-dude jeff-dude deleted the T-15760-fix-tornado-cash-materialization-strategy-and-lowercase branch September 1, 2022 15:03
'dune.data_explorer.category'='abstraction',
'dune.data_explorer.abstraction.type'='project',
'dune.data_explorer.abstraction.name'='tornado_cash',
'dune.data_explorer.contributors'='["hildobby", "dot2dotseurat"]');
{% endset %}

{% set tornado_cash_withdrawals %}
ALTER TABLE tornado_cash.withdrawals SET TBLPROPERTIES ('dune.public'='true',
'dune.data_explorer.blockchains'='["ethereum", "bnb", "avalanche", "gnosis", "optimism", "arbitrum"]',
ALTER VIEW tornado_cash.withdrawals SET TBLPROPERTIES ('dune.public'='true',
Copy link
Member

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'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants