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

[enhancement] Tx signing doesn't support concurrent testing #172

Open
mohamedalichelbi opened this issue Jun 15, 2022 · 0 comments
Open

Comments

@mohamedalichelbi
Copy link

mohamedalichelbi commented Jun 15, 2022

Problem description: I have a contract with many owner-only methods, so I made a test with workspaces-js 2.0 that calls all those methods at the same time. Something like:

await Promise.all([
 alice.call( "my-contract", "method_1", {} ),
 alice.call( "my-contract", "method_2", {} ),
 alice.call( "my-contract", "method_3", {} ),
 ]);

However with many calls, the tests would take an unusually long time: 12 calls took ~1.5 minutes to run, and going over 14 calls will fail the test.

Problem cause: Every time we run account.call(), the RPC is queried for the user's nonce in order to sign the transaction. Since we're running all 3 calls concurrently, the RPC would return the same nonce for all transactions, which means all transactions will be signed with the same nonce. The first signed transaction to arrive at the the RPC will be accepted, the other 2 will be rejected. Since the library has up to 10 automatic retries, it will retry to send the failed 2 transactions and the same will happen again. The first of the two will be accepted, the other one will be rejected. As you can see, this means there will be a lot of delay until all transactions get eventually accepted. Things get worse when trying to do this for a lot of transactions (>14 in my experience) since the library will run out of the 10 automatic retries and simply fail the test.

Possible solution: I think there should be a method that allows to sign & send multiple transactions from the same user. I remember seeing something similar last year in near-api-js but I couldn't find it anymore, so I made this method for my own tests and it's running fine. See this test for an example usage.

@github-project-automation github-project-automation bot moved this to Backlog 🥶 in DevRel Jun 3, 2024
@thisisjoshford thisisjoshford removed this from DevRel Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant