Browse Source

4MB block size with sapling

metaverse
jl777 6 years ago
parent
commit
91f355fd69
  1. 9
      src/chainparams.cpp
  2. 2
      src/consensus/consensus.h
  3. 3
      src/consensus/params.h
  4. 2
      src/komodo-tx.cpp
  5. 1
      src/komodo_defs.h
  6. 10
      src/main.cpp
  7. 4
      src/main.h
  8. 2
      src/merkleblock.cpp
  9. 2
      src/miner.cpp
  10. 2
      src/rpc/mining.cpp

9
src/chainparams.cpp

@ -89,6 +89,7 @@ class CMainParams : public CChainParams {
public:
CMainParams()
{
strNetworkID = "main";
strCurrencyUnits = "KMD";
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;
void CChainParams::SetCheckpointData(CChainParams::CCheckpointData checkpointData)
@ -213,6 +215,12 @@ void CChainParams::SetCheckpointData(CChainParams::CCheckpointData checkpointDat
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)
{
mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = height;
@ -224,6 +232,7 @@ void komodo_setactivation(int32_t height)
void *chainparams_commandline(void *ptr)
{
CChainParams::CCheckpointData checkpointData;
mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].MAX_BLOCKSIZE = 2000000;
while ( ASSETCHAINS_P2PPORT == 0 )
{
#ifdef _WIN32

2
src/consensus/consensus.h

@ -19,7 +19,7 @@ static const int32_t SAPLING_MIN_TX_VERSION = 4;
/** The maximum allowed Sapling transaction version (network rule) */
static const int32_t SAPLING_MAX_TX_VERSION = 4;
/** 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) */
extern unsigned int MAX_BLOCK_SIGOPS;
/** The maximum size of a transaction (network rule) */

3
src/consensus/params.h

@ -10,6 +10,8 @@
#include <boost/optional.hpp>
int32_t MAX_BLOCK_SIZE(int32_t height);
namespace Consensus {
/**
@ -40,7 +42,6 @@ struct NetworkUpgrade {
* Height of the first block for which the new consensus rules will be active
*/
int nActivationHeight;
/**
* 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

2
src/komodo-tx.cpp

@ -220,7 +220,7 @@ static void MutateTxAddInput(CMutableTransaction& tx, const std::string& strInpu
uint256 txid(uint256S(strTxid));
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
std::string strVout = vStrInputParts[1];

1
src/komodo_defs.h

@ -15,5 +15,6 @@
#define KOMODO_SAPLING_DEADLINE 1550188800 // Feb 15th, 2019
extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC;
int32_t MAX_BLOCK_SIZE();
#endif

10
src/main.cpp

@ -1089,7 +1089,7 @@ bool ContextualCheckTransaction(
// Rules that apply before Sapling:
if (!saplingActive) {
// 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)
return state.DoS(100, error("ContextualCheckTransaction(): size limits failed"),
REJECT_INVALID, "bad-txns-oversize");
@ -1311,7 +1311,7 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio
REJECT_INVALID, "bad-txns-vout-empty");
// 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
if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_TX_SIZE_AFTER_SAPLING)
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.
// 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"),
REJECT_INVALID, "bad-blk-length");
@ -5977,7 +5977,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
try {
// 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, 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();
while (!blkdat.eof()) {
boost::this_thread::interruption_point();
@ -5996,7 +5996,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
continue;
// read size
blkdat >> nSize;
if (nSize < 80 || nSize > MAX_BLOCK_SIZE)
if (nSize < 80 || nSize > MAX_BLOCK_SIZE(10000000))
continue;
} catch (const std::exception&) {
// no valid block header found; don't complain

4
src/main.h

@ -54,7 +54,7 @@ struct CNodeStateStats;
#define _COINBASE_MATURITY 100
/** 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;
/** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/
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;
// 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);
#define equihash_parameters_acceptable(N, K) \

2
src/merkleblock.cpp

@ -153,7 +153,7 @@ uint256 CPartialMerkleTree::ExtractMatches(std::vector<uint256> &vMatch) {
if (nTransactions == 0)
return uint256();
// 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();
// there can never be more hashes provided than one for every txid
if (vHash.size() > nTransactions)

2
src/miner.cpp

@ -179,7 +179,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
// Largest block you're willing to create:
unsigned int nBlockMaxSize = GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_SIZE);
// 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,
// included regardless of the fees they pay

2
src/rpc/mining.cpp

@ -795,7 +795,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
result.push_back(Pair("mutable", aMutable));
result.push_back(Pair("noncerange", "00000000ffffffff"));
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("bits", strprintf("%08x", pblock->nBits)));
result.push_back(Pair("height", (int64_t)(pindexPrev->GetHeight()+1)));

Loading…
Cancel
Save