Merge branch 'FSM' into jl777

This commit is contained in:
jl777
2018-12-16 02:38:03 -11:00
3 changed files with 13 additions and 15 deletions

View File

@@ -24,7 +24,7 @@ so you can pay to a pubkey, or to its hash. or to a script's hash. the last is h
all of the above are the standard bitcoin vout types and there should be plenty of materials about it all of the above are the standard bitcoin vout types and there should be plenty of materials about it
Encrypted by a verified device Encrypted by a verified device
what I did with the CC contracts is created a fourth type of vout, the CC vout. this is using the cryptoconditions standard and it is even a different signature mechanism. ed25519 instead of secp256k1. it is basically a big extension to the bitcoin script. There is a special opcode that is added that says it is a CC script. what I did with the CC contracts is created a fourth type of vout, the CC vout. this is using the cryptoconditions standard and it is even a different signature mechanism. ed25519 instead of secp256k1. it is basically a big extension to the bitcoin script. There is a special opcode that is added that says it is a CC script.
but it gets more interesting but it gets more interesting
each CC script has an evalcode each CC script has an evalcode
this is just an arbitrary number. but what it does is allows to create a self-contained universe of CC utxo that all have the same evalcode and that is how a faucet CC differentiates itself from a dice CC, the eval code is different this is just an arbitrary number. but what it does is allows to create a self-contained universe of CC utxo that all have the same evalcode and that is how a faucet CC differentiates itself from a dice CC, the eval code is different
@@ -73,7 +73,7 @@ struct CC_utxo
// these are the parameters stored after Verus crypto-condition vouts. new versions may change // these are the parameters stored after Verus crypto-condition vouts. new versions may change
// the format // the format
struct CC_meta struct CC_meta
{ {
std::vector<unsigned char> version; std::vector<unsigned char> version;
uint8_t evalCode; uint8_t evalCode;
@@ -110,7 +110,7 @@ int32_t komodo_nextheight();
static const uint256 zeroid; static const uint256 zeroid;
bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock); bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock);
int32_t is_hexstr(char *str,int32_t n); int32_t is_hexstr(char *str,int32_t n);
bool myAddtomempool(CTransaction &tx, CValidationState *pstate = NULL); bool myAddtomempool(CTransaction &tx, CValidationState *pstate = NULL, bool fSkipExpiry = false);
//uint64_t myGettxout(uint256 hash,int32_t n); //uint64_t myGettxout(uint256 hash,int32_t n);
bool myIsutxo_spentinmempool(uint256 txid,int32_t vout); bool myIsutxo_spentinmempool(uint256 txid,int32_t vout);
bool mytxid_inmempool(uint256 txid); bool mytxid_inmempool(uint256 txid);

View File

@@ -1599,7 +1599,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF
} }
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,bool* pfMissingInputs, bool fRejectAbsurdFee, int dosLevel) bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,bool* pfMissingInputs, bool fRejectAbsurdFee, int dosLevel, bool fSkipExpiry)
{ {
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
if (pfMissingInputs) if (pfMissingInputs)
@@ -1636,7 +1636,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
} }
// 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, (dosLevel == -1) ? 10 : dosLevel)) if (!fSkipExpiry && !ContextualCheckTransaction(tx, state, nextBlockHeight, (dosLevel == -1) ? 10 : dosLevel))
{ {
return error("AcceptToMemoryPool: ContextualCheckTransaction failed"); return error("AcceptToMemoryPool: ContextualCheckTransaction failed");
} }
@@ -1733,7 +1733,7 @@ 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");
//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");
return(false); return(false);
} }
} }
@@ -1975,14 +1975,14 @@ bool GetAddressUnspent(uint160 addressHash, int type,
else return(coins.vout[n].nValue); else return(coins.vout[n].nValue);
}*/ }*/
bool myAddtomempool(CTransaction &tx, CValidationState *pstate) bool myAddtomempool(CTransaction &tx, CValidationState *pstate, bool fSkipExpiry)
{ {
CValidationState state; CValidationState state;
if (!pstate) if (!pstate)
pstate = &state; pstate = &state;
CTransaction Ltx; bool fMissingInputs,fOverrideFees = false; CTransaction Ltx; bool fMissingInputs,fOverrideFees = false;
if ( mempool.lookup(tx.GetHash(),Ltx) == 0 ) if ( mempool.lookup(tx.GetHash(),Ltx) == 0 )
return(AcceptToMemoryPool(mempool, *pstate, tx, false, &fMissingInputs, !fOverrideFees)); return(AcceptToMemoryPool(mempool, *pstate, tx, false, &fMissingInputs, !fOverrideFees, -1, fSkipExpiry));
else return(true); else return(true);
} }
@@ -4686,7 +4686,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) { BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) {
const CTransaction &tx = e.GetTx(); const CTransaction &tx = e.GetTx();
const uint256 &hash = tx.GetHash(); const uint256 &hash = tx.GetHash();
if ( tx.vjoinsplit.size() == 0 ) { if ( tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) {
transactionsToRemove.push_back(tx); transactionsToRemove.push_back(tx);
tmpmempool.addUnchecked(hash,e,true); tmpmempool.addUnchecked(hash,e,true);
} }
@@ -4705,10 +4705,10 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
CValidationState state; CValidationState state;
CTransaction Tx; CTransaction Tx;
const CTransaction &tx = (CTransaction)block.vtx[i]; const CTransaction &tx = (CTransaction)block.vtx[i];
if (tx.IsCoinBase() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0))) if (tx.IsCoinBase() || (!tx.vjoinsplit.empty() && !tx.vShieldedSpend.empty()) || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0)))
continue; continue;
Tx = tx; Tx = tx;
if ( myAddtomempool(Tx, &state) == false ) // happens with out of order tx in block on resync if ( myAddtomempool(Tx, &state, true) == false ) // happens with out of order tx in block on resync
{ {
//LogPrintf("Rejected by mempool, reason: .%s.\n", state.GetRejectReason().c_str()); //LogPrintf("Rejected by mempool, reason: .%s.\n", state.GetRejectReason().c_str());
// take advantage of other checks, but if we were only rejected because it is a valid staking // take advantage of other checks, but if we were only rejected because it is a valid staking
@@ -4773,9 +4773,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
{ {
const CTransaction &tx = e.GetTx(); const CTransaction &tx = e.GetTx();
const uint256 &hash = tx.GetHash(); const uint256 &hash = tx.GetHash();
if ( tx.vjoinsplit.size() == 0 ) { mempool.addUnchecked(hash,e,true);
mempool.addUnchecked(hash,e,true);
}
} }
//fprintf(stderr, "finished adding back. mempoolsize.%ld\n",mempool.size()); //fprintf(stderr, "finished adding back. mempoolsize.%ld\n",mempool.size());
// empty the temp mempool for next time. // empty the temp mempool for next time.

View File

@@ -274,7 +274,7 @@ void PruneAndFlush();
/** (try to) add transaction to memory pool **/ /** (try to) add transaction to memory pool **/
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
bool* pfMissingInputs, bool fRejectAbsurdFee=false, int dosLevel=-1); bool* pfMissingInputs, bool fRejectAbsurdFee=false, int dosLevel=-1, bool fSkipExpiry=false);
struct CNodeStateStats { struct CNodeStateStats {