Skip to content

Conversation

@jkczyz
Copy link
Contributor

@jkczyz jkczyz commented Nov 7, 2019

This removes boilerplate code in the subclasses which otherwise only
differ by the result type.

The subclassing was introduced in a27a295.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK aa67e6d736fab1cf125687f3393a3eb259fb8608.

Medium concept ACK. Nice that this eliminates duplicate code. Added #includes and template function might slow down compilation a bit, though.

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 7, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Concept ACK.

@laanwj
Copy link
Member

laanwj commented Nov 8, 2019

Concept ACK.

Added #includes and template function might slow down compilation a bit, though.

Yes, although this is a quite straightforward use of templates, no boost nested template horrors, so I hope it's not too bad.

Copy link
Contributor

@ajtowns ajtowns left a comment

Choose a reason for hiding this comment

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

Concept ACK

@jnewbery
Copy link
Contributor

jnewbery commented Nov 8, 2019

Concept ACK. Will review code once @ajtowns's comments are addressed.

@jkczyz jkczyz force-pushed the 2019-11-validation-state branch 2 times, most recently from 376e209 to 3f2e048 Compare November 8, 2019 21:22
Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Nice suggestions from @ajtowns!

@jkczyz jkczyz force-pushed the 2019-11-validation-state branch from 3f2e048 to 0468628 Compare November 8, 2019 22:04
@practicalswift
Copy link
Contributor

Concept ACK: new code is easier to reason about

Copy link
Contributor

@jnewbery jnewbery left a comment

Choose a reason for hiding this comment

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

Tested ACK 0468628e8191c574d2568f5e9e7fa15dd43d80f2. Nice tidy up!

One suggestion for getting rid of a now almost-empty file. Can be done in this PR or a follow-up.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Code review ACK 0468628e8191c574d2568f5e9e7fa15dd43d80f2.

Restarted failed job on travis.

@jkczyz jkczyz force-pushed the 2019-11-validation-state branch from 0468628 to 2948ebd Compare November 11, 2019 23:22
@jnewbery
Copy link
Contributor

utACK 2948ebd

@jkczyz
Copy link
Contributor Author

jkczyz commented Nov 30, 2019

Rebased and updated to account for #17624 in 1452949.

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

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

Code review ACK 1452949.

About the increase compilation time concern, on my system compare to master it's even a bit slightly slightly faster.

@maflcko
Copy link
Member

maflcko commented Dec 20, 2019

ACK 14529499743e071ddc091e5508e1eea4532e754d 🎏

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

ACK 14529499743e071ddc091e5508e1eea4532e754d 🎏
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUgCpgv/XrM9w3dqV6IqX53LVCU81lx6hex2Gjbb8X0wb2rfaBxS1H/y+DHq9cPs
iBh6bp5HGABL2dRPcS3mvyBzA9lbWu4MZVzqu728m9m2tUdMjnezxzz0tZOhmcWL
vW8+UpYVnr4UahR9k5X2N06v7YoqkpNmQ06aSOkRCNd7XPkjOAh3SN5zOSUjs1n8
2wUOPPNAbBS5UgFt6vTPTzm6AMNWp+fXtqnSIe84JFkefEoFo0EW1f72Nyb1agrG
70Cxd+Ph4de0yZq+lvcrZz62JPOGwF8AWW8ls+82hOFMmmxI1eduQPo9xuEvv14b
euvSNwjmUenZBhldWXAR0ct13O3NNgSzdbWZjBomqtDFDa5MpcOGHeCppYmxykD7
7FX/+Ye7Q181D7vXBFj/YBEGqPyIuLIm0NV1N6EPl8gYiqaK0c7UF0TJPqwWE6k1
HjhDdT4cD9rZrcl9u6mt2zdjcavNuyfMO13seNINZVXuNkgleta/sCh2edQU41XL
I09hdKhh
=2AEE
-----END PGP SIGNATURE-----

Timestamp of file with hash 70e15c1a24082f6b136c95c7920ed1bc271fccb39fdfee1f98976554082edd59 -

@jnewbery
Copy link
Contributor

utACK 14529499743e071ddc091e5508e1eea4532e754d

Since the initialization relies on [TX|BLOCK]_RESULT_UNSET being 0, what do you think of:

--- a/src/consensus/validation.h
+++ b/src/consensus/validation.h
@@ -16,7 +16,7 @@
   * provider of the transaction should be banned/ignored/disconnected/etc.
   */
 enum class TxValidationResult {
-    TX_RESULT_UNSET,         //!< initial value. Tx has not yet been rejected
+    TX_RESULT_UNSET = 0,     //!< initial value. Tx has not yet been rejected. Must be zero/first defined enumerator for default initialization.
     TX_CONSENSUS,            //!< invalid by consensus rules
     /**
      * Invalid by a change to consensus rules more recent than SegWit.
@@ -50,7 +50,7 @@ enum class TxValidationResult {
   * useful for some other use-cases.
   */
 enum class BlockValidationResult {
-    BLOCK_RESULT_UNSET,      //!< initial value. Block has not yet been rejected
+    BLOCK_RESULT_UNSET = 0,  //!< initial value. Block has not yet been rejected. Must be zero/first defined enumerator for default initialization.
     BLOCK_CONSENSUS,         //!< invalid by consensus rules (excluding any below reasons)
     /**
      * Invalid by a change to consensus rules more recent than SegWit.

@jkczyz jkczyz force-pushed the 2019-11-validation-state branch from 1452949 to a975974 Compare December 22, 2019 03:41
@jkczyz jkczyz force-pushed the 2019-11-validation-state branch 2 times, most recently from cb77316 to bf5bc26 Compare January 9, 2020 22:09
@jkczyz
Copy link
Contributor Author

jkczyz commented Jan 9, 2020

Rebased to account for changes in #16688. Specifically, pushed 7bb194ba252191b531803ad2952c984c70d192da to:

  • Account for changes to FormatStateMessage made in 72f3227 and 6edebac
  • Update use of FormatStateMessage in f9abf4a

Can be verified with:

git range-diff 17e14ac..2afff87 e7f8450..bf5bc26

@jnewbery
Copy link
Contributor

code review ACK bf5bc260e914e2413bed4041e5089fdee03a344a

@maflcko
Copy link
Member

maflcko commented Feb 28, 2020

ACK 10efc04 🐱

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

ACK 10efc0487c442bccb0e4a9ac29452af1592a3cf2 🐱
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUiSBQv9GTJ4FVCrg3wq2XM0X75nYvO3+OK32UmnzgXDJjk7Pghohc7v7mUhqpnc
hmwCVwvvs9r5PdRx2BYx/GgPi6UEQ0KSjZfDxKUYcA7lMYCcHlHUxoohNj0mssN+
hpuGhzhBEYyX1jHNFazpSMSlKVPvesXQRHgo4Kw4EyyI1EU1Mpdi/nPWpsY6Of0y
Gg49gHJVvMp08RmkTVLRBWF0KqUATRfUTgqVUr5bit3tKZZPacxaiXSE8W8WXRa5
Nb6e1WHAa8+jWqlahlCFJnw4UoyXSIHtijhBgVliCo7wX5Lj588VjouQeaXEIufZ
q823LmNj8QdOwnNnE9wMSKYX/kQaGB+R3KRDpH+s6zHub86fA0/oz3dkER4XWaIM
DZNcYPnJYNgWtZ9f99uIC87pHeQ3kFA+5/xroVzjPvFEGLv7euwlgZn0v2rb2dB5
vgmIwvEH/B8/pH3GvL65yGCVFrkVA5rAnNGViav0KJujkWXukc0fkC9to5urHnwB
oz7K+tzI
=g9Fg
-----END PGP SIGNATURE-----

Timestamp of file with hash 02d3cb1c7845b1a605977e2f801af0118c57df49376b61c77970f1807528dacf -

@practicalswift
Copy link
Contributor

ACK 10e85d4 -- patch looks correct

@ajtowns
Copy link
Contributor

ajtowns commented Mar 1, 2020

ACK 10efc04 -- looks good to me

@jonatack
Copy link
Member

jonatack commented Mar 1, 2020

ACK 10efc04 code review, build/tests green, nice cleanup

@maflcko maflcko merged commit 54a7ef6 into bitcoin:master Mar 1, 2020
@practicalswift
Copy link
Contributor

post-merge ACK 10efc04

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Mar 2, 2020
…f subclassing

10efc04 Templatize ValidationState instead of subclassing (Jeffrey Czyz)
10e85d4 Remove ValidationState's constructor (Jeffrey Czyz)
0aed17e Refactor FormatStateMessage into ValidationState (Jeffrey Czyz)

Pull request description:

  This removes boilerplate code in the subclasses which otherwise only
  differ by the result type.

  The subclassing was introduced in a27a295.

ACKs for top commit:
  MarcoFalke:
    ACK 10efc04 🐱
  ajtowns:
    ACK 10efc04 -- looks good to me
  jonatack:
    ACK 10efc04 code review, build/tests green, nice cleanup

Tree-SHA512: 765dd52dde7d49b9a5c6d99d97c96f4492673e2aed0b0604faa88db0308fa4500a26bf755cca0b896be283874096c215932e1110a2d01dc012cd36a5fce58a42
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 9, 2020
Summary:
Partial backport 1/3 of core [[bitcoin/bitcoin#17399 | PR17399]]:
bitcoin/bitcoin@0aed17e

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D8326
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 9, 2020
Summary:
Partial backport 2/3 of core [[bitcoin/bitcoin#17399 | PR17399]]:
bitcoin/bitcoin@10e85d4

Depends on D8326.

Test Plan:
  ninja all check

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D8327
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 9, 2020
Summary:
```
This removes boilerplate code in the subclasses which otherwise only
differ by the result type.
```

Completes backport 3/3 of core [[bitcoin/bitcoin#17399 | PR17399]]:
bitcoin/bitcoin@10efc04

Depends on D8327.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Subscribers: majcosta

Differential Revision: https://reviews.bitcoinabc.org/D8328
sidhujag pushed a commit to syscoin-core/syscoin that referenced this pull request Nov 10, 2020
…f subclassing

10efc04 Templatize ValidationState instead of subclassing (Jeffrey Czyz)
10e85d4 Remove ValidationState's constructor (Jeffrey Czyz)
0aed17e Refactor FormatStateMessage into ValidationState (Jeffrey Czyz)

Pull request description:

  This removes boilerplate code in the subclasses which otherwise only
  differ by the result type.

  The subclassing was introduced in a27a295.

ACKs for top commit:
  MarcoFalke:
    ACK 10efc04 🐱
  ajtowns:
    ACK 10efc04 -- looks good to me
  jonatack:
    ACK 10efc04 code review, build/tests green, nice cleanup

Tree-SHA512: 765dd52dde7d49b9a5c6d99d97c96f4492673e2aed0b0604faa88db0308fa4500a26bf755cca0b896be283874096c215932e1110a2d01dc012cd36a5fce58a42
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.