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

bug: patched Environment import trigger errors in apply_body #671

Closed
Eikix opened this issue Feb 6, 2025 · 0 comments · Fixed by #672
Closed

bug: patched Environment import trigger errors in apply_body #671

Eikix opened this issue Feb 6, 2025 · 0 comments · Fixed by #672

Comments

@Eikix
Copy link
Member

Eikix commented Feb 6, 2025

Context:

apply_body code has:

system_tx_env = vm.Environment(
            caller=SYSTEM_ADDRESS,
            origin=SYSTEM_ADDRESS,
            block_hashes=block_hashes,
            coinbase=coinbase,
            number=block_number,
            gas_limit=block_gas_limit,
            base_fee_per_gas=base_fee_per_gas,
            gas_price=base_fee_per_gas,
            time=block_time,
            prev_randao=prev_randao,
            state=state,
            chain_id=chain_id,
            traces=[],
            excess_blob_gas=excess_blob_gas,
            blob_versioned_hashes=(),
            transient_storage=TransientStorage(),
        )

But Environment from args_gen does not have traces field.


# All these classes are auto-patched in test imports in cairo/tests/conftests.py
@dataclass
class Environment(
    make_dataclass(
        "Environment",
        [(f.name, f.type, f) for f in fields(EnvironmentBase) if f.name != "traces"],
        namespace={"__doc__": EnvironmentBase.__doc__},
    )
):
    def __eq__(self, other):
        return all(
            getattr(self, field.name) == getattr(other, field.name)
            for field in fields(self)
        )

This triggers an error "Trying to call init on Environment with unknown field traces"

Problem

We patched all imports of Environment to take our redefined class. This applies to inner code of EELS too. This forces us to make sure our modified types have the same fields as EELS classes.

Proposed fix

Stop removing traces field from the modified class and skip it in serialization into cairo altogether

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

Successfully merging a pull request may close this issue.

1 participant