Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.21.kyo.2 #50

Open
wants to merge 22 commits into
base: 0.21.base
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1a85d7c
:zap: Add Enigma annoucement message skeleton \n Fix up PoW validation
akyo8 Feb 18, 2021
b840689
Multi-line
akyo8 Feb 18, 2021
40b2167
Update CBlockIndex for PoS. Fix coinbase maturity in consensus rules
akyo8 Feb 18, 2021
1a00326
Fix up fees and block extra connections when using -onnect
akyo8 Feb 18, 2021
687bc08
Update PoW check to ignore genesis block
akyo8 Feb 18, 2021
850f5c6
:zap: Add PoS placeholder and params. Update clientversion.
akyo8 Feb 18, 2021
749652f
Update block, transaction and uint256 (add uint512)
akyo8 Feb 18, 2021
1de3eec
Update version.h
akyo8 Feb 18, 2021
e762b6d
Update chainparams
akyo8 Feb 18, 2021
c5c2338
Add X13 crypto sources to makefile
akyo8 Feb 18, 2021
c8e1daf
Add X13 crypto files
akyo8 Feb 18, 2021
63bba49
Stake modifier work
akyo8 Feb 19, 2021
5aa90a6
Fix some sync issues
akyo8 Feb 19, 2021
90750ea
Add more proof-of-stake code and re-add canHandlePoSHeaders logic
akyo8 Feb 19, 2021
73daa61
Fix nProofOfWorkLimit and nProofOfStakeLimit consensus values for mai…
akyo8 Feb 19, 2021
937041a
Add crypto/hmac_sha512.h to src/Makefile.am
akyo8 Feb 19, 2021
ad37d7a
Fix GetStakeModifierChecksum and removed unwanted uint256 arith exten…
akyo8 Feb 19, 2021
58b2566
More proof-of-stake code and minor refactoring
akyo8 Feb 19, 2021
8806e08
Resolve secp256k1_ecdsa_verify issue with TX validation.
akyo8 Feb 20, 2021
be75d75
Add Cloak references
akyo8 Feb 20, 2021
71f5454
Update some Cloak/BTC references
akyo8 Feb 20, 2021
25cfe3a
squash commit
akyo8 Feb 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,36 @@
Bitcoin Core integration/staging tree
Cloak Core integration/staging tree
=====================================
https://www.cloakcoin.com

https://bitcoincore.org

What is Bitcoin?
What is Cloak?
----------------

Bitcoin is an experimental digital currency that enables instant payments to
anyone, anywhere in the world. Bitcoin uses peer-to-peer technology to operate
Cloak is an experimental digital currency that enables instant payments to
anyone, anywhere in the world. Cloak uses peer-to-peer technology to operate
with no central authority: managing transactions and issuing money are carried
out collectively by the network. Bitcoin Core is the name of open source
out collectively by the network. Cloak Core is the name of open source
software which enables the use of this currency.

For more information, as well as an immediately usable, binary version of
the Bitcoin Core software, see https://bitcoincore.org/en/download/, or read the
[original whitepaper](https://bitcoincore.org/bitcoin.pdf).
For more information, as well as an immediately useable, binary version of
the Cloak Core software, see https://www.cloakcoin.com, or read the
[original whitepaper](https://www.cloakcoin.com/en/whitepaper).

License
-------

Bitcoin Core is released under the terms of the MIT license. See [COPYING](COPYING) for more
Cloak Core is released under the terms of the MIT license. See [COPYING](COPYING) for more
information or see https://opensource.org/licenses/MIT.

Development Process
-------------------

The `master` branch is regularly built (see `doc/build-*.md` for instructions) and tested, but it is not guaranteed to be
completely stable. [Tags](https://github.com/bitcoin/bitcoin/tags) are created
regularly from release branches to indicate new official, stable release versions of Bitcoin Core.
**Important**: Configure with [--disable-tests] and [--disable-bench] for now, while the codebase upgrade is in its early stages. Tests will be updated in due course and this requirement will cease.

The https://github.com/bitcoin-core/gui repository is used exclusively for the
development of the GUI. Its master branch is identical in all monotree
repositories. Release branches and tags do not exist, so please do not fork
that repository unless it is for development reasons.
The `master` branch is regularly built and tested, but is not guaranteed to be
completely stable. [Tags](https://github.com/bitcoin/bitcoin/tags) are created
regularly to indicate new official, stable release versions of Cloak Core.

The contribution workflow is described in [CONTRIBUTING.md](CONTRIBUTING.md)
and useful hints for developers can be found in [doc/developer-notes.md](doc/developer-notes.md).
The contribution workflow is described in [CONTRIBUTING.md](CONTRIBUTING.md).

Testing
-------
Expand Down Expand Up @@ -69,7 +64,7 @@ Translations
------------

Changes to translations as well as new translations can be submitted to
[Bitcoin Core's Transifex page](https://www.transifex.com/bitcoin/bitcoin/).
[Bitcoin Core's Transifex page](https://www.transifex.com/projects/p/bitcoin/).

Translations are periodically pulled from Transifex and merged into the git repository. See the
[translation process](doc/translation_process.md) for details on how this works.
Expand Down
341 changes: 139 additions & 202 deletions build_msvc/bitcoin.sln

Large diffs are not rendered by default.

Empty file.
30 changes: 30 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,37 @@ crypto_libbitcoin_crypto_base_a_SOURCES = \
crypto/hmac_sha256.cpp \
crypto/hmac_sha256.h \
crypto/hmac_sha512.cpp \

crypto/hmac_sha512.h \
crypto/sha512.h \
crypto/aes_helper.c \
crypto/blake.c \
crypto/bmw.c \
crypto/cubehash.c \
crypto/echo.c \
crypto/fugue.c \
crypto/groestl.c \
crypto/hamsi.c \
crypto/hamsi_helper.c \
crypto/jh.c \
crypto/keccak.c \
crypto/luffa.c \
crypto/shavite.c \
crypto/simd.c \
crypto/skein.c \
crypto/sph_simd.h \
crypto/sph_shavite.h \
crypto/sph_skein.h \
crypto/sph_jh.h \
crypto/sph_hamsi.h \
crypto/sph_keccak.h \
crypto/sph_echo.h \
crypto/sph_fugue.h \
crypto/sph_groestl.h \
crypto/sph_cubehash.h \
crypto/sph_bmw.h \
crypto/sph_blake.h \
crypto/sph_luffa.h \
crypto/poly1305.h \
crypto/poly1305.cpp \
crypto/ripemd160.cpp \
Expand Down
2 changes: 1 addition & 1 deletion src/amount.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static const CAmount COIN = 100000000;
* critical; in unusual circumstances like a(nother) overflow bug that allowed
* for the creation of coins out of thin air modification could lead to a fork.
* */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happened to
static const CAmount CENT = 1000000;
I believe this was used across different files?

static const CAmount MAX_MONEY = 21000000 * COIN;
static const CAmount MAX_MONEY = 10000000 * COIN;
inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }

#endif // BITCOIN_AMOUNT_H
84 changes: 84 additions & 0 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

#include <vector>

#define BLOCK_PROOF_OF_STAKE 0x01 // is proof-of-stake block
#define BLOCK_STAKE_ENTROPY 0x02 // entropy bit for stake modifier
#define BLOCK_STAKE_MODIFIER 0x04

/**
* Maximum amount of time that a block timestamp is allowed to exceed the
* current network-adjusted time before the block will be accepted.
Expand Down Expand Up @@ -63,6 +67,12 @@ class CBlockFileInfo
nBlocks = 0;
nSize = 0;
nUndoSize = 0;
nFlags = 0;
Copy link
Collaborator

@anorakthagreat anorakthagreat Mar 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes belong in the CBlockIndex class, not here in CBlockFileInfo. Please move these.

Also, CBlockIndex is completely missing the SetNull method, which is called on COutPoint prevoutStake across the file and possibly elsewhere.

Take a look at the file on 0.17 here:
https://github.com/CloakProject/codename-phoenix/blob/0.17.cloak/src/chain.h

Please make sure you're careful when you move code, it needs to be added to appropriate locations - this is important as some properties are purposely mem-only or not serialized at all depending on usage. I understand you were trying to short-hand initialize the values on declaration with {0}, but this has other implications, security and byte-size included (declaring a var doesn't reserve memory, sometimes there is no stack at all depending on the compiler optimization), so some classes don't need all the properties or we don't want them on disk.

nStakeModifier = 0;
nStakeModifierChecksum = 0;
hashProofOfStake = arith_uint256();
prevoutStake.SetNull();
nStakeTime = 0;
nHeightFirst = 0;
nHeightLast = 0;
nTimeFirst = 0;
Expand Down Expand Up @@ -180,14 +190,27 @@ class CBlockIndex
uint32_t nBits{0};
uint32_t nNonce{0};

unsigned int nFlags; // ppcoin: block index flags

uint64_t nStakeModifier; // hash modifier for proof-of-stake
unsigned int nStakeModifierChecksum; // checksum of index; in-memeory only

// proof-of-stake specific fields
COutPoint prevoutStake;
unsigned int nStakeTime;
arith_uint256 hashProofOfStake;

//! (memory only) Sequential id assigned to distinguish order in which blocks are received.
int32_t nSequenceId{0};

//! (memory only) Maximum nTime in the chain up to and including this block.
unsigned int nTimeMax{0};



CBlockIndex()
{

}

explicit CBlockIndex(const CBlockHeader& block)
Expand Down Expand Up @@ -301,6 +324,47 @@ class CBlockIndex
return false;
}

bool IsProofOfWork() const
{
return !(nFlags & BLOCK_PROOF_OF_STAKE);
}

bool IsProofOfStake() const
{
return (nFlags & BLOCK_PROOF_OF_STAKE);
}

void SetProofOfStake()
{
nFlags |= BLOCK_PROOF_OF_STAKE;
}

unsigned int GetStakeEntropyBit() const
{
return ((nFlags & BLOCK_STAKE_ENTROPY) >> 1);
}

bool SetStakeEntropyBit(unsigned int nEntropyBit)
{
if (nEntropyBit > 1)
return false;
nFlags |= (nEntropyBit ? BLOCK_STAKE_ENTROPY : 0);
return true;
}

void SetStakeModifier(uint64_t nModifier, bool fGeneratedStakeModifier)
{
nStakeModifier = nModifier;
if (fGeneratedStakeModifier)
nFlags |= BLOCK_STAKE_MODIFIER;
}

bool GeneratedStakeModifier() const
{
return (nFlags & BLOCK_STAKE_MODIFIER);
}


//! Build the skiplist pointer for this entry.
void BuildSkip();

Expand All @@ -319,11 +383,15 @@ const CBlockIndex* LastCommonAncestor(const CBlockIndex* pa, const CBlockIndex*
/** Used to marshal pointers into hashes for db storage. */
class CDiskBlockIndex : public CBlockIndex
{
private:
uint256 blockHash;

public:
uint256 hashPrev;

CDiskBlockIndex() {
hashPrev = uint256();

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing blockHash = uint256();

}

explicit CDiskBlockIndex(const CBlockIndex* pindex) : CBlockIndex(*pindex) {
Expand All @@ -342,13 +410,27 @@ class CDiskBlockIndex : public CBlockIndex
if (obj.nStatus & BLOCK_HAVE_DATA) READWRITE(VARINT(obj.nDataPos));
if (obj.nStatus & BLOCK_HAVE_UNDO) READWRITE(VARINT(obj.nUndoPos));

READWRITE(nFlags);
READWRITE(nStakeModifier);
if (IsProofOfStake()) {
READWRITE(prevoutStake);
READWRITE(nStakeTime);
} else if (ser_action.ForRead()) {
const_cast<CDiskBlockIndex*>(this)->prevoutStake.SetNull();
const_cast<CDiskBlockIndex*>(this)->nStakeTime = 0;
}

READWRITE(hashProofOfStake);

// block header
READWRITE(obj.nVersion);
READWRITE(obj.hashPrev);
READWRITE(obj.hashMerkleRoot);
READWRITE(obj.nTime);
READWRITE(obj.nBits);
READWRITE(obj.nNonce);
READWRITE(blockHash);

}

uint256 GetBlockHash() const
Expand All @@ -360,6 +442,8 @@ class CDiskBlockIndex : public CBlockIndex
block.nTime = nTime;
block.nBits = nBits;
block.nNonce = nNonce;
const_cast<CDiskBlockIndex*>(this)->blockHash = block.GetHash();

return block.GetHash();
}

Expand Down
Loading