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

System contracts are not displayed as contracts in the UI. #358

Open
vasyl-ivanchuk opened this issue Dec 15, 2024 · 0 comments
Open

System contracts are not displayed as contracts in the UI. #358

vasyl-ivanchuk opened this issue Dec 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@vasyl-ivanchuk
Copy link
Collaborator

🐛 Bug Report

📝 Description:

System contracts are not displayed as contracts in the UI until they have been updated.
Here is how the explorer works now:

  1. It parses transaction logs and searches for ContractDeployed events.
  2. When a ContractDeployed event is found, it extracts the address of the deployed contract from the log, fetches additional data from the network (e.g., bytecode), and stores it as a contract record in the DB.
  3. In the UI, when an address is opened, general information such as balances, transactions, and transfers is shown. If the address is a contract (i.e., there is a contract record for that address), additional contract information is displayed, including the Contract and Events tabs.

Unfortunately, system contracts created during genesis are not created with a transaction, so there is no ContractDeployed log. This means they won’t be added to the database and won’t appear as contracts.
However, when system contracts are updated, a transaction containing ContractDeployed events is created, and these events are picked up by the explorer.

🔄 Reproduction Steps:

  1. Spin up a new local node environment (network + explorer).
  2. Make sure that the explorer is up and running and indexed all existing data.
  3. Open any system contract address (e. g. ContractDeployer: http://localhost:3010/address/0x0000000000000000000000000000000000008006) and check that the address page doesn't show a Contract and Events tabs:
image

🤔 Expected Behavior:

Describe what you expected to happen:

System contracts to be shown as contracts from the very beginning, even if they haven't been updated.

🤔 Possible fix:

The caveat here is that the fix should be executed on the existing environments. Since there is no functionality that runs migration scripts with the initialized blockchain provider, we need either to add it (which is out of scope for this bug) or fix it differently.

One possible way to fix the problem is as follows:

  1. Add a new service to the worker, where OnModuleInit it will request system contracts from the DB. For those that do not exist in the DB, it will use the blockchain service to fetch data about them and add them to the DB.
  2. Since contracts created in step 1 won't have a createdInBlockNumber, creatorTxHash, createdInLogIndex, or creatorAddress, we need to fix the UI to properly display contracts without these fields.
@vasyl-ivanchuk vasyl-ivanchuk added the bug Something isn't working label Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant