Skip to content

Commit 847e905

Browse files
authored
Merge branch 'development' into remove-merkle-branch
2 parents 9ac3dfa + 076e5b6 commit 847e905

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2260
-1704
lines changed

doc/build-unix.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ These dependencies are required:
6464
libdb4.8 | Berkeley DB | Wallet storage (only needed when wallet enabled)
6565
qt | GUI | GUI toolkit (only needed when GUI enabled)
6666
libqrencode | QR codes in GUI | Optional for generating QR codes (only needed when GUI enabled)
67+
libzip | Zip Compression | For Zip Compression and Decompression for snapshot and scraper related functions
6768

6869
For the versions used in the release, see [release-process.md](release-process.md) under *Fetch and build inputs*.
6970

@@ -81,7 +82,7 @@ Dependency Build Instructions: Ubuntu & Debian
8182
----------------------------------------------
8283
Build requirements:
8384

84-
sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils
85+
sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils libzip-dev libfreetype-dev
8586

8687
Options when installing required Boost library files:
8788

@@ -98,13 +99,22 @@ install necessary parts of boost:
9899
BerkeleyDB is required for the wallet.
99100

100101
**For Ubuntu only:** db4.8 packages are available [here](https://launchpad.net/~bitcoin/+archive/bitcoin).
102+
101103
You can add the repository and install using the following commands:
102104

105+
**For Ubuntu 18.04 and earlier versions**
106+
103107
sudo apt-get install software-properties-common
104108
sudo add-apt-repository ppa:bitcoin/bitcoin
105109
sudo apt-get update
106110
sudo apt-get install libdb4.8-dev libdb4.8++-dev
107111

112+
**For Ubuntu 20.04+**
113+
114+
For Ubuntu 20.04+ users the db4.8 is not available on the official PPA. Use the script in contrib/install_db4.sh
115+
to compile and install db4.8. You can use the script in your build location. For example if your build
116+
location is Gridcoin-Research/ then `./contrib/install_db4.sh $PWD`
117+
108118
Ubuntu and Debian have their own libdb-dev and libdb++-dev packages, but these will install
109119
BerkeleyDB 5.1 or later, which break binary wallet compatibility with the distributed executables which
110120
are based on BerkeleyDB 4.8. If you do not care about wallet compatibility,

src/Makefile.am

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ GRIDCOIN_CORE_H = \
7575
consensus/consensus.h \
7676
consensus/merkle.h \
7777
consensus/params.h \
78+
consensus/tx_verify.h \
7879
crypter.h \
7980
fs.h \
8081
fwd.h \
@@ -128,6 +129,8 @@ GRIDCOIN_CORE_H = \
128129
gridcoin/voting/result.h \
129130
gridcoin/voting/vote.h \
130131
hash.h \
132+
index/disktxpos.h \
133+
index/txindex.h \
131134
init.h \
132135
key.h \
133136
keystore.h \
@@ -138,7 +141,10 @@ GRIDCOIN_CORE_H = \
138141
netbase.h \
139142
net.h \
140143
pbkdf2.h \
144+
policy/fees.h \
145+
policy/policy.h \
141146
prevector.h \
147+
primitives/transaction.h \
142148
protocol.h \
143149
reverselock.h \
144150
rpc/blockchain.h \
@@ -168,6 +174,7 @@ GRIDCOIN_CORE_H = \
168174
util/threadnames.h \
169175
util/time.h \
170176
util.h \
177+
validation.h \
171178
version.h \
172179
wallet/coincontrol.h \
173180
wallet/db.h \
@@ -184,6 +191,7 @@ GRIDCOIN_CORE_CPP = addrdb.cpp \
184191
chainparamsbase.cpp \
185192
checkpoints.cpp \
186193
consensus/merkle.cpp \
194+
consensus/tx_verify.cpp \
187195
crypter.cpp \
188196
fs.cpp \
189197
gridcoin/appcache.cpp \
@@ -209,6 +217,7 @@ GRIDCOIN_CORE_CPP = addrdb.cpp \
209217
gridcoin/superblock.cpp \
210218
gridcoin/support/block_finder.cpp \
211219
gridcoin/tally.cpp \
220+
gridcoin/tx_message.cpp \
212221
gridcoin/upgrade.cpp \
213222
gridcoin/voting/builders.cpp \
214223
gridcoin/voting/claims.cpp \
@@ -226,6 +235,8 @@ GRIDCOIN_CORE_CPP = addrdb.cpp \
226235
net.cpp \
227236
noui.cpp \
228237
pbkdf2.cpp \
238+
policy/policy.cpp \
239+
primitives/transaction.cpp \
229240
protocol.cpp \
230241
rpc/blockchain.cpp \
231242
rpc/client.cpp \
@@ -251,6 +262,7 @@ GRIDCOIN_CORE_CPP = addrdb.cpp \
251262
util/threadnames.cpp \
252263
util/time.cpp \
253264
util.cpp \
265+
validation.cpp \
254266
version.cpp \
255267
wallet/db.cpp \
256268
wallet/rpcdump.cpp \

src/Makefile.qt.include

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,9 @@ RES_ICONS = \
368368
qt/res/icons/icons_light/transactions.svg \
369369
qt/res/icons/icons_native/transactions.svg \
370370
qt/res/icons/icons_light/chevron_down.svg \
371-
qt/res/icons/icons_dark/chevron_down.svg
371+
qt/res/icons/icons_light/chevron_up.svg \
372+
qt/res/icons/icons_dark/chevron_down.svg \
373+
qt/res/icons/icons_dark/chevron_up.svg
372374

373375
RES_IMAGES = \
374376
qt/res/images/about.svg \

src/chainparams.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,8 @@ inline int GetNewbieSnapshotFixHeight()
145145
{
146146
return fTestNet ? 1480000 : 2197000;
147147
}
148+
149+
inline unsigned int GetMinimumConnectionsRequiredForStaking()
150+
{
151+
return fTestNet ? 1 : 3;
152+
}

src/consensus/consensus.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include "amount.h"
4+
35
static const int LAST_POW_BLOCK = 2050;
46
static const int CONSENSUS_LOOKBACK = 5; //Amount of blocks to go back from best block, to avoid counting forked blocks
57
static const int BLOCK_GRANULARITY = 10; //Consensus block divisor
@@ -20,6 +22,6 @@ static const unsigned int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100;
2022
/** The maximum number of entries in an 'inv' protocol message */
2123
static const unsigned int MAX_INV_SZ = 50000;
2224
/** Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) */
23-
static const int64_t MIN_TX_FEE = 10000;
25+
static const CAmount MIN_TX_FEE = 10000;
2426
/** Fees smaller than this (in satoshi) are considered zero fee (for relaying) */
25-
static const int64_t MIN_RELAY_TX_FEE = MIN_TX_FEE;
27+
static const CAmount MIN_RELAY_TX_FEE = MIN_TX_FEE;

src/consensus/tx_verify.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright (c) 2017-2020 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#include <consensus/tx_verify.h>
6+
7+
#include <primitives/transaction.h>
8+
9+
bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
10+
{
11+
AssertLockHeld(cs_main);
12+
// Time based nLockTime implemented in 0.1.6
13+
if (tx.nLockTime == 0)
14+
return true;
15+
if (nBlockHeight == 0)
16+
nBlockHeight = nBestHeight;
17+
if (nBlockTime == 0)
18+
nBlockTime = GetAdjustedTime();
19+
if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))
20+
return true;
21+
for (auto const& txin : tx.vin)
22+
if (!txin.IsFinal())
23+
return false;
24+
return true;
25+
}
26+
27+
unsigned int GetLegacySigOpCount(const CTransaction& tx)
28+
{
29+
unsigned int nSigOps = 0;
30+
for (auto const& txin : tx.vin)
31+
{
32+
nSigOps += txin.scriptSig.GetSigOpCount(false);
33+
}
34+
for (auto const& txout : tx.vout)
35+
{
36+
nSigOps += txout.scriptPubKey.GetSigOpCount(false);
37+
}
38+
return nSigOps;
39+
}
40+
41+
unsigned int GetP2SHSigOpCount(const CTransaction& tx, const MapPrevTx& inputs)
42+
{
43+
if (tx.IsCoinBase())
44+
return 0;
45+
46+
unsigned int nSigOps = 0;
47+
for (unsigned int i = 0; i < tx.vin.size(); i++)
48+
{
49+
const CTxOut& prevout = GetOutputFor(tx.vin[i], inputs);
50+
if (prevout.scriptPubKey.IsPayToScriptHash())
51+
nSigOps += prevout.scriptPubKey.GetSigOpCount(tx.vin[i].scriptSig);
52+
}
53+
return nSigOps;
54+
}

src/consensus/tx_verify.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) 2017-2020 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#ifndef BITCOIN_CONSENSUS_TX_VERIFY_H
6+
#define BITCOIN_CONSENSUS_TX_VERIFY_H
7+
8+
#include "main.h"
9+
10+
class CTransaction;
11+
12+
/** Count ECDSA signature operations the old-fashioned (pre-0.6) way
13+
@param[in] tx The transaction to count
14+
@return number of sigops tx's outputs will produce when spent
15+
@see FetchInputs
16+
*/
17+
unsigned int GetLegacySigOpCount(const CTransaction& tx);
18+
19+
/** Count ECDSA signature operations in pay-to-script-hash inputs.
20+
@param[in] tx The transaction to count
21+
@param[in] mapInputs Map of previous transactions that have outputs tx is spending
22+
@return maximum number of sigops required to validate tx's inputs
23+
@see FetchInputs
24+
*/
25+
unsigned int GetP2SHSigOpCount(const CTransaction& tx, const MapPrevTx& inputs);
26+
27+
/**
28+
* Check if transaction is final and can be included in a block with the
29+
* specified height and time. Consensus critical.
30+
*/
31+
bool IsFinalTx(const CTransaction &tx, int nBlockHeight = 0, int64_t nBlockTime = 0);
32+
33+
#endif // BITCOIN_CONSENSUS_TX_VERIFY_H

src/gridcoin/gridcoin.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,12 @@ void ScheduleUpdateChecks(CScheduler& scheduler)
406406
LogPrintf("Gridcoin: checking for updates every %" PRId64 " hours", hours);
407407

408408
scheduler.scheduleEvery([]{
409-
g_UpdateChecker->CheckForLatestUpdate();
409+
g_UpdateChecker->ScheduledUpdateCheck();
410410
}, hours * 60 * 60 * 1000);
411411

412412
// Schedule a start-up check one minute from now:
413413
scheduler.scheduleFromNow([]{
414-
g_UpdateChecker->CheckForLatestUpdate();
414+
g_UpdateChecker->ScheduledUpdateCheck();
415415
}, 60 * 1000);
416416
}
417417

@@ -429,6 +429,7 @@ void ScheduleBeaconDBPassivation(CScheduler& scheduler)
429429

430430
std::unique_ptr<Upgrade> g_UpdateChecker;
431431
bool fSnapshotRequest = false;
432+
bool fResetBlockchainRequest = false;
432433

433434
// -----------------------------------------------------------------------------
434435
// Functions

src/gridcoin/tx_message.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) 2014-2020 The Gridcoin developers
2+
// Distributed under the MIT/X11 software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#include <string>
6+
7+
#include "gridcoin/support/xml.h"
8+
#include "gridcoin/tx_message.h"
9+
10+
std::string GetMessage(const CTransaction& tx)
11+
{
12+
if (tx.nVersion <= 1) {
13+
return ExtractXML(tx.hashBoinc, "<MESSAGE>", "</MESSAGE>");
14+
}
15+
16+
if (tx.vContracts.empty()) {
17+
return std::string();
18+
}
19+
20+
if (tx.vContracts.front().m_type != GRC::ContractType::MESSAGE) {
21+
return std::string();
22+
}
23+
24+
const auto payload = tx.vContracts.front().SharePayloadAs<GRC::TxMessage>();
25+
26+
return payload->m_message;
27+
}

src/gridcoin/tx_message.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#pragma once
66

77
#include "gridcoin/contract/payload.h"
8+
#include "primitives/transaction.h"
89

910
#include <string>
1011

@@ -103,3 +104,8 @@ class TxMessage : public IContractPayload
103104
}
104105
}; // TxMessage
105106
}
107+
108+
//!
109+
//! \brief Get the custom, user-supplied transaction message, if any.
110+
//!
111+
std::string GetMessage(const CTransaction& tx);

0 commit comments

Comments
 (0)