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: check errors and remove ineffectual assignments. #689

Merged
merged 1 commit into from
Jul 17, 2017
Merged

blockchain: check errors and remove ineffectual assignments. #689

merged 1 commit into from
Jul 17, 2017

Conversation

dajohi
Copy link
Member

@dajohi dajohi commented May 4, 2017

No description provided.

@@ -1044,7 +1044,6 @@ func Generate() (tests [][]TestInstance, err error) {
// \-> b38(10)
//
// OP_CHECKMULTISIG counts for 20 sigops.
tooManySigOps = repeatOpcode(txscript.OP_CHECKMULTISIG, maxBlockSigOps/20)
Copy link
Member

Choose a reason for hiding this comment

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

is this a bug?

Copy link
Member

Choose a reason for hiding this comment

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

It looks like a merge artifact (yay merges...). Notice how this line is 100% the same as manySigOps above. Either this line can be removed like this, or it can be kept and the line below updated to append to tooManySigOps.

That said, I sort of think I'd prefer the latter since it won't break the test if the manySigOps above is changed in the future.

@@ -250,6 +250,9 @@ func BlockOneCoinbasePaysTokens(tx *dcrutil.Tx,
// There should only be one address.
_, addrs, _, err :=
txscript.ExtractPkScriptAddrs(txout.Version, txout.PkScript, params)
if err != nil {
return err
Copy link
Member

Choose a reason for hiding this comment

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

Probably the wrong error here, see how it returns a rule error below.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed. This should return a ruleError.

@jrick
Copy link
Member

jrick commented May 10, 2017

Since this touches consensus code I want @davecgh and @marcopeereboom to give it a look before merging.

@dajohi dajohi added this to the v1.1.0 milestone May 17, 2017
@@ -1044,7 +1044,6 @@ func Generate() (tests [][]TestInstance, err error) {
// \-> b38(10)
//
// OP_CHECKMULTISIG counts for 20 sigops.
tooManySigOps = repeatOpcode(txscript.OP_CHECKMULTISIG, maxBlockSigOps/20)
Copy link
Member

Choose a reason for hiding this comment

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

It looks like a merge artifact (yay merges...). Notice how this line is 100% the same as manySigOps above. Either this line can be removed like this, or it can be kept and the line below updated to append to tooManySigOps.

That said, I sort of think I'd prefer the latter since it won't break the test if the manySigOps above is changed in the future.

@@ -920,7 +920,6 @@ func deserializeUtxoEntry(serialized []byte) (*UtxoEntry, error) {
stakeExtra := make([]byte, len(serialized[offset:]))
copy(stakeExtra, serialized[offset:])
entry.stakeExtra = stakeExtra
offset += len(serialized[offset:])
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer to leave this. Even though it's technically not used, if any fields are added, removing this would cause the offset to be incorrect if it weren't added back, and it's pretty likely it would be missed.

@@ -1066,7 +1065,6 @@ func Generate() (tests [][]TestInstance, err error) {
// ... -> b39(10)
// \-> b40(11)
//
tooManySigOps = repeatOpcode(txscript.OP_CHECKMULTISIGVERIFY, maxBlockSigOps/20)
Copy link
Member

Choose a reason for hiding this comment

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

Same here as above. I think it would be less error prone to keep this line and change the line below to append to it.

@@ -250,6 +250,9 @@ func BlockOneCoinbasePaysTokens(tx *dcrutil.Tx,
// There should only be one address.
_, addrs, _, err :=
txscript.ExtractPkScriptAddrs(txout.Version, txout.PkScript, params)
if err != nil {
return err
Copy link
Member

Choose a reason for hiding this comment

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

Agreed. This should return a ruleError.

@@ -360,7 +360,6 @@ func TestCalcStakeVersionCorners(t *testing.T) {
bc.bestNode = currentNode

}
height += runCount
Copy link
Member

Choose a reason for hiding this comment

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

Is that right? It seems like it is needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

height is not used after.

@davecgh davecgh merged commit 59db139 into decred:master Jul 17, 2017
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.

5 participants