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

[EVM-Equivalence-YUL] Extcodecopy fix #2191

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
127 changes: 127 additions & 0 deletions core/lib/multivm/src/versions/vm_latest/tests/evm_simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3847,6 +3847,133 @@ fn test_basic_environment3_vectors() {
assert_eq!(evm_output, 64.into());
}

#[test]
fn test_basic_extcodecopy() {
// Extcodecopy with dest != 0
let evm_output = test_evm_vector(
vec![
// push32
hex::decode("7F").unwrap(),
hex::decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")
.unwrap(),
// push0
hex::decode("5F").unwrap(),
// mstore
hex::decode("52").unwrap(),
// push32
hex::decode("7F").unwrap(),
hex::decode("3760005260206000F30000000000000000000000000000000000000000000000")
.unwrap(),
// push1 32
hex::decode("60").unwrap(),
hex::decode("20").unwrap(),
// mstore
hex::decode("52").unwrap(),
// push1 41
hex::decode("60").unwrap(),
hex::decode("29").unwrap(),
// push0
hex::decode("5F").unwrap(),
// push0
hex::decode("5F").unwrap(),
// create
hex::decode("F0").unwrap(),
// push0 -- clear the memory
hex::decode("5F").unwrap(),
// push0
hex::decode("5F").unwrap(),
// mstore
hex::decode("52").unwrap(),
// push0
hex::decode("5F").unwrap(),
// push1 32
hex::decode("60").unwrap(),
hex::decode("20").unwrap(),
// mstore
hex::decode("52").unwrap(),
// push1 32 -- begin extcodecopy
hex::decode("60").unwrap(),
hex::decode("20").unwrap(),
// push0
hex::decode("5F").unwrap(),
// push1 2
hex::decode("60").unwrap(),
hex::decode("02").unwrap(),
// dup4
hex::decode("83").unwrap(),
// extcodecopy
hex::decode("3C").unwrap(),
// push1 memOffset
hex::decode("60").unwrap(),
hex::decode("02").unwrap(),
// mload
hex::decode("51").unwrap(),
// push32 0
hex::decode("7F").unwrap(),
H256::zero().0.to_vec(),
// sstore
hex::decode("55").unwrap(),
]
.into_iter()
.concat(),
);
assert_eq!(
H256(evm_output.into()),
H256(U256::from("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff37").into())
);

// Extcodecopy with addr without code
let evm_output = test_evm_vector(
vec![
// push0 -- clear the memory
hex::decode("5F").unwrap(),
// push0
hex::decode("5F").unwrap(),
// mstore
hex::decode("52").unwrap(),
// push0
hex::decode("5F").unwrap(),
// push1 32
hex::decode("60").unwrap(),
hex::decode("20").unwrap(),
// mstore
hex::decode("52").unwrap(),
// push1 32 -- begin extcodecopy
hex::decode("60").unwrap(),
hex::decode("00").unwrap(),
// push0
hex::decode("5F").unwrap(),
// push0
hex::decode("60").unwrap(),
hex::decode("00").unwrap(),
// push0
hex::decode("61").unwrap(),
hex::decode("0176").unwrap(),
// extcodecopy
hex::decode("3C").unwrap(),
// push1 memOffset
hex::decode("60").unwrap(),
hex::decode("00").unwrap(),
// push1 1
hex::decode("60").unwrap(),
hex::decode("01").unwrap(),
//push0
hex::decode("5F").unwrap(),
// sstore
hex::decode("55").unwrap(),
// mload
hex::decode("51").unwrap(),
// push32 0
hex::decode("7F").unwrap(),
H256::zero().0.to_vec(),
// sstore
hex::decode("55").unwrap(),
]
.into_iter()
.concat(),
);
assert_eq!(H256(evm_output.into()), H256(U256::zero().into()));
}
#[test]
fn test_basic_environment4_vectors() {
// Here we just try to test some small EVM contracts and ensure that they work.
Expand Down
Loading