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

Extract proofs creating scripts #432

Closed
alexauroradev opened this issue Nov 24, 2020 · 3 comments
Closed

Extract proofs creating scripts #432

alexauroradev opened this issue Nov 24, 2020 · 3 comments

Comments

@alexauroradev
Copy link

At the moment the only way how the bridge can be used is through CLI. CLI is intentionally abstracting complicated calls to the higher level, making bridge usage simpler. However, fails in the CLI calls execution may not be directly connected with contracts bugs, but with the CLI implementation. The absence of lower interface of interaction with the bridge automatically lead to several problems:

  1. There's no clear way for a user to finalise the transfer if it was interrupted by the CLI bug
  2. No separation of concerns. Execution failures may not directly lead to the level where the problem occurred.
  3. There's no clear way how to run complicated e2e tests that are not following the CLI logic
  4. A user is passing his private keys to some (really complex) script and is not controlling actual transactions that are signed. For some users this would be a major concern for usage of the CLI.

Though the CLI script is rather simple for ERC-20 transfers. ERC-20 -> NEP-21 transfer has multiple steps (similar logic works within transfer back):

  1. Ethereum transaction. Approve ERC-20 transfer.
  2. Ethereum transaction. Lock tokens.
  3. Custom script. Extract event proof.
  4. Custom script. Wait for enough confirmations in EthOnNearClient.
  5. NEAR transaction. Deposit token to destination address.

Stages 1, 2 can be passed knowing all the inputs to CLI (contract addresses, user addresses, private keys, etc.) through geth (even in a light client mode). Stage 5 can be passed through near-cli. Stage 4 is just waiting so can be substituted to recommendations on timings & checking view calls to NEAR blockchain (or Ethereum blockchain for opposite transfer).

The only stage that can not be passed easily is 3. Within this stage CLI collects the data from Ethereum full nodes (from RPC) and does not that simple assemblin MPT proof, which cannot be simply done from shell.

The solution to all above mentioned problems is to extract proof creation scripts and make them available through the CLI of the bridge.

Note: proof creation scripts are literally the only pieces that are needed to the end users from the core bridge. All the other interfaces / methods / endpoints can be completely hidden. Perhaps, this means that proof creation should be the only calls available in bridge-cli (if we don't think we should fit in it tools for devs), other scripts should be moved to connector-cli.

Extracting proof scripts would highly simplify the understanding of way how the bridge is operating for early bridge users.

@alexauroradev
Copy link
Author

Step 5 would require signing a BLOB by near-cli. @vgrichina started the PR on this: near/near-cli#614. Really appreciate his help!

@mfornet
Copy link
Contributor

mfornet commented Dec 22, 2020

Step 3 is already implemented in: https://github.com/near/rainbow-bridge/blob/master/cli/index.js#L570-L580

Use it with:

node cli/index.js eth-to-near-find-proof <locked_event>

@alexauroradev
Copy link
Author

Done in https://github.com/djsatok/bridge-testing/
CLI requires refactoring, no need to add scripts to CLI.

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

No branches or pull requests

4 participants