mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Rename the SHA3 assembly instruction to KECCAK256
This commit is contained in:
@@ -349,7 +349,7 @@ BOOST_AUTO_TEST_CASE(retain_information_in_branches)
|
||||
bytes optimizedBytecode = compileAndRunWithOptimizer(sourceCode, 0, "c", true);
|
||||
size_t numSHA3s = 0;
|
||||
eachInstruction(optimizedBytecode, [&](Instruction _instr, u256 const&) {
|
||||
if (_instr == Instruction::SHA3)
|
||||
if (_instr == Instruction::KECCAK256)
|
||||
numSHA3s++;
|
||||
});
|
||||
// TEST DISABLED - OPTIMIZER IS NOT EFFECTIVE ON THIS ONE ANYMORE
|
||||
@@ -392,7 +392,7 @@ BOOST_AUTO_TEST_CASE(store_tags_as_unions)
|
||||
bytes optimizedBytecode = compileAndRunWithOptimizer(sourceCode, 0, "test", true);
|
||||
size_t numSHA3s = 0;
|
||||
eachInstruction(optimizedBytecode, [&](Instruction _instr, u256 const&) {
|
||||
if (_instr == Instruction::SHA3)
|
||||
if (_instr == Instruction::KECCAK256)
|
||||
numSHA3s++;
|
||||
});
|
||||
// TEST DISABLED UNTIL 93693404 IS IMPLEMENTED
|
||||
@@ -826,7 +826,7 @@ BOOST_AUTO_TEST_CASE(cse_empty_sha3)
|
||||
AssemblyItems input{
|
||||
u256(0),
|
||||
Instruction::DUP2,
|
||||
Instruction::SHA3
|
||||
Instruction::KECCAK256
|
||||
};
|
||||
checkCSE(input, {
|
||||
u256(dev::keccak256(bytesConstRef()))
|
||||
@@ -841,7 +841,7 @@ BOOST_AUTO_TEST_CASE(cse_partial_sha3)
|
||||
Instruction::MSTORE,
|
||||
u256(2),
|
||||
u256(0),
|
||||
Instruction::SHA3
|
||||
Instruction::KECCAK256
|
||||
};
|
||||
checkCSE(input, {
|
||||
u256(0xabcd) << (256 - 16),
|
||||
@@ -860,10 +860,10 @@ BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_location)
|
||||
Instruction::MSTORE,
|
||||
u256(64),
|
||||
Instruction::DUP2,
|
||||
Instruction::SHA3,
|
||||
Instruction::KECCAK256,
|
||||
u256(64),
|
||||
Instruction::DUP3,
|
||||
Instruction::SHA3
|
||||
Instruction::KECCAK256
|
||||
};
|
||||
checkCSE(input, {
|
||||
Instruction::DUP2,
|
||||
@@ -871,7 +871,7 @@ BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_location)
|
||||
Instruction::MSTORE,
|
||||
u256(64),
|
||||
Instruction::DUP2,
|
||||
Instruction::SHA3,
|
||||
Instruction::KECCAK256,
|
||||
Instruction::DUP1
|
||||
});
|
||||
}
|
||||
@@ -885,13 +885,13 @@ BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_content)
|
||||
Instruction::MSTORE, // m[128] = DUP1
|
||||
u256(0x20),
|
||||
u256(0x80),
|
||||
Instruction::SHA3, // sha3(m[128..(128+32)])
|
||||
Instruction::KECCAK256, // keccak256(m[128..(128+32)])
|
||||
Instruction::DUP2,
|
||||
u256(12),
|
||||
Instruction::MSTORE, // m[12] = DUP1
|
||||
u256(0x20),
|
||||
u256(12),
|
||||
Instruction::SHA3 // sha3(m[12..(12+32)])
|
||||
Instruction::KECCAK256 // keccak256(m[12..(12+32)])
|
||||
};
|
||||
checkCSE(input, {
|
||||
u256(0x80),
|
||||
@@ -900,7 +900,7 @@ BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_content)
|
||||
Instruction::MSTORE,
|
||||
u256(0x20),
|
||||
Instruction::SWAP1,
|
||||
Instruction::SHA3,
|
||||
Instruction::KECCAK256,
|
||||
u256(12),
|
||||
Instruction::DUP3,
|
||||
Instruction::SWAP1,
|
||||
@@ -921,7 +921,7 @@ BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_content_dynamic_store_in_between)
|
||||
u256(0x20),
|
||||
Instruction::DUP1,
|
||||
Instruction::DUP3,
|
||||
Instruction::SHA3, // sha3(m[128..(128+32)])
|
||||
Instruction::KECCAK256, // keccak256(m[128..(128+32)])
|
||||
u256(12),
|
||||
Instruction::DUP5,
|
||||
Instruction::DUP2,
|
||||
@@ -932,7 +932,7 @@ BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_content_dynamic_store_in_between)
|
||||
Instruction::SWAP2,
|
||||
Instruction::SWAP1,
|
||||
Instruction::SWAP2,
|
||||
Instruction::SHA3 // sha3(m[12..(12+32)])
|
||||
Instruction::KECCAK256 // keccak256(m[12..(12+32)])
|
||||
};
|
||||
checkCSE(input, input);
|
||||
}
|
||||
@@ -949,7 +949,7 @@ BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_content_noninterfering_store_in_between
|
||||
u256(0x20),
|
||||
Instruction::DUP1,
|
||||
Instruction::DUP3,
|
||||
Instruction::SHA3, // sha3(m[128..(128+32)])
|
||||
Instruction::KECCAK256, // keccak256(m[128..(128+32)])
|
||||
u256(12),
|
||||
Instruction::DUP5,
|
||||
Instruction::DUP2,
|
||||
@@ -962,12 +962,12 @@ BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_content_noninterfering_store_in_between
|
||||
Instruction::MSTORE, // does not destoy memory knowledge
|
||||
u256(0x20),
|
||||
u256(12),
|
||||
Instruction::SHA3 // sha3(m[12..(12+32)])
|
||||
Instruction::KECCAK256 // keccak256(m[12..(12+32)])
|
||||
};
|
||||
// if this changes too often, only count the number of SHA3 and MSTORE instructions
|
||||
AssemblyItems output = CSE(input);
|
||||
BOOST_CHECK_EQUAL(4, count(output.begin(), output.end(), AssemblyItem(Instruction::MSTORE)));
|
||||
BOOST_CHECK_EQUAL(1, count(output.begin(), output.end(), AssemblyItem(Instruction::SHA3)));
|
||||
BOOST_CHECK_EQUAL(1, count(output.begin(), output.end(), AssemblyItem(Instruction::KECCAK256)));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(cse_with_initially_known_stack)
|
||||
|
||||
Reference in New Issue
Block a user