Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Stress test - too many bids - too many to finalize in one go #30

Merged
merged 1 commit into from
May 29, 2018

Conversation

stefek99
Copy link
Contributor

date; truffle test ./test/StressFinalize.js > output14; date
Tue 15 May 2018 14:41:46 BST
Tue 15 May 2018 15:02:32 BST

Output of the test: https://pastebin.com/XYQ51F0a

I left console.log statements on purpose so that it is possible to observe what's going on, feel free to remove as you see fit.

It is send to a file, otherwise on error there were too many Events emitted and couldn't scroll the console.

@clesaege
Copy link
Member

Thanks, I merge.

@clesaege clesaege merged commit 3c57d7d into kleros:master May 29, 2018
@stefek99
Copy link
Contributor Author

Did you have the patience to run it?

@clesaege
Copy link
Member

I just ran it and it fails:

  1. Contract: IICO Test case from the blog:
    AssertionError: Reimbursement amount not correct: expected 91821152005000000000 to be close to 91805038500000000000 +/- 10000000000000000
    at Function.assert.closeTo (C:\Users\Clementine\AppData\Roaming\npm\node_modules\truffle\build\webpack:~\chai\lib\chai\interface\assert.js:1223:1)
    at Context.it (test\IICO.js:899:12)
    at
    at process._tickCallback (internal/process/next_tick.js:188:7)

  2. Contract: IICO Should gracefull handle situation with many participants (over the block gas limit):
    Error: VM Exception while processing transaction: revert
    at Object.InvalidResponse (C:\Users\Clementine\AppData\Roaming\npm\node_modules\truffle\build\webpack:~\web3\lib\web3\errors.js:38:1)
    at C:\Users\Clementine\AppData\Roaming\npm\node_modules\truffle\build\webpack:~\web3\lib\web3\requestmanager.js:86:1
    at C:\Users\Clementine\AppData\Roaming\npm\node_modules\truffle\build\webpack:~\truffle-provider\wrapper.js:134:1
    at XMLHttpRequest.request.onreadystatechange (C:\Users\Clementine\AppData\Roaming\npm\node_modules\truffle\build\webpack:~\web3\lib\web3\httpprovider.js:128:1)
    at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\Clementine\AppData\Roaming\npm\node_modules\truffle\build\webpack:~\xhr2\lib\xhr2.js:64:1)
    at XMLHttpRequest._setReadyState (C:\Users\Clementine\AppData\Roaming\npm\node_modules\truffle\build\webpack:~\xhr2\lib\xhr2.js:354:1)
    at XMLHttpRequest._onHttpResponseEnd (C:\Users\Clementine\AppData\Roaming\npm\node_modules\truffle\build\webpack:~\xhr2\lib\xhr2.js:509:1)
    at IncomingMessage. (C:\Users\Clementine\AppData\Roaming\npm\node_modules\truffle\build\webpack:~\xhr2\lib\xhr2.js:469:1)
    at endReadableNT (_stream_readable.js:1054:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

@clesaege
Copy link
Member

It may be because of truffle update which now count gas and make things slower.

@clesaege
Copy link
Member

@stefek99 Can you look at this?

@stefek99
Copy link
Contributor Author

truffle test ./test/StressFinalize.js

I'm running it now, will finish in about 30 minutes...

@stefek99
Copy link
Contributor Author

image

truffle version
Truffle v4.1.8 (core: 4.1.8)
Solidity v0.4.23 (solc-js)

image

(might be a good idea to increase closeTo tolerance to 0.3 ether maybe)

@clesaege
Copy link
Member

I'm with the new truffle version, that may be the difference.

@stefek99
Copy link
Contributor Author

No way, I've updated recently!

ganache-cli --verion
Ganache CLI v7.0.0-beta.0 (ganache-core: 3.0.0-beta.0)

@clesaege
Copy link
Member

Your screenshot still display ms. Mine now display the gas used.

@clesaege
Copy link
Member

Are you at "truffle@4.1.11" ?

@epiqueras
Copy link
Contributor

epiqueras commented May 30, 2018

No way, I've updated recently!

That's ganache (testrpc). You need to update truffle too.

@stefek99
Copy link
Contributor Author

stefek99 commented Jun 1, 2018

npm update -g truffle
/Users/zen/.nvm/versions/node/v9.5.0/bin/truffle -> /Users/zen/.nvm/versions/node/v9.5.0/lib/node_modules/truffle/build/cli.bundled.js
+ truffle@4.1.11
removed 11 packages and updated 10 packages in 4.335s


truffle version
Truffle v4.1.11 (core: 4.1.11)
Solidity v0.4.24 (solc-js)

Sh!t, it is failing now:

image

@clesaege
Copy link
Member

clesaege commented Jun 1, 2018

Yeah, it's seems that the new truffle version is breaking stuff.

@stefek99
Copy link
Contributor Author

stefek99 commented Jun 1, 2018

truffle test ./test/StressFinalize.js - works...

image

truffle test - sometimes fails, sometimes works...

image

image

image

@stefek99
Copy link
Contributor Author

stefek99 commented Jun 1, 2018

See #33

Moved to a new folder so that truffle test does not take forever.

Intermittent failure, really tricky to debug.

@epiqueras
Copy link
Contributor

@stefek99 @clesaege
I suggest using evm_increaseTime to avoid having to wait so much.

@stefek99
Copy link
Contributor Author

stefek99 commented Jun 1, 2018

It's not about increasing time.

It's about running 5000 * 2 transactions so that finalize takes more than gasLimit of the block.

@epiqueras
Copy link
Contributor

@stefek99
You can set your own block gas limit. ganache-cli --gasLimit X

@stefek99
Copy link
Contributor Author

stefek99 commented Jun 1, 2018

Cannot set gasLimit on the mainnet.

See #26

@stefek99
Copy link
Contributor Author

stefek99 commented Jun 1, 2018

I know!

Set lower gasLimit, start testrpc manually.

Then we will hit it in 10 seconds, not half an hour...

Thanks for suggestions!

I won’t be investing more time on this issue unless explicitly instructed, I’m more interested in baking in affiliate / referral / commission to align incentives of participants as well as the core team when promoting the IICO.

@stefek99
Copy link
Contributor Author

stefek99 commented Jul 3, 2018

Some new lessons learned:

1. Cannot set block gas limit arbitrarily low - there will be not enough gas to deploy contract in the first place.

Maybe there is a dynamic block gas limit somewhere, potentially?

2. Say I start it with testrpc -a 15 --gasLimit 6000000 --gasPrice 10000000000

StackOverflow question: https://ethereum.stackexchange.com/questions/48413/truffle-test-how-to-get-more-than-10-accounts

It needs to have matching truffle.js config:

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*", // Match any network id
      gas: 6000000
    }
  }
};

Without gas: 6000000 it will complain:

Exceeds block gas limit

This issue was helpful - trufflesuite/truffle#660 - figured out I need to explicitly define config.

3. eth_getTransactionByHash vs eth_getTransactionReceipt

There is a difference if you want to get gas used by a transaction: https://ethereum.stackexchange.com/questions/8603/gas-and-gas-used-by-transaction-and-how-to-get-both-values-through-json-rpc

Added a helper for my personal use:

 getTransaction: hash => {
   console.log("getTransaction");
   return web3.currentProvider.send({jsonrpc: "2.0", method: "eth_getTransactionReceipt", params: [hash]})
 },

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

Successfully merging this pull request may close these issues.

3 participants