Difference between revisions of "Not all transactions are equal"

From Internet Computer Wiki
Jump to: navigation, search
Line 23: Line 23:
 
Previous work from the Ethereum Foundation estimates the validation of an EdDSA signature to cost ~500k in Gas [[https://ethresear.ch/t/verify-ed25519-signatures-cheaply-on-eth-using-zk-snarks/13139 source]]. One way to get a comparison on the IC is to create a canister, import the [https://docs.rs/ed25519/latest/ed25519/ Rust ed25519 library] and test verification by creating a signature on a hash of an arbitrary message and using that for verification. Counting cycles burned before and after this call, discounting the base cost (i.e., cycles charged for ingress and for running an update call) results in a cycle cost of 4,211,120.  
 
Previous work from the Ethereum Foundation estimates the validation of an EdDSA signature to cost ~500k in Gas [[https://ethresear.ch/t/verify-ed25519-signatures-cheaply-on-eth-using-zk-snarks/13139 source]]. One way to get a comparison on the IC is to create a canister, import the [https://docs.rs/ed25519/latest/ed25519/ Rust ed25519 library] and test verification by creating a signature on a hash of an arbitrary message and using that for verification. Counting cycles burned before and after this call, discounting the base cost (i.e., cycles charged for ingress and for running an update call) results in a cycle cost of 4,211,120.  
  
Putting a dollar cost on this comparison, with a conservative assumption that 1 Gas costs 40GWEI and 1 ETH being ~USD1800 means the cost of an EdDSA validation on Ethereum currently costs USD36. Considering the cycle cost (4,211,120) on the IC with an XDR rate of USD1.3476 yields a cost of USD0.00000567490 to run an EdDSA verification on the IC. Overall, this suggests that the IC is 6,343,718 times less costly for computation.  
+
Putting a dollar cost on this comparison, with a conservative assumption that 1 Gas costs 40GWEI and 1 ETH being ~USD1800 means the cost of an EdDSA verification on Ethereum currently costs USD36. Considering the cycle cost (4,211,120) on the IC with an XDR rate of USD1.3476 yields a cost of USD0.00000567490 to run an EdDSA verification on the IC. Overall, this suggests that the IC is 6,343,718 times less costly for a standard computation.
  
 
[[L1 comparison]]
 
[[L1 comparison]]

Revision as of 16:10, 28 June 2023

Whilst it’s typical for blockchains to flaunt metrics around transactions per second (TX/s) or transactions per day (TX/d), comparisons between blockchains only make sense when those transactions are roughly equivalent i.e. TX/s comparisons only make sense to compare within a single problem domain.

The ICP is a blockchain which aims to provide a general purpose world computer, capable of serving real web services directly to user's browsers without any need for web2 cloud providers. Individual transactions on the ICP can be considered to be richer and must do more computation than most other blockchains.

This page aims to explain the differences between the work performed by transactions on the ICP vs those on Ethereum.

ETH vs. ICP execution throughput

Both ETH and ICP are able to run (general-purpose) smart contracts. At the execution layer, contracts are translated to a lower-level virtual machine interpretable language. These are EVM in the case of ETH and a Wasm-compatible runtime in the ICP case. Both EVM and Wasm instructions include arithmetic instructions (e.g., add, mul, div), but also more smart-contract specific instructions (e.g., reading and writing memory). The latter are in general more expensive operations in terms of consumed resources, which is then translated to the amount of gas used for each opcode of ETH and cycles used for ICP.

To compare the overall throughput of the two blockchains (i.e., how many ops per second can be handled), one needs to make several assumptions. First, it is assumed that the simpler EVM instructions (e.g., add, mul, div etc.) are roughly equivalent to the Wasm instructions of the same type, both kinds being translated to a similar x86 instruction executed by the hardware. The comparison is much more complex and not apples-to-apples for the more complex operations. For a proper comparison here one would need to either (1) thoroughly understand the design of both execution layers or (2) run a similar program/benchmark on both blockchains and compare their overall performance. These two options are time-consuming and would lead to longer-term research efforts. For a quicker comparison, it can be assumed that all EVM instructions are equal in terms of gas cost (and also assume no fees are involved). Since ETH is currently burning approximately 108B gas units per day, and assuming each instruction costs 1 gas unit (which vastly underestimates the costs of memory access operations), it is clear that the ETH blockchain is running less than 108B instructions per day.

The IC executes more than 20 billion replicated Wasm instructions per second. Under the simplifying assumption that all instructions are comparable, this means the IC runs the daily number of ETH instructions in less than 6 seconds.

To see this, consider that Ethereum executes 1,250,000 instructions and 15 transactions per second, which means that there are on average 83,333 instructions per transaction. While the IC executes 20 Billion instructions and 3,000 update calls per second, there are on average 6,666,667 instructions per call. Comparing the work intensity of the two blockchains, taking the ratio of instructions per transaction (6,666,667/83,333) ICP performs 80x the amount of computational work of Ethereum per transaction.

To compare the two networks in terms of efficiency, one also needs to consider the replication factor. In ICP the typical replication factor is 13 versus approximately 550'000 for Ethereum (a number that is steadily increasing and rose by approximately 100'000 over the last 6 months). Concluding, ICP is at least 3.4 million times more efficient than Ethereum.

ETH vs ICP EdDSA verification

To get a view on the validity of the above calculations in a real-world setting, comparisons can be made by running a given function. A realistic function that is used often in the blockchain setting is signature verification.

Previous work from the Ethereum Foundation estimates the validation of an EdDSA signature to cost ~500k in Gas [source]. One way to get a comparison on the IC is to create a canister, import the Rust ed25519 library and test verification by creating a signature on a hash of an arbitrary message and using that for verification. Counting cycles burned before and after this call, discounting the base cost (i.e., cycles charged for ingress and for running an update call) results in a cycle cost of 4,211,120.

Putting a dollar cost on this comparison, with a conservative assumption that 1 Gas costs 40GWEI and 1 ETH being ~USD1800 means the cost of an EdDSA verification on Ethereum currently costs USD36. Considering the cycle cost (4,211,120) on the IC with an XDR rate of USD1.3476 yields a cost of USD0.00000567490 to run an EdDSA verification on the IC. Overall, this suggests that the IC is 6,343,718 times less costly for a standard computation.

L1 comparison