Browse Source

Fix for crazy compiler lambda behaviour.

cl-refactor
Gav Wood 10 years ago
parent
commit
19c272c32d
  1. 2
      alethzero/MainWin.cpp
  2. 11
      libethereum/State.cpp
  3. 5
      liblll/CompilerState.cpp

2
alethzero/MainWin.cpp

@ -1266,7 +1266,7 @@ void Main::on_blocks_currentItemChanged()
if (info.number)
s << "<br/>Proof-of-Work: <b>" << ProofOfWork::eval(info.headerHashWithoutNonce(), info.nonce) << " &lt;= " << (h256)u256((bigint(1) << 256) / info.difficulty) << "</b>";
else
s << "<br/>Proof-of-Work: <i>Phil need prove nothing</i>";
s << "<br/>Proof-of-Work: <i>Phil has nothing to prove</i>";
s << "<br/>Parent: <b>" << info.parentHash << "</b>";
// s << "<br/>Bloom: <b>" << details.bloom << "</b>";
s << "<br/>Log Bloom: <b>" << info.logBloom << "</b>";

11
libethereum/State.cpp

@ -89,9 +89,9 @@ void ripemd160Code(bytesConstRef _in, bytesRef _out)
const std::map<unsigned, PrecompiledAddress> State::c_precompiled =
{
{ 1, { [](bytesConstRef){ return (bigint)500; }, ecrecoverCode }},
{ 2, { [](bytesConstRef i){ return (bigint)50 + (i.size() + 31) / 32 * 50; }, sha256Code }},
{ 3, { [](bytesConstRef i){ return (bigint)50 + (i.size() + 31) / 32 * 50; }, ripemd160Code }}
{ 1, { [](bytesConstRef) -> bigint { return (bigint)500; }, ecrecoverCode }},
{ 2, { [](bytesConstRef i) -> bigint { return (bigint)50 + (i.size() + 31) / 32 * 50; }, sha256Code }},
{ 3, { [](bytesConstRef i) -> bigint { return (bigint)50 + (i.size() + 31) / 32 * 50; }, ripemd160Code }}
};
OverlayDB State::openDB(std::string _path, bool _killExisting)
@ -1202,13 +1202,14 @@ bool State::call(Address _receiveAddress, Address _codeAddress, Address _senderA
auto it = !(_codeAddress & ~h160(0xffffffff)) ? c_precompiled.find((unsigned)(u160)_codeAddress) : c_precompiled.end();
if (it != c_precompiled.end())
{
if (*_gas < it->second.gas(_data))
bigint g = it->second.gas(_data);
if (*_gas < g)
{
*_gas = 0;
return false;
}
*_gas -= (u256)it->second.gas(_data);
*_gas -= (u256)g;
it->second.exec(_data, _out);
}
else if (addressHasCode(_codeAddress))

5
liblll/CompilerState.cpp

@ -72,6 +72,11 @@ void CompilerState::populateStandard()
"(def 'regname (name) { [32]'register [64]name (call allgas namereg 0 32 64 0 0) })"
"(def 'regcoin (name) { [32]name (call allgas coinreg 0 32 32 0 0) })"
"(def 'regcoin (name denom) { [32]name [64]denom (call allgas coinreg 0 32 64 0 0) })"
"(def 'ecrecover (r s v hash) { [0] r [32] s [64] v [96] hash (msg allgas 1 0 0 128) })"
"(def 'sha256 (data datasize) (msg allgas 2 0 data datasize))"
"(def 'ripemd160 (data datasize) (msg allgas 3 0 data datasize))"
"(def 'sha256 (val) { [0]:val (sha256 0 32) })"
"(def 'ripemd160 (val) { [0]:val (ripemd160 0 32) })"
"}";
CodeFragment::compile(s, *this);
}

Loading…
Cancel
Save