Skip to content

Conversation

sipa
Copy link
Member

@sipa sipa commented Dec 2, 2021

Originally written for #21590 (safegcd-based MuHash inverses), but then found a better way that removed the need for it, so I'm submitting it independently.

@sipa
Copy link
Member Author

sipa commented Dec 2, 2021

I'm happy to let #23438 (std::byte Serialize) go first and rebase this on top.

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.

ACK 06a1adf 💽

Show signature

Signature:

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

ACK 06a1adf88d51e2771802c6c0f646e3ff16a4baa7 💽
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUibXQwAg72RLZWg263rc7eMLWvExHZ+JJj91IV1IcqQqOd+BlGWIhtwih2/wy5J
+fjp98EEgwYPy18TivkjGddaQqL+HCou9PWJNyUV0GPqgd2HDT+KNU9e1T6IDZsS
9+Ug+m/wsiY8tNLDOnZ6vJK+xFzu2oGQnNLOFxG4VFwh7fR20qvSitLU8Uhaz7et
+9KBO2XAtHUAeYusDeTc6ZZHPErw/Pvd6p/qt3cBPtGSRMjNCSCUSGaDzXar415L
AswOh/7NxXs3gETjlGkGIITAZSxHbdGVbiHYA7VTKn69OoYezlOxcgd2RTx+nLEv
DkjguFkA6oacFVCOhRZGqblUMnxfDm5r7SG9nG1bHpt5XaUJ5354EIS2M1moca48
gRku2NfErtayNR0xh3ZnkkyzrSvNKVlA3f9SehpuXjwUK7YY0Rd0ynxBcIx/Ii5D
rp2dhsT+uAH/9lRWVBzmUUqfOwfwpRxAQLhx50JcCap0fpRx6bLrakhMxhbf2XWv
hJQfoMcI
=k3Yq
-----END PGP SIGNATURE-----

@sipa sipa force-pushed the 202112_spanreader branch from 06a1adf to 2c35a93 Compare December 2, 2021 19:47
Copy link
Member Author

@sipa sipa left a comment

Choose a reason for hiding this comment

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

Addressed @MarcoFalke's comments.

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 3, 2021

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #23438 (refactor: Use spans of std::byte in serialize by MarcoFalke)

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

@shaavan shaavan left a comment

Choose a reason for hiding this comment

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

ACK 2c35a93

@maflcko
Copy link
Member

maflcko commented Dec 3, 2021

re-ACK 2c35a93 🖨

Show signature

Signature:

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

re-ACK 2c35a93b3cc19dc71d5664f9f61c24a04f419e35 🖨
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUgcPgv+KnKiX/J5RN0CHNr/DpP/v+1fhK27eioJvsEcH9DXAdY0Y/mntZ0mMOSZ
rYAqSHTmDn9uFwwEu9QCffS5VRiyPdi3tb6X/v34uEiAQhOwVPA3o/b0D6fF3t17
AkEIM2uSX03yj1PSbpeeTkR8clP2B3Tc5SVcg+fCduDSeQCjAcBP94bIzqQBI18M
47GpVMBG6ZWLE3yvf/z0mdJq4/wmTRLUonpCQtHFHhtaTHm3FxxmsN7QOX9LwHEi
oLMGM7qM/Ag09i+AC9mhuSBBi/tlyKGgtKNpmZITqZyT7Kc+bWodCcufbYhxOFl7
ylFE58QIyPpUbbLTxybu+2anvL/m9ABnXDxxqbiNG0DvqEhtSjZRzcq0nPsIYlMH
860ewOu0SU4XsMjMJzptEyfz/E5VQQbmIgGGMTg6iBezFuliYruQl09SsxcHJeFx
eROywgR4zpvLtt0yONmyAU9tfq/2zbjlRJe7IeyMlXP8jOneqavZj7sa0zKJmk5c
Tvx9RDcp
=JgBF
-----END PGP SIGNATURE-----

@maflcko maflcko merged commit fd1c9e2 into bitcoin:master Dec 3, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 3, 2021
2c35a93 Generalize/simplify VectorReader into SpanReader (Pieter Wuille)

Pull request description:

  Originally written for bitcoin#21590 (safegcd-based MuHash inverses), but then found a better way that removed the need for it, so I'm submitting it independently.

ACKs for top commit:
  MarcoFalke:
    re-ACK 2c35a93 🖨
  shaavan:
    ACK 2c35a93

Tree-SHA512: 959e3251e0cfe20e13a50639b617c9dc2a561d613a0884d983c93d15dacb6d2305d760aa933d18ba055cef8a1651a344bcb6b3f93051ecf26d3f2efc5779efa4
}
data = data.subspan(pos);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be

Suggested change
data = data.subspan(pos);
m_data = m_data.subspan(pos);

Copy link
Member Author

Choose a reason for hiding this comment

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

Ugh, yes! Will create a PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, it looks like all call sites use pos=0, which makes this harmless. With spans, having a separate pos is also pointless as it can be easily done by the caller using subspan. I'm just going to drop it.

Copy link
Member

@achow101 achow101 Dec 6, 2021

Choose a reason for hiding this comment

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

I need it for PSBT things (which is how I found this bug). It would also be nice to have a test for other pos too.

Copy link
Member Author

Choose a reason for hiding this comment

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

maflcko pushed a commit to bitcoin-core/gui that referenced this pull request Dec 7, 2021
… in SpanReader

31ba1af Remove unused (and broken) functionality in SpanReader (Pieter Wuille)

Pull request description:

  This removes the ability to set an offset in the `SpanReader::SpanReader` constructor, as the current code is broken since #23653. All call sites use `pos=0`, so it is actually unused. If future call sites need it, `SpanReader{a, b, c, d}` is equivalent to `SpanReader{a, b, c.subspan(d)}`.

  It also removes the ability to deserialize from `SpanReader` directly from the constructor. This too is unused, and can be more idiomatically simulated using `(SpanReader{a, b, c} >> x >> y >> z)` instead of `SpanReader{a, b, c, x, y, z}`.

  This was pointed out by achow101 in bitcoin/bitcoin#23653 (comment).

ACKs for top commit:
  jb55:
    crACK 31ba1af
  achow101:
    ACK 31ba1af

Tree-SHA512: 700ebcd74147628488c39168dbf3a00f8ed41709a26711695f4bf036250a9b115574923bbf96040ec7b7fee4132d6dbbcb5c6e5a2977c4beb521dc1500e6ed53
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 7, 2021
…Reader

31ba1af Remove unused (and broken) functionality in SpanReader (Pieter Wuille)

Pull request description:

  This removes the ability to set an offset in the `SpanReader::SpanReader` constructor, as the current code is broken since bitcoin#23653. All call sites use `pos=0`, so it is actually unused. If future call sites need it, `SpanReader{a, b, c, d}` is equivalent to `SpanReader{a, b, c.subspan(d)}`.

  It also removes the ability to deserialize from `SpanReader` directly from the constructor. This too is unused, and can be more idiomatically simulated using `(SpanReader{a, b, c} >> x >> y >> z)` instead of `SpanReader{a, b, c, x, y, z}`.

  This was pointed out by achow101 in bitcoin#23653 (comment).

ACKs for top commit:
  jb55:
    crACK 31ba1af
  achow101:
    ACK 31ba1af

Tree-SHA512: 700ebcd74147628488c39168dbf3a00f8ed41709a26711695f4bf036250a9b115574923bbf96040ec7b7fee4132d6dbbcb5c6e5a2977c4beb521dc1500e6ed53
Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

Post-merge ACK 2c35a93

RandyMcMillan pushed a commit to RandyMcMillan/mempool-tab that referenced this pull request Dec 23, 2021
…anReader

c6d9984 Generalize/simplify VectorReader into SpanReader (Pieter Wuille)

Pull request description:

  Originally written for #21590 (safegcd-based MuHash inverses), but then found a better way that removed the need for it, so I'm submitting it independently.

ACKs for top commit:
  MarcoFalke:
    re-ACK c6d9984 🖨
  shaavan:
    ACK c6d9984

Tree-SHA512: 959e3251e0cfe20e13a50639b617c9dc2a561d613a0884d983c93d15dacb6d2305d760aa933d18ba055cef8a1651a344bcb6b3f93051ecf26d3f2efc5779efa4
RandyMcMillan pushed a commit to RandyMcMillan/mempool-tab that referenced this pull request Dec 23, 2021
… in SpanReader

9f98adf Remove unused (and broken) functionality in SpanReader (Pieter Wuille)

Pull request description:

  This removes the ability to set an offset in the `SpanReader::SpanReader` constructor, as the current code is broken since #23653. All call sites use `pos=0`, so it is actually unused. If future call sites need it, `SpanReader{a, b, c, d}` is equivalent to `SpanReader{a, b, c.subspan(d)}`.

  It also removes the ability to deserialize from `SpanReader` directly from the constructor. This too is unused, and can be more idiomatically simulated using `(SpanReader{a, b, c} >> x >> y >> z)` instead of `SpanReader{a, b, c, x, y, z}`.

  This was pointed out by achow101 in bitcoin/bitcoin#23653 (comment).

ACKs for top commit:
  jb55:
    crACK 9f98adf
  achow101:
    ACK 9f98adf

Tree-SHA512: 700ebcd74147628488c39168dbf3a00f8ed41709a26711695f4bf036250a9b115574923bbf96040ec7b7fee4132d6dbbcb5c6e5a2977c4beb521dc1500e6ed53
@bitcoin bitcoin locked and limited conversation to collaborators Dec 7, 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.

7 participants