Add notarypay to eras, for main chain.
This commit is contained in:
@@ -885,7 +885,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
|
||||
break;
|
||||
}
|
||||
// Notary pay chains need notarisation in position 1, ignore the rest on validation. Check notarisation is 1 on check.
|
||||
if ( !fJustCheck && ASSETCHAINS_NOTARY_PAY != 0 && i > 1)
|
||||
if ( !fJustCheck && i > 1 && ASSETCHAINS_NOTARY_PAY[0] != 0 )
|
||||
break;
|
||||
txhash = block.vtx[i].GetHash();
|
||||
numvouts = block.vtx[i].vout.size();
|
||||
|
||||
@@ -1778,8 +1778,21 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height)
|
||||
|
||||
int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt);
|
||||
|
||||
uint64_t komodo_notarypayamount(int64_t notarycount)
|
||||
uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount)
|
||||
{
|
||||
int8_t curEra = 0;
|
||||
// if we have an end block in the first era, find our current era
|
||||
if ( ASSETCHAINS_ENDSUBSIDY[0] > 1 )
|
||||
{
|
||||
for ( curEra = 0; curEra <= ASSETCHAINS_LASTERA; curEra++ )
|
||||
{
|
||||
if ( ASSETCHAINS_ENDSUBSIDY[curEra] > nHeight || ASSETCHAINS_ENDSUBSIDY[curEra] == 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( curEra > ASSETCHAINS_LASTERA )
|
||||
return(0);
|
||||
|
||||
if ( notarycount == 0 )
|
||||
{
|
||||
fprintf(stderr, "komodo_notarypayamount failed num notaries is 0!\n");
|
||||
@@ -1798,16 +1811,16 @@ uint64_t komodo_notarypayamount(int64_t notarycount)
|
||||
return(0);
|
||||
}
|
||||
if ( prevnotarizedht == pprevnotarizedht )
|
||||
return(0); // cant happen, sanity check.
|
||||
return(0); // cant happen, sanity check.
|
||||
|
||||
// use the previous height and the height before that to guarentee that the notarzations used to calculate these values,
|
||||
// are them selves actually notarised and cannot be reorged.
|
||||
// are them selves actually notarised and cannot be reorged.
|
||||
int32_t n = prevnotarizedht - pprevnotarizedht;
|
||||
|
||||
fprintf(stderr, "blocks since last notarization: %i\n",n);
|
||||
// multiply the amount possible to be used for each block by the amount of blocks passed
|
||||
// to get the total posible to be paid for this notarisation.
|
||||
AmountToPay = ASSETCHAINS_NOTARY_PAY*n;
|
||||
AmountToPay = ASSETCHAINS_NOTARY_PAY[curEra]*n;
|
||||
fprintf(stderr, "era.%i paying total of %lu for %i blocks\n",curEra,AmountToPay,n);
|
||||
ret = AmountToPay / notarycount;
|
||||
return(ret);
|
||||
}
|
||||
@@ -1859,7 +1872,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &Notar
|
||||
txNew.vout.resize(NotarisationNotaries.size()+1);
|
||||
|
||||
// Calcualte the amount to pay. If 0, means not enough notarizations to calcuate amount.
|
||||
AmountToPay = komodo_notarypayamount(NotarisationNotaries.size());
|
||||
AmountToPay = komodo_notarypayamount(height,NotarisationNotaries.size());
|
||||
if ( AmountToPay == 0 )
|
||||
return(0);
|
||||
|
||||
@@ -1973,7 +1986,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height)
|
||||
{
|
||||
matches++;
|
||||
total += txout.nValue;
|
||||
fprintf(stderr, "MATCHED AmountPaid.%lu notaryid.%i\n",AmountToPay,NotarisationNotaries[n-1]);
|
||||
//fprintf(stderr, "MATCHED AmountPaid.%lu notaryid.%i\n",AmountToPay,NotarisationNotaries[n-1]);
|
||||
}
|
||||
else fprintf(stderr, "NOT MATCHED AmountPaid.%lu AmountToPay.%lu notaryid.%i\n", pblock->vtx[0].vout[n].nValue, AmountToPay, NotarisationNotaries[n-1]);
|
||||
}
|
||||
@@ -2171,7 +2184,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
||||
// the default daemon miner, checks the actual vins so the only way this will fail, is if someone changes the miner,
|
||||
// and then creates txs to the crypto address meeting min sigs and puts it in tx position 1.
|
||||
// If they go through this effort, the block will still fail at connect block, and will be auto purged by the temp file fix.
|
||||
if ( failed == 0 && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[0].vout.size() > 1 )
|
||||
if ( failed == 0 && ASSETCHAINS_NOTARY_PAY[0] != 0 && pblock->vtx[0].vout.size() > 1 )
|
||||
{
|
||||
// We check the full validation in ConnectBlock directly to get the amount for coinbase. So just approx here.
|
||||
if ( slowflag == 0 )
|
||||
|
||||
@@ -40,7 +40,7 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
|
||||
extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC;
|
||||
extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER;
|
||||
extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD, ASSETCHAINS_NOTARY_PAY;
|
||||
extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD;
|
||||
|
||||
extern uint64_t ASSETCHAINS_TIMELOCKGTE;
|
||||
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOMODO_INITDONE;
|
||||
@@ -48,7 +48,7 @@ extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOM
|
||||
extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_ON_DEMAND,KOMODO_PASSPORT_INITDONE,ASSETCHAINS_STAKED;
|
||||
extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_LASTERA;
|
||||
extern bool VERUS_MINTBLOCKS;
|
||||
extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[];
|
||||
extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[];
|
||||
extern const char *ASSETCHAINS_ALGORITHMS[];
|
||||
extern int32_t VERUS_MIN_STAKEAGE;
|
||||
extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[];
|
||||
|
||||
@@ -69,7 +69,7 @@ uint64_t ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF;
|
||||
uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0;
|
||||
|
||||
uint64_t ASSETCHAINS_LASTERA = 1;
|
||||
uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS];
|
||||
uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS];
|
||||
uint8_t ASSETCHAINS_CCDISABLES[256];
|
||||
|
||||
#define _ASSETCHAINS_EQUIHASH 0
|
||||
@@ -97,7 +97,7 @@ int32_t ASSETCHAINS_OVERWINTER = -1;
|
||||
|
||||
uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE;
|
||||
int32_t ASSETCHAINS_STAKED;
|
||||
uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS,ASSETCHAINS_FOUNDERS_REWARD,ASSETCHAINS_NOTARY_PAY;
|
||||
uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS,ASSETCHAINS_FOUNDERS_REWARD;
|
||||
|
||||
uint32_t KOMODO_INITDONE;
|
||||
char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771;
|
||||
|
||||
@@ -1764,6 +1764,7 @@ void komodo_args(char *argv0)
|
||||
Split(GetArg("-ac_reward",""), ASSETCHAINS_REWARD, 0);
|
||||
Split(GetArg("-ac_halving",""), ASSETCHAINS_HALVING, 0);
|
||||
Split(GetArg("-ac_decay",""), ASSETCHAINS_DECAY, 0);
|
||||
Split(GetArg("-ac_notarypay",""), ASSETCHAINS_NOTARY_PAY, 0);
|
||||
|
||||
for ( int i = 0; i < ASSETCHAINS_MAX_ERAS; i++ )
|
||||
{
|
||||
@@ -1777,6 +1778,11 @@ void komodo_args(char *argv0)
|
||||
ASSETCHAINS_DECAY[i] = 0;
|
||||
printf("ERA%u: ASSETCHAINS_DECAY cant be more than 100000000\n", i);
|
||||
}
|
||||
if ( ASSETCHAINS_NOTARY_PAY[i] < 64 )
|
||||
{
|
||||
ASSETCHAINS_NOTARY_PAY[i] = 64;
|
||||
printf("ERA%u: ASSETCHAINS_NOTARY_PAY cant be less than 64. Set to 64.\n", i);
|
||||
}
|
||||
}
|
||||
|
||||
MAX_BLOCK_SIGOPS = 60000;
|
||||
@@ -1869,6 +1875,11 @@ void komodo_args(char *argv0)
|
||||
}
|
||||
if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
||||
{
|
||||
if ( ASSETCHAINS_NOTARY_PAY[0] != 0 )
|
||||
{
|
||||
printf("Assetchains NOTARY PAY cannot be used with ac_pubkey or ac_script.\n");
|
||||
exit(0);
|
||||
}
|
||||
if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 )
|
||||
{
|
||||
decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str());
|
||||
@@ -1894,9 +1905,6 @@ void komodo_args(char *argv0)
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSETCHAINS_NOTARY_PAY = GetArg("-ac_notarypay",0);
|
||||
if ( ASSETCHAINS_NOTARY_PAY != 0 )
|
||||
printf("Assetchains NOTARY PAY set to %lu sats per notarisation per notary. Cannot work with ac_script or ac_pubkey!\n",ASSETCHAINS_NOTARY_PAY);
|
||||
if ( ASSETCHAINS_COMMISSION != 0 )
|
||||
{
|
||||
ASSETCHAINS_COMMISSION = 0;
|
||||
@@ -1913,7 +1921,7 @@ void komodo_args(char *argv0)
|
||||
fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n");
|
||||
exit(0);
|
||||
}
|
||||
if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY != 0 )
|
||||
if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY[0] != 0 )
|
||||
{
|
||||
fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size());
|
||||
extraptr = extrabuf;
|
||||
@@ -1922,17 +1930,19 @@ void komodo_args(char *argv0)
|
||||
// if we have one era, this should create the same data structure as it used to, same if we increase _MAX_ERAS
|
||||
for ( int i = 0; i <= ASSETCHAINS_LASTERA; i++ )
|
||||
{
|
||||
printf("ERA%u: end.%llu reward.%llu halving.%llu decay.%llu\n", i,
|
||||
printf("ERA%u: end.%llu reward.%llu halving.%llu decay.%llu notarypay.%llu\n", i,
|
||||
(long long)ASSETCHAINS_ENDSUBSIDY[i],
|
||||
(long long)ASSETCHAINS_REWARD[i],
|
||||
(long long)ASSETCHAINS_HALVING[i],
|
||||
(long long)ASSETCHAINS_DECAY[i]);
|
||||
(long long)ASSETCHAINS_DECAY[i],
|
||||
(long long)ASSETCHAINS_NOTARY_PAY[i]);
|
||||
|
||||
// TODO: Verify that we don't overrun extrabuf here, which is a 256 byte buffer
|
||||
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_ENDSUBSIDY[i]),(void *)&ASSETCHAINS_ENDSUBSIDY[i]);
|
||||
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_REWARD[i]),(void *)&ASSETCHAINS_REWARD[i]);
|
||||
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_HALVING[i]),(void *)&ASSETCHAINS_HALVING[i]);
|
||||
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_DECAY[i]),(void *)&ASSETCHAINS_DECAY[i]);
|
||||
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY[i]),(void *)&ASSETCHAINS_NOTARY_PAY[i]);
|
||||
}
|
||||
|
||||
if (ASSETCHAINS_LASTERA > 0)
|
||||
@@ -2008,8 +2018,6 @@ void komodo_args(char *argv0)
|
||||
}
|
||||
fprintf(stderr," <- CCLIB name\n");
|
||||
}
|
||||
if ( ASSETCHAINS_NOTARY_PAY != 0 )
|
||||
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY),(void *)&ASSETCHAINS_NOTARY_PAY);
|
||||
}
|
||||
|
||||
addn = GetArg("-seednode","");
|
||||
|
||||
@@ -3282,7 +3282,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
fprintf(stderr,"grandfathered exception, until jan 15th 2019\n");
|
||||
}
|
||||
// Do this here before the block is moved to the main block files.
|
||||
if ( ASSETCHAINS_NOTARY_PAY != 0 && pindex->GetHeight() > 10 )
|
||||
if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 )
|
||||
{
|
||||
// do a full block scan to get notarisation position and to enforce a valid notarization is in position 1.
|
||||
// if notarisation in the block, must be position 1 and the coinbase must pay notaries.
|
||||
|
||||
@@ -722,7 +722,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
txNew.vout[1].nValue = 0;
|
||||
// timelocks and commissions are currently incompatible due to validation complexity of the combination
|
||||
}
|
||||
else if ( fNotarisationBlock && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 0 )
|
||||
else if ( fNotarisationBlock && ASSETCHAINS_NOTARY_PAY[0] != 0 && pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 0 )
|
||||
{
|
||||
// Get the OP_RETURN for the notarisation
|
||||
uint8_t *script = (uint8_t *)&pblock->vtx[1].vout[1].scriptPubKey[0];
|
||||
|
||||
Reference in New Issue
Block a user