mirror of
https://github.com/FlipsideCrypto/berachain-models.git
synced 2026-02-06 14:17:04 +00:00
gold tables and docs
This commit is contained in:
parent
7b2c1d772e
commit
d5654062c2
@ -65,9 +65,9 @@ vars:
|
||||
OBSERV_FULL_TEST: False
|
||||
WAIT: 0
|
||||
HEAL_MODEL: False
|
||||
HEAL_CURATED_MODEL: []
|
||||
HEAL_MODELS: []
|
||||
START_GHA_TASKS: False
|
||||
|
||||
RELOAD_TRACES: False
|
||||
|
||||
#### STREAMLINE 2.0 BEGIN ####
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
block_number AS base_block_number,
|
||||
tx_hash AS base_tx_hash
|
||||
FROM
|
||||
{{ ref('test_silver_testnet__transactions_full') }}
|
||||
{{ ref('test_silver__transactions_full') }}
|
||||
),
|
||||
model_name AS (
|
||||
SELECT
|
||||
@ -40,7 +40,7 @@ WHERE
|
||||
block_number AS base_block_number,
|
||||
tx_hash AS base_tx_hash
|
||||
FROM
|
||||
{{ ref('test_silver_testnet__transactions_recent') }}
|
||||
{{ ref('test_silver__transactions_recent') }}
|
||||
),
|
||||
model_name AS (
|
||||
SELECT
|
||||
|
||||
126
models/doc_descriptions/core/berachain_blocks.md
Normal file
126
models/doc_descriptions/core/berachain_blocks.md
Normal file
@ -0,0 +1,126 @@
|
||||
{% docs berachain_block_header_json %}
|
||||
|
||||
This JSON column contains the block header details.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_blockchain %}
|
||||
|
||||
The blockchain on which transactions are being confirmed.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_blocks_hash %}
|
||||
|
||||
The hash of the block header for a given block.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_blocks_nonce %}
|
||||
|
||||
Block nonce is a value used during mining to demonstrate proof of work for a given block.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% 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/)
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_difficulty %}
|
||||
|
||||
The effort required to mine the block.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_extra_data %}
|
||||
|
||||
Any data included by the validator for a given block.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_gas_limit %}
|
||||
|
||||
Total gas limit provided by all transactions in the block.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_gas_used %}
|
||||
|
||||
Total gas used in the block.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_miner %}
|
||||
|
||||
Miner who successfully added a given block to the blockchain.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_network %}
|
||||
|
||||
The network on the blockchain used by a transaction.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_parent_hash %}
|
||||
|
||||
The hash of the block from which a given block is generated. Also known as the parent block.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_receipts_root %}
|
||||
|
||||
The root of the state trie.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_sha3_uncles %}
|
||||
|
||||
The mechanism which Ethereum Javascript RLP encodes an empty string.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_size %}
|
||||
|
||||
Block size, which is determined by a given block's gas limit.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_total_difficulty %}
|
||||
|
||||
Total difficulty of the chain at a given block.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_tx_count %}
|
||||
|
||||
Total number of transactions within a block.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_uncle_blocks %}
|
||||
|
||||
Uncle blocks occur when two blocks are mined and broadcasted at the same time, with the same block number. The block validated across the most nodes will be added to the primary chain, and the other one becomes an uncle block. Miners do receive rewards for uncle blocks.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
96
models/doc_descriptions/core/berachain_event_logs.md
Normal file
96
models/doc_descriptions/core/berachain_event_logs.md
Normal file
@ -0,0 +1,96 @@
|
||||
{% docs berachain_event_index %}
|
||||
|
||||
Event number within a transaction.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_event_inputs %}
|
||||
|
||||
The decoded event inputs for a given event.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_event_name %}
|
||||
|
||||
The decoded event name for a given event.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_event_removed %}
|
||||
|
||||
Whether the event has been removed from the transaction.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_origin_sig %}
|
||||
|
||||
The function signature of this transaction.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_log_id_events %}
|
||||
|
||||
This is the primary key for this table. This is a concatenation of the transaction hash and the event index at which the event occurred.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_logs_contract_address %}
|
||||
|
||||
The address interacted with for a given event.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_logs_contract_name %}
|
||||
|
||||
The name of the contract or token, where possible.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_logs_data %}
|
||||
|
||||
The un-decoded event data.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% 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.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_logs_tx_hash %}
|
||||
|
||||
Transaction hash is a unique 66-character identifier that is generated when a transaction is executed. This field will not be unique in this table, as a given transaction can include multiple events.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_origin_from %}
|
||||
|
||||
The from address of this transaction.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_origin_to %}
|
||||
|
||||
The to address of this transaction.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_topics %}
|
||||
|
||||
The un-decoded event input topics.
|
||||
|
||||
{% enddocs %}
|
||||
112
models/doc_descriptions/core/berachain_traces.md
Normal file
112
models/doc_descriptions/core/berachain_traces.md
Normal file
@ -0,0 +1,112 @@
|
||||
{% docs berachain_traces_block_no %}
|
||||
|
||||
The block number of this transaction.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_traces_blocktime %}
|
||||
|
||||
The block timestamp of this transaction.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_traces_call_data %}
|
||||
|
||||
The raw JSON data for this trace.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_traces_from %}
|
||||
|
||||
The sending address of this trace. This is not necessarily the from address of the transaction.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_traces_gas %}
|
||||
|
||||
The gas supplied for this trace.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_traces_gas_used %}
|
||||
|
||||
The gas used for this trace.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_traces_identifier %}
|
||||
|
||||
This field represents the position and type of the trace within the transaction.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_trace_index %}
|
||||
|
||||
The index of the trace within the transaction.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_traces_input %}
|
||||
|
||||
The input data for this trace.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_traces_output %}
|
||||
|
||||
The output data for this trace.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_traces_sub %}
|
||||
|
||||
The amount of nested sub traces for this trace.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% 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()`.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_traces_to %}
|
||||
|
||||
The receiving address of this trace. This is not necessarily the to address of the transaction.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_traces_tx_hash %}
|
||||
|
||||
The transaction hash for the trace. Please note, this is not necessarily unique in this table as transactions frequently have multiple traces.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_traces_type %}
|
||||
|
||||
The type of internal transaction. Common trace types are `CALL`, `DELEGATECALL`, and `STATICCALL`.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_traces_value %}
|
||||
|
||||
The amount of ETH transferred in this trace.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
105
models/doc_descriptions/core/berachain_transactions.md
Normal file
105
models/doc_descriptions/core/berachain_transactions.md
Normal file
@ -0,0 +1,105 @@
|
||||
{% docs berachain_cumulative_gas_used %}
|
||||
|
||||
The total amount of gas used when this transaction was executed in the block.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_tx_block_hash %}
|
||||
|
||||
Block hash is a unique 66-character identifier that is generate when a block is produced.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_tx_fee %}
|
||||
|
||||
Amount paid to validate the transaction in ETH.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_tx_gas_limit %}
|
||||
|
||||
Maximum amount of gas allocated for the transaction.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_tx_gas_price %}
|
||||
|
||||
Cost per unit of gas in Gwei.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_tx_gas_used %}
|
||||
|
||||
Gas used by transaction.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_tx_hash %}
|
||||
|
||||
Transaction hash is a unique 66-character identifier that is generated when a transaction is executed.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_tx_input_data %}
|
||||
|
||||
This column contains additional data for this transaction, and is commonly used as part of a contract interaction or as a message to the recipient.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_tx_json %}
|
||||
|
||||
This JSON column contains the transaction details, including event logs.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_tx_nonce %}
|
||||
|
||||
The number of transactions sent from a given address.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_tx_origin_sig %}
|
||||
|
||||
The function signature of the contract call.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_tx_position %}
|
||||
|
||||
The position of the transaction within the block.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_tx_status %}
|
||||
|
||||
Status of the transaction.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% 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/)
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_value %}
|
||||
|
||||
The value transacted in ETH.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
141
models/doc_descriptions/core/berachain_transfers.md
Normal file
141
models/doc_descriptions/core/berachain_transfers.md
Normal file
@ -0,0 +1,141 @@
|
||||
{% docs berachain_eth_amount %}
|
||||
|
||||
ETH value transferred.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
|
||||
|
||||
{% docs berachain_eth_amount_usd %}
|
||||
|
||||
ETH value transferred, in USD.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
|
||||
{% docs berachain_ez_eth_transfers_table_doc %}
|
||||
|
||||
This table contains all native ETH transfers, including equivalent USD amounts. The origin addresses correspond to the to and from addresses from the `fact_transactions` table. The `identifier` and `tx_hash` columns relate this table back to `fact_traces`, which contains more details on the transfers.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_ez_transfers_table_doc %}
|
||||
|
||||
This table will contain all events in the ```fact_token_transfers table```, along with joined columns such as token price, symbol, and decimals where possible that allow for easier analysis of token transfer events. Please note Native ETH transfers are not included here.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_log_id_transfers %}
|
||||
|
||||
This is the primary key for this table. This is a concatenation of the transaction hash and the event index at which the transfer event occurred. This field can be used to find more details on the event within the ```fact_event_logs``` table.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_eth_origin_from %}
|
||||
|
||||
The from address at the transaction level.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_eth_origin_to %}
|
||||
|
||||
The to address at the transaction level.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_transfer_amount %}
|
||||
|
||||
The decimal transformed amount for this token. Tokens without a decimal adjustment will be nulled out here.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs berachain_transfer_amount_precise %}
|
||||
|
||||
The decimal transformed amount for this token returned as a string to preserve precision. Tokens without a decimal adjustment will be nulled out here.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_transfer_amount_usd %}
|
||||
|
||||
The amount in US dollars for this transfer at the time of the transfer. Tokens without a decimal adjustment or price will be nulled out here.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_transfer_contract_address %}
|
||||
|
||||
Contract address of the token being transferred.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_transfer_from_address %}
|
||||
|
||||
The sending address of this transfer.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_transfer_has_decimal %}
|
||||
|
||||
Whether or not our contracts model contains the necessary decimal adjustment for this token.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_transfer_has_price %}
|
||||
|
||||
Whether or not our prices model contains this hourly token price.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_transfer_raw_amount %}
|
||||
|
||||
The amount of tokens transferred. This value is not decimal adjusted.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs berachain_transfer_raw_amount_precise %}
|
||||
|
||||
The amount of tokens transferred returned as a string to preserve precision. This value is not decimal adjusted.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% 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.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_transfer_to_address %}
|
||||
|
||||
The receiving address of this transfer. This can be a contract address.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_transfer_token_price %}
|
||||
|
||||
The price, if available, for this token at the transfer time.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs berachain_transfer_tx_hash %}
|
||||
|
||||
Transaction hash is a unique 66-character identifier that is generated when a transaction is executed. This will not be unique in this table as a transaction could include multiple transfer events.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
76
models/doc_descriptions/general/__overview__.md
Normal file
76
models/doc_descriptions/general/__overview__.md
Normal file
@ -0,0 +1,76 @@
|
||||
{% docs __overview__ %}
|
||||
|
||||
# Welcome to the Flipside Crypto Berachain Models Documentation!
|
||||
|
||||
## **What does this documentation cover?**
|
||||
The documentation included here details the design of the Berachain tables and views available via [Flipside Crypto.](https://flipsidecrypto.xyz/) For more information on how these models are built, please see [the github repository.](https://github.com/FlipsideCrypto/berachain-models)
|
||||
|
||||
## **How do I use these docs?**
|
||||
The easiest way to navigate this documentation is to use the Quick Links below. These links will take you to the documentation for each table, which contains a description, a list of the columns, and other helpful information.
|
||||
|
||||
If you are experienced with dbt docs, feel free to use the sidebar to navigate the documentation, as well as explore the relationships between tables and the logic building them.
|
||||
|
||||
There is more information on how to use dbt docs in the last section of this document.
|
||||
|
||||
## **Quick Links to Table Documentation**
|
||||
|
||||
**Click on the links below to jump to the documentation for each schema.**
|
||||
|
||||
### Testnet Tables (berachain.testnet)
|
||||
|
||||
**Dimension Tables:**
|
||||
- [dim_labels](https://flipsidecrypto.github.io/berachain-models/#!/model/model.berachain_models.testnet__dim_labels)
|
||||
|
||||
**Fact Tables:**
|
||||
- [fact_blocks](https://flipsidecrypto.github.io/berachain-models/#!/model/model.berachain_models.testnet__fact_blocks)
|
||||
- [fact_event_logs](https://flipsidecrypto.github.io/berachain-models/#!/model/model.berachain_models.testnet__fact_event_logs)
|
||||
- [fact_transactions](https://flipsidecrypto.github.io/berachain-models/#!/model/model.berachain_models.testnet__fact_transactions)
|
||||
- [fact_traces](https://flipsidecrypto.github.io/berachain-models/#!/model/model.berachain_models.testnet__fact_traces)
|
||||
|
||||
## **Helpful User-Defined Functions (UDFs)**
|
||||
|
||||
UDFs are custom functions built by the Flipside team that can be used in your queries to make your life easier.
|
||||
|
||||
Please visit [LiveQuery Functions Overview](https://flipsidecrypto.github.io/livequery-models/#!/overview) for a full list of helpful UDFs.
|
||||
|
||||
## **Data Model Overview**
|
||||
|
||||
The berachain models are built a few different ways, but the core fact tables are built using three layers of sql models: **bronze, silver, and gold (or core).**
|
||||
|
||||
- Bronze: Data is loaded in from the source as a view
|
||||
- Silver: All necessary parsing, filtering, de-duping, and other transformations are done here
|
||||
- Gold (or core): Final views and tables that are available publicly
|
||||
|
||||
The dimension tables are sourced from a variety of on-chain and off-chain sources.
|
||||
|
||||
Convenience views (denoted ez_) are a combination of different fact and dimension tables. These views are built to make it easier to query the data.
|
||||
|
||||
## **Using dbt docs**
|
||||
### Navigation
|
||||
|
||||
You can use the ```Project``` and ```Database``` navigation tabs on the left side of the window to explore the models in the project.
|
||||
|
||||
### Database Tab
|
||||
|
||||
This view shows relations (tables and views) grouped into database schemas. Note that ephemeral models are *not* shown in this interface, as they do not exist in the database.
|
||||
|
||||
### Graph Exploration
|
||||
|
||||
You can click the blue icon on the bottom-right corner of the page to view the lineage graph of your models.
|
||||
|
||||
On model pages, you'll see the immediate parents and children of the model you're exploring. By clicking the Expand button at the top-right of this lineage pane, you'll be able to see all of the models that are used to build, or are built from, the model you're exploring.
|
||||
|
||||
Once expanded, you'll be able to use the ```--models``` and ```--exclude``` model selection syntax to filter the models in the graph. For more information on model selection, check out the [dbt docs](https://docs.getdbt.com/docs/model-selection-syntax).
|
||||
|
||||
Note that you can also right-click on models to interactively filter and explore the graph.
|
||||
|
||||
|
||||
### **More information**
|
||||
- [Flipside](https://flipsidecrypto.xyz/)
|
||||
- [Velocity](https://app.flipsidecrypto.com/velocity?nav=Discover)
|
||||
- [Tutorials](https://docs.flipsidecrypto.com/our-data/tutorials)
|
||||
- [Github](https://github.com/FlipsideCrypto/berachain-models)
|
||||
- [What is dbt?](https://docs.getdbt.com/docs/introduction)
|
||||
|
||||
|
||||
{% enddocs %}
|
||||
@ -0,0 +1,5 @@
|
||||
{% docs berachain_block_number %}
|
||||
|
||||
Also known as block height. The block number, which indicates the length of the blockchain, increases after the addition of each new block.
|
||||
|
||||
{% enddocs %}
|
||||
@ -0,0 +1,5 @@
|
||||
{% docs berachain_block_timestamp %}
|
||||
|
||||
The date and time at which the block was produced.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/doc_descriptions/general/berachain_decimals.md
Normal file
5
models/doc_descriptions/general/berachain_decimals.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs berachain_decimals %}
|
||||
|
||||
The number of decimal places this contract needs adjusted where token values exist. For example, use the decimal field to correctly transform raw amounts in ```fact_token_transfers```.
|
||||
|
||||
{% enddocs %}
|
||||
@ -0,0 +1,5 @@
|
||||
{% docs berachain_from_address %}
|
||||
|
||||
The sending address of this transaction.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/doc_descriptions/general/berachain_ingested_at.md
Normal file
5
models/doc_descriptions/general/berachain_ingested_at.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs berachain_ingested_at %}
|
||||
|
||||
Internal column.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/doc_descriptions/general/berachain_symbol.md
Normal file
5
models/doc_descriptions/general/berachain_symbol.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs berachain_symbol %}
|
||||
|
||||
The symbol belonging to the address of the token
|
||||
|
||||
{% enddocs %}
|
||||
5
models/doc_descriptions/general/berachain_to_address.md
Normal file
5
models/doc_descriptions/general/berachain_to_address.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs berachain_to_address %}
|
||||
|
||||
The receiving address of this transaction. This can be a contract address.
|
||||
|
||||
{% enddocs %}
|
||||
11
models/doc_descriptions/general/deprecation.md
Normal file
11
models/doc_descriptions/general/deprecation.md
Normal file
@ -0,0 +1,11 @@
|
||||
{% docs internal_column %}
|
||||
|
||||
Deprecated. This column is no longer used. Please remove from your query by Jan. 31 2024.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs amount_deprecation %}
|
||||
|
||||
This column is being deprecated for standardization purposes on Jan. 31 2024. Please use the equivalent column without the native asset prefix. For example, use `amount` instead of `eth_amount`.
|
||||
|
||||
{% enddocs %}
|
||||
19
models/doc_descriptions/general/export_columns.md
Normal file
19
models/doc_descriptions/general/export_columns.md
Normal file
@ -0,0 +1,19 @@
|
||||
{% docs pk %}
|
||||
|
||||
The unique identifier for each row in the table.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs inserted_timestamp %}
|
||||
|
||||
The utc timestamp at which the row was inserted into the table.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs modified_timestamp %}
|
||||
|
||||
The utc timestamp at which the row was last modified.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
17
models/doc_descriptions/general/precise_amounts.md
Normal file
17
models/doc_descriptions/general/precise_amounts.md
Normal file
@ -0,0 +1,17 @@
|
||||
{% docs precise_amount_unadjusted %}
|
||||
|
||||
The precise, unadjusted amount of the transaction. This is returned as a string to avoid precision loss.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs precise_amount_adjusted %}
|
||||
|
||||
The precise, adjusted amount of the transaction. This is returned as a string to avoid precision loss.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs tx_fee_precise %}
|
||||
|
||||
The precise amount of the transaction fee. This is returned as a string to avoid precision loss.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/doc_descriptions/labels/berachain_label.md
Normal file
5
models/doc_descriptions/labels/berachain_label.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs berachain_project_name %}
|
||||
|
||||
The name of the project for this address.
|
||||
|
||||
{% enddocs %}
|
||||
@ -0,0 +1,5 @@
|
||||
{% docs berachain_label_address %}
|
||||
|
||||
Address that the label is for. This is the field that should be used to join other tables with labels.
|
||||
|
||||
{% enddocs %}
|
||||
@ -0,0 +1,5 @@
|
||||
{% docs berachain_label_address_name %}
|
||||
|
||||
The most granular label for this address.
|
||||
|
||||
{% enddocs %}
|
||||
@ -0,0 +1,5 @@
|
||||
{% docs berachain_label_blockchain %}
|
||||
|
||||
The name of the blockchain.
|
||||
|
||||
{% enddocs %}
|
||||
@ -0,0 +1,5 @@
|
||||
{% docs berachain_label_creator %}
|
||||
|
||||
The name of the creator of the label.
|
||||
|
||||
{% enddocs %}
|
||||
@ -0,0 +1,5 @@
|
||||
{% docs berachain_label_subtype %}
|
||||
|
||||
A sub-category nested within label type providing further detail.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/doc_descriptions/labels/berachain_label_type.md
Normal file
5
models/doc_descriptions/labels/berachain_label_type.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs berachain_label_type %}
|
||||
|
||||
A high-level category describing the addresses main function or ownership.
|
||||
|
||||
{% enddocs %}
|
||||
@ -0,0 +1,5 @@
|
||||
{% docs berachain_labels_table %}
|
||||
|
||||
This table contains labels for addresses on the Base Blockchain.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/doc_descriptions/labels/table_dim_labels.md
Normal file
5
models/doc_descriptions/labels/table_dim_labels.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs table_dim_labels %}
|
||||
|
||||
The labels table is a store of one-to-one address identifiers, or an address name. Labels are broken out into a "type" (such as cex, dex, dapp, games, etc.) and a "subtype" (ex: contract_deployer, hot_wallet, token_contract, etc.) in order to help classify each address name into similar groups. Our labels are sourced from many different places, but can primarily be grouped into two categories: automatic and manual. Automatic labels are continuously labeled based on certain criteria, such as a known contract deploying another contract, behavior based algorithms for finding deposit wallets, and consistent data pulls of custom protocol APIs. Manual labels are done periodically to find addresses that cannot be found programmatically such as finding new protocol addresses, centralized exchange hot wallets, or trending addresses. Labels can also be added by our community by using our add-a-label tool (https://science.flipsidecrypto.xyz/add-a-label/) or on-chain with near (https://near.social/lord1.near/widget/Form) and are reviewed by our labels team. A label can be removed by our labels team if it is found to be incorrect or no longer relevant; this generally will only happen for mislabeled deposit wallets.
|
||||
|
||||
{% enddocs %}
|
||||
95
models/gold/testnet__fact_blocks.sql
Normal file
95
models/gold/testnet__fact_blocks.sql
Normal file
@ -0,0 +1,95 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = "block_number",
|
||||
incremental_strategy = 'delete+insert',
|
||||
merge_exclude_columns = ["inserted_timestamp"],
|
||||
cluster_by = "block_timestamp::date",
|
||||
tags = ['non_realtime']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
A.block_number AS block_number,
|
||||
block_timestamp,
|
||||
'bartio' AS network,
|
||||
'berachain' AS blockchain,
|
||||
tx_count,
|
||||
difficulty,
|
||||
total_difficulty,
|
||||
extra_data,
|
||||
gas_limit,
|
||||
gas_used,
|
||||
HASH,
|
||||
parent_hash,
|
||||
receipts_root,
|
||||
sha3_uncles,
|
||||
SIZE,
|
||||
uncles AS uncle_blocks,
|
||||
OBJECT_CONSTRUCT(
|
||||
'baseFeePerGas',
|
||||
base_fee_per_gas,
|
||||
'difficulty',
|
||||
difficulty,
|
||||
'extraData',
|
||||
extra_data,
|
||||
'gasLimit',
|
||||
gas_limit,
|
||||
'gasUsed',
|
||||
gas_used,
|
||||
'hash',
|
||||
HASH,
|
||||
'logsBloom',
|
||||
logs_bloom,
|
||||
'miner',
|
||||
miner,
|
||||
'nonce',
|
||||
nonce,
|
||||
'number',
|
||||
NUMBER,
|
||||
'parentHash',
|
||||
parent_hash,
|
||||
'parentBeaconBlockRoot',
|
||||
parent_beacon_block_root,
|
||||
'receiptsRoot',
|
||||
receipts_root,
|
||||
'sha3Uncles',
|
||||
sha3_uncles,
|
||||
'size',
|
||||
SIZE,
|
||||
'stateRoot',
|
||||
state_root,
|
||||
'timestamp',
|
||||
block_timestamp,
|
||||
'totalDifficulty',
|
||||
total_difficulty,
|
||||
'transactionsRoot',
|
||||
transactions_root,
|
||||
'uncles',
|
||||
uncles,
|
||||
'withdrawals',
|
||||
withdrawals,
|
||||
'withdrawalsRoot',
|
||||
withdrawals_root
|
||||
) AS block_header_json,
|
||||
blocks_id AS fact_blocks_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
FROM
|
||||
{{ ref(
|
||||
'silver_testnet__blocks'
|
||||
) }} A
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
A.modified_timestamp > (
|
||||
SELECT
|
||||
MAX(
|
||||
modified_timestamp
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
|
||||
qualify(ROW_NUMBER() over (PARTITION BY A.block_number
|
||||
ORDER BY
|
||||
A.modified_timestamp DESC)) = 1
|
||||
46
models/gold/testnet__fact_blocks.yml
Normal file
46
models/gold/testnet__fact_blocks.yml
Normal file
@ -0,0 +1,46 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: testnet__fact_blocks
|
||||
description: '{{ doc("berachain_blocks_table_doc") }}'
|
||||
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
description: '{{ doc("berachain_block_number") }}'
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: '{{ doc("berachain_block_timestamp") }}'
|
||||
- name: NETWORK
|
||||
description: '{{ doc("berachain_network") }}'
|
||||
- name: BLOCKCHAIN
|
||||
description: '{{ doc("berachain_blockchain") }}'
|
||||
- name: TX_COUNT
|
||||
description: '{{ doc("berachain_tx_count") }}'
|
||||
- name: DIFFICULTY
|
||||
description: '{{ doc("berachain_difficulty") }}'
|
||||
- name: TOTAL_DIFFICULTY
|
||||
description: '{{ doc("berachain_total_difficulty") }}'
|
||||
- name: EXTRA_DATA
|
||||
description: '{{ doc("berachain_extra_data") }}'
|
||||
- name: GAS_LIMIT
|
||||
description: '{{ doc("berachain_gas_limit") }}'
|
||||
- name: GAS_USED
|
||||
description: '{{ doc("berachain_gas_used") }}'
|
||||
- name: HASH
|
||||
description: '{{ doc("berachain_blocks_hash") }}'
|
||||
- name: PARENT_HASH
|
||||
description: '{{ doc("berachain_parent_hash") }}'
|
||||
- name: RECEIPTS_ROOT
|
||||
description: '{{ doc("berachain_receipts_root") }}'
|
||||
- name: SHA3_UNCLES
|
||||
description: '{{ doc("berachain_sha3_uncles") }}'
|
||||
- name: SIZE
|
||||
description: '{{ doc("berachain_size") }}'
|
||||
- name: UNCLE_BLOCKS
|
||||
description: '{{ doc("berachain_uncle_blocks") }}'
|
||||
- name: BLOCK_HEADER_JSON
|
||||
description: '{{ doc("berachain_block_header_json") }}'
|
||||
- name: FACT_BLOCKS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
40
models/gold/testnet__fact_event_logs.sql
Normal file
40
models/gold/testnet__fact_event_logs.sql
Normal file
@ -0,0 +1,40 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = "block_number",
|
||||
cluster_by = "block_timestamp::date",
|
||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION",
|
||||
tags = ['non_realtime']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
event_index,
|
||||
contract_address,
|
||||
topics,
|
||||
DATA,
|
||||
event_removed,
|
||||
tx_status AS tx_succeeded,
|
||||
_log_id,
|
||||
logs_id AS fact_event_logs_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref(
|
||||
'silver_testnet__logs'
|
||||
) }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp) _INSERTED_TIMESTAMP
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
38
models/gold/testnet__fact_event_logs.yml
Normal file
38
models/gold/testnet__fact_event_logs.yml
Normal file
@ -0,0 +1,38 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: testnet__fact_event_logs
|
||||
description: '{{ doc("berachain_logs_table_doc") }}'
|
||||
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
description: '{{ doc("berachain_block_number") }}'
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: '{{ doc("berachain_block_timestamp") }}'
|
||||
- name: TX_HASH
|
||||
description: '{{ doc("berachain_logs_tx_hash") }}'
|
||||
- name: EVENT_INDEX
|
||||
description: '{{ doc("berachain_event_index") }}'
|
||||
- name: CONTRACT_ADDRESS
|
||||
description: '{{ doc("berachain_logs_contract_address") }}'
|
||||
- name: TOPICS
|
||||
description: '{{ doc("berachain_topics") }}'
|
||||
- name: DATA
|
||||
description: '{{ doc("berachain_logs_data") }}'
|
||||
- name: EVENT_REMOVED
|
||||
description: '{{ doc("berachain_event_removed") }}'
|
||||
- name: _LOG_ID
|
||||
description: '{{ doc("internal_column") }}'
|
||||
- name: TX_SUCCEEDED
|
||||
description: '{{ doc("berachain_tx_status") }}'
|
||||
- name: ORIGIN_FUNCTION_SIGNATURE
|
||||
description: '{{ doc("berachain_origin_sig") }}'
|
||||
- name: ORIGIN_FROM_ADDRESS
|
||||
description: '{{ doc("berachain_origin_from") }}'
|
||||
- name: ORIGIN_TO_ADDRESS
|
||||
description: '{{ doc("berachain_origin_to") }}'
|
||||
- name: FACT_EVENT_LOGS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
405
models/gold/testnet__fact_traces.sql
Normal file
405
models/gold/testnet__fact_traces.sql
Normal file
@ -0,0 +1,405 @@
|
||||
{{ config (
|
||||
materialized = "incremental",
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = ['block_number'],
|
||||
cluster_by = "block_timestamp::date",
|
||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION"
|
||||
) }}
|
||||
|
||||
WITH silver_traces AS (
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
tx_position,
|
||||
trace_address,
|
||||
parent_trace_address,
|
||||
trace_address_array,
|
||||
trace_json,
|
||||
traces_id,
|
||||
'standard' AS source
|
||||
FROM
|
||||
{{ ref('silver_testnet__traces') }}
|
||||
WHERE
|
||||
1 = 1
|
||||
|
||||
{% if is_incremental() and not var(
|
||||
'RELOAD_TRACES',
|
||||
) %}
|
||||
AND modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
) {% elif is_incremental() and var(
|
||||
'RELOAD_TRACES',
|
||||
) %}
|
||||
AND block_number BETWEEN (
|
||||
SELECT
|
||||
MAX(
|
||||
block_number
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND (
|
||||
SELECT
|
||||
MAX(
|
||||
block_number
|
||||
) + 1000000
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% else %}
|
||||
AND block_number <= 5000000
|
||||
{% endif %}
|
||||
),
|
||||
sub_traces AS (
|
||||
SELECT
|
||||
block_number,
|
||||
tx_position,
|
||||
parent_trace_address,
|
||||
COUNT(*) AS sub_traces
|
||||
FROM
|
||||
silver_traces
|
||||
GROUP BY
|
||||
block_number,
|
||||
tx_position,
|
||||
parent_trace_address
|
||||
),
|
||||
trace_index_array AS (
|
||||
SELECT
|
||||
block_number,
|
||||
tx_position,
|
||||
trace_address,
|
||||
ARRAY_AGG(flat_value) AS number_array
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
block_number,
|
||||
tx_position,
|
||||
trace_address,
|
||||
IFF(
|
||||
VALUE :: STRING = 'ORIGIN',
|
||||
-1,
|
||||
VALUE :: INT
|
||||
) AS flat_value
|
||||
FROM
|
||||
silver_traces,
|
||||
LATERAL FLATTEN (
|
||||
input => trace_address_array
|
||||
)
|
||||
)
|
||||
GROUP BY
|
||||
block_number,
|
||||
tx_position,
|
||||
trace_address
|
||||
),
|
||||
trace_index_sub_traces AS (
|
||||
SELECT
|
||||
b.block_number,
|
||||
b.tx_position,
|
||||
b.trace_address,
|
||||
IFNULL(
|
||||
sub_traces,
|
||||
0
|
||||
) AS sub_traces,
|
||||
number_array,
|
||||
ROW_NUMBER() over (
|
||||
PARTITION BY b.block_number,
|
||||
b.tx_position
|
||||
ORDER BY
|
||||
number_array ASC
|
||||
) - 1 AS trace_index,
|
||||
b.trace_json,
|
||||
b.traces_id
|
||||
FROM
|
||||
silver_traces b
|
||||
LEFT JOIN sub_traces s
|
||||
ON b.block_number = s.block_number
|
||||
AND b.tx_position = s.tx_position
|
||||
AND b.trace_address = s.parent_trace_address
|
||||
JOIN trace_index_array n
|
||||
ON b.block_number = n.block_number
|
||||
AND b.tx_position = n.tx_position
|
||||
AND b.trace_address = n.trace_address
|
||||
),
|
||||
error_logic AS (
|
||||
SELECT
|
||||
b0.block_number,
|
||||
b0.tx_position,
|
||||
b0.trace_address,
|
||||
b0.trace_json :error :: STRING AS error,
|
||||
b1.trace_json :error :: STRING AS any_error,
|
||||
b2.trace_json :error :: STRING AS origin_error
|
||||
FROM
|
||||
trace_index_sub_traces b0
|
||||
LEFT JOIN trace_index_sub_traces b1
|
||||
ON b0.block_number = b1.block_number
|
||||
AND b0.tx_position = b1.tx_position
|
||||
AND b0.trace_address LIKE CONCAT(
|
||||
b1.trace_address,
|
||||
'_%'
|
||||
)
|
||||
LEFT JOIN trace_index_sub_traces b2
|
||||
ON b0.block_number = b2.block_number
|
||||
AND b0.tx_position = b2.tx_position
|
||||
AND b2.trace_address = 'ORIGIN'
|
||||
AND b2.trace_json :error :: STRING IS NOT NULL
|
||||
),
|
||||
aggregated_errors AS (
|
||||
SELECT
|
||||
block_number,
|
||||
tx_position,
|
||||
trace_address,
|
||||
error,
|
||||
IFF(MAX(any_error) IS NULL
|
||||
AND error IS NULL
|
||||
AND origin_error IS NULL, TRUE, FALSE) AS trace_succeeded
|
||||
FROM
|
||||
error_logic
|
||||
GROUP BY
|
||||
block_number,
|
||||
tx_position,
|
||||
trace_address,
|
||||
error,
|
||||
origin_error),
|
||||
json_traces AS (
|
||||
SELECT
|
||||
block_number,
|
||||
tx_position,
|
||||
trace_address,
|
||||
sub_traces,
|
||||
number_array,
|
||||
trace_index,
|
||||
trace_json AS DATA,
|
||||
trace_succeeded,
|
||||
trace_json :error :: STRING AS error_reason,
|
||||
trace_json :from :: STRING AS from_address,
|
||||
trace_json :to :: STRING AS to_address,
|
||||
IFNULL(
|
||||
utils.udf_hex_to_int(
|
||||
trace_json :value :: STRING
|
||||
),
|
||||
'0'
|
||||
) AS value_precise_raw,
|
||||
utils.udf_decimal_adjust(
|
||||
value_precise_raw,
|
||||
18
|
||||
) AS value_precise,
|
||||
value_precise :: FLOAT AS VALUE,
|
||||
utils.udf_hex_to_int(
|
||||
trace_json :gas :: STRING
|
||||
) :: INT AS gas,
|
||||
utils.udf_hex_to_int(
|
||||
trace_json :gasUsed :: STRING
|
||||
) :: INT AS gas_used,
|
||||
trace_json :input :: STRING AS input,
|
||||
trace_json :output :: STRING AS output,
|
||||
trace_json :type :: STRING AS TYPE,
|
||||
concat_ws(
|
||||
'_',
|
||||
TYPE,
|
||||
trace_address
|
||||
) AS identifier,
|
||||
IFF(
|
||||
trace_succeeded,
|
||||
'SUCCESS',
|
||||
'FAIL'
|
||||
) AS trace_status,
|
||||
traces_id
|
||||
FROM
|
||||
trace_index_sub_traces
|
||||
JOIN aggregated_errors USING (
|
||||
block_number,
|
||||
tx_position,
|
||||
trace_address
|
||||
)
|
||||
),
|
||||
incremental_traces AS (
|
||||
SELECT
|
||||
f.block_number,
|
||||
t.tx_hash,
|
||||
t.block_timestamp,
|
||||
t.tx_status,
|
||||
f.tx_position,
|
||||
f.trace_index,
|
||||
f.from_address,
|
||||
f.to_address,
|
||||
f.value_precise_raw,
|
||||
f.value_precise,
|
||||
f.value,
|
||||
f.gas,
|
||||
f.gas_used,
|
||||
f.input,
|
||||
f.output,
|
||||
f.type,
|
||||
f.identifier,
|
||||
f.sub_traces,
|
||||
f.error_reason,
|
||||
f.trace_status,
|
||||
IFF(
|
||||
t.tx_hash IS NULL
|
||||
OR t.block_timestamp IS NULL
|
||||
OR t.tx_status IS NULL,
|
||||
TRUE,
|
||||
FALSE
|
||||
) AS _is_pending,
|
||||
f.data,
|
||||
traces_id,
|
||||
f.trace_succeeded
|
||||
FROM
|
||||
json_traces f
|
||||
LEFT OUTER JOIN {{ ref('silver_testnet__transactions') }}
|
||||
t
|
||||
ON f.tx_position = t.position
|
||||
AND f.block_number = t.block_number
|
||||
|
||||
{% if is_incremental() and not var(
|
||||
'RELOAD_TRACES',
|
||||
) %}
|
||||
AND t._INSERTED_TIMESTAMP >= (
|
||||
SELECT
|
||||
DATEADD('hour', -24, MAX(modified_timestamp))
|
||||
FROM
|
||||
{{ this }})
|
||||
{% endif %}
|
||||
)
|
||||
|
||||
{% if is_incremental() %},
|
||||
heal_missing_data AS (
|
||||
SELECT
|
||||
t.block_number,
|
||||
txs.tx_hash,
|
||||
txs.block_timestamp,
|
||||
txs.tx_status,
|
||||
t.tx_position,
|
||||
t.trace_index,
|
||||
t.from_address,
|
||||
t.to_address,
|
||||
t.value_precise_raw,
|
||||
t.value_precise,
|
||||
t.value,
|
||||
t.gas,
|
||||
t.gas_used,
|
||||
t.input,
|
||||
t.output,
|
||||
t.type,
|
||||
t.identifier,
|
||||
t.sub_traces,
|
||||
t.error_reason,
|
||||
t.trace_status,
|
||||
IFF(
|
||||
txs.tx_hash IS NULL
|
||||
OR txs.block_timestamp IS NULL
|
||||
OR txs.tx_status IS NULL,
|
||||
TRUE,
|
||||
FALSE
|
||||
) AS _is_pending,
|
||||
t.data,
|
||||
t.fact_traces_id AS traces_id,
|
||||
t.trace_succeeded
|
||||
FROM
|
||||
{{ this }}
|
||||
t
|
||||
INNER JOIN {{ ref('silver_testnet__transactions') }}
|
||||
txs
|
||||
ON t.tx_position = txs.position
|
||||
AND t.block_number = txs.block_number
|
||||
WHERE
|
||||
t._is_pending
|
||||
)
|
||||
{% endif %},
|
||||
all_traces AS (
|
||||
SELECT
|
||||
block_number,
|
||||
tx_hash,
|
||||
block_timestamp,
|
||||
tx_status,
|
||||
tx_position,
|
||||
trace_index,
|
||||
from_address,
|
||||
to_address,
|
||||
value_precise_raw,
|
||||
value_precise,
|
||||
VALUE,
|
||||
gas,
|
||||
gas_used,
|
||||
input,
|
||||
output,
|
||||
TYPE,
|
||||
identifier,
|
||||
sub_traces,
|
||||
error_reason,
|
||||
trace_status,
|
||||
DATA,
|
||||
_is_pending,
|
||||
traces_id,
|
||||
trace_succeeded
|
||||
FROM
|
||||
incremental_traces
|
||||
|
||||
{% if is_incremental() %}
|
||||
UNION ALL
|
||||
SELECT
|
||||
block_number,
|
||||
tx_hash,
|
||||
block_timestamp,
|
||||
tx_status,
|
||||
tx_position,
|
||||
trace_index,
|
||||
from_address,
|
||||
to_address,
|
||||
value_precise_raw,
|
||||
value_precise,
|
||||
VALUE,
|
||||
gas,
|
||||
gas_used,
|
||||
input,
|
||||
output,
|
||||
TYPE,
|
||||
identifier,
|
||||
sub_traces,
|
||||
error_reason,
|
||||
trace_status,
|
||||
DATA,
|
||||
_is_pending,
|
||||
traces_id,
|
||||
trace_succeeded
|
||||
FROM
|
||||
heal_missing_data
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
from_address,
|
||||
to_address,
|
||||
VALUE,
|
||||
value_precise_raw,
|
||||
value_precise,
|
||||
gas,
|
||||
gas_used,
|
||||
input,
|
||||
output,
|
||||
TYPE,
|
||||
identifier,
|
||||
DATA,
|
||||
tx_status,
|
||||
sub_traces,
|
||||
trace_status,
|
||||
error_reason,
|
||||
trace_index,
|
||||
tx_position,
|
||||
tx_status AS tx_succeeded,
|
||||
trace_succeeded,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['tx_hash', 'trace_index']
|
||||
) }} AS fact_traces_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
_is_pending
|
||||
FROM
|
||||
all_traces qualify(ROW_NUMBER() over(PARTITION BY block_number, tx_position, trace_index
|
||||
ORDER BY
|
||||
_is_pending ASC)) = 1
|
||||
56
models/gold/testnet__fact_traces.yml
Normal file
56
models/gold/testnet__fact_traces.yml
Normal file
@ -0,0 +1,56 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: testnet__fact_traces
|
||||
description: '{{ doc("berachain_traces_table_doc") }}'
|
||||
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
description: '{{ doc("berachain_traces_block_no") }}'
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: '{{ doc("berachain_traces_blocktime") }}'
|
||||
- name: TX_HASH
|
||||
description: '{{ doc("berachain_traces_tx_hash") }}'
|
||||
- name: FROM_ADDRESS
|
||||
description: '{{ doc("berachain_traces_from") }}'
|
||||
- name: TO_ADDRESS
|
||||
description: '{{ doc("berachain_traces_to") }}'
|
||||
- name: VALUE
|
||||
description: '{{ doc("berachain_traces_value") }}'
|
||||
- name: VALUE_PRECISE_RAW
|
||||
description: '{{ doc("precise_amount_unadjusted") }}'
|
||||
- name: VALUE_PRECISE
|
||||
description: '{{ doc("precise_amount_adjusted") }}'
|
||||
- name: GAS
|
||||
description: '{{ doc("berachain_traces_gas") }}'
|
||||
- name: GAS_USED
|
||||
description: '{{ doc("berachain_traces_gas_used") }}'
|
||||
- name: INPUT
|
||||
description: '{{ doc("berachain_traces_input") }}'
|
||||
- name: OUTPUT
|
||||
description: '{{ doc("berachain_traces_output") }}'
|
||||
- name: TYPE
|
||||
description: '{{ doc("berachain_traces_type") }}'
|
||||
- name: IDENTIFIER
|
||||
description: '{{ doc("berachain_traces_identifier") }}'
|
||||
- name: DATA
|
||||
description: '{{ doc("berachain_traces_call_data") }}'
|
||||
- name: TX_SUCCEEDED
|
||||
description: '{{ doc("berachain_tx_status") }}'
|
||||
- name: SUB_TRACES
|
||||
description: '{{ doc("berachain_traces_sub") }}'
|
||||
- name: TRACE_SUCCEEDED
|
||||
description: The status of the trace, where TRUE = SUCCESS and FALSE = FAILED.
|
||||
- name: ERROR_REASON
|
||||
description: The reason for the trace failure, if any.
|
||||
- name: TRACE_INDEX
|
||||
description: The index of the trace within the transaction.
|
||||
- name: FACT_TRACES_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
|
||||
|
||||
|
||||
|
||||
53
models/gold/testnet__fact_transactions.sql
Normal file
53
models/gold/testnet__fact_transactions.sql
Normal file
@ -0,0 +1,53 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = "block_number",
|
||||
incremental_strategy = 'delete+insert',
|
||||
cluster_by = "block_timestamp::date",
|
||||
tags = ['non_realtime']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
block_hash,
|
||||
tx_hash,
|
||||
nonce,
|
||||
POSITION,
|
||||
origin_function_signature,
|
||||
from_address,
|
||||
to_address,
|
||||
VALUE,
|
||||
value_precise_raw,
|
||||
value_precise,
|
||||
tx_fee,
|
||||
tx_fee_precise,
|
||||
gas_price,
|
||||
effective_gas_price,
|
||||
gas AS gas_limit,
|
||||
gas_used,
|
||||
cumulative_gas_used,
|
||||
max_fee_per_gas,
|
||||
max_priority_fee_per_gas,
|
||||
input_data,
|
||||
tx_status AS tx_succeeded,
|
||||
r,
|
||||
s,
|
||||
v,
|
||||
y_parity,
|
||||
transactions_id AS fact_transactions_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref(
|
||||
'silver_testnet__transactions'
|
||||
) }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
66
models/gold/testnet__fact_transactions.yml
Normal file
66
models/gold/testnet__fact_transactions.yml
Normal file
@ -0,0 +1,66 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: testnet__fact_transactions
|
||||
description: '{{ doc("berachain_tx_table_doc") }}'
|
||||
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
description: '{{ doc("berachain_block_number") }}'
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: '{{ doc("berachain_block_timestamp") }}'
|
||||
- name: BLOCK_HASH
|
||||
description: '{{ doc("berachain_tx_block_hash") }}'
|
||||
- name: TX_HASH
|
||||
description: '{{ doc("berachain_tx_hash") }}'
|
||||
- name: NONCE
|
||||
description: '{{ doc("berachain_tx_nonce") }}'
|
||||
- name: POSITION
|
||||
description: '{{ doc("berachain_tx_position") }}'
|
||||
- name: FROM_ADDRESS
|
||||
description: '{{ doc("berachain_from_address") }}'
|
||||
- name: TO_ADDRESS
|
||||
description: '{{ doc("berachain_to_address") }}'
|
||||
- name: VALUE
|
||||
description: '{{ doc("berachain_value") }}'
|
||||
- name: VALUE_PRECISE_RAW
|
||||
description: '{{ doc("precise_amount_unadjusted") }}'
|
||||
- name: VALUE_PRECISE
|
||||
description: '{{ doc("precise_amount_adjusted") }}'
|
||||
- name: TX_FEE
|
||||
description: '{{ doc("berachain_tx_fee") }}'
|
||||
- name: TX_FEE_PRECISE
|
||||
description: '{{ doc("tx_fee_precise") }}'
|
||||
- name: GAS_PRICE
|
||||
description: '{{ doc("berachain_tx_gas_price") }}'
|
||||
- name: EFFECTIVE_GAS_PRICE
|
||||
description: The total base charge plus tip paid for each unit of gas, in Gwei.
|
||||
- name: GAS_LIMIT
|
||||
description: '{{ doc("berachain_tx_gas_limit") }}'
|
||||
- name: GAS_USED
|
||||
description: '{{ doc("berachain_tx_gas_used") }}'
|
||||
- name: CUMULATIVE_GAS_USED
|
||||
description: '{{ doc("berachain_cumulative_gas_used") }}'
|
||||
- name: MAX_FEE_PER_GAS
|
||||
description: The maximum fee per gas of the transaction, in Gwei.
|
||||
- name: MAX_PRIORITY_FEE_PER_GAS
|
||||
description: The maximum priority fee per gas of the transaction, in Gwei.
|
||||
- name: SUCCEEDED
|
||||
description: '{{ doc("berachain_tx_status") }}'
|
||||
- name: INPUT_DATA
|
||||
description: '{{ doc("berachain_tx_input_data") }}'
|
||||
- name: ORIGIN_FUNCTION_SIGNATURE
|
||||
description: '{{ doc("berachain_tx_origin_sig") }}'
|
||||
- name: R
|
||||
description: The r value of the transaction signature.
|
||||
- name: S
|
||||
description: The s value of the transaction signature.
|
||||
- name: V
|
||||
description: The v value of the transaction signature.
|
||||
- name: Y_PARITY
|
||||
description: The parity of the y value of the transaction signature.
|
||||
- name: FACT_TRANSACTIONS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
@ -1,6 +1,6 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver_testnet__blocks_full
|
||||
- name: test_silver__blocks_full
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver_testnet__blocks_recent
|
||||
- name: test_silver__blocks_recent
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver_testnet__logs_full
|
||||
- name: test_silver__logs_full
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver_testnet__logs_recent
|
||||
- name: test_silver__logs_recent
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver_testnet__receipts_full
|
||||
- name: test_silver__receipts_full
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver_testnet__receipts_recent
|
||||
- name: test_silver__receipts_recent
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver_testnet__traces_full
|
||||
- name: test_silver__traces_full
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver_testnet__traces_recent
|
||||
- name: test_silver__traces_recent
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver_testnet__transactions_full
|
||||
- name: test_silver__transactions_full
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver_testnet__transactions_recent
|
||||
- name: test_silver__transactions_recent
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user