Query editor
with computebudget_a as (selectt.id,CASEWHEN BYTEARRAY_SUBSTRING(from_base58(ixs.data), 1, 1) = 0x02THEN bytearray_to_bigint(bytearray_reverse(bytearray_substring(from_base58(ixs.data), 2, 4)))ELSE -1END as requestedUnitsfromsolana.transactions AS tLEFT JOIN UNNEST (instructions) AS ixs ON TRUEwhereblock_slot = {{block_slot}}and ixs.executing_account = 'ComputeBudget111111111111111111111111111111'), computebudget as (select id,requestedUnits,ROW_NUMBER() OVER(PARTITION BY id ORDER BY requestedUnits DESC) as "rn"from computebudget_a), outerixs_a as (selectt.id,SPLIT(logs1.log, ' ')[2] as outer_program_id,CARDINALITY(log_messages) as final_log_index,logs1.nr as "rn"fromsolana.transactions AS t,UNNEST (log_messages) WITH ORDINALITY logs1(log, nr)whereblock_slot = {{block_slot}}and logs1.log LIKE 'Program % invoke [1]'), outerixs as (select a.id, a.outer_program_id, a.rn as "index", COALESCE(MIN(b.rn), a.final_log_index) as "nextIndex"from outerixs_a aleft join outerixs_a b on a.id = b.id and a.rn < b.rngroup by a.id, a.outer_program_id, a.rn, a.final_log_index), consumedunits_a as (selectt.id,SPLIT(logs2.log, ' ')[2] as program_id,TRY_CAST(SPLIT(logs2.log, ' ') [4] AS BIGINT) AS computed_units_spent,TRY_CAST(SPLIT(logs2.log, ' ') [6] AS BIGINT) AS computed_units_allocated,logs2.nr as "rn"fromsolana.transactions AS t,UNNEST (t.log_messages) WITH ORDINALITY logs2(log, nr)whereblock_slot = {{block_slot}}and logs2.log LIKE 'Program % consumed % of % compute units'), consumedunits_b as (selecta.id,o.outer_program_id,COALESCE(a.computed_units_spent, 150) as compute_units_spentfrom outerixs oleft join consumedunits_a a on a.id = o.id and o.index < a.rn and a.rn < o.nextIndex and o.outer_program_id = a.program_id), consumedunits as (selectid,SUM(compute_units_spent) as compute_units_spentfrom consumedunits_b