From 2d28ad9c6f57360f0596b2b2ef2ef5994d0f6dfe Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Jun 2018 07:08:30 -1100 Subject: [PATCH 1/5] Tweak height 1 fix --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c6272cc35..2d83ac89d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4060,11 +4060,11 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta // Don't accept any forks from the main chain prior to last checkpoint CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints()); int32_t notarized_height; - if ( pcheckpoint && nHeight > 1 ) + if ( nHeight > 1 ) { - if (nHeight < pcheckpoint->nHeight ) + if ( pcheckpoint != 0 && nHeight < pcheckpoint->nHeight ) return state.DoS(1, error("%s: forked chain older than last checkpoint (height %d) vs %d", __func__, nHeight,pcheckpoint->nHeight)); - else if ( komodo_checkpoint(¬arized_height,nHeight,hash) < 0 ) + if ( komodo_checkpoint(¬arized_height,nHeight,hash) < 0 ) { CBlockIndex *heightblock = chainActive[nHeight]; if ( heightblock != 0 && heightblock->GetBlockHash() == hash ) From e7433b08e5dfec2592ef2c5207918179c596d2ab Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Jun 2018 08:43:08 -1100 Subject: [PATCH 2/5] Reject height 1 reorganization --- src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 2d83ac89d..c22b93fae 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4060,7 +4060,9 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta // Don't accept any forks from the main chain prior to last checkpoint CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints()); int32_t notarized_height; - if ( nHeight > 1 ) + if ( nHeight == 1 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight > 1 ) + return(false) + if ( nHeight != 0 ) { if ( pcheckpoint != 0 && nHeight < pcheckpoint->nHeight ) return state.DoS(1, error("%s: forked chain older than last checkpoint (height %d) vs %d", __func__, nHeight,pcheckpoint->nHeight)); From 9710a28a54684545eb549f61688301caa4d0474a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Jun 2018 08:59:05 -1100 Subject: [PATCH 3/5] Use entire magic in height 1 reward --- src/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c22b93fae..c67974971 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1753,7 +1753,11 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) else { if ( nHeight == 1 ) - return(ASSETCHAINS_SUPPLY * COIN + (ASSETCHAINS_MAGIC & 0xffffff)); + { + if ( ASSETCHAINS_STAKED == 0 || strcmp("VRSC",ASSETCHAINS_SYMBOL) == 0 ) + return(ASSETCHAINS_SUPPLY * COIN + (ASSETCHAINS_MAGIC & 0xffffff)); + else return(ASSETCHAINS_SUPPLY * COIN + ASSETCHAINS_MAGIC); + } else if ( ASSETCHAINS_ENDSUBSIDY == 0 || nHeight < ASSETCHAINS_ENDSUBSIDY ) { if ( ASSETCHAINS_REWARD == 0 ) From 40d1de3231eaf5646f7551690624d89ee2d0c346 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 27 Jun 2018 09:18:59 -1100 Subject: [PATCH 4/5] Syntax --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c67974971..6ba31906a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4065,7 +4065,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints()); int32_t notarized_height; if ( nHeight == 1 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight > 1 ) - return(false) + return(false); if ( nHeight != 0 ) { if ( pcheckpoint != 0 && nHeight < pcheckpoint->nHeight ) From 7efaea1895460371b6dc168447e907b7ef9cb1ff Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Wed, 27 Jun 2018 20:32:50 -0300 Subject: [PATCH 5/5] two fixes for eval.h, so it compiles on older gcc and prevent an overflow --- src/cc/eval.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cc/eval.h b/src/cc/eval.h index 4bcdd5617..0eef563a3 100644 --- a/src/cc/eval.h +++ b/src/cc/eval.h @@ -129,14 +129,16 @@ public: uint256 blockHash = uint256(); uint32_t height = 0; uint256 txHash = uint256(); - char symbol[64] = "\0"; + char symbol[64]; uint256 MoM = uint256(); uint16_t MoMDepth = 0; uint16_t ccId = 0; uint256 MoMoM = uint256(); uint32_t MoMoMDepth = 0; - NotarisationData(int IsBack=2) : IsBackNotarisation(IsBack) {} + NotarisationData(int IsBack=2) : IsBackNotarisation(IsBack) { + symbol[0] = '\0'; + } ADD_SERIALIZE_METHODS; @@ -171,7 +173,8 @@ public: template void SerSymbol(Stream& s, CSerActionUnserialize act) { - char *nullPos = (char*) memchr(&s[0], 0, s.size()); + size_t readlen = std::min(sizeof(symbol), s.size()); + char *nullPos = (char*) memchr(&s[0], 0, readlen); if (!nullPos) throw std::ios_base::failure("couldn't parse symbol"); s.read(symbol, nullPos-&s[0]+1);