Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d70db70
update rlp crate, expose it via chain-evm
saibatizoku Mar 28, 2022
80464af
add ethereum crate to cargo manifest in chain-evm
saibatizoku Apr 5, 2022
1308456
rlp encoding for evm transactions
saibatizoku Mar 31, 2022
bac6b40
add AccessList type and impl rlp en/de
saibatizoku Mar 31, 2022
54f1d87
impl rlp::Encodable for EvmTransaction
saibatizoku Mar 31, 2022
d8016e2
use AccessList and AccessListItem types from ethereum crate
saibatizoku Apr 4, 2022
35fafe7
implement Encodable/Decodabe traits for EvmTransaction
saibatizoku Apr 4, 2022
a5e3348
expose chain_evm::Config thru chain-impl-mockchain
saibatizoku Apr 4, 2022
d6516ba
implement RLP encoding under the hood for Payload/DeserializeFromSlice
saibatizoku Apr 4, 2022
2701296
clean up lints, make clippy happy
saibatizoku Apr 4, 2022
61e7b42
add feature gate for evm serialize_in function
saibatizoku Apr 4, 2022
c3ac841
clean clippy lint
saibatizoku Apr 4, 2022
6a96f54
move import used only in tests
saibatizoku Apr 4, 2022
0891c7b
make utility function for access list conversation into private
saibatizoku Apr 4, 2022
d5e96d0
impl Serialize n Deserialize for EvmTransaction
saibatizoku Apr 5, 2022
323bfe5
update evm transaction serialization bijection test
saibatizoku Apr 5, 2022
a1839c3
more test coverage to evm transaction RLP ser/de
saibatizoku Apr 5, 2022
bed4ed5
serialize length of RLP bytes
saibatizoku Apr 6, 2022
9249541
serialize length of RLP bytes in Serialize trait
saibatizoku Apr 6, 2022
04fbe20
read expected RLP bytes from Codec
saibatizoku Apr 6, 2022
187ef34
test no longer applies
saibatizoku Apr 6, 2022
c880bcf
arbitrary AccessList is either empty or has 4 items
saibatizoku Apr 7, 2022
7c0658c
add EthereumTransaction type
saibatizoku Apr 14, 2022
ce58956
add unsigned transaction types, implement RLP decoding
saibatizoku Apr 21, 2022
e95f1cb
adds signed and unsigned tx support for Ethereum
saibatizoku Apr 25, 2022
31d812b
fix clippy errors
saibatizoku Apr 25, 2022
8e2628a
sign and recover transactions
saibatizoku Apr 26, 2022
e7f086e
repair signed tx recovery, improve tests
saibatizoku Apr 26, 2022
7955c4d
few corrections to doc strings
saibatizoku Apr 26, 2022
f3bd658
refactor signed tx recovery, tidy up code a bit
saibatizoku Apr 26, 2022
fd5df75
Add transactions related scenarios (#790)
nicopado May 4, 2022
c33bc87
change Vec<u8> to Box<[u8]> (#803)
Mr-Leshiy May 5, 2022
b7e56ca
cleanup code, add docs, handle errors
saibatizoku May 9, 2022
cf41a3b
update EvmTransaction encoding for Box[u8] bytecode
saibatizoku May 11, 2022
8775bd0
Merge remote-tracking branch 'origin/master' into rlp-evm-transactions
saibatizoku May 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions chain-evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ edition = "2021"
[dependencies]
imhamt = { path = "../imhamt" }
chain-ser = { path = "../chain-ser" }
chain-core = { path = "../chain-core" }
typed-bytes = { path = "../typed-bytes" }
base64 = { version = "0.13.0", default-features = false, features = ["alloc"] }
blake2 = { version = "0.9.1", git = "https://github.com/near/near-blake2.git", rev = "736ff607cc8160af87ffa697c14ebef85050138f", default-features = false }
bn = { package = "aurora-bn", version = "0.1.0", git = "https://github.com/aurora-is-near/aurora-bn.git", default-features = false, features = ["std"] }
libsecp256k1 = { version = "0.7.0", default-features = false, features = ["static-context"] }
secp256k1 = { version = "0.22.1", features = ["global-context", "rand-std", "recovery"] }
num = { version = "0.4.0", default-features = false, features = ["alloc"] }
ripemd = { version = "0.1", default-features = false }
rlp = { version = "0.5.1", default-features = false }
Expand All @@ -20,6 +24,7 @@ byte-slice-cast = { version = "1.0", default-features = false }
thiserror = "1.0"
quickcheck = { version = "0.9", optional = true }
evm = { version = "0.35.0" }
ethereum = { version = "0.12.0" }
ethereum-types = { version = "0.13.1", features = ["rlp"] }

[dev-dependencies]
Expand Down
6 changes: 5 additions & 1 deletion chain-evm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
pub use ethereum;
pub use ethereum_types;
pub use rlp;

pub mod machine;
mod precompiles;
pub mod state;
pub mod transaction;
pub mod util;

#[cfg(test)]
mod tests;

pub use machine::{Address, BlockGasLimit, Config, Environment, ExitError, GasLimit, GasPrice};
pub use machine::{AccessList, Address, BlockGasLimit, Config, Environment, GasLimit, GasPrice};
45 changes: 26 additions & 19 deletions chain-evm/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use std::collections::{BTreeMap, BTreeSet};
use thiserror::Error;

/// Export EVM types
pub use ethereum::{AccessList, AccessListItem};
pub use evm::backend::Log;
pub use evm::ExitError;

Expand Down Expand Up @@ -267,24 +268,35 @@ where
}
}

// Convenience function to convert AccessList types into
// arguments used by the EVM transactions.
fn convert_access_list_to_tuples_vec(access_list: AccessList) -> Vec<(Address, Vec<Key>)> {
access_list
.iter()
.map(|list_item| {
let AccessListItem {
address,
storage_keys,
} = list_item;
(*address, storage_keys.clone())
})
.collect()
}

/// Execute a CREATE transaction
#[allow(clippy::too_many_arguments)]
#[allow(clippy::boxed_local)]
pub fn transact_create<State: EvmState>(
vm: VirtualMachine<State>,
value: U256,
init_code: ByteCode,
access_list: Vec<(Address, Vec<Key>)>,
access_list: AccessList,
) -> Result<Vec<u8>, Error> {
let caller = vm.origin;
let gas_limit = vm.gas_limit;
let access_list = convert_access_list_to_tuples_vec(access_list);
execute_transaction(vm, |executor| {
executor.transact_create(
caller,
value,
init_code.into(),
gas_limit,
access_list.clone(),
)
executor.transact_create(caller, value, init_code.to_vec(), gas_limit, access_list)
})
}

Expand All @@ -295,18 +307,19 @@ pub fn transact_create2<State: EvmState>(
value: U256,
init_code: ByteCode,
salt: H256,
access_list: Vec<(Address, Vec<Key>)>,
access_list: AccessList,
) -> Result<Vec<u8>, Error> {
let caller = vm.origin;
let gas_limit = vm.gas_limit;
let access_list = convert_access_list_to_tuples_vec(access_list);
execute_transaction(vm, |executor| {
executor.transact_create2(
caller,
value,
init_code.into(),
salt,
gas_limit,
access_list.clone(),
access_list,
)
})
}
Expand All @@ -318,19 +331,13 @@ pub fn transact_call<State: EvmState>(
address: Address,
value: U256,
data: ByteCode,
access_list: Vec<(Address, Vec<Key>)>,
access_list: AccessList,
) -> Result<Vec<u8>, Error> {
let caller = vm.origin;
let gas_limit = vm.gas_limit;
let access_list = convert_access_list_to_tuples_vec(access_list);
execute_transaction(vm, |executor| {
executor.transact_call(
caller,
address,
value,
data.into(),
gas_limit,
access_list.clone(),
)
executor.transact_call(caller, address, value, data.into(), gas_limit, access_list)
})
}

Expand Down
Loading