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

blockchain: Ensure no stake opcodes in tx sanity. #1453

Merged

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Sep 14, 2018

This requires PR #1452.

This moves the check for validating that output scripts in non-stake transactions do not contain any of the opcodes only allowed in the stake tree to the CheckTransactionSanity function where it more naturally belongs since it does not require access to transaction inputs as its location in CheckTransactionInputs would otherwise indicate.

It should be noted that the check just before the one being moved in this change is removed because it checked that specific patterns involving stake opcodes where not being used in non-stake transactions which is a strict subset of the more general check which ensures there are no stake opcodes at all in the output scripts.

Also, to improve efficiency, the check is added to the existing loop which already iterates the outputs and the entire block is moved after some other faster checks.

Finally, since the transaction sanity code previously did not determine if the transaction is a stake transaction which is required for the check in question, this adds code to relatively efficiently determine that.

This is work towards #1145.

@davecgh davecgh added this to the 1.4.0 milestone Sep 14, 2018
@davecgh davecgh force-pushed the blockchain_no_stake_opcodes_tx_sanity branch from 28f1703 to 4e97fcb Compare September 14, 2018 03:24
@davecgh davecgh mentioned this pull request Sep 14, 2018
28 tasks
blockchain/validate.go Outdated Show resolved Hide resolved
This moves the check for validating that output scripts in non-stake
transactions do not contain any of the opcodes only allowed in the stake
tree to the CheckTransactionSanity function where it more naturally
belongs since it does not require access to transaction inputs as its
location in CheckTransactionInputs would otherwise indicate.

It should be noted that the check just before the one being moved in
this change is removed because it checked that specific patterns
involving stake opcodes where not being used in non-stake transactions
which is a strict subset of the more general check which ensures there
are no stake opcodes at all in the output scripts.

Also, to improve efficiency, the check is added to the existing loop
which already iterates the outputs and the entire block is moved after
some other faster checks.

Finally, since the transaction sanity code previously did not determine
if the transaction is a stake transaction which is required for the
check in question, this adds code to relatively efficiently determine
that.
@davecgh davecgh force-pushed the blockchain_no_stake_opcodes_tx_sanity branch from 4e97fcb to 37315c0 Compare September 14, 2018 18:48
@davecgh davecgh merged commit 37315c0 into decred:master Sep 14, 2018
@davecgh davecgh deleted the blockchain_no_stake_opcodes_tx_sanity branch September 14, 2018 18:57
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.

None yet

3 participants