Skip to content

feat(rt-next): make instantiate public - #188

Merged
rvolosatovs merged 1 commit into
LFDT-Nightstream:mainfrom
rvolosatovs:feat/rt-instance
Aug 4, 2026
Merged

rvolosatovs merged 1 commit into
LFDT-Nightstream:mainfrom
rvolosatovs:feat/rt-instance

Conversation

@rvolosatovs

Copy link
Copy Markdown
Contributor

Make Contract::instantiate public and have it return a new repr(transparent) ContractInstance wrapper around the wasmtime Instance. Move create_utxo, load_utxo and
call_coordination_script onto ContractInstance and drop the Contract-level convenience wrappers, so callers instantiate explicitly and the runtime keeps track of the instance.

This addresses #185 (comment)

Comment thread starstream-runtime-next/src/lib.rs Outdated

/// Single instantiation of a [Contract]
#[derive(Debug, Copy, Clone)]
#[repr(transparent)]

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.

is there any specific reason to use #[repr(transparent)]?

I wouldn't usually add this unless this is going through some unsafe code somewhere that requires the layout (like a transmute)

Not necessarily saying this is wrong though

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Mostly just a habit. I use it as a hint to the compiler, but also the developer that this is a thin newtype wrapper

@ecioppettini ecioppettini left a comment

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.

Not really sure about the #[repr(transparent)] thing (left a comment in that line)

Besides that this looks reasonable to me (and even that is mainly nitpicking, so I would be fine with that being merged anyway)

Make `Contract::instantiate` public and have it return a new
`repr(transparent)` `ContractInstance` wrapper around the wasmtime
`Instance`. Move `create_utxo`, `load_utxo` and
`call_coordination_script` onto `ContractInstance` and drop the
`Contract`-level convenience wrappers, so callers instantiate
explicitly and the runtime keeps track of the instance.

Assisted-by: anthropic:claude-fable-5
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
@rvolosatovs
rvolosatovs enabled auto-merge (squash) August 4, 2026 14:07
@rvolosatovs

Copy link
Copy Markdown
Contributor Author

Not really sure about the #[repr(transparent)] thing (left a comment in that line)

Besides that this looks reasonable to me (and even that is mainly nitpicking, so I would be fine with that being merged anyway)

removed it, merging!

@rvolosatovs
rvolosatovs merged commit 497e6ce into LFDT-Nightstream:main Aug 4, 2026
3 checks passed
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.

2 participants