Browse Source

Params & JSON file.

cl-refactor
Gav Wood 10 years ago
parent
commit
d7d8875399
  1. 2
      libdevcrypto/OverlayDB.cpp
  2. 19
      libethcore/BlockInfo.cpp
  3. 2
      libethcore/BlockInfo.h
  4. 11
      libethcore/Params.cpp
  5. 10
      libethcore/Params.h
  6. 2
      libethcore/ProofOfWork.cpp
  7. 2
      libethereum/Client.h
  8. 2
      libethereum/Interface.h
  9. 2
      libethereum/Precompiled.cpp
  10. 2
      libethereum/State.h
  11. 1
      libevm/All.h
  12. 2
      libevm/VM.h
  13. 2
      libsolidity/Types.cpp
  14. 10
      params.json

2
libdevcrypto/OverlayDB.cpp

@ -56,10 +56,8 @@ void OverlayDB::commit()
if (m_aux.count(i)) if (m_aux.count(i))
{ {
m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i]));
cdebug << "Committing aux: " << i;
m_aux.erase(i); m_aux.erase(i);
} }
cdebug << "Discarding " << keysOf(m_aux);
m_auxActive.clear(); m_auxActive.clear();
m_aux.clear(); m_aux.clear();
m_over.clear(); m_over.clear();

19
libethcore/BlockInfo.cpp

@ -25,13 +25,12 @@
#include <libethcore/CommonEth.h> #include <libethcore/CommonEth.h>
#include "ProofOfWork.h" #include "ProofOfWork.h"
#include "Exceptions.h" #include "Exceptions.h"
#include "Params.h"
#include "BlockInfo.h" #include "BlockInfo.h"
using namespace std; using namespace std;
using namespace dev; using namespace dev;
using namespace dev::eth; using namespace dev::eth;
u256 dev::eth::c_genesisDifficulty = (u256)1 << 11;
BlockInfo::BlockInfo(): timestamp(Invalid256) BlockInfo::BlockInfo(): timestamp(Invalid256)
{ {
} }
@ -128,7 +127,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce)
if (gasUsed > gasLimit) if (gasUsed > gasLimit)
BOOST_THROW_EXCEPTION(TooMuchGasUsed()); BOOST_THROW_EXCEPTION(TooMuchGasUsed());
if (number && extraData.size() > 1024) if (number && extraData.size() > c_maximumExtraDataSize)
BOOST_THROW_EXCEPTION(ExtraDataTooBig()); BOOST_THROW_EXCEPTION(ExtraDataTooBig());
} }
@ -185,23 +184,23 @@ void BlockInfo::populateFromParent(BlockInfo const& _parent)
h256 BlockInfo::calculateSeedHash(BlockInfo const& _parent) const h256 BlockInfo::calculateSeedHash(BlockInfo const& _parent) const
{ {
return number % 30 == 0 ? sha3(_parent.seedHash.asBytes()) : _parent.seedHash; return number % c_epochDuration == 0 ? sha3(_parent.seedHash.asBytes()) : _parent.seedHash;
} }
u256 BlockInfo::calculateGasLimit(BlockInfo const& _parent) const u256 BlockInfo::calculateGasLimit(BlockInfo const& _parent) const
{ {
if (!parentHash) if (!parentHash)
return 1000000; return c_genesisGasLimit;
else else
return max<u256>(125000, (_parent.gasLimit * (1024 - 1) + (_parent.gasUsed * 6 / 5)) / 1024); return max<u256>(c_minGasLimit, (_parent.gasLimit * (c_gasLimitBoundDivisor - 1) + (_parent.gasUsed * 6 / 5)) / c_gasLimitBoundDivisor);
} }
u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const
{ {
if (!parentHash) if (!parentHash)
return c_genesisDifficulty; return (u256)c_genesisDifficulty;
else else
return max<u256>(2048, timestamp >= _parent.timestamp + 8 ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); return max<u256>(c_minimumDifficulty, timestamp >= _parent.timestamp + c_durationLimit ? _parent.difficulty - (_parent.difficulty / c_difficultyBoundDivisor) : (_parent.difficulty + (_parent.difficulty / c_difficultyBoundDivisor)));
} }
template <class N> inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } template <class N> inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); }
@ -211,8 +210,8 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const
if (difficulty != calculateDifficulty(_parent)) if (difficulty != calculateDifficulty(_parent))
BOOST_THROW_EXCEPTION(InvalidDifficulty()); BOOST_THROW_EXCEPTION(InvalidDifficulty());
if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 2048) if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / c_gasLimitBoundDivisor)
BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 2048)); BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / c_gasLimitBoundDivisor));
if (seedHash != calculateSeedHash(_parent)) if (seedHash != calculateSeedHash(_parent))
BOOST_THROW_EXCEPTION(InvalidSeedHash()); BOOST_THROW_EXCEPTION(InvalidSeedHash());

2
libethcore/BlockInfo.h

@ -30,8 +30,6 @@ namespace dev
namespace eth namespace eth
{ {
extern u256 c_genesisDifficulty;
enum IncludeNonce enum IncludeNonce
{ {
WithoutNonce = 0, WithoutNonce = 0,

11
libevm/FeeStructure.cpp → libethcore/Params.cpp

@ -19,7 +19,7 @@
* @date 2014 * @date 2014
*/ */
#include "FeeStructure.h" #include "Params.h"
using namespace std; using namespace std;
namespace dev namespace dev
@ -28,6 +28,15 @@ namespace eth
{ {
//--- BEGIN: AUTOGENERATED FROM /feeStructure.json //--- BEGIN: AUTOGENERATED FROM /feeStructure.json
u256 const c_genesisDifficulty = 2048;
u256 const c_maximumExtraDataSize = 1024;
u256 const c_epochDuration = 3000;
u256 const c_genesisGasLimit = 1000000;
u256 const c_minGasLimit = 125000;
u256 const c_gasLimitBoundDivisor = 1024;
u256 const c_minimumDifficulty = 2048;
u256 const c_difficultyBoundDivisor = 2048;
u256 const c_durationLimit = 8;
u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0};
u256 const c_expGas = 10; u256 const c_expGas = 10;
u256 const c_expByteGas = 10; u256 const c_expByteGas = 10;

10
libevm/FeeStructure.h → libethcore/Params.h

@ -29,6 +29,16 @@ namespace eth
{ {
//--- BEGIN: AUTOGENERATED FROM /feeStructure.json //--- BEGIN: AUTOGENERATED FROM /feeStructure.json
extern u256 const c_genesisDifficulty;
extern u256 const c_maximumExtraDataSize;
extern u256 const c_epochDuration;
extern u256 const c_genesisGasLimit;
extern u256 const c_minGasLimit;
extern u256 const c_gasLimitBoundDivisor;
extern u256 const c_minimumDifficulty;
extern u256 const c_difficultyBoundDivisor;
extern u256 const c_durationLimit;
extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them.
extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expGas; ///< Once per EXP instuction.
extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction.

2
libethcore/ProofOfWork.cpp

@ -66,6 +66,7 @@ public:
writeFile(memoFile, m_caches[_header.seedHash]); writeFile(memoFile, m_caches[_header.seedHash]);
} }
} }
cdebug << "sha3 of cache: " << sha3(m_caches[_header.seedHash]);
return m_caches[_header.seedHash]; return m_caches[_header.seedHash];
} }
@ -90,6 +91,7 @@ public:
writeFile(memoFile, m_fulls[_header.seedHash]); writeFile(memoFile, m_fulls[_header.seedHash]);
} }
} }
cdebug << "sha3 of full pad: " << sha3(m_fulls[_header.seedHash]);
return m_fulls[_header.seedHash].data(); return m_fulls[_header.seedHash].data();
} }

2
libethereum/Client.h

@ -32,7 +32,7 @@
#include <libdevcore/CommonIO.h> #include <libdevcore/CommonIO.h>
#include <libdevcore/Guards.h> #include <libdevcore/Guards.h>
#include <libdevcore/Worker.h> #include <libdevcore/Worker.h>
#include <libevm/FeeStructure.h> #include <libethcore/Params.h>
#include <libp2p/Common.h> #include <libp2p/Common.h>
#include "CanonBlockChain.h" #include "CanonBlockChain.h"
#include "TransactionQueue.h" #include "TransactionQueue.h"

2
libethereum/Interface.h

@ -25,7 +25,7 @@
#include <libdevcore/CommonIO.h> #include <libdevcore/CommonIO.h>
#include <libdevcore/Guards.h> #include <libdevcore/Guards.h>
#include <libdevcrypto/Common.h> #include <libdevcrypto/Common.h>
#include <libevm/FeeStructure.h> #include <libethcore/Params.h>
#include "LogFilter.h" #include "LogFilter.h"
#include "Transaction.h" #include "Transaction.h"
#include "AccountDiff.h" #include "AccountDiff.h"

2
libethereum/Precompiled.cpp

@ -24,7 +24,7 @@
#include <libdevcrypto/SHA3.h> #include <libdevcrypto/SHA3.h>
#include <libdevcrypto/Common.h> #include <libdevcrypto/Common.h>
#include <libethcore/CommonEth.h> #include <libethcore/CommonEth.h>
#include <libevm/FeeStructure.h> #include <libethcore/Params.h>
using namespace std; using namespace std;
using namespace dev; using namespace dev;
using namespace dev::eth; using namespace dev::eth;

2
libethereum/State.h

@ -30,7 +30,7 @@
#include <libethcore/Exceptions.h> #include <libethcore/Exceptions.h>
#include <libethcore/BlockInfo.h> #include <libethcore/BlockInfo.h>
#include <libethcore/ProofOfWork.h> #include <libethcore/ProofOfWork.h>
#include <libevm/FeeStructure.h> #include <libethcore/Params.h>
#include <libevm/ExtVMFace.h> #include <libevm/ExtVMFace.h>
#include "TransactionQueue.h" #include "TransactionQueue.h"
#include "Account.h" #include "Account.h"

1
libevm/All.h

@ -1,5 +1,4 @@
#pragma once #pragma once
#include "ExtVMFace.h" #include "ExtVMFace.h"
#include "FeeStructure.h"
#include "VM.h" #include "VM.h"

2
libevm/VM.h

@ -27,7 +27,7 @@
#include <libevmcore/Instruction.h> #include <libevmcore/Instruction.h>
#include <libdevcrypto/SHA3.h> #include <libdevcrypto/SHA3.h>
#include <libethcore/BlockInfo.h> #include <libethcore/BlockInfo.h>
#include "FeeStructure.h" #include <libethcore/Params.h>
#include "VMFace.h" #include "VMFace.h"
namespace dev namespace dev

2
libsolidity/Types.cpp

@ -308,6 +308,8 @@ TypePointer IntegerConstantType::unaryOperatorResult(Token::Value _operator) con
case Token::Sub: case Token::Sub:
value = -m_value; value = -m_value;
break; break;
case Token::After:
return shared_from_this();
default: default:
return TypePointer(); return TypePointer();
} }

10
feeStructure.json → params.json

@ -1,4 +1,14 @@
var x = { var x = {
"genesisDifficulty": { "v": 2048, "d": "Difficulty of the Genesis block." },
"maximumExtraDataSize": { "v": 1024, "d": "Maximum size extra data may be after Genesis." },
"epochDuration": { "v": 3000, "d": "Duration between proof-of-work epochs." },
"genesisGasLimit": { "v": 1000000, "d": "Gas limit of the Genesis block." },
"minGasLimit": { "v": 125000, "d": "Minimum the gas limit may ever be." },
"gasLimitBoundDivisor": { "v": 1024, "d": "The bound divisor of the gas limit, used in update calculations." },
"minimumDifficulty": { "v": 2048, "d": "The minimum that the difficulty may ever be." },
"difficultyBoundDivisor": { "v": 2048, "d": "The bound divisor of the difficulty, used in the update calculations." },
"durationLimit": { "v": 8, "d": "The decision boundary on the blocktime duration used to determine whether difficulty should go up or not." },
"tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." },
"expGas": { "v": 10, "d": "Once per EXP instuction." }, "expGas": { "v": 10, "d": "Once per EXP instuction." },
"expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." },
Loading…
Cancel
Save