Macros: Core Tables: Traces - FlipsideCrypto/fsc-evm GitHub Wiki

The following macros are intended to be used to create and maintain the silver and gold traces models. These macros can be accessed via version >=v1.9.0 of the fsc-evm package. Please see the fsc-evm installation instructions in the README for more details on how to access and utilize this macro effectively.


silver_traces

Usage

This macro is used to build the silver.traces table. silver.traces is a trace-level, de-duped table containing all traces. The main logic of this model is the recursive flatten to build the trace_json at the trace-level. Special parameters exist for Arbitrum and SEI, as well as for reloading the model from scratch.

This will likely have a few versions as we add and remove columns. The existing structure for most EVM models in silver.traces is very different than this set up. It will take time to complete this migration. You may see these macros referenced in tables with a 2 suffix for the time being.

Parameters

Note: Parameters with default values must be ordered after non-default parameters.

Parameter Type Default Description
full_reload_start_block Integer - Sets max block for the initial load of the table.
full_reload_blocks Integer - Number of blocks per incremental the model will load. For most L1s, 1 million is appropriate. For L2s, or chains with quicker block times, 1 million may not be sufficient.
full_reload_mode Boolean false Controls the incremental logic for the model. Set to true when rebuilding the whole table.
arb_traces_model Boolean false Adds the beforeEVMTranfers and afterEVMTransfers columns for Arbitrum One. Set to true only for Arbitrum One.
use_partition_key Boolean false Flag to determine whether to use partition_key or _partition_by_block_id. This should be set to true for all 2.0 and newer projects.
source_schema String bronze This column allows you to use schemas other than bronze for your traces model, e.g. bronze_dexalot
sei_traces_mode Boolean false When set to true, this will pull through tx_hash in place of tx_position. This is needed for SEI EVM since the IBC txs do count towards position in the same block. The array index is not the same as the tx_position on SEI EVM, but it is on all other EVM chains.
tx_status_bool Boolean false When set to true, this will pull through tx_status directly as a Boolean, instead of applying logic to create it. This will not be needed in future versions.
kaia_traces_mode Boolean false When set to true, this will include logic to correctly flatten Kaia reverts into the JSON column.

Example

{{ fsc_evm.silver_traces_v1(
      full_reload_start_block = 2300000,
      full_reload_blocks = 1000000,
      full_reload_mode = false,
      arb_traces_mode = false,
      use_partition_key = true
) }}

Versions

Version Upgrades / Changes Status
silver_traces_v1 - Original version Latest Version
silver_traces_v2 - [Placeholder for future upgrades] Planned

gold_traces

Usage

This macro is used to build the core.fact_traces table. core.fact_traces is the gold level traces table for users. This macro pulls out each JSON field, joins in columns from core.fact_transactions, handles the error logic for trace_succeeded and adds in other helpful columns such as trace_index and sub_traces. Special parameters exist for Arbitrum and SEI, as well as for reloading the model from scratch.

This will likely have a few versions as we add and remove columns. The existing structure for most EVM models in core.fact_traces is just a view, compared to this which builds a table. It will take time to complete this migration. You may see these macros referenced in tables with a _v2 suffix for the time being.

Parameters

Note: Parameters with default values must be ordered after non-default parameters.

Parameter Type Default Description
full_reload_start_block Integer - Sets max block for the initial load of the table.
full_reload_blocks Integer - Number of blocks per incremental the model will load. For most L1s, 1 million is appropriate. For L2s, or chains with quicker block times, 1 million may not be sufficient.
full_reload_mode Boolean false Controls the incremental logic for the model. Set to true when rebuilding the whole table.
uses_overflow_steps Boolean false Adds additional logic to handle large blocks of traces (and/or receipts). For more info, see the Overflow Process Wiki.
arb_traces_model Boolean false Adds the beforeEVMTranfers and afterEVMTransfers columns for Arbitrum One. Set to true only for Arbitrum One.
source_schema String silver This column allows you to use schemas other than silver for your traces model, e.g. silver_dexalot
sei_traces_mode Boolean false When set to true, this will use tx_hash in place of tx_position for the relevant joins and groupings. This is needed for SEI EVM since the IBC txs do count towards position in the same block. The array index is not the same as the tx_position on SEI EVM, but it is on all other EVM chains.
uses_tx_status Bool false This column allows you to use the tx_status column from transactions to generate the tx_succeeded column. We should move away from this ASAP.

NOTE: This is only available in _v2
kaia_traces_mode Boolean false When set to true, this will include logic to correctly pull through the revert reason for Kaia.

Example

{{ fsc_evm.gold_traces_v2(
    full_reload_start_block = 5000000,
    full_reload_blocks = 1000000,
    full_reload_mode = true,
    uses_overflow_steps = true,
    arb_traces_mode = false
) }}

Versions

Version Upgrades / Changes Status
gold_traces_v1 - Original version
- Includes soon-to-be deprecated columns (e.g., trace_status, tx_status, identifier)
- Uses silver.traces2 as the source
Legacy
gold_traces_v2 - Removed soon-to-be deprecated columns
- Uses updated source table
- Uses silver.traces as the source.
- Includes uses_tx_status parameter.
Latest Version
gold_traces_v3 - [Placeholder for future upgrades] Planned

Note: gold_traces_v2 is the recommended version for new builds and is the target version for existing builds.

⚠️ **GitHub.com Fallback** ⚠️