mpgen: Allow wrapped interfaces to inherit from unwrapped interfaces #377

pull ryanofsky wants to merge 1 commits into bitcoin-core:master from ryanofsky:pr/methodkey changing 8 files +69 −24
  1. ryanofsky commented at 1:45 AM on October 15, 2026: collaborator

    Problem: Currently, interface inheritance in libmultiprocess only works if capnproto base and derived interfaces both use $Proxy.wrap annotations and have C++ base and derived classes implementing methods of both interfaces. It is currently not possible to have derived capnproto interface that uses $Proxy.wrap inherit from a base interface that is unwrapped. This is needed for the stable/unstable Chain interface split proposed in bitcoin/bitcoin#34981. This limitation exists because ProxyMethod template class which is responsible for mapping capnproto method types to c++ method pointers currently assumes that that every capnproto method will be implemented by the wrapped base interface, and doesn't allow them to be implemented be derived classes.

    Solution: Pass an interface type template parameter to ProxyMethod and to the ProxyMethodTraits, ProxyClientMethodTraits and ProxyServerMethodTraits traits classes, and have mpgen generate ProxyMethod specializations for every method an interface handles, including inherited ones. Small change to proxy.h, proxy-types.h and gen.cpp, plus a test of an interface inheriting from a base interface with no C++ class.

    This is a potentially breaking change for code that specializes ProxyClientMethodTraits or ProxyServerMethodTraits, which now takes the interface type as its first template argument. But Bitcoin Core master does not have any of these specializations currently, so it needs no changes. Generated code is otherwise equivalent and there are no wire protocol changes.

  2. mpgen: Key ProxyMethod and method traits by interface type
    Add an Interface template parameter to ProxyMethod, ProxyMethodTraits,
    ProxyClientMethodTraits and ProxyServerMethodTraits, and generate ProxyMethod
    specializations for inherited methods as well as each interface's own methods.
    
    This lets a wrapped capnp interface inherit methods from a base interface
    that is wrapped by a different C++ class, or not wrapped at all. Previously
    the mapping from an inherited method to a C++ method came from the base
    interface's generated ProxyMethod<Params> specialization, so it only worked
    when the base interface was wrapped by a C++ base class of the derived
    interface's class. Each method could only have one mapping, so two wrapped
    interfaces inheriting from the same unwrapped base could not each supply one.
    
    Bitcoin Core needs this to split its Chain interface into stable Chain and
    UnstableChain capnp interfaces wrapping the same interfaces::Chain class
    (bitcoin/bitcoin#34981).
    
    This is a breaking change for code specializing ProxyClientMethodTraits or
    ProxyServerMethodTraits, which now takes the interface type as its first
    template argument.
    
    This change was written with Claude Opus 5.5 (1M context).
    08f72b0a2b
  3. DrahtBot commented at 1:45 AM on October 15, 2026: none

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #342 (Allow request cancellation for wrapped C++ methods by xyzconstant)

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/libmultiprocess. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-10-28 08:30 UTC

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