Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Go-wasi Edits #206

Merged
merged 17 commits into from
Mar 8, 2024
Merged

Go-wasi Edits #206

merged 17 commits into from
Mar 8, 2024

Conversation

rachel-bousfield
Copy link
Contributor

@rachel-bousfield rachel-bousfield commented Mar 8, 2024

This PR provides final review edits for go-wasi, which consists of the following PRs.

In particular, this PR

  • Introduces GuestPtr to complete the Uptr concept. This provides additional safety since it's no longer just a alias. This is possible via the new traits provided by the wasmer-traits feature flag in caller-env (new name), which allows us to use these types in wasmer Host I/Os directly. Applying these changes lead to type checking errors, revealing each instance of accidental u32 <=> pointer type confusion. These have been fixed & made consistent :)
  • The wrap! macro is now multi-line and allows you to write more complete functions.
  • We now use a ThreadState type instead of an Option for tracking the cothread state in the machine. This makes things easier to read & audit.
  • Consolidates GoSliceData and SendGoSliceData into one type (updated in notion too btw). We do this by a manual impl of Send.
  • Uses a streaming pattern to parse messages from Rust => Go in a safer way.
  • Fixes a bug in handleReqImpl where Go and Rust type-confused rustBytes vs rustSlice.
  • Fixes debug messages printing out during error recovery on production chains.
  • Makes wasip1 get_args successful.
  • Optimizes read_u32/64 and write_u32/64 and reduces copies throughout the system.
  • Removes unnecessary !wasm build tags
  • Refactors evmApi in native.go to be receiver based.
  • Reverts startInk and the two require_gas's in UserHost.
  • Adds docstrings, makes things more idiomatic, and other minor improvements

Closes STY-7

Associated PRs

@cla-bot cla-bot bot added the s label Mar 8, 2024
let subs_base = in_subs + (SUBSCRIPTION_SIZE * (i as u32));
const SUBSCRIPTION_SIZE: u32 = 48; // user data + 40-byte union
for index in 0..num_subscriptions {
let subs_base = in_subs + (SUBSCRIPTION_SIZE * index);
let subs_type = mem.read_u32(subs_base + 8);
if subs_type != 0 {
// not a clock subscription type
continue;
}
let user_data = mem.read_u32(subs_base);
Copy link
Contributor

Choose a reason for hiding this comment

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

we could also read more properties of the clock and advance time here.. though probably not too important

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some extra passage of time at the top of poll_oneshot

}
}

impl Deref for GuestPtr {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need deref and deref mut? I'm worried implementing them for a GuestPtr will seem like we access the guest data and not the underline uint32

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added them so that we could auto-implement a bunch of math functions.

How's this, I've just removed DerefMut but kept Deref for the read-only ops :)

arbitrator/prover/src/machine.rs Outdated Show resolved Hide resolved
fn brotli_compress(in_buf_ptr: GuestPtr, in_buf_len: u32, out_buf_ptr: GuestPtr, out_len_ptr: GuestPtr, level: u32, window_size: u32) -> BrotliStatus
}
Copy link
Contributor

Choose a reason for hiding this comment

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

note: I see you added into the git: arbitrator/wasm-libraries/go-js-test/js-test.wasm

Copy link
Contributor

Choose a reason for hiding this comment

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

(probably worthwhile even editing the commit and force-pushing the branch, to avoid adding that 2.5MB data)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re-wrote history :)

arbitrator/wasm-libraries/user-host/src/program.rs Outdated Show resolved Hide resolved
arbos/programs/api.go Outdated Show resolved Hide resolved
arbitrator/jit/src/caller_env.rs Outdated Show resolved Hide resolved
arbitrator/caller-env/src/static_caller.rs Outdated Show resolved Hide resolved
@tsahee tsahee merged commit 69ae4b7 into go_wasi_code_reuse Mar 8, 2024
8 checks passed
@tsahee tsahee deleted the go-wasi-edits branch March 8, 2024 23:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants