ethereum-etl icon indicating copy to clipboard operation
ethereum-etl copied to clipboard

Is there a way to export failed transaction before Byzantium?

Open ksiau opened this issue 3 years ago • 8 comments

After Byzantium, the receipt_status in Table traces can be used to tell if this transaction is successful or failed. Is there a way to differenciate a failed transaction before Byzantium in BigQuery tables? If not, is there a way to export failed transaction before Byzantium?

ksiau avatar Jul 10 '21 08:07 ksiau

receipt_status column is in table transactions. You can join it with table traces which has column status to know the status of pre-byzantine transaction

medvedev1088 avatar Jul 10 '21 09:07 medvedev1088

receipt_status column is in table transactions. You can join it with table traces which has column status to know the status of pre-byzantine transaction

I made it wrong. receipt_status is a column in Table transactions, but receipt_status is null for transactions before Byzantium. How do I differenciate a failed transaction before Byzantium in BigQuery tables?

ksiau avatar Jul 10 '21 11:07 ksiau

You can join transactions with traces on transaction_hash where traces.trade_address is null, then traces.status will tell you if a transaction failed or succeeded

medvedev1088 avatar Jul 10 '21 12:07 medvedev1088

Something like this:

select transaction_hash, status
from bigquery-public-data.crypto_ethereum.transactions 
    join bigquery-public-data.crypto_ethereum.traces on transactions.hash = traces.transaction_hash
where traces.trace_address is null

medvedev1088 avatar Jul 10 '21 12:07 medvedev1088

Something like this:

select transaction_hash, status
from bigquery-public-data.crypto_ethereum.transactions 
    join bigquery-public-data.crypto_ethereum.traces on transactions.hash = traces.transaction_hash
where traces.trace_address is null

That way is not correct. traces.trace_address is null cannot be used to differentiate failed transactions. I tried the following:

select 
    b.block_timestamp,
    transaction_hash, 
    status
from 
    (
        select
            block_timestamp, 
            `hash`
        from 
            bigquery-public-data.crypto_ethereum.transactions 
        where true
            and date(block_timestamp) = '2020-02-01'
    ) a
    join 
    (
        select
            block_timestamp,
            transaction_hash,
            status 
        from
            bigquery-public-data.crypto_ethereum.traces 
        where true
            and date(block_timestamp) = '2020-02-01'
            and trace_address is null
    ) b
on a.hash = b.transaction_hash

ksiau avatar Jul 10 '21 13:07 ksiau

Sorry I wasn't clear. traces.trace_address is null is not supposed to differentiate failed transactions, it filters out only top-level traces within a transaction. If you need to filter out only failed transactions add and traces.status = 0

medvedev1088 avatar Jul 10 '21 13:07 medvedev1088

Sorry I wasn't clear. traces.trace_address is null is not supposed to differentiate failed transactions, it filters out only top-level traces within a transaction. If you need to filter out only failed transactions add and traces.status = 0

Thank you. I tried and did some tests. Your method works.

ksiau avatar Jul 13 '21 09:07 ksiau

By the way, I have added a way in this repo to export raw EVM opcode trace using the RPC API debug_traceTransaction. Do you think it is needed? If so, I can send a pull request to you guys.

ksiau avatar Jul 13 '21 09:07 ksiau