diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 434971c28..172583271 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -158,7 +158,7 @@ u256 BlockInfo::calculateGasLimit(BlockInfo const& _parent) const if (!parentHash) return 1000000; else - return max(10000, (_parent.gasLimit * (1024 - 1) + (_parent.gasUsed * 6 / 5)) / 1024); + return max(125000, (_parent.gasLimit * (1024 - 1) + (_parent.gasUsed * 6 / 5)) / 1024); } u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index e4f629f8c..dfdee092e 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -29,7 +29,7 @@ using namespace eth; //#define ETH_ADDRESS_DEBUG 1 -const unsigned eth::c_protocolVersion = 20; +const unsigned eth::c_protocolVersion = 21; static const vector> g_units = { diff --git a/libethential/Common.cpp b/libethential/Common.cpp index fc4708f23..955d73361 100644 --- a/libethential/Common.cpp +++ b/libethential/Common.cpp @@ -27,6 +27,6 @@ using namespace eth; namespace eth { -char const* EthVersion = "0.5.12"; +char const* EthVersion = "0.5.13"; } diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 871d773eb..946b5d42d 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -74,7 +74,7 @@ std::map const& eth::genesisState() for (auto i: vector({ "51ba59315b3a95761d0863b05ccc7a7f54703d99", "e6716f9544a56c530d868e4bfbacb172315bdead", - "1e12515ce3e0f817a4ddef9ca55788a1d66bd2df", + "b9c015918bdaba24b4ff057a92a3873d6eb201be", "1a26338f0d905e295fccb71fa9ea849ffa12aaf4", "2ef47100e0787b915105fd5e3f4ff6752079d5cb", "cd2a3d9f938e13cd947ec05abc7fe734df8dd826", diff --git a/libethereum/Executive.cpp b/libethereum/Executive.cpp index faabee133..7274b8917 100644 --- a/libethereum/Executive.cpp +++ b/libethereum/Executive.cpp @@ -229,4 +229,8 @@ void Executive::finalize() u256 feesEarned = gasSpentInEth; // cnote << "Transferring" << formatBalance(gasSpent) << "to miner."; m_s.addBalance(m_s.m_currentBlock.coinbaseAddress, feesEarned); + + // Suicides... + for (auto a: m_ext->suicides) + m_s.m_cache[a].kill(); } diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index b0edf2e4d..7555a728f 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -30,7 +30,7 @@ namespace eth { /** - * @brief Externalality interface for the Virtual Machine providing access to world state. + * @brief Externality interface for the Virtual Machine providing access to world state. */ class ExtVM: public ExtVMFace { @@ -53,13 +53,13 @@ public: { // Increment associated nonce for sender. m_s.noteSending(myAddress); - return m_s.create(myAddress, _endowment, gasPrice, _gas, _code, origin); + return m_s.create(myAddress, _endowment, gasPrice, _gas, _code, origin, &suicides); } /// Create a new message call. bool call(Address _receiveAddress, u256 _txValue, bytesConstRef _txData, u256* _gas, bytesRef _out) { - return m_s.call(_receiveAddress, myAddress, _txValue, gasPrice, _txData, _gas, _out, origin); + return m_s.call(_receiveAddress, myAddress, _txValue, gasPrice, _txData, _gas, _out, origin, &suicides); } /// Read address's balance. @@ -75,7 +75,7 @@ public: void suicide(Address _a) { m_s.addBalance(_a, m_s.balance(myAddress)); - m_s.m_cache[myAddress].kill(); + ExtVMFace::suicide(_a); } /// Revert any changes made (by any of the other calls). diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 48e16d2e5..301319c6d 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -1004,7 +1004,7 @@ u256 State::execute(bytesConstRef _rlp) return e.gasUsed(); } -bool State::call(Address _receiveAddress, Address _senderAddress, u256 _value, u256 _gasPrice, bytesConstRef _data, u256* _gas, bytesRef _out, Address _originAddress) +bool State::call(Address _receiveAddress, Address _senderAddress, u256 _value, u256 _gasPrice, bytesConstRef _data, u256* _gas, bytesRef _out, Address _originAddress, std::set
* o_suicides) { if (!_originAddress) _originAddress = _senderAddress; @@ -1022,6 +1022,9 @@ bool State::call(Address _receiveAddress, Address _senderAddress, u256 _value, u { auto out = vm.go(evm); memcpy(_out.data(), out.data(), std::min(out.size(), _out.size())); + if (o_suicides) + for (auto i: evm.suicides) + o_suicides->insert(i); } catch (OutOfGas const& /*_e*/) { @@ -1052,7 +1055,7 @@ bool State::call(Address _receiveAddress, Address _senderAddress, u256 _value, u return true; } -h160 State::create(Address _sender, u256 _endowment, u256 _gasPrice, u256* _gas, bytesConstRef _code, Address _origin) +h160 State::create(Address _sender, u256 _endowment, u256 _gasPrice, u256* _gas, bytesConstRef _code, Address _origin, std::set
* o_suicides) { if (!_origin) _origin = _sender; @@ -1064,7 +1067,7 @@ h160 State::create(Address _sender, u256 _endowment, u256 _gasPrice, u256* _gas, // Set up new account... m_cache[newAddress] = AddressState(0, 0, h256(), h256()); - // Execute _init. + // Execute init code. VM vm(*_gas); ExtVM evm(*this, newAddress, _sender, _origin, _endowment, _gasPrice, bytesConstRef(), _code); bool revert = false; @@ -1073,6 +1076,9 @@ h160 State::create(Address _sender, u256 _endowment, u256 _gasPrice, u256* _gas, try { out = vm.go(evm); + if (o_suicides) + for (auto i: evm.suicides) + o_suicides->insert(i); } catch (OutOfGas const& /*_e*/) { @@ -1096,7 +1102,7 @@ h160 State::create(Address _sender, u256 _endowment, u256 _gasPrice, u256* _gas, if (revert) evm.revert(); - // Set code as long as we didn't suicide. + // Set code. if (addressInUse(newAddress)) m_cache[newAddress].setCode(out); diff --git a/libethereum/State.h b/libethereum/State.h index 59bd423fc..0aff4d879 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -289,12 +289,12 @@ private: // We assume all instrinsic fees are paid up before this point. /// Execute a contract-creation transaction. - h160 create(Address _txSender, u256 _endowment, u256 _gasPrice, u256* _gas, bytesConstRef _code, Address _originAddress = Address()); + h160 create(Address _txSender, u256 _endowment, u256 _gasPrice, u256* _gas, bytesConstRef _code, Address _originAddress = Address(), std::set
* o_suicides = nullptr); /// Execute a call. /// @a _gas points to the amount of gas to use for the call, and will lower it accordingly. /// @returns false if the call ran out of gas before completion. true otherwise. - bool call(Address _myAddress, Address _txSender, u256 _txValue, u256 _gasPrice, bytesConstRef _txData, u256* _gas, bytesRef _out, Address _originAddress = Address()); + bool call(Address _myAddress, Address _txSender, u256 _txValue, u256 _gasPrice, bytesConstRef _txData, u256* _gas, bytesRef _out, Address _originAddress = Address(), std::set
* o_suicides = nullptr); /// Sets m_currentBlock to a clean state, (i.e. no change from m_previousBlock). void resetCurrent(); diff --git a/libevm/ExtVMFace.h b/libevm/ExtVMFace.h index 3e5a80580..7e8af6b3b 100644 --- a/libevm/ExtVMFace.h +++ b/libevm/ExtVMFace.h @@ -59,7 +59,7 @@ public: u256 txCount(Address) { return 0; } /// Suicide the associated contract to the given address. - void suicide(Address) {} + void suicide(Address _a) { suicides.insert(_a); } /// Create a new (contract) account. h160 create(u256, u256*, bytesConstRef, bytesConstRef) { return h160(); } @@ -79,6 +79,7 @@ public: bytesConstRef code; ///< Current code that is executing. BlockInfo previousBlock; ///< The previous block's information. BlockInfo currentBlock; ///< The current block's information. + std::set
suicides; ///< Any accounts that have suicided. }; } diff --git a/libserpent/rewriter.cpp b/libserpent/rewriter.cpp index 0e7e28c2b..0ef185e3c 100644 --- a/libserpent/rewriter.cpp +++ b/libserpent/rewriter.cpp @@ -350,7 +350,7 @@ Node array_lit_transform(Node node) { o2.push_back(astnode("alloc", o1, node.metadata)); std::vector o3; o3.push_back(astnode("set", o2, node.metadata)); - for (int i = 0; i < node.args.size(); i++) { + for (unsigned i = 0; i < node.args.size(); i++) { // (mstore (add (get symb) i*32) v) std::vector o5; o5.push_back(token(symb, node.metadata));