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

Introduce a feature to avoid "Invalid Ethereum transaction nonce" in the OZ tests #189

Open
vasiliy-zaznobin opened this issue Dec 14, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@vasiliy-zaznobin
Copy link
Contributor

It needs to add a feature:
A test should use the right nonce for a transaction by sending getTransactionCount.

For example: test/utils/escrow/RefundEscrow.test.js

  2) Contract: RefundEscrow
       once deployed
         closed state
           "before each" hook for "rejects deposits":
     Error: Returned error: {"err": {"InstructionError": [1, "InvalidArgument"]}, "fee": 10000, "innerInstructions": [], "logMessages": ["Program 53DfF883gyixYNXnM7s5xhdeyV8mVk9T4i2hGV9vG9io invoke [1]", "Program log: program/src/entrypoint.rs:1256 : Invalid Ethereum transaction nonce: acc 13, trx 12", "Program 53DfF883gyixYNXnM7s5xhdeyV8mVk9T4i2hGV9vG9io consumed 31859 of 500000 compute units", "Program 53DfF883gyixYNXnM7s5xhdeyV8mVk9T4i2hGV9vG9io failed: invalid program argument"], "postBalances": [4975963116800, 925880, 2039280, 2039280, 2672640, 2039280, 64456560, 2672640, 1, 0, 1, 1141440, 1461600, 1130582400, 1169280], "postTokenBalances": [{"accountIndex": 2, "mint": "HPsV9Deocecw3GeZv1FkAPNCBRfuVyfw9MMwjwRe1xaU", "uiTokenAmount": {"amount": "99951000003212714", "decimals": 9, "uiAmount": 99951000.00321272, "uiAmountString": "99951000.003212714"}}, {"accountIndex": 3, "mint": "HPsV9Deocecw3GeZv1FkAPNCBRfuVyfw9MMwjwRe1xaU", "uiTokenAmount": {"amount": "783998504074", "decimals": 9, "uiAmount": 783.998504074, "uiAmountString": "783.998504074"}}, {"accountIndex": 5, "mint": "HPsV9Deocecw3GeZv1FkAPNCBRfuVyfw9MMwjwRe1xaU", "uiTokenAmount": {"amount": "1054000000000", "decimals": 9, "uiAmount": 1054.0, "uiAmountString": "1054"}}], "preBalances": [4975963126800, 925880, 2039280, 2039280, 2672640, 2039280, 64456560, 2672640, 1, 0, 1, 1141440, 1461600, 1130582400, 1169280], "preTokenBalances": [{"accountIndex": 2, "mint": "HPsV9Deocecw3GeZv1FkAPNCBRfuVyfw9MMwjwRe1xaU", "uiTokenAmount": {"amount": "99951000003212714", "decimals": 9, "uiAmount": 99951000.00321272, "uiAmountString": "99951000.003212714"}}, {"accountIndex": 3, "mint": "HPsV9Deocecw3GeZv1FkAPNCBRfuVyfw9MMwjwRe1xaU", "uiTokenAmount": {"amount": "783998504074", "decimals": 9, "uiAmount": 783.998504074, "uiAmountString": "783.998504074"}}, {"accountIndex": 5, "mint": "HPsV9Deocecw3GeZv1FkAPNCBRfuVyfw9MMwjwRe1xaU", "uiTokenAmount": {"amount": "1054000000000", "decimals": 9, "uiAmount": 1054.0, "uiAmountString": "1054"}}], "rewards": [], "status": {"Err": {"InstructionError": [1, "InvalidArgument"]}}}
      at /home/vzaznobin/neon/neon-compatibility/openzeppelin-contracts/test/utils/escrow/RefundEscrow.test.js:63:65
      at Array.map (<anonymous>)
      at Context.<anonymous> (test/utils/escrow/RefundEscrow.test.js:63:37)
      at processImmediate (node:internal/timers:464:21)

Additional Info:
https://github.com/neonlabsorg/proxy-model.py/blob/7841b07f33d9d45b68b621c711ff4c7e67b7f3f6/proxy/testing/test_eth_sendRawTransaction.py#L172

@vasiliy-zaznobin vasiliy-zaznobin added the enhancement New feature or request label Dec 14, 2021
@ivandzen
Copy link

ivandzen commented Dec 14, 2021

During investigation it was found that this issue is caused by parallel execution of eth_sendRawTransaction with the same nonces. The behaviour is next:

  1. beforeEach hook maps async lambda on array with eth accounts (line 63 in RefundEscrow.test.js)
  2. lambdas simultaneously calls RefundEscrow.deposit() contract method using the same nonce - this is approved by proxy's logs.
  3. evm loader fails transaction that was received later.

After talk with @otselnik we concluded that this behaviour is expected. The solution to this issue could be forcing tests to execute functions in sequential manner - this approach was tested by me on local environment with this particular test case and approved to solve issue

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

No branches or pull requests

4 participants