Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

AssertionError type(self.address) == int when deploying Account #308

Closed
ericglau opened this issue Nov 24, 2022 · 3 comments · Fixed by #320
Closed

AssertionError type(self.address) == int when deploying Account #308

ericglau opened this issue Nov 24, 2022 · 3 comments · Fixed by #320
Assignees
Milestone

Comments

@ericglau
Copy link
Member

ericglau commented Nov 24, 2022

Summary

From a script:

  • if await Account(signer, nre.network, watch_mode="track") is called, the account does not seem to get created.
  • if await Account(signer, nre.network) is called, there is an error the first time, but it succeeds the second time.

Sample project

https://github.com/ericglau/nile-account-test

To reproduce

  1. Run nile init to create a new project with Nile v0.11
  2. Start a node with nile node
  3. Create a script with
from nile.core.account import Account

async def run(nre):
    signer = "PRIVATE_KEY"
    await Account(signer, nre.network, watch_mode="track")
  1. Run the script with nile run <script>. Script returns but localhost.accounts.json and localhost.deployments.txt are empty.
  2. Remove , watch_mode="track" from the script
  3. Run the script with nile run <script>. Script fails with
Traceback (most recent call last):
  File "/Users/eric/git/nileproj3/env/bin/nile", line 8, in <module>
    sys.exit(cli())
  File "/Users/eric/git/nileproj3/env/lib/python3.9/site-packages/asyncclick/core.py", line 1157, in __call__
    return anyio.run(self._main, main, args, kwargs, **opts)
  File "/Users/eric/git/nileproj3/env/lib/python3.9/site-packages/anyio/_core/_eventloop.py", line 70, in run
    return asynclib.run(func, *args, **backend_options)
  File "/Users/eric/git/nileproj3/env/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 292, in run
    return native_run(wrapper(), debug=debug)
  File "/opt/homebrew/Cellar/python@3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/opt/homebrew/Cellar/python@3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/Users/eric/git/nileproj3/env/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 287, in wrapper
    return await func(*args)
  File "/Users/eric/git/nileproj3/env/lib/python3.9/site-packages/asyncclick/core.py", line 1160, in _main
    return await main(*args, **kwargs)
  File "/Users/eric/git/nileproj3/env/lib/python3.9/site-packages/asyncclick/core.py", line 1076, in main
    rv = await self.invoke(ctx)
  File "/Users/eric/git/nileproj3/env/lib/python3.9/site-packages/asyncclick/core.py", line 1687, in invoke
    return await _process_result(await sub_ctx.command.invoke(sub_ctx))
  File "/Users/eric/git/nileproj3/env/lib/python3.9/site-packages/asyncclick/core.py", line 1434, in invoke
    return await ctx.invoke(self.callback, **ctx.params)
  File "/Users/eric/git/nileproj3/env/lib/python3.9/site-packages/asyncclick/core.py", line 780, in invoke
    rv = await rv
  File "/Users/eric/git/nileproj3/env/lib/python3.9/site-packages/nile/cli.py", line 94, in run
    await run_command(path, network)
  File "/Users/eric/git/nileproj3/env/lib/python3.9/site-packages/nile/core/run.py", line 14, in run
    await script.run(nre)
  File "scripts/run.py", line 6, in run
    await Account(signer, nre.network)
  File "/Users/eric/git/nileproj3/env/lib/python3.9/site-packages/nile/core/account.py", line 40, in __new__
    await instance.__init__(*a, **kw)
  File "/Users/eric/git/nileproj3/env/lib/python3.9/site-packages/nile/core/account.py", line 104, in __init__
    assert type(self.address) == int
AssertionError
  1. Run the script again. Script passes and localhost.accounts.json and localhost.deployments.txt have the account.
@martriay martriay moved this to 📋 Backlog in Cairo team Nov 25, 2022
@ericglau ericglau changed the title Error deploying Account from script AssertionError type(self.address) == int when deploying Account Nov 25, 2022
@martriay
Copy link
Contributor

I think this is fixed by #301, will look into it to confirm.

@martriay martriay added this to the current milestone Nov 26, 2022
@ericnordelo ericnordelo moved this from 📋 Backlog to 🏗 In progress in Cairo team Nov 28, 2022
@ericnordelo
Copy link
Member

ericnordelo commented Nov 28, 2022

It is partially fixed @martriay, because the assertion issue is fixed.

But the real issue here is the integration of the status command with NRE. watch_mode option in NRE is doing the same thing that in CLI, is logging the information, and returning an empty response. But NRE doesn't process the logging output, so basically, watch_mode is just returning an empty account object, without address, and not registered, instead of returning the transaction status somehow (this is when the transaction fails, like when the account is not declared).

@ericglau confusion is completely justified, but this is not a quick fix. I suggest removing the watch_mode option from NRE commands and handling this integration properly in another issue.

@martriay
Copy link
Contributor

martriay commented Dec 5, 2022

Partially fixed by #301, will be fully fixed by #320.

@martriay martriay closed this as completed Dec 5, 2022
Repository owner moved this from 👀 In review to ✅ Resolved in Cairo team Dec 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Archived in project
3 participants