4MB block size with sapling
This commit is contained in:
@@ -89,6 +89,7 @@ class CMainParams : public CChainParams {
|
|||||||
public:
|
public:
|
||||||
CMainParams()
|
CMainParams()
|
||||||
{
|
{
|
||||||
|
|
||||||
strNetworkID = "main";
|
strNetworkID = "main";
|
||||||
strCurrencyUnits = "KMD";
|
strCurrencyUnits = "KMD";
|
||||||
bip44CoinType = 133; // As registered in https://github.com/satoshilabs/slips/blob/master/slip-0044.md (ZCASH, should be VRSC)
|
bip44CoinType = 133; // As registered in https://github.com/satoshilabs/slips/blob/master/slip-0044.md (ZCASH, should be VRSC)
|
||||||
@@ -206,6 +207,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static CMainParams mainParams;
|
static CMainParams mainParams;
|
||||||
|
|
||||||
void CChainParams::SetCheckpointData(CChainParams::CCheckpointData checkpointData)
|
void CChainParams::SetCheckpointData(CChainParams::CCheckpointData checkpointData)
|
||||||
@@ -213,6 +215,12 @@ void CChainParams::SetCheckpointData(CChainParams::CCheckpointData checkpointDat
|
|||||||
CChainParams::checkpointData = checkpointData;
|
CChainParams::checkpointData = checkpointData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t MAX_BLOCK_SIZE(int32_t height)
|
||||||
|
{
|
||||||
|
if ( height >= mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight )
|
||||||
|
return(4000000);
|
||||||
|
else return(2000000);
|
||||||
|
}
|
||||||
void komodo_setactivation(int32_t height)
|
void komodo_setactivation(int32_t height)
|
||||||
{
|
{
|
||||||
mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = height;
|
mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = height;
|
||||||
@@ -224,6 +232,7 @@ void komodo_setactivation(int32_t height)
|
|||||||
void *chainparams_commandline(void *ptr)
|
void *chainparams_commandline(void *ptr)
|
||||||
{
|
{
|
||||||
CChainParams::CCheckpointData checkpointData;
|
CChainParams::CCheckpointData checkpointData;
|
||||||
|
mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].MAX_BLOCKSIZE = 2000000;
|
||||||
while ( ASSETCHAINS_P2PPORT == 0 )
|
while ( ASSETCHAINS_P2PPORT == 0 )
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ static const int32_t SAPLING_MIN_TX_VERSION = 4;
|
|||||||
/** The maximum allowed Sapling transaction version (network rule) */
|
/** The maximum allowed Sapling transaction version (network rule) */
|
||||||
static const int32_t SAPLING_MAX_TX_VERSION = 4;
|
static const int32_t SAPLING_MAX_TX_VERSION = 4;
|
||||||
/** The maximum allowed size for a serialized block, in bytes (network rule) */
|
/** The maximum allowed size for a serialized block, in bytes (network rule) */
|
||||||
static const unsigned int MAX_BLOCK_SIZE = 2000000;
|
//static const unsigned int MAX_BLOCK_SIZE = 2000000;
|
||||||
/** The maximum allowed number of signature check operations in a block (network rule) */
|
/** The maximum allowed number of signature check operations in a block (network rule) */
|
||||||
extern unsigned int MAX_BLOCK_SIGOPS;
|
extern unsigned int MAX_BLOCK_SIGOPS;
|
||||||
/** The maximum size of a transaction (network rule) */
|
/** The maximum size of a transaction (network rule) */
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
|
int32_t MAX_BLOCK_SIZE(int32_t height);
|
||||||
|
|
||||||
namespace Consensus {
|
namespace Consensus {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +42,6 @@ struct NetworkUpgrade {
|
|||||||
* Height of the first block for which the new consensus rules will be active
|
* Height of the first block for which the new consensus rules will be active
|
||||||
*/
|
*/
|
||||||
int nActivationHeight;
|
int nActivationHeight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special value for nActivationHeight indicating that the upgrade is always active.
|
* Special value for nActivationHeight indicating that the upgrade is always active.
|
||||||
* This is useful for testing, as it means tests don't need to deal with the activation
|
* This is useful for testing, as it means tests don't need to deal with the activation
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ static void MutateTxAddInput(CMutableTransaction& tx, const std::string& strInpu
|
|||||||
uint256 txid(uint256S(strTxid));
|
uint256 txid(uint256S(strTxid));
|
||||||
|
|
||||||
static const unsigned int minTxOutSz = 9;
|
static const unsigned int minTxOutSz = 9;
|
||||||
static const unsigned int maxVout = MAX_BLOCK_SIZE / minTxOutSz;
|
static const unsigned int maxVout = MAX_BLOCK_SIZE(chainActive.LastTip()->GetHeight()+1) / minTxOutSz;
|
||||||
|
|
||||||
// extract and validate vout
|
// extract and validate vout
|
||||||
std::string strVout = vStrInputParts[1];
|
std::string strVout = vStrInputParts[1];
|
||||||
|
|||||||
@@ -15,5 +15,6 @@
|
|||||||
#define KOMODO_SAPLING_DEADLINE 1550188800 // Feb 15th, 2019
|
#define KOMODO_SAPLING_DEADLINE 1550188800 // Feb 15th, 2019
|
||||||
|
|
||||||
extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC;
|
extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC;
|
||||||
|
int32_t MAX_BLOCK_SIZE();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
10
src/main.cpp
10
src/main.cpp
@@ -1089,7 +1089,7 @@ bool ContextualCheckTransaction(
|
|||||||
// Rules that apply before Sapling:
|
// Rules that apply before Sapling:
|
||||||
if (!saplingActive) {
|
if (!saplingActive) {
|
||||||
// Size limits
|
// Size limits
|
||||||
BOOST_STATIC_ASSERT(MAX_BLOCK_SIZE > MAX_TX_SIZE_BEFORE_SAPLING); // sanity
|
BOOST_STATIC_ASSERT(MAX_BLOCK_SIZE(chainActive.LastTip()->GetHeight()+1) > MAX_TX_SIZE_BEFORE_SAPLING); // sanity
|
||||||
if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_TX_SIZE_BEFORE_SAPLING)
|
if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_TX_SIZE_BEFORE_SAPLING)
|
||||||
return state.DoS(100, error("ContextualCheckTransaction(): size limits failed"),
|
return state.DoS(100, error("ContextualCheckTransaction(): size limits failed"),
|
||||||
REJECT_INVALID, "bad-txns-oversize");
|
REJECT_INVALID, "bad-txns-oversize");
|
||||||
@@ -1311,7 +1311,7 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio
|
|||||||
REJECT_INVALID, "bad-txns-vout-empty");
|
REJECT_INVALID, "bad-txns-vout-empty");
|
||||||
|
|
||||||
// Size limits
|
// Size limits
|
||||||
BOOST_STATIC_ASSERT(MAX_BLOCK_SIZE >= MAX_TX_SIZE_AFTER_SAPLING); // sanity
|
BOOST_STATIC_ASSERT(MAX_BLOCK_SIZE(chainActive.LastTip()->GetHeight()+1) >= MAX_TX_SIZE_AFTER_SAPLING); // sanity
|
||||||
BOOST_STATIC_ASSERT(MAX_TX_SIZE_AFTER_SAPLING > MAX_TX_SIZE_BEFORE_SAPLING); // sanity
|
BOOST_STATIC_ASSERT(MAX_TX_SIZE_AFTER_SAPLING > MAX_TX_SIZE_BEFORE_SAPLING); // sanity
|
||||||
if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_TX_SIZE_AFTER_SAPLING)
|
if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_TX_SIZE_AFTER_SAPLING)
|
||||||
return state.DoS(100, error("CheckTransaction(): size limits failed"),
|
return state.DoS(100, error("CheckTransaction(): size limits failed"),
|
||||||
@@ -4645,7 +4645,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
|
|||||||
// because we receive the wrong transactions for it.
|
// because we receive the wrong transactions for it.
|
||||||
|
|
||||||
// Size limits
|
// Size limits
|
||||||
if (block.vtx.empty() || block.vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE)
|
if (block.vtx.empty() || block.vtx.size() > MAX_BLOCK_SIZE(height) || ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE(height))
|
||||||
return state.DoS(100, error("CheckBlock: size limits failed"),
|
return state.DoS(100, error("CheckBlock: size limits failed"),
|
||||||
REJECT_INVALID, "bad-blk-length");
|
REJECT_INVALID, "bad-blk-length");
|
||||||
|
|
||||||
@@ -5977,7 +5977,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
|
|||||||
try {
|
try {
|
||||||
// This takes over fileIn and calls fclose() on it in the CBufferedFile destructor
|
// This takes over fileIn and calls fclose() on it in the CBufferedFile destructor
|
||||||
//CBufferedFile blkdat(fileIn, 2*MAX_BLOCK_SIZE, MAX_BLOCK_SIZE+8, SER_DISK, CLIENT_VERSION);
|
//CBufferedFile blkdat(fileIn, 2*MAX_BLOCK_SIZE, MAX_BLOCK_SIZE+8, SER_DISK, CLIENT_VERSION);
|
||||||
CBufferedFile blkdat(fileIn, 32*MAX_BLOCK_SIZE, MAX_BLOCK_SIZE+8, SER_DISK, CLIENT_VERSION);
|
CBufferedFile blkdat(fileIn, 32*MAX_BLOCK_SIZE(10000000), MAX_BLOCK_SIZE(10000000)+8, SER_DISK, CLIENT_VERSION);
|
||||||
uint64_t nRewind = blkdat.GetPos();
|
uint64_t nRewind = blkdat.GetPos();
|
||||||
while (!blkdat.eof()) {
|
while (!blkdat.eof()) {
|
||||||
boost::this_thread::interruption_point();
|
boost::this_thread::interruption_point();
|
||||||
@@ -5996,7 +5996,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
|
|||||||
continue;
|
continue;
|
||||||
// read size
|
// read size
|
||||||
blkdat >> nSize;
|
blkdat >> nSize;
|
||||||
if (nSize < 80 || nSize > MAX_BLOCK_SIZE)
|
if (nSize < 80 || nSize > MAX_BLOCK_SIZE(10000000))
|
||||||
continue;
|
continue;
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
// no valid block header found; don't complain
|
// no valid block header found; don't complain
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ struct CNodeStateStats;
|
|||||||
#define _COINBASE_MATURITY 100
|
#define _COINBASE_MATURITY 100
|
||||||
|
|
||||||
/** Default for -blockmaxsize and -blockminsize, which control the range of sizes the mining code will create **/
|
/** Default for -blockmaxsize and -blockminsize, which control the range of sizes the mining code will create **/
|
||||||
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = MAX_BLOCK_SIZE;
|
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 2000000;//MAX_BLOCK_SIZE;
|
||||||
static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0;
|
static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0;
|
||||||
/** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/
|
/** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/
|
||||||
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = DEFAULT_BLOCK_MAX_SIZE / 2;
|
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = DEFAULT_BLOCK_MAX_SIZE / 2;
|
||||||
@@ -113,7 +113,7 @@ static const unsigned int DEFAULT_DB_MAX_OPEN_FILES = 1000;
|
|||||||
static const bool DEFAULT_DB_COMPRESSION = true;
|
static const bool DEFAULT_DB_COMPRESSION = true;
|
||||||
|
|
||||||
// Sanity check the magic numbers when we change them
|
// Sanity check the magic numbers when we change them
|
||||||
BOOST_STATIC_ASSERT(DEFAULT_BLOCK_MAX_SIZE <= MAX_BLOCK_SIZE);
|
BOOST_STATIC_ASSERT(DEFAULT_BLOCK_MAX_SIZE <= MAX_BLOCK_SIZE(10000000));
|
||||||
BOOST_STATIC_ASSERT(DEFAULT_BLOCK_PRIORITY_SIZE <= DEFAULT_BLOCK_MAX_SIZE);
|
BOOST_STATIC_ASSERT(DEFAULT_BLOCK_PRIORITY_SIZE <= DEFAULT_BLOCK_MAX_SIZE);
|
||||||
|
|
||||||
#define equihash_parameters_acceptable(N, K) \
|
#define equihash_parameters_acceptable(N, K) \
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ uint256 CPartialMerkleTree::ExtractMatches(std::vector<uint256> &vMatch) {
|
|||||||
if (nTransactions == 0)
|
if (nTransactions == 0)
|
||||||
return uint256();
|
return uint256();
|
||||||
// check for excessively high numbers of transactions
|
// check for excessively high numbers of transactions
|
||||||
if (nTransactions > MAX_BLOCK_SIZE / 60) // 60 is the lower bound for the size of a serialized CTransaction
|
if (nTransactions > MAX_BLOCK_SIZE(chainActive.LastTip()->GetHeight()+1) / 60) // 60 is the lower bound for the size of a serialized CTransaction
|
||||||
return uint256();
|
return uint256();
|
||||||
// there can never be more hashes provided than one for every txid
|
// there can never be more hashes provided than one for every txid
|
||||||
if (vHash.size() > nTransactions)
|
if (vHash.size() > nTransactions)
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
|||||||
// Largest block you're willing to create:
|
// Largest block you're willing to create:
|
||||||
unsigned int nBlockMaxSize = GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_SIZE);
|
unsigned int nBlockMaxSize = GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_SIZE);
|
||||||
// Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity:
|
// Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity:
|
||||||
nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE-1000), nBlockMaxSize));
|
nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE(chainActive.LastTip()->GetHeight()+1)-1000), nBlockMaxSize));
|
||||||
|
|
||||||
// How much of the block should be dedicated to high-priority transactions,
|
// How much of the block should be dedicated to high-priority transactions,
|
||||||
// included regardless of the fees they pay
|
// included regardless of the fees they pay
|
||||||
|
|||||||
@@ -795,7 +795,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
|||||||
result.push_back(Pair("mutable", aMutable));
|
result.push_back(Pair("mutable", aMutable));
|
||||||
result.push_back(Pair("noncerange", "00000000ffffffff"));
|
result.push_back(Pair("noncerange", "00000000ffffffff"));
|
||||||
result.push_back(Pair("sigoplimit", (int64_t)MAX_BLOCK_SIGOPS));
|
result.push_back(Pair("sigoplimit", (int64_t)MAX_BLOCK_SIGOPS));
|
||||||
result.push_back(Pair("sizelimit", (int64_t)MAX_BLOCK_SIZE));
|
result.push_back(Pair("sizelimit", (int64_t)MAX_BLOCK_SIZE(chainActive.LastTip()->GetHeight()+1)));
|
||||||
result.push_back(Pair("curtime", pblock->GetBlockTime()));
|
result.push_back(Pair("curtime", pblock->GetBlockTime()));
|
||||||
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits)));
|
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits)));
|
||||||
result.push_back(Pair("height", (int64_t)(pindexPrev->GetHeight()+1)));
|
result.push_back(Pair("height", (int64_t)(pindexPrev->GetHeight()+1)));
|
||||||
|
|||||||
Reference in New Issue
Block a user