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

Allow debots to get data from main net smart contracts without deploying them main net #58

Open
NoamDev opened this issue Aug 21, 2021 · 7 comments
Labels
enhancement New feature or request Fixed Issue fixed, closed soon

Comments

@NoamDev
Copy link
Contributor

NoamDev commented Aug 21, 2021

Some DeBots, need to get data from main net smart contracts, however I don't want to pay deployment fees each time I change something in the debot code.
I think there's a need to allow running a debot that will interact with main net without deploying it to main net.

@NoamDev
Copy link
Contributor Author

NoamDev commented Aug 21, 2021

I have three ideas of how to implement this.
A) Run the debot without deploying at all. Requires generating contract data and hacking the debot browser to run the debot without downloading it.
B) Create a dapp proxy that will pass requests regarding this debot address to tonos se while redirecting all other requests to main.ton.dev.
C) Downloading the required contracts from main net in advance and deploy them to tonos se.

@lefessan lefessan added the enhancement New feature or request label Aug 23, 2021
@lefessan
Copy link
Member

ft is currently not able to run debots. The reason is that, to run a debot, it would require to call OCaml from Rust (for example, to give access to wallet keys in the debot), and we haven't tested that with the current OCaml-Rust binding. Yet, the proposed feature would be a "must-have" feature when we start implementing debots.

@lefessan
Copy link
Member

I finally decided to give it a try. Here is what I have:

  • Download tonos-cli from https://github.com/lefessan/tonos-cli, branch z-2021-08-23-debot-from-boc
  • Set DEBOT_BOC_PRINT=1 in your environment, run the debot from TONOS SE , it should print the BOC it is using
  • Set DEBOT_BOC=XXX where XXX is the printed BOC value, run the debot on another network, it should print "Using state from DEBOT_BOC" and run the debot with the saved state but on the new network...

@NoamDev
Copy link
Contributor Author

NoamDev commented Aug 29, 2021

Hey @lefessan, I was finally able to test the hack thoroughly, it has a problem.
since you simply always return DEBOT_BOC whenever load_state is called, you are also preventing any getters on other smart contracts from being run locally.
I think checking if the address requested is the address of the running debot would solve this problem.
It's a good start though:)

@lefessan
Copy link
Member

Indeed. I have uploaded a new version (should just need to call cargo update before cargo build in tonos-cli same branch). This time, the BOC of the debot is extracted from env variable DEBOT_XXX for address 0:XXX. DEBOT_BOC_PRINT=1 should display the name of that variable.

@lefessan
Copy link
Member

And another version:

  • If $DEBOT_SAVE_DIR is defined, it will save the debot state in that directory (under name DEBOT_XXX.boc, where 0:XXX is the debot address)
  • If $DEBOT_LOAD_DIR is defined, it will load the debot state from that directory (from name DEBOT_XXX.boc)

@lefessan
Copy link
Member

lefessan commented Sep 6, 2021

Latest version of ft automatically supports this behavior (since commit b117b28), using ft debot fetch --boc-from NETWORK ADDR (where ADDR is the debot address on NETWORK). It will automatically download the BOC, save it in $DEBOT_LOAD_DIR and set the env var before calling tonos-cli. However, you need to have the patched version of tonos-cli in $HOME/.ft/bin/.

@lefessan lefessan added the Fixed Issue fixed, closed soon label Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Fixed Issue fixed, closed soon
Projects
None yet
Development

No branches or pull requests

2 participants