5

Is it possible to enable Ganache GUI to put multiple transactions into ONE block ?. The details about Why i need this thing, is given below;

I am going to test Transaction Order Dependence (TOD) contracts details are here, which need multiple transactions into one block (if i am not wrong). To achieve the real behavior of true miner, i have to test A race condition vulnerability in my contract. So, is it possible to launch TOD attack using Ganache ?

2
  • There shouldn't be any race condition if you send your transactions using the same account, because the transactions will be executed in the order dictated by the nonce of that account. Dec 23, 2019 at 7:32
  • yes, I know there is no race condition in current ganache, because ganache make one block for one transaction, but i am searching for a way, to enable ganache to put multiple transactions into one block.... ,could you help me in this regard ,
    – Amir Ali
    Dec 23, 2019 at 14:13

2 Answers 2

5

Ganache can be configured to mine new blocks on a specific time interval. With this setting enabled you are able to include multiple transactions in a single block.

To enable this functionality in the GUI, access the settings by clicking the gear icon in the top right corner. Choose "Server" settings. From there you will be able to disable auto-mining and set the number of seconds between blocks.

To enable it in ganache-cli, include the --blockTime [number] flag when launching the program. [number] is the number of seconds between blocks.

5
  • yes, its works, but only when i used my transactions without await... if i uese await then again it becomes one transaction into one block.... However, If i send my transaction without await, then this error occurred... Error: Transaction has been reverted by the EVM
    – Amir Ali
    Dec 27, 2019 at 3:32
  • please have a look for details... i have posted my detailed question above above mentioned problem in above comment.... ethereum.stackexchange.com/questions/78529/…
    – Amir Ali
    Dec 27, 2019 at 4:35
  • This will not solve the problem of multiple transactions in one block. IMO This will only increase the time a transaction needs to get confirmed.
    – Sanjay S B
    Dec 27, 2019 at 5:58
  • I have tested and confirmed using ganache-cli 6.7.0 - multiple transactions do get added to a single block. Dec 27, 2019 at 6:28
  • Can you manually mine a block before waiting for the blockTime to pass? Feb 22, 2022 at 15:34
0

Ganache does not have mining or consensus. It is a "one-click" single node blockchain which can be used to unit test your contracts. It runs transactions in an EVM and immediately confirm successful transactions by putting into a block.

To answer your question, this cannot be tested in Ganache. You need to use a proper ethereum node.

3
  • for proper etheruem, there i have to wait for 15 seconds... that's why its not fulfill my requirement..
    – Amir Ali
    Dec 23, 2019 at 14:14
  • Ganache was not designed for this purpose. The answer above tells about blocktime. Still only one transaction will go into one block.
    – Sanjay S B
    Dec 27, 2019 at 5:55
  • see my detailed question on this topic... btw. i have achieved it partially... but still working to complete , if you can help me, i shall be grateful to you... ethereum.stackexchange.com/questions/78529/…
    – Amir Ali
    Dec 27, 2019 at 6:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.