Hush DPoW won't attack their own villages, lulz

This commit is contained in:
Duke Leto
2020-12-07 08:24:09 -05:00
parent 8db68f55c6
commit 4f27af7545
5 changed files with 14 additions and 14 deletions

View File

@@ -287,7 +287,7 @@ int32_t komodo_prevMoMheight()
return(0);
}
int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp)
int32_t hush_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp)
{
char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp;
*prevMoMheightp = 0;

View File

@@ -674,7 +674,7 @@ bool komodo_dailysnapshot(int32_t height)
int reorglimit = 100;
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,undo_height,extraoffset;
// NOTE: To make this 100% safe under all sync conditions, it should be using a notarized notarization, from the DB.
// Under heavy reorg attack, its possible `komodo_notarized_height` can return a height that can't be found on chain sync.
// Under heavy reorg attack, its possible `hush_notarized_height` can return a height that can't be found on chain sync.
// However, the DB can reorg the last notarization. By using 2 deep, we know 100% that the previous notarization cannot be reorged by online nodes,
// and as such will always be notarizing the same height. May need to check heights on scan back to make sure they are confirmed in correct order.
if ( (extraoffset= height % KOMODO_SNAPSHOT_INTERVAL) != 0 )
@@ -691,7 +691,7 @@ bool komodo_dailysnapshot(int32_t height)
else
{
// we are at the right height in connect block to scan back to last notarized height.
notarized_height = komodo_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);
notarized_height = hush_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);
notarized_height > height-reorglimit ? undo_height = notarized_height : undo_height = height-reorglimit;
}
fprintf(stderr, "doing snapshot for height.%i undo_height.%i\n", height, undo_height);
@@ -3976,7 +3976,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
//if ( SMART_CHAIN_SYMBOL[0] != 0 || pindexDelete->GetHeight() > 1400000 )
{
int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid;
notarizedht = komodo_notarized_height(&prevMoMheight,&notarizedhash,&txid);
notarizedht = hush_notarized_height(&prevMoMheight,&notarizedhash,&txid);
if ( block.GetHash() == notarizedhash )
{
fprintf(stderr,"DisconnectTip trying to disconnect notarized block at ht.%d\n",(int32_t)pindexDelete->GetHeight());
@@ -4340,7 +4340,7 @@ static bool ActivateBestChainStep(bool fSkipdpow, CValidationState &state, CBloc
// stop trying to reorg if the reorged chain is before last notarized height.
// stay on the same chain tip!
int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid;
notarizedht = komodo_notarized_height(&prevMoMheight,&notarizedhash,&txid);
notarizedht = hush_notarized_height(&prevMoMheight,&notarizedhash,&txid);
if ( !fSkipdpow && pindexFork != 0 && pindexOldTip->GetHeight() > notarizedht && pindexFork->GetHeight() < notarizedht )
{
LogPrintf("pindexOldTip->GetHeight().%d > notarizedht %d && pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexOldTip->GetHeight(),notarizedht,(int32_t)pindexFork->GetHeight(),notarizedht);
@@ -5886,7 +5886,7 @@ uint64_t CalculateCurrentUsage()
bool PruneOneBlockFile(bool tempfile, const int fileNumber)
{
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height;
notarized_height = komodo_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);
notarized_height = hush_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);
//fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15);
for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it)
{

View File

@@ -54,7 +54,7 @@ extern int32_t HUSH_INSYNC;
extern bool fZindex;
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry);
void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp);
int32_t hush_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp);
#include "hush_defs.h"
#include "hush_structs.h"
@@ -138,7 +138,7 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex)
return(result);
}
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height;
notarized_height = komodo_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);
notarized_height = hush_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);
result.push_back(Pair("last_notarized_height", notarized_height));
result.push_back(Pair("hash", blockindex->GetBlockHash().GetHex()));
int confirmations = -1;
@@ -292,7 +292,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
{
UniValue result(UniValue::VOBJ);
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height;
notarized_height = komodo_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);
notarized_height = hush_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);
result.push_back(Pair("last_notarized_height", notarized_height));
result.push_back(Pair("hash", block.GetHash().GetHex()));
int confirmations = -1;
@@ -1654,7 +1654,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp, const CPubKey& my
int32_t longestchain = HUSH_LONGESTCHAIN;//hush_longestchain();
progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 1.0;
}
notarized_height = komodo_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);
notarized_height = hush_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("chain", Params().NetworkIDString()));
obj.push_back(Pair("blocks", (int)chainActive.Height()));

View File

@@ -56,7 +56,7 @@ using namespace std;
uint64_t komodo_interestsum();
int32_t hush_longestchain();
int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp);
int32_t hush_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp);
bool komodo_txnotarizedconfirmed(uint256 txid);
uint32_t komodo_chainactive_timestamp();
int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp);
@@ -219,7 +219,7 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
proxyType proxy;
GetProxy(NET_IPV4, proxy);
notarized_height = komodo_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);
notarized_height = hush_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);
//fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL));
UniValue obj(UniValue::VOBJ);

View File

@@ -52,7 +52,7 @@
#include <univalue.h>
int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp);
int32_t hush_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp);
using namespace std;
@@ -133,7 +133,7 @@ int32_t myIsutxo_spent(uint256 &spenttxid,uint256 txid,int32_t vout)
void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& entry, int nHeight = 0, int nConfirmations = 0, int nBlockTime = 0)
{
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height;
notarized_height = komodo_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);
notarized_height = hush_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);
uint256 txid = tx.GetHash();
entry.push_back(Pair("txid", txid.GetHex()));
entry.push_back(Pair("overwintered", tx.fOverwintered));