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

Consolidate trace data for Sunny Awards projects #2182

Open
ccerv1 opened this issue Sep 21, 2024 · 1 comment
Open

Consolidate trace data for Sunny Awards projects #2182

ccerv1 opened this issue Sep 21, 2024 · 1 comment
Assignees
Labels
c:data Gathering data (e.g. indexing)

Comments

@ccerv1
Copy link
Member

ccerv1 commented Sep 21, 2024

What is it?

Many of the Sunny Awards projects have trace event data that we need to derive metrics. We need to union the relevant trace data from all supported chains and filter on the to/from events that include Sunny project contracts.

@ccerv1 ccerv1 self-assigned this Sep 21, 2024
@ccerv1 ccerv1 added the c:data Gathering data (e.g. indexing) label Sep 21, 2024
@ccerv1
Copy link
Member Author

ccerv1 commented Sep 21, 2024

First, we create a snapshot of relevant project contracts. We'll use a Google Sheet just to keep this simple to update.

Then, we prepare a filter for relevant traces from the 180 day time window we care about. That's effectively this query:

with txns as (
    select
      transaction_hash, to_address,from_address,block_timestamp, 'Base' as chain
    from `opensource-observer.superchain.base_traces`
    where
      block_timestamp between '2024-03-01' and '2024-09-01'
      and status = 1
      and call_type = 'call'
    union all
    select
      transaction_hash, to_address,from_address,block_timestamp, 'Optimism' as chain
    from `opensource-observer.superchain.optimism_traces`
    where
      block_timestamp between '2024-03-01' and '2024-09-01'
      and status = 1
      and call_type = 'call'
    union all
    select
      transaction_hash, to_address,from_address,block_timestamp, 'Zora' as chain
    from `opensource-observer.superchain.zora_traces`
    where
      block_timestamp between '2024-03-01' and '2024-09-01'
      and status = 1  
      and call_type = 'call'
    union all
    select
      transaction_hash, to_address,from_address,block_timestamp, 'Mode' as chain
    from `opensource-observer.superchain.mode_traces`
    where
      block_timestamp between '2024-03-01' and '2024-09-01'
      and status = 1
      and call_type = 'call'
    union all
    select
      transaction_hash, to_address,from_address,block_timestamp, 'Frax' as chain
    from `opensource-observer.superchain.frax_traces`
    where
      block_timestamp between '2024-03-01' and '2024-09-01'
      and status = 1
      and call_type = 'call'
    union all
    select
      transaction_hash, to_address,from_address,block_timestamp, 'Metal' as chain
    from `opensource-observer.superchain.metal_traces`
    where
      block_timestamp between '2024-03-01' and '2024-09-01'
      and status = 1  
)

select *
from txns

Unfortunately, this is a huge query so we need to store it temporarily in a new table.

Now, we apply the project filter to get a much smaller (50GB) table of just the traces we care about:

select * 
from `static_data_sources.sunny_traces` traces
join `static_data_sources.sunny_project_apps` projects
  on 
    traces.chain = projects.chain
    and (traces.to_address = projects.address or traces.from_address = projects.address)

Finally, we derive a high level set of events that we can use for further metrics analysis.

select
  projects.uuid,
  case when traces.block_timestamp < '2024-06-01' then '180D' else '90D' end as time_window,
  case when traces.to_address = projects.address then 'to_event' else 'from_event' end as event_type,
  traces.chain,
  traces.to_address,
  traces.from_address,
  count(distinct transaction_hash) as txns
from `static_data_sources.sunny_project_traces` traces
join `static_data_sources.sunny_project_apps` projects
  on 
    traces.chain = projects.chain
    and (traces.to_address = projects.address or traces.from_address = projects.address)    
group by 1,2,3,4,5,6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c:data Gathering data (e.g. indexing)
Projects
Status: Backlog
Development

No branches or pull requests

1 participant