|
13 | 13 |
|
14 | 14 | #include <chainparams.h> |
15 | 15 | #include <consensus/validation.h> |
| 16 | +#include <chainlock/chainlock.h> |
16 | 17 | #include <core_io.h> |
17 | 18 | #include <init/common.h> |
18 | 19 | #include <node/blockstorage.h> |
|
24 | 25 | #include <validation.h> |
25 | 26 | #include <validationinterface.h> |
26 | 27 |
|
| 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 | + |
27 | 41 | #include <filesystem> |
28 | 42 | #include <functional> |
29 | 43 | #include <iosfwd> |
30 | 44 |
|
31 | 45 | const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr; |
32 | 46 |
|
33 | | - |
34 | 47 | //---------------- |
35 | 48 | // symbols g_stats_client, ValueFromAmount, GetPrettyExceptionStr are re-defined |
36 | 49 | // here especially for dash-chainstate binary (kernel), because adding sources |
@@ -105,25 +118,78 @@ int main(int argc, char* argv[]) |
105 | 118 |
|
106 | 119 |
|
107 | 120 | // 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, |
111 | 158 | 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 |
114 | 174 | chainparams.GetConsensus(), |
115 | | - false, |
| 175 | + fReindexChainState, |
116 | 176 | 2 << 20, |
117 | 177 | 2 << 22, |
118 | 178 | (450 << 20) - (2 << 20) - (2 << 22), |
119 | 179 | false, |
120 | 180 | 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 |
122 | 187 | if (rv.has_value()) { |
123 | 188 | std::cerr << "Failed to load Chain state from your datadir." << std::endl; |
124 | 189 | goto epilogue; |
125 | 190 | } else { |
126 | 191 | auto maybe_verify_error = node::VerifyLoadedChainstate(std::ref(chainman), |
| 192 | + *evodb, |
127 | 193 | false, |
128 | 194 | false, |
129 | 195 | chainparams.GetConsensus(), |
@@ -217,7 +283,7 @@ int main(int argc, char* argv[]) |
217 | 283 | bool new_block; |
218 | 284 | auto sc = std::make_shared<submitblock_StateCatcher>(block.GetHash()); |
219 | 285 | 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); |
221 | 287 | UnregisterSharedValidationInterface(sc); |
222 | 288 | if (!new_block && accepted) { |
223 | 289 | std::cerr << "duplicate" << std::endl; |
@@ -259,6 +325,9 @@ int main(int argc, char* argv[]) |
259 | 325 | case BlockValidationResult::BLOCK_CHECKPOINT: |
260 | 326 | std::cerr << "the block failed to meet one of our checkpoints" << std::endl; |
261 | 327 | break; |
| 328 | + case BlockValidationResult::BLOCK_CHAINLOCK: |
| 329 | + std::cerr << "the block conflicts with the ChainLock" << std::endl; |
| 330 | + break; |
262 | 331 | } |
263 | 332 | } |
264 | 333 |
|
|
0 commit comments