Skip to content

✨ Feature: Replace hardhatExec with Hardcoded Bytecode Deployment in testUtils #100

@joepegler

Description

@joepegler

Feature or Improvement Description

Remove the hardhatExec functionality from the testUtils file and replace it with hardcoded bytecode deployment using setCode on the Anvil instance. Add K1_VALIDATOR_FACTORY_BYTECODE, K1_VALIDATOR_BYTECODE, and NEXUS_IMPLEMENTATION_BYTECODE to callData.ts.

Benefits & Outcomes

  • Enable our code to be included in viem's repository for testing purposes
  • Simplify the testing setup by removing the dependency on hardhat execution
  • Improve test reliability by using consistent, hardcoded bytecode
  • Reduce external dependencies in the testing process
  • Speed up test execution by eliminating the need for hardhat compilation and deployment

Implementation Ideas

  1. Remove hardhatExec imports and related functions from testUtils.ts

  2. Add new constants to callData.ts:

    export const K1_VALIDATOR_FACTORY_BYTECODE: Hex = "0x..."
    export const K1_VALIDATOR_BYTECODE: Hex = "0x..."
    export const NEXUS_IMPLEMENTATION_BYTECODE: Hex = "0x..."

    (Fetch these bytecodes from the Base Sepolia explorer)

  3. Update the initDeployments function in testUtils.ts:

    • Remove calls to hardhatExec.init() and hardhatExec.deploy()
    • Implement setCode calls using the new bytecode constants:
      await testClient.setCode({
        address: K1_VALIDATOR_FACTORY_ADDRESS,
        bytecode: K1_VALIDATOR_FACTORY_BYTECODE
      })
      // Repeat for K1_VALIDATOR and NEXUS_IMPLEMENTATION
  4. Update any other functions in testUtils.ts that relied on hardhatExec

  5. Modify the toConfiguredAnvil function to remove any hardhat-specific configurations

  6. Update unit tests to reflect the new deployment method

  7. Verify that all tests pass with the new bytecode deployment method

  8. Update documentation to reflect the changes in the testing setup

  9. Remove any remaining hardhat dependencies that are no longer needed

References

Any References?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions