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
multi: Add isAutoRevocationsEnabled to CheckSSRtx. #2719
multi: Add isAutoRevocationsEnabled to CheckSSRtx. #2719
Conversation
e79247f
to
4374260
Compare
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.
Have you considered simply adding the specific contextual check for the new revocations within checkBlockContext()
(e.g. through adding a CheckRRTxContext()
) instead?
This would reduce the code churn due to doing all this then (assuming the agenda passes) moving everything back into place.
Granted, this would make CheckRRTx incomplete (in the sense that it would be insufficient to fully determine whether a tx is in fact a revocation once the autorevocation
agenda actives) and we'd probably have to verify the assumptions in some other functions (that rely on a prior CheckSSRtx being applied), but splitting the checks would better match the actual activation process, given that all the checks in the original CheckSSRtx
are still applied.
Yeah, I did consider something along those lines. Unfortunately, as you noted, if we don't update Since |
e8aa7a9
to
528689d
Compare
Sure. But in practice, would something break specifically? Enforcement of the consensus rules for the additional conditions under the new rules would still be happening as appropriate (as an additional contextual check that would be added). The wallet (which iirc is the only other software which deals with revocations) could be modified to also verify the correct condition if we really wanted to make sure not extraneous data could make its way into the db. BTW, I'm not necessarily opposed to doing the check in one go based on the |
Nothing would break. It would still be enforced by consensus, as you stated. The reasons I am slightly in favor of the changes in this PR are:
In short, I don't think it would necessarily cause any issues not to do this, but I went in this direction because it is more technically correct and consistent with the existing code, which makes the behavior of the function easier to reason about. Other than making the updates in this PR, I don't think there is much of a downside since callers already have to pass Either way, we ultimately want to remove both the |
528689d
to
1c10805
Compare
1c10805
to
6ff90bf
Compare
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.
There are a lot of places I am compelled to whine about args having bool
two or three times, but I guess DCP0008 will allow those bools to be removed completely? Anyway good work.
6ff90bf
to
bdb5a62
Compare
I went ahead and updated those since it doesn't involve any functional changes and is arguably the more idiomatic approach.
If there are no version 2 revocation transactions in blocks prior to the agenda activating, then the agenda flag can be removed here, and instead the transaction version can be used as a proxy for the agenda being active. If a version 2 revocation transaction does exist in a block prior to the agenda activating (which would be fairly unlikely), we'd need another consensus change after DCP0008 is active to bump the revocation transaction version to something higher than the max allowed tx version in order to use the tx version as a proxy for the agenda activating. |
This adds the isAutoRevocationsEnabled flag to stake.CheckSSRtx, which in turn requires it to be added to stake.DetermineTxType and updating all callers. This is required for stake.CheckSSRtx since it will be updated to return errors if revocation transactions are not valid when the automatic ticket revocations agenda is enabled. This is not ideal since it requires passing around the context-based isAutoRevocationsEnabled flag in many places. If the automatic ticket revocations agenda activates and there are no existing version 2 revocation transactions in blocks, then this could retroactively be removed and the updated checks can be based on the transaction version instead.
881c5fe
to
598bf66
Compare
Requires #2718.
Note: This modifies the following exported functions from the
stake
package:func CheckSSRtx(tx *wire.MsgTx, isAutoRevocationsEnabled bool) error
func IsSSRtx(tx *wire.MsgTx, isAutoRevocationsEnabled bool) bool
func DetermineTxType(tx *wire.MsgTx, isTreasuryEnabled bool, isAutoRevocationsEnabled bool) TxType
This adds the
isAutoRevocationsEnabled
flag tostake.CheckSSRtx
, which in turn requires it to be added tostake.DetermineTxType
and updating all callers.This is required for
stake.CheckSSRtx
since it will be updated to return errors if revocation transactions are not valid when the automatic ticket revocations agenda is enabled.This is not ideal since it requires passing around the context-based
isAutoRevocationsEnabled
flag in many places.If the automatic ticket revocations agenda activates and there are no existing version 2 revocation transactions in blocks, then this could retroactively be removed and the updated checks can be based on the transaction version instead.
This does not contain any consensus rule changes. The consensus rule changes for DCP0009 will come in a separate pull request that is dependent on this one.