Skip to content

Commit

Permalink
Merge pull request #22 from Butkoin/spork6
Browse files Browse the repository at this point in the history
merged for new butk version
  • Loading branch information
butkcore-dev authored May 8, 2022
2 parents 40fbdea + 0ee6bb3 commit e03be6d
Show file tree
Hide file tree
Showing 57 changed files with 2,016 additions and 1,080 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# What is But?
<img src="https://coinpaprika.com/coin/butk-butkoin/logo.png" width="150">
ButKoin is a decentralized secure cryptocurrency that is easy to mine devoid from 51% attack and it provide easy means of transactions between individuals. It is a Multi-algorithm coin. ButKoin uses a Smartnode collateral and reward system that prevent hyperinflation.
ButKoin is an experimental decentralized secure cryptocurrency that is easy to mine devoid from 51% attack and it provide easy means of transactions between individuals. It is a Multi-algorithm coin. ButKoin uses a Smartnode collateral and reward system that prevent hyperinflation.

# Supported Algorithms

Expand All @@ -16,6 +16,8 @@ ButKoin is a decentralized secure cryptocurrency that is easy to mine devoid fro
| Lyra2z330 | GPU |
| Sha256 | Asic |
| Scrypt | Asic |
| ButkScrypt | Asic |


License
-------
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ BITCOIN_CORE_H = \
wallet/coincontrol.h \
wallet/crypter.h \
wallet/db.h \
wallet/fees.h \
wallet/rpcwallet.h \
wallet/wallet.h \
wallet/walletdb.h \
Expand Down Expand Up @@ -375,6 +376,7 @@ libbut_wallet_a_SOURCES = \
privatesend/privatesend-util.cpp \
wallet/crypter.cpp \
wallet/db.cpp \
wallet/fees.cpp \
wallet/rpcdump.cpp \
wallet/rpcwallet.cpp \
wallet/wallet.cpp \
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.bench.include
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ bench_bench_but_SOURCES = \
bench/ccoins_caching.cpp \
bench/merkle_root.cpp \
bench/mempool_eviction.cpp \
bench/util_time.cpp \
bench/base58.cpp \
bench/lockedpool.cpp \
bench/poly1305.cpp \
Expand Down
42 changes: 42 additions & 0 deletions src/bench/util_time.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) 2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <bench/bench.h>

#include <utiltime.h>

static void BenchTimeDeprecated(benchmark::State& state)
{
while (state.KeepRunning()) {
(void)GetTime();
}
}

static void BenchTimeMock(benchmark::State& state)
{
SetMockTime(111);
while (state.KeepRunning()) {
(void)GetTime<std::chrono::seconds>();
}
SetMockTime(0);
}

static void BenchTimeMillis(benchmark::State& state)
{
while (state.KeepRunning()) {
(void)GetTime<std::chrono::milliseconds>();
}
}

static void BenchTimeMillisSys(benchmark::State& state)
{
while (state.KeepRunning()) {
(void)GetTimeMillis();
}
}

BENCHMARK(BenchTimeDeprecated/*, 100000000*/);
BENCHMARK(BenchTimeMillis/*, 6000000*/);
BENCHMARK(BenchTimeMillisSys/*, 6000000*/);
BENCHMARK(BenchTimeMock/*, 300000000*/);
43 changes: 29 additions & 14 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ class CMainParams : public CChainParams {
consensus.v2DiffChangeHeight = 5;
consensus.v3DiffChangeHeight = 10;
consensus.AlgoChangeHeight = 28;
consensus.nSwitchHeight = 170000;
consensus.nSwitchHeight = 150000;
consensus.nLocalTargetAdjustment = 4; //target adjustment per algo
consensus.nLocalDifficultyAdjustment = 4; //difficulty adjustment per algo

Expand All @@ -477,10 +477,10 @@ class CMainParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000000fade80"); // 153
consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000000008d254bb784e3f00"); // 127918

// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0x0000012eb451fbdf5e8b5c588c0912b3e70e2ea5a37ac88e4ca8c1ad27279509"); // 153
consensus.defaultAssumeValid = uint256S("0x0000000000000307a7ca1e00c041513a63eab4f62a083aae6d19466478737894"); // 127918

/**
* The message start string is designed to be unlikely to occur in normal data.
Expand Down Expand Up @@ -527,7 +527,10 @@ class CMainParams : public CChainParams {
consensus.nFounderPayment = FounderPayment(rewardStructures, 250);
consensus.nCollaterals = SmartnodeCollaterals(
{
{400000, 6000000 * COIN}, {INT_MAX, 8000000 * COIN}
{150000, 6000000 * COIN},
{500000, 15000000 * COIN},
{700000, 20000000 * COIN},
{INT_MAX, 25000000 * COIN}
},
{
{5761, 0}, {INT_MAX, 20}
Expand All @@ -552,7 +555,9 @@ class CMainParams : public CChainParams {
miningRequiresPeers = true;

nPoolMinParticipants = 3;
nPoolNewMinParticipants = 3;
nPoolMaxParticipants = 5;
nPoolNewMaxParticipants = 20;
nFulfilledRequestExpireTime = 60*60; // fulfilled requests expire in 1 hour

vSporkAddresses = {"XdccBnRd4AMEnfEhVgoLUL6aPjC3kkgJih"};
Expand All @@ -561,18 +566,16 @@ class CMainParams : public CChainParams {

checkpointData = (CCheckpointData) {
{
{0, uint256S("0x001787e5f9c3cd249f84f0142071f6098d9e3b7ec8591ff73543ddc4900c1dc2")},
{10, uint256S("0x005cab51de3bef6840c7866dbc1d2f69738cff67155a975fa3f1800aa4bbfcf9")},
{50, uint256S("0x0037fcf4a01c6c445f2ca1201aa67bca5c3a769cd9225199764c5d2b20e10e9f")},
{100, uint256S("0x00008474034c9e03197c723b565b14cfdbedefbac17b6f25fb0a37214be66062")},
{0, uint256S("0x001787e5f9c3cd249f84f0142071f6098d9e3b7ec8591ff73543ddc4900c1dc2")},
{127918, uint256S("0x0000000000000307a7ca1e00c041513a63eab4f62a083aae6d19466478737894")},
}
};

chainTxData = ChainTxData{
// Data from RPC: getchaintxstats 4096 00000000000000000008a89e854d57e5667df88f1cdef6fde2fbca1de5b639ad
/* nTime */ 1642793439,
/* nTxCount */ 465,
/* dTxRate */ 0.003272177305365523,
// Data from RPC: getchaintxstats 127917 00000000000000000008a89e854d57e5667df88f1cdef6fde2fbca1de5b639ad
/* nTime */ 1652019164,
/* nTxCount */ 281951,
/* dTxRate */ 0.03009734730359049,
};
}
};
Expand Down Expand Up @@ -695,6 +698,14 @@ class CTestNetParams : public CChainParams {
};
consensus.nFounderPayment = FounderPayment(rewardStructures, 200);

consensus.nCollaterals = SmartnodeCollaterals(
{
{40000, 15000000 * COIN}, {INT_MAX, 20000000 * COIN}
},
{
{200, 0}, {INT_MAX, 20}
}
);
fDefaultConsistencyChecks = false;
fRequireStandard = false;
fRequireRoutableExternalIP = true;
Expand All @@ -703,10 +714,12 @@ class CTestNetParams : public CChainParams {
fAllowMultiplePorts = true;

nPoolMinParticipants = 3;
nPoolNewMinParticipants = 2;
nPoolMaxParticipants = 5;
nPoolNewMaxParticipants = 20;
nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes

vSporkAddresses = {"yVeVxPpzbebak4EZdASJdrnCSPZfAucLNv"};
vSporkAddresses = {"yVcjXscgATKsvq8JYPKus2opsj6gxEuV7t"};
nMinSporkKeys = 1;
fBIP9CheckSmartnodesUpgraded = true;

Expand Down Expand Up @@ -846,8 +859,10 @@ class CDevNetParams : public CChainParams {
fAllowMultipleAddressesFromGroup = true;
fAllowMultiplePorts = true;

nPoolMinParticipants = 3;
nPoolMinParticipants = 2;
nPoolNewMinParticipants = 2;
nPoolMaxParticipants = 5;
nPoolNewMaxParticipants = 20;
nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes

vSporkAddresses = {"yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55"};
Expand Down
4 changes: 4 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ class CChainParams
void UpdateLLMQChainLocks(Consensus::LLMQType llmqType);
void UpdateLLMQParams(size_t totalMnCount, int height, bool lowLLMQParams = false);
int PoolMinParticipants() const { return nPoolMinParticipants; }
int PoolNewMinParticipants() const { return nPoolNewMinParticipants; }
int PoolMaxParticipants() const { return nPoolMaxParticipants; }
int PoolNewMaxParticipants() const { return nPoolNewMaxParticipants; }
int FulfilledRequestExpireTime() const { return nFulfilledRequestExpireTime; }
const std::vector<std::string>& SporkAddresses() const { return vSporkAddresses; }
int MinSporkKeys() const { return nMinSporkKeys; }
Expand Down Expand Up @@ -121,7 +123,9 @@ class CChainParams
CCheckpointData checkpointData;
ChainTxData chainTxData;
int nPoolMinParticipants;
int nPoolNewMinParticipants;
int nPoolMaxParticipants;
int nPoolNewMaxParticipants;
int nFulfilledRequestExpireTime;
std::vector<std::string> vSporkAddresses;
int nMinSporkKeys;
Expand Down
11 changes: 11 additions & 0 deletions src/evo/mnauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "smartnode/activesmartnode.h"
#include "evo/deterministicmns.h"
#include "smartnode/smartnode-sync.h"
#include <smartnode/smartnode-meta.h>
#include "net.h"
#include "net_processing.h"
#include "netmessagemaker.h"
Expand Down Expand Up @@ -100,6 +101,16 @@ void CMNAuth::ProcessMessage(CNode* pnode, const std::string& strCommand, CDataS
return;
}

if (!pnode->fInbound) {
mmetaman.GetMetaInfo(mnauth.proRegTxHash)->SetLastOutboundSuccess(GetAdjustedTime());
if (pnode->fSmartnodeProbe) {
LogPrint(BCLog::NET, "CMNAuth::ProcessMessage -- Smartnode probe successful for %s, disconnecting. peer=%d\n",
mnauth.proRegTxHash.ToString(), pnode->GetId());
pnode->fDisconnect = true;
return;
}
}

connman.ForEachNode([&](CNode* pnode2) {
if (pnode2->verifiedProRegTxHash == mnauth.proRegTxHash) {
LogPrint(BCLog::NET, "CMNAuth::ProcessMessage -- Smartnode %s has already verified as peer %d, dropping new connection. peer=%d\n",
Expand Down
19 changes: 6 additions & 13 deletions src/governance/governance-vote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ bool CGovernanceVote::Sign(const CKey& key, const CKeyID& keyID)
{
std::string strError;

if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
// Harden Spork6 so that it is active on testnet and no other networks
if (Params().NetworkIDString() == CBaseChainParams::TESTNET) {
uint256 hash = GetSignatureHash();

if (!CHashSigner::SignHash(hash, key, vchSig)) {
Expand Down Expand Up @@ -199,21 +200,13 @@ bool CGovernanceVote::CheckSignature(const CKeyID& keyID) const
{
std::string strError;

if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
// Harden Spork6 so that it is active on testnet and no other networks
if (Params().NetworkIDString() == CBaseChainParams::TESTNET) {
uint256 hash = GetSignatureHash();

if (!CHashSigner::VerifyHash(hash, keyID, vchSig, strError)) {
// could be a signature in old format
std::string strMessage = smartnodeOutpoint.ToStringShort() + "|" + nParentHash.ToString() + "|" +
std::to_string(nVoteSignal) + "|" +
std::to_string(nVoteOutcome) + "|" +
std::to_string(nTime);

if (!CMessageSigner::VerifyMessage(keyID, vchSig, strMessage, strError)) {
// nope, not in old format either
LogPrint(BCLog::GOBJECT, "CGovernanceVote::IsValid -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
LogPrint(BCLog::GOBJECT, "CGovernanceVote::IsValid -- VerifyHash() failed, error: %s\n", strError);
return false;
}
} else {
std::string strMessage = smartnodeOutpoint.ToStringShort() + "|" + nParentHash.ToString() + "|" +
Expand Down
8 changes: 4 additions & 4 deletions src/governance/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm

{
LOCK(cs_main);
connman.RemoveAskFor(nHash);
EraseObjectRequest(pfrom->GetId(), CInv(MSG_GOVERNANCE_OBJECT, nHash));
}

if (pfrom->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) {
Expand Down Expand Up @@ -211,7 +211,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm

{
LOCK(cs_main);
connman.RemoveAskFor(nHash);
EraseObjectRequest(pfrom->GetId(), CInv(MSG_GOVERNANCE_OBJECT_VOTE, nHash));
}

if (pfrom->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) {
Expand Down Expand Up @@ -1034,8 +1034,8 @@ int CGovernanceManager::RequestGovernanceObjectVotes(const std::vector<CNode*>&
// stop early to prevent setAskFor overflow
{
LOCK(cs_main);
size_t nProjectedSize = pnode->setAskFor.size() + nProjectedVotes;
if (nProjectedSize > SETASKFOR_MAX_SZ / 2) continue;
size_t nProjectedSize = GetRequestedObjectCount(pnode->GetId()) + nProjectedVotes;
if (nProjectedSize > MAX_INV_SZ) continue;
// to early to ask the same node
if (mapAskedRecently[nHashGovobj].count(pnode->addr)) continue;
}
Expand Down
6 changes: 3 additions & 3 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-privatesendsessions=<n>", strprintf(_("Use N separate smartnodes in parallel to mix funds (%u-%u, default: %u)"), MIN_PRIVATESEND_SESSIONS, MAX_PRIVATESEND_SESSIONS, DEFAULT_PRIVATESEND_SESSIONS));
strUsage += HelpMessageOpt("-privatesendrounds=<n>", strprintf(_("Use N separate smartnodes for each denominated input to mix funds (%u-%u, default: %u)"), MIN_PRIVATESEND_ROUNDS, MAX_PRIVATESEND_ROUNDS, DEFAULT_PRIVATESEND_ROUNDS));
strUsage += HelpMessageOpt("-privatesendamount=<n>", strprintf(_("Target PrivateSend balance (%u-%u, default: %u)"), MIN_PRIVATESEND_AMOUNT, MAX_PRIVATESEND_AMOUNT, DEFAULT_PRIVATESEND_AMOUNT));
strUsage += HelpMessageOpt("-privatesenddenoms=<n>", strprintf(_("Create up to N inputs of each denominated amount (%u-%u, default: %u)"), MIN_PRIVATESEND_DENOMS, MAX_PRIVATESEND_DENOMS, DEFAULT_PRIVATESEND_DENOMS));
strUsage += HelpMessageOpt("-privatesenddenoms=<n>", strprintf(_("Create up to N inputs of each denominated amount (%u-%u, default: %u)"), MIN_PRIVATESEND_DENOMS_GOAL, MAX_PRIVATESEND_DENOMS_GOAL, DEFAULT_PRIVATESEND_DENOMS_GOAL));
#endif // ENABLE_WALLET

strUsage += HelpMessageGroup(_("InstantSend options:"));
Expand Down Expand Up @@ -2101,14 +2101,14 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
privateSendClient.nPrivateSendSessions = std::min(std::max((int)gArgs.GetArg("-privatesendsessions", DEFAULT_PRIVATESEND_SESSIONS), MIN_PRIVATESEND_SESSIONS), MAX_PRIVATESEND_SESSIONS);
privateSendClient.nPrivateSendRounds = std::min(std::max((int)gArgs.GetArg("-privatesendrounds", DEFAULT_PRIVATESEND_ROUNDS), MIN_PRIVATESEND_ROUNDS), nMaxRounds);
privateSendClient.nPrivateSendAmount = std::min(std::max((int)gArgs.GetArg("-privatesendamount", DEFAULT_PRIVATESEND_AMOUNT), MIN_PRIVATESEND_AMOUNT), MAX_PRIVATESEND_AMOUNT);
privateSendClient.nPrivateSendDenoms = std::min(std::max((int)gArgs.GetArg("-privatesenddenoms", DEFAULT_PRIVATESEND_DENOMS), MIN_PRIVATESEND_DENOMS), MAX_PRIVATESEND_DENOMS);
privateSendClient.nPrivateSendDenomsGoal = std::min(std::max((int)gArgs.GetArg("-privatesenddenoms", DEFAULT_PRIVATESEND_DENOMS_GOAL), MIN_PRIVATESEND_DENOMS_GOAL), MAX_PRIVATESEND_DENOMS_GOAL);

if (privateSendClient.fEnablePrivateSend) {
LogPrintf("PrivateSend: autostart=%d, multisession=%d, "
"sessions=%d, rounds=%d, amount=%d, denoms=%d\n",
privateSendClient.fPrivateSendRunning, privateSendClient.fPrivateSendMultiSession,
privateSendClient.nPrivateSendSessions, privateSendClient.nPrivateSendRounds,
privateSendClient.nPrivateSendAmount, privateSendClient.nPrivateSendDenoms);
privateSendClient.nPrivateSendAmount, privateSendClient.nPrivateSendDenomsGoal);
}
#endif // ENABLE_WALLET

Expand Down
Loading

0 comments on commit e03be6d

Please sign in to comment.