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

apply HH-verify input simplification #706

Closed
kanej opened this issue Feb 28, 2024 · 4 comments · Fixed by #712
Closed

apply HH-verify input simplification #706

kanej opened this issue Feb 28, 2024 · 4 comments · Fixed by #712
Assignees
Labels
status:ready This issue is ready to be worked on

Comments

@kanej
Copy link
Member

kanej commented Feb 28, 2024

The build info used for the input to Etherscan during verification can include extraneous files for the compilation of the contract.
In Hardhat verify there is a simplification step that is attempted to reduce the nubmer of files that have to be sent to Etherscan.
We should replicate this behaviour in Ignition's verify logic.

Questions

  1. Can we get an outline of the HH-verify logic for simplifying the input to Etherscan, to determine if we can replicate it in general
  2. Is it possible to reuse the HH-verify logic directly by applying it to the Etherscan class that is programmatically exposed?
  3. How should Ignition, with its pre-saved artifacts and build infos recreate this behaviour?
@kanej kanej added status:ready This issue is ready to be worked on and removed status:triaging labels Feb 28, 2024
@kanej kanej moved this to Todo in Hardhat Ignition Feb 28, 2024
@zoeyTM zoeyTM self-assigned this Feb 29, 2024
@zoeyTM zoeyTM moved this from Todo to In Progress in Hardhat Ignition Feb 29, 2024
@alcuadrado
Copy link
Member

  • Can we get an outline of the HH-verify logic for simplifying the input to Etherscan, to determine if we can replicate it in general

The pseudocode would be:

verify(contract, minifyInput):
     const buildInfo = getBuildInfoOfContractFromDeploymentArtifacts(contract);
     const fullInput = buildInfo.input;
     
     const input = minifyInput ? minifyInput(contract, buildInfo.input) : buildInfo.input;
     
     verifyOnEtherscan(contract, input)
     
minifyInput(contract, input):
   const newInput = {...};
   const filesToProcess = emptyQueue();
   filesToProcess.push(findContractFileInInput(contract, input))
   
   while !filesToProcess.isEmpty()
         const file = filesToProcess.pop();
         newInput.add(file)
         
         const dependencies = file.getResolvedImports();
         for (dep in dependencies)
              if not in newInput:
                  filesToProcess.push(dep)
  • Is it possible to reuse the HH-verify logic directly by applying it to the Etherscan class that is programmatically exposed?

I don't think we'd be able to reuse the entire logic, because as hh-verify gets its input from the contracts/ folder instead of the deployment artifacts, it can reuse the compilation subtasks, which ignition can't.

  • How should Ignition, with its pre-saved artifacts and build infos recreate this behaviour?

Yes

@alcuadrado
Copy link
Member

getResolvedImports means two things:

  1. extracting the inputs with solidity-analyzer
  2. Resolving any relative path

@kanej
Copy link
Member Author

kanej commented Mar 4, 2024

getResolvedImports means two things:

1. extracting the inputs with `solidity-analyzer`

2. Resolving any relative path

Just to clarify. You would approach this by recreating the logic locally with solidity-analyer rather than trying to reuse internals from HH?

@alcuadrado
Copy link
Member

getResolvedImports means two things:

1. extracting the inputs with `solidity-analyzer`

2. Resolving any relative path

Just to clarify. You would approach this by recreating the logic locally with solidity-analyer rather than trying to reuse internals from HH?

Yes, because that logic is not present "as is" in the other plugin.

@zoeyTM zoeyTM moved this from In Progress to In Review in Hardhat Ignition Mar 13, 2024
@github-project-automation github-project-automation bot moved this from In Review to Done in Hardhat Ignition Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants