Skip to content

chore: move protocol components from miden-lib to miden-objects#2191

Merged
bobbinth merged 64 commits intonextfrom
pgackst-split-protocol-and-standards
Dec 20, 2025
Merged

chore: move protocol components from miden-lib to miden-objects#2191
bobbinth merged 64 commits intonextfrom
pgackst-split-protocol-and-standards

Conversation

@PhilippGackstatter
Copy link
Copy Markdown
Contributor

@PhilippGackstatter PhilippGackstatter commented Dec 17, 2025

Refactors the codebase to separate protocol and standards library code. The idea here is that miden-objects will eventually become miden-protocol and miden-lib will become miden-standards.

Main changes

  • Moved transaction kernel and related components from miden-lib to miden-objects, including kernel procedures, memory layout, advice inputs, and event IDs
  • Extracted standards library into StandardsLib in miden-lib. So, now we have three libraries, TransactionKernel::library, MidenLib and StandardsLib.
  • Split build.rs into two, one in objects and one in lib. A shared module was setup that should be kept in sync; however I could not find an easy way to actually share that code. In particular, using an include! in both build.rs scripts technically works when using cargo but rust-analyzer would always show an error.
  • CodeBuilder was left in miden-lib.
    • Moving it to objects is possible, but it would not be able to contain StandardsLib by default, which seems desirable. We'd need an extension trait in lib for that.
    • Having it in objects would be nice to simplify assembly of some components, but it's easy enough to work around that with TransactionKernel::assembler directly.
  • Updated imports across miden-tx and miden-testing
  • Notably, the AccountInterface is not being moved in this PR. While I think it should eventually live in the protocol crate, I realized it depends too tightly on AccountComponentInterface whose definition consists of references to standard components, and so it doesn't make sense to me to actually move it to objects now. I think we should do this as part of the account (component) interface refactor. Until that time, there's probably no real problem with leaving it in miden-lib.

Review

I tried to keep commits organized as much as possible, and so reviewing by commit should make things a bit easier. Changes in miden-tx and miden-testing are almost all contained in one of the last commits, which consists only of fixing imports.

Open Questions

The CodeBuilder dynamically links StandardsLib. The assumption is that StandardsLib will always be present in the executor and prover host's mast stores. Is this the right choice?

Follow-Up

In a follow-up, I would:

  • Rename objects and lib into protocols and standards.
  • Reorganize MidenLib with the miden namespace into miden::protocol.
  • Reorganize StandardsLib with the miden::contracts namespace into miden::standards.

part of #1563

Fumuran and others added 30 commits December 10, 2025 18:41
@bobbinth
Copy link
Copy Markdown
Contributor

I'm about to start reviewing the PR - so, haven't looked at code in detail yet, but I was imagining this slightly differently:

  1. We'd keep miden-objects largely unchanged.
  2. We'd split miden-lib into miden-protocol and miden-standards

My understanding is that miden-lib in this PR is basically what I was thinking miden-standards would be. And miden-objects and miden-protocol are merged - correct? If so, the main question is whether merging these two simplifies things in some ways (not saying we shouldn't do it, just trying to think through pros and cons).

@PhilippGackstatter
Copy link
Copy Markdown
Contributor Author

My understanding is that miden-lib in this PR is basically what I was thinking miden-standards would be. And miden-objects and miden-protocol are merged - correct?

Yes 👍

  • We'd keep miden-objects largely unchanged.

  • We'd split miden-lib into miden-protocol and miden-standards

I see, I think there was a misunderstanding then. I thought we wanted a single miden-protocol crate that contained all protocol related parts, which includes the types from miden-objects, since these also define part of the protocol.
And miden-objects would later be reintroduced and build on top of miden-protocol to provide pretty much only serialization for the types exposed by it, e.g. tx, block, note, etc.

I think having a single protocol crate like with this PR may allow us to keep protocol-related things more nicely together. For instance, the block building process is currently split in objects and lib, i.e. build_block must be in lib because of the dependency on TransactionKernel. In this PR, this becomes a method on ProposedBlock. I imagine we can come up with a nicer structure for other parts as well, maybe TransactionInputs and others.

I think when we touched objects in the past, we frequently also touched lib which is due to the relatively tight dependency and I don't see a significant downside to merging the two, or a significant upside in keeping them separate.

So I think I slightly prefer the approach in this PR, but would also be fine with trying the split into three crates.

Copy link
Copy Markdown
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you! I left some comments inline - but they are pretty small. I did not review the build.rs files in too much details - so, would be good to get another set of eyes on them.

The CodeBuilder dynamically links StandardsLib. The assumption is that StandardsLib will always be present in the executor and prover host's mast stores. Is this the right choice?

Yes - this will be a guarantee of the network: the standards library will always be available (and in fact, every version of the standards library will be assumed to be available to all network participants).

So I think I slightly prefer the approach in this PR, but would also be fine with trying the split into three crates.

I think it is fine to keep as is. A big part of my original motivation was to reduce the amount of work - but since the work has been done already, not much point in rolling it back.

I do think in the future we'll introduce a different incarnation of miden-objects - this will probably contain basic objects and their serialization/deserialization code, but not much else.

Copy link
Copy Markdown
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

All looks good! Thank you! I left just one small nit inline - but we can easily address it in a follow-up.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I would probably rename this file into protocol_lib.rs to keep the naming consistent with standards_lib.rs.

Base automatically changed from pgackst-protocol-and-standards to next December 20, 2025 08:11
@bobbinth bobbinth merged commit fb0b6e9 into next Dec 20, 2025
18 checks passed
@bobbinth bobbinth deleted the pgackst-split-protocol-and-standards branch December 20, 2025 08:43
afa7789 pushed a commit to afa7789/miden-base that referenced this pull request Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants