Skip to content

Commit

Permalink
Merge pull request #9 from cakedefi/feature_doublesign_proof
Browse files Browse the repository at this point in the history
Feature doublesign proof
  • Loading branch information
uzyn authored Oct 30, 2019
2 parents 70e582e + 2629749 commit f0a2f3c
Show file tree
Hide file tree
Showing 75 changed files with 1,091 additions and 3,363 deletions.
1,269 changes: 1 addition & 1,268 deletions contrib/seeds/nodes_main.txt

Large diffs are not rendered by default.

12 changes: 3 additions & 9 deletions contrib/seeds/nodes_test.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# List of fixed seed nodes for testnet
13.250.126.204:18323
13.229.219.199:18323
54.169.219.91:18323

# Onion nodes
thfsmmn2jbitcoin.onion
it2pj4f7657g3rhi.onion
nkf5e6b7pl4jfd4a.onion
4zhkir2ofl7orfom.onion
t6xj6wilh4ytvcs7.onion
i6y6ivorwakd7nw3.onion
ubqj4rsu3nqtxmtp.onion

1 change: 1 addition & 0 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ BITCOIN_TESTS =\
test/merkle_tests.cpp \
test/merkleblock_tests.cpp \
test/miner_tests.cpp \
test/double_sign.cpp \
test/multisig_tests.cpp \
test/net_tests.cpp \
test/netbase_tests.cpp \
Expand Down
12 changes: 8 additions & 4 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class CTestNetParams : public CChainParams {
consensus.pos.diffLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.pos.nTargetTimespan = 14 * 24 * 60 * 60; // two weeks
consensus.pos.nTargetSpacing = 10 * 60; // 10 minutes
consensus.pos.fAllowMinDifficultyBlocks = false; // only for regtest
consensus.pos.fAllowMinDifficultyBlocks = true;
consensus.pos.fNoRetargeting = false; // only for regtest

consensus.pos.coinstakeMaturity = 100;
Expand Down Expand Up @@ -393,14 +393,18 @@ class CRegTestParams : public CChainParams {
// owner base58, operator base58
vMasternodes.push_back({"mwsZw8nF7pKxWH8eoKL9tPxTpaFkz7QeLU", "mswsMVsyGMj1FzDMbbxw2QW3KvQAv2FKiy"});
vMasternodes.push_back({"msER9bmJjyEemRpQoS8YYVL21VyZZrSgQ7", "mps7BdmwEF2vQ9DREDyNPibqsuSRZ8LuwQ"});
vMasternodes.push_back({"myF3aHuxtEuqqTw44EurtVs6mjyc1QnGUS", "mtbWisYQmw9wcaecvmExeuixG7rYGqKEU4"});
vMasternodes.push_back({"mwyaBGGE7ka58F7aavH5hjMVdJENP9ZEVz", "n1n6Z5Zdoku4oUnrXeQ2feLz3t7jmVLG9t"});
vMasternodes.push_back({"mgsE1SqrcfUhvuYuRjqy6rQCKmcCVKNhMu", "mzqdipBJcKX9rXXxcxw2kTHC3Xjzd3siKg"});
vMasternodes.push_back({"mud4VMfbBqXNpbt8ur33KHKx8pk3npSq8c", "mk5DkY4qcV6CUpuxDVyD3AHzRq5XK9kbRN"});
vMasternodes.push_back({"bcrt1qyrfrpadwgw7p5eh3e9h3jmu4kwlz4prx73cqny", "bcrt1qmfvw3dp3u6fdvqkdc0y3lr0e596le9cf22vtsv"});
vMasternodes.push_back({"bcrt1qyeuu9rvq8a67j86pzvh5897afdmdjpyankp4mu", "bcrt1qurwyhta75n2g75u2u5nds9p6w9v62y8wr40d2r"});

genesis = CreateGenesisBlock(1296688602, 0x207fffff, 1, 50 * COIN, CreateGenesisMasternodes());
genesis = CreateGenesisBlock(1298732709, 0x207fffff, 1, 50 * COIN, CreateGenesisMasternodes()); // old=1296688602
consensus.hashGenesisBlock = genesis.GetHash();

assert(consensus.hashGenesisBlock == uint256S("0x5deed118789bf5acdce79974f15b9a1cffb924875f52e702ca93d926d290b31f"));
assert(genesis.hashMerkleRoot == uint256S("0x955d1c4074ccd34639cae5d1234bbef645b34866bfd18f083dd80928618e80fb"));
assert(consensus.hashGenesisBlock == uint256S("0x00000089a42802dfd816d0986339546b1f33a8d0e8ce2b9a4844a301407bac13"));
assert(genesis.hashMerkleRoot == uint256S("0xd43efce4ced3bacf52a958ae189ba1dd977031910cbeb72eb5e7f56a59ca4f52"));

vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.
Expand Down
1,280 changes: 5 additions & 1,275 deletions src/chainparamsseeds.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/consensus/tx_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe

if (tx.IsCoinBase())
{
if (tx.vin[0].scriptSig.size() < 2 || tx.vin[0].scriptSig.size() > 100)
if (tx.vin[0].scriptSig.size() < 2) // || tx.vin[0].scriptSig.size() > 100 // TODO: (ss) !
return state.Invalid(ValidationInvalidReason::CONSENSUS, false, REJECT_INVALID, "bad-cb-length");
}
else
Expand Down
7 changes: 7 additions & 0 deletions src/consensus/tx_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <coins.h>
#include <util/moneystr.h>

extern bool fIsFakeNet;

bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
{
if (tx.nLockTime == 0)
Expand Down Expand Up @@ -188,6 +190,11 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, CValidationState& state, c
return state.Invalid(ValidationInvalidReason::CONSENSUS, false, REJECT_INVALID, "mn-collateral-locked",
strprintf("tried to spend locked collateral for %s", prevout.hash.ToString())); /// @todo @max may be somehow place the height of unlocking?
}

if (pmasternodesview->FindBlockedCriminalCoins(prevout.hash, prevout.n, fIsFakeNet)) {
return state.Invalid(ValidationInvalidReason::CONSENSUS, false, REJECT_INVALID, "mn-using-criminal-coins",
strprintf("tried to spend criminal coins for %s", prevout.hash.ToString()));
}
}

const CAmount value_out = tx.GetValueOut();
Expand Down
3 changes: 2 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ void SetupServerArgs()
gArgs.AddArg("-torpassword=<pass>", "Tor control port password (default: empty)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
gArgs.AddArg("-masternode_owner=<address>", "Masternode owner address (default: empty)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
gArgs.AddArg("-masternode_operator=<address>", "Masternode operator address (default: empty)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
gArgs.AddArg("-dummypos", "Flag to skip PoS-related checks (regtest only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
#ifdef USE_UPNP
#if USE_UPNP
gArgs.AddArg("-upnp", "Use UPnP to map the listening port (default: 1 when listening and no -proxy)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
Expand Down Expand Up @@ -1165,7 +1166,7 @@ bool AppInitParameterInteraction()
return InitError("unknown rpcserialversion requested.");

nMaxTipAge = gArgs.GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);

fIsFakeNet = Params().NetworkIDString() == "regtest" && gArgs.GetArg("-dummypos", false);
return true;
}

Expand Down
14 changes: 13 additions & 1 deletion src/interfaces/chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,24 @@ class ChainImpl : public Chain
return true;
}
void findCoins(std::map<COutPoint, Coin>& coins) override { return FindCoins(coins); }
bool mnCanSpend(const uint256 & nodeId, int height) override
bool mnCanSpend(const uint256 & nodeId, int height) const override
{
LOCK(cs_main);
return pmasternodesview->CanSpend(nodeId, height);
}

bool mnFindBlockedCriminalCoins(const uint256 & txid, int index) const override
{
LOCK(cs_main);
return pmasternodesview->FindBlockedCriminalCoins(txid, index, fIsFakeNet);
}

CMasternode const * mnExists(const uint256 & nodeId) const override
{
LOCK(cs_main);
return pmasternodesview->ExistMasternode(nodeId);
}

double guessVerificationProgress(const uint256& block_hash) override
{
LOCK(cs_main);
Expand Down
5 changes: 4 additions & 1 deletion src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

class CBlock;
class CFeeRate;
class CMasternode;
class CRPCCommand;
class CScheduler;
class CValidationState;
Expand Down Expand Up @@ -145,7 +146,9 @@ class Chain
//! populates the values.
virtual void findCoins(std::map<COutPoint, Coin>& coins) = 0;

virtual bool mnCanSpend(const uint256 & nodeId, int height) = 0;
virtual bool mnCanSpend(const uint256 & nodeId, int height) const = 0;
virtual bool mnFindBlockedCriminalCoins(const uint256 & txid, int index) const = 0;
virtual CMasternode const * mnExists(const uint256 & nodeId) const = 0;

//! Estimate fraction of total transactions verified if blocks up to
//! the specified block hash are verified.
Expand Down
Loading

0 comments on commit f0a2f3c

Please sign in to comment.