near / pagoda-relayer-rs

Rust Reference Implementation of Relayer for NEP-366 Meta Transactions
MIT License
32 stars 15 forks source link

Unit tests fail #6

Closed Lozu closed 8 months ago

Lozu commented 1 year ago

Even though cargo test finishes successfully and transactions are relayed (they can be seen at near explorer), they fail with the following:

{
  "type": "action",
  "error": {
    "type": "delegateActionInvalidSignature"
  }
}

For an example see https://explorer.testnet.near.org/transactions/2K45R7291Ddz6MkKapMACAq6g1ZBFnsrk9STyXFuHBG9. This is actually unmodified transaction from the first unit test.

I was unable to relay any transaction with success using pagoda relayer no matter how I formed them.

frol commented 1 year ago

Well, the test does not sign the DelegateAction from relayer_test0.testnet account and just puts placeholders there:

https://github.com/near/pagoda-relayer-rs/blob/0afc16514ec45917a4de44e3db59620f757d14b6/src/main.rs#L181-L183

You should populate the public key with relayer_test0.testnet public key, and then sign the DelegateAction with the private key and put the signature into the signature field (which you cannot do since neither you nor I are owners of the keys, so for you to test I suggest you create a new account and replace relayer_test0.testnet with your account and fill out the public key and sign it with your keypair).

See near.cli.rs implementation to learn more how to construct the meta-transaction properly: https://github.com/near/near-cli-rs/blob/1c9a7a62ed8eb31edea91f584090838b91f512a0/src/transaction_signature_options/mod.rs#L315-L353

You can use near-cli-rs without this relayer at all: https://asciinema.org/a/79Pwj2KxIHJgxC0CFrRTgfNcs?autoplay=1&t=1&speed=2; in order to create a meta-testnet network, use the following commands:

near config \
              add-connection \
                  --network-name testnet \
                  --connection-name meta-testnet \
                  --rpc-url https://rpc.testnet.near.org \
                  --wallet-url https://wallet.testnet.near.org/ \
                  --explorer-transaction-url https://explorer.testnet.near.org/transactions/ \
                  --linkdrop-account-id testnet \
                  --faucet-url https://helper.nearprotocol.com/account \
                  --meta-transaction-relayer-url http://127.0.0.1:3030
Lozu commented 1 year ago

You are right. I just lacked some knowledge. Thank you. If unit tests author only wanted to test relaying itself, there is no issue.

I can write a patch with which relayed transactions from unit tests will be successful. If you think this is a good idea, let me know.

frol commented 1 year ago

@Lozu I think it makes sense to have a proper example in the test. Please, go ahead with creating a PR

anthony-near commented 8 months ago

https://github.com/near/pagoda-relayer-rs/pull/65