Browse Source

Merge remote-tracking branch 'up/develop' into bugFix

cl-refactor
yann300 10 years ago
parent
commit
e09338e2af
  1. 25
      evmjit/libevmjit-cpp/Env.cpp
  2. 6
      evmjit/libevmjit-cpp/JitVM.h
  3. 2
      libethcore/Ethash.cpp
  4. 2
      libethcore/Miner.h

25
evmjit/libevmjit-cpp/Env.cpp

@ -64,19 +64,24 @@ extern "C"
EXPORT bool env_call(ExtVMFace* _env, int64_t* io_gas, int64_t _callGas, h256* _receiveAddress, i256* _value, byte* _inBeg, uint64_t _inSize, byte* _outBeg, uint64_t _outSize, h256* _codeAddress) EXPORT bool env_call(ExtVMFace* _env, int64_t* io_gas, int64_t _callGas, h256* _receiveAddress, i256* _value, byte* _inBeg, uint64_t _inSize, byte* _outBeg, uint64_t _outSize, h256* _codeAddress)
{ {
auto value = llvm2eth(*_value); CallParameters params;
auto receiveAddress = right160(*_receiveAddress); params.value = llvm2eth(*_value);
auto codeAddress = right160(*_codeAddress); params.senderAddress = _env->myAddress;
const auto isCall = receiveAddress == codeAddress; // OPT: The same address pointer can be used if not CODECALL params.receiveAddress = right160(*_receiveAddress);
params.codeAddress = right160(*_codeAddress);
params.data = {_inBeg, _inSize};
params.out = {_outBeg, _outSize};
params.onOp = {};
const auto isCall = params.receiveAddress == params.codeAddress; // OPT: The same address pointer can be used if not CODECALL
*io_gas -= _callGas; *io_gas -= _callGas;
if (*io_gas < 0) if (*io_gas < 0)
return false; return false;
if (isCall && !_env->exists(receiveAddress)) if (isCall && !_env->exists(params.receiveAddress))
*io_gas -= static_cast<int64_t>(c_callNewAccountGas); // no underflow, *io_gas non-negative before *io_gas -= static_cast<int64_t>(c_callNewAccountGas); // no underflow, *io_gas non-negative before
if (value > 0) // value transfer if (params.value > 0) // value transfer
{ {
/*static*/ assert(c_callValueTransferGas > c_callStipend && "Overflow possible"); /*static*/ assert(c_callValueTransferGas > c_callStipend && "Overflow possible");
*io_gas -= static_cast<int64_t>(c_callValueTransferGas); // no underflow *io_gas -= static_cast<int64_t>(c_callValueTransferGas); // no underflow
@ -87,11 +92,11 @@ extern "C"
return false; return false;
auto ret = false; auto ret = false;
auto callGas = u256{_callGas}; params.gas = u256{_callGas};
if (_env->balance(_env->myAddress) >= value && _env->depth < 1024) if (_env->balance(_env->myAddress) >= params.value && _env->depth < 1024)
ret = _env->call(receiveAddress, value, {_inBeg, _inSize}, callGas, {_outBeg, _outSize}, {}, {}, codeAddress); ret = _env->call(params);
*io_gas += static_cast<int64_t>(callGas); // it is never more than initial _callGas *io_gas += static_cast<int64_t>(params.gas); // it is never more than initial _callGas
return ret; return ret;
} }

6
evmjit/libevmjit-cpp/JitVM.h

@ -12,10 +12,14 @@ class JitVM: public VMFace
{ {
virtual bytesConstRef go(ExtVMFace& _ext, OnOpFunc const& _onOp = {}, uint64_t _steps = (uint64_t)-1) override final; virtual bytesConstRef go(ExtVMFace& _ext, OnOpFunc const& _onOp = {}, uint64_t _steps = (uint64_t)-1) override final;
virtual u256 gas() const noexcept { return m_gas; }
virtual void reset(u256 const& _gas = 0) noexcept { m_gas = _gas; }
private: private:
friend class VMFactory; friend class VMFactory;
explicit JitVM(u256 _gas = 0) : VMFace(_gas) {} explicit JitVM(u256 _gas = 0): m_gas(_gas) {}
u256 m_gas;
jit::RuntimeData m_data; jit::RuntimeData m_data;
jit::ExecutionEngine m_engine; jit::ExecutionEngine m_engine;
std::unique_ptr<VMFace> m_fallbackVM; ///< VM used in case of input data rejected by JIT std::unique_ptr<VMFace> m_fallbackVM; ///< VM used in case of input data rejected by JIT

2
libethcore/Ethash.cpp

@ -142,7 +142,7 @@ void Ethash::CPUMiner::workLoop()
WorkPackage w = work(); WorkPackage w = work();
EthashAux::FullType dag; EthashAux::FullType dag;
while (!shouldStop() && !(dag = EthashAux::full(w.seedHash))) while (!shouldStop() && !(dag = EthashAux::full(w.seedHash, true)))
this_thread::sleep_for(chrono::milliseconds(500)); this_thread::sleep_for(chrono::milliseconds(500));
h256 boundary = w.boundary; h256 boundary = w.boundary;

2
libethcore/Miner.h

@ -44,7 +44,7 @@ struct MiningProgress
// MiningProgress& operator+=(MiningProgress const& _mp) { hashes += _mp.hashes; ms = std::max(ms, _mp.ms); return *this; } // MiningProgress& operator+=(MiningProgress const& _mp) { hashes += _mp.hashes; ms = std::max(ms, _mp.ms); return *this; }
uint64_t hashes = 0; ///< Total number of hashes computed. uint64_t hashes = 0; ///< Total number of hashes computed.
uint64_t ms = 0; ///< Total number of milliseconds of mining thus far. uint64_t ms = 0; ///< Total number of milliseconds of mining thus far.
uint64_t rate() const { return hashes * 1000 / ms; } uint64_t rate() const { return ms == 0 ? 0 : hashes * 1000 / ms; }
}; };
struct MineInfo: public MiningProgress {}; struct MineInfo: public MiningProgress {};

Loading…
Cancel
Save