-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix: Various fixes for GetProjectedMNPayees #5638
Conversation
…ing to check mn_rr internally This ensures consitensy between pindex and the height of the mn list itself. Also try to guess mn_rr activation status at nHeight if possible
…ount, should reserve memory accordingly
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.
ACK
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.
re-ACK
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 like these 3 commits:
f49dc1e - an additional fix on qt part
3329fcf and b9bc8f2 - small optimizations
Beside me (who met this issue first probably) it seems as similar issue happened by xckd also with dash-qt
and it seems as it happens when mnList
generated before chain re-organization and GetProjectedMNPayees
are requested after by GUI and only GUI (because it uses Tip() instead known pindex).
Taking in consideration that pindex
is used here only to determine flag "mn_rr" is activated to see different version of projected mn payees
; I propose to take a fix from 5590 as it is; add 3 other commits with improvements and in future after MN_RR would be buried (and height is fixed) we can use hardened height; the issue would be resolved by disappearing.
src/evo/deterministicmns.cpp
Outdated
{ | ||
if (nCount < 0 ) { | ||
return {}; | ||
} | ||
|
||
bool isMNRewardReallocation{false}; | ||
if (auto pindex = ::ChainActive()[nHeight]; pindex == nullptr) { |
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 don't like using here global variable ::ChainActive().Tip().
Also there can be 2 different chain (2 forks on same time) and extracting pindex by [nHeight] can be incorrect value. if after mnList is generated the chain would be switched to other one; the value of ::ChainActive()[nHeight]
would be not expected and list would be wrong.
For example call below:
auto projection = deterministicMNManager->GetListForBlock(pindexTip).GetProjectedMNPayees(20);
pindexTip
is known but we lost this information.
btw, GetProjecctedMNPayees
is just estimation list; is not used in consensus rules; so, I don't think that we need to consider case of LOCKED_IN to make calculation 100% exact for case that happens only once in chain - during MN_RR activation, I vote for simplicity here.
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, if we will change exact known pindex
by using ::ChainActive()[nHeight]
it may cause similar bug not only in GUI code but in all usages of GetProjecctedMNPayees
(that are non-GUI only), so in this case it can cause this issue getting bigger rather than beeing solved and we won't see it anymore because no crash -> seems works (but it does not). So, now I think that call g_chainman.m_blockman.LookupBlockIndex(blockHash))
is a proper solution until the BIP9 fork is buried (and we can use hardened height and drop g_chainman usage from here)
closing in fav of #5590 |
…xception 74d23bf rpc: document RPC_TRANSACTION_ALREADY_IN_CHAIN exception (Jarol Rodriguez) Pull request description: It is not documented in the `RPCHelpMan` of `sendrawtransaction` that if you attempt to send a transaction which already exists in a block, an `RPC_TRANSACTION_ALREADY_IN_CHAIN` exception will be raised. It is best to make developers aware of this so that it can be properly caught and avoid any headaches. Closes dashpay#5638 ACKs for top commit: jonatack: ACK 74d23bf Tree-SHA512: d1d5fc242574377c8a76b4ef7b12239996424d8bee186533b5a8fe337bbeb3186e51dbdd28c5eafb982601e44e17b68a7f52db5dd7bc647429f6f95e2de289f6
…xception 74d23bf rpc: document RPC_TRANSACTION_ALREADY_IN_CHAIN exception (Jarol Rodriguez) Pull request description: It is not documented in the `RPCHelpMan` of `sendrawtransaction` that if you attempt to send a transaction which already exists in a block, an `RPC_TRANSACTION_ALREADY_IN_CHAIN` exception will be raised. It is best to make developers aware of this so that it can be properly caught and avoid any headaches. Closes dashpay#5638 ACKs for top commit: jonatack: ACK 74d23bf Tree-SHA512: d1d5fc242574377c8a76b4ef7b12239996424d8bee186533b5a8fe337bbeb3186e51dbdd28c5eafb982601e44e17b68a7f52db5dd7bc647429f6f95e2de289f6
…xception 74d23bf rpc: document RPC_TRANSACTION_ALREADY_IN_CHAIN exception (Jarol Rodriguez) Pull request description: It is not documented in the `RPCHelpMan` of `sendrawtransaction` that if you attempt to send a transaction which already exists in a block, an `RPC_TRANSACTION_ALREADY_IN_CHAIN` exception will be raised. It is best to make developers aware of this so that it can be properly caught and avoid any headaches. Closes dashpay#5638 ACKs for top commit: jonatack: ACK 74d23bf Tree-SHA512: d1d5fc242574377c8a76b4ef7b12239996424d8bee186533b5a8fe337bbeb3186e51dbdd28c5eafb982601e44e17b68a7f52db5dd7bc647429f6f95e2de289f6
…xception 74d23bf rpc: document RPC_TRANSACTION_ALREADY_IN_CHAIN exception (Jarol Rodriguez) Pull request description: It is not documented in the `RPCHelpMan` of `sendrawtransaction` that if you attempt to send a transaction which already exists in a block, an `RPC_TRANSACTION_ALREADY_IN_CHAIN` exception will be raised. It is best to make developers aware of this so that it can be properly caught and avoid any headaches. Closes dashpay#5638 ACKs for top commit: jonatack: ACK 74d23bf Tree-SHA512: d1d5fc242574377c8a76b4ef7b12239996424d8bee186533b5a8fe337bbeb3186e51dbdd28c5eafb982601e44e17b68a7f52db5dd7bc647429f6f95e2de289f6
…xception 74d23bf rpc: document RPC_TRANSACTION_ALREADY_IN_CHAIN exception (Jarol Rodriguez) Pull request description: It is not documented in the `RPCHelpMan` of `sendrawtransaction` that if you attempt to send a transaction which already exists in a block, an `RPC_TRANSACTION_ALREADY_IN_CHAIN` exception will be raised. It is best to make developers aware of this so that it can be properly caught and avoid any headaches. Closes dashpay#5638 ACKs for top commit: jonatack: ACK 74d23bf Tree-SHA512: d1d5fc242574377c8a76b4ef7b12239996424d8bee186533b5a8fe337bbeb3186e51dbdd28c5eafb982601e44e17b68a7f52db5dd7bc647429f6f95e2de289f6
…xception 74d23bf rpc: document RPC_TRANSACTION_ALREADY_IN_CHAIN exception (Jarol Rodriguez) Pull request description: It is not documented in the `RPCHelpMan` of `sendrawtransaction` that if you attempt to send a transaction which already exists in a block, an `RPC_TRANSACTION_ALREADY_IN_CHAIN` exception will be raised. It is best to make developers aware of this so that it can be properly caught and avoid any headaches. Closes dashpay#5638 ACKs for top commit: jonatack: ACK 74d23bf Tree-SHA512: d1d5fc242574377c8a76b4ef7b12239996424d8bee186533b5a8fe337bbeb3186e51dbdd28c5eafb982601e44e17b68a7f52db5dd7bc647429f6f95e2de289f6
Issue being fixed or feature implemented
Another attempt to fix a crash mentioned in #5590. It's still a workaround and not a fix for the root of the issue (which is still unknown). Also, a couple of additional fixes and optimizations.
What was done?
240e8a9 - a more robust (imo) alternative to the solution provided in #5590
f49dc1e - an additional fix on qt part
3329fcf and b9bc8f2 - small optimizations
How Has This Been Tested?
run local qt node, run tests
Breaking Changes
n/a
Checklist: