Inspiration
What it does
Running ethereum bytecode in eosio smart contract
How I built it
There are two related repositories:
https://github.com/learnforpractice/eos-with-evm
https://github.com/learnforpractice/evm4eosio
The source code in evm4eosio/evm4eos will used to generate a wasm file named ethereum_vm.wasm that can be deploy to a eosio based network.
The same source code in evm4eosio/evm4eos will also generate a shared library named evm4eos which will used to implement intrinsic functions.
The source code have three API functions:
int evm_execute(const char *raw_trx, size_t raw_trx_size, const char *sender_address, size_t sender_address_size);
int evm_get_account_id(uint64_t account, const char* arbitrary_string, size_t arbitrary_string_size, char* hash, size_t hash_size);
int evm_recover_key(const uint8_t* _sig, uint32_t _sig_size, const uint8_t* _message, uint32_t _message_len, uint8_t* _serialized_public_key, uint32_t _serialized_public_key_size);
evm_execute and evm_get_account_id implemented in evm4eosio/evm4eos/main.cpp
evm_recover_key implemented in evm4eosio/libdevcrypto/Common.cpp
These functions can be configured to implemented as intrinsic functions which can be called by wasm code or compile directly in WASM bytecode with the following cmake variables to improve performance.
USE_INTRINSIC_EVM_EXECUTE
USE_INTRINSIC_EVM_GET_ACCOUNT_ID
USE_INTRINSIC_EVM_RECOVER_KEY
The source code of https://github.com/learnforpractice/eos-with-evm is a fork of eosio source code that have the above three intrinsic function implemented.
Challenges I ran into
Compile EVM source code to WASM
Accomplishments that I'm proud of
Abstracting vm api functions from eosio which allow compile C++ smart contract to native code without changes.
What I learned
Security > Usability > Maintainability > Simplicity > Performance
What's next for evm4eos
Bug Fixes & Continue to improve evm performance and some other things.
Built With
- aleth
- boost
- eosio
- ethash
- secp256k1
Log in or sign up for Devpost to join the conversation.