-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Use a proper factory for creating chainparams #8855
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
Conversation
45a4a48 to
183c143
Compare
|
Pushed with more changes added to the OP. |
183c143 to
0de6821
Compare
0de6821 to
180ee2a
Compare
|
Added 1 commit. |
180ee2a to
3d5a1af
Compare
3d5a1af to
cfa5c2b
Compare
|
Needed rebase |
cfa5c2b to
3ae62e4
Compare
|
Needed rebase to adapt to a new test using Params(std::string). |
3ae62e4 to
eb6c595
Compare
|
Needed rebase for bench/checkblock.cpp again |
src/chainparamsbase.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why this does not return a unique_ptr?
src/chainparamsbase.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be a function rather than a static method.
src/bitcoin-cli.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines like this (as there are many) can avoid some redundancy by using const auto defaultBaseParmams = ... instead.
src/chainparams.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be a function rather than a static method.
eb6c595 to
dd882d1
Compare
|
Updated, hopefully fixing all nits. |
src/chainparamsbase.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto-nit: why remove this?
src/test/pow_tests.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also all these could remain const, will push shortly...
sipa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK dd882d15c846da56a3338626be4e411a003eb8b5
src/chainparams.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μnit: you can just use assert(globalChainParams) (std::unique_ptr has an implicit conversion to bool, which checks whether there is an owned object),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remains from boost::scoped_ptr, fixing now...
ea5175d to
e0e2a3e
Compare
|
Solved auto-nits, also rebased. |
src/chainparamsbase.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment out of date now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the caller doesn't have to explicitly delete the object anymore, thanks.
e0e2a3e to
f9794a5
Compare
|
Updated and hopefully fixed latest small nits. Thanks again for the nits. |
…n default 4aa2508 Bugfix: Use testnet RequireStandard for -acceptnonstdtxn default (Luke Dashjr) Pull request description: Fixes a bug introduced in #8855 `-acceptnonstdtxn` is a valid option only for testnet/regtest (in Core), and the help message reflects that. Currently, however, it is buggy in two ways: 1. It uses mainnet to get the default value, which doesn't make sense since the option is never available for mainnet, and the only time the option is available, is when the default is the opposite. 2. It uses the value of "require standard" directly as the default for "accept non-standard transactions", but these concepts are opposites: a negation must be performed to transform one to the other. Note the combination of these bugs results in the correct boolean output, but the logic to get there is completely wrong. Tree-SHA512: 06ce513f59ba31f7ab4b6422a08a17bb37a5652dea4c38a4bbefedd5e2752d17bfccc32a4b0508068fa4783e316bff00a821ef18a24b1a2bb02859995d188fdc
c1082a7 Chainparams: Use the factory for pow tests (Jorge Timón) 2351a06 Chainparams: Get rid of CChainParams& Params(std::string) (Jorge Timón) f87f362 Chainparams: Use a regular factory for creating chainparams (Jorge Timón) Tree-SHA512: 359c8a2a1bc9d02db7856d02810240ada28048ac088f878b575597a7255cdb0ffdd1a647085ee67a34c6a7e7ed9e6cfdb61240cf6e75139619b640dbb096072c
c1082a7 Chainparams: Use the factory for pow tests (Jorge Timón) 2351a06 Chainparams: Get rid of CChainParams& Params(std::string) (Jorge Timón) f87f362 Chainparams: Use a regular factory for creating chainparams (Jorge Timón) Tree-SHA512: 359c8a2a1bc9d02db7856d02810240ada28048ac088f878b575597a7255cdb0ffdd1a647085ee67a34c6a7e7ed9e6cfdb61240cf6e75139619b640dbb096072c
…onstdtxn default 4aa2508 Bugfix: Use testnet RequireStandard for -acceptnonstdtxn default (Luke Dashjr) Pull request description: Fixes a bug introduced in bitcoin#8855 `-acceptnonstdtxn` is a valid option only for testnet/regtest (in Core), and the help message reflects that. Currently, however, it is buggy in two ways: 1. It uses mainnet to get the default value, which doesn't make sense since the option is never available for mainnet, and the only time the option is available, is when the default is the opposite. 2. It uses the value of "require standard" directly as the default for "accept non-standard transactions", but these concepts are opposites: a negation must be performed to transform one to the other. Note the combination of these bugs results in the correct boolean output, but the logic to get there is completely wrong. Tree-SHA512: 06ce513f59ba31f7ab4b6422a08a17bb37a5652dea4c38a4bbefedd5e2752d17bfccc32a4b0508068fa4783e316bff00a821ef18a24b1a2bb02859995d188fdc
…onstdtxn default 4aa2508 Bugfix: Use testnet RequireStandard for -acceptnonstdtxn default (Luke Dashjr) Pull request description: Fixes a bug introduced in bitcoin#8855 `-acceptnonstdtxn` is a valid option only for testnet/regtest (in Core), and the help message reflects that. Currently, however, it is buggy in two ways: 1. It uses mainnet to get the default value, which doesn't make sense since the option is never available for mainnet, and the only time the option is available, is when the default is the opposite. 2. It uses the value of "require standard" directly as the default for "accept non-standard transactions", but these concepts are opposites: a negation must be performed to transform one to the other. Note the combination of these bugs results in the correct boolean output, but the logic to get there is completely wrong. Tree-SHA512: 06ce513f59ba31f7ab4b6422a08a17bb37a5652dea4c38a4bbefedd5e2752d17bfccc32a4b0508068fa4783e316bff00a821ef18a24b1a2bb02859995d188fdc
…cture d1244f3 Fix UB in CChainParams unique_ptr subclasses destructor. (furszy) cf20f43 Chainparams: Get rid of CChainParams& Params(std::string) (Jorge Timón) eeea862 Chainparams: Use a regular factory for creating chainparams (Jorge Timón) f9d585a More zerocoin unused functions and classes cleanup. (furszy) 029ce7b pivx-cli align -rpcport help message to init.cpp help message. (furszy) 3431977 Chainparams: Translations: DRY: options and error strings Also remove SelectBaseParamsFromCommandLine and SelectParamsFromCommandLin (Jorge Timón) ce7a792 Removed unused AreBaseParamsConfigured() (furszy) 508fec1 Chainparams: Replace CBaseChainParams::Network enum with string constants (furszy) 2a1f16c Chainparams: CTestNetParams and CRegTestParams extend directly from CChainParams (furszy) 0ed1a48 Refactor `Params().NetworkID() == CBaseChainParams::TESTNET` for IsTestnet() direct call. (furszy) Pull request description: Made several updates to the base chain params structure and further cleanups over the zerocoin code: * Replaced `CBaseChainParams::Network` enum with string constants and unified better the network selection error + network help message (adaptation of dashpay#6235). * Removed unused NetworkID field from chain params (dashpay#5598). * Improved the network params creation using a proper factory (adaptation of bitcoin#8855). * Cleaned almost all the zerocoin related functions inside `zerocoin.h/cpp` and `zpivchain.h/cpp`. ACKs for top commit: random-zebra: ACK d1244f3 Fuzzbawls: ACK d1244f3 Tree-SHA512: c7ecb34045f9e14dc60130d3f7142c2f32c4c16f5678e871036db0b513ec3c416762a2464ff0d50383a50d345ea90f2c5958284657479c2becaaf9bf3936fcd3
2 global variables are currently enough for basechainparams and CChainParams, but we're
using N + 1 globals instead. Although N is likely to remain 3 for the
foreseeable future
(and not many people seemed interested in turning NI believe segwit was an example on how starting a new testchain can be very useful and anything that makes that easier is potentially valuable.into infinite in #6382)
Traceability: Replaces #6907.
Changes from final non-merged #6907:
UpdateBIP9Parameters since we don't have a separate global for
regtest anymore. An additional assert/error could be added if we
wanted to restrict its usage beyond regtest, bit I don't think the
restriction makes sense. Remember that Params() now returns a const ref and init.cpp was the only context was the only context where UpdateRegtestBIP9Parameters was called from.