Browse Source

Fixes for transact gas usage.

cl-refactor
Gav Wood 10 years ago
parent
commit
47b6e38df9
  1. 2
      alethzero/Transact.cpp
  2. 2
      libethcore/Ethash.cpp
  3. 6
      libethcore/EthashAux.cpp
  4. 7
      libethcore/EthashAux.h
  5. 2
      libethereum/Executive.h
  6. 11
      libethereum/TransactionQueue.cpp
  7. 4
      mix/qml/DeploymentDialog.qml

2
alethzero/Transact.cpp

@ -361,7 +361,7 @@ void Transact::rejigData()
to = m_context->fromString(ui->destination->currentText().toStdString()).first; to = m_context->fromString(ui->destination->currentText().toStdString()).first;
er = ethereum()->call(s, value(), to, m_data, gasNeeded, gasPrice()); 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("<div class=\"info\"><span class=\"icon\">INFO</span> Gas required: %1 total = %2 base, %3 exec [%4 refunded later]</div>").arg(gasNeeded).arg(baseGas).arg(gasNeeded - baseGas).arg((qint64)er.gasRefunded) + htmlInfo; htmlInfo = QString("<div class=\"info\"><span class=\"icon\">INFO</span> Gas required: %1 total = %2 base, %3 exec [%4 refunded later]</div>").arg(gasNeeded).arg(baseGas).arg(gasNeeded - baseGas).arg((qint64)er.gasRefunded) + htmlInfo;
if (er.excepted != TransactionException::None) if (er.excepted != TransactionException::None)

2
libethcore/Ethash.cpp

@ -317,7 +317,7 @@ void Ethash::GPUMiner::workLoop()
} }
if (shouldStop()) if (shouldStop())
return; 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(); bytesConstRef dagData = dag->data();
m_miner->init(dagData.data(), dagData.size(), 32, s_platformId, device); m_miner->init(dagData.data(), dagData.size(), 32, s_platformId, device);
} }

6
libethcore/EthashAux.cpp

@ -156,8 +156,10 @@ static int dagCallbackShim(unsigned _p)
return s_dagCallback ? s_dagCallback(_p) : 0; return s_dagCallback ? s_dagCallback(_p) : 0;
} }
EthashAux::FullType EthashAux::full(uint64_t _blockNumber, function<int(unsigned)> const& _f) EthashAux::FullType EthashAux::full(uint64_t _blockNumber, function<int(unsigned)> const& _f, bool _createIfMissing)
{ {
(void)_createIfMissing;
// TODO: implement
auto l = light(_blockNumber); auto l = light(_blockNumber);
h256 seedHash = EthashAux::seedHash(_blockNumber); h256 seedHash = EthashAux::seedHash(_blockNumber);
FullType ret; FullType ret;
@ -195,7 +197,7 @@ unsigned EthashAux::computeFull(uint64_t _blockNumber)
get()->m_generatingFullNumber = _blockNumber / ETHASH_EPOCH_LENGTH * ETHASH_EPOCH_LENGTH; get()->m_generatingFullNumber = _blockNumber / ETHASH_EPOCH_LENGTH * ETHASH_EPOCH_LENGTH;
get()->m_fullGenerator = unique_ptr<thread>(new thread([=](){ get()->m_fullGenerator = unique_ptr<thread>(new thread([=](){
cnote << "Loading full DAG of" << _blockNumber; 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"; cnote << "Full DAG loaded";
get()->m_fullProgress = 0; get()->m_fullProgress = 0;
get()->m_generatingFullNumber = NotGenerating; get()->m_generatingFullNumber = NotGenerating;

7
libethcore/EthashAux.h

@ -73,8 +73,9 @@ public:
static unsigned computeFull(uint64_t _blockNumber); static unsigned computeFull(uint64_t _blockNumber);
/// Information on the generation progress. /// Information on the generation progress.
static std::pair<uint64_t, unsigned> fullGeneratingProgress() { return std::make_pair(get()->m_generatingFullNumber, get()->m_fullProgress); } static std::pair<uint64_t, unsigned> 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<int(unsigned)> const& _f = std::function<int(unsigned)>()); /// 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<int(unsigned)> const& _f = std::function<int(unsigned)>(), bool _createIfMissing = false);
static Ethash::Result eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } static Ethash::Result eval(BlockInfo const& _header) { return eval(_header, _header.nonce); }
static Ethash::Result eval(BlockInfo const& _header, Nonce const& _nonce); static Ethash::Result eval(BlockInfo const& _header, Nonce const& _nonce);
@ -83,6 +84,8 @@ public:
private: private:
EthashAux() {} EthashAux() {}
/// Kicks off generation of DAG for @a _blocknumber and blocks until ready; @returns result.
void killCache(h256 const& _s); void killCache(h256 const& _s);
static EthashAux* s_this; static EthashAux* s_this;

2
libethereum/Executive.h

@ -137,7 +137,7 @@ private:
Transaction m_t; ///< The original transaction. Set by setup(). Transaction m_t; ///< The original transaction. Set by setup().
LogEntries m_logs; ///< The log entries created by this transaction. Set by finalize(). 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_gasCost;
bigint m_totalCost; bigint m_totalCost;
}; };

11
libethereum/TransactionQueue.cpp

@ -41,9 +41,14 @@ ImportResult TransactionQueue::import(bytesConstRef _transactionRLP, ImportCallb
if (ir != ImportResult::Success) if (ir != ImportResult::Success)
return ir; return ir;
Transaction t(_transactionRLP, CheckTransaction::Everything); try {
UpgradeGuard ul(l); Transaction t(_transactionRLP, CheckTransaction::Everything);
return manageImport_WITH_LOCK(h, t, _cb); UpgradeGuard ul(l);
return manageImport_WITH_LOCK(h, t, _cb);
}
catch (...) {
return ImportResult::Malformed;
}
} }
ImportResult TransactionQueue::check_WITH_LOCK(h256 const& _h, IfDropped _ik) ImportResult TransactionQueue::check_WITH_LOCK(h256 const& _h, IfDropped _ik)

4
mix/qml/DeploymentDialog.qml

@ -300,8 +300,8 @@ Dialog {
{ {
Layout.preferredWidth: 350 Layout.preferredWidth: 350
id: registrarAddr id: registrarAddr
text: "ab69f864e49fc4294d18355c4bafb0b91b5e629b" text: "c6d9d2cd449a754c494264e1809c50e34d64562b"
visible: false
} }
DefaultLabel DefaultLabel

Loading…
Cancel
Save