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

backport: merge bitcoin#19905, #19927, #21025, #20749, #21055, partial #19775, #20750, #21270 (prune g_chainman usage) #5235

Merged
merged 37 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d5ccebd
log: add a log for invalid mnauth (#5271)
PastaPastaPasta Mar 29, 2023
7f520f5
log: Add logs when send qgetdata (#5275)
ogabrielides Mar 29, 2023
5456be6
feat(rpc): Added RPC cleardiscouraged (#5273)
ogabrielides Mar 29, 2023
376f78d
format: fix indentation (#5277)
PastaPastaPasta Mar 29, 2023
238e585
Merge #15718: docs: Improve netaddress comments
knst Feb 2, 2023
57e3060
Merge #16250: signrawtransactionwithkey: report error when missing re…
Jul 2, 2019
9149463
Merge #14734: fix an undefined behavior in uint::SetHex
laanwj Jul 3, 2019
13ac152
Merge #16325: rpc: Clarify that block count means height excl genesis
laanwj Jul 3, 2019
4459e60
Merge #16352: build: prune dbus from depends
laanwj Jul 8, 2019
906dd71
Merge #16267: bench: Benchmark blockToJSON
laanwj Jul 8, 2019
ddd8e2f
Merge #16334: test: rpc_users: Also test rpcauth.py with password.
laanwj Jul 12, 2019
e246892
Merge #16464: [qa] Ensure we don't generate a too-big block in p2sh s…
Jul 28, 2019
211faa9
Merge #15709: wallet: Do not add "setting" key as unknown
meshcollider Jul 30, 2019
7a850da
Merge pull request #5199 from knst/bc-bp-missing-2
UdjinM6 Mar 29, 2023
08aa10c
fix: add a missing name for key `hdaccounts` for RPC help for `getwal…
knst Mar 30, 2023
f4b91c0
fix(net): Do not punish nodes when Quorum data are missing. (#5272)
ogabrielides Mar 30, 2023
2d89442
fix: hpmn adjustements to getprojectedmnpayees (#5274)
ogabrielides Mar 30, 2023
1a96a98
fix: add a `bias` to IsExpired to avoid potential timing issues where…
PastaPastaPasta Mar 30, 2023
6e00fd0
fix(test): bump `quorum_data_request_expiration_timeout` to fix `p2p_…
UdjinM6 Mar 30, 2023
6947dfb
Merge #18817: doc: Document differences in bitcoind and bitcoin-qt lo…
Aug 29, 2020
b35557b
Merge #18952: test: avoid os-dependant path
May 16, 2020
38b42f6
Merge pull request #5013 from vijaydasmp/bp21_3
PastaPastaPasta Apr 2, 2023
79a5b19
refactor/fix: replace expired requests with a new one in RequestQuoru…
UdjinM6 Apr 4, 2023
15a9783
trivial(doc): fix typos in getrawtransaction and decoderawtransaction…
UdjinM6 Apr 4, 2023
ce3e807
merge #13868: Remove unused fScriptChecks parameter from CheckInputs
knst Sep 2, 2019
bd00a6a
merge #16400: refactor: Rewrite AcceptToMemoryPoolWorker() using smal…
knst Mar 16, 2023
bce9b6b
merge bitcoin#19905: Remove dead CheckForkWarningConditionsOnNewFork
kwvg Sep 7, 2020
0d7516e
merge bitcoin#19927: Reduce direct g_chainman usage
kwvg Sep 8, 2020
6648e9f
merge bitcoin#21025: Guard all chainstates with cs_main
kwvg Jan 27, 2021
b0b80d0
partial bitcoin#19775: Activate segwit in TestChain100Setup
kwvg Mar 13, 2023
431415a
merge bitcoin#20828: Introduce CallOneOf helper to replace switch-case
kwvg Mar 16, 2023
3eb8931
fuzz: remove unused variable in script_bitcoin_consensus
kwvg Mar 16, 2023
9d55bd8
merge bitcoin#20749: Prune g_chainman usage related to ::LookupBlockI…
kwvg Mar 27, 2023
228a7fb
merge bitcoin#20972: Annotate CTxMemPool::check to require cs_main
kwvg Jan 20, 2021
30191be
merge bitcoin#20750: Prune g_chainman usage in mempool-related valida…
kwvg Mar 23, 2023
548e870
merge bitcoin#21055: Prune remaining g_chainman usage in validation f…
kwvg Mar 13, 2023
24a5552
partial bitcoin#21270: Prune g_chainman usage in validation-adjacent …
kwvg Mar 8, 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
27 changes: 0 additions & 27 deletions depends/packages/dbus.mk

This file was deleted.

2 changes: 1 addition & 1 deletion depends/packages/packages.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
packages:=boost libevent gmp backtrace

qt_linux_packages:=qt expat dbus libxcb xcb_proto libXau xproto freetype fontconfig libxkbcommon
qt_linux_packages:=qt expat libxcb xcb_proto libXau xproto freetype fontconfig libxkbcommon

qrencode_linux_packages = qrencode
qrencode_android_packages = qrencode
Expand Down
1 change: 0 additions & 1 deletion doc/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ These are the dependencies currently used by Dash Core. You can find instruction
| Berkeley DB | [4.8.30](https://www.oracle.com/technetwork/database/database-technologies/berkeleydb/downloads/index.html) | 4.8.x | No | | |
| Boost | [1.73.0](https://www.boost.org/users/download/) | [1.64.0](https://github.com/bitcoin/bitcoin/pull/22320) | No | | |
| Clang<sup>[ \* ](#note1)</sup> | | [5.0+](https://releases.llvm.org/download.html) (C++17 support) | | | |
| D-Bus | [1.10.18](https://cgit.freedesktop.org/dbus/dbus/tree/NEWS?h=dbus-1.10) | | No | Yes | |
| Expat | [2.2.7](https://libexpat.github.io/) | | No | Yes | |
| fontconfig | [2.12.1](https://www.freedesktop.org/software/fontconfig/release/) | | No | Yes | |
| FreeType | [2.7.1](https://download.savannah.gnu.org/releases/freetype) | | No | | [Yes](https://github.com/dashpay/dash/blob/develop/depends/packages/qt.mk) (Android only) |
Expand Down
5 changes: 5 additions & 0 deletions doc/release-notes-5273.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Added RPCs
--------

- `cleardiscouraged` clears all the already discouraged peers.

1 change: 1 addition & 0 deletions src/Makefile.bench.include
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ bench_bench_dash_SOURCES = \
bench/mempool_stress.cpp \
bench/nanobench.h \
bench/nanobench.cpp \
bench/rpc_blockchain.cpp \
bench/rpc_mempool.cpp \
bench/util_time.cpp \
bench/base58.cpp \
Expand Down
10 changes: 10 additions & 0 deletions src/banman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ void BanMan::ClearBanned()
if (m_client_interface) m_client_interface->BannedListChanged();
}

void BanMan::ClearDiscouraged()
{
{
LOCK(m_cs_banned);
m_discouraged.reset();
m_is_dirty = true;
}
if (m_client_interface) m_client_interface->BannedListChanged();
}

bool BanMan::IsDiscouraged(const CNetAddr& net_addr)
{
LOCK(m_cs_banned);
Expand Down
1 change: 1 addition & 0 deletions src/banman.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class BanMan
void Ban(const CSubNet& sub_net, int64_t ban_time_offset = 0, bool since_unix_epoch = false);
void Discourage(const CNetAddr& net_addr);
void ClearBanned();
void ClearDiscouraged();

//! Return whether net_addr is banned
bool IsBanned(const CNetAddr& net_addr);
Expand Down
2 changes: 1 addition & 1 deletion src/bench/block_assemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static void AssembleBlock(benchmark::Bench& bench)

for (const auto& txr : txs) {
CValidationState state;
bool ret{::AcceptToMemoryPool(*test_setup.m_node.mempool, state, txr, nullptr /* pfMissingInputs */, false /* bypass_limits */, /* nAbsurdFee */ 0)};
bool ret{::AcceptToMemoryPool(::ChainstateActive(), *test_setup.m_node.mempool, state, txr, nullptr /* pfMissingInputs */, false /* bypass_limits */, /* nAbsurdFee */ 0)};
assert(ret);
}
}
Expand Down
35 changes: 35 additions & 0 deletions src/bench/rpc_blockchain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2016-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 <bench/data.h>

#include <validation.h>
#include <streams.h>
#include <consensus/validation.h>
#include <llmq/chainlocks.h>
#include <llmq/instantsend.h>
#include <rpc/blockchain.h>

#include <univalue.h>

static void BlockToJsonVerbose(benchmark::Bench& bench) {
CDataStream stream(benchmark::data::block813851, SER_NETWORK, PROTOCOL_VERSION);
char a = '\0';
stream.write(&a, 1); // Prevent compaction

CBlock block;
stream >> block;

CBlockIndex blockindex;
const uint256 blockHash = block.GetHash();
blockindex.phashBlock = &blockHash;
blockindex.nBits = 403014710;

bench.run([&] {
(void)blockToJSON(block, &blockindex, &blockindex, *llmq::chainLocksHandler, *llmq::quorumInstantSendManager, /*verbose*/ true);
});
}

BENCHMARK(BlockToJsonVerbose);
2 changes: 1 addition & 1 deletion src/coinjoin/coinjoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ bool CCoinJoin::IsCollateralValid(CTxMemPool& mempool, const CTransaction& txCol
{
LOCK(cs_main);
CValidationState validationState;
if (!AcceptToMemoryPool(mempool, validationState, MakeTransactionRef(txCollateral), /*pfMissingInputs=*/nullptr, /*bypass_limits=*/false, /*nAbsurdFee=*/DEFAULT_MAX_RAW_TX_FEE, /*test_accept=*/true)) {
if (!AcceptToMemoryPool(::ChainstateActive(), mempool, validationState, MakeTransactionRef(txCollateral), /*pfMissingInputs=*/nullptr, /*bypass_limits=*/false, /*nAbsurdFee=*/DEFAULT_MAX_RAW_TX_FEE, /*test_accept=*/true)) {
LogPrint(BCLog::COINJOIN, "CCoinJoin::IsCollateralValid -- didn't pass AcceptToMemoryPool()\n");
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/coinjoin/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void CCoinJoinServer::CommitFinalTransaction()
TRY_LOCK(cs_main, lockMain);
CValidationState validationState;
mempool.PrioritiseTransaction(hashTx, 0.1 * COIN);
if (!lockMain || !AcceptToMemoryPool(mempool, validationState, finalTransaction, nullptr /* pfMissingInputs */, false /* bypass_limits */, DEFAULT_MAX_RAW_TX_FEE /* nAbsurdFee */)) {
if (!lockMain || !AcceptToMemoryPool(::ChainstateActive(), mempool, validationState, finalTransaction, nullptr /* pfMissingInputs */, false /* bypass_limits */, DEFAULT_MAX_RAW_TX_FEE /* nAbsurdFee */)) {
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CommitFinalTransaction -- AcceptToMemoryPool() error: Transaction not valid\n");
WITH_LOCK(cs_coinjoin, SetNull());
// not much we can do in this case, just notify clients
Expand Down Expand Up @@ -455,7 +455,7 @@ void CCoinJoinServer::ConsumeCollateral(const CTransactionRef& txref) const
{
LOCK(cs_main);
CValidationState validationState;
if (!AcceptToMemoryPool(mempool, validationState, txref, nullptr /* pfMissingInputs */, false /* bypass_limits */, 0 /* nAbsurdFee */)) {
if (!AcceptToMemoryPool(::ChainstateActive(), mempool, validationState, txref, nullptr /* pfMissingInputs */, false /* bypass_limits */, 0 /* nAbsurdFee */)) {
LogPrint(BCLog::COINJOIN, "%s -- AcceptToMemoryPool failed\n", __func__);
} else {
connman.RelayTransaction(*txref);
Expand Down
26 changes: 23 additions & 3 deletions src/evo/deterministicmns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,35 @@ std::vector<CDeterministicMNCPtr> CDeterministicMNList::GetProjectedMNPayees(int
if (nCount < 0 ) {
return {};
}
nCount = std::min(nCount, int(GetValidMNsCount()));
nCount = std::min(nCount, int(GetValidWeightedMNsCount()));

std::vector<CDeterministicMNCPtr> result;
result.reserve(nCount);

auto remaining_hpmn_payments = 0;
CDeterministicMNCPtr hpmn_to_be_skipped = nullptr;
ForEachMNShared(true, [&](const CDeterministicMNCPtr& dmn) {
result.emplace_back(dmn);
if (dmn->pdmnState->nLastPaidHeight == nHeight) {
// We found the last MN Payee.
// If the last payee is a HPMN, we need to check its consecutive payments and pay him again if needed
if (dmn->nType == MnType::HighPerformance && dmn->pdmnState->nConsecutivePayments < dmn_types::HighPerformance.voting_weight) {
remaining_hpmn_payments = dmn_types::HighPerformance.voting_weight - dmn->pdmnState->nConsecutivePayments;
for ([[maybe_unused]] auto _ : irange::range(remaining_hpmn_payments)) {
result.emplace_back(dmn);
hpmn_to_be_skipped = dmn;
}
}
}
return;
});

ForEachMNShared(true, [&](const CDeterministicMNCPtr& dmn) {
if (dmn == hpmn_to_be_skipped) return;
for ([[maybe_unused]] auto _ : irange::range(GetMnType(dmn->nType).voting_weight)) {
result.emplace_back(dmn);
}
});
std::sort(result.begin(), result.end(), [&](const CDeterministicMNCPtr& a, const CDeterministicMNCPtr& b) {
std::sort(result.begin() + remaining_hpmn_payments, result.end(), [&](const CDeterministicMNCPtr& a, const CDeterministicMNCPtr& b) {
return CompareByLastPaid(a.get(), b.get());
});

Expand Down
9 changes: 9 additions & 0 deletions src/evo/deterministicmns.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <immer/map.hpp>

#include <numeric>
#include <unordered_map>
#include <utility>

Expand Down Expand Up @@ -241,6 +242,14 @@ class CDeterministicMNList
return ranges::count_if(mnMap, [](const auto& p) { return p.second->nType == MnType::HighPerformance && IsMNValid(*p.second); });
}

[[nodiscard]] size_t GetValidWeightedMNsCount() const
{
return std::accumulate(mnMap.begin(), mnMap.end(), 0, [](auto res, const auto& p) {
if (!IsMNValid(*p.second)) return res;
return res + GetMnType(p.second->nType).voting_weight;
});
}

/**
* Execute a callback on all masternodes in the mnList. This will pass a reference
* of each masternode to the callback function. This should be preferred over ForEachMNShared.
Expand Down
1 change: 1 addition & 0 deletions src/evo/mnauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void CMNAuth::ProcessMessage(CNode& peer, CConnman& connman, std::string_view ms

if (!mnauth.sig.IsValid()) {
Misbehaving(peer.GetId(), 100, "invalid mnauth signature");
LogPrint(BCLog::NET_NETCONN, "CMNAuth::ProcessMessage -- invalid mnauth for protx=%s with sig=%s\n", mnauth.proRegTxHash.ToString(), mnauth.sig.ToString());
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/evo/mnhftx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool CheckMNHFTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidat
return state.Invalid(ValidationInvalidReason::CONSENSUS, false, REJECT_INVALID, "bad-mnhf-version");
}

const CBlockIndex* pindexQuorum = LookupBlockIndex(mnhfTx.signal.quorumHash);
const CBlockIndex* pindexQuorum = g_chainman.m_blockman.LookupBlockIndex(mnhfTx.signal.quorumHash);
if (!pindexQuorum) {
return state.Invalid(ValidationInvalidReason::CONSENSUS, false, REJECT_INVALID, "bad-mnhf-quorum-hash");
}
Expand Down
4 changes: 2 additions & 2 deletions src/evo/simplifiedmns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,14 @@ bool BuildSimplifiedMNListDiff(const uint256& baseBlockHash, const uint256& bloc

const CBlockIndex* baseBlockIndex = ::ChainActive().Genesis();
if (!baseBlockHash.IsNull()) {
baseBlockIndex = LookupBlockIndex(baseBlockHash);
baseBlockIndex = g_chainman.m_blockman.LookupBlockIndex(baseBlockHash);
if (!baseBlockIndex) {
errorRet = strprintf("block %s not found", baseBlockHash.ToString());
return false;
}
}

const CBlockIndex* blockIndex = LookupBlockIndex(blockHash);
const CBlockIndex* blockIndex = g_chainman.m_blockman.LookupBlockIndex(blockHash);
if (!blockIndex) {
errorRet = strprintf("block %s not found", blockHash.ToString());
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/evo/specialtxman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bool CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CVali
case TRANSACTION_QUORUM_COMMITMENT:
return llmq::CheckLLMQCommitment(tx, pindexPrev, state);
case TRANSACTION_MNHF_SIGNAL:
return VersionBitsTipState(Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024) == ThresholdState::ACTIVE && CheckMNHFTx(tx, pindexPrev, state);
return VersionBitsState(::ChainActive().Tip(), Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024, versionbitscache) == ThresholdState::ACTIVE && CheckMNHFTx(tx, pindexPrev, state);
}
} catch (const std::exception& e) {
LogPrintf("%s -- failed: %s\n", __func__, e.what());
Expand Down
2 changes: 1 addition & 1 deletion src/governance/classes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ void CSuperblock::ParsePaymentSchedule(const std::string& strPaymentAddresses, c

// TODO: script addresses limit here and cs_main lock in
// CGovernanceManager::InitOnLoad()once DIP0024 is active
bool fAllowScript = (VersionBitsTipState(Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024) == ThresholdState::ACTIVE);
bool fAllowScript = (VersionBitsState(::ChainActive().Tip(), Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024, versionbitscache) == ThresholdState::ACTIVE);
for (int i = 0; i < (int)vecParsed1.size(); i++) {
CTxDestination dest = DecodeDestination(vecParsed1[i]);
if (!IsValidDestination(dest)) {
Expand Down
4 changes: 2 additions & 2 deletions src/governance/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ void CGovernanceManager::UpdateCachesAndClean()
} else {
// NOTE: triggers are handled via triggerman
if (pObj->GetObjectType() == GOVERNANCE_OBJECT_PROPOSAL) {
bool fAllowScript = (VersionBitsTipState(Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024) == ThresholdState::ACTIVE);
bool fAllowScript = (VersionBitsState(::ChainActive().Tip(), Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024, versionbitscache) == ThresholdState::ACTIVE);
CProposalValidator validator(pObj->GetDataAsHexString(), fAllowScript);
if (!validator.Validate()) {
LogPrint(BCLog::GOBJECT, "CGovernanceManager::UpdateCachesAndClean -- set for deletion expired obj %s\n", strHash);
Expand Down Expand Up @@ -635,7 +635,7 @@ void CGovernanceManager::SyncObjects(CNode& peer, CConnman& connman) const

LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s -- syncing all objects to peer=%d\n", __func__, peer.GetId());

bool fAllowScript = WITH_LOCK(cs_main, return VersionBitsTipState(Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024) == ThresholdState::ACTIVE);
bool fAllowScript = WITH_LOCK(cs_main, return VersionBitsState(::ChainActive().Tip(), Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024, versionbitscache) == ThresholdState::ACTIVE);

LOCK(cs);

Expand Down
8 changes: 4 additions & 4 deletions src/governance/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ bool CGovernanceObject::IsValidLocally(std::string& strError, bool& fMissingConf

switch (nObjectType) {
case GOVERNANCE_OBJECT_PROPOSAL: {
bool fAllowScript = (VersionBitsTipState(Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024) == ThresholdState::ACTIVE);
bool fAllowScript = (VersionBitsState(::ChainActive().Tip(), Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024, versionbitscache) == ThresholdState::ACTIVE);
CProposalValidator validator(GetDataAsHexString(), fAllowScript);
// Note: It's ok to have expired proposals
// they are going to be cleared by CGovernanceManager::UpdateCachesAndClean()
Expand Down Expand Up @@ -563,7 +563,7 @@ bool CGovernanceObject::IsCollateralValid(std::string& strError, bool& fMissingC
findScript << OP_RETURN << ToByteVector(nExpectedHash);

AssertLockHeld(cs_main);
bool fork_active = VersionBitsState(LookupBlockIndex(nBlockHash), Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024, versionbitscache) == ThresholdState::ACTIVE;
bool fork_active = VersionBitsState(g_chainman.m_blockman.LookupBlockIndex(nBlockHash), Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024, versionbitscache) == ThresholdState::ACTIVE;
CAmount nMinFee = GetMinCollateralFee(fork_active);

LogPrint(BCLog::GOBJECT, "CGovernanceObject::IsCollateralValid -- txCollateral->vout.size() = %s, findScript = %s, nMinFee = %lld\n",
Expand Down Expand Up @@ -594,7 +594,7 @@ bool CGovernanceObject::IsCollateralValid(std::string& strError, bool& fMissingC
AssertLockHeld(cs_main);
int nConfirmationsIn = 0;
if (nBlockHash != uint256()) {
const CBlockIndex* pindex = LookupBlockIndex(nBlockHash);
const CBlockIndex* pindex = g_chainman.m_blockman.LookupBlockIndex(nBlockHash);
if (pindex && ::ChainActive().Contains(pindex)) {
nConfirmationsIn += ::ChainActive().Height() - pindex->nHeight + 1;
}
Expand Down Expand Up @@ -692,7 +692,7 @@ void CGovernanceObject::Relay(CConnman& connman) const
// But we don't want to relay it to pre-GOVSCRIPT_PROTO_VERSION peers if payment_address is p2sh
// because they won't accept it anyway and will simply ban us eventually.
LOCK(cs_main);
bool fAllowScript = (VersionBitsTipState(Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024) == ThresholdState::ACTIVE);
bool fAllowScript = (VersionBitsState(::ChainActive().Tip(), Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024, versionbitscache) == ThresholdState::ACTIVE);
if (fAllowScript) {
CProposalValidator validator(GetDataAsHexString(), false /* no script */);
if (!validator.Validate(false /* ignore expiration */)) {
Expand Down
4 changes: 2 additions & 2 deletions src/index/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bool BaseIndex::Init()
if (locator.IsNull()) {
m_best_block_index = nullptr;
} else {
m_best_block_index = FindForkInGlobalIndex(::ChainActive(), locator);
m_best_block_index = g_chainman.m_blockman.FindForkInGlobalIndex(::ChainActive(), locator);
}
m_synced = m_best_block_index.load() == ::ChainActive().Tip();
return true;
Expand Down Expand Up @@ -238,7 +238,7 @@ void BaseIndex::ChainStateFlushed(const CBlockLocator& locator)
const CBlockIndex* locator_tip_index;
{
LOCK(cs_main);
locator_tip_index = LookupBlockIndex(locator_tip_hash);
locator_tip_index = g_chainman.m_blockman.LookupBlockIndex(locator_tip_hash);
}

if (!locator_tip_index) {
Expand Down
Loading