Skip to content

TypeError: ZksyncEnv.execute_code() missing 'simulate' parameter compatibility with anvil-zksync #271

@dettriva

Description

@dettriva

Bug Description

Contract deployment works correctly on anvil-zksync, but any subsequent function calls (both view and state-changing functions) fail with TypeError: ZksyncEnv.execute_code() got an unexpected keyword argument 'simulate'. This prevents any post-deployment interaction with contracts on ZKsync networks.

Environment

  • Moccasin version: v0.4.2
  • anvil-zksync version: 0.6.9
  • OS: Ubuntu 22.04 (WSL on Windows 11)
  • Network: eravm (anvil-zksync)
  • Python: 3.13

Steps to Reproduce

  1. Setup: Configure anvil-zksync network in moccasin.toml:

    [networks.eravm]
    url = "http://localhost:8011"
    chain_id = 260
    is_zksync = true
  2. Deploy contract:

    mox run deploy --network eravm

    This works successfully - contract deploys without issues

  3. Try to interact with deployed contract:

    mox console --network eravm
    import boa
    contract = boa.load("src/favorites.vy")
    contract.retrieve()  # This fails
  4. Error occurs on any function call attempt

Expected Behavior

Contract functions should execute normally after successful deployment, allowing full interaction with deployed contracts.

Actual Behavior

TypeError: ZksyncEnv.execute_code() got an unexpected keyword argument 'simulate'

Full Error Stack Trace

File "/home/daniele/.local/share/uv/tools/moccasin/lib/python3.13/site-packages/boa/contracts/abi/abi_contract.py", line 128, in __call__
  computation = self.contract.env.execute_code(
      to_address=self.contract.address,
  ...<6 lines>...
      contract=self.contract,
  )
TypeError: ZksyncEnv.execute_code() got an unexpected keyword argument 'simulate'

Code Sample

Working deployment script (script/deploy.py):

import boa

def deploy_favorites():
    favorites_contract = boa.load("src/favorites.vy")
    
    # This line fails with the 'simulate' error:
    starting_number: int = favorites_contract.retrieve()
    print(f"The starting number is: {starting_number}")
    
    return favorites_contract

def moccasin_main():
    return deploy_favorites()

Contract (src/favorites.vy):

# pragma version 0.4.3

my_favorite_number: uint256

@deploy
def __init__():
    self.my_favorite_number = 7

@external
@view
def retrieve() -> uint256:
    return self.my_favorite_number

@external
def store(favorite_number: uint256):
    self.my_favorite_number = favorite_number

Successful Deployment Evidence

  • Transaction Hash: 0xcc000352d2e39b0fbfe2b07dc8185d347f235f94a15f6e681d34e7ecf0472165
  • Contract Address: 0x588758d8a0Ad1162A6294f3C274753137E664aE0
  • Gas Used: 682,947 / 1,192,652

Current Workaround

Remove all post-deployment function calls from deployment scripts:

def deploy_favorites():
    favorites_contract = boa.load("src/favorites.vy")
    
    # Comment out function calls to avoid the error
    # starting_number: int = favorites_contract.retrieve()
    # print(f"The starting number is: {starting_number}")
    
    print(f"Contract deployed at: {favorites_contract.address}")
    return favorites_contract

Additional Notes

  • The issue affects both boa.load() and favorites.deploy() methods
  • All contract function calls fail (view functions, state-changing functions)
  • The deployment process itself works perfectly
  • Moccasin works correctly with standard anvil (non-ZKsync)
  • This appears to be a compatibility issue between Moccasin v0.4.2 and anvil-zksync 0.6.9

Impact

This bug prevents any meaningful development workflow with ZKsync contracts in Moccasin, as developers cannot test or interact with their deployed contracts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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