Lenient banscore
This commit is contained in:
47
src/komodo.h
47
src/komodo.h
@@ -507,6 +507,31 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t komodo_validate_chain(uint256 srchash,int32_t notarized_height)
|
||||||
|
{
|
||||||
|
static int32_t last_rewind; int32_t rewindtarget; CBlockIndex *pblock; struct komodo_state *sp; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN];
|
||||||
|
if ( (sp= komodo_stateptr(symbol,dest)) == 0 )
|
||||||
|
return(0);
|
||||||
|
if ( IsInitialBlockDownload() == 0 && ((pindex= mapBlockIndex[srchash]) == 0 || pindex->nHeight != notarizedheight) )
|
||||||
|
{
|
||||||
|
if ( sp->NOTARIZED_HEIGHT > 0 && sp->NOTARIZED_HEIGHT < notarizedheight )
|
||||||
|
rewindtarget = sp->NOTARIZED_HEIGHT - 1;
|
||||||
|
else if ( *notarizedheightp > 101 )
|
||||||
|
rewindtarget = notarizedheight - 101;
|
||||||
|
else rewindtarget = 0;
|
||||||
|
if ( rewindtarget != 0 && rewindtarget > KOMODO_REWIND && rewindtarget > last_rewind )
|
||||||
|
{
|
||||||
|
if ( last_rewind != 0 )
|
||||||
|
{
|
||||||
|
KOMODO_REWIND = rewindtarget;
|
||||||
|
fprintf(stderr,"%s FORK detected. notarized.%d %s not in this chain! last notarization %d -> rewindtarget.%d\n",ASSETCHAINS_SYMBOL,notarizedheight,srchash.ToString().c_str(),sp->NOTARIZED_HEIGHT,rewindtarget);
|
||||||
|
}
|
||||||
|
last_rewind = rewindtarget;
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
} else return(1);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp)
|
int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp)
|
||||||
{
|
{
|
||||||
static uint256 zero; static FILE *signedfp;
|
static uint256 zero; static FILE *signedfp;
|
||||||
@@ -557,8 +582,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
|||||||
}
|
}
|
||||||
if ( scriptbuf[len++] == 0x6a )
|
if ( scriptbuf[len++] == 0x6a )
|
||||||
{
|
{
|
||||||
static int32_t last_rewind; int32_t rewindtarget,validated = 0,nameoffset,opoffset = 0; CBlockIndex *pindex;//
|
|
||||||
struct komodo_ccdata ccdata; struct komodo_ccdataMoMoM MoMoMdata;
|
struct komodo_ccdata ccdata; struct komodo_ccdataMoMoM MoMoMdata;
|
||||||
|
int32_t validated = 0,nameoffset,opoffset = 0;
|
||||||
if ( (opretlen= scriptbuf[len++]) == 0x4c )
|
if ( (opretlen= scriptbuf[len++]) == 0x4c )
|
||||||
opretlen = scriptbuf[len++];
|
opretlen = scriptbuf[len++];
|
||||||
else if ( opretlen == 0x4d )
|
else if ( opretlen == 0x4d )
|
||||||
@@ -598,23 +623,9 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
|||||||
len += iguana_rwnum(0,&scriptbuf[len],sizeof(*notarizedheightp),(uint8_t *)notarizedheightp);
|
len += iguana_rwnum(0,&scriptbuf[len],sizeof(*notarizedheightp),(uint8_t *)notarizedheightp);
|
||||||
if ( matched != 0 )
|
if ( matched != 0 )
|
||||||
len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid);
|
len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid);
|
||||||
if ( matched != 0 && IsInitialBlockDownload() == 0 && ((pindex= mapBlockIndex[srchash]) == 0 || pindex->nHeight != *notarizedheightp) )
|
if ( matched != 0 )
|
||||||
{
|
validated = komodo_validate_chain(srchash,*notarizedheightp);
|
||||||
if ( sp->NOTARIZED_HEIGHT > 0 && sp->NOTARIZED_HEIGHT < *notarizedheightp )
|
else validated = 1;
|
||||||
rewindtarget = sp->NOTARIZED_HEIGHT - 1;
|
|
||||||
else if ( *notarizedheightp > 101 )
|
|
||||||
rewindtarget = *notarizedheightp - 101;
|
|
||||||
else rewindtarget = 0;
|
|
||||||
if ( rewindtarget != 0 && rewindtarget > KOMODO_REWIND && rewindtarget > last_rewind )
|
|
||||||
{
|
|
||||||
if ( last_rewind != 0 )
|
|
||||||
{
|
|
||||||
KOMODO_REWIND = rewindtarget;
|
|
||||||
fprintf(stderr,"%s FORK detected. notarized.%d %s not in this chain! last notarization %d -> rewindtarget.%d\n",ASSETCHAINS_SYMBOL,*notarizedheightp,srchash.ToString().c_str(),sp->NOTARIZED_HEIGHT,rewindtarget);
|
|
||||||
}
|
|
||||||
last_rewind = rewindtarget;
|
|
||||||
}
|
|
||||||
} else validated = 1;
|
|
||||||
if ( notarized != 0 && validated != 0 )
|
if ( notarized != 0 && validated != 0 )
|
||||||
{
|
{
|
||||||
//sp->NOTARIZED_HEIGHT = *notarizedheightp;
|
//sp->NOTARIZED_HEIGHT = *notarizedheightp;
|
||||||
|
|||||||
14
src/main.cpp
14
src/main.cpp
@@ -1242,11 +1242,14 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|||||||
return error("AcceptToMemoryPool: komodo_validate_interest failed");
|
return error("AcceptToMemoryPool: komodo_validate_interest failed");
|
||||||
}
|
}
|
||||||
if (!CheckTransaction(tx, state, verifier))
|
if (!CheckTransaction(tx, state, verifier))
|
||||||
return error("AcceptToMemoryPool: CheckTransaction failed");
|
{
|
||||||
|
|
||||||
|
return error("AcceptToMemoryPool: CheckTransaction failed");
|
||||||
|
}
|
||||||
// DoS level set to 10 to be more forgiving.
|
// DoS level set to 10 to be more forgiving.
|
||||||
// Check transaction contextually against the set of consensus rules which apply in the next block to be mined.
|
// Check transaction contextually against the set of consensus rules which apply in the next block to be mined.
|
||||||
if (!ContextualCheckTransaction(tx, state, nextBlockHeight, 10)) {
|
if (!ContextualCheckTransaction(tx, state, nextBlockHeight, 10))
|
||||||
|
{
|
||||||
return error("AcceptToMemoryPool: ContextualCheckTransaction failed");
|
return error("AcceptToMemoryPool: ContextualCheckTransaction failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1850,7 +1853,7 @@ void Misbehaving(NodeId pnode, int howmuch)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
state->nMisbehavior += howmuch;
|
state->nMisbehavior += howmuch;
|
||||||
int banscore = GetArg("-banscore", 100);
|
int banscore = GetArg("-banscore", 5000);
|
||||||
if (state->nMisbehavior >= banscore && state->nMisbehavior - howmuch < banscore)
|
if (state->nMisbehavior >= banscore && state->nMisbehavior - howmuch < banscore)
|
||||||
{
|
{
|
||||||
LogPrintf("%s: %s (%d -> %d) BAN THRESHOLD EXCEEDED\n", __func__, state->name, state->nMisbehavior-howmuch, state->nMisbehavior);
|
LogPrintf("%s: %s (%d -> %d) BAN THRESHOLD EXCEEDED\n", __func__, state->name, state->nMisbehavior-howmuch, state->nMisbehavior);
|
||||||
@@ -3865,9 +3868,12 @@ bool ProcessNewBlock(int32_t height,CValidationState &state, CNode* pfrom, CBloc
|
|||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
bool fRequested = MarkBlockAsReceived(pblock->GetHash());
|
bool fRequested = MarkBlockAsReceived(pblock->GetHash());
|
||||||
fRequested |= fForceProcessing;
|
fRequested |= fForceProcessing;
|
||||||
if (!checked) {
|
if (!checked)
|
||||||
|
{
|
||||||
if ( pfrom != 0 )
|
if ( pfrom != 0 )
|
||||||
|
{
|
||||||
Misbehaving(pfrom->GetId(), 1);
|
Misbehaving(pfrom->GetId(), 1);
|
||||||
|
}
|
||||||
return error("%s: CheckBlock FAILED", __func__);
|
return error("%s: CheckBlock FAILED", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
|||||||
|
|
||||||
if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight))
|
if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight))
|
||||||
continue;
|
continue;
|
||||||
if ( komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,2) < 0 )
|
if ( komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure\n");
|
fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure\n");
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -803,7 +803,7 @@ UniValue minerids(const UniValue& params, bool fHelp)
|
|||||||
if ( pblockindex != 0 )
|
if ( pblockindex != 0 )
|
||||||
timestamp = pblockindex->GetBlockTime();
|
timestamp = pblockindex->GetBlockTime();
|
||||||
}
|
}
|
||||||
if ( 0 && (n= komodo_minerids(minerids,height,(int32_t)(sizeof(minerids)/sizeof(*minerids)))) > 0 )
|
if ( (n= komodo_minerids(minerids,height,(int32_t)(sizeof(minerids)/sizeof(*minerids)))) > 0 )
|
||||||
{
|
{
|
||||||
memset(tally,0,sizeof(tally));
|
memset(tally,0,sizeof(tally));
|
||||||
numnotaries = komodo_notaries(pubkeys,height,timestamp);
|
numnotaries = komodo_notaries(pubkeys,height,timestamp);
|
||||||
|
|||||||
Reference in New Issue
Block a user