Skip to content

Commit 99a6c63

Browse files
committed
fix: multiple dashifications applied to bitcoin-chainstate.cpp
1 parent 54f251e commit 99a6c63

1 file changed

Lines changed: 78 additions & 9 deletions

File tree

src/bitcoin-chainstate.cpp

Lines changed: 78 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <chainparams.h>
1515
#include <consensus/validation.h>
16+
#include <chainlock/chainlock.h>
1617
#include <core_io.h>
1718
#include <init/common.h>
1819
#include <node/blockstorage.h>
@@ -24,13 +25,25 @@
2425
#include <validation.h>
2526
#include <validationinterface.h>
2627

28+
// Temporary added, filter & clean-up:
29+
#include <evo/chainhelper.h>
30+
#include <evo/creditpool.h>
31+
#include <evo/deterministicmns.h>
32+
#include <evo/evodb.h>
33+
#include <governance/governance.h>
34+
#include <llmq/context.h>
35+
#include <masternode/meta.h>
36+
#include <masternode/sync.h>
37+
#include <netfulfilledman.h>
38+
#include <spork.h>
39+
// ----------
40+
2741
#include <filesystem>
2842
#include <functional>
2943
#include <iosfwd>
3044

3145
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
3246

33-
3447
//----------------
3548
// symbols g_stats_client, ValueFromAmount, GetPrettyExceptionStr are re-defined
3649
// here especially for dash-chainstate binary (kernel), because adding sources
@@ -105,25 +118,78 @@ int main(int argc, char* argv[])
105118

106119

107120
// SETUP: Chainstate
108-
ChainstateManager chainman;
109-
110-
auto rv = node::LoadChainstate(false,
121+
ChainstateManager chainman{chainparams};
122+
123+
// DASH SPECIFIC; maybe remove some
124+
CMasternodeMetaMan metaman;
125+
bool dash_dbs_in_memory = false;
126+
bool fReset = false;
127+
bool fReindexChainState = false;
128+
/* CEvoDB evodb(util::DbWrapperParams{.path = gArgs.GetDataDirNet(),
129+
.memory = dash_dbs_in_memory, .wipe = fReset || fReindexChainState});
130+
std::unique_ptr<CDeterministicMNManager> dmnman = std::make_unique<CDeterministicMNManager>(evodb, metaman);
131+
CGovernanceManager govman(metaman, chainman, dmnman, mn_sync);
132+
*/
133+
134+
std::unique_ptr<CEvoDB> evodb;
135+
std::unique_ptr<CDeterministicMNManager> dmnman;
136+
CMasternodeSync mn_sync{std::make_unique<NullNodeSyncNotifier>()};
137+
CGovernanceManager govman(metaman, chainman, dmnman, mn_sync);
138+
139+
140+
CSporkManager sporkman;
141+
chainlock::Chainlocks chainlocks(sporkman);
142+
143+
// try to drop govman, mn_payment, mempool
144+
int bls_threads = 1;
145+
int max_sigs_age = 1;
146+
int worker_count = 1;
147+
const auto data_dir = gArgs.GetDataDirNet();
148+
/*
149+
util::DbWrapperParams db_params{.path = data_dir, .memory = llmq_dbs_in_memory, .wipe = llmq_dbs_wipe};
150+
*/
151+
// LLMQContext llmq_ctx{*dmnman, evodb, sporkman, chainman, mn_sync, db_params, bls_threads, max_sigs_age, worker_count};
152+
// CChainstateHelper chain_helper(evodb, *dmnman, govman, *llmq_ctx.isman, *llmq_ctx.quorum_block_processor, *llmq_ctx.qsnapman, chainman, chanparams.GetConsensus(), mn_sync, sporkman, chainlocks, *llmq_ctx.qman);
153+
// --- DASH
154+
155+
std::unique_ptr<LLMQContext> llmq_ctx;
156+
std::unique_ptr<CChainstateHelper> chain_helper;
157+
auto rv = node::LoadChainstate(fReset,
111158
std::ref(chainman),
112-
nullptr,
113-
false,
159+
govman,
160+
metaman,
161+
mn_sync,
162+
sporkman,
163+
chainlocks,
164+
chain_helper,
165+
dmnman,
166+
evodb,
167+
llmq_ctx,
168+
nullptr, // mempool
169+
gArgs.GetDataDirNet(),
170+
false, // fPruneMode
171+
false, // index
172+
false, // index
173+
false, // index
114174
chainparams.GetConsensus(),
115-
false,
175+
fReindexChainState,
116176
2 << 20,
117177
2 << 22,
118178
(450 << 20) - (2 << 20) - (2 << 22),
119179
false,
120180
false,
121-
[]() { return false; });
181+
dash_dbs_in_memory,
182+
bls_threads, // bls threads
183+
worker_count,
184+
max_sigs_age,
185+
[]() { return false; }, // shutdown_requested
186+
[]() { return false; }); // this corner case be added to
122187
if (rv.has_value()) {
123188
std::cerr << "Failed to load Chain state from your datadir." << std::endl;
124189
goto epilogue;
125190
} else {
126191
auto maybe_verify_error = node::VerifyLoadedChainstate(std::ref(chainman),
192+
*evodb,
127193
false,
128194
false,
129195
chainparams.GetConsensus(),
@@ -217,7 +283,7 @@ int main(int argc, char* argv[])
217283
bool new_block;
218284
auto sc = std::make_shared<submitblock_StateCatcher>(block.GetHash());
219285
RegisterSharedValidationInterface(sc);
220-
bool accepted = chainman.ProcessNewBlock(chainparams, blockptr, /* force_processing */ true, /* new_block */ &new_block);
286+
bool accepted = chainman.ProcessNewBlock(blockptr, /*force_processing=*/true, /*new_block=*/&new_block);
221287
UnregisterSharedValidationInterface(sc);
222288
if (!new_block && accepted) {
223289
std::cerr << "duplicate" << std::endl;
@@ -259,6 +325,9 @@ int main(int argc, char* argv[])
259325
case BlockValidationResult::BLOCK_CHECKPOINT:
260326
std::cerr << "the block failed to meet one of our checkpoints" << std::endl;
261327
break;
328+
case BlockValidationResult::BLOCK_CHAINLOCK:
329+
std::cerr << "the block conflicts with the ChainLock" << std::endl;
330+
break;
262331
}
263332
}
264333

0 commit comments

Comments
 (0)