feat(runtime): Runtime preset bundling components and add-ons#194
Open
mfw78 wants to merge 1 commit into
Open
Conversation
Add a Runtime preset trait that names a lattice, its component builders, and its add-on set as one bundle, plus the domain-free CoreRuntime default preset. RuntimeBuilder::runtime binds a preset so an embedder launches with RuntimeBuilder::new(cfg).runtime::<Preset>().launch(). Update the embed example to use the preset.
fdd03a5 to
f7c4c52
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #93.
Adds a
Runtimepreset trait tonexum-runtimethat bundles a component set and an add-on list behind a single type, plus aRuntimeBuilder::runtime::<R>()shortcut that consumes a preset directly, so an embedder with no domain extensions can go from configuration to a running node in one call.This is part of the epic #79 train and merges in stack order.
Changes
crates/nexum-runtime/src/preset.rsis new and defines theRuntimetrait: an associatedTypeslattice, three associated component-builder types bounded byComponentBuilder<Output = Types::Chain/Store/Ext>, andcomponents()/add_ons()associated functions returning aComponentsBuilderand anAddOnslist. The same file definesCoreRuntime, the domain-free default preset (Chain = ProviderPool,Store = LocalStore,Ext = ()), which bundlesPrometheusAddOnas its default add-on.crates/nexum-runtime/src/builder.rsgainsRuntimeBuilder::runtime::<R>(), a new terminal stage (PresetBuilder) reached directly from the initial builder. It exposeswith_extensions,with_module_source, andlaunch.launchbuilds the preset'sComponents, keeps the preset's ownedVec<Box<dyn RuntimeAddOns>>alive alongside a borrowed&dyn RuntimeAddOnsview across the launch await, and hands both into the existingAssembledRuntime/LaunchRuntime::launchpath unchanged.crates/nexum-runtime/src/addons.rsaddspub type AddOns = Vec<Box<dyn RuntimeAddOns>>, the return type the issue names foradd_ons().crates/nexum-runtime/src/lib.rsregisters the newpresetmodule.crates/nexum-runtime/examples/embed.rsis rewritten to the one-lineRuntimeBuilder::new(&cfg).runtime::<CoreRuntime>().launch().await?.wait().await. The prior example'scomponents.logsread-back demo is kept as a module-doc note rather than dropped, since that path only makes sense against the explicit component builder, not a preset.Test plan
cargo fmt --all --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspace --all-features(all suites pass, including the wasm-backedcow_bootsupervisor end-to-end fixture, built rather than skipped)embed.rsexample compiles and matches the one-liner in this descriptionNotes for reviewer
components()andadd_ons()are associated functions with noself, since presets are zero-sized markers;runtime::<CoreRuntime>()needs no value to construct. The three associated builder types (rather than a single opaque return) exist becauseComponentsBuilder<C, S, E>is generic over the concrete builder types, and theOutput = Types::Chain/Store/Extbounds are exactly whatComponentsBuilder::buildneeds, so no extra where-clauses leak to callers of the trait.The default preset is named
CoreRuntime, not the issue text's staleEthRuntime, to match the tree's existing domain-freeCoreTypesnaming and stay honest that this preset carries no chain-specific behaviour.Two items from the issue are deliberately left out of scope. The CLI (
nexum-cli) is not converted to a preset here: it needs the cowExtensionlinker hook, which theRuntimetrait (components plus add-ons only) does not carry, and wiring that in is a separate decision about whether presets should also provide extensions. Shipping a cow-specificReferenceRuntimepreset inshepherd-cow-hostis the natural follow-up once that question is settled; the issue only suggested it as a possible example, not a requirement.AI Assistance: Claude Code (Opus 4.8 implementation and adversarial review, Sonnet 5 PR authoring) used for the full change.