Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EVM Engine and Rust libs #1815

Merged
merged 275 commits into from
Jun 9, 2023
Merged

Add EVM Engine and Rust libs #1815

merged 275 commits into from
Jun 9, 2023

Conversation

Mixa84
Copy link
Contributor

@Mixa84 Mixa84 commented Mar 13, 2023

Summary

  • Adding SputnikVM code
  • Adapting build process
  • Adding Rust tools as prerequisite for building

Implications

  • Index changes

    • Reindex required
    • Reindex optional
    • Reindex not required
  • Consensus

    • Network upgrade required
    • Includes backward compatible changes
    • Includes consensus workarounds
    • Includes consensus refactors

@Mixa84 Mixa84 requested review from prasannavl and Jouzo March 13, 2023 03:26
@Mixa84 Mixa84 self-assigned this Mar 13, 2023
@prasannavl prasannavl added the evm label Mar 15, 2023
@Mixa84 Mixa84 dismissed a stale review via 91d1556 March 24, 2023 02:46
src/key.cpp Outdated Show resolved Hide resolved
src/key_io.cpp Outdated Show resolved Hide resolved
src/pubkey.h Outdated Show resolved Hide resolved
@Bushstar Bushstar dismissed a stale review via ffd26eb March 28, 2023 05:30
DocteurPing and others added 6 commits April 5, 2023 09:43
* Add context calls for EVM block creation

* Add update_state bool

* Add context discard

* Return vector of vectors

* Vector of vectors unsupported

* Add EVM context to ConnectBlock

* Add TransactionQueueMap and rough finalize_block

* Add EVM header to coinbase

* Add call to get key from wallets

* Send encoded block header

* Remove evm_add_balance dummy call

* Remove comment

* Fix tests

---------

Co-authored-by: Bushstar <bushsolo@gmail.com>
* Make handlers extensible, add block handler

* Move EVMHandler

* Fix build errors

* Add connect_block

* Fix Eth_GetBlockByHash

* Fix incomplete merge

* Add bin files to gitignore

* Change RPC methods to lowerCamelCase

* Formatting
* Return error on sub balance failure.

* Change to expected return type

* Update EVM in/out TX

* Use array instead of rust::Vec

* Pass context to CustomTxVisit

* Add temporary state to TransactionQueue

* Improve readability

* Block integration test

---------

Co-authored-by: Bushstar <bushsolo@gmail.com>
Co-authored-by: Prasanna Loganathar <pvl@prasannavl.com>
Jouzo and others added 7 commits April 6, 2023 08:07
* Return error on sub balance failure.

* Change to expected return type

* Update EVM in/out TX

* Use array instead of rust::Vec

* Pass context to CustomTxVisit

* Add temporary state to TransactionQueue

* Improve readability

* Block integration test

---------

Co-authored-by: Bushstar <bushsolo@gmail.com>
* Got correct hash for public key recovery. Add test.

* Add support for EIP1559 TXs address recovery

* Add support for EIP2930 TXs address recovery

* Add failing test
* Improve error handling

* Correct test addresses
* Get correct hash for public key recovery. Add test.

* Update test for EIP-2930
* Add smart contract create && call tests
* add ci for evm

* toolchain nightly will do

* add cargo clippy ci

* Add EVM BlockHandler (#1864)

* Make handlers extensible, add block handler

* Move EVMHandler

* Fix build errors

* Add connect_block

* Fix Eth_GetBlockByHash

* Fix incomplete merge

* Add bin files to gitignore

* Change RPC methods to lowerCamelCase

* Formatting

* EVM in/out refinements (#1865)

* Return error on sub balance failure.

* Change to expected return type

* Update EVM in/out TX

* Use array instead of rust::Vec

* Pass context to CustomTxVisit

* Add temporary state to TransactionQueue

* Improve readability

* Block integration test

---------

Co-authored-by: Bushstar <bushsolo@gmail.com>
Co-authored-by: Prasanna Loganathar <pvl@prasannavl.com>

* Revert "EVM in/out refinements (#1865)" (#1867)

This reverts commit 35c85d4.

* EVM in/out refinements  (#1868)

* Return error on sub balance failure.

* Change to expected return type

* Update EVM in/out TX

* Use array instead of rust::Vec

* Pass context to CustomTxVisit

* Add temporary state to TransactionQueue

* Improve readability

* Block integration test

---------

Co-authored-by: Bushstar <bushsolo@gmail.com>

* Fix warnings (#1869)

* Got correct hash for public key recovery. Add test. (#1870)

* Got correct hash for public key recovery. Add test.

* Add support for EIP1559 TXs address recovery

* Add support for EIP2930 TXs address recovery

* Add failing test

* Improve error handling (#1872)

* Improve error handling

* Correct test addresses

* Fix public key extraction from Eth TXs and add tests (#1875)

* Get correct hash for public key recovery. Add test.

* Update test for EIP-2930

* EVM block integration test (#1874)

* Add smart contract create && call tests

* evm ci event triggered by path

* fmt

---------

Co-authored-by: Shoham Chakraborty <shhmchk@gmail.com>
Co-authored-by: Jouzo <15011228+Jouzo@users.noreply.github.com>
Co-authored-by: Bushstar <bushsolo@gmail.com>
Co-authored-by: Prasanna Loganathar <pvl@prasannavl.com>
canonbrother and others added 5 commits April 10, 2023 12:14
* eth_call from and to are mandatory field

* expose evm ExitReason and ExitSucceed

* add should_call_evm test

* add should_call test

* add should_get_balance test

* rm println and unuse assert

* fix tests

* fmt
* revert from,to to optional in ethtxinfo

* fmt
* Do auth on EvmOut wtih DFI equivalent

* Add authorization for EvmOut with equivalent DFI address of ETH address
* Store ethereum blocks in BlockManager

* Update ffi call

* eth_blockNumber and eth_getBlockByCount implementations

* formatting

* Fix hanging

* Fix RPC names and output

* Format

* Fix test

* Fix tests

* Fix logic

* Remove explicit drop

* Fix hash outputs, add test

* Syntax improvements
Bushstar and others added 24 commits June 9, 2023 07:41
* Install solc from make.sh

* Add pkg_install_solc to ci_setup_deps

* Install web3.py in make.sh
…feature/evm' of github.com:DeFiCh/ain into feature/evm
* Fix block 0 generation

* Formatting

* Remove unused imports
* Refactor transferdomain message and rpc

* Add test for multiple transfer and mixed transfers

* Add comment note

* Squashed commit of the following:

commit 9cc4f21
Author: Peter John Bushnell <bushsolo@gmail.com>
Date:   Wed Jun 7 08:21:57 2023 +0100

    Move EVM state changes to outside Connect/DisconnectBlock (#2032)

    * Demo work in progress code

    * Add iter method to keep transaction in queue instead of draining

    * Remove print from test

    * Rename iter to get_cloned_vec

    * Use get_cloned_vec

    * Update code after merge

    ---------

    Co-authored-by: jouzo <jdesclercs@gmail.com>

commit bba09e5
Author: Peter John Bushnell <bushsolo@gmail.com>
Date:   Wed Jun 7 06:52:30 2023 +0100

    Include EVM mnview in rollback. Convert miner fee to Sats. (#1999)

    * Convert miner fee to Sats

    * Move evm_finalize to ProcessDefi and include mnview changes in rollback

commit 3208586
Author: canonbrother <w.canonbrother@gmail.com>
Date:   Wed Jun 7 11:10:04 2023 +0800

    refactor(workflows): move `./scripts/fixtures.sh` to `.github` (#2030)

    * move scripts/fixtures.sh to .github

    * update bob addr to checksum addr

commit 571ae53
Author: Shoham Chakraborty <shhmchk@gmail.com>
Date:   Tue Jun 6 18:42:42 2023 +0800

    evm: Support contracts in functional tests (#2023)

    * Add contract compilation and interaction to Python tests

    * Fix path

    * Clean up test

    * Change function name

    * Refactor to EVMProvider and KeyPair

    * Move files to test_framework

    * Add EVMProvider to TestNode

    * Add static from_node method to KeyPair

    * Add static from_file method to EVMContract

    * Add static from_node method to EVMProvider

    * Remove web3 checksum

* Strip out validation of transferdomain as pure functions.

* Fix conversion

* Fix rpc command

* Update tests for new TransferDomain values

---------

Co-authored-by: Prasanna Loganathar <pvl@prasannavl.com>
Co-authored-by: Peter Bushnell <bushsolo@gmail.com>
* Add Eth addresses to getaccount

* Output tokens in order

* Revert test framework option scans

---------

Co-authored-by: Prasanna Loganathar <pvl@prasannavl.com>
* Return nonce on evm_prevalidate_raw_tx

* Catch thrown error from evm_prevalidate_raw_tx

* Returns sender address in evm_prevalidate_raw_tx

* Check if nonce is the expected value

* Get evm nonce and balance at latest block height

* With RustRes instead of throw

* Use RustRes in evm_try_queue_tx

* Parse metadata into txMessage

* Add evm_get_nonce_in_context FFI method

* Document TransactionQueue nonce handling

* Return InvalidNonce if queued nonce is not in increasing order

* Add unit test for nonce order

* Use FFI evm_get_nonce_in_context

* Get the next valid nonce

* Track failed nonces and try them once other TXs are added

* Prevalidate all TXs with nonce > account nonce

* Test transactions added in order

* Time order mempool TXs

* Remove commented out gas check in validate raw tx

* Add more EVM TXs for test

---------

Co-authored-by: Peter Bushnell <bushsolo@gmail.com>
* Discourage sending to Eth address on account layer

* Remove unused function and add test
* Deduct fee from sender

* Prevalidate balance for MIN_GAS_PER_TX

* Additional check to prevalidate tx and tests
* Fix block gas limit

* Fix build

* Add base_fee_per_gas to block output

* Formatting

* Calculate base fee

* Save base fee map

* eth_feeHistory implementation

* Formatting

* Fix block_count type, remove debug param

* Fix build

* Implement eth_maxPriorityFeePerGas

* Fix suggested_priority_fee loop

* Address issues

* Increase initial base fee, set minimum base fee, fix feeHistory output order

* Refactor to use match

* Use EIP1559 for eth_gasPrice estimation
* Set trie state and get new state root from JSON

* Load state from input JSON

* Store genesis block after loading state from json

* Remove panic and document handlers initialization

* Add warning

* Add debug log

* WIP BLOCK

---------

Co-authored-by: jouzo <jdesclercs@gmail.com>
* Set max gas limit per block

* Send used gas to miner in evm_prevalidate_raw_tx

* Rename to used_gas

* Get used gas from FFI

* Do not add failed TX gas to total

* Optional prevalidation of TX gas usage

---------

Co-authored-by: jouzo <jdesclercs@gmail.com>
@prasannavl prasannavl changed the title Add EVM Support Add EVM Engine and Rust libs Jun 9, 2023
@prasannavl prasannavl merged commit 9ceb025 into master Jun 9, 2023
@prasannavl prasannavl deleted the feature/evm branch June 9, 2023 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants