Add trace addresses to Geth tracer output

Andrew explained that the trace address from Parity is the index of each
nested call.  I can compute that as I flatten the tree into a sequence.
pull/1072/head
Luke Imhoff 6 years ago
parent e4b7a4ee5f
commit 60b02b4604
  1. 68
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/call.ex
  2. 78
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/calls.ex
  3. 20
      apps/ethereum_jsonrpc/priv/js/ethereum_jsonrpc/geth/debug_traceTransaction/tracer.js

@ -14,6 +14,7 @@ defmodule EthereumJSONRPC.Geth.Call do
...> "transactionIndex" => 13,
...> "transactionHash" => "0x32b17f27ddb546eab3c4c33f31eb22c1cb992d4ccc50dae26922805b717efe5c",
...> "index" => 0,
...> "traceAddress" => [],
...> "type" => "call",
...> "callType" => "call",
...> "from" => "0xa931c862e662134b85e4dc4baf5c70cc9ba74db4",
@ -30,6 +31,7 @@ defmodule EthereumJSONRPC.Geth.Call do
transaction_index: 13,
transaction_hash: "0x32b17f27ddb546eab3c4c33f31eb22c1cb992d4ccc50dae26922805b717efe5c",
index: 0,
trace_address: [],
type: "call",
call_type: "call",
from_address_hash: "0xa931c862e662134b85e4dc4baf5c70cc9ba74db4",
@ -38,7 +40,6 @@ defmodule EthereumJSONRPC.Geth.Call do
gas_used: 32055,
input: "0xb118e2db0000000000000000000000000000000000000000000000000000000000000008",
output: "0x",
trace_address: [],
value: 100000000000
}
@ -47,17 +48,18 @@ defmodule EthereumJSONRPC.Geth.Call do
iex> EthereumJSONRPC.Geth.Call.to_internal_transaction_params(
...> %{
...> "blockNumber" => 3293221,
...> "transactionIndex" => 16,
...> "transactionHash" => "0xa9a893fe2f019831496cec9777ad25ff940823b9b47a3969299ea139e42b2073",
...> "index" => 0,
...> "traceAddress" => [],
...> "type" => "call",
...> "callType" => "call",
...> "error" => "out of gas",
...> "from" => "0x8ec75ef3adf6c953775d0738e0e7bd60e647e5ef",
...> "to" => "0xaae465ad04b12e90c32291e59b65ca781c57e361",
...> "input" => "0xa83627de",
...> "error" => "out of gas",
...> "gas" => "0x4c9",
...> "gasUsed" => "0x4c9",
...> "index" => 0,
...> "input" => "0xa83627de",
...> "to" => "0xaae465ad04b12e90c32291e59b65ca781c57e361",
...> "transactionHash" => "0xa9a893fe2f019831496cec9777ad25ff940823b9b47a3969299ea139e42b2073",
...> "transactionIndex" => 16,
...> "type" => "call",
...> "value" => "0x0"
...> }
...> )
@ -66,6 +68,7 @@ defmodule EthereumJSONRPC.Geth.Call do
transaction_index: 16,
transaction_hash: "0xa9a893fe2f019831496cec9777ad25ff940823b9b47a3969299ea139e42b2073",
index: 0,
trace_address: [],
type: "call",
call_type: "call",
error: "out of gas",
@ -73,7 +76,6 @@ defmodule EthereumJSONRPC.Geth.Call do
to_address_hash: "0xaae465ad04b12e90c32291e59b65ca781c57e361",
gas: 1225,
input: "0xa83627de",
trace_address: [],
value: 0
}
@ -85,6 +87,7 @@ defmodule EthereumJSONRPC.Geth.Call do
...> "transactionIndex" => 7,
...> "transactionHash" => "0xc4f4ba28bf8e6093b3f5932191a7a6af1dd17517c2b0e1be3b76dc445564a9ff",
...> "index" => 64,
...> "traceAddress" => [],
...> "type" => "call",
...> "callType" => "call",
...> "from" => "0xaf7cf620c3df1b9ccbc640be903d5ea6cea7bc96",
@ -101,6 +104,7 @@ defmodule EthereumJSONRPC.Geth.Call do
transaction_index: 7,
transaction_hash: "0xc4f4ba28bf8e6093b3f5932191a7a6af1dd17517c2b0e1be3b76dc445564a9ff",
index: 64,
trace_address: [],
type: "call",
call_type: "call",
from_address_hash: "0xaf7cf620c3df1b9ccbc640be903d5ea6cea7bc96",
@ -108,7 +112,6 @@ defmodule EthereumJSONRPC.Geth.Call do
input: "0x49b46d5d",
error: "stack limit reached 1024 (1024)",
gas: 1445580,
trace_address: [],
value: 0
}
@ -120,6 +123,7 @@ defmodule EthereumJSONRPC.Geth.Call do
...> "transactionIndex" => 1,
...> "transactionHash" => "0x248a832af263a298b9869ee9a669c2c86a3676799b0b8b566c6dd452daaedbf6",
...> "index" => 0,
...> "traceAddress" => [],
...> "type" => "create",
...> "from" => "0xb95754d27da16a0f17aba278fc10a69e1c9fee1c",
...> "createdContractAddressHash" => "0x08d24f568715041e72223cc023e806060de8a2a5",
@ -154,6 +158,7 @@ defmodule EthereumJSONRPC.Geth.Call do
...> "transactionIndex" => 14,
...> "transactionHash" => "0x5c0c728190e593f2bbcbd9d7f851cbfbcaf041e41ce1b1eead97c301deb071fa",
...> "index" => 0,
...> "traceAddress" => [],
...> "type" => "create",
...> "from" => "0x0a49007c56c5f9eda04a2ae4229da03a30be892e",
...> "gas" => "0x84068",
@ -168,12 +173,12 @@ defmodule EthereumJSONRPC.Geth.Call do
transaction_index: 14,
transaction_hash: "0x5c0c728190e593f2bbcbd9d7f851cbfbcaf041e41ce1b1eead97c301deb071fa",
index: 0,
trace_address: [],
type: "create",
from_address_hash: "0x0a49007c56c5f9eda04a2ae4229da03a30be892e",
init: "0xf49e4745",
error: "stack underflow (0 <=> 6)",
gas: 540776,
trace_address: [],
value: 5287885714285715
}
@ -185,6 +190,7 @@ defmodule EthereumJSONRPC.Geth.Call do
...> "transactionIndex" => 21,
...> "transactionHash" => "0x6cf0aa434f6500251ce8579d031c821b9fd4b687685b21c368f1c1106e9a49a9",
...> "index" => 1,
...> "traceAddress" => [0],
...> "type" => "call",
...> "callType" => "delegatecall",
...> "from" => "0x54a298ee9fccbf0ad8e55bc641d3086b81a48c41",
@ -201,6 +207,7 @@ defmodule EthereumJSONRPC.Geth.Call do
transaction_index: 21,
transaction_hash: "0x6cf0aa434f6500251ce8579d031c821b9fd4b687685b21c368f1c1106e9a49a9",
index: 1,
trace_address: [0],
type: "call",
call_type: "delegatecall",
from_address_hash: "0x54a298ee9fccbf0ad8e55bc641d3086b81a48c41",
@ -209,7 +216,6 @@ defmodule EthereumJSONRPC.Geth.Call do
gas_used: 6111,
input: "0xeb9d50e46930b3227102b442f93b4aed3dead4ed76f850a76ee7f8b2cbe763428f2790530000000000000000000000000000000000000000000000000926708dfd7272e3",
output: "0x",
trace_address: [],
value: 0
}
@ -222,6 +228,7 @@ defmodule EthereumJSONRPC.Geth.Call do
...> "transactionIndex" => 0,
...> "transactionHash" => "0xb49ac6385dce60e2d88d8b4579f4e70a23cd40b45ecb29eb6c6069efc895325b",
...> "index" => 1,
...> "traceAddress" => [0],
...> "type" => "call",
...> "callType" => "staticcall",
...> "from" => "0xa4b3886db53bebdabbe17592a57886810b906200",
@ -238,6 +245,7 @@ defmodule EthereumJSONRPC.Geth.Call do
transaction_index: 0,
transaction_hash: "0xb49ac6385dce60e2d88d8b4579f4e70a23cd40b45ecb29eb6c6069efc895325b",
index: 1,
trace_address: [0],
type: "call",
call_type: "staticcall",
from_address_hash: "0xa4b3886db53bebdabbe17592a57886810b906200",
@ -246,7 +254,6 @@ defmodule EthereumJSONRPC.Geth.Call do
gas_used: 1040,
input: "0x0f370699",
output: "0x",
trace_address: [],
value: 0
}
@ -258,6 +265,7 @@ defmodule EthereumJSONRPC.Geth.Call do
...> "transactionIndex" => 9,
...> "transactionHash" => "0xe098557c8fa82be6779f5c2b3f248e990e2dc67b6bd60a4fa4a9aa66f6c24c08",
...> "index" => 32,
...> "traceAddress" => [1],
...> "type" => "selfdestruct",
...> "from" => "0x9317da7be8e05f36f329a95f004a44552effb968",
...> "to" => "0xff77830c100623316736b45c4983df970423aaf4",
@ -268,14 +276,15 @@ defmodule EthereumJSONRPC.Geth.Call do
...> )
%{
block_number: 3298074,
transaction_index: 9,
transaction_hash: "0xe098557c8fa82be6779f5c2b3f248e990e2dc67b6bd60a4fa4a9aa66f6c24c08",
index: 32,
trace_address: [1],
type: "selfdestruct",
from_address_hash: "0x9317da7be8e05f36f329a95f004a44552effb968",
to_address_hash: "0xff77830c100623316736b45c4983df970423aaf4",
gas: 742088,
gas_used: 718517,
index: 32,
to_address_hash: "0xff77830c100623316736b45c4983df970423aaf4",
transaction_hash: "0xe098557c8fa82be6779f5c2b3f248e990e2dc67b6bd60a4fa4a9aa66f6c24c08",
transaction_index: 9,
type: "selfdestruct",
value: 0
}
@ -302,11 +311,18 @@ defmodule EthereumJSONRPC.Geth.Call do
{key, quantity_to_integer(quantity)}
end
defp entry_to_elixir({"traceAddress", trace_address} = entry) when is_list(trace_address) do
true = Enum.all?(trace_address, &is_integer/1)
entry
end
defp elixir_to_internal_transaction_params(%{
"blockNumber" => block_number,
"transactionIndex" => transaction_index,
"transactionHash" => transaction_hash,
"index" => index,
"traceAddress" => trace_address,
"type" => "call" = type,
"callType" => call_type,
"from" => from_address_hash,
@ -323,6 +339,7 @@ defmodule EthereumJSONRPC.Geth.Call do
transaction_index: transaction_index,
transaction_hash: transaction_hash,
index: index,
trace_address: trace_address,
type: type,
call_type: call_type,
from_address_hash: from_address_hash,
@ -331,7 +348,6 @@ defmodule EthereumJSONRPC.Geth.Call do
gas_used: gas_used,
input: input,
output: output,
trace_address: [],
value: value
}
end
@ -341,6 +357,7 @@ defmodule EthereumJSONRPC.Geth.Call do
"transactionIndex" => transaction_index,
"transactionHash" => transaction_hash,
"index" => index,
"traceAddress" => trace_address,
"type" => "call" = type,
"callType" => call_type,
"from" => from_address_hash,
@ -356,6 +373,7 @@ defmodule EthereumJSONRPC.Geth.Call do
transaction_index: transaction_index,
transaction_hash: transaction_hash,
index: index,
trace_address: trace_address,
type: type,
call_type: call_type,
from_address_hash: from_address_hash,
@ -363,7 +381,6 @@ defmodule EthereumJSONRPC.Geth.Call do
gas: gas,
input: input,
error: error,
trace_address: [],
value: value
}
end
@ -373,6 +390,7 @@ defmodule EthereumJSONRPC.Geth.Call do
"transactionIndex" => transaction_index,
"transactionHash" => transaction_hash,
"index" => index,
"traceAddress" => trace_address,
"type" => "call" = type,
"callType" => "staticcall" = call_type,
"from" => from_address_hash,
@ -388,6 +406,7 @@ defmodule EthereumJSONRPC.Geth.Call do
transaction_index: transaction_index,
transaction_hash: transaction_hash,
index: index,
trace_address: trace_address,
type: type,
call_type: call_type,
from_address_hash: from_address_hash,
@ -396,7 +415,6 @@ defmodule EthereumJSONRPC.Geth.Call do
gas_used: gas_used,
input: input,
output: output,
trace_address: [],
value: value
}
end
@ -406,6 +424,7 @@ defmodule EthereumJSONRPC.Geth.Call do
"transactionIndex" => transaction_index,
"transactionHash" => transaction_hash,
"index" => index,
"traceAddress" => trace_address,
"type" => "create",
"from" => from_address_hash,
"createdContractAddressHash" => created_contract_address_hash,
@ -420,6 +439,7 @@ defmodule EthereumJSONRPC.Geth.Call do
transaction_index: transaction_index,
transaction_hash: transaction_hash,
index: index,
trace_address: trace_address,
type: "create",
from_address_hash: from_address_hash,
gas: gas,
@ -427,7 +447,6 @@ defmodule EthereumJSONRPC.Geth.Call do
created_contract_address_hash: created_contract_address_hash,
init: init,
created_contract_code: created_contract_code,
trace_address: [],
value: value
}
end
@ -437,6 +456,7 @@ defmodule EthereumJSONRPC.Geth.Call do
"transactionIndex" => transaction_index,
"transactionHash" => transaction_hash,
"index" => index,
"traceAddress" => trace_address,
"type" => "create" = type,
"from" => from_address_hash,
"error" => error,
@ -449,12 +469,12 @@ defmodule EthereumJSONRPC.Geth.Call do
transaction_index: transaction_index,
transaction_hash: transaction_hash,
index: index,
trace_address: trace_address,
type: type,
from_address_hash: from_address_hash,
gas: gas,
error: error,
init: init,
trace_address: [],
value: value
}
end
@ -464,6 +484,7 @@ defmodule EthereumJSONRPC.Geth.Call do
"transactionIndex" => transaction_index,
"transactionHash" => transaction_hash,
"index" => index,
"traceAddress" => trace_address,
"type" => "selfdestruct" = type,
"from" => from_address_hash,
"to" => to_address_hash,
@ -476,6 +497,7 @@ defmodule EthereumJSONRPC.Geth.Call do
transaction_index: transaction_index,
transaction_hash: transaction_hash,
index: index,
trace_address: trace_address,
type: type,
from_address_hash: from_address_hash,
to_address_hash: to_address_hash,

@ -14,33 +14,35 @@ defmodule EthereumJSONRPC.Geth.Calls do
iex> EthereumJSONRPC.Geth.Calls.to_internal_transactions_params(
...> [
...> %{
...> "blockNumber" => 3287375,
...> "blockNumber" => 3287375,
...> "transactionIndex" => 13,
...> "transactionHash" => "0x32b17f27ddb546eab3c4c33f31eb22c1cb992d4ccc50dae26922805b717efe5c",
...> "index" => 0,
...> "traceAddress" => [],
...> "type" => "call",
...> "callType" => "call",
...> "from" => "0xa931c862e662134b85e4dc4baf5c70cc9ba74db4",
...> "to" => "0x1469b17ebf82fedf56f04109e5207bdc4554288c",
...> "gas" => "0x8600",
...> "gasUsed" => "0x7d37",
...> "index" => 0,
...> "input" => "0xb118e2db0000000000000000000000000000000000000000000000000000000000000008",
...> "output" => "0x",
...> "to" => "0x1469b17ebf82fedf56f04109e5207bdc4554288c",
...> "transactionHash" => "0x32b17f27ddb546eab3c4c33f31eb22c1cb992d4ccc50dae26922805b717efe5c",
...> "transactionIndex" => 13,
...> "type" => "call",
...> "value" => "0x174876e800"
...> },
...> %{
...> "blockNumber" => 3287375,
...> "transactionIndex" => 13,
...> "transactionHash" => "0x32b17f27ddb546eab3c4c33f31eb22c1cb992d4ccc50dae26922805b717efe5c",
...> "index" => 1,
...> "traceAddress" => [0],
...> "type" => "call",
...> "callType" => "call",
...> "from" => "0x1469b17ebf82fedf56f04109e5207bdc4554288c",
...> "to" => "0xf8d67a2d17b7936bda99585d921fd7276fc5cac7",
...> "gas" => "0x25e4",
...> "gasUsed" => "0x1ce8",
...> "index" => 1,
...> "input" => "0x",
...> "output" => "0x",
...> "to" => "0xf8d67a2d17b7936bda99585d921fd7276fc5cac7",
...> "transactionHash" => "0x32b17f27ddb546eab3c4c33f31eb22c1cb992d4ccc50dae26922805b717efe5c",
...> "transactionIndex" => 13,
...> "type" => "call",
...> "value" => "0x174876e800"
...> }
...> ]
@ -48,34 +50,34 @@ defmodule EthereumJSONRPC.Geth.Calls do
[
%{
block_number: 3287375,
transaction_index: 13,
transaction_hash: "0x32b17f27ddb546eab3c4c33f31eb22c1cb992d4ccc50dae26922805b717efe5c",
index: 0,
trace_address: [],
type: "call",
call_type: "call",
from_address_hash: "0xa931c862e662134b85e4dc4baf5c70cc9ba74db4",
to_address_hash: "0x1469b17ebf82fedf56f04109e5207bdc4554288c",
gas: 34304,
gas_used: 32055,
index: 0,
input: "0xb118e2db0000000000000000000000000000000000000000000000000000000000000008",
output: "0x",
to_address_hash: "0x1469b17ebf82fedf56f04109e5207bdc4554288c",
trace_address: [],
transaction_hash: "0x32b17f27ddb546eab3c4c33f31eb22c1cb992d4ccc50dae26922805b717efe5c",
transaction_index: 13,
type: "call",
value: 100000000000
},
%{
block_number: 3287375,
transaction_index: 13,
transaction_hash: "0x32b17f27ddb546eab3c4c33f31eb22c1cb992d4ccc50dae26922805b717efe5c",
index: 1,
trace_address: [0],
type: "call",
call_type: "call",
from_address_hash: "0x1469b17ebf82fedf56f04109e5207bdc4554288c",
to_address_hash: "0xf8d67a2d17b7936bda99585d921fd7276fc5cac7",
gas: 9700,
gas_used: 7400,
index: 1,
input: "0x",
output: "0x",
to_address_hash: "0xf8d67a2d17b7936bda99585d921fd7276fc5cac7",
trace_address: [],
transaction_hash: "0x32b17f27ddb546eab3c4c33f31eb22c1cb992d4ccc50dae26922805b717efe5c",
transaction_index: 13,
type: "call",
value: 100000000000
}
]
@ -86,17 +88,18 @@ defmodule EthereumJSONRPC.Geth.Calls do
...> [
...> %{
...> "blockNumber" => 3293221,
...> "transactionIndex" => 16,
...> "transactionHash" => "0xa9a893fe2f019831496cec9777ad25ff940823b9b47a3969299ea139e42b2073",
...> "index" => 0,
...> "traceAddress" => [],
...> "type" => "call",
...> "callType" => "call",
...> "error" => "out of gas",
...> "from" => "0x8ec75ef3adf6c953775d0738e0e7bd60e647e5ef",
...> "to" => "0xaae465ad04b12e90c32291e59b65ca781c57e361",
...> "gas" => "0x4c9",
...> "gasUsed" => "0x4c9",
...> "index" => 0,
...> "input" => "0xa83627de",
...> "to" => "0xaae465ad04b12e90c32291e59b65ca781c57e361",
...> "transactionHash" => "0xa9a893fe2f019831496cec9777ad25ff940823b9b47a3969299ea139e42b2073",
...> "transactionIndex" => 16,
...> "type" => "call",
...> "error" => "out of gas",
...> "value" => "0x0"
...> }
...> ]
@ -107,14 +110,14 @@ defmodule EthereumJSONRPC.Geth.Calls do
transaction_index: 16,
transaction_hash: "0xa9a893fe2f019831496cec9777ad25ff940823b9b47a3969299ea139e42b2073",
index: 0,
trace_address: [],
type: "call",
call_type: "call",
input: "0xa83627de",
error: "out of gas",
from_address_hash: "0x8ec75ef3adf6c953775d0738e0e7bd60e647e5ef",
to_address_hash: "0xaae465ad04b12e90c32291e59b65ca781c57e361",
gas: 1225,
input: "0xa83627de",
trace_address: [],
value: 0
}
]
@ -125,10 +128,11 @@ defmodule EthereumJSONRPC.Geth.Calls do
...> [
...> %{
...> "blockNumber" => 3292697,
...> "type" => "create",
...> "transactionIndex" => 1,
...> "transactionHash" => "0x248a832af263a298b9869ee9a669c2c86a3676799b0b8b566c6dd452daaedbf6",
...> "index" => 0,
...> "traceAddress" => [],
...> "type" => "create",
...> "from" => "0xb95754d27da16a0f17aba278fc10a69e1c9fee1c",
...> "createdContractAddressHash" => "0x08d24f568715041e72223cc023e806060de8a2a5",
...> "gas" => "0x5e46ef",
@ -145,6 +149,7 @@ defmodule EthereumJSONRPC.Geth.Calls do
transaction_index: 1,
transaction_hash: "0x248a832af263a298b9869ee9a669c2c86a3676799b0b8b566c6dd452daaedbf6",
index: 0,
trace_address: [],
type: "create",
from_address_hash: "0xb95754d27da16a0f17aba278fc10a69e1c9fee1c",
created_contract_address_hash: "0x08d24f568715041e72223cc023e806060de8a2a5",
@ -152,7 +157,6 @@ defmodule EthereumJSONRPC.Geth.Calls do
gas_used: 1477258,
init: "0x",
created_contract_code: "0x",
trace_address: [],
value: 0
}
]
@ -166,6 +170,8 @@ defmodule EthereumJSONRPC.Geth.Calls do
...> "transactionIndex" => 13,
...> "transactionHash" => "0x19379505cd9fcd16f19d92f23dc323ee921991da1f169df2af1d93fdb8bca461",
...> "index" => 0,
...> "traceAddress" => [],
...> "type" => "call",
...> "callType" => "call",
...> "from" => "0x129f447137b03ee3d8bbad62ef5d89021d944324",
...> "to" => "0x2c8a58ddba2dc097ea0f95db6cd51ac7d31d1518",
@ -173,7 +179,6 @@ defmodule EthereumJSONRPC.Geth.Calls do
...> "gasUsed" => "0x106e24",
...> "input" => "0xe9696f54",
...> "output" => "0x0000000000000000000000009b5a1dcfd53caa108ef83cf2ff0e17db27facf0f",
...> "type" => "call",
...> "value" => "0x0"
...> },
...> %{
@ -181,6 +186,7 @@ defmodule EthereumJSONRPC.Geth.Calls do
...> "transactionIndex" => 13,
...> "transactionHash" => "0x19379505cd9fcd16f19d92f23dc323ee921991da1f169df2af1d93fdb8bca461",
...> "index" => 1,
...> "traceAddress" => [0],
...> "type" => "create",
...> "from" => "0x2c8a58ddba2dc097ea0f95db6cd51ac7d31d1518",
...> "createdContractAddressHash" => "0x9b5a1dcfd53caa108ef83cf2ff0e17db27facf0f",
@ -198,6 +204,7 @@ defmodule EthereumJSONRPC.Geth.Calls do
transaction_index: 13,
transaction_hash: "0x19379505cd9fcd16f19d92f23dc323ee921991da1f169df2af1d93fdb8bca461",
index: 0,
trace_address: [],
type: "call",
call_type: "call",
from_address_hash: "0x129f447137b03ee3d8bbad62ef5d89021d944324",
@ -206,12 +213,12 @@ defmodule EthereumJSONRPC.Geth.Calls do
gas_used: 1076772,
input: "0xe9696f54",
output: "0x0000000000000000000000009b5a1dcfd53caa108ef83cf2ff0e17db27facf0f",
trace_address: [],
value: 0
},
%{
block_number: 3293393,
transaction_index: 13,
trace_address: [0],
transaction_hash: "0x19379505cd9fcd16f19d92f23dc323ee921991da1f169df2af1d93fdb8bca461",
index: 1,
type: "create",
@ -221,7 +228,6 @@ defmodule EthereumJSONRPC.Geth.Calls do
gas_used: 1041448,
init: "0x6080604",
created_contract_code: "0x608060",
trace_address: [],
value: 0
}
]

@ -220,7 +220,7 @@
result(ctx, db) {
const result = this.ctxToResult(ctx, db);
const filtered = this.filterNotUndefined(result);
const callSequence = this.sequence(filtered, [], filtered.valueBigInt, filtered.gasUsedBigInt).callSequence;
const callSequence = this.sequence(filtered, [], filtered.valueBigInt, filtered.gasUsedBigInt, []).callSequence;
return this.encodeCallSequence(callSequence);
},
@ -339,10 +339,12 @@
},
// sequence converts the finalized calls from a call tree to a call sequence
sequence(call, callSequence, availableValueBigInt, availableGasBigInt) {
sequence(call, callSequence, availableValueBigInt, availableGasBigInt, traceAddress) {
const subcalls = call.calls;
delete call.calls;
call.traceAddress = traceAddress;
if (call.type === 'call' && call.callType === 'delegatecall') {
call.valueBigInt = availableValueBigInt;
} else if (call.type === 'selfdestruct') {
@ -356,7 +358,13 @@
var nestedAvailableGasBigInt = availableGasBigInt;
for (var i = 0; i < subcalls.length; i++) {
const nestedSequenced = this.sequence(subcalls[i], newCallSequence, nestedAvailableValueBigInt, availableGasBigInt);
const nestedSequenced = this.sequence(
subcalls[i],
newCallSequence,
nestedAvailableValueBigInt,
availableGasBigInt,
traceAddress.concat([i])
);
newCallSequence = nestedSequenced.callSequence;
nestedAvailableValueBigInt = nestedSequenced.availableValueBigInt;
nestedAvailableGasBigInt = nestedSequenced.availableGasBigInt;
@ -367,7 +375,11 @@
const newAvailableGasUsedBigInt = availableGasBigInt.subtract(call.gasUsedBigInt);
return {callSequence: newCallSequence, availableValueBigInt: newAvailableValueBigInt, availableGasBigInt: newAvailableGasUsedBigInt};
return {
callSequence: newCallSequence,
availableValueBigInt: newAvailableValueBigInt,
availableGasBigInt: newAvailableGasUsedBigInt
};
},
encodeCallSequence(calls) {

Loading…
Cancel
Save