3

Firstly I want to make sure my understanding of the Ethereum is correct: A "normal" transaction of Ether from one account to another does not usually invoke the Ethereum Virtual Machine?

Secondly: What is the easiest way of finding out what percentage of transactions in a block have invoked the EVM from nodeJS? I am thinking of getting a block with web3, running debug.traceTransaction() for each transaction hash in the blocks transaction list. If this function returns undefined, then the EVM was not invoked. I was originally thinking of using .getCode(destinationAddress) and counting non-zero return accounts for each transactions destination but "normal" transaction of Ether can taken place with accounts that have code present too.

Thanks

1
  • 1
    One rough approach would be to look at how much gas was spent on each transaction. Sending with no extra actions will cost exactly 21000 gas.
    – carver
    Commented Aug 23, 2017 at 22:10

2 Answers 2

2

1) If you name normal all TXs that sends funds from an account (not a smart contract) to another (not a smart contract), and saying invoke the EVM you mean executing EVM code, then yes: normal TXs never invoke EVM

2) To find the GAS spent by a TX for the EVM code execution only, you need to get from the receipt the total GAS spent by the TX and then subract the intrinsic gas cost of that TX.

You find the formula to calculate the intrinsic gas cost of a TX looking inside the Yellow Paper, at paragraph #6.2 Execution.

Note that normal TXs usually cost 21.000 GAS, but the sender can add extra data to a TX, so they actually can cost more then that. If you want to be exact in your precentage, use the intrinsic GAS cost of the TX.

Also note that almost all ethereum clients already check that value before let you sign the transaction (rise the hand who got the famous "Intrinsic gas too low" error at least once), so you can find that formula already implemented in many different languages (GO, Rust, Java, Javascript, and so on).

1

You could inspect the gas spent on each transaction. A basic send will use exactly 21 kgas. Any other transactions ran instructions in the EVM.

Note that the approach would likely need to change with EIP #86, in the second part of Metropolis (aka~ Constantinople).

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.