From a7244b523e19add1bf4c09a35fc0d11b96ab093b Mon Sep 17 00:00:00 2001 From: Austin <93135983+austinFlipside@users.noreply.github.com> Date: Wed, 10 Jan 2024 16:00:49 -0500 Subject: [PATCH] An 4316/shapella upgrade (#230) * new api fields - silver * withdrawals --- models/gold/core/core__fact_blocks.sql | 4 +++- models/gold/core/core__fact_blocks.yml | 6 +++++- models/gold/core/core__fact_transactions.sql | 4 +++- models/gold/core/core__fact_transactions.yml | 6 +++++- models/silver/core/silver__blocks.sql | 2 ++ models/silver/core/silver__receipts.sql | 8 +++++++- models/silver/core/silver__transactions.sql | 20 +++++++++++++++----- 7 files changed, 40 insertions(+), 10 deletions(-) diff --git a/models/gold/core/core__fact_blocks.sql b/models/gold/core/core__fact_blocks.sql index 64153fa4..17bd52f0 100644 --- a/models/gold/core/core__fact_blocks.sql +++ b/models/gold/core/core__fact_blocks.sql @@ -122,7 +122,9 @@ SELECT d.modified_timestamp, '2000-01-01' ) - ) AS modified_timestamp + ) AS modified_timestamp, + withdrawals, + withdrawals_root FROM {{ ref('silver__blocks') }} A LEFT JOIN {{ ref('silver__state_hashes') }} diff --git a/models/gold/core/core__fact_blocks.yml b/models/gold/core/core__fact_blocks.yml index db04b5ed..3c14bdea 100644 --- a/models/gold/core/core__fact_blocks.yml +++ b/models/gold/core/core__fact_blocks.yml @@ -53,4 +53,8 @@ models: - name: INSERTED_TIMESTAMP description: '{{ doc("inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file + description: '{{ doc("modified_timestamp") }}' + - name: WITHDRAWALS + description: An array of withdrawals that occurred in this block. + - name: WITHDRAWALS_ROOT + description: A hash of the withdrawals that occurred in this block. \ No newline at end of file diff --git a/models/gold/core/core__fact_transactions.sql b/models/gold/core/core__fact_transactions.sql index 0101dab7..f720f5b3 100644 --- a/models/gold/core/core__fact_transactions.sql +++ b/models/gold/core/core__fact_transactions.sql @@ -67,7 +67,9 @@ SELECT GREATEST(COALESCE(A.modified_timestamp, '2000-01-01'), COALESCE(b.modified_timestamp, '2000-01-01'), COALESCE(C.modified_timestamp, '2000-01-01')) AS modified_timestamp, VALUE AS eth_value, value_precise_raw AS eth_value_precise_raw, - value_precise AS eth_value_precise + value_precise AS eth_value_precise, + deposit_nonce, + deposit_receipt_version FROM {{ ref('silver__transactions') }} A LEFT JOIN {{ ref('silver__state_hashes') }} diff --git a/models/gold/core/core__fact_transactions.yml b/models/gold/core/core__fact_transactions.yml index 413c62c3..871500ec 100644 --- a/models/gold/core/core__fact_transactions.yml +++ b/models/gold/core/core__fact_transactions.yml @@ -87,4 +87,8 @@ models: - name: INSERTED_TIMESTAMP description: '{{ doc("inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file + description: '{{ doc("modified_timestamp") }}' + - name: DEPOSIT_NONCE + description: The nonce of the deposit transaction. + - name: DEPOSIT_RECEIPT_VERSION + description: The version of the deposit receipt. \ No newline at end of file diff --git a/models/silver/core/silver__blocks.sql b/models/silver/core/silver__blocks.sql index dc550871..04035e22 100644 --- a/models/silver/core/silver__blocks.sql +++ b/models/silver/core/silver__blocks.sql @@ -48,6 +48,8 @@ SELECT ) :: INT AS total_difficulty, DATA :transactionsRoot :: STRING AS transactions_root, DATA :uncles AS uncles, + DATA :result :withdrawals AS withdrawals, + DATA :result :withdrawalsRoot :: STRING AS withdrawals_root, _inserted_timestamp, {{ dbt_utils.generate_surrogate_key( ['block_number'] diff --git a/models/silver/core/silver__receipts.sql b/models/silver/core/silver__receipts.sql index f7749100..af847e52 100644 --- a/models/silver/core/silver__receipts.sql +++ b/models/silver/core/silver__receipts.sql @@ -109,7 +109,13 @@ FINAL AS ( utils.udf_hex_to_int( DATA :type :: STRING ) :: INT AS TYPE, - _inserted_timestamp + _inserted_timestamp, + utils.udf_hex_to_int( + DATA :depositNonce :: STRING + ) :: INT AS deposit_nonce, + utils.udf_hex_to_int( + DATA: depositReceiptVersion :: STRING + ) :: INT AS deposit_receipt_version FROM base ) diff --git a/models/silver/core/silver__transactions.sql b/models/silver/core/silver__transactions.sql index 1763322a..875d6234 100644 --- a/models/silver/core/silver__transactions.sql +++ b/models/silver/core/silver__transactions.sql @@ -172,7 +172,9 @@ new_records AS ( effective_gas_price, r.type AS tx_type, t._inserted_timestamp, - t.data + t.data, + r.deposit_nonce, + r.deposit_receipt_version FROM base_tx t LEFT OUTER JOIN {{ ref('silver__blocks') }} @@ -248,7 +250,9 @@ missing_data AS ( b._inserted_timestamp, r._inserted_timestamp ) AS _inserted_timestamp, - t.data + t.data, + r.deposit_nonce, + r.deposit_receipt_version FROM {{ this }} t @@ -311,7 +315,9 @@ FINAL AS ( tx_fee_precise, tx_type, _inserted_timestamp, - DATA + DATA, + deposit_nonce, + deposit_receipt_version FROM new_records @@ -354,7 +360,9 @@ SELECT tx_fee_precise_heal AS tx_fee_precise, tx_type, _inserted_timestamp, - DATA + DATA, + deposit_nonce, + deposit_receipt_version FROM missing_data {% endif %} @@ -421,7 +429,9 @@ SELECT ) }} AS transactions_id, SYSDATE() AS inserted_timestamp, SYSDATE() AS modified_timestamp, - '{{ invocation_id }}' AS _invocation_id + '{{ invocation_id }}' AS _invocation_id, + deposit_nonce, + deposit_receipt_version FROM FINAL WHERE