Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P23 #1511

Merged
merged 3 commits into from
Jan 22, 2025
Merged

P23 #1511

merged 3 commits into from
Jan 22, 2025

Conversation

graydon
Copy link
Contributor

@graydon graydon commented Jan 22, 2025

This PR strictly bumps the protocol to p23 (and re-observes tests) not changing anything else.

The commit that needs the most scrutiny is f4dc35d since it is the reobservation run: only small changes that derive from the protocol number itself should be visible (typically "the change of protocol number in the wasm metadata").

@graydon graydon marked this pull request as ready for review January 22, 2025 02:08
@graydon graydon requested review from sisuresh, dmkozh and a team as code owners January 22, 2025 02:08
@graydon graydon enabled auto-merge January 22, 2025 02:38
@graydon graydon added this pull request to the merge queue Jan 22, 2025
Merged via the queue into stellar:main with commit c6c25a6 Jan 22, 2025
12 checks passed
@graydon graydon deleted the p23 branch January 22, 2025 17:19
github-merge-queue bot pushed a commit that referenced this pull request Jan 22, 2025
The goals of this PR are:

1. Surface the `ModuleCache` from inside soroban to its embedding
environment.
2. Allow a module cache to _outlive_ the soroban `Host`, and be reused
from one `Host` to the next.
3. Allow the `ModuleCache` to be _pre-populated_ from before the
lifetime of a single `Host`, (eg. by stellar-core, with all the
non-archived contracts currently live in the ledger, at startup or
such.)

These goals are accomplished by the following structural changes:

1. Factoring out error-handling / error-mapping functionality of `Host`
into a separate trait `ErrorHandler` that `Host` implements, and adding
a new trait `CompilationContext` that extends both `ErrorHandler +
AsBudget`. This abstracts the services the `ModuleCache` _needs_ from
the `Host`, such that the embedding environment can provide its own
`CompilationContext` in the times pre- or post-`Host` lifetime.
2. Modifying the internal map that stores `Module`s inside the
`ModuleCache` to use a refcounted-shared-mutable `std::map::BtreeMap`
that can be incrementally and efficiently added-to or removed-from, and
is _not_ metered.
3. `Module` storage and arguments that were `Rc<>` are made `Arc<>` and
the whole `ModuleCache` is made `Send+Sync`. This is mainly because we
want to work with the reusable `ModuleCache` across C++ threads, and
while Rust has no idea about C++ threads it at least helps us shoot
ourselves in the foot less if all the Rust code that works with it
preserves the sense of "this would be threadsafe in Rust if Rust was
making the threads".
4. There is also a bit of gratuitous churn where things get renamed from
`foo` => `wasmi_foo` and `Foo` => `wasmi::Foo`. This is because this
change was done as part of (and there'll be a followup PR including)
work equipping the `Vm` and `ModuleCache` with an experimental
wasmtime/winch backend. It turns out this PR's work (on just the
`ModuleCache` reuse part) is high enough value, and agnostic enough to
which backend it's using, that we want to split this work out, move it
up in the schedule and explore getting it into as early a release as
possible. But I didn't bother reverting-out the `wasmi_`-qualification
since it's intertwined with other changes here and harmless to keep.

This PR is a continuation of
#1511 and should be merged
after it.

This PR implements
[CAP-0065](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0065.md)
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