Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart-contract proxy detection refactoring #8807

Merged
merged 14 commits into from
Nov 16, 2023

Conversation

vbaranov
Copy link
Member

@vbaranov vbaranov commented Nov 10, 2023

#8758
Resolves #8760
Resolves #8761

Motivation

Refactor proxy smart-contracts detection and add missing proxy standards

Changelog

  • Combine all proxy standards in apps/explorer/lib/explorer/chain/smart_contract/proxy path:

Screenshot 2023-11-13 at 10 41 46

  • Move related to smart contracts logic from Explorer.Chain to Explorer.Chain.SmartContract.
  • Move related to proxy smart contracts logic from Explorer.Chain to Explorer.Chain.SmartContract.Proxy.
  • Add support of EIP-1822 Universal Upgradeable Proxy Standard (UUPS)
  • Add support of EIP-930 Eternal Storage Standard.
  • Add specifications and description for public functions in SmartContract, Proxy modules.
  • Refactor logic of those functions and rename to more precisely reflect their actions.

Checklist for your Pull Request (PR)

@vbaranov vbaranov added the wip label Nov 10, 2023
@vbaranov vbaranov force-pushed the vb-enhance-gnosis-safe-proxy branch 20 times, most recently from db6e3d0 to 1d364fe Compare November 13, 2023 07:43
@vbaranov vbaranov force-pushed the vb-enhance-gnosis-safe-proxy branch 7 times, most recently from 4a77a03 to c649899 Compare November 13, 2023 11:17
@vbaranov vbaranov removed the wip label Nov 13, 2023
@vbaranov vbaranov force-pushed the vb-enhance-gnosis-safe-proxy branch 2 times, most recently from 060fb6f to 7026ef9 Compare November 13, 2023 14:18
apps/explorer/lib/explorer/chain/block/reward.ex Outdated Show resolved Hide resolved
apps/explorer/lib/explorer/chain/smart_contract.ex Outdated Show resolved Hide resolved
apps/explorer/lib/explorer/chain/smart_contract.ex Outdated Show resolved Hide resolved
apps/explorer/lib/explorer/chain/smart_contract.ex Outdated Show resolved Hide resolved
apps/explorer/lib/explorer/chain/smart_contract.ex Outdated Show resolved Hide resolved
apps/explorer/lib/explorer/chain/smart_contract.ex Outdated Show resolved Hide resolved
apps/explorer/lib/explorer/chain/smart_contract.ex Outdated Show resolved Hide resolved
@vbaranov vbaranov force-pushed the vb-enhance-gnosis-safe-proxy branch from 680dbad to 3cca119 Compare November 14, 2023 09:47
apps/explorer/lib/explorer/chain/smart_contract.ex Outdated Show resolved Hide resolved
apps/explorer/lib/explorer/chain.ex Show resolved Hide resolved
apps/explorer/lib/explorer/chain/address/name.ex Outdated Show resolved Hide resolved
apps/explorer/lib/explorer/chain/smart_contract/proxy.ex Outdated Show resolved Hide resolved
@vbaranov vbaranov force-pushed the vb-enhance-gnosis-safe-proxy branch from 81c9e2b to d419fd1 Compare November 15, 2023 12:21
@vbaranov vbaranov force-pushed the vb-enhance-gnosis-safe-proxy branch from 62b4e6c to fff31fe Compare November 15, 2023 13:11
@nikitosing nikitosing force-pushed the vb-enhance-gnosis-safe-proxy branch from 731e32f to f8782d0 Compare November 15, 2023 15:24
@vbaranov vbaranov requested a review from nikitosing November 15, 2023 19:28
Comment on lines +567 to +570
def save_implementation_data(nil, _, _, _), do: {nil, nil}

{:ok, implementation_address} =
case Contract.eth_get_storage_at_request(
proxy_address_hash,
master_copy_storage_pointer,
nil,
json_rpc_named_arguments
) do
{:ok, empty_address}
when is_burn_signature(empty_address) ->
{:ok, "0x"}

{:ok, logic_contract_address} ->
{:ok, logic_contract_address}

_ ->
{:ok, nil}
end

abi_decode_address_output(implementation_address)
end

defp save_implementation_data(nil, _, _, _), do: {nil, nil}

defp save_implementation_data(empty_address_hash_string, proxy_address_hash, metadata_from_verified_twin, options)
when is_burn_signature_extended(empty_address_hash_string) do
def save_implementation_data(empty_address_hash_string, proxy_address_hash, metadata_from_verified_twin, options)
when is_burn_signature_extended(empty_address_hash_string) do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we union these 2 caluses to:

def save_implementation_data(empty_address_hash_string, proxy_address_hash, metadata_from_verified_twin, options)
      when is_burn_signature_extended(empty_address_hash_string) or is_nil(empty_address_hash_string) do

It will allow us to save implementation_fetched_at for nil cases

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest doing this in frame of a separate PR. Currently, I have doubts to implement this in suggested maneer. Anyways, changes in this PR don't touch this logic and targeted to solve other (not performance) problems. Please, create an issue for the case you're reffering to.

@vbaranov vbaranov requested a review from nikitosing November 16, 2023 09:36
@vbaranov vbaranov merged commit f268c1c into master Nov 16, 2023
41 checks passed
@vbaranov vbaranov deleted the vb-enhance-gnosis-safe-proxy branch November 16, 2023 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants