Skip to content

Conversation

theuni
Copy link
Member

@theuni theuni commented Sep 7, 2023

This is also a much simpler replacement for #28327.

There are version fields in CBlockLocator and CDiskBlockIndex that have always been written but discarded when read.

I intended to convert them to use SerParams as introduced by #25284, which ended up looking like this. However because we don't currently have any definition of what a hash value would mean for either one of those, and we've never assigned the version field any meaning, I think it's better to just not worry about them.

If we ever need to assign meaning in the future, we can introduce SerParams as was done for CAddress.

As for the dummy values chosen:

CDiskBlockIndex::DUMMY_VERSION was easy as the highest ever client version, and I don't expect any objection there.

CBlockLocator::DUMMY_VERSION is hard-coded to the higest PROTOCOL version ever used. This is to avoid a sudden bump that would be visible on the network if CLIENT_VERSION were used instead. In the future, if we ever need to use the value, we can discard anything in the CLIENT_VERSION range (for a few years as needed), as it's quite a bit higher.

While reviewing, I suggest looking at the throwaway SerParams commit above as it shows where the call-sites are. I believe that should be enough to convince one's self that hashing is never used.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 7, 2023

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK TheCharlatan, ajtowns
Stale ACK sipa

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #28438 (Use serialization parameters for CTransaction by ajtowns)

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.

@theuni
Copy link
Member Author

theuni commented Sep 7, 2023

Ping @sipa @MarcoFalke

@sipa
Copy link
Member

sipa commented Sep 7, 2023

utACK c1aa0af

1 similar comment
@ajtowns
Copy link
Contributor

ajtowns commented Sep 7, 2023

utACK c1aa0af

Copy link
Contributor

@TheCharlatan TheCharlatan left a comment

Choose a reason for hiding this comment

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

ACK c1aa0af

@theuni
Copy link
Member Author

theuni commented Sep 8, 2023

Resolved formatting nit.

Reviewers can confirm locally that the diff from before amounts only to whitespace:
git diff -w --ignore-blank-lines c1aa0af69eee05a9fad1eabd45662fc2143a3e0c..e73d2a8018def940afadb5d699b18f39e882c1fc

@TheCharlatan
Copy link
Contributor

Re-ACK e73d2a8

@DrahtBot DrahtBot requested review from sipa and ajtowns September 8, 2023 13:52
@ajtowns
Copy link
Contributor

ajtowns commented Sep 9, 2023

reACK e73d2a8

@DrahtBot DrahtBot removed the request for review from ajtowns September 9, 2023 04:07
@fanquake fanquake merged commit 579c49b into bitcoin:master Sep 9, 2023
@@ -167,7 +166,7 @@ class CDBIterator

template<typename V> bool GetValue(V& value) {
try {
CDataStream ssValue{GetValueImpl(), SER_DISK, CLIENT_VERSION};
DataStream ssValue{GetValueImpl()};
Copy link
Contributor

Choose a reason for hiding this comment

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

Just saw that this did replace the CDataStream with a DataStream here in CDBIterator and CDBWrapper, but it is still using a CDataStream for CDBBatch. Should that be replaced too, as I've done here: TheCharlatan@95405b8?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, if it compiles, then it should be fine to replace.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes please, thanks for catching this. IIRC I couldn't do this with my original approach of converting to SerParams, but forgot about it after switching. As @MarcoFalke says, this must be correct if it compiles.

@maflcko
Copy link
Member

maflcko commented Sep 11, 2023

While reviewing, I suggest looking at the throwaway SerParams commit above as it shows where the call-sites are. I believe that should be enough to convince one's self that hashing is never used.

I think it would have been easier to review if SER_GETHASH was removed. It will need to be removed anyway, and it is already unused, so removing it should be correct, if it compiles.

Concept ACK either way

@maflcko
Copy link
Member

maflcko commented Sep 11, 2023

Fixed in #28451, I guess.

Frank-GER pushed a commit to syscoin/syscoin that referenced this pull request Sep 19, 2023
… and CDiskBlockIndex

e73d2a8 refactor: remove clientversion include from dbwrapper.h (Cory Fields)
4240a08 refactor: Use DataStream now that version/type are unused (Cory Fields)
f15f790 Remove version/hashing options from CBlockLocator/CDiskBlockIndex (Cory Fields)

Pull request description:

  This is also a much simpler replacement for bitcoin#28327.

  There are version fields in `CBlockLocator` and `CDiskBlockIndex` that have always been written but discarded when read.

  I intended to convert them to use SerParams as introduced by bitcoin#25284, which [ended up looking like this](theuni@3e3af45). However because we don't currently have any definition of what a hash value would mean for either one of those, and we've never assigned the version field any meaning, I think it's better to just not worry about them.

  If we ever need to assign meaning in the future, we can introduce `SerParams` as was done for `CAddress`.

  As for the dummy values chosen:

  `CDiskBlockIndex::DUMMY_VERSION` was easy as the highest ever client version, and I don't expect any objection there.

  `CBlockLocator::DUMMY_VERSION` is hard-coded to the higest _PROTOCOL_ version ever used. This is to avoid a sudden bump that would be visible on the network if CLIENT_VERSION were used instead. In the future, if we ever need to use the value, we can discard anything in the CLIENT_VERSION range (for a few years as needed), as it's quite a bit higher.

  While reviewing, I suggest looking at the throwaway `SerParams` commit above as it shows where the call-sites are. I believe that should be enough to convince one's self that hashing is never used.

ACKs for top commit:
  TheCharlatan:
    Re-ACK e73d2a8
  ajtowns:
    reACK e73d2a8

Tree-SHA512: 45b0dd7c2e918493e2ee92a8e35320ad17991cb8908cb811150a96c5fd584ce177c775baeeb8675a602c90b9ba9203b8cefc0a2a0c6a71078b1d9c2b41e1f3ba
fanquake added a commit to bitcoin-core/gui that referenced this pull request Oct 2, 2023
…client version in CKeyPool serialize

fac29a0 Remove SER_GETHASH, hard-code client version in CKeyPool serialize (MarcoFalke)
fa72f09 Remove CHashWriter type (MarcoFalke)
fa4a9c0 Remove unused GetType() from OverrideStream, CVectorWriter, SpanReader (MarcoFalke)

Pull request description:

  Removes a bunch of redundant, dead or duplicate code.

  Uses the idea from and finishes the idea bitcoin/bitcoin#28428 by theuni

ACKs for top commit:
  ajtowns:
    ACK fac29a0
  kevkevinpal:
    added one nit but otherwise ACK [fac29a0](bitcoin/bitcoin@fac29a0)

Tree-SHA512: cc805e2f38e73869a6691fdb5da09fa48524506b87fc93f05d32c336ad3033425a2d7608e317decd3141fde3f084403b8de280396c0c39132336fe0f7510af9e
@bitcoin bitcoin locked and limited conversation to collaborators Sep 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: Done or Closed or Rethinking
Development

Successfully merging this pull request may close these issues.

7 participants