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

Used proofs in workflows (Ethereum -> NEAR) / (Ethereum -> Aurora) #43

Open
3 tasks
mfornet opened this issue Jun 1, 2021 · 3 comments
Open
3 tasks
Assignees
Labels
enhancement New feature or request P1

Comments

@mfornet
Copy link
Contributor

mfornet commented Jun 1, 2021

We need to determine when proofs to transfer assets from Ethereum to NEAR have been already used. (Mentioned by @sept-en in #40 (comment))

This needs to be handled for:

  • ethConnector
  • eNEAR
  • erc20

We should have a similar function as the one described in #40:

function proofInNearExists(nearProvider, connectorType, address, proof) {
    // Return true if the proof already exists, false otherwise
    // connectorType can be one of ["EthConnector", "eNEAR", "Erc20"]
}

One option that doesn't involve changing contracts, is querying directly the state. This is an example about how to do it:

curl --location --request POST 'https://archival-rpc.testnet.near.org/' \
--header 'Content-Type: application/json' \
--data-raw '{
  "jsonrpc": "2.0",
  "id": "dontcare",
  "method": "query",
  "params": {
    "request_type": "view_state",
    "finality": "final",
    "account_id": "dev-1620133090135-4688553",
    "prefix_base64": "U1RBVEU="
  }
}'
@mfornet
Copy link
Contributor Author

mfornet commented Jun 3, 2021

Relevant PR exposing used proofs in NEAR contracts:

@paouvrard
Copy link
Member

@sept-en
Doing a view call to is_used_proof() produces the following error:
(index):1216 Error: [-32602] Invalid params: Query data size 25730 is too large

I notice that the event relayer is working because it uses changeMethods which broadcasts a tx instead of usingviewMethods to make the query: https://github.com/aurora-is-near/eth-to-near-event-relayer/blob/75efb4303a8e5d8838584bc16a06bf586d6e6e21/src/utils_near.js#L28

So I think the computation of Proof.get_key() could be done offchain and the key can be used as the view argument directly in order to avoid the query data size error.

cc @mfornet

@mfornet
Copy link
Contributor Author

mfornet commented Jun 7, 2021

So I think the computation of Proof.get_key() could be done offchain and the key can be used as the view argument directly in order to avoid the query data size error.

This sounds good to me. We can rename it or even add a different function is_used_proof_from_key

We should make sure to expose this function publicly so other developer can use it in case they need that info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P1
Projects
None yet
Development

No branches or pull requests

3 participants