2

I understand it takes time to include a legitimate transaction in the blockchain. And I understand to execute a SmartContract function is nothing more than sending a transaction. My question is that if it takes more time to finish a SmartContract function execution than to include a plain transaction in Blockchain.

4

My question is that if it takes more time to finish a SmartContract function execution than to include a plain transaction in BlockChain.

Both events - executing a smart contract function, and sending a plain transaction - both bring about state transitions. That is, they change some data in the blockchain.

At a transaction level, it may be the case that the smart contract call causes a larger state transition. In which case, technically, yes, such a transition would take physically longer to perform on a given machine's CPU/GPU. The transaction would take up more space in a block (i.e. it would cost more gas), and it would take longer for other miners to run and verify that the transition is valid.

However, at a block level, a full block is still limited to a certain size. It could be that the smart contract call is twice as complex as a plain transaction, takes twice the amount of gas, and takes twice as long to run, but the time to run and verify to contents of the whole full block is still the same.

(For reference, a full block - ~8M gas - takes in the order of 100-150 milliseconds for a miner to run and verify.)

| improve this answer | |
  • Thank you for your answer, Richard. A follow-up question is, from an end-user point of view, if she submits a SmartContract function call which is computationally expensive (gas consuming), should she expect larger latency for this call to finish? If yes, how much longer in orders of magnitude? – Ju Chen Feb 21 '18 at 23:15
  • Hi @JuChen. I'll edit my answer later to include an explanation to what you're asking. In the meantime: the time taken for either a plain transaction or smart contract call to be registered as a state change in the blockchain doesn't just depend on the time it physically takes to make the state transitions (which is what I thought you were asking). When a transaction is submitted to the network by a client, it needs to be included in a block. The time taken to be included isn't dependent on how computationally expensive it is. It's dependent on whether a miner wants to include it in a block. – Richard Horrocks Feb 22 '18 at 10:10
  • A miner is more likely to want to include it in a block if you're paying him a good wage to do so. Which is where gas price comes in. A smart contract call with a high gas price will be included in a block more quickly than a plain transaction with a low gas price. (Statistically speaking, anyway.) – Richard Horrocks Feb 22 '18 at 10:12

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.