Skip to content

Commit

Permalink
Merge branch ‘dev’ into release
Browse files Browse the repository at this point in the history
  • Loading branch information
renovoner committed Jun 27, 2022
1 parent 1fcfc91 commit 2e29dc8
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 6 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 2)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, false)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2022)
define(_COPYRIGHT_HOLDERS,[The %s developers])
define(_COPYRIGHT_HOLDERS_SUBSTITUTION,[[Bitcoin Core and Dogecoin Core and Novo]])
Expand Down
13 changes: 9 additions & 4 deletions doc/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Release Notes for Novo version 0.2.0rc2
# Release Notes for Novo version 0.2.0

Novo version 0.2.0rc2 is released.
Novo version 0.2.0 is released.

It includes a number of improvements to RC1.
If nothing else, it will soon become official version 0.2.0.
1. Opcode being compatible with v0.1.2
2. Dust is now a fixed value (0.4368 Novo)
3. FeeRate is set to 0.8 Novo/KB, consistent with v0.1.2.
4. RPC is modified and basically compatible with v0.1.2.
5. GUI is removed.
6. Alert system is removed.
7. Hark fork is scheduled at height 130000 to disable RichTXID.
3 changes: 2 additions & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ class CMainParams : public CChainParams {
// difficulty is cut in half. Doubled if blocks are ahead of schedule.
consensus.nUnsteadyASERTHalfLife = UNSTEADY_ASERT_HALF_LIFE;
consensus.nSteadyASERTHalfLife = STEADY_ASERT_HALF_LIFE;
consensus.SteadyASERTHeight = 0;
consensus.SteadyASERTHeight = 130000;
consensus.DisableRichTxIDHeight = 130000;

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0000000000000000000000000000000000000000000000000000d9e4a0215757");
Expand Down
1 change: 1 addition & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct Params {
/** Block height at which BIP66 becomes active */
int32_t BIP66Height;

int32_t DisableRichTxIDHeight;
int32_t SteadyASERTHeight;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ class CTransaction
// CURRENT_VERSION and MAX_STANDARD_VERSION will be equal.
static const int32_t MAX_STANDARD_VERSION = 2;

static const int32_t RICHTX_VERSION = 2;

// The local variables are made const to prevent unintended modification
// without updating the cached hash value. However, CTransaction is not
// actually immutable; deserialization and assignment are implemented,
Expand Down
92 changes: 92 additions & 0 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,97 @@ UniValue getchaintips(const JSONRPCRequest& request)
return res;
}


UniValue getchaintxstats(const JSONRPCRequest &request) {
if (request.fHelp || request.params.size() > 2) {
throw std::runtime_error(
"getchaintxstats"
"\nCompute statistics about the total number and rate of transactions in the chain.\n"
"\nArguments:\n"
"1. nblocks (numeric, optional, default=\"one month\") Size of the window in number of blocks"
"2. \"blockhash\" (string, optional, default=\"\") The hash of the block that ends the window."
"\nResult:\n"
"{\n"
" \"time\": xxxxx, (numeric) The "
"timestamp for the final block in the window in UNIX format.\n"
" \"txcount\": xxxxx, (numeric) The total "
"number of transactions in the chain up to that point.\n"
" \"window_final_block_hash\": \"...\", (string) The hash of "
"the final block in the window.\n"
" \"window_block_count\": xxxxx, (numeric) Size of "
"the window in number of blocks.\n"
" \"window_tx_count\": xxxxx, (numeric) The number "
"of transactions in the window. Only returned if "
"\"window_block_count\" is > 0.\n"
" \"window_interval\": xxxxx, (numeric) The elapsed "
"time in the window in seconds. Only returned if "
"\"window_block_count\" is > 0.\n"
" \"txrate\": x.xx, (numeric) The average "
"rate of transactions per second in the window. Only returned if "
"\"window_interval\" is > 0.\n"
"}\n"
"\nExamples:\n" +
HelpExampleCli("getchaintxstats", "") +
HelpExampleRpc("getchaintxstats", "2016"));
}

const CBlockIndex *pindex;

// By default: 1 month
int blockcount = 30 * 24 * 60 * 60 /
Params().GetConsensus().nPowTargetSpacing;

if (request.params[1].isNull()) {
LOCK(cs_main);
pindex = chainActive.Tip();
} else {
std::string strHash = request.params[1].get_str();
uint256 hash(uint256S(strHash));
LOCK(cs_main);
if (mapBlockIndex.count(hash) == 0)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
pindex = mapBlockIndex[hash];
if (!chainActive.Contains(pindex)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block is not in main chain");
}
}

assert(pindex != nullptr);

if (request.params[0].isNull()) {
blockcount = std::max(0, std::min(blockcount, pindex->nHeight - 1));
} else {
blockcount = request.params[0].get_int();

if (blockcount < 0 ||
(blockcount > 0 && blockcount >= pindex->nHeight)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block count: "
"should be between 0 and "
"the block's height - 1");
}
}

const CBlockIndex *pindexPast =
pindex->GetAncestor(pindex->nHeight - blockcount);
int nTimeDiff =
pindex->GetMedianTimePast() - pindexPast->GetMedianTimePast();
int nTxDiff = pindex->nChainTx - pindexPast->nChainTx;

UniValue ret(UniValue::VOBJ);
ret.pushKV("time", pindex->GetBlockTime());
ret.pushKV("txcount", (int64_t) pindex->nChainTx);
ret.pushKV("window_final_block_hash", pindex->GetBlockHash().GetHex());
ret.pushKV("window_block_count", (int64_t) blockcount);
if (blockcount > 0) {
ret.pushKV("window_tx_count", (int64_t) nTxDiff);
ret.pushKV("window_interval", (int64_t) nTimeDiff);
if (nTimeDiff > 0) {
ret.pushKV("txrate", double(nTxDiff) / nTimeDiff);
}
}
return ret;
}

UniValue mempoolInfoToJSON()
{
UniValue ret(UniValue::VOBJ);
Expand Down Expand Up @@ -1437,6 +1528,7 @@ static const CRPCCommand commands[] =
{ "blockchain", "getblockhash", &getblockhash, true, {"height"} },
{ "blockchain", "getblockheader", &getblockheader, true, {"blockhash","verbose"} },
{ "blockchain", "getchaintips", &getchaintips, true, {} },
{ "blockchain", "getchaintxstats", &getchaintxstats, true, {"nblocks", "blockhash"} },
{ "blockchain", "getdifficulty", &getdifficulty, true, {} },
{ "blockchain", "getmempoolancestors", &getmempoolancestors, true, {"txid","verbose"} },
{ "blockchain", "getmempooldescendants", &getmempooldescendants, true, {"txid","verbose"} },
Expand Down
1 change: 1 addition & 0 deletions src/rpc/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "listunspent", 4, "query_options" },
{ "getblock", 1, "verbose" },
{ "getblockheader", 1, "verbose" },
{ "getchaintxstats", 0, "nblocks"},
{ "gettransaction", 1, "include_watchonly" },
{ "getrawtransaction", 1, "verbose" },
{ "createrawtransaction", 0, "inputs" },
Expand Down
18 changes: 18 additions & 0 deletions src/rpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,23 @@ UniValue stop(const JSONRPCRequest& jsonRequest)
return "Novo server stopping";
}

UniValue uptime(const JSONRPCRequest &jsonRequest) {
if (jsonRequest.fHelp || jsonRequest.params.size() > 0) {
throw std::runtime_error(
"uptime\n"
"\nReturns the total uptime of the server.\n"
"\nResult:\n"
"{\n"
" \"ttt\": xxx, (numeric) The number of seconds that the server has been running\n"
"}\n"
"\nExamples:\n" +
HelpExampleCli("uptime", "") +
HelpExampleRpc("uptime", ""));
}

return GetTime() - GetStartupTime();
}

/**
* Call Table
*/
Expand All @@ -276,6 +293,7 @@ static const CRPCCommand vRPCCommands[] =
/* Overall control/query calls */
{ "control", "help", &help, true, {"command"} },
{ "control", "stop", &stop, true, {} },
{ "control", "uptime", &uptime, true, {} },
};

CRPCTable::CRPCTable()
Expand Down
7 changes: 7 additions & 0 deletions src/utiltime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ using namespace std;

static int64_t nMockTime = 0; //!< For unit testing

const int64_t nStartupTime = GetTime();

// Obtain the application startup time (used for uptime calculation)
int64_t GetStartupTime() {
return nStartupTime;
}

int64_t GetTime()
{
if (nMockTime) return nMockTime;
Expand Down
1 change: 1 addition & 0 deletions src/utiltime.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ int64_t GetTimeMillis();
int64_t GetTimeMicros();
int64_t GetSystemTimeInSeconds(); // Like GetTime(), but not mockable
int64_t GetLogTimeMicros();
int64_t GetStartupTime();
void SetMockTime(int64_t nMockTimeIn);
void MilliSleep(int64_t n);

Expand Down
6 changes: 6 additions & 0 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,12 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe
return state.DoS(10, false, REJECT_INVALID, "bad-txns-prevout-null");
}

// disable RichTX
const Consensus::Params& consensus = Params().GetConsensus();
if (consensus.DisableRichTxIDHeight > 0 && chainActive.Height() >= consensus.DisableRichTxIDHeight)
if (tx.nVersion == CTransaction::RICHTX_VERSION)
return state.DoS(0, false, REJECT_INVALID, "bad-txns-richtx");

return true;
}

Expand Down

0 comments on commit 2e29dc8

Please sign in to comment.