Remove unused SERIALIZE_METHODS on CFeeRate #22962

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2109-noSerFeeRate changing 5 files +4 −10
  1. MarcoFalke commented at 10:49 am on September 13, 2021: member

    CFeeRate serialization has several issues:

    • It is confusing, because feerates can be in BTC/kvB, sat/vB, … making any serialization ambigious. If there was future code using the serialize method, it would be better off using a serialization method that mentions the unit.
    • It is unused, only used in fuzzing. The useless fuzz test will consume CPU time of the other fuzz targets and make fuzzing less effective overall.

    Fix both by removing the methods.

  2. Remove unused SERIALIZE_METHODS on CFeeRate fa26f9d831
  3. ryanofsky approved
  4. ryanofsky commented at 12:26 pm on September 13, 2021: member

    Code review ACK fa26f9d8319b4d508f85731a35ae17524b0465bc. But I’m not sure I agree with rationale that serialization method is “confusing”. The implementation is:

    0SERIALIZE_METHODS(CFeeRate, obj) { READWRITE(obj.nSatoshisPerK); }
    

    It saves the object to the stream, and it loads the object from the stream. It doesn’t serve as protocol documentation, but that doesn’t matter because the serialization isn’t used in a public protocol or disk format. The serialization is used in #10102, so if you remove it here, I will need to add it back there are or replace it with a different serialization. This isn’t hard, but you can see why these “remove serialization” commits are not my favorite.

    Maybe we can come up with a different strategy if the real goal here is to reduce fuzzing costs. Maybe some serialize methods could be marked internal-only. Maybe internal serialize methods could be fuzzed less heavily? We could disable streaming << >> operators for these and require them to be serialized with SerializeInternal/UnserializeInternal functions if there is concern about things being serialized accidentally.

    I don’t know. I’m not too concerned about this PR, but if there will be more PRs like this one, this would be good to think about.

  5. DrahtBot added the label TX fees and policy on Sep 13, 2021
  6. DrahtBot added the label Utils/log/libs on Sep 13, 2021
  7. MarcoFalke removed the label TX fees and policy on Sep 13, 2021
  8. MarcoFalke removed the label Utils/log/libs on Sep 13, 2021
  9. MarcoFalke added the label Refactoring on Sep 13, 2021
  10. MarcoFalke commented at 1:17 pm on September 13, 2021: member

    I don’t think there will be any/many similar changes. Though, I don’t see how #10102 is an argument against this change. There is also no serialize method for many other classes, like CAmount or WitnessUnknown. #10102 doesn’t solve this by adding the serialize methods, but by defining a capnp struct to use internally. Defining the capnp struct (internally to multiprocess) seems preferable to me than to mark the public serialize method “internal” in some way.

    This isn’t hard, but you can see why these “remove serialization” commits are not my favorite.

    The only other example I could find was #10102 (review), where I mentioned that the serialize method could be kept (if simplified).

    I understand that this may mean more work for you, but I don’t think we should use effort as an excuse to keep stinky code.

  11. ryanofsky commented at 1:50 pm on September 13, 2021: member

    Though, I don’t see how #10102 is an argument against this change.

    I reviewed and acked this PR. I’m definitely not saying #10102 is an argument against this change. All I’m saying is if there will be more PRs like this, it would be good to know what exactly the goal is and make sure #10102 will not get in the way of that goal.

    There is also no serialize method for many other classes, like CAmount or WitnessUnknown. #10102 doesn’t solve this by adding the serialize methods, but by defining a capnp struct to use internally. Defining the capnp struct (internally to multiprocess) seems preferable to me than to mark the public serialize method “internal” in some way.

    This preference is strange to me. These are just two different methods of “internal” serialization. I have been trying to get #10102 reviewed for years now, so my preference is to have less code in #10102 not more code. My preference is to keep existing code instead deleting it, rewriting it, and adding it back again. My preference is to use standard serialization code instead of using new serialization methods.

    This isn’t hard, but you can see why these “remove serialization” commits are not my favorite.

    The only other example I could find was #10102 (comment), where I mentioned that the serialize method could be kept (if simplified).

    Right. And in that case, the existing serialization seemed broken so it did seem better remove. The serialization here seems perfectly simple and not broken, so I’m ask whether this serialization would be better not to remove. I am asking what problem removing serialization solves and whether different solution, like marking it internal and deprioritizing fuzzing that would solve the problem. I don’t know the answer to this question. And again, I don’t think this PR is a big deal. You can ignore these questions unless you think there will be 5 more PRs like this one.

    I understand that this may mean more work for you

    The work for me is trivial and not the issue. The issue is how much more custom serialization code has to be added #10102 making it more work to review. If there is one “remove serialization” PR. I don’t care. If there will be 5 more PR’s, let’s figure out what problem they solve and solve it some way that doesn’t blow up #10102.

    but I don’t think we should use effort as an excuse to keep stinky code.

    I’m literally just adding back the same serialization code in #10102 with less fuzz coverage, so I think I am missing something here.

  12. DrahtBot commented at 8:29 pm on September 13, 2021: member

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #22951 (consensus: move amount.h into consensus by fanquake)

    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.

  13. vincenzopalazzo approved
  14. vincenzopalazzo commented at 10:56 pm on September 13, 2021: none
  15. laanwj commented at 1:52 pm on September 16, 2021: member

    The serialization is used in #10102

    I don’t see the point of doing this if it’s going to be added back later.

  16. ryanofsky commented at 2:03 pm on September 16, 2021: member

    The serialization is used in #10102

    I don’t see the point of doing this if it’s going to be added back later.

    To be fair, adding this back later in #10102 is just the easiest option, not the only option. #10102 requires some kind of serialize/unserialize functions for this class to be written. It could be stream serialization, it could be json serialization, it could be field-by-field capnp struct serialization. Using the standard steam serialization is just nice because it’s one line of code and works out of the box with no need for any CFeeRate code in src/ipc/capnp.

  17. MarcoFalke commented at 2:39 pm on September 16, 2021: member

    I’m literally just adding back the same serialization code in #10102 with less fuzz coverage, so I think I am missing something here.

    I’d say that the CFeeRate fuzz target is improving the fuzz coverage of 10102 at most by epsilon. It would be better to write a proper fuzz target for multiprocess (that ideally also covers serialization).

    Closing for now. Can be reopened after 10102

  18. MarcoFalke closed this on Sep 16, 2021

  19. MarcoFalke deleted the branch on Sep 16, 2021
  20. ryanofsky commented at 12:06 pm on September 17, 2021: member

    I’d say that the CFeeRate fuzz target is improving the fuzz coverage of 10102 at most by epsilon.

    Agree with this. That is why I was suggesting marking serialization internal-only, so you could drop the fuzz target while I could still keep one-line serialization:

    0UNSAFE_INTERNAL_SERIALIZE(CFeeRate, obj) { READWRITE(obj.nSatoshisPerK); }
    

    It would be better to write a proper fuzz target for multiprocess (that ideally also covers serialization).

    It should be pretty easy to add a multiprocess fuzz target I think, depending on what you want it to do. Opened issue #23015 to figure out what would be ideal.

  21. DrahtBot locked this on Oct 30, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-10-30 00:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me