Skip to content

Migrate immutable values for test contract #1079

@popzxc

Description

@popzxc

Component

Forge

Describe the bug

#1078 introduced a fix for test contract not being available in EraVM context.
However, it has a bug: immutable values are not migrated for it.

To reproduce, remote the #[ignore] attribute on the test_zk_can_invoke_test_contract_with_immutables test added in the abovementioned PR -- it will fail.

The exact approach to fix the bug is not clear. I see two options:

  1. Try to deduce the slots for ImmutableSimulator based on deployed bytecode and immutable references. Not sure if it's possible: zksolc assigns slots for the simulator based on the order in which values are assigned, not declared, and AFAIU we can't get this information easily.
  2. Try to deploy the contract in the EraVM context and check which slots will be set. This feels error-prone, since a lot of factors can cause different values for immutables between EraVM and EVM. If we're going to go this way, I would probably suggest to add a safety check: after getting immutables for EraVM contract, extract values from deployed EVM contract and ensure that set(eravm_immutable_values) == set(evm_immutable_values).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't workingneeds triage ♟️Issue needs to be picked up or assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions