I'm working on a project that will allow for me to benchmark of the top ten most popular smart contracts which I'll take from EtherScan.

The idea of the project is to determine if the smart contract execution rewards are proportional to the cost incurred to the miners.

I understand the other overheads such as Transaction validation, Signature validation and POW computation. My idea is to perform execution in a single client EVM and simulate the other aspects as needed. But i'm not quite sure how to go about this.

Then there is the problem of measuring energy usage of execution. I was thinking a potential estimation, or I could use a device such as a Kill-A-Watt to measure output from the wall. Not sure if this is feasible also.

Then i'm looking for a way to continuously run these executions taking the energy usage over 50 executions and produce an average for reference.

I'm not sure where to start with this project and if it's even possible, any help would be appreciated.

If you have any questions I'll be happy to clarify.

Note: I am new to Ethereum so i'm sorry if some of my knowledge is wrong or incorrect

  • I'm afraid I don't understand what you mean with "if the smart contract execution rewards are proportional to the cost incurred to the miners". To this kind of "estimate costs / performance" questions the default answer is typically "the only measurement you should be interested in is gas usage". – Lauri Peltonen Jan 30 at 20:08
  • @LauriPeltonen But the miner has incurred some cost to them by running the contract so I'm trying to determine if the incentives cover the cost – Dnaap Jan 31 at 10:45
  • Ah ok. Then I might suggest you check some mining profitability calculators. Because those give you numbers for everything. I would still argue that trying to calculate electricity usage per contract is meaningless - only the bigger picture counts (mining profitability). – Lauri Peltonen Jan 31 at 13:46

I would suggest this.

  • Smart contract execution on EVM is effectively same as code execution on any (virtual) machine

  • For each transaction, you can trace what "CPU" instructions were executed

  • You can assign a cost for each instructions

  • If you want to do this in advanced way, you can for example use Intel performance tuning suites and a doctored Go Ethereum/Parity node that translates VM instructions performance to actual PC CPU performance counters. For this, you need advanced skills in Go or Rust and very deep x64 CPU understanding.

  • Then you can map EVM instruction -> AMD64 instruction -> energy usage on Intel/AMD CPU

  • After you have this "per instruction performance mapping" done it is trivial to apply it to any Ethereum smart contract transaction. You just map EVM instructions to their respective reference joule(?) values.

  • 1
    Also please note that the energy usage of smart contracts is different than from miners. Miners solve hashes, but smart contract transactions are executed across all nodes in Ethereum network to verify the transactions. – Mikko Ohtamaa Jan 31 at 9:07
  • 1
    So if a user wanted to execute a contract would that just use their electricity to execute then every node in the network has to validate it using everyones electricity? – Dnaap Jan 31 at 10:52
  • 1
    Also how would you go about assigning a cost per instruction would I have to find a way to relate that to energy cost? – Dnaap Jan 31 at 10:53
  • 1
    Yes, the execution cost is executing the smart contract code on every full node in the network. For the energy consumption, please refer to Intel and AMD manuals. It is very advanced topic and probably a question to some other StackExchange site. – Mikko Ohtamaa Feb 1 at 9:33

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.