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

[DRAFT] Build Enriched Traces & Transactions + Aggregation Tables #1161

Draft
wants to merge 47 commits into
base: main
Choose a base branch
from

Conversation

MSilb7
Copy link
Contributor

@MSilb7 MSilb7 commented Dec 12, 2024

Working PR - See overall project #1055

closes #1160 - Transaction Models Exploration
closes #1168 - Trace Models Exploration

The end results of these models are also expected to be used in conjunction with: #1151

TODO:

  • Enriched Transactions Extend existing transaction_fees model
    • Validate that daily_address_summary sustains
  • Enriched Traces
  • Aggregations for Transactions
  • Aggregations for Traces
  • Build Tests

Aggregation strategy:

  • Make a view that aggregates at the transaction level (at least), so we can preserve transaction-level fields (i.e. gas usage).
  • Then build all later aggregations from there.
  • For aggregations below the transaction level, make sure we don't sum up transaction-level fields, since they're not part of the whole.

I'm the worst at excalidraw, but this is what I envision. Progress moves left to right, this PR ends at "Aggregation Models"
image

@MSilb7 MSilb7 self-assigned this Dec 12, 2024
@MSilb7
Copy link
Contributor Author

MSilb7 commented Dec 13, 2024

Added a rough diagram to the first text bubble in the PR

@MSilb7
Copy link
Contributor Author

MSilb7 commented Dec 13, 2024

Remaining gap: How do we test in notebooks when there are input datasets we haven't built yet.

@@ -15,6 +15,9 @@ def create_duckdb_macros(duckdb_client: duckdb.DuckDBPyConnection):

CREATE OR REPLACE MACRO wei_to_gwei(a)
AS a::DECIMAL(28, 0) * 0.000000001::DECIMAL(10, 10);

CREATE OR REPLACE MACRO gwei_to_eth(a)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

modified decimal precision here, it wasn't allowing for a to be a decimal before

The definition of the L1 fee scalar changed in Fjord, we should not combine them together.
-- L2 Legacy Fee
if(l2_priority_fee = 0, l2_fee - l2_base_fee, 0) AS l2_legacy_extra_fee,
--
-- L1 Base
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should build tests here that l1_base_fee + l1_blob_fee = l1_fee

This should hold through the history of time.

"refined_transactions_fees_v1": duckdb_client.view("refined_transactions_fees"),
"refined_trace_calls_v1": duckdb_client.view("refined_trace_calls"),
"event_emitting_transactions_v1": duckdb_client.view("event_emitting_transactions"),
"summary_v1": duckdb_client.view("daily_address_summary"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should we rename this to daily_address_summary_v1? Maybe in a future PR to keep this clean-ish

refined_transactions_fees
WHERE
NOT is_system_transaction
AND gas_price > 0
Copy link
Contributor Author

@MSilb7 MSilb7 Dec 14, 2024

Choose a reason for hiding this comment

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

this used to be at the transactions_fees level, but I unfiltered there (so we preserve those transactions) and brought it here.

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.

Build Enriched Traces & Aggregation Model Build Enriched Transactions & Aggregation Model
2 participants