Fix verification with experimental features enabled

pull/3202/head
Victor Baranov 4 years ago
parent 479719e863
commit 406a6003fa
  1. 102
      apps/explorer/lib/explorer/smart_contract/verifier.ex
  2. 178
      apps/explorer/lib/explorer/smart_contract/verifier/constructor_arguments.ex

@ -15,8 +15,10 @@ defmodule Explorer.SmartContract.Verifier do
@metadata_hash_prefix_0_4_23 "a165627a7a72305820"
@metadata_hash_prefix_0_5_10 "a265627a7a72305820"
@metadata_hash_prefix_0_5_11 "a265627a7a72315820"
@metadata_hash_prefix_0_5_16 "a365627a7a72315820"
@metadata_hash_prefix_0_6_0 "a264697066735822"
@experimental "6c6578706572696d656e74616cf5"
@metadata_hash_common_suffix "64736f6c63"
def evaluate_authenticity(_, %{"name" => ""}), do: {:error, :name}
@ -230,6 +232,20 @@ defmodule Explorer.SmartContract.Verifier do
@metadata_hash_prefix_0_5_11 <>
<<metadata_hash::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <>
"43" <> <<compiler_version::binary-size(6)>> <> "0032" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@metadata_hash_prefix_0_5_11 <>
<<metadata_hash::binary-size(64)>> <>
@metadata_hash_common_suffix <>
"7826" <> <<compiler_version::binary-size(76)>> <> "0057" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@metadata_hash_prefix_0_5_11 <>
<<metadata_hash::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <>
"7826" <> <<compiler_version::binary-size(76)>> <> "0057" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@ -242,6 +258,20 @@ defmodule Explorer.SmartContract.Verifier do
@metadata_hash_prefix_0_5_11 <>
<<metadata_hash::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <>
"7827" <> <<compiler_version::binary-size(78)>> <> "0057" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@metadata_hash_prefix_0_5_11 <>
<<metadata_hash::binary-size(64)>> <>
@metadata_hash_common_suffix <>
"7828" <> <<compiler_version::binary-size(80)>> <> "0058" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@metadata_hash_prefix_0_5_11 <>
<<metadata_hash::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <>
"7828" <> <<compiler_version::binary-size(80)>> <> "0058" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@ -252,6 +282,78 @@ defmodule Explorer.SmartContract.Verifier do
"7829" <> <<compiler_version::binary-size(82)>> <> "0059" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@metadata_hash_prefix_0_5_11 <>
<<metadata_hash::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <>
"7829" <> <<compiler_version::binary-size(82)>> <> "0059" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@metadata_hash_prefix_0_5_16 <>
<<metadata_hash::binary-size(64)>> <>
@metadata_hash_common_suffix <>
"43" <> <<compiler_version::binary-size(6)>> <> "0032" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@metadata_hash_prefix_0_5_16 <>
<<metadata_hash::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <>
"43" <> <<compiler_version::binary-size(6)>> <> "0040" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@metadata_hash_prefix_0_5_16 <>
<<metadata_hash::binary-size(64)>> <>
@metadata_hash_common_suffix <>
"7826" <> <<compiler_version::binary-size(76)>> <> "0057" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@metadata_hash_prefix_0_5_16 <>
<<metadata_hash::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <>
"7826" <> <<compiler_version::binary-size(76)>> <> "0057" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@metadata_hash_prefix_0_5_16 <>
<<metadata_hash::binary-size(64)>> <>
@metadata_hash_common_suffix <>
"7827" <> <<compiler_version::binary-size(78)>> <> "0057" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@metadata_hash_prefix_0_5_16 <>
<<metadata_hash::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <>
"7827" <> <<compiler_version::binary-size(78)>> <> "0057" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@metadata_hash_prefix_0_5_16 <>
<<metadata_hash::binary-size(64)>> <>
@metadata_hash_common_suffix <>
"7828" <> <<compiler_version::binary-size(80)>> <> "0058" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@metadata_hash_prefix_0_5_16 <>
<<metadata_hash::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <>
"7828" <> <<compiler_version::binary-size(80)>> <> "0058" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@metadata_hash_prefix_0_5_16 <>
<<metadata_hash::binary-size(64)>> <>
@metadata_hash_common_suffix <>
"7829" <> <<compiler_version::binary-size(82)>> <> "0059" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
@metadata_hash_prefix_0_5_16 <>
<<metadata_hash::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <>
"7829" <> <<compiler_version::binary-size(82)>> <> "0059" <> _constructor_arguments ->
do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version)
# Solidity >= 0.6.0 https://github.com/ethereum/solidity/blob/develop/Changelog.md#060-2019-12-17
# https://github.com/ethereum/solidity/blob/26b700771e9cc9c956f0503a05de69a1be427963/docs/metadata.rst#encoding-of-the-metadata-hash-in-the-bytecode
# IPFS is used instead of Swarm

@ -9,8 +9,10 @@ defmodule Explorer.SmartContract.Verifier.ConstructorArguments do
@metadata_hash_prefix_0_4_23 "a165627a7a72305820"
@metadata_hash_prefix_0_5_10 "a265627a7a72305820"
@metadata_hash_prefix_0_5_11 "a265627a7a72315820"
@metadata_hash_prefix_0_5_16 "a365627a7a72315820"
@metadata_hash_prefix_0_6_0 "a264697066735822"
@experimental "6c6578706572696d656e74616cf5"
@metadata_hash_common_suffix "64736f6c63"
def verify(address_hash, contract_code, arguments_data, contract_source_code, contract_name) do
@ -120,6 +122,18 @@ defmodule Explorer.SmartContract.Verifier.ConstructorArguments do
@metadata_hash_prefix_0_5_11
)
@metadata_hash_prefix_0_5_11 <>
<<_::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <> "43" <> <<_::binary-size(6)>> <> "0032" <> constructor_arguments ->
split_constructor_arguments_and_extract_check_func(
constructor_arguments,
check_func,
contract_source_code,
contract_name,
@experimental <> @metadata_hash_prefix_0_5_11
)
@metadata_hash_prefix_0_5_11 <>
<<_::binary-size(64)>> <>
@metadata_hash_common_suffix <> "7826" <> <<_::binary-size(76)>> <> "0057" <> constructor_arguments ->
@ -131,6 +145,18 @@ defmodule Explorer.SmartContract.Verifier.ConstructorArguments do
@metadata_hash_prefix_0_5_11
)
@metadata_hash_prefix_0_5_11 <>
<<_::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <> "7826" <> <<_::binary-size(76)>> <> "0057" <> constructor_arguments ->
split_constructor_arguments_and_extract_check_func(
constructor_arguments,
check_func,
contract_source_code,
contract_name,
@experimental <> @metadata_hash_prefix_0_5_11
)
@metadata_hash_prefix_0_5_11 <>
<<_::binary-size(64)>> <>
@metadata_hash_common_suffix <> "7827" <> <<_::binary-size(78)>> <> "0057" <> constructor_arguments ->
@ -142,6 +168,18 @@ defmodule Explorer.SmartContract.Verifier.ConstructorArguments do
@metadata_hash_prefix_0_5_11
)
@metadata_hash_prefix_0_5_11 <>
<<_::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <> "7827" <> <<_::binary-size(78)>> <> "0057" <> constructor_arguments ->
split_constructor_arguments_and_extract_check_func(
constructor_arguments,
check_func,
contract_source_code,
contract_name,
@experimental <> @metadata_hash_prefix_0_5_11
)
@metadata_hash_prefix_0_5_11 <>
<<_::binary-size(64)>> <>
@metadata_hash_common_suffix <> "7828" <> <<_::binary-size(80)>> <> "0058" <> constructor_arguments ->
@ -153,6 +191,18 @@ defmodule Explorer.SmartContract.Verifier.ConstructorArguments do
@metadata_hash_prefix_0_5_11
)
@metadata_hash_prefix_0_5_11 <>
<<_::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <> "7828" <> <<_::binary-size(80)>> <> "0058" <> constructor_arguments ->
split_constructor_arguments_and_extract_check_func(
constructor_arguments,
check_func,
contract_source_code,
contract_name,
@experimental <> @metadata_hash_prefix_0_5_11
)
@metadata_hash_prefix_0_5_11 <>
<<_::binary-size(64)>> <>
@metadata_hash_common_suffix <> "7829" <> <<_::binary-size(82)>> <> "0059" <> constructor_arguments ->
@ -164,6 +214,134 @@ defmodule Explorer.SmartContract.Verifier.ConstructorArguments do
@metadata_hash_prefix_0_5_11
)
@metadata_hash_prefix_0_5_11 <>
<<_::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <> "7829" <> <<_::binary-size(82)>> <> "0059" <> constructor_arguments ->
split_constructor_arguments_and_extract_check_func(
constructor_arguments,
check_func,
contract_source_code,
contract_name,
@experimental <> @metadata_hash_prefix_0_5_11
)
# ABIEncoder V2
@metadata_hash_prefix_0_5_16 <>
<<_::binary-size(64)>> <>
@metadata_hash_common_suffix <> "43" <> <<_::binary-size(6)>> <> "0032" <> constructor_arguments ->
split_constructor_arguments_and_extract_check_func(
constructor_arguments,
check_func,
contract_source_code,
contract_name,
@metadata_hash_prefix_0_5_16
)
@metadata_hash_prefix_0_5_16 <>
<<_::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <> "43" <> <<_::binary-size(6)>> <> "0032" <> constructor_arguments ->
split_constructor_arguments_and_extract_check_func(
constructor_arguments,
check_func,
contract_source_code,
contract_name,
@experimental <> @metadata_hash_prefix_0_5_16
)
@metadata_hash_prefix_0_5_16 <>
<<_::binary-size(64)>> <>
@metadata_hash_common_suffix <> "7826" <> <<_::binary-size(76)>> <> "0057" <> constructor_arguments ->
split_constructor_arguments_and_extract_check_func(
constructor_arguments,
check_func,
contract_source_code,
contract_name,
@metadata_hash_prefix_0_5_16
)
@metadata_hash_prefix_0_5_16 <>
<<_::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <> "7826" <> <<_::binary-size(76)>> <> "0057" <> constructor_arguments ->
split_constructor_arguments_and_extract_check_func(
constructor_arguments,
check_func,
contract_source_code,
contract_name,
@experimental <> @metadata_hash_prefix_0_5_16
)
@metadata_hash_prefix_0_5_16 <>
<<_::binary-size(64)>> <>
@metadata_hash_common_suffix <> "7827" <> <<_::binary-size(78)>> <> "0057" <> constructor_arguments ->
split_constructor_arguments_and_extract_check_func(
constructor_arguments,
check_func,
contract_source_code,
contract_name,
@metadata_hash_prefix_0_5_16
)
@metadata_hash_prefix_0_5_16 <>
<<_::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <> "7827" <> <<_::binary-size(78)>> <> "0057" <> constructor_arguments ->
split_constructor_arguments_and_extract_check_func(
constructor_arguments,
check_func,
contract_source_code,
contract_name,
@experimental <> @metadata_hash_prefix_0_5_16
)
@metadata_hash_prefix_0_5_16 <>
<<_::binary-size(64)>> <>
@metadata_hash_common_suffix <> "7828" <> <<_::binary-size(80)>> <> "0058" <> constructor_arguments ->
split_constructor_arguments_and_extract_check_func(
constructor_arguments,
check_func,
contract_source_code,
contract_name,
@metadata_hash_prefix_0_5_16
)
@metadata_hash_prefix_0_5_16 <>
<<_::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <> "7828" <> <<_::binary-size(80)>> <> "0058" <> constructor_arguments ->
split_constructor_arguments_and_extract_check_func(
constructor_arguments,
check_func,
contract_source_code,
contract_name,
@experimental <> @metadata_hash_prefix_0_5_16
)
@metadata_hash_prefix_0_5_16 <>
<<_::binary-size(64)>> <>
@metadata_hash_common_suffix <> "7829" <> <<_::binary-size(82)>> <> "0059" <> constructor_arguments ->
split_constructor_arguments_and_extract_check_func(
constructor_arguments,
check_func,
contract_source_code,
contract_name,
@metadata_hash_prefix_0_5_16
)
@metadata_hash_prefix_0_5_16 <>
<<_::binary-size(64)>> <>
@experimental <>
@metadata_hash_common_suffix <> "7829" <> <<_::binary-size(82)>> <> "0059" <> constructor_arguments ->
split_constructor_arguments_and_extract_check_func(
constructor_arguments,
check_func,
contract_source_code,
contract_name,
@experimental <> @metadata_hash_prefix_0_5_16
)
# Solidity >= 0.6.0 https://github.com/ethereum/solidity/blob/develop/Changelog.md#060-2019-12-17
# https://github.com/ethereum/solidity/blob/26b700771e9cc9c956f0503a05de69a1be427963/docs/metadata.rst#encoding-of-the-metadata-hash-in-the-bytecode
# IPFS is used instead of Swarm

Loading…
Cancel
Save