From 47b6e38df9d56866af2093516c364e1921acd506 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 15 May 2015 17:58:31 +0200 Subject: [PATCH] Fixes for transact gas usage. --- alethzero/Transact.cpp | 2 +- libethcore/Ethash.cpp | 2 +- libethcore/EthashAux.cpp | 6 ++++-- libethcore/EthashAux.h | 7 +++++-- libethereum/Executive.h | 2 +- libethereum/TransactionQueue.cpp | 11 ++++++++--- mix/qml/DeploymentDialog.qml | 4 ++-- 7 files changed, 22 insertions(+), 12 deletions(-) diff --git a/alethzero/Transact.cpp b/alethzero/Transact.cpp index f2a8ef0d5..1336c3f05 100644 --- a/alethzero/Transact.cpp +++ b/alethzero/Transact.cpp @@ -361,7 +361,7 @@ void Transact::rejigData() to = m_context->fromString(ui->destination->currentText().toStdString()).first; er = ethereum()->call(s, value(), to, m_data, gasNeeded, gasPrice()); } - gasNeeded = (qint64)(er.gasUsed + er.gasRefunded); + gasNeeded = (qint64)(er.gasUsed + er.gasRefunded + c_callStipend); htmlInfo = QString("
INFO Gas required: %1 total = %2 base, %3 exec [%4 refunded later]
").arg(gasNeeded).arg(baseGas).arg(gasNeeded - baseGas).arg((qint64)er.gasRefunded) + htmlInfo; if (er.excepted != TransactionException::None) diff --git a/libethcore/Ethash.cpp b/libethcore/Ethash.cpp index 80550886c..fedf23826 100644 --- a/libethcore/Ethash.cpp +++ b/libethcore/Ethash.cpp @@ -317,7 +317,7 @@ void Ethash::GPUMiner::workLoop() } if (shouldStop()) return; - EthashAux::FullType dag = EthashAux::full(EthashAux::number(w.seedHash)); + EthashAux::FullType dag = EthashAux::full(EthashAux::number(w.seedHash)); // todo , , false bytesConstRef dagData = dag->data(); m_miner->init(dagData.data(), dagData.size(), 32, s_platformId, device); } diff --git a/libethcore/EthashAux.cpp b/libethcore/EthashAux.cpp index 9287bcbfc..2f369c458 100644 --- a/libethcore/EthashAux.cpp +++ b/libethcore/EthashAux.cpp @@ -156,8 +156,10 @@ static int dagCallbackShim(unsigned _p) return s_dagCallback ? s_dagCallback(_p) : 0; } -EthashAux::FullType EthashAux::full(uint64_t _blockNumber, function const& _f) +EthashAux::FullType EthashAux::full(uint64_t _blockNumber, function const& _f, bool _createIfMissing) { + (void)_createIfMissing; + // TODO: implement auto l = light(_blockNumber); h256 seedHash = EthashAux::seedHash(_blockNumber); FullType ret; @@ -195,7 +197,7 @@ unsigned EthashAux::computeFull(uint64_t _blockNumber) get()->m_generatingFullNumber = _blockNumber / ETHASH_EPOCH_LENGTH * ETHASH_EPOCH_LENGTH; get()->m_fullGenerator = unique_ptr(new thread([=](){ cnote << "Loading full DAG of" << _blockNumber; - get()->full(_blockNumber, [](unsigned p){ get()->m_fullProgress = p; return 0; }); + get()->full(_blockNumber, [](unsigned p){ get()->m_fullProgress = p; return 0; }), true; cnote << "Full DAG loaded"; get()->m_fullProgress = 0; get()->m_generatingFullNumber = NotGenerating; diff --git a/libethcore/EthashAux.h b/libethcore/EthashAux.h index f57f7a4d3..bc87f9dff 100644 --- a/libethcore/EthashAux.h +++ b/libethcore/EthashAux.h @@ -73,8 +73,9 @@ public: static unsigned computeFull(uint64_t _blockNumber); /// Information on the generation progress. static std::pair fullGeneratingProgress() { return std::make_pair(get()->m_generatingFullNumber, get()->m_fullProgress); } - /// Kicks off generation of DAG for @a _blocknumber and blocks until ready; @returns result. - static FullType full(uint64_t _blockNumber, std::function const& _f = std::function()); + + /// Kicks off generation of DAG for @a _blocknumber and blocks until ready; @returns result or empty pointer if not existing. + static FullType full(uint64_t _blockNumber, std::function const& _f = std::function(), bool _createIfMissing = false); static Ethash::Result eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } static Ethash::Result eval(BlockInfo const& _header, Nonce const& _nonce); @@ -83,6 +84,8 @@ public: private: EthashAux() {} + /// Kicks off generation of DAG for @a _blocknumber and blocks until ready; @returns result. + void killCache(h256 const& _s); static EthashAux* s_this; diff --git a/libethereum/Executive.h b/libethereum/Executive.h index 8903fd464..3806221be 100644 --- a/libethereum/Executive.h +++ b/libethereum/Executive.h @@ -137,7 +137,7 @@ private: Transaction m_t; ///< The original transaction. Set by setup(). LogEntries m_logs; ///< The log entries created by this transaction. Set by finalize(). - bigint m_gasRequired; + bigint m_gasRequired; ///< Gas required during execution of the transaction. bigint m_gasCost; bigint m_totalCost; }; diff --git a/libethereum/TransactionQueue.cpp b/libethereum/TransactionQueue.cpp index 5aca67a29..11104705c 100644 --- a/libethereum/TransactionQueue.cpp +++ b/libethereum/TransactionQueue.cpp @@ -41,9 +41,14 @@ ImportResult TransactionQueue::import(bytesConstRef _transactionRLP, ImportCallb if (ir != ImportResult::Success) return ir; - Transaction t(_transactionRLP, CheckTransaction::Everything); - UpgradeGuard ul(l); - return manageImport_WITH_LOCK(h, t, _cb); + try { + Transaction t(_transactionRLP, CheckTransaction::Everything); + UpgradeGuard ul(l); + return manageImport_WITH_LOCK(h, t, _cb); + } + catch (...) { + return ImportResult::Malformed; + } } ImportResult TransactionQueue::check_WITH_LOCK(h256 const& _h, IfDropped _ik) diff --git a/mix/qml/DeploymentDialog.qml b/mix/qml/DeploymentDialog.qml index 1fbde3ac9..e2d15d487 100644 --- a/mix/qml/DeploymentDialog.qml +++ b/mix/qml/DeploymentDialog.qml @@ -300,8 +300,8 @@ Dialog { { Layout.preferredWidth: 350 id: registrarAddr - text: "ab69f864e49fc4294d18355c4bafb0b91b5e629b" - visible: false + text: "c6d9d2cd449a754c494264e1809c50e34d64562b" + } DefaultLabel