Skip to content
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: Remove agenda flags from DetermineTxType. #2922

Merged
merged 12 commits into from
May 8, 2022

Conversation

rstaudt2
Copy link
Member

NOTE: This is ready for review, however, it can't be merged until the auto revocations consensus change agenda becomes active.

--

This removes the auto revocations and treasury agenda flags from stake.DetermineTxType, stake.IsSSGen, stake.CheckSSGen, stake.CheckSSGenVotes, stake.CheckSSRtx, stake.CheckSSRtx, and several other functions where the flags became unused due to them being removed from these functions.

Instead of using the agenda flags, this updates the logic to use the transaction version as a proxy for the agendas. This is desirable because callers need global state to properly specify the agenda flags, whereas the transaction version can be determined from the transaction itself.

This is broken down into several commits to ease the review process. The major changes to call out are:

  • Remove the auto revocations agenda flag from stake.CheckSSRtx
    • This updates the stake.CheckSSRtx function to use the transaction version rather than the auto revocations agenda flag to determine whether to apply additional checks
    • This is now safe since:
      • The automatic revocations agenda has activated
      • Consensus rules enforce that the revocation transaction version MUST be 2 if the automatic revocations agenda is active
      • There are no revocations with a transaction version greater than or equal to 2 in any blocks prior to the agenda activating on mainnet
  • Remove the treasury agenda flag from stake.CheckSSGenVotes
    • This updates the stake.CheckSSGenVotes function to remove the treasury agenda check, but still retain the logic to reject vote transactions that contain a null data script in the last output but don't have a transaction version equal to the treasury transaction version
    • This is now safe since:
      • The treasury agenda has activated
      • There are no transactions that violate this rule in any blocks prior to the agenda activating
  • Remove the treasury agenda flag from stake.DetermineTxType
    • This updates stake.DetermineTxType to use the tx version to check if the treasury agenda is active rather than relying on the agenda flag
    • This is safe since the treasury agenda has activated and there are no transactions with a transaction version greater than or equal to the treasury transaction version in any blocks prior to the agenda activating

Upcoming changes constitute breaking public API changes to the gcs
module, therefore, this follows the process for introducing major API
breaks which consists of:

- Bump the major version in the go.mod of the affected module if not
  already done since the last release tag
- Add a replacement to the go.mod in the main module if not already done
  since the last release tag
- Update all imports in the repo to use the new major version as
  necessary
- Make necessary modifications to allow all other modules to use the new
  version in the same commit
- Repeat the process for any other modules the require a new major as a
  result of consuming the new major(s)
Upcoming changes constitute breaking public API changes to the
blockchain/stake module, therefore, this follows the process for
introducing major API breaks which consists of:

- Bump the major version in the go.mod of the affected module if not
  already done since the last release tag
- Add a replacement to the go.mod in the main module if not already done
  since the last release tag
- Update all imports in the repo to use the new major version as
  necessary
- Make necessary modifications to allow all other modules to use the new
  version in the same commit
- Repeat the process for any other modules the require a new major as a
  result of consuming the new major(s)
@davecgh davecgh added this to the 1.8.0 milestone Apr 11, 2022
@davecgh davecgh added the waiting for consensus change Pull requests that are waiting for consensus changes to activate. label Apr 12, 2022
Copy link
Member

@davecgh davecgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice change and I appreciate the logical commit structure that makes it so much easier to review for correctness.

I've thoroughly reviewed this and only spotted one thing in the tests that I called out inline. Once the necessary changes activate, I'll run a sync on mainnet and testnet with --nocheckpoints --assumevalid=0 as well to serve as an additional double check.

blockchain/stake/staketx_test.go Show resolved Hide resolved
This updates several test vote transactions to be version 1, since that
is the actual version that is currently used.
This updates the stake.CheckSSRtx function to use the transaction
version rather than the auto revocations agenda flag to determine
whether to apply additional checks.

This is now safe since:
- The automatic revocations agenda has activated
- Consensus rules enforce that the revocation transaction version MUST
  be 2 if the automatic revocations agenda is active
- There are no revocations with a transaction version greater than or
  equal to 2 in any blocks prior to the agenda activating on mainnet
This removes the auto revocations agenda flag from the stake.IsSSRtx
function since it is now unused due to it being removed from the
stake.CheckSSRtx function.
This updates the stake.CheckSSGenVotes function to remove the treasury
agenda check, but still retain the logic to reject vote transactions
that contain a null data script in the last output but don't have a
transaction version equal to the treasury transaction version.

This is now safe since:
- The treasury agenda has activated
- There are no transactions that violate this rule in any blocks prior
  to the agenda activating
This removes the treasury agenda flag from the stake.CheckSSGen
function since it is now unused due to it being removed from the
stake.CheckSSGenVotes function.
This removes the treasury agenda flag from the stake.IsSSGen function
since it is now unused due to it being removed from the stake.CheckSSGen
function.
This removes the treasury agenda flag from the several functions since
it is now unused due to it being removed from the stake.IsSSGen
function.
This updates stake.DetermineTxType to use the tx version to check if the
treasury agenda is active rather than relying on the agenda flag.

This is safe since the treasury agenda has activated and there are no
transactions with a transaction version greater than or equal to the
treasury transaction version in any blocks prior to the agenda
activating.
This removes the treasury and auto revocations agenda flags from the
stake.DetermineTxType since they are no longer used.
This removes the treasury and auto revocations agenda flags from the
several functions since it is now unused due to it being removed from
the stake.DetermineTxType function.
@rstaudt2 rstaudt2 force-pushed the check-auto-revocation-tx-version branch from 6b1eb41 to a415a35 Compare April 12, 2022 19:35
Copy link
Member

@davecgh davecgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm approving this now as everything looks good, but as previously mentioned, I still plan to test it again once the required consensus change activates.

@davecgh
Copy link
Member

davecgh commented May 8, 2022

I've now run the aforementioned sync on mainnet and testnet with --nocheckpoints--assumevalid=0` without issue.

@davecgh davecgh merged commit 1aa1afc into decred:master May 8, 2022
@davecgh davecgh removed the waiting for consensus change Pull requests that are waiting for consensus changes to activate. label Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants