From 4e9b4323c06ac07cfc8676c430233185bf2d8f96 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 8 May 2014 00:24:57 +0100 Subject: [PATCH] Gas fix & GUI enhancements. --- alethzero/Main.ui | 9 +++++++++ libethereum/Instruction.cpp | 1 - libethereum/State.cpp | 35 ++++++----------------------------- libethereum/State.h | 10 +++++----- 4 files changed, 20 insertions(+), 35 deletions(-) diff --git a/alethzero/Main.ui b/alethzero/Main.ui index a76d5b77c..54c3207cd 100644 --- a/alethzero/Main.ui +++ b/alethzero/Main.ui @@ -398,6 +398,12 @@ + + + 2 + 0 + + QFrame::NoFrame @@ -947,6 +953,9 @@ &Quit + + Ctrl+Q + diff --git a/libethereum/Instruction.cpp b/libethereum/Instruction.cpp index 0ff68d0e0..3e0777f33 100644 --- a/libethereum/Instruction.cpp +++ b/libethereum/Instruction.cpp @@ -661,7 +661,6 @@ static int compileLispFragment(char const*& d, char const* e, bool _quiet, bytes int o = compileLispFragment(d, e, _quiet, codes[i], locs[i], _vars); if (o == -1 || (i == 0 && o != 1)) return false; - cnote << "FOR " << i << o; if (i > 0) for (int j = 0; j < o; ++j) codes[i].push_back((byte)Instruction::POP); // pop additional items off stack for the previous item (final item's returns get left on). diff --git a/libethereum/State.cpp b/libethereum/State.cpp index a20c39b32..4184b5b57 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -561,17 +561,12 @@ u256 State::playbackRaw(bytesConstRef _block, BlockInfo const& _grandParent, boo void State::uncommitToMine() { - if (m_currentBlock.sha3Uncles != h256()) - { -// cnote << "Unapplying rewards: " << balance(m_currentBlock.coinbaseAddress); - Addresses uncleAddresses; - for (auto i: RLP(m_currentUncles)) - uncleAddresses.push_back(i[2].toHash
()); - unapplyRewards(uncleAddresses); -// cnote << "Unapplied rewards: " << balance(m_currentBlock.coinbaseAddress); - - m_currentBlock.sha3Uncles = h256(); - } + m_cache.clear(); + if (!m_transactions.size()) + m_state.setRoot(m_previousBlock.stateRoot); + else + m_state.setRoot(m_transactions[m_transactions.size() - 1].stateRoot); + m_currentBlock.sha3Uncles = h256(); } bool State::amIJustParanoid(BlockChain const& _bc) @@ -972,7 +967,6 @@ h160 State::create(Address _sender, u256 _endowment, u256 _gasPrice, u256* _gas, State State::fromPending(unsigned _i) const { State ret = *this; - ret.uncommitToMine(); ret.m_cache.clear(); _i = min(_i, m_transactions.size()); if (!_i) @@ -1001,23 +995,6 @@ void State::applyRewards(Addresses const& _uncleAddresses) addBalance(m_currentBlock.coinbaseAddress, r); } -void State::unapplyRewards(Addresses const&) -{ - m_cache.clear(); - if (!m_transactions.size()) - m_state.setRoot(m_previousBlock.stateRoot); - else - m_state.setRoot(m_transactions[m_transactions.size() - 1].stateRoot); - -/* u256 r = m_blockReward; - for (auto const& i: _uncleAddresses) - { - subBalance(i, m_blockReward * 3 / 4); - r += m_blockReward / 8; - } - subBalance(m_currentBlock.coinbaseAddress, r);*/ -} - std::ostream& eth::operator<<(std::ostream& _out, State const& _s) { _out << "--- " << _s.rootHash() << std::endl; diff --git a/libethereum/State.h b/libethereum/State.h index 55d6c0c7d..0872d4d9c 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -238,11 +238,14 @@ public: /// This might throw. u256 playback(bytesConstRef _block, BlockInfo const& _bi, BlockInfo const& _parent, BlockInfo const& _grandParent, bool _fullCommit); + /// Get the fee associated for a transaction with the given data. + u256 txGas(uint _dataCount, u256 _gas = 0) const { return c_txDataGas * _dataCount + c_txGas + _gas; } + /// Get the fee associated for a contract created with the given data. - u256 createGas(uint _dataCount, u256 _gas = 0) const { return c_txDataGas * _dataCount + c_createGas + _gas; } + u256 createGas(uint _dataCount, u256 _gas = 0) const { return txGas(_dataCount, _gas); } /// Get the fee associated for a normal transaction. - u256 callGas(uint _dataCount, u256 _gas = 0) const { return c_txDataGas * _dataCount + c_callGas + _gas; } + u256 callGas(uint _dataCount, u256 _gas = 0) const { return txGas(_dataCount, _gas); } /// @return the difference between this state (origin) and @a _c (destination). StateDiff diff(State const& _c) const; @@ -290,9 +293,6 @@ private: void refreshManifest(RLPStream* _txs = nullptr); - /// Unfinalise the block, unapplying the earned rewards. - void unapplyRewards(Addresses const& _uncleAddresses); - /// @returns gas used by transactions thus far executed. u256 gasUsed() const { return m_transactions.size() ? m_transactions.back().gasUsed : 0; }