Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.

Update chainweb development version#92

Open
larskuhtz wants to merge 6 commits intomainfrom
evm/lars/update-development-version
Open

Update chainweb development version#92
larskuhtz wants to merge 6 commits intomainfrom
evm/lars/update-development-version

Conversation

@larskuhtz
Copy link
Contributor

@larskuhtz larskuhtz commented Oct 15, 2025

This PR upgrades the sandbox to the latest version of the evm/main branch of chainweb-node:

  • Fixes the internal chainweb-node version code for eve-development. In previous versions it collided with the version code of the evm-testnet, which could cause issues in some scenarios.
  • Add test cases for the availability of the CREATE2 factory system contract that is pre-deployed at genesis in evm-development networks, which include the sandbox network.
  • Update the chain-spec files to reflect the changes to genesis.
  • Increase some outer timeouts on tests to make them more consistent with inner timeouts.

CREATE2 Factory System Contract

The provided CREATE2 factory is well known and widely used across the Ethereum ecosystem. It is deterministically deployed at address 0x4e59b44847b379578588920cA78FbF26c0B4956C.

The factory contract is very minimalistic, which suites its use as a preinstalled system contract. It does not use ABI encoding. The contract is called with the 32 bytes of the salt followed by the contract initialization code as the only parameter. It returns the deployment address of the contract.

The availability in the sandbox network can be tested via:

./network devnet pull
./network devnet start
./network solidity test --chainweb sandbox ./test/Create2.test.js

There is a PR that adds support to the hardhat-kadena-plugin. By using this branch one can run the tests directly on the hardhat network via ./network solidity test.

Foundry provides this CREATE2 factory out of the box. The contract is also available on all EVM chains in the Kadena EVM testnet.

@larskuhtz larskuhtz force-pushed the evm/lars/update-development-version branch from 07f434a to 66b5383 Compare October 16, 2025 03:28
Copy link
Contributor

@hswopeams hswopeams left a comment

Choose a reason for hiding this comment

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

Looks mostly OK. There are a few changes that need to be made in the test file.

const { hexlify } = require('ethers');
const { switchChain, getChainIds } = chainweb;

const CREATE2_DEPLOYER = '0x4e59b44847b379578588920cA78FbF26c0B4956C';
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be called CREATE2_FACTORY. That is the standard name for this type of factory.

const initCode = ethers.concat([SimpleToken.bytecode, encodedConstructorArgs]);

// Expected address
const address = ethers.getCreate2Address(
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be called predictedAddress. It gets set in the contract object, and it looks as if this is an actual deployed address. I had to keep going back to look at the before code to see what that address actually is.

const contract = contracts.find(d => d.chain === chain);
const signers = await getSigners(chain);
const deployer = signers.deployer;
const address = await deployer.call({
Copy link
Contributor

@hswopeams hswopeams Oct 17, 2025

Choose a reason for hiding this comment

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

It's odd and not standard to use deployer.call in this situation. sendTransaction should be used. Something like this:

 // Use the predicted address computed in the `before` hook
      const predicted = contract.address;

      console.log(`Deploying SimpleToken on chain ${chain} via CREATE2 factory (normal sendTransaction)... predicted: ${predicted}`);
      const tx = await deployer.sendTransaction({
        to: CREATE2_DEPLOYER,
        data: ethers.concat([contract.salt, contract.initCode]),
      });

      const receipt = await tx.wait();
      expect(receipt.status).to.equal(1);

      // Verify deployed code exists at the predicted address
      const deployedCode = await deployer.provider.getCode(predicted);
      expect(deployedCode).to.not.equal('0x');

it('Should have deployed code at the address', async function () {
await chainweb.runOverChains(async (chain) => {
const contract = contracts.find(d => d.chain === chain);
const deployedCode = await ethers.provider.getCode(contract.address);
Copy link
Contributor

Choose a reason for hiding this comment

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

There shouldn't be any deployedCode at this address. The before hook doesn't actually deploy. This test case appears to rely on state from previous test cases. That violates unit testing principles. Each unit test must be isolated from other test cases. The before hook should be a beforeEach hook to ensure a clean slate for each test case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants