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

Predictor #440

Open
wants to merge 19 commits into
base: development
Choose a base branch
from
Open

Predictor #440

wants to merge 19 commits into from

Conversation

jjmr007
Copy link
Contributor

@jjmr007 jjmr007 commented May 23, 2022

Links to:

Need for this PR
Description how it works

Script to help to predict if a bytecode in a deployed contract will correspond to the locally compiled bytecode.

@@ -0,0 +1,59 @@
# WHAT IS THIS SCRIPT SET FOR?

This set of scripts is intended to help devs to find out if the contracts of a given commit / branch in a repo will reproduce exactly the contracts deployed in the blockchain.
Copy link
Contributor

@tjcloa tjcloa Jun 8, 2022

Choose a reason for hiding this comment

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

This set of scripts is intended to help devs to find out if the contracts ABI of a given commit / branch in a repo correspond to the contracts deployed in the blockchain.


This set of scripts is intended to help devs to find out if the contracts of a given commit / branch in a repo will reproduce exactly the contracts deployed in the blockchain.
These scripts are categorized into four .js files for convenient separate execution.
This can be used as a tool to predict if the contract code in certain repo / branch / commit will verify in a block explorer.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This can be used as a tool to predict if the contract code in certain repo / branch / commit will verify in a block explorer.
This can be used as a tool to identify if the contract code in certain repo / branch / commit will verify in a block explorer.


The folder ./scripts/predictor have four .js files and may have several .json files, but one them is invariant: contract_config.json

These scripts will work only provided that there exist a folder in the repo named ./scripts/contractInteraction contentive of the .json files listing all the Sovryn's deployed contracts.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
These scripts will work only provided that there exist a folder in the repo named ./scripts/contractInteraction contentive of the .json files listing all the Sovryn's deployed contracts.
These scripts will work only provided that there exists a folder in the repo named ./scripts/contractInteraction contentive of the .json files listing all the Sovryn's deployed contracts.

pls consider putting all settings - paths etc. in e.g. .deployment-verifier.json or .ts/.js

## How to Use These Scripts

1. Clone locally the smart contracts git repo.
2. Install the dependencies as instructed in the RAEADME.md file of that repo.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
2. Install the dependencies as instructed in the RAEADME.md file of that repo.
2. Install the dependencies as instructed in the README.md file of that repo.

$ node createJSON
```

After this, files like `m_deployed_compiled.json` mut be present. Be ware that if there was a previous .json file with that name, this script will overwrite it.
Copy link
Contributor

Choose a reason for hiding this comment

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

pls consider adding it as parameter to cover cases when you can add an external ABI manually and those won't be overwritten

$ node createJSON
```

After this, files like `m_deployed_compiled.json` mut be present. Be ware that if there was a previous .json file with that name, this script will overwrite it.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
After this, files like `m_deployed_compiled.json` mut be present. Be ware that if there was a previous .json file with that name, this script will overwrite it.
After this, files like `m_deployed_compiled.json` mut be present. Beware that if there was a previous .json file with that name, this script will overwrite it.

```
$ node findFiles
```
This will fill the dump files with the paths of the files with the conpiled bytecodes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This will fill the dump files with the paths of the files with the conpiled bytecodes.
This will fill the dump files with the paths of the files with the compiled bytecodes.

Comment on lines +30 to +32
4. `./scripts/predictor/contract_config.json` can be edited to extend it. Be ware that the info must be precise or the script may fail with unexpected errors.
5. Check the info in folder `./scripts/contractInteraction` and make sure that at least that the files `mainnet_contracts.json` and `testnet_contracts.json` are present with the relevant info. These files are expected to contain as accurate and complete information as possible, about contract deployments on chain.
6. Go to the folder `./scripts/predictor` and execute:
Copy link
Contributor

@tjcloa tjcloa Jun 8, 2022

Choose a reason for hiding this comment

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

pls consider adding paths to a config like .deployment-verifier.json

# WHAT IS THIS SCRIPT SET FOR?

This set of scripts is intended to help devs to find out if the contracts of a given commit / branch in a repo will reproduce exactly the contracts deployed in the blockchain.
These scripts are categorized into four .js files for convenient separate execution.
Copy link
Contributor

Choose a reason for hiding this comment

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

pls add a high level schematic description of how it works as a sequence of steps like

  1. provide/generate ABIs and bytecodes of the contracts you want to verify
  2. provide contracts addresses
  3. run comparator script on a blockchain (provide as parameter) to get the list of contracts which ABIs correspond to the deployed contracts meaning that they will be successfully verified in the blockchain explorers

Copy link
Contributor

Choose a reason for hiding this comment

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

btw can it be extended with automatic verifier? :)

Copy link
Contributor

@tjcloa tjcloa left a comment

Choose a reason for hiding this comment

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

pls see inline comments
also pls run the README.md text through grammarly or similar to tackle typos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants