Skip to content

Conversation

sipa
Copy link
Member

@sipa sipa commented Jan 5, 2024

Closes #28941.

Our current tests for serfloat verify two distinct properties:

  1. Whether they roundtrip double->uint64_t->double (excluding NaN values) on all systems.
  2. Whether on systems with a typical floating point unit that encoding matches the hardware representation, as before v22.0, we would dump the hardware representation directly to disk and we wanted to retain compatibility with that.

#28941 seems to show that the second property doesn't always hold, but just for "subnormal" numbers (below $2^{-1021}$). Since we don't care about encoding these numbers, we could exclude such subnormal numbers from the hardware-identical representation test, but this PR goes further and just drops the second property entirely, as I don't think we care about edge-case compatibility with pre-v22.0 code for fee_estimates.dat (the only place it is used).

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 5, 2024

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

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK glozow, fanquake

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

@maflcko
Copy link
Member

maflcko commented Jan 5, 2024

I think the fuzz tests are also checking the exact hardware representation? So they should be failing as well, but I guess no one is running them through homebrew (or whatever the affected system is).

@sipa
Copy link
Member Author

sipa commented Jan 5, 2024

@maflcko I don't think they are affected, as the fuzz tests always start from a double (even if one obtained by decoding raw memory) and test roundtripping double->uint64_t->double of that. The issue only seems to appear when starting from raw memory, then encoding + decoding, and comparing with the raw memory started with.

@sipa
Copy link
Member Author

sipa commented Jan 5, 2024

@maflcko I've added a commit to verify that... it adds a hardware-representation equivalence test again, but starting from a double like the fuzz tests do.

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

lgtm

@fanquake
Copy link
Member

fanquake commented Jan 8, 2024

Pushed up the patches into my PR, it has fixed some of the test failures, but not all: https://github.com/Homebrew/homebrew-core/actions/runs/7446626418/job/20257419440?pr=156745#step:4:82.

  ==> /home/linuxbrew/.linuxbrew/Cellar/bitcoin/26.0/bin/test_bitcoin
  Running 585 test cases...
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [1 != 0]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9223372036854775809 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9227078312698333629 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9227541302258710164 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9226320440948298264 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9224296035333843957 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [3342972290171876 != 0]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [455962168228056 != 0]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9226157041067996541 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9225839089286856993 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9225901867614656042 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9227430019473490172 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9224285440633669494 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9224305768567079357 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9223409755742115848 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9224058209782467602 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [2599738216344523 != 0]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9227049248406766111 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9226155215443275398 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [4045757423585278 != 0]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9225916179490235579 != 9223372036854775808]
  test/serfloat_tests.cpp(39): error: in "serfloat_tests/double_serfloat_tests": check repr == i has failed [9227295753411824867 != 9223372036854775808]
  
  *** 22 failures are detected in the test module "Bitcoin Core Test Suite"

If anyone wants to reproduce the failures locally (against master), they can do:

docker pull docker.io/homebrew/brew:latest
docker run -it homebrew/brew

brew install bitcoin --head
brew test bitcoin

==> Testing bitcoin
==> /home/linuxbrew/.linuxbrew/Cellar/bitcoin/HEAD-04b9df0/bin/test_bitcoin
Last 15 lines from /home/linuxbrew/.cache/Homebrew/Logs/bitcoin/test.01.test_bitcoin:
test/serfloat_tests.cpp(96): error: in "serfloat_tests/double_serfloat_tests": check v == v2 has failed [602650259075964 != 0]
test/serfloat_tests.cpp(96): error: in "serfloat_tests/double_serfloat_tests": check v == v2 has failed [9225028085348500152 != 9223372036854775808]
test/serfloat_tests.cpp(96): error: in "serfloat_tests/double_serfloat_tests": check v == v2 has failed [225556757220273 != 0]
test/serfloat_tests.cpp(96): error: in "serfloat_tests/double_serfloat_tests": check v == v2 has failed [808287137814849 != 0]
test/serfloat_tests.cpp(96): error: in "serfloat_tests/double_serfloat_tests": check v == v2 has failed [1601366725718274 != 0]
test/serfloat_tests.cpp(96): error: in "serfloat_tests/double_serfloat_tests": check v == v2 has failed [1803809784509295 != 0]
test/serfloat_tests.cpp(96): error: in "serfloat_tests/double_serfloat_tests": check v == v2 has failed [9224578429555196467 != 9223372036854775808]
test/serfloat_tests.cpp(96): error: in "serfloat_tests/double_serfloat_tests": check v == v2 has failed [2210598722220679 != 0]
test/serfloat_tests.cpp(96): error: in "serfloat_tests/double_serfloat_tests": check v == v2 has failed [869264799447506 != 0]
test/serfloat_tests.cpp(96): error: in "serfloat_tests/double_serfloat_tests": check v == v2 has failed [1193579134805228 != 0]
test/serfloat_tests.cpp(96): error: in "serfloat_tests/double_serfloat_tests": check v == v2 has failed [1018605001172173 != 0]
test/serfloat_tests.cpp(96): error: in "serfloat_tests/double_serfloat_tests": check v == v2 has failed [9226505921543298662 != 9223372036854775808]

*** 219 failures are detected in the test module "Bitcoin Core Test Suite"

@sipa
Copy link
Member Author

sipa commented Jan 8, 2024

@fanquake What if you drop the last commit here?

@fanquake
Copy link
Member

fanquake commented Jan 8, 2024

What if you drop the last commit here?

Tests are passing: https://github.com/Homebrew/homebrew-core/actions/runs/7448770957/job/20264045705?pr=156745.

@sipa sipa force-pushed the 202401_serfloat_weaken_test branch from d5cd5a7 to e520241 Compare January 8, 2024 15:28
@sipa
Copy link
Member Author

sipa commented Jan 8, 2024

Dropped the last commit, and improved the code changes a bit. For backport, if needed, the first commit suffices.

@luke-jr
Copy link
Member

luke-jr commented Jan 23, 2024

Does dropping 2 lose the test that we haven't broken the serialization format somehow? Maybe it should be comparing a fixed mapping of some values at least?

@glozow
Copy link
Member

glozow commented Feb 2, 2024

ACK ea60c95, based on Homebrew/homebrew-core#156745 and #29192 (comment) it looks like this fixes the issue.

re #29192 (comment), the values that were failing the tests are irrelevant in the context we're using this, and 21.0 has been eol for a while now - also see #28941 (comment)

second commit diff looks correct to me though I'm unsure if it's necessary (ACK e520241)

@sipa sipa force-pushed the 202401_serfloat_weaken_test branch from e520241 to 6e873df Compare February 20, 2024 11:35
@sipa
Copy link
Member Author

sipa commented Feb 20, 2024

@luke-jr There were a few expected encoding value tests, but I've expanded them significantly now.

Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

ACK 6e873df

@sipa
Copy link
Member Author

sipa commented Mar 17, 2024

Anything left to do here?

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

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

ACK 6e873df - It's not as much of a priority, but I think we could still backport this.

@fanquake fanquake merged commit 479ecc0 into bitcoin:master Mar 19, 2024
fanquake pushed a commit to fanquake/bitcoin that referenced this pull request Mar 21, 2024
fanquake pushed a commit to fanquake/bitcoin that referenced this pull request Mar 21, 2024
@fanquake
Copy link
Member

Backported to 27.x in #29693.

fanquake added a commit that referenced this pull request Mar 26, 2024
a7116c8 ci: Bump msan to llvm-18 (MarcoFalke)
05f69b3 ci, macos: Use `--break-system-packages` with Homebrew's python (Hennadii Stepanov)
603f036 ci: Add workaround for Homebrew's python link error (Hennadii Stepanov)
5d381cf serfloat: improve/simplify tests (Pieter Wuille)
f4be4d7 serfloat: do not test encode(bits)=bits anymore (Pieter Wuille)

Pull request description:

  Currently:
  * #29192
  * #29610
  * #29676

ACKs for top commit:
  stickies-v:
    ACK a7116c8 - all clean test backports

Tree-SHA512: f3508a2c20d336c8647ba16886859d6a070584c4739fc8b5cfce2041a0662794775fb0ce89c9bf848a29e70089bae05ad1c921bbe45afe3fd5cac2a5c6b76baf
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Oct 25, 2024
6e873df serfloat: improve/simplify tests (Pieter Wuille)
b45f1f5 serfloat: do not test encode(bits)=bits anymore (Pieter Wuille)

Pull request description:

  Closes bitcoin#28941.

  Our current tests for serfloat verify two distinct properties:
  1. Whether they roundtrip `double`->`uint64_t`->`double` (excluding NaN values) on all systems.
  2. Whether on systems with a typical floating point unit that encoding matches the hardware representation, as before v22.0, we would dump the hardware representation directly to disk and we wanted to retain compatibility with that.

  bitcoin#28941 seems to show that the second property doesn't always hold, but just for "subnormal" numbers (below $2^{-1021}$). Since we don't care about encoding these numbers, we could exclude such subnormal numbers from the hardware-identical representation test, but this PR goes further and just drops the second property entirely, as I don't think we care about edge-case compatibility with pre-v22.0 code for fee_estimates.dat (the only place it is used).

ACKs for top commit:
  glozow:
    ACK 6e873df
  fanquake:
    ACK 6e873df - It's not as much of a priority, but I think we could still backport this.

Tree-SHA512: e18ceee0753a7ee7e999fdfa10b014dc5bb67b6ef79522a0f8c76b889adcfa785772fc26ed7559bcb5a09a9938e243bb54eedd9549bc59080a2c8090155e2267
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Oct 26, 2024
6e873df serfloat: improve/simplify tests (Pieter Wuille)
b45f1f5 serfloat: do not test encode(bits)=bits anymore (Pieter Wuille)

Pull request description:

  Closes bitcoin#28941.

  Our current tests for serfloat verify two distinct properties:
  1. Whether they roundtrip `double`->`uint64_t`->`double` (excluding NaN values) on all systems.
  2. Whether on systems with a typical floating point unit that encoding matches the hardware representation, as before v22.0, we would dump the hardware representation directly to disk and we wanted to retain compatibility with that.

  bitcoin#28941 seems to show that the second property doesn't always hold, but just for "subnormal" numbers (below $2^{-1021}$). Since we don't care about encoding these numbers, we could exclude such subnormal numbers from the hardware-identical representation test, but this PR goes further and just drops the second property entirely, as I don't think we care about edge-case compatibility with pre-v22.0 code for fee_estimates.dat (the only place it is used).

ACKs for top commit:
  glozow:
    ACK 6e873df
  fanquake:
    ACK 6e873df - It's not as much of a priority, but I think we could still backport this.

Tree-SHA512: e18ceee0753a7ee7e999fdfa10b014dc5bb67b6ef79522a0f8c76b889adcfa785772fc26ed7559bcb5a09a9938e243bb54eedd9549bc59080a2c8090155e2267
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Oct 28, 2024
6e873df serfloat: improve/simplify tests (Pieter Wuille)
b45f1f5 serfloat: do not test encode(bits)=bits anymore (Pieter Wuille)

Pull request description:

  Closes bitcoin#28941.

  Our current tests for serfloat verify two distinct properties:
  1. Whether they roundtrip `double`->`uint64_t`->`double` (excluding NaN values) on all systems.
  2. Whether on systems with a typical floating point unit that encoding matches the hardware representation, as before v22.0, we would dump the hardware representation directly to disk and we wanted to retain compatibility with that.

  bitcoin#28941 seems to show that the second property doesn't always hold, but just for "subnormal" numbers (below $2^{-1021}$). Since we don't care about encoding these numbers, we could exclude such subnormal numbers from the hardware-identical representation test, but this PR goes further and just drops the second property entirely, as I don't think we care about edge-case compatibility with pre-v22.0 code for fee_estimates.dat (the only place it is used).

ACKs for top commit:
  glozow:
    ACK 6e873df
  fanquake:
    ACK 6e873df - It's not as much of a priority, but I think we could still backport this.

Tree-SHA512: e18ceee0753a7ee7e999fdfa10b014dc5bb67b6ef79522a0f8c76b889adcfa785772fc26ed7559bcb5a09a9938e243bb54eedd9549bc59080a2c8090155e2267
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Oct 28, 2024
6e873df serfloat: improve/simplify tests (Pieter Wuille)
b45f1f5 serfloat: do not test encode(bits)=bits anymore (Pieter Wuille)

Pull request description:

  Closes bitcoin#28941.

  Our current tests for serfloat verify two distinct properties:
  1. Whether they roundtrip `double`->`uint64_t`->`double` (excluding NaN values) on all systems.
  2. Whether on systems with a typical floating point unit that encoding matches the hardware representation, as before v22.0, we would dump the hardware representation directly to disk and we wanted to retain compatibility with that.

  bitcoin#28941 seems to show that the second property doesn't always hold, but just for "subnormal" numbers (below $2^{-1021}$). Since we don't care about encoding these numbers, we could exclude such subnormal numbers from the hardware-identical representation test, but this PR goes further and just drops the second property entirely, as I don't think we care about edge-case compatibility with pre-v22.0 code for fee_estimates.dat (the only place it is used).

ACKs for top commit:
  glozow:
    ACK 6e873df
  fanquake:
    ACK 6e873df - It's not as much of a priority, but I think we could still backport this.

Tree-SHA512: e18ceee0753a7ee7e999fdfa10b014dc5bb67b6ef79522a0f8c76b889adcfa785772fc26ed7559bcb5a09a9938e243bb54eedd9549bc59080a2c8090155e2267
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Oct 28, 2024
6e873df serfloat: improve/simplify tests (Pieter Wuille)
b45f1f5 serfloat: do not test encode(bits)=bits anymore (Pieter Wuille)

Pull request description:

  Closes bitcoin#28941.

  Our current tests for serfloat verify two distinct properties:
  1. Whether they roundtrip `double`->`uint64_t`->`double` (excluding NaN values) on all systems.
  2. Whether on systems with a typical floating point unit that encoding matches the hardware representation, as before v22.0, we would dump the hardware representation directly to disk and we wanted to retain compatibility with that.

  bitcoin#28941 seems to show that the second property doesn't always hold, but just for "subnormal" numbers (below $2^{-1021}$). Since we don't care about encoding these numbers, we could exclude such subnormal numbers from the hardware-identical representation test, but this PR goes further and just drops the second property entirely, as I don't think we care about edge-case compatibility with pre-v22.0 code for fee_estimates.dat (the only place it is used).

ACKs for top commit:
  glozow:
    ACK 6e873df
  fanquake:
    ACK 6e873df - It's not as much of a priority, but I think we could still backport this.

Tree-SHA512: e18ceee0753a7ee7e999fdfa10b014dc5bb67b6ef79522a0f8c76b889adcfa785772fc26ed7559bcb5a09a9938e243bb54eedd9549bc59080a2c8090155e2267
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Oct 29, 2024
6e873df serfloat: improve/simplify tests (Pieter Wuille)
b45f1f5 serfloat: do not test encode(bits)=bits anymore (Pieter Wuille)

Pull request description:

  Closes bitcoin#28941.

  Our current tests for serfloat verify two distinct properties:
  1. Whether they roundtrip `double`->`uint64_t`->`double` (excluding NaN values) on all systems.
  2. Whether on systems with a typical floating point unit that encoding matches the hardware representation, as before v22.0, we would dump the hardware representation directly to disk and we wanted to retain compatibility with that.

  bitcoin#28941 seems to show that the second property doesn't always hold, but just for "subnormal" numbers (below $2^{-1021}$). Since we don't care about encoding these numbers, we could exclude such subnormal numbers from the hardware-identical representation test, but this PR goes further and just drops the second property entirely, as I don't think we care about edge-case compatibility with pre-v22.0 code for fee_estimates.dat (the only place it is used).

ACKs for top commit:
  glozow:
    ACK 6e873df
  fanquake:
    ACK 6e873df - It's not as much of a priority, but I think we could still backport this.

Tree-SHA512: e18ceee0753a7ee7e999fdfa10b014dc5bb67b6ef79522a0f8c76b889adcfa785772fc26ed7559bcb5a09a9938e243bb54eedd9549bc59080a2c8090155e2267
PastaPastaPasta added a commit to dashpay/dash that referenced this pull request Oct 29, 2024
fbc0bce Merge bitcoin#29665: build, depends: Fix `libmultiprocess` cross-compilation (fanquake)
59a2145 Merge bitcoin#29747: depends: fix mingw-w64 Qt DEBUG=1 build (fanquake)
bdb2fa6 Merge bitcoin#29671: index: avoid "failed to commit" errors on initialization (Ava Chow)
65377ea Merge bitcoin#29192: Weaken serfloat tests (fanquake)
4122404 Merge bitcoin#28891: test: fix `AddNode` unit test failure on OpenBSD (fanquake)
812ef53 Merge bitcoin#25677: refactor: make active_chain_tip a reference (MacroFake)
34e12fa Merge bitcoin#24564: doc: Clarify that CheckSequenceLocksAtTip is a validation function (glozow)
d529751 Merge bitcoin#24788: doc: Add gpg key import instructions for Windows (fanquake)
61bae78 Merge bitcoin#24784: refactor: deduplicate integer serialization in RollingBloom benchmark (MarcoFalke)

Pull request description:

  ## Issue being fixed or feature implemented
  Trivial backports

  ## What was done?

  ## How Has This Been Tested?
  built locally

  ## Breaking Changes

  ## Checklist:
    _Go over all the following points, and put an `x` in all the boxes that apply._
  - [ ] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    utACK fbc0bce

Tree-SHA512: 731f70b747712810d4f74fe64a90139b02ddb62e9ac260705fa2588595feb19bd6e5ffed521fd878bacaab0015683e582fed19ed1855c3e955f93cd223862a17
@bitcoin bitcoin locked and limited conversation to collaborators Mar 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

brew: serfloat_tests tests fail on Linux
6 participants