Skip to content

Commit

Permalink
Populate data_availability field in traces from receipts
Browse files Browse the repository at this point in the history
  • Loading branch information
kirugan committed Oct 17, 2024
1 parent 99e16d8 commit 32055cb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion rpc/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,27 @@ func (h *Handler) traceBlockTransactions(ctx context.Context, block *core.Block,
}

if !v0_6Response {
txDataAvailability := make(map[felt.Felt]vm.DataAvailability, len(block.Receipts))
for _, receipt := range block.Receipts {
if receipt.ExecutionResources == nil {
continue
}
if receiptDA := receipt.ExecutionResources.DataAvailability; receiptDA != nil {
da := vm.DataAvailability{
L1Gas: receiptDA.L1Gas,
L1DataGas: receiptDA.L1DataGas,
}
txDataAvailability[*receipt.TransactionHash] = da
}
}

// add execution resources on root level
for index, trace := range result {
executionResources := trace.TraceRoot.TotalExecutionResources()
// fgw doesn't provide this data in traces endpoint
executionResources.DataAvailability = &vm.DataAvailability{}
// some receipts don't have data availability data in this case we don't
da := txDataAvailability[*trace.TransactionHash]
executionResources.DataAvailability = &da
result[index].TraceRoot.ExecutionResources = executionResources
}
}
Expand Down

0 comments on commit 32055cb

Please sign in to comment.