Skip to content

Commit

Permalink
fix issues with create opcode
Browse files Browse the repository at this point in the history
  • Loading branch information
JereSalo committed Nov 4, 2024
1 parent 796ceb1 commit 362ff24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions crates/vm/levm/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ impl VM {
return Ok(OpcodeSuccess::Result(ResultReason::Revert));
};
sender_account.info.nonce = new_nonce;
sender_account.info.balance -= value_in_wei_to_send;
// sender_account.info.balance -= value_in_wei_to_send; // This is done in the generic_call
let code = Bytes::from(
current_call_frame
.memory
Expand All @@ -649,7 +649,7 @@ impl VM {
return Ok(OpcodeSuccess::Result(ResultReason::Revert));
}

let new_account = Account::new(value_in_wei_to_send, code.clone(), 0, Default::default());
let new_account = Account::new(U256::zero(), code.clone(), 0, Default::default());
self.cache.add_account(&new_address, &new_account);

current_call_frame
Expand Down
4 changes: 2 additions & 2 deletions crates/vm/levm/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3650,7 +3650,7 @@ fn create_happy_path() {
.get_account(word_to_address(returned_addr))
.unwrap();
assert_eq!(new_account.info.balance, U256::from(value_to_transfer));
assert_eq!(new_account.info.nonce, 1);
assert_eq!(new_account.info.nonce, 0); // This was previously set to 1 but I understand that a new account should have nonce 0

// Check that the sender account is updated
let sender_account = vm.cache.get_account(sender_addr).unwrap();
Expand Down Expand Up @@ -3916,7 +3916,7 @@ fn create2_happy_path() {
.get_account(word_to_address(returned_addr))
.unwrap();
assert_eq!(new_account.info.balance, U256::from(value));
assert_eq!(new_account.info.nonce, 1);
assert_eq!(new_account.info.nonce, 0); // I understand new account should have nonce 0, not 1.

// Check that the sender account is updated
let sender_account = vm.cache.get_account(sender_addr).unwrap();
Expand Down

0 comments on commit 362ff24

Please sign in to comment.