mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Move hash to a hidden function, and provide a datapath to it so avoid
unneeded SHA3s.
This commit is contained in:
parent
966407f285
commit
0dc70c63a9
@ -120,11 +120,15 @@ BOOST_AUTO_TEST_CASE(blocks)
|
||||
ETH_CHECK_EQUAL(expectedBlockInfoBloom, _blockInfo.logBloom);
|
||||
ETH_CHECK_EQUAL(expectedBlockInfoCoinbase, _blockInfo.coinbaseAddress);
|
||||
ETH_CHECK_EQUAL(expectedBlockInfoDifficulty, _blockInfo.difficulty);
|
||||
ETH_CHECK_EQUAL_COLLECTIONS(expectedBlockInfoExtraData.begin(), expectedBlockInfoExtraData.end(),
|
||||
_blockInfo.extraData.begin(), _blockInfo.extraData.end());
|
||||
ETH_CHECK_EQUAL_COLLECTIONS(
|
||||
expectedBlockInfoExtraData.begin(),
|
||||
expectedBlockInfoExtraData.end(),
|
||||
_blockInfo.extraData.begin(),
|
||||
_blockInfo.extraData.end()
|
||||
);
|
||||
ETH_CHECK_EQUAL(expectedBlockInfoGasLimit, _blockInfo.gasLimit);
|
||||
ETH_CHECK_EQUAL(expectedBlockInfoGasUsed, _blockInfo.gasUsed);
|
||||
ETH_CHECK_EQUAL(expectedBlockInfoHash, _blockInfo.hash);
|
||||
ETH_CHECK_EQUAL(expectedBlockInfoHash, _blockInfo.hash());
|
||||
ETH_CHECK_EQUAL(expectedBlockInfoMixHash, _blockInfo.mixHash);
|
||||
ETH_CHECK_EQUAL(expectedBlockInfoNonce, _blockInfo.nonce);
|
||||
ETH_CHECK_EQUAL(expectedBlockInfoNumber, _blockInfo.number);
|
||||
@ -155,8 +159,12 @@ BOOST_AUTO_TEST_CASE(blocks)
|
||||
u256 expectedTransactionSignatureS = h256(fromHex(_t["s"].asString()));
|
||||
// unsigned expectedTransactionSignatureV = jsToInt(t["v"].asString());
|
||||
|
||||
ETH_CHECK_EQUAL_COLLECTIONS(expectedTransactionData.begin(), expectedTransactionData.end(),
|
||||
_transaction.data().begin(), _transaction.data().end());
|
||||
ETH_CHECK_EQUAL_COLLECTIONS(
|
||||
expectedTransactionData.begin(),
|
||||
expectedTransactionData.end(),
|
||||
_transaction.data().begin(),
|
||||
_transaction.data().end()
|
||||
);
|
||||
ETH_CHECK_EQUAL(expectedTransactionGasLimit, _transaction.gas());
|
||||
ETH_CHECK_EQUAL(expectedTransactionGasPrice, _transaction.gasPrice());
|
||||
ETH_CHECK_EQUAL(expectedTransactionNonce, _transaction.nonce());
|
||||
|
@ -70,7 +70,10 @@ namespace test
|
||||
struct ValueTooLarge: virtual Exception {};
|
||||
bigint const c_max256plus1 = bigint(1) << 256;
|
||||
|
||||
ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller) : m_statePre(Address(_o["env"].get_obj()["currentCoinbase"].get_str()), OverlayDB(), eth::BaseState::Empty), m_statePost(Address(_o["env"].get_obj()["currentCoinbase"].get_str()), OverlayDB(), eth::BaseState::Empty), m_TestObject(_o)
|
||||
ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller):
|
||||
m_statePre(OverlayDB(), eth::BaseState::Empty, Address(_o["env"].get_obj()["currentCoinbase"].get_str())),
|
||||
m_statePost(OverlayDB(), eth::BaseState::Empty, Address(_o["env"].get_obj()["currentCoinbase"].get_str())),
|
||||
m_TestObject(_o)
|
||||
{
|
||||
importEnv(_o["env"].get_obj());
|
||||
importState(_o["pre"].get_obj(), m_statePre);
|
||||
@ -92,7 +95,7 @@ void ImportTest::importEnv(json_spirit::mObject& _o)
|
||||
assert(_o.count("currentCoinbase") > 0);
|
||||
assert(_o.count("currentNumber") > 0);
|
||||
|
||||
m_environment.previousBlock.hash = h256(_o["previousHash"].get_str());
|
||||
m_environment.currentBlock.parentHash = h256(_o["parentHash"].get_str());
|
||||
m_environment.currentBlock.number = toInt(_o["currentNumber"]);
|
||||
m_environment.currentBlock.gasLimit = toInt(_o["currentGasLimit"]);
|
||||
m_environment.currentBlock.difficulty = toInt(_o["currentDifficulty"]);
|
||||
|
@ -101,7 +101,7 @@ namespace test
|
||||
class ImportTest
|
||||
{
|
||||
public:
|
||||
ImportTest(json_spirit::mObject& _o) : m_statePre(Address(), OverlayDB(), eth::BaseState::Empty), m_statePost(Address(), OverlayDB(), eth::BaseState::Empty), m_TestObject(_o) {}
|
||||
ImportTest(json_spirit::mObject& _o): m_TestObject(_o) {}
|
||||
ImportTest(json_spirit::mObject& _o, bool isFiller);
|
||||
// imports
|
||||
void importEnv(json_spirit::mObject& _o);
|
||||
|
@ -52,7 +52,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
|
||||
|
||||
BOOST_REQUIRE(o.count("pre"));
|
||||
ImportTest importer(o["pre"].get_obj());
|
||||
State state(biGenesisBlock.coinbaseAddress, OverlayDB(), BaseState::Empty);
|
||||
State state(OverlayDB(), BaseState::Empty, biGenesisBlock.coinbaseAddress);
|
||||
importer.importState(o["pre"].get_obj(), state);
|
||||
o["pre"] = fillJsonWithState(state);
|
||||
state.commit();
|
||||
@ -599,7 +599,7 @@ void updatePoW(BlockInfo& _bi)
|
||||
ret = pow.mine(_bi, 10000, true, true);
|
||||
Ethash::assignResult(ret.second, _bi);
|
||||
}
|
||||
_bi.hash = _bi.headerHash(WithNonce);
|
||||
_bi.noteDirty();
|
||||
}
|
||||
|
||||
void writeBlockHeaderToJson(mObject& _o, BlockInfo const& _bi)
|
||||
@ -619,7 +619,7 @@ void writeBlockHeaderToJson(mObject& _o, BlockInfo const& _bi)
|
||||
_o["extraData"] ="0x" + toHex(_bi.extraData);
|
||||
_o["mixHash"] = toString(_bi.mixHash);
|
||||
_o["nonce"] = toString(_bi.nonce);
|
||||
_o["hash"] = toString(_bi.hash);
|
||||
_o["hash"] = toString(_bi.hash());
|
||||
}
|
||||
|
||||
RLPStream createFullBlockFromHeader(BlockInfo const& _bi, bytes const& _txs, bytes const& _uncles)
|
||||
|
@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE(Complex)
|
||||
CanonBlockChain bc;
|
||||
cout << bc;
|
||||
|
||||
State s(myMiner.address(), stateDB);
|
||||
State s(stateDB, BaseState::Empty, myMiner.address());
|
||||
cout << s;
|
||||
|
||||
// Sync up - this won't do much until we use the last state.
|
||||
|
4
vm.cpp
4
vm.cpp
@ -96,7 +96,7 @@ void FakeExtVM::push(mArray& a, u256 _v)
|
||||
mObject FakeExtVM::exportEnv()
|
||||
{
|
||||
mObject ret;
|
||||
ret["previousHash"] = toString(previousBlock.hash);
|
||||
ret["previousHash"] = toString(currentBlock.parentHash);
|
||||
push(ret, "currentDifficulty", currentBlock.difficulty);
|
||||
push(ret, "currentTimestamp", currentBlock.timestamp);
|
||||
ret["currentCoinbase"] = toString(currentBlock.coinbaseAddress);
|
||||
@ -115,7 +115,7 @@ void FakeExtVM::importEnv(mObject& _o)
|
||||
assert(_o.count("currentCoinbase") > 0);
|
||||
assert(_o.count("currentNumber") > 0);
|
||||
|
||||
previousBlock.hash = h256(_o["previousHash"].get_str());
|
||||
currentBlock.parentHash = h256(_o["previousHash"].get_str());
|
||||
currentBlock.number = toInt(_o["currentNumber"]);
|
||||
lastHashes = test::lastHashes(currentBlock.number);
|
||||
currentBlock.gasLimit = toInt(_o["currentGasLimit"]);
|
||||
|
Loading…
Reference in New Issue
Block a user