From afb57644e144618b803f8d7cd50ce6b85a91c871 Mon Sep 17 00:00:00 2001 From: drethereum Date: Mon, 8 Jul 2024 17:33:44 -0600 Subject: [PATCH] test changes for traces --- .../doc_descriptions/core/berachain_blocks.md | 2 +- .../core/berachain_event_logs.md | 2 +- .../doc_descriptions/core/berachain_traces.md | 2 +- .../core/berachain_transactions.md | 2 +- .../core/berachain_transfers.md | 2 +- .../tests/blocks/test_gold__blocks_full.sql | 9 ++++ .../tests/blocks/test_gold__blocks_full.yml | 10 ++++ .../tests/blocks/test_gold__blocks_recent.sql | 24 +++++++++ .../tests/blocks/test_gold__blocks_recent.yml | 19 +++++++ .../event_logs/test_gold__event_logs_full.sql | 9 ++++ .../event_logs/test_gold__event_logs_full.yml | 19 +++++++ .../test_gold__event_logs_recent.sql | 23 +++++++++ .../test_gold__event_logs_recent.yml | 18 +++++++ .../tests/traces/test_gold__traces_full.sql | 13 +++++ .../tests/traces/test_gold__traces_full.yml | 17 +++++++ .../tests/traces/test_gold__traces_recent.sql | 27 ++++++++++ .../tests/traces/test_gold__traces_recent.yml | 16 ++++++ .../test_gold__transactions_full.sql | 9 ++++ .../test_gold__transactions_full.yml | 19 +++++++ .../test_gold__transactions_recent.sql | 23 +++++++++ .../test_gold__transactions_recent.yml | 18 +++++++ .../tests/traces/test_silver__traces_full.yml | 49 +++++-------------- .../traces/test_silver__traces_recent.yml | 25 +++++----- .../berachain/test_silver__missing_traces.sql | 2 +- .../test_silver__recent_missing_traces.sql | 2 +- 25 files changed, 302 insertions(+), 59 deletions(-) create mode 100644 models/gold/tests/blocks/test_gold__blocks_full.sql create mode 100644 models/gold/tests/blocks/test_gold__blocks_full.yml create mode 100644 models/gold/tests/blocks/test_gold__blocks_recent.sql create mode 100644 models/gold/tests/blocks/test_gold__blocks_recent.yml create mode 100644 models/gold/tests/event_logs/test_gold__event_logs_full.sql create mode 100644 models/gold/tests/event_logs/test_gold__event_logs_full.yml create mode 100644 models/gold/tests/event_logs/test_gold__event_logs_recent.sql create mode 100644 models/gold/tests/event_logs/test_gold__event_logs_recent.yml create mode 100644 models/gold/tests/traces/test_gold__traces_full.sql create mode 100644 models/gold/tests/traces/test_gold__traces_full.yml create mode 100644 models/gold/tests/traces/test_gold__traces_recent.sql create mode 100644 models/gold/tests/traces/test_gold__traces_recent.yml create mode 100644 models/gold/tests/transactions/test_gold__transactions_full.sql create mode 100644 models/gold/tests/transactions/test_gold__transactions_full.yml create mode 100644 models/gold/tests/transactions/test_gold__transactions_recent.sql create mode 100644 models/gold/tests/transactions/test_gold__transactions_recent.yml diff --git a/models/doc_descriptions/core/berachain_blocks.md b/models/doc_descriptions/core/berachain_blocks.md index 4f46df0..36c53fd 100644 --- a/models/doc_descriptions/core/berachain_blocks.md +++ b/models/doc_descriptions/core/berachain_blocks.md @@ -28,7 +28,7 @@ Block nonce is a value used during mining to demonstrate proof of work for a giv {% docs berachain_blocks_table_doc %} -This table contains block level data for the kaia Blockchain. This table can be used to analyze trends at a block level, for example gas fees vs. total transactions over time. For more information on EVM transactions, please see [Etherscan Resources](https://etherscan.io/directory/Learning_Resources/Ethereum) or [The Ethereum Organization](https://ethereum.org/en/developers/docs/blocks/) +This table contains block level data for the berachain Blockchain. This table can be used to analyze trends at a block level, for example gas fees vs. total transactions over time. For more information on EVM transactions, please see [Etherscan Resources](https://etherscan.io/directory/Learning_Resources/Ethereum) or [The Ethereum Organization](https://ethereum.org/en/developers/docs/blocks/) {% enddocs %} diff --git a/models/doc_descriptions/core/berachain_event_logs.md b/models/doc_descriptions/core/berachain_event_logs.md index 31e908b..8c9b70d 100644 --- a/models/doc_descriptions/core/berachain_event_logs.md +++ b/models/doc_descriptions/core/berachain_event_logs.md @@ -63,7 +63,7 @@ The un-decoded event data. {% docs berachain_logs_table_doc %} -This table contains flattened event logs from transactions on the kaia Blockchain. Transactions may have multiple events, which are denoted by the event index for a transaction hash. Therefore, this table is unique on the combination of transaction hash and event index. +This table contains flattened event logs from transactions on the berachain Blockchain. Transactions may have multiple events, which are denoted by the event index for a transaction hash. Therefore, this table is unique on the combination of transaction hash and event index. {% enddocs %} diff --git a/models/doc_descriptions/core/berachain_traces.md b/models/doc_descriptions/core/berachain_traces.md index c1ba8b4..879731f 100644 --- a/models/doc_descriptions/core/berachain_traces.md +++ b/models/doc_descriptions/core/berachain_traces.md @@ -77,7 +77,7 @@ The amount of nested sub traces for this trace. {% docs berachain_traces_table_doc %} -Data is reliable starting on June 1st, 2024. We are in the process of backfilling this data further. This table contains flattened trace data for internal contract calls on the kaia Blockchain. Hex encoded fields can be decoded to integers by using `utils.udf_hex_to_int()`. +Data is reliable starting on June 1st, 2024. We are in the process of backfilling this data further. This table contains flattened trace data for internal contract calls on the berachain Blockchain. Hex encoded fields can be decoded to integers by using `utils.udf_hex_to_int()`. {% enddocs %} diff --git a/models/doc_descriptions/core/berachain_transactions.md b/models/doc_descriptions/core/berachain_transactions.md index 93286ff..7a75353 100644 --- a/models/doc_descriptions/core/berachain_transactions.md +++ b/models/doc_descriptions/core/berachain_transactions.md @@ -91,7 +91,7 @@ Status of the transaction. {% docs berachain_tx_table_doc %} -This table contains transaction level data for the kaia Blockchain. Each transaction will have a unique transaction hash, along with transactions fees and a ETH value transferred when applicable. Transactions may be native ETH transfers or interactions with contract addresses. For more information, please see [The Ethereum Organization - Transactions](https://ethereum.org/en/developers/docs/transactions/) +This table contains transaction level data for the berachain Blockchain. Each transaction will have a unique transaction hash, along with transactions fees and a ETH value transferred when applicable. Transactions may be native ETH transfers or interactions with contract addresses. For more information, please see [The Ethereum Organization - Transactions](https://ethereum.org/en/developers/docs/transactions/) {% enddocs %} diff --git a/models/doc_descriptions/core/berachain_transfers.md b/models/doc_descriptions/core/berachain_transfers.md index 147e826..f5e0a00 100644 --- a/models/doc_descriptions/core/berachain_transfers.md +++ b/models/doc_descriptions/core/berachain_transfers.md @@ -113,7 +113,7 @@ The amount of tokens transferred returned as a string to preserve precision. Thi {% docs berachain_transfer_table_doc %} -This table contains events on the kaia Blockchain with an event name of 'Transfer'. The contract address is the token transferred, and the raw amount field is the amount of tokens transferred. Please note this amount is not decimal adjusted. This table will not contain transfers of native ETH. +This table contains events on the berachain Blockchain with an event name of 'Transfer'. The contract address is the token transferred, and the raw amount field is the amount of tokens transferred. Please note this amount is not decimal adjusted. This table will not contain transfers of native ETH. {% enddocs %} diff --git a/models/gold/tests/blocks/test_gold__blocks_full.sql b/models/gold/tests/blocks/test_gold__blocks_full.sql new file mode 100644 index 0000000..0cc4ff3 --- /dev/null +++ b/models/gold/tests/blocks/test_gold__blocks_full.sql @@ -0,0 +1,9 @@ +{{ config ( + materialized = 'view', + tags = ['full_test'] +) }} + +SELECT + * +FROM + {{ ref('testnet__fact_blocks') }} diff --git a/models/gold/tests/blocks/test_gold__blocks_full.yml b/models/gold/tests/blocks/test_gold__blocks_full.yml new file mode 100644 index 0000000..d04b3be --- /dev/null +++ b/models/gold/tests/blocks/test_gold__blocks_full.yml @@ -0,0 +1,10 @@ +version: 2 +models: + - name: test_gold__blocks_full + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - BLOCK_NUMBER + - fsc_utils.sequence_gaps: + column_name: BLOCK_NUMBER + where: BLOCK_TIMESTAMP < CURRENT_DATE - 1 \ No newline at end of file diff --git a/models/gold/tests/blocks/test_gold__blocks_recent.sql b/models/gold/tests/blocks/test_gold__blocks_recent.sql new file mode 100644 index 0000000..c0a26c6 --- /dev/null +++ b/models/gold/tests/blocks/test_gold__blocks_recent.sql @@ -0,0 +1,24 @@ +{{ config ( + materialized = 'view', + tags = ['recent_test'] +) }} + +WITH last_3_days AS ( + + SELECT + block_number + FROM + {{ ref("_block_lookback") }} +) + +SELECT + * +FROM + {{ ref('testnet__fact_blocks') }} +WHERE + block_number >= ( + SELECT + block_number + FROM + last_3_days + ) diff --git a/models/gold/tests/blocks/test_gold__blocks_recent.yml b/models/gold/tests/blocks/test_gold__blocks_recent.yml new file mode 100644 index 0000000..8613c22 --- /dev/null +++ b/models/gold/tests/blocks/test_gold__blocks_recent.yml @@ -0,0 +1,19 @@ +version: 2 +models: + - name: test_gold__blocks_recent + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - BLOCK_NUMBER + - fsc_utils.sequence_gaps: + column_name: BLOCK_NUMBER + config: + severity: error + error_if: ">10" + columns: + - name: BLOCK_TIMESTAMP + tests: + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: hour + interval: 3 + \ No newline at end of file diff --git a/models/gold/tests/event_logs/test_gold__event_logs_full.sql b/models/gold/tests/event_logs/test_gold__event_logs_full.sql new file mode 100644 index 0000000..dce5b77 --- /dev/null +++ b/models/gold/tests/event_logs/test_gold__event_logs_full.sql @@ -0,0 +1,9 @@ +{{ config ( + materialized = 'view', + tags = ['full_test'] +) }} + +SELECT + * +FROM + {{ ref('testnet__fact_event_logs') }} diff --git a/models/gold/tests/event_logs/test_gold__event_logs_full.yml b/models/gold/tests/event_logs/test_gold__event_logs_full.yml new file mode 100644 index 0000000..0fa67e4 --- /dev/null +++ b/models/gold/tests/event_logs/test_gold__event_logs_full.yml @@ -0,0 +1,19 @@ +version: 2 +models: + - name: test_gold__event_logs_full + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - _LOG_ID + - fsc_utils.sequence_gaps: + partition_by: + - BLOCK_NUMBER + - TX_HASH + column_name: EVENT_INDEX + where: BLOCK_TIMESTAMP < CURRENT_DATE - 1 + columns: + - name: BLOCK_TIMESTAMP + tests: + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 1 \ No newline at end of file diff --git a/models/gold/tests/event_logs/test_gold__event_logs_recent.sql b/models/gold/tests/event_logs/test_gold__event_logs_recent.sql new file mode 100644 index 0000000..6d58b42 --- /dev/null +++ b/models/gold/tests/event_logs/test_gold__event_logs_recent.sql @@ -0,0 +1,23 @@ +{{ config ( + materialized = 'view', + tags = ['recent_test'] +) }} + +WITH last_3_days AS ( + + SELECT + block_number + FROM + {{ ref("_block_lookback") }} +) +SELECT + * +FROM + {{ ref('testnet__fact_event_logs') }} +WHERE + block_number >= ( + SELECT + block_number + FROM + last_3_days + ) diff --git a/models/gold/tests/event_logs/test_gold__event_logs_recent.yml b/models/gold/tests/event_logs/test_gold__event_logs_recent.yml new file mode 100644 index 0000000..a90829f --- /dev/null +++ b/models/gold/tests/event_logs/test_gold__event_logs_recent.yml @@ -0,0 +1,18 @@ +version: 2 +models: + - name: test_gold__event_logs_recent + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - _LOG_ID + - fsc_utils.sequence_gaps: + partition_by: + - BLOCK_NUMBER + - TX_HASH + column_name: EVENT_INDEX + columns: + - name: BLOCK_TIMESTAMP + tests: + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: hour + interval: 3 diff --git a/models/gold/tests/traces/test_gold__traces_full.sql b/models/gold/tests/traces/test_gold__traces_full.sql new file mode 100644 index 0000000..0bae578 --- /dev/null +++ b/models/gold/tests/traces/test_gold__traces_full.sql @@ -0,0 +1,13 @@ +{{ config ( + materialized = 'view', + tags = ['full_test'] +) }} + +SELECT + * +FROM + {{ ref('testnet__fact_traces') }} +WHERE + from_address <> '0x' +AND + to_address <> '0x' \ No newline at end of file diff --git a/models/gold/tests/traces/test_gold__traces_full.yml b/models/gold/tests/traces/test_gold__traces_full.yml new file mode 100644 index 0000000..adfb9ad --- /dev/null +++ b/models/gold/tests/traces/test_gold__traces_full.yml @@ -0,0 +1,17 @@ +version: 2 +models: + - name: test_gold__traces_full + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - BLOCK_NUMBER + - TX_POSITION + - TRACE_INDEX + columns: + - name: BLOCK_TIMESTAMP + tests: + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 1 + + diff --git a/models/gold/tests/traces/test_gold__traces_recent.sql b/models/gold/tests/traces/test_gold__traces_recent.sql new file mode 100644 index 0000000..805d7dc --- /dev/null +++ b/models/gold/tests/traces/test_gold__traces_recent.sql @@ -0,0 +1,27 @@ +{{ config ( + materialized = 'view', + tags = ['recent_test'] +) }} + +WITH last_3_days AS ( + + SELECT + block_number + FROM + {{ ref("_block_lookback") }} +) +SELECT + * +FROM + {{ ref('testnet__fact_traces') }} +WHERE + block_number >= ( + SELECT + block_number + FROM + last_3_days + ) +AND + from_address <> '0x' +AND + to_address <> '0x' diff --git a/models/gold/tests/traces/test_gold__traces_recent.yml b/models/gold/tests/traces/test_gold__traces_recent.yml new file mode 100644 index 0000000..e3e7d93 --- /dev/null +++ b/models/gold/tests/traces/test_gold__traces_recent.yml @@ -0,0 +1,16 @@ +version: 2 +models: + - name: test_gold__traces_recent + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - BLOCK_NUMBER + - TX_POSITION + - TRACE_INDEX + columns: + - name: BLOCK_TIMESTAMP + tests: + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 1 + \ No newline at end of file diff --git a/models/gold/tests/transactions/test_gold__transactions_full.sql b/models/gold/tests/transactions/test_gold__transactions_full.sql new file mode 100644 index 0000000..c72f060 --- /dev/null +++ b/models/gold/tests/transactions/test_gold__transactions_full.sql @@ -0,0 +1,9 @@ +{{ config ( + materialized = 'view', + tags = ['full_test'] +) }} + +SELECT + * +FROM + {{ ref('testnet__fact_transactions') }} diff --git a/models/gold/tests/transactions/test_gold__transactions_full.yml b/models/gold/tests/transactions/test_gold__transactions_full.yml new file mode 100644 index 0000000..98ada1a --- /dev/null +++ b/models/gold/tests/transactions/test_gold__transactions_full.yml @@ -0,0 +1,19 @@ +version: 2 +models: + - name: test_gold__transactions_full + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - TX_HASH + - fsc_utils.sequence_gaps: + partition_by: + - BLOCK_NUMBER + column_name: POSITION + where: BLOCK_TIMESTAMP < CURRENT_DATE - 1 + columns: + - name: BLOCK_TIMESTAMP + tests: + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 1 + diff --git a/models/gold/tests/transactions/test_gold__transactions_recent.sql b/models/gold/tests/transactions/test_gold__transactions_recent.sql new file mode 100644 index 0000000..c8e149b --- /dev/null +++ b/models/gold/tests/transactions/test_gold__transactions_recent.sql @@ -0,0 +1,23 @@ +{{ config ( + materialized = 'view', + tags = ['recent_test'] +) }} + +WITH last_3_days AS ( + + SELECT + block_number + FROM + {{ ref("_block_lookback") }} +) +SELECT + * +FROM + {{ ref('testnet__fact_transactions') }} +WHERE + block_number >= ( + SELECT + block_number + FROM + last_3_days + ) diff --git a/models/gold/tests/transactions/test_gold__transactions_recent.yml b/models/gold/tests/transactions/test_gold__transactions_recent.yml new file mode 100644 index 0000000..87b286b --- /dev/null +++ b/models/gold/tests/transactions/test_gold__transactions_recent.yml @@ -0,0 +1,18 @@ +version: 2 +models: + - name: test_gold__transactions_recent + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - TX_HASH + - fsc_utils.sequence_gaps: + partition_by: + - BLOCK_NUMBER + column_name: POSITION + columns: + - name: BLOCK_TIMESTAMP + tests: + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: hour + interval: 3 + \ No newline at end of file diff --git a/models/silver/core/tests/traces/test_silver__traces_full.yml b/models/silver/core/tests/traces/test_silver__traces_full.yml index 43f7806..b5a2883 100644 --- a/models/silver/core/tests/traces/test_silver__traces_full.yml +++ b/models/silver/core/tests/traces/test_silver__traces_full.yml @@ -6,7 +6,7 @@ models: combination_of_columns: - BLOCK_NUMBER - TX_POSITION - - TRACE_INDEX + - TRACE_ADDRESS columns: - name: BLOCK_NUMBER tests: @@ -14,46 +14,19 @@ models: - dbt_expectations.expect_column_values_to_be_in_type_list: column_type_list: - NUMBER - - FLOAT - - name: BLOCK_TIMESTAMP + - FLOAT + - name: TX_POSITION tests: - - not_null: - where: NOT IS_PENDING - - dbt_expectations.expect_row_values_to_have_recent_data: - datepart: day - interval: 1 + - not_null - dbt_expectations.expect_column_values_to_be_in_type_list: column_type_list: - - TIMESTAMP_NTZ - - name: TX_HASH + - NUMBER + - FLOAT + - name: TRACE_ADDRESS + tests: + - not_null + - name: PARENT_TRACE_ADDRESS tests: - not_null: - where: NOT IS_PENDING - - dbt_expectations.expect_column_values_to_match_regex: - regex: 0[xX][0-9a-fA-F]+ - - name: FROM_ADDRESS - tests: - - not_null: - where: TYPE <> 'SELFDESTRUCT' AND INPUT <> '0x' AND OUTPUT <> '0x' - - dbt_expectations.expect_column_values_to_match_regex: - regex: 0[xX][0-9a-fA-F]+ - where: TYPE <> 'SELFDESTRUCT' AND INPUT <> '0x' AND OUTPUT <> '0x' - - name: TO_ADDRESS - tests: - - dbt_expectations.expect_column_values_to_match_regex: - regex: 0[xX][0-9a-fA-F]+ - where: TO_ADDRESS IS NOT NULL AND INPUT <> '0x' AND OUTPUT <> '0x' - - name: IDENTIFIER - tests: - - not_null - - name: VALUE - tests: - - not_null - - name: GAS - tests: - - not_null - - name: GAS_USED - tests: - - not_null - + where: TRACE_ADDRESS <> 'ORIGIN' diff --git a/models/silver/core/tests/traces/test_silver__traces_recent.yml b/models/silver/core/tests/traces/test_silver__traces_recent.yml index 2e8b3d5..d62be9d 100644 --- a/models/silver/core/tests/traces/test_silver__traces_recent.yml +++ b/models/silver/core/tests/traces/test_silver__traces_recent.yml @@ -6,7 +6,7 @@ models: combination_of_columns: - BLOCK_NUMBER - TX_POSITION - - TRACE_INDEX + - TRACE_ADDRESS columns: - name: BLOCK_NUMBER tests: @@ -14,21 +14,18 @@ models: - dbt_expectations.expect_column_values_to_be_in_type_list: column_type_list: - NUMBER - - FLOAT - - name: BLOCK_TIMESTAMP + - FLOAT + - name: TX_POSITION tests: - - not_null: - where: NOT IS_PENDING - - dbt_expectations.expect_row_values_to_have_recent_data: - datepart: day - interval: 1 + - not_null - dbt_expectations.expect_column_values_to_be_in_type_list: column_type_list: - - TIMESTAMP_NTZ - - name: TX_HASH + - NUMBER + - FLOAT + - name: TRACE_ADDRESS + tests: + - not_null + - name: PARENT_TRACE_ADDRESS tests: - not_null: - where: NOT IS_PENDING - - dbt_expectations.expect_column_values_to_match_regex: - regex: 0[xX][0-9a-fA-F]+ - \ No newline at end of file + where: TRACE_ADDRESS <> 'ORIGIN' \ No newline at end of file diff --git a/tests/berachain/test_silver__missing_traces.sql b/tests/berachain/test_silver__missing_traces.sql index c96256f..b7a48e4 100644 --- a/tests/berachain/test_silver__missing_traces.sql +++ b/tests/berachain/test_silver__missing_traces.sql @@ -1,2 +1,2 @@ -- depends_on: {{ ref('test_silver__transactions_full') }} -{{ missing_txs(ref("test_silver__traces_full")) }} +{{ missing_txs(ref("test_gold__traces_full")) }} diff --git a/tests/berachain/test_silver__recent_missing_traces.sql b/tests/berachain/test_silver__recent_missing_traces.sql index 26a69d4..82557a3 100644 --- a/tests/berachain/test_silver__recent_missing_traces.sql +++ b/tests/berachain/test_silver__recent_missing_traces.sql @@ -1,2 +1,2 @@ -- depends_on: {{ ref('test_silver__transactions_recent') }} -{{ recent_missing_txs(ref("test_silver__traces_recent")) }} +{{ recent_missing_txs(ref("test_gold__traces_recent")) }}