tezos-checker / checker

An in-development "robocoin" system for the Tezos blockchain
24 stars 16 forks source link

Update client to better handle deployment to non-sandbox networks #139

Closed dorranh closed 3 years ago

dorranh commented 3 years ago

Enables the client to deploy to remote nodes / real networks and fixes a variety of stability issues causing timeout errors, etc.

gkaracha commented 3 years ago

@dorranh I am facing the following error locally when trying to deploy. Have you come across it before?

$ checker sandbox start
Starting sandbox container using host port 18731...
Sandbox started.

$ checker deploy mock-oracle
Connecting to tezos node at: http://127.0.0.1:18731
Detected block time: ['5']
('Not found: /chains/main/blocks/head-55/hash',)
('Not found: /chains/main/blocks/head-55/hash',)
('Not found: /chains/main/blocks/head-55/hash',)
('Not found: /chains/main/blocks/head-55/hash',)
Traceback (most recent call last):
  File "/nix/store/kfszfw0zbzfa3l5cdfpq36178hlba36a-python3.8-checker-client-0.1.0/bin/.checker-wrapped", line 9, in <module>
    sys.exit(cli())
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/checker_client/cli.py", line 254, in mock_oracle
    oracle = checker_lib.deploy_contract(
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/checker_client/checker.py", line 83, in deploy_contract
    tz.origination(script, balance=initial_balance)
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/pytezos/operation/group.py", line 219, in autofill
    opg = self.fill(counter=counter, ttl=ttl)
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/pytezos/operation/group.py", line 109, in fill
    branch = self.branch or self.shell.blocks[f'head-{MAX_OPERATIONS_TTL - ttl}'].hash()
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/pytezos/rpc/query.py", line 99, in __call__
    return self.node.get(
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/pytezos/rpc/node.py", line 27, in wrapper
    raise e
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/pytezos/rpc/node.py", line 24, in wrapper
    return fn(*args, **kwargs)
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/pytezos/rpc/node.py", line 139, in get
    return self.request('GET', path, params=params, timeout=timeout).json()
  File "/nix/store/fgiqzm4vvbyylq6nnbmww0dghg42r26a-python3-3.8.9-env/lib/python3.8/site-packages/pytezos/rpc/node.py", line 129, in request
    raise RpcError(f'Not found: {path}')
pytezos.rpc.node.RpcError: ('Not found: /chains/main/blocks/head-55/hash',)
utdemir commented 3 years ago

@gkaracha I feel like this might be about removing branch_offset parameter. For some reason pytezos only works with chains with at least 55 blocks, which is not the case if you run the sandbox straightaway. We can confirm this by waiting for 55*5 seconds after spinning up the sandbox and trying again :). We might need to introduce that branch_offset parameter again. Also, it seems to be deprecated and replaced with ttl with different semantics, so we probably should figure out how to use that one.

gkaracha commented 3 years ago

@utdemir You're right, after waiting long enough (it certainly felt more than 55 * 5) it worked :+1: I'll try restoring branch_offset locally and see if it works then, thanks!

gkaracha commented 3 years ago

Yeah, restoring all the branch_offset=1 does make some deployments work, but it brings back all those occasional Timeouts. You're right, I'll have a look at how to use ttl instead.

dorranh commented 3 years ago

@utdemir @gkaracha, I think this is actually a pytezos bug. Digging into it now.

dorranh commented 3 years ago

Going to go ahead and merge since the sandbox issue seems to be fixed now and following my discussion this morning with @utdemir

gkaracha commented 3 years ago

Nice! I confirm that it works for me locally as well :tada: