1

I am creating large contracts A and T (not real names) that represent actual business needs and these contract have several setters (A.setXXX, A.setYYY, T.setZZZ ...) functions to initialize the storage of the contracts.

I am working on the pattern that 1) first I create the contract with the basing info and then the end user (java script) set the other info from outside with several transactions.

I then realise that each transaction on the same contract are mined one at at time. If I have in javascript

A.setXXX();
A.setYYY();

then it takes 2 blocks to have them both processed

However if I call

A.setXXX();
T.setZZZ();

Both transactions are included in the same block

So i conclude that the miner only take one transation for each object and discard the other transactions for later processing.

My questions are:

  • Is this rule normal?
  • What is the reasoning?
  • Is there a way around this?
  • Am I using an incorrect pattern for populating large contract?

Thanks for advises

Note that I selected this pattern because I could find solution to call a transaction with a large structure as parameters.

1

A miner will usually mine multiple transactions in the same block, and they will be executed in order, regardless whether they access the same contract or not.

If your setters are using a lot of gas, it may be that the two calls to A in combination are using more than the block gas limit (or the remaining gas in the block if there are already other transactions included in it), in which case they can't both be included in the same block. If T uses less gas than your second call to A, it may be possible to squeeze that in where a second call to A wouldn't fit.

  • I see. I have selected to call all my methods with the maximum gas allowed by the block (eth.getBlock().gasLimit). And all my call are senr from the same account that has a lot of ether (it is the coinbase doing the mining). So both set of calls are with the same parameters, the only difference is the contract receiving the call. I will check the total of both transactions gas consumption to see. – Guenole de Cadoudal Feb 14 '17 at 21:45
  • This is effectively the amount of gas passed to the call. If the amount is close (but above) to the gasEstimate then several calls are budled in one single transaction. Thanks for the help. – Guenole de Cadoudal Feb 15 '17 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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