Major rebase and fix staking.
This commit is contained in:
@@ -1112,7 +1112,6 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_
|
|||||||
commission must be in coinbase.vout[1] and must be >= 10000 sats
|
commission must be in coinbase.vout[1] and must be >= 10000 sats
|
||||||
PoS stake must be without txfee and in the last tx in the block at vout[0]
|
PoS stake must be without txfee and in the last tx in the block at vout[0]
|
||||||
*/
|
*/
|
||||||
extern int32_t ASSETCHAINS_FOUNDERS_PERIOD;
|
|
||||||
|
|
||||||
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
|
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
|
||||||
|
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
|
|||||||
if (is_STAKED(ASSETCHAINS_SYMBOL) == 0)
|
if (is_STAKED(ASSETCHAINS_SYMBOL) == 0)
|
||||||
{
|
{
|
||||||
if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 )
|
if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 )
|
||||||
{
|
timestamp = 0;
|
||||||
if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) )
|
if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) )
|
||||||
{
|
{
|
||||||
if ( did0 == 0 )
|
if ( did0 == 0 )
|
||||||
@@ -247,11 +247,8 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
|
|||||||
return(n1);
|
return(n1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (timestamp != 0)
|
||||||
else
|
|
||||||
{ // here we can activate our pubkeys for STAKED chains everythig is in notaries_staked.cpp
|
{ // here we can activate our pubkeys for STAKED chains everythig is in notaries_staked.cpp
|
||||||
if (timestamp != 0)
|
|
||||||
{
|
|
||||||
int32_t staked_era; int8_t numSN;
|
int32_t staked_era; int8_t numSN;
|
||||||
uint8_t staked_pubkeys[64][33];
|
uint8_t staked_pubkeys[64][33];
|
||||||
staked_era = STAKED_era(timestamp);
|
staked_era = STAKED_era(timestamp);
|
||||||
@@ -259,7 +256,6 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
|
|||||||
memcpy(pubkeys,staked_pubkeys,numSN * 33);
|
memcpy(pubkeys,staked_pubkeys,numSN * 33);
|
||||||
return(numSN);
|
return(numSN);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
htind = height / KOMODO_ELECTION_GAP;
|
htind = height / KOMODO_ELECTION_GAP;
|
||||||
if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP )
|
if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP )
|
||||||
|
|||||||
54
src/main.cpp
54
src/main.cpp
@@ -1244,7 +1244,8 @@ int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only
|
|||||||
{
|
{
|
||||||
if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 )
|
if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 )
|
||||||
{
|
{
|
||||||
if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) {
|
if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 )
|
||||||
|
{
|
||||||
for (int32_t i=0; i<=NUM_NOTARIES; i++)
|
for (int32_t i=0; i<=NUM_NOTARIES; i++)
|
||||||
if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 )
|
if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 )
|
||||||
return(1);
|
return(1);
|
||||||
@@ -1764,7 +1765,9 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|||||||
if (pfMissingInputs)
|
if (pfMissingInputs)
|
||||||
*pfMissingInputs = true;
|
*pfMissingInputs = true;
|
||||||
//fprintf(stderr,"missing inputs\n");
|
//fprintf(stderr,"missing inputs\n");
|
||||||
|
if (!fSkipExpiry)
|
||||||
return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing");
|
return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing");
|
||||||
|
else
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1773,7 +1776,10 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|||||||
if (!view.HaveInputs(tx))
|
if (!view.HaveInputs(tx))
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"accept failure.1\n");
|
//fprintf(stderr,"accept failure.1\n");
|
||||||
|
if (!fSkipExpiry)
|
||||||
return state.Invalid(error("AcceptToMemoryPool: inputs already spent"),REJECT_DUPLICATE, "bad-txns-inputs-spent");
|
return state.Invalid(error("AcceptToMemoryPool: inputs already spent"),REJECT_DUPLICATE, "bad-txns-inputs-spent");
|
||||||
|
else
|
||||||
|
return(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// are the joinsplit's requirements met?
|
// are the joinsplit's requirements met?
|
||||||
@@ -3302,7 +3308,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
{
|
{
|
||||||
if (!view.HaveInputs(tx))
|
if (!view.HaveInputs(tx))
|
||||||
{
|
{
|
||||||
return state.DoS(100, error("ConnectBlock(): inputs missing/spent"),
|
return state.DoS(100, error("ConnectBlock(): inputs missing/spent %s",tx.GetHash().ToString().c_str()),
|
||||||
REJECT_INVALID, "bad-txns-inputs-missingorspent");
|
REJECT_INVALID, "bad-txns-inputs-missingorspent");
|
||||||
}
|
}
|
||||||
// are the JoinSplit's requirements met?
|
// are the JoinSplit's requirements met?
|
||||||
@@ -3846,8 +3852,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
|
|||||||
if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0)))
|
if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0)))
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
TxToRemove.push_back(tx.GetHash());
|
pwalletMain->EraseFromWallet(tx.GetHash());
|
||||||
//pwalletMain->EraseFromWallet(tx.GetHash());
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -3855,25 +3860,6 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
|
|||||||
SyncWithWallets(tx, NULL);
|
SyncWithWallets(tx, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ASSETCHAINS_STAKED != 0 ) // If Staked chain, scan wallet for orphaned txs and delete them.
|
|
||||||
{
|
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
|
||||||
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
|
||||||
{
|
|
||||||
CTransaction tx;
|
|
||||||
uint256 hashBlock;
|
|
||||||
if (!GetTransaction((*it).first,tx,hashBlock,true))
|
|
||||||
{
|
|
||||||
fprintf(stderr, "TX Does Not Exist: %s\n",(*it).first.ToString().c_str());
|
|
||||||
TxToRemove.push_back((*it).first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BOOST_FOREACH (uint256& hash, TxToRemove)
|
|
||||||
{
|
|
||||||
pwalletMain->EraseFromWallet(hash);
|
|
||||||
fprintf(stderr, "Erased %s from wallet.\n",hash.ToString().c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Update cached incremental witnesses
|
// Update cached incremental witnesses
|
||||||
GetMainSignals().ChainTip(pindexDelete, &block, newSproutTree, newSaplingTree, false);
|
GetMainSignals().ChainTip(pindexDelete, &block, newSproutTree, newSaplingTree, false);
|
||||||
return true;
|
return true;
|
||||||
@@ -6601,33 +6587,21 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
CAddress addrFrom;
|
CAddress addrFrom;
|
||||||
uint64_t nNonce = 1;
|
uint64_t nNonce = 1;
|
||||||
int nVersion; // use temporary for version, don't set version number until validated as connected
|
int nVersion; // use temporary for version, don't set version number until validated as connected
|
||||||
|
int minVersion = MIN_PEER_PROTO_VERSION;
|
||||||
|
if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 )
|
||||||
|
minVersion = STAKEDMIN_PEER_PROTO_VERSION;
|
||||||
vRecv >> nVersion >> pfrom->nServices >> nTime >> addrMe;
|
vRecv >> nVersion >> pfrom->nServices >> nTime >> addrMe;
|
||||||
if (nVersion == 10300)
|
if (nVersion == 10300)
|
||||||
nVersion = 300;
|
nVersion = 300;
|
||||||
if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 )
|
if (nVersion < minVersion)
|
||||||
{
|
|
||||||
if (nVersion < STAKEDMIN_PEER_PROTO_VERSION)
|
|
||||||
{
|
{
|
||||||
// disconnect from peers older than this proto version
|
// disconnect from peers older than this proto version
|
||||||
LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion);
|
LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion);
|
||||||
pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE,
|
pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE,
|
||||||
strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION));
|
strprintf("Version must be %d or greater", minVersion));
|
||||||
pfrom->fDisconnect = true;
|
pfrom->fDisconnect = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (nVersion < MIN_PEER_PROTO_VERSION)
|
|
||||||
{
|
|
||||||
// disconnect from peers older than this proto version
|
|
||||||
LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion);
|
|
||||||
pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE,
|
|
||||||
strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION));
|
|
||||||
pfrom->fDisconnect = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reject incoming connections from nodes that don't know about the current epoch
|
// Reject incoming connections from nodes that don't know about the current epoch
|
||||||
const Consensus::Params& params = Params().GetConsensus();
|
const Consensus::Params& params = Params().GetConsensus();
|
||||||
|
|||||||
@@ -5317,7 +5317,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
|||||||
counter++;
|
counter++;
|
||||||
if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth )
|
if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth);
|
fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
CAmount nValue = out.tx->vout[out.i].nValue;
|
CAmount nValue = out.tx->vout[out.i].nValue;
|
||||||
@@ -5388,7 +5388,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
|||||||
}
|
}
|
||||||
} //else fprintf(stderr,"utxo not eligible\n");
|
} //else fprintf(stderr,"utxo not eligible\n");
|
||||||
}
|
}
|
||||||
if ( numkp < 10000 && array != 0 )
|
if ( numkp < 1000 && array != 0 )
|
||||||
{
|
{
|
||||||
free(array);
|
free(array);
|
||||||
array = 0;
|
array = 0;
|
||||||
|
|||||||
@@ -867,8 +867,6 @@ static bool IsKeyType(string strType)
|
|||||||
strType == "mkey" || strType == "ckey");
|
strType == "mkey" || strType == "ckey");
|
||||||
}
|
}
|
||||||
|
|
||||||
extern uint64_t ASSETCHAINS_STAKED;
|
|
||||||
|
|
||||||
DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||||
{
|
{
|
||||||
pwallet->vchDefaultKey = CPubKey();
|
pwallet->vchDefaultKey = CPubKey();
|
||||||
@@ -920,9 +918,8 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
|||||||
{
|
{
|
||||||
// Leave other errors alone, if we try to fix them we might make things worse.
|
// Leave other errors alone, if we try to fix them we might make things worse.
|
||||||
fNoncriticalErrors = true; // ... but do warn the user there is something wrong.
|
fNoncriticalErrors = true; // ... but do warn the user there is something wrong.
|
||||||
if (strType == "tx" && ASSETCHAINS_STAKED == 0 )
|
if (strType == "tx" )
|
||||||
// Rescan if there is a bad transaction record..
|
// Rescan if there is a bad transaction record..
|
||||||
// But dont on staked chains!
|
|
||||||
SoftSetBoolArg("-rescan", true);
|
SoftSetBoolArg("-rescan", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user