mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Drop implicit alignment argument from FixedHash
This commit is contained in:
parent
725253551e
commit
2a41295d03
@ -61,7 +61,7 @@ public:
|
|||||||
explicit FixedHash() { m_data.fill(0); }
|
explicit FixedHash() { m_data.fill(0); }
|
||||||
|
|
||||||
/// Construct from another hash, filling with zeroes or cropping as necessary.
|
/// Construct from another hash, filling with zeroes or cropping as necessary.
|
||||||
template <unsigned M> explicit FixedHash(FixedHash<M> const& _h, ConstructFromHashType _t = AlignLeft)
|
template <unsigned M> explicit FixedHash(FixedHash<M> const& _h, ConstructFromHashType _t)
|
||||||
{
|
{
|
||||||
m_data.fill(0);
|
m_data.fill(0);
|
||||||
unsigned c = std::min(M, N);
|
unsigned c = std::min(M, N);
|
||||||
|
@ -255,7 +255,7 @@ evmc::result EVMHost::call(evmc_message const& _message) noexcept
|
|||||||
h160 createAddress(keccak256(
|
h160 createAddress(keccak256(
|
||||||
bytes(begin(message.sender.bytes), end(message.sender.bytes)) +
|
bytes(begin(message.sender.bytes), end(message.sender.bytes)) +
|
||||||
asBytes(to_string(sender.nonce++))
|
asBytes(to_string(sender.nonce++))
|
||||||
));
|
), h160::AlignLeft);
|
||||||
message.destination = convertToEVMC(createAddress);
|
message.destination = convertToEVMC(createAddress);
|
||||||
code = evmc::bytes(message.input_data, message.input_data + message.input_size);
|
code = evmc::bytes(message.input_data, message.input_data + message.input_size);
|
||||||
}
|
}
|
||||||
@ -266,7 +266,7 @@ evmc::result EVMHost::call(evmc_message const& _message) noexcept
|
|||||||
bytes(begin(message.sender.bytes), end(message.sender.bytes)) +
|
bytes(begin(message.sender.bytes), end(message.sender.bytes)) +
|
||||||
bytes(begin(message.create2_salt.bytes), end(message.create2_salt.bytes)) +
|
bytes(begin(message.create2_salt.bytes), end(message.create2_salt.bytes)) +
|
||||||
keccak256(bytes(message.input_data, message.input_data + message.input_size)).asBytes()
|
keccak256(bytes(message.input_data, message.input_data + message.input_size)).asBytes()
|
||||||
));
|
), h160::AlignLeft);
|
||||||
message.destination = convertToEVMC(createAddress);
|
message.destination = convertToEVMC(createAddress);
|
||||||
if (accounts.count(message.destination) && (
|
if (accounts.count(message.destination) && (
|
||||||
accounts[message.destination].nonce > 0 ||
|
accounts[message.destination].nonce > 0 ||
|
||||||
|
@ -146,29 +146,30 @@ BOOST_AUTO_TEST_CASE(string_constructor_frombytes)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(converting_constructor)
|
BOOST_AUTO_TEST_CASE(converting_constructor)
|
||||||
{
|
{
|
||||||
// Truncation
|
// Left-aligned truncation
|
||||||
FixedHash<8> a = FixedHash<8>(FixedHash<12>("112233445566778899001122"));
|
FixedHash<8> a = FixedHash<8>(FixedHash<12>("112233445566778899001122"), FixedHash<8>::AlignLeft);
|
||||||
BOOST_CHECK_EQUAL(a.size, 8);
|
BOOST_CHECK_EQUAL(a.size, 8);
|
||||||
BOOST_CHECK_EQUAL(a.hex(), "1122334455667788");
|
BOOST_CHECK_EQUAL(a.hex(), "1122334455667788");
|
||||||
|
|
||||||
|
// Right-aligned truncation
|
||||||
|
FixedHash<8> b = FixedHash<8>(FixedHash<12>("112233445566778899001122"), FixedHash<8>::AlignRight);
|
||||||
|
BOOST_CHECK_EQUAL(b.size, 8);
|
||||||
|
BOOST_CHECK_EQUAL(b.hex(), "5566778899001122");
|
||||||
|
|
||||||
// Left-aligned extension
|
// Left-aligned extension
|
||||||
FixedHash<12> b = FixedHash<12>(FixedHash<8>("1122334455667788"), FixedHash<12>::AlignLeft);
|
FixedHash<12> c = FixedHash<12>(FixedHash<8>("1122334455667788"), FixedHash<12>::AlignLeft);
|
||||||
BOOST_CHECK_EQUAL(b.size, 12);
|
BOOST_CHECK_EQUAL(c.size, 12);
|
||||||
BOOST_CHECK_EQUAL(b.hex(), "112233445566778800000000");
|
BOOST_CHECK_EQUAL(c.hex(), "112233445566778800000000");
|
||||||
|
|
||||||
// Right-aligned extension
|
// Right-aligned extension
|
||||||
FixedHash<12> c = FixedHash<12>(FixedHash<8>("1122334455667788"), FixedHash<12>::AlignRight);
|
FixedHash<12> d = FixedHash<12>(FixedHash<8>("1122334455667788"), FixedHash<12>::AlignRight);
|
||||||
BOOST_CHECK_EQUAL(c.size, 12);
|
BOOST_CHECK_EQUAL(d.size, 12);
|
||||||
BOOST_CHECK_EQUAL(c.hex(), "000000001122334455667788");
|
BOOST_CHECK_EQUAL(d.hex(), "000000001122334455667788");
|
||||||
|
|
||||||
// Default setting
|
|
||||||
FixedHash<12> d = FixedHash<12>(FixedHash<8>("1122334455667788"));
|
|
||||||
BOOST_CHECK_EQUAL(d, b);
|
|
||||||
|
|
||||||
// FailIfDifferent setting
|
// FailIfDifferent setting
|
||||||
// TODO: Shouldn't this throw?
|
// TODO: Shouldn't this throw?
|
||||||
FixedHash<12> e = FixedHash<12>(FixedHash<8>("1122334455667788"), FixedHash<12>::FailIfDifferent);
|
FixedHash<12> e = FixedHash<12>(FixedHash<8>("1122334455667788"), FixedHash<12>::FailIfDifferent);
|
||||||
BOOST_CHECK_EQUAL(e, b);
|
BOOST_CHECK_EQUAL(e, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(arith_constructor)
|
BOOST_AUTO_TEST_CASE(arith_constructor)
|
||||||
|
@ -439,7 +439,7 @@ u256 EwasmBuiltinInterpreter::evalEthBuiltin(string const& _fun, vector<uint64_t
|
|||||||
}
|
}
|
||||||
else if (_fun == "getExternalCodeSize")
|
else if (_fun == "getExternalCodeSize")
|
||||||
// Generate "random" code length.
|
// Generate "random" code length.
|
||||||
return uint32_t(u256(keccak256(h256(readAddress(arg[0])))) & 0xfff);
|
return uint32_t(u256(keccak256(h256(readAddress(arg[0]), h256::AlignLeft))) & 0xfff);
|
||||||
else if (_fun == "getGasLeft")
|
else if (_fun == "getGasLeft")
|
||||||
return 0x99;
|
return 0x99;
|
||||||
else if (_fun == "getBlockGasLimit")
|
else if (_fun == "getBlockGasLimit")
|
||||||
|
Loading…
Reference in New Issue
Block a user