From 3e4def1c5efb02b1dbdd66825313b49857a8e837 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 3 Aug 2015 12:53:56 +0200 Subject: [PATCH 01/11] adjust gasPricerTests to 50 shannon --- test/libethereum/gaspricer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/libethereum/gaspricer.cpp b/test/libethereum/gaspricer.cpp index b4cbed8cb..46c911f85 100644 --- a/test/libethereum/gaspricer.cpp +++ b/test/libethereum/gaspricer.cpp @@ -54,11 +54,11 @@ BOOST_AUTO_TEST_CASE(trivialGasPricer) { cnote << "trivialGasPricer"; std::shared_ptr gp(new TrivialGasPricer); - BOOST_CHECK_EQUAL(gp->ask(State()), 10 * szabo); - BOOST_CHECK_EQUAL(gp->bid(), 10 * szabo); + BOOST_CHECK_EQUAL(gp->ask(State()), 50 * shannon); + BOOST_CHECK_EQUAL(gp->bid(), 50 * shannon); gp->update(CanonBlockChain(TransientDirectory().path(), WithExisting::Kill)); - BOOST_CHECK_EQUAL(gp->ask(State()), 10 * szabo); - BOOST_CHECK_EQUAL(gp->bid(), 10 * szabo); + BOOST_CHECK_EQUAL(gp->ask(State()), 50 * shannon); + BOOST_CHECK_EQUAL(gp->bid(), 50 * shannon); } BOOST_AUTO_TEST_CASE(basicGasPricerNoUpdate) From 5f887e840ab13011cfe8f3a59fb28a3254f0c76a Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 3 Aug 2015 12:55:19 +0200 Subject: [PATCH 02/11] set default gasPrice to 50 shannon --- libethcore/Common.h | 1 + libethereum/GasPricer.h | 4 ++-- libethereum/Interface.h | 8 ++++---- libethereumx/Ethereum.h | 6 +++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/libethcore/Common.h b/libethcore/Common.h index 072d78cc3..883a14e9b 100644 --- a/libethcore/Common.h +++ b/libethcore/Common.h @@ -80,6 +80,7 @@ template <> inline u256 exp10<0>() static const u256 ether = exp10<18>(); static const u256 finney = exp10<15>(); static const u256 szabo = exp10<12>(); +static const u256 shannon = exp10<9>(); static const u256 wei = exp10<0>(); using Nonce = h64; diff --git a/libethereum/GasPricer.h b/libethereum/GasPricer.h index f0fc6b520..6dd034cf7 100644 --- a/libethereum/GasPricer.h +++ b/libethereum/GasPricer.h @@ -66,8 +66,8 @@ public: u256 bid(TransactionPriority = TransactionPriority::Medium) const override { return m_bid; } private: - u256 m_ask = 10 * szabo; - u256 m_bid = 10 * szabo; + u256 m_ask = 50 * shannon; + u256 m_bid = 50 * shannon; }; } diff --git a/libethereum/Interface.h b/libethereum/Interface.h index b21ebfdb2..013728042 100644 --- a/libethereum/Interface.h +++ b/libethereum/Interface.h @@ -70,25 +70,25 @@ public: virtual std::pair submitTransaction(TransactionSkeleton const& _t, Secret const& _secret) = 0; /// Submits the given message-call transaction. - void submitTransaction(Secret const& _secret, u256 const& _value, Address const& _dest, bytes const& _data = bytes(), u256 const& _gas = 10000, u256 const& _gasPrice = 10 * szabo, u256 const& _nonce = UndefinedU256); + void submitTransaction(Secret const& _secret, u256 const& _value, Address const& _dest, bytes const& _data = bytes(), u256 const& _gas = 10000, u256 const& _gasPrice = 50 * shannon, u256 const& _nonce = UndefinedU256); /// Submits a new contract-creation transaction. /// @returns the new contract's address (assuming it all goes through). - Address submitTransaction(Secret const& _secret, u256 const& _endowment, bytes const& _init, u256 const& _gas = 10000, u256 const& _gasPrice = 10 * szabo, u256 const& _nonce = UndefinedU256); + Address submitTransaction(Secret const& _secret, u256 const& _endowment, bytes const& _init, u256 const& _gas = 10000, u256 const& _gasPrice = 50 * shannon, u256 const& _nonce = UndefinedU256); /// Blocks until all pending transactions have been processed. virtual void flushTransactions() = 0; /// Makes the given call. Nothing is recorded into the state. virtual ExecutionResult call(Address const& _from, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff = FudgeFactor::Strict) = 0; - ExecutionResult call(Address const& _from, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 10 * szabo, FudgeFactor _ff = FudgeFactor::Strict) { return call(_from, _value, _dest, _data, _gas, _gasPrice, m_default, _ff); } + ExecutionResult call(Address const& _from, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 50 * shannon, FudgeFactor _ff = FudgeFactor::Strict) { return call(_from, _value, _dest, _data, _gas, _gasPrice, m_default, _ff); } ExecutionResult call(Secret const& _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff = FudgeFactor::Strict) { return call(toAddress(_secret), _value, _dest, _data, _gas, _gasPrice, _blockNumber, _ff); } ExecutionResult call(Secret const& _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, FudgeFactor _ff = FudgeFactor::Strict) { return call(toAddress(_secret), _value, _dest, _data, _gas, _gasPrice, _ff); } /// Does the given creation. Nothing is recorded into the state. /// @returns the pair of the Address of the created contract together with its code. virtual ExecutionResult create(Address const& _from, u256 _value, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff = FudgeFactor::Strict) = 0; - ExecutionResult create(Address const& _from, u256 _value, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 10 * szabo, FudgeFactor _ff = FudgeFactor::Strict) { return create(_from, _value, _data, _gas, _gasPrice, m_default, _ff); } + ExecutionResult create(Address const& _from, u256 _value, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 50 * shannon, FudgeFactor _ff = FudgeFactor::Strict) { return create(_from, _value, _data, _gas, _gasPrice, m_default, _ff); } ExecutionResult create(Secret const& _secret, u256 _value, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff = FudgeFactor::Strict) { return create(toAddress(_secret), _value, _data, _gas, _gasPrice, _blockNumber, _ff); } ExecutionResult create(Secret const& _secret, u256 _value, bytes const& _data, u256 _gas, u256 _gasPrice, FudgeFactor _ff = FudgeFactor::Strict) { return create(toAddress(_secret), _value, _data, _gas, _gasPrice, _ff); } diff --git a/libethereumx/Ethereum.h b/libethereumx/Ethereum.h index 1e24b396c..ac6f9f115 100644 --- a/libethereumx/Ethereum.h +++ b/libethereumx/Ethereum.h @@ -62,11 +62,11 @@ public: ~Ethereum(); /// Submits the given message-call transaction. - void submitTransaction(Secret const& _secret, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 10 * szabo); + void submitTransaction(Secret const& _secret, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 50 * shannon); /// Submits a new contract-creation transaction. /// @returns the new contract's address (assuming it all goes through). - Address submitTransaction(Secret const& _secret, u256 _endowment, bytes const& _init, u256 _gas = 10000, u256 _gasPrice = 10 * szabo); + Address submitTransaction(Secret const& _secret, u256 _endowment, bytes const& _init, u256 _gas = 10000, u256 _gasPrice = 50 * shannon); /// Injects the RLP-encoded transaction given by the _rlp into the transaction queue directly. void inject(bytesConstRef _rlp); @@ -75,7 +75,7 @@ public: void flushTransactions(); /// Makes the given call. Nothing is recorded into the state. - bytes call(Address const& _from, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 10 * szabo); + bytes call(Address const& _from, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 50 * shannon); // Informational stuff From dca407ae6253d58dde42ca91d50742c1bc59f6b6 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 3 Aug 2015 12:55:54 +0200 Subject: [PATCH 03/11] target 3141592 as BlockGasLimit --- libethcore/Params.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethcore/Params.cpp b/libethcore/Params.cpp index fbf0f6d9e..8db3833ca 100644 --- a/libethcore/Params.cpp +++ b/libethcore/Params.cpp @@ -61,7 +61,7 @@ Network resetNetwork(Network _n) c_minGasLimit = 5000; break; } - c_gasFloorTarget = c_network == Network::Frontier ? 5000 : 3141592; + c_gasFloorTarget = 3141592; c_gasLimitBoundDivisor = 1024; c_minimumDifficulty = 131072; c_difficultyBoundDivisor = 2048; From 7ca950c937476739ee0a6349a03f907e3fc12d7d Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 3 Aug 2015 17:48:18 +0200 Subject: [PATCH 04/11] use global constant for defsultGasPrice --- libethereum/GasPricer.h | 6 ++++-- libethereum/Interface.h | 9 +++++---- libethereumx/Ethereum.h | 6 +++--- test/libethereum/gaspricer.cpp | 8 ++++---- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/libethereum/GasPricer.h b/libethereum/GasPricer.h index 6dd034cf7..c45fb8f67 100644 --- a/libethereum/GasPricer.h +++ b/libethereum/GasPricer.h @@ -40,6 +40,8 @@ enum class TransactionPriority Highest = 8 }; +static const u256 c_defaultGasPrice = 50 * shannon; + class GasPricer { public: @@ -66,8 +68,8 @@ public: u256 bid(TransactionPriority = TransactionPriority::Medium) const override { return m_bid; } private: - u256 m_ask = 50 * shannon; - u256 m_bid = 50 * shannon; + u256 m_ask = c_defaultGasPrice; + u256 m_bid = c_defaultGasPrice; }; } diff --git a/libethereum/Interface.h b/libethereum/Interface.h index 013728042..c33236962 100644 --- a/libethereum/Interface.h +++ b/libethereum/Interface.h @@ -26,6 +26,7 @@ #include #include #include +#include #include "LogFilter.h" #include "Transaction.h" #include "AccountDiff.h" @@ -70,25 +71,25 @@ public: virtual std::pair submitTransaction(TransactionSkeleton const& _t, Secret const& _secret) = 0; /// Submits the given message-call transaction. - void submitTransaction(Secret const& _secret, u256 const& _value, Address const& _dest, bytes const& _data = bytes(), u256 const& _gas = 10000, u256 const& _gasPrice = 50 * shannon, u256 const& _nonce = UndefinedU256); + void submitTransaction(Secret const& _secret, u256 const& _value, Address const& _dest, bytes const& _data = bytes(), u256 const& _gas = 10000, u256 const& _gasPrice = c_defaultGasPrice, u256 const& _nonce = UndefinedU256); /// Submits a new contract-creation transaction. /// @returns the new contract's address (assuming it all goes through). - Address submitTransaction(Secret const& _secret, u256 const& _endowment, bytes const& _init, u256 const& _gas = 10000, u256 const& _gasPrice = 50 * shannon, u256 const& _nonce = UndefinedU256); + Address submitTransaction(Secret const& _secret, u256 const& _endowment, bytes const& _init, u256 const& _gas = 10000, u256 const& _gasPrice = c_defaultGasPrice, u256 const& _nonce = UndefinedU256); /// Blocks until all pending transactions have been processed. virtual void flushTransactions() = 0; /// Makes the given call. Nothing is recorded into the state. virtual ExecutionResult call(Address const& _from, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff = FudgeFactor::Strict) = 0; - ExecutionResult call(Address const& _from, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 50 * shannon, FudgeFactor _ff = FudgeFactor::Strict) { return call(_from, _value, _dest, _data, _gas, _gasPrice, m_default, _ff); } + ExecutionResult call(Address const& _from, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = c_defaultGasPrice, FudgeFactor _ff = FudgeFactor::Strict) { return call(_from, _value, _dest, _data, _gas, _gasPrice, m_default, _ff); } ExecutionResult call(Secret const& _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff = FudgeFactor::Strict) { return call(toAddress(_secret), _value, _dest, _data, _gas, _gasPrice, _blockNumber, _ff); } ExecutionResult call(Secret const& _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, FudgeFactor _ff = FudgeFactor::Strict) { return call(toAddress(_secret), _value, _dest, _data, _gas, _gasPrice, _ff); } /// Does the given creation. Nothing is recorded into the state. /// @returns the pair of the Address of the created contract together with its code. virtual ExecutionResult create(Address const& _from, u256 _value, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff = FudgeFactor::Strict) = 0; - ExecutionResult create(Address const& _from, u256 _value, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 50 * shannon, FudgeFactor _ff = FudgeFactor::Strict) { return create(_from, _value, _data, _gas, _gasPrice, m_default, _ff); } + ExecutionResult create(Address const& _from, u256 _value, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = c_defaultGasPrice, FudgeFactor _ff = FudgeFactor::Strict) { return create(_from, _value, _data, _gas, _gasPrice, m_default, _ff); } ExecutionResult create(Secret const& _secret, u256 _value, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff = FudgeFactor::Strict) { return create(toAddress(_secret), _value, _data, _gas, _gasPrice, _blockNumber, _ff); } ExecutionResult create(Secret const& _secret, u256 _value, bytes const& _data, u256 _gas, u256 _gasPrice, FudgeFactor _ff = FudgeFactor::Strict) { return create(toAddress(_secret), _value, _data, _gas, _gasPrice, _ff); } diff --git a/libethereumx/Ethereum.h b/libethereumx/Ethereum.h index ac6f9f115..73392ea88 100644 --- a/libethereumx/Ethereum.h +++ b/libethereumx/Ethereum.h @@ -62,11 +62,11 @@ public: ~Ethereum(); /// Submits the given message-call transaction. - void submitTransaction(Secret const& _secret, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 50 * shannon); + void submitTransaction(Secret const& _secret, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = c_defaultGasPrice); /// Submits a new contract-creation transaction. /// @returns the new contract's address (assuming it all goes through). - Address submitTransaction(Secret const& _secret, u256 _endowment, bytes const& _init, u256 _gas = 10000, u256 _gasPrice = 50 * shannon); + Address submitTransaction(Secret const& _secret, u256 _endowment, bytes const& _init, u256 _gas = 10000, u256 _gasPrice = c_defaultGasPrice); /// Injects the RLP-encoded transaction given by the _rlp into the transaction queue directly. void inject(bytesConstRef _rlp); @@ -75,7 +75,7 @@ public: void flushTransactions(); /// Makes the given call. Nothing is recorded into the state. - bytes call(Address const& _from, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 50 * shannon); + bytes call(Address const& _from, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = c_defaultGasPrice); // Informational stuff diff --git a/test/libethereum/gaspricer.cpp b/test/libethereum/gaspricer.cpp index 46c911f85..820b623e5 100644 --- a/test/libethereum/gaspricer.cpp +++ b/test/libethereum/gaspricer.cpp @@ -54,11 +54,11 @@ BOOST_AUTO_TEST_CASE(trivialGasPricer) { cnote << "trivialGasPricer"; std::shared_ptr gp(new TrivialGasPricer); - BOOST_CHECK_EQUAL(gp->ask(State()), 50 * shannon); - BOOST_CHECK_EQUAL(gp->bid(), 50 * shannon); + BOOST_CHECK_EQUAL(gp->ask(State()), c_defaultGasPrice); + BOOST_CHECK_EQUAL(gp->bid(), c_defaultGasPrice); gp->update(CanonBlockChain(TransientDirectory().path(), WithExisting::Kill)); - BOOST_CHECK_EQUAL(gp->ask(State()), 50 * shannon); - BOOST_CHECK_EQUAL(gp->bid(), 50 * shannon); + BOOST_CHECK_EQUAL(gp->ask(State()), c_defaultGasPrice); + BOOST_CHECK_EQUAL(gp->bid(), c_defaultGasPrice); } BOOST_AUTO_TEST_CASE(basicGasPricerNoUpdate) From b8fad9ef1273b70bd73ebb016c03828e28deb61b Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 3 Aug 2015 20:49:55 +0200 Subject: [PATCH 05/11] typo - trigger buildbot --- test/libethereum/transaction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/libethereum/transaction.cpp b/test/libethereum/transaction.cpp index b620fc5ec..f6ed3ffa3 100644 --- a/test/libethereum/transaction.cpp +++ b/test/libethereum/transaction.cpp @@ -17,7 +17,7 @@ /** @file transaction.cpp * @author Dmitrii Khokhlov * @date 2015 - * Transaaction test functions. + * Transaction test functions. */ #include "../TestHelper.h" From b559aff4cc9f7ec52a581b5f8c93e00db1cfc75b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 4 Aug 2015 19:08:35 +0200 Subject: [PATCH 06/11] Difficulty adjustment. --- libethcore/BlockInfo.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 5cf909959..3b24e31ba 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -202,10 +202,14 @@ u256 BlockInfo::childGasLimit(u256 const& _gasFloorTarget) const u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const { + const unsigned c_expDiffPeriod = 100000; + if (!m_number) throw GenesisBlockCannotBeCalculated(); - else - return max(c_minimumDifficulty, m_timestamp >= _parent.m_timestamp + c_durationLimit ? _parent.m_difficulty - (_parent.m_difficulty / c_difficultyBoundDivisor) : (_parent.m_difficulty + (_parent.m_difficulty / c_difficultyBoundDivisor))); + u256 o = max(c_minimumDifficulty, m_timestamp >= _parent.m_timestamp + c_durationLimit ? _parent.m_difficulty - (_parent.m_difficulty / c_difficultyBoundDivisor) : (_parent.m_difficulty + (_parent.m_difficulty / c_difficultyBoundDivisor))); + if (unsigned periodCount = unsigned(_parent.number() + 1) / c_expDiffPeriod) + o = (u256)max(c_minimumDifficulty, bigint(o) - (bigint(1) << (periodCount - 1))); // latter will eventually become negative, so ensure it's a bigint. + return o; } void BlockInfo::verifyParent(BlockInfo const& _parent) const From 0dd42d2e5d8825f730a3b42cb219a7c69296165c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 4 Aug 2015 19:54:18 +0200 Subject: [PATCH 07/11] Don't give away internal state with the nonce. --- libdevcrypto/Common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdevcrypto/Common.cpp b/libdevcrypto/Common.cpp index b0db3ea4f..4f7c28025 100644 --- a/libdevcrypto/Common.cpp +++ b/libdevcrypto/Common.cpp @@ -367,7 +367,7 @@ Secret Nonce::next() { initialiseIfNeeded(); m_value = sha3(m_value); - return sha3(m_value); + return sha3(~m_value); // TODO: some sort of PRNG series. } void Nonce::resetInternal() From d7d76b5b19d36625dd34fff08ff4bd8cc9e91ff9 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 5 Aug 2015 00:07:02 +0200 Subject: [PATCH 08/11] 200k adjustment start. --- libethcore/BlockInfo.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 3b24e31ba..71f5469dd 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -207,8 +207,9 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const if (!m_number) throw GenesisBlockCannotBeCalculated(); u256 o = max(c_minimumDifficulty, m_timestamp >= _parent.m_timestamp + c_durationLimit ? _parent.m_difficulty - (_parent.m_difficulty / c_difficultyBoundDivisor) : (_parent.m_difficulty + (_parent.m_difficulty / c_difficultyBoundDivisor))); - if (unsigned periodCount = unsigned(_parent.number() + 1) / c_expDiffPeriod) - o = (u256)max(c_minimumDifficulty, bigint(o) - (bigint(1) << (periodCount - 1))); // latter will eventually become negative, so ensure it's a bigint. + unsigned periodCount = unsigned(_parent.number() + 1) / c_expDiffPeriod; + if (periodCount > 2) + o = (u256)max(c_minimumDifficulty, bigint(o) - (bigint(1) << (periodCount - 2))); // latter will eventually become negative, so ensure it's a bigint. return o; } From f00d58089d79e9494dec95da9a92bea2c970027c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 5 Aug 2015 00:12:18 +0200 Subject: [PATCH 09/11] Gah. Revert "fix" since it results in a build failure without corresponding FixedHash fix. --- libdevcrypto/Common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdevcrypto/Common.cpp b/libdevcrypto/Common.cpp index 4f7c28025..b0db3ea4f 100644 --- a/libdevcrypto/Common.cpp +++ b/libdevcrypto/Common.cpp @@ -367,7 +367,7 @@ Secret Nonce::next() { initialiseIfNeeded(); m_value = sha3(m_value); - return sha3(~m_value); // TODO: some sort of PRNG series. + return sha3(m_value); } void Nonce::resetInternal() From a0c84e1aaade755a614da3c803a6a675611e1e1e Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 5 Aug 2015 11:11:34 +0200 Subject: [PATCH 10/11] - becomes + --- libethcore/BlockInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 71f5469dd..53ff29626 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -209,7 +209,7 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const u256 o = max(c_minimumDifficulty, m_timestamp >= _parent.m_timestamp + c_durationLimit ? _parent.m_difficulty - (_parent.m_difficulty / c_difficultyBoundDivisor) : (_parent.m_difficulty + (_parent.m_difficulty / c_difficultyBoundDivisor))); unsigned periodCount = unsigned(_parent.number() + 1) / c_expDiffPeriod; if (periodCount > 2) - o = (u256)max(c_minimumDifficulty, bigint(o) - (bigint(1) << (periodCount - 2))); // latter will eventually become negative, so ensure it's a bigint. + o = max(c_minimumDifficulty, o + (u256(1) << (periodCount - 2))); // latter will eventually become huge, so ensure it's a bigint. return o; } From dccc9ac86c8e41fe4026d256628e98b5e9df0a5f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 5 Aug 2015 11:24:01 +0200 Subject: [PATCH 11/11] Fix comparison in diff adjustment. --- libethcore/BlockInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 53ff29626..c0fe1c8e4 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -208,7 +208,7 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const throw GenesisBlockCannotBeCalculated(); u256 o = max(c_minimumDifficulty, m_timestamp >= _parent.m_timestamp + c_durationLimit ? _parent.m_difficulty - (_parent.m_difficulty / c_difficultyBoundDivisor) : (_parent.m_difficulty + (_parent.m_difficulty / c_difficultyBoundDivisor))); unsigned periodCount = unsigned(_parent.number() + 1) / c_expDiffPeriod; - if (periodCount > 2) + if (periodCount > 1) o = max(c_minimumDifficulty, o + (u256(1) << (periodCount - 2))); // latter will eventually become huge, so ensure it's a bigint. return o; }