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

Implement RingCT Staking #1019

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
188bd83
[Refactor] SetOutputs, ArrangeOutBlinds
Zannick May 19, 2022
43d50f7
[Refactor] Parameterize CreateCoinStake.
Zannick May 19, 2022
01c1ae9
Initial RingCTStake class.
Zannick Jun 28, 2022
e67ccd2
Reduce effective weights of inputs.
Zannick Jul 16, 2022
b5366b0
RingCT: SignStakeTx
Zannick Jul 16, 2022
3c258cc
RingCT Stake: mark input as spent
Zannick Jul 16, 2022
ba6ad67
RingCT: Refactor to isolate input/output handling.
Zannick Jul 16, 2022
66f7e40
RingCT staking params and fixes
Zannick Aug 9, 2022
d9ebfd2
Fix weight calculation.
Zannick Aug 13, 2022
e588f97
More attempted fixes
Zannick Aug 15, 2022
ce5daef
checkpoint some more attempts for ringct
Zannick Aug 28, 2022
f14b4c3
RingCT stake: add reward outputs.
Zannick Oct 22, 2022
d971e6c
RingCT Stake: Sign block.
Zannick Oct 23, 2022
a4b064f
RingCT: Correctly mark pending spends.
Zannick Oct 23, 2022
3b423c6
RingCT Stake: verify block signature
Zannick Oct 23, 2022
727d150
RingCT stake: Move rewards to coinbase.
Zannick Oct 28, 2022
986c7a5
RingCT stake: accept and load the block
Zannick Oct 29, 2022
4787fba
Alter some regtest params.
Zannick Oct 29, 2022
52e904f
RingCT Staking: Make hash proof match.
Zannick Oct 29, 2022
9156bd4
RingCT Stake: Rangeproof the min. allowed weight.
Zannick Oct 30, 2022
d6af2ec
RingCT Stake: Cleanup
Zannick Oct 30, 2022
fae067a
RingCT Stake: Removed transactionsigcontext.
Zannick Oct 30, 2022
4b7e21f
RingCT Stake: change required depth.
Zannick Oct 30, 2022
037b458
Remove unneeded try-catch.
Zannick Nov 5, 2022
89822cb
DevNet RingCT staking at height 25000.
Zannick Jan 14, 2023
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ add_executable(veil
src/veil/ringct/rpcanonwallet.h
src/veil/ringct/stealth.cpp
src/veil/ringct/stealth.h
src/veil/ringct/transactionsigcontext.h
src/veil/ringct/types.h
src/veil/zerocoin/accumulatormap.cpp
src/veil/zerocoin/accumulatormap.h
Expand Down
13 changes: 12 additions & 1 deletion src/arith_uint256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ base_uint<BITS>& base_uint<BITS>::operator*=(uint32_t b32)
}

template <unsigned int BITS>
base_uint<BITS>& base_uint<BITS>::operator*=(const base_uint& b)
base_uint<BITS>& base_uint<BITS>::safeMultiply(const base_uint& b, bool& overflow)
{
base_uint<BITS> a;
for (int j = 0; j < WIDTH; j++) {
Expand All @@ -76,11 +76,20 @@ base_uint<BITS>& base_uint<BITS>::operator*=(const base_uint& b)
a.pn[i + j] = n & 0xffffffff;
carry = n >> 32;
}
// j > 0 implies we hit i + j == WIDTH before i == WIDTH
overflow |= carry > 0 || (j > 0 && pn[j] > 0 && b.pn[WIDTH - j] > 0);
}
*this = a;
return *this;
}

template <unsigned int BITS>
base_uint<BITS>& base_uint<BITS>::operator*=(const base_uint& b)
{
bool overflow = true;
return safeMultiply(b, overflow);
}

template <unsigned int BITS>
base_uint<BITS>& base_uint<BITS>::operator/=(const base_uint& b)
{
Expand Down Expand Up @@ -188,6 +197,7 @@ unsigned int base_uint<BITS>::bits() const
template base_uint<256>::base_uint(const std::string&);
template base_uint<256>& base_uint<256>::operator<<=(unsigned int);
template base_uint<256>& base_uint<256>::operator>>=(unsigned int);
template base_uint<256>& base_uint<256>::safeMultiply(const base_uint<256>& b, bool& overflow);
template base_uint<256>& base_uint<256>::operator*=(uint32_t b32);
template base_uint<256>& base_uint<256>::operator*=(const base_uint<256>& b);
template base_uint<256>& base_uint<256>::operator/=(const base_uint<256>& b);
Expand All @@ -203,6 +213,7 @@ template unsigned int base_uint<256>::bits() const;
template base_uint<512>::base_uint(const std::string&);
template base_uint<512>& base_uint<512>::operator<<=(unsigned int);
template base_uint<512>& base_uint<512>::operator>>=(unsigned int);
template base_uint<512>& base_uint<512>::safeMultiply(const base_uint<512>& b, bool& overflow);
template base_uint<512>& base_uint<512>::operator*=(uint32_t b32);
template base_uint<512>& base_uint<512>::operator*=(const base_uint<512>& b);
template base_uint<512>& base_uint<512>::operator/=(const base_uint<512>& b);
Expand Down
1 change: 1 addition & 0 deletions src/arith_uint256.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class base_uint
return *this;
}

base_uint& safeMultiply(const base_uint& b, bool& overflow);
base_uint& operator*=(uint32_t b32);
base_uint& operator*=(const base_uint& b);
base_uint& operator/=(const base_uint& b);
Expand Down
5 changes: 3 additions & 2 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ class CRegTestParams : public CChainParams {
// ProgPow, RandomX, Sha256d
consensus.nProgPowTargetSpacing = 172;
consensus.nRandomXTargetSpacing = 600;
consensus.nSha256DTargetSpacing = 1200;
consensus.nSha256DTargetSpacing = 120;

consensus.nDgwPastBlocks = 60; // number of blocks to average in Dark Gravity Wave
consensus.nDgwPastBlocks_old = 60; // number of blocks to average in Dark Gravity Wave
Expand Down Expand Up @@ -879,9 +879,10 @@ class CRegTestParams : public CChainParams {
/** RingCT/Stealth **/
nDefaultRingSize = 11;

nHeightLightZerocoin = 500;
nHeightLightZerocoin = 110;
nZerocoinRequiredStakeDepthV2 = 10; //The required confirmations for a zerocoin to be stakable
nHeightEnforceBlacklist = 0;
nHeightRingCTStaking = 300;

nMaxHeaderRequestWithoutPoW = 50;
nPreferredMintsPerBlock = 70; //Miner will not include more than this many mints per block
Expand Down
3 changes: 3 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ class CChainParams
int HeightLightZerocoin() const { return nHeightLightZerocoin; }
int HeightEnforceBlacklist() const { return nHeightEnforceBlacklist; }
int HeightProgPowDAGSizeReduction() const { return nHeightProgPowDAGSizeReduction; }
int HeightRingCTStaking() const { return nHeightRingCTStaking; }
int RingCT_RequiredStakeDepth() const { return nZerocoinRequiredStakeDepthV2; }

uint32_t PowUpdateTimestamp() const { return nPowUpdateTimestamp; }
uint64_t KIforkTimestamp() const { return nTimeKIfork; }
Expand Down Expand Up @@ -236,6 +238,7 @@ class CChainParams
int nHeightLightZerocoin;
int nHeightEnforceBlacklist;
int nHeightProgPowDAGSizeReduction;
int nHeightRingCTStaking = 50000000;

//Settings that are not chain critical, but should not be edited unless the person changing understands the consequence
int nMaxHeaderRequestWithoutPoW;
Expand Down
2 changes: 1 addition & 1 deletion src/consensus/tx_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, CValidationState& state, c
} else {
// Return stake reward in nTxFee
txfee = nPlainValueOut - nValueIn;
if (nCt > 0 || nRingCT > 0) { // counters track both outputs and inputs
if (nCt > 0) { // counters track both outputs and inputs
return state.DoS(100, error("ConnectBlock(): non-standard elements in coinstake"),
REJECT_INVALID, "bad-coinstake-outputs");
}
Expand Down
Loading