This post relates to https://blog.ethereum.org/2014/08/27/state-ethereum-august-edition
The proposed solution for native code extensions running outside of the gas-realm is a deviation from the simpler idea of tracking cost of small execution steps. I think the proposed fix is too complex and does not resolve the root cause: the EVM design is not speed efficient.
Performance issues might be related to the instruction set being too small, being interpreted, being stack-base or lack of optimization phase in the tool chain... anyway, we probably all agree here that it is not "fast" enough.
I believe the safest path to end-up with an efficient EVM is to re-use what has been developed for years: either Mono/CLR or JVM.
Optimized intermediate language and JIT compilation is key to resolve the root cause.
How can this work?
Roughly, I estimate 4 months one engineer and the following will very likely work:
- Select an existing VM, say Mono/CLR for example.
- Do a contract to C# translation tool. Consider first using only a subset of C# to simplify the gas consumption logic (done in next step).
- Modify the C# compiler to inject CIL (intermediate code) for keeping track of gas for each CIL instruction from the contract code... that is the hard part. An alternative to explore would be to move some gas tracking at a higher level, say the C# generation phase.
- EVM code (now CIL with gaz tracking) are still the contract code in the block-chain. Making a contract to be load as a package or assembly allows inter-contract call. All the hard work is done, just have to use it.
- Will need some development time for security and sandboxing (e.g. to prevent dependency on assembly that are not gaz metered), but such isolation has been done before by many others.
Some good info for tracking cost at CIL instruction granularity: http://msdn.microsoft.com/en-us/library/ms973852.aspx
If you use an existing intermediate language over an existing VM supporting JIT, in the end the "EVM" will:
- run a couple order of magnitudes faster than the current design.
- might run about half the speed of native code (after JIT and with consideration of doubling the number of native instructions for gaz consumption tracking).
Beside resolving the root cause, you get a new marketing bullet that contracts are sandbox and run over a well-known VM.