Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e955e72
add EvmStateBuilder struct
Mr-Leshiy Jan 18, 2022
3d1d9f7
add ethereum tests submodule
Mr-Leshiy Jan 18, 2022
a5e6846
add initial test parsing
Mr-Leshiy Jan 19, 2022
40098ea
add setup env paramets from the test case
Mr-Leshiy Jan 19, 2022
97a08d2
add accounts initial setup
Mr-Leshiy Jan 19, 2022
3ce2eef
add TestExpect struct
Mr-Leshiy Jan 19, 2022
a8ff21f
Merge branch 'master' into evm-test-suite
Mr-Leshiy Jan 20, 2022
8c3349e
update parsing
Mr-Leshiy Jan 21, 2022
5f2dc28
small refactor
Mr-Leshiy Jan 21, 2022
b661c0b
add state validation functions
Mr-Leshiy Jan 21, 2022
8caf4e1
fix TestEvmTransaction
Mr-Leshiy Jan 21, 2022
334355f
fix Account converting
Mr-Leshiy Jan 21, 2022
0b14a63
small refactor
Mr-Leshiy Jan 22, 2022
d251f11
add TestEvmTransaction conversions
Mr-Leshiy Feb 3, 2022
1ac8b69
Merge branch 'master' into evm-test-suite
Mr-Leshiy Feb 3, 2022
f98b1b8
fixing small issues
Mr-Leshiy Feb 3, 2022
b84f532
fix clippy
Mr-Leshiy Feb 3, 2022
f48d9af
ignore vm_add_test
Mr-Leshiy Feb 4, 2022
76f3ff7
Merge branch 'master' into evm-test-suite
Mr-Leshiy Feb 4, 2022
91af6d3
fix issue with gas fees
Mr-Leshiy Feb 4, 2022
a703960
move tests
Mr-Leshiy Feb 7, 2022
b99319a
add bitwise_logic_operation tests
Mr-Leshiy Feb 7, 2022
eaa25a5
ci: checkout submodules
eugene-babichenko Feb 7, 2022
dbd11d5
add more tests for the evm
Mr-Leshiy Feb 7, 2022
fe9db26
Update chain-impl-mockchain/src/tokens/policy_hash.rs
Mr-Leshiy Feb 7, 2022
33065f0
Update chain-impl-mockchain/src/tokens/name.rs
Mr-Leshiy Feb 7, 2022
d0d37b1
Update chain-impl-mockchain/src/certificate/test.rs
Mr-Leshiy Feb 7, 2022
af42bc8
Update chain-impl-mockchain/src/tokens/identifier.rs
Mr-Leshiy Feb 7, 2022
2f2a670
update suggestions
Mr-Leshiy Feb 8, 2022
aec68a4
add comments
Mr-Leshiy Feb 8, 2022
ea0fc90
Merge branch 'master' into fix-vm-add-test
Mr-Leshiy Feb 14, 2022
b994ce6
fix env_test evm, update
Mr-Leshiy Feb 14, 2022
9618469
Merge branch 'master' into fix-env-info-evm-test
Mr-Leshiy Feb 17, 2022
c097741
Merge branch 'master' into fix-env-info-evm-test
Mr-Leshiy Mar 7, 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
11 changes: 6 additions & 5 deletions chain-evm/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub enum Error {
pub struct VirtualMachine<'runtime> {
/// EVM Block Configuration.
config: Config,
environment: &'runtime Environment,
environment: &'runtime mut Environment,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that the VM should mutate the environment outside of tests.

precompiles: Precompiles,
state: AccountTrie,
logs: LogsState,
Expand Down Expand Up @@ -170,6 +170,7 @@ impl<'runtime> VirtualMachine<'runtime> {
u64,
) -> (ExitReason, T),
{
self.environment.origin = caller;
let config = &(self.config.into());
let metadata = StackSubstateMetadata::new(gas_limit, config);
let memory_stack_state = MemoryStackState::new(metadata, self);
Expand Down Expand Up @@ -208,14 +209,14 @@ impl<'runtime> VirtualMachine<'runtime> {

impl<'runtime> VirtualMachine<'runtime> {
/// Creates a new `VirtualMachine` given configuration parameters.
pub fn new(config: Config, environment: &'runtime Environment) -> Self {
pub fn new(config: Config, environment: &'runtime mut Environment) -> Self {
Self::new_with_state(config, environment, Default::default(), Default::default())
}

/// Creates a new `VirtualMachine` given configuration params and a given account storage.
pub fn new_with_state(
config: Config,
environment: &'runtime Environment,
environment: &'runtime mut Environment,
state: AccountTrie,
logs: LogsState,
) -> Self {
Expand Down Expand Up @@ -460,7 +461,7 @@ mod test {
use std::rc::Rc;

let config = Config::Istanbul;
let environment = Environment {
let mut environment = Environment {
gas_price: Default::default(),
origin: Default::default(),
chain_id: Default::default(),
Expand All @@ -475,7 +476,7 @@ mod test {

let evm_config = config.into();

let vm = VirtualMachine::new(config, &environment);
let vm = VirtualMachine::new(config, &mut environment);

let gas_limit = u64::max_value();

Expand Down
2 changes: 1 addition & 1 deletion chain-impl-mockchain/src/ledger/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Ledger {
) -> Result<(), Error> {
let mut vm = VirtualMachine::new_with_state(
config,
&self.environment,
&mut self.environment,
self.accounts.clone(),
self.logs.clone(),
);
Expand Down
3 changes: 1 addition & 2 deletions chain-impl-mockchain/src/ledger/tests/evm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ pub fn run_evm_test(path: PathBuf) {
}

// TODO: need to fix following tests
// "../evm-tests/BlockchainTests/GeneralStateTests/VMTests/vmTests/envInfo.json"
// "../evm-tests/BlockchainTests/GeneralStateTests/VMTests/vmIOandFlowOperations/loop_stacklimit.json"
// "../evm-tests/BlockchainTests/GeneralStateTests/VMTests/vmIOandFlowOperations/jumpToPush.json"
#[test]
Expand Down Expand Up @@ -370,6 +369,6 @@ fn run_evm_tests() {
#[ignore]
fn evm_test() {
run_evm_test(PathBuf::from(
"../evm-tests/BlockchainTests/GeneralStateTests/VMTests/vmTests/blockInfo.json",
"../evm-tests/BlockchainTests/GeneralStateTests/VMTests/vmTests/envInfo.json",
));
}