Skip to content

Commit

Permalink
Add missing execution resources to fetched traces (#2222)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirugan authored Oct 17, 2024
1 parent f4d9d69 commit 7faba7c
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 7 deletions.
24 changes: 20 additions & 4 deletions clients/feeder/testdata/integration/block/0.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@
"ecdsa_builtin": 0,
"ec_op_builtin": 0
},
"n_memory_holes": 0
"n_memory_holes": 0,
"data_availability": {
"l1_gas": 1,
"l1_data_gas": 2
}
},
"actual_fee": "0x0"
},
Expand All @@ -99,7 +103,11 @@
"ecdsa_builtin": 0,
"ec_op_builtin": 0
},
"n_memory_holes": 0
"n_memory_holes": 0,
"data_availability": {
"l1_gas": 2,
"l1_data_gas": 3
}
},
"actual_fee": "0x0"
},
Expand All @@ -119,7 +127,11 @@
"ecdsa_builtin": 0,
"ec_op_builtin": 0
},
"n_memory_holes": 22
"n_memory_holes": 22,
"data_availability": {
"l1_gas": 3,
"l1_data_gas": 4
}
},
"actual_fee": "0x0"
},
Expand All @@ -139,7 +151,11 @@
"ecdsa_builtin": 0,
"ec_op_builtin": 0
},
"n_memory_holes": 22
"n_memory_holes": 22,
"data_availability": {
"l1_gas": 4,
"l1_data_gas": 5
}
},
"actual_fee": "0x0"
}
Expand Down
112 changes: 111 additions & 1 deletion clients/feeder/testdata/integration/block/300000.json
Original file line number Diff line number Diff line change
@@ -1 +1,111 @@
{"block_hash": "0xe3828bd9154ab385e2cbb95b3b650365fb3c6a4321660d98ce8b0a9194f9a3", "parent_block_hash": "0x3e313bf24e413beadee1bf88590debeffdd7d24c979a7fbf790a3a5c4d9e88f", "block_number": 300000, "state_root": "0x293feec0a25b7134299ded77f1a701ce7da3191d419ef88dc6b9b1c4f9b2f68", "status": "ACCEPTED_ON_L1", "gas_price": "0x277a02decd", "transactions": [{"transaction_hash": "0x2a648ab1aa6847eb38507fc842e050f256562bf87b26083c332f3f21318c2c3", "version": "0x1", "max_fee": "0x2386f26fc10000", "signature": ["0x3e71a0a29877eae7a045b8d5153ca26770e104b1ac7712dc6fdd0f005ab1d37", "0x5e7446beab40bb53324d05be3d8f130a86890895221d00bd8cd2e3839d0593a"], "nonce": "0x39bd", "sender_address": "0x58b7ee817bd2978c7657d05d3131e83e301ed1aa79d5ad16f01925fd52d1da7", "calldata": ["0x1", "0x332299dc083f3778122e5b7762bc9d399da18fefe93769aee67bb49f51c8d2", "0x2d7cf5d5a324a320f9f37804b1615a533fde487400b41af80f13f7ac5581325", "0x0", "0x4", "0x4", "0xaf35ee8ed700ff132c5d1d298a73becda25ccdf9", "0x2", "0x6cd852fe1b2bbd8587bb0aaeb09813436c57c8ce21e75651e317273a1f22228", "0x58feb991988e53fffcba71f6df23c803fb062f1b3bab126d2c9ce574255b36e"], "type": "INVOKE_FUNCTION"}, {"transaction_hash": "0xbc984e8e1fe594dd518a3a51db4f338437a5d2fbdda772d4426b532a67ffff", "version": "0x1", "max_fee": "0x2386f26fc10000", "signature": ["0x36faaf651e7e4a783dacd362bc4853f2906f8ff23f1b8b52ed4b3b3cd51c09f", "0x59b8b785b9b494aa6d6d30a3535e4a649c305643fe6e4c5d3aacefbbae00004"], "nonce": "0x39be", "sender_address": "0x58b7ee817bd2978c7657d05d3131e83e301ed1aa79d5ad16f01925fd52d1da7", "calldata": ["0x1", "0x5f9211b05c9609d54a8bf5f9cfa4e2cd5a3cab3b5d79682c585575495a15dd1", "0x317eb442b72a9fae758d4fb26830ed0d9f31c8e7da4dbff4e8c59ea6a158e7f", "0x0", "0x4", "0x4", "0x447379c077035ef4f442411d0407ce9aa66c558f0060137f6455f4f230eabeb", "0x2", "0x6811b7755a7dd0ec1fb6f51a883e3f255368e2dfd497b5f6480c00cf9cd5a2e", "0x23b9e26720dd7aaf98c7cea56499f48f75dc1d4123f7e2d6c23bfc4d5f4a336"], "type": "INVOKE_FUNCTION"}], "timestamp": 1688044916, "sequencer_address": "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8", "transaction_receipts": [{"execution_status": "SUCCEEDED", "transaction_index": 0, "transaction_hash": "0x2a648ab1aa6847eb38507fc842e050f256562bf87b26083c332f3f21318c2c3", "l2_to_l1_messages": [{"from_address": "0x332299dc083f3778122e5b7762bc9d399da18fefe93769aee67bb49f51c8d2", "to_address": "0xAf35eE8eD700ff132C5d1d298A73BECdA25ccDF9", "payload": ["0x6cd852fe1b2bbd8587bb0aaeb09813436c57c8ce21e75651e317273a1f22228", "0x58feb991988e53fffcba71f6df23c803fb062f1b3bab126d2c9ce574255b36e"]}], "events": [], "execution_resources": {"n_steps": 374, "builtin_instance_counter": {"range_check_builtin": 7}, "n_memory_holes": 4}, "actual_fee": "0x127089df3a1984"}, {"execution_status": "SUCCEEDED", "transaction_index": 1, "transaction_hash": "0xbc984e8e1fe594dd518a3a51db4f338437a5d2fbdda772d4426b532a67ffff", "l2_to_l1_messages": [], "events": [], "execution_resources": {"n_steps": 307, "builtin_instance_counter": {"range_check_builtin": 9, "pedersen_builtin": 2}, "n_memory_holes": 25}, "actual_fee": "0x3b2d25cd7bccc"}], "starknet_version": "0.12.0"}
{
"block_hash": "0xe3828bd9154ab385e2cbb95b3b650365fb3c6a4321660d98ce8b0a9194f9a3",
"parent_block_hash": "0x3e313bf24e413beadee1bf88590debeffdd7d24c979a7fbf790a3a5c4d9e88f",
"block_number": 300000,
"state_root": "0x293feec0a25b7134299ded77f1a701ce7da3191d419ef88dc6b9b1c4f9b2f68",
"status": "ACCEPTED_ON_L1",
"gas_price": "0x277a02decd",
"transactions": [
{
"transaction_hash": "0x2a648ab1aa6847eb38507fc842e050f256562bf87b26083c332f3f21318c2c3",
"version": "0x1",
"max_fee": "0x2386f26fc10000",
"signature": [
"0x3e71a0a29877eae7a045b8d5153ca26770e104b1ac7712dc6fdd0f005ab1d37",
"0x5e7446beab40bb53324d05be3d8f130a86890895221d00bd8cd2e3839d0593a"
],
"nonce": "0x39bd",
"sender_address": "0x58b7ee817bd2978c7657d05d3131e83e301ed1aa79d5ad16f01925fd52d1da7",
"calldata": [
"0x1",
"0x332299dc083f3778122e5b7762bc9d399da18fefe93769aee67bb49f51c8d2",
"0x2d7cf5d5a324a320f9f37804b1615a533fde487400b41af80f13f7ac5581325",
"0x0",
"0x4",
"0x4",
"0xaf35ee8ed700ff132c5d1d298a73becda25ccdf9",
"0x2",
"0x6cd852fe1b2bbd8587bb0aaeb09813436c57c8ce21e75651e317273a1f22228",
"0x58feb991988e53fffcba71f6df23c803fb062f1b3bab126d2c9ce574255b36e"
],
"type": "INVOKE_FUNCTION"
},
{
"transaction_hash": "0xbc984e8e1fe594dd518a3a51db4f338437a5d2fbdda772d4426b532a67ffff",
"version": "0x1",
"max_fee": "0x2386f26fc10000",
"signature": [
"0x36faaf651e7e4a783dacd362bc4853f2906f8ff23f1b8b52ed4b3b3cd51c09f",
"0x59b8b785b9b494aa6d6d30a3535e4a649c305643fe6e4c5d3aacefbbae00004"
],
"nonce": "0x39be",
"sender_address": "0x58b7ee817bd2978c7657d05d3131e83e301ed1aa79d5ad16f01925fd52d1da7",
"calldata": [
"0x1",
"0x5f9211b05c9609d54a8bf5f9cfa4e2cd5a3cab3b5d79682c585575495a15dd1",
"0x317eb442b72a9fae758d4fb26830ed0d9f31c8e7da4dbff4e8c59ea6a158e7f",
"0x0",
"0x4",
"0x4",
"0x447379c077035ef4f442411d0407ce9aa66c558f0060137f6455f4f230eabeb",
"0x2",
"0x6811b7755a7dd0ec1fb6f51a883e3f255368e2dfd497b5f6480c00cf9cd5a2e",
"0x23b9e26720dd7aaf98c7cea56499f48f75dc1d4123f7e2d6c23bfc4d5f4a336"
],
"type": "INVOKE_FUNCTION"
}
],
"timestamp": 1688044916,
"sequencer_address": "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8",
"transaction_receipts": [
{
"execution_status": "SUCCEEDED",
"transaction_index": 0,
"transaction_hash": "0x2a648ab1aa6847eb38507fc842e050f256562bf87b26083c332f3f21318c2c3",
"l2_to_l1_messages": [
{
"from_address": "0x332299dc083f3778122e5b7762bc9d399da18fefe93769aee67bb49f51c8d2",
"to_address": "0xAf35eE8eD700ff132C5d1d298A73BECdA25ccDF9",
"payload": [
"0x6cd852fe1b2bbd8587bb0aaeb09813436c57c8ce21e75651e317273a1f22228",
"0x58feb991988e53fffcba71f6df23c803fb062f1b3bab126d2c9ce574255b36e"
]
}
],
"events": [],
"execution_resources": {
"n_steps": 374,
"builtin_instance_counter": {
"range_check_builtin": 7
},
"n_memory_holes": 4,
"data_availability": {
"l1_gas": 1,
"l1_data_gas": 2
}
},
"actual_fee": "0x127089df3a1984"
},
{
"execution_status": "SUCCEEDED",
"transaction_index": 1,
"transaction_hash": "0xbc984e8e1fe594dd518a3a51db4f338437a5d2fbdda772d4426b532a67ffff",
"l2_to_l1_messages": [],
"events": [],
"execution_resources": {
"n_steps": 307,
"builtin_instance_counter": {
"range_check_builtin": 9,
"pedersen_builtin": 2
},
"n_memory_holes": 25,
"data_availability": {
"l1_gas": 2,
"l1_data_gas": 3
}
},
"actual_fee": "0x3b2d25cd7bccc"
}
],
"starknet_version": "0.12.0"
}
30 changes: 30 additions & 0 deletions rpc/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,36 @@ func (h *Handler) traceBlockTransactions(ctx context.Context, block *core.Block,
} else if blockVer.LessThanEqual(traceFallbackVersion) && block.ProtocolVersion != excludedVersion {
// version <= 0.13.1 and not 0.13.1.1 fetch blocks from feeder gateway
result, err := h.fetchTraces(ctx, block.Hash)
if err != nil {
return nil, httpHeader, err
}

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
// 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
}
}

return result, httpHeader, err
}

Expand Down
Loading

0 comments on commit 7faba7c

Please sign in to comment.