Skip to content

Commit

Permalink
Merge pull request #2086 from poanetwork/ab-fix-staticcall-without-ou…
Browse files Browse the repository at this point in the history
…tput

fix geth's staticcall without output
  • Loading branch information
vbaranov committed Jun 4, 2019
2 parents a89c512 + a9c7f26 commit 885e2eb
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
- [#2014](https://github.com/poanetwork/blockscout/pull/2014) - fix: use better queries for listLogs endpoint
- [#2027](https://github.com/poanetwork/blockscout/pull/2027) - fix: `BlocksTransactionsMismatch` ignoring blocks without transactions
- [#2070](https://github.com/poanetwork/blockscout/pull/2070) - reduce `max_concurrency` of `BlocksTransactionsMismatch` fetcher
- [#2086](https://github.com/poanetwork/blockscout/pull/2086) - fix geth's staticcall without output

### Chore

Expand Down
35 changes: 18 additions & 17 deletions apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/call.ex
Original file line number Diff line number Diff line change
Expand Up @@ -385,22 +385,23 @@ defmodule EthereumJSONRPC.Geth.Call do
}
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" => "staticcall" = call_type,
"from" => from_address_hash,
"to" => to_address_hash,
"input" => input,
"output" => output,
"gas" => gas,
"gasUsed" => gas_used,
"value" => 0 = value
}) do
defp elixir_to_internal_transaction_params(
%{
"blockNumber" => block_number,
"transactionIndex" => transaction_index,
"transactionHash" => transaction_hash,
"index" => index,
"traceAddress" => trace_address,
"type" => "call" = type,
"callType" => "staticcall" = call_type,
"from" => from_address_hash,
"to" => to_address_hash,
"input" => input,
"gas" => gas,
"gasUsed" => gas_used,
"value" => 0 = value
} = params
) do
%{
block_number: block_number,
transaction_index: transaction_index,
Expand All @@ -414,7 +415,7 @@ defmodule EthereumJSONRPC.Geth.Call do
gas: gas,
gas_used: gas_used,
input: input,
output: output,
output: params["output"],
value: value
}
end
Expand Down
43 changes: 43 additions & 0 deletions apps/ethereum_jsonrpc/test/ethereum_jsonrpc/geth/call_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,47 @@ defmodule EthereumJSONRPC.Geth.CallTest do
use ExUnit.Case, async: true

doctest EthereumJSONRPC.Geth.Call

alias EthereumJSONRPC.Geth.Call

describe "to_internal_transaction_params/1" do
test "does not fail decoding static_call without output" do
result =
Call.to_internal_transaction_params(%{
"blockNumber" => 584_340,
"callType" => "staticcall",
"error" => "execution reverted",
"from" => "0x3858636f27e269d23db2ef1fcca5f93dcaa564cd",
"gas" => "0x0",
"gasUsed" => "0x0",
"index" => 1,
"input" =>
"0x09d10a5e00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000002",
"to" => "0x79073fc2117dd054fcedacad1e7018c9cbe3ec0b",
"traceAddress" => [1, 3],
"transactionHash" => "0xbc38745b826f058ed2f6c93fa5b145323857f06bbb5230b6a6a50e09e0915857",
"transactionIndex" => 0,
"type" => "call",
"value" => "0x0"
})

assert result == %{
block_number: 584_340,
call_type: "staticcall",
from_address_hash: "0x3858636f27e269d23db2ef1fcca5f93dcaa564cd",
gas: 0,
gas_used: 0,
index: 1,
input:
"0x09d10a5e00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000002",
output: nil,
to_address_hash: "0x79073fc2117dd054fcedacad1e7018c9cbe3ec0b",
trace_address: [1, 3],
transaction_hash: "0xbc38745b826f058ed2f6c93fa5b145323857f06bbb5230b6a6a50e09e0915857",
transaction_index: 0,
type: "call",
value: 0
}
end
end
end

0 comments on commit 885e2eb

Please sign in to comment.