Stream: git-wasmtime

Topic: wasmtime / PR #13934 wasi-sockets: Unify the p2 & p3 impl...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 14:38):

badeend opened PR #13934 from badeend:addr-checks to bytecodealliance:main:

Currently, the shared socket code (crates/wasi/src/sockets/*) is modeled after the
p2 interface, with p3 bindings papering over the differences. Some
functionality is duplicated between the p2/* and p3/* implementations. This has
already caused bugs in the past.

Since the p3 interface is strictly a superset of p2, I think it makes more sense to invert that relationship. This PR updates the shared code to become the canonical (p3-shaped)
implementation with the p3's bindings now a thin wrapper around it. All
p2-only behavior & state is moved into the p2 bindings layer. Think of: artificial restrictions like disallowing implicit
binds, and the start/finish async bookkeeping.

Other notable changes:

Added test coverage for previously-untested behavior:


All-in-all, the goal of this PR is to consolidate the socket code (even further) into a single place and make it less error-prone to maintain. I realize there's quite a bit of unannounced code movement here, so let me know what you think.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 14:38):

badeend requested pchickey for a review on PR #13934.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 14:38):

badeend requested wasmtime-wasi-reviewers for a review on PR #13934.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 14:38):

badeend requested wasmtime-core-reviewers for a review on PR #13934.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 17:05):

github-actions[bot] added the label wasi on PR #13934.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 17:46):

alexcrichton unassigned pchickey from PR #13934 wasi-sockets: Unify the p2 & p3 implementations.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 17:46):

alexcrichton requested alexcrichton for a review on PR #13934.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 17:55):

:thumbs_up: alexcrichton submitted PR review:

Thanks so much for this! This all sounds great to me and I think the refactoring's a good idea. Do you think long-term it would be possible to fold the utils.rs module into the tcp/udp modules directly? That seems a vestige of a time where it was a home of common functionality between p2/p3, but nowadays that should just be {Tcp,Udp}Socket. (Fine to happen in a follow-up PR of course)

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 17:55):

:speech_balloon: alexcrichton created PR review comment:

For this the handling of finish is a bit subtle, but the basic idea is that this continues to do everything below and then instead of returning Pending at the last second it returns Cancelled instead. That gives sort of a "final chance" to get everything completed

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 17:55):

:speech_balloon: alexcrichton created PR review comment:

Similar comment to below on finish here

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 17:55):

:speech_balloon: alexcrichton created PR review comment:

Similar comment to below on finish here

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 20:26):

badeend updated PR #13934.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 20:34):

:memo: badeend submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 20:34):

:speech_balloon: badeend created PR review comment:

My reasoning was that; if the guest cancels the read/write, there's no point in us to querying the OS again for something the guest isn't interested in anymore. Which is why I had the early return.

But I'm fine with giving it one last poll. See latest commit.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 20:44):

badeend commented on PR #13934:

Do you think long-term it would be possible to fold the utils.rs module into the tcp/udp modules directly?

For the things that are explicitly marked as tcp_* & udp_*; Yes, that should be possible.

There are also a bunch of functions that are shared between tcp & udp, like:

For those , I think the best we can do is move them into mod.rs.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 21:20):

:memo: alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 21:21):

:speech_balloon: alexcrichton created PR review comment:

Yeah the intent of the guest is a bit ambiguous because it could mean "I still want to try to finish, but clear out otherwise" vs "I'm totally uninterested in the result just clean up" which is conflated right now

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 21:21):

alexcrichton commented on PR #13934:

Makes sense yeah, not something worth proactively doing necessarily, just curious!

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 21:21):

alexcrichton added PR #13934 wasi-sockets: Unify the p2 & p3 implementations to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 21:53):

:check: alexcrichton merged PR #13934.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 21:53):

alexcrichton removed PR #13934 wasi-sockets: Unify the p2 & p3 implementations from the merge queue.


Last updated: Jul 29 2026 at 05:03 UTC