gossamer
gossamer copied to clipboard
chore(wasmer): add helpers.go file with helper functions
Changes
- Split out (CGO related) helper functions from
imports.go
tolib/runtime/wasmer/helpers.go
- Move pointer size helper functions to
lib/runtime/wasmer/helpers.go
- Change
toWasmMemorySized
to NOT take a size argument (unneeded) - Clarify all comments for helper functions
- Update all error wrappings
- Review variable names
- Use
ptr
instead ofout
for 32 bit pointers - Use
pointerSize
instead ofspan
for 64 bit pointers size - Name return values
- Other minor renamings such as
res
toresult
,enc
toencodedResult
- Use
- Optimizations:
-
storageAppend
: use slice capacity allocation,copy
and remove unneededappend
s -
toKillStorageResultEnum
: usecopy
instead ofappend
-
toWasmMemoryOptional
: remove unneeded variable copy
-
Tests
go test -tags integration github.com/ChainSafe/gossamer
Issues
Friday evening fun. Also aiming to make the migration to wazero easier.
Primary Reviewer
@EclesioMeloJunior
Codecov Report
Merging #2749 (040c139) into development (62d750d) will increase coverage by
0.23%
. The diff coverage is68.96%
.
Additional details and impacted files
@@ Coverage Diff @@
## development #2749 +/- ##
===============================================
+ Coverage 63.02% 63.25% +0.23%
===============================================
Files 213 213
Lines 26965 26957 -8
===============================================
+ Hits 16994 17051 +57
+ Misses 8425 8358 -67
- Partials 1546 1548 +2
LGTM, just a suggestion: since all the operations relies on the
wasmer.InstanceContext
could we rename the file fromhelpers.go
tocontext.go
orinstance_context.go
?
Good suggestion, although storageAppend
isn't really about context, and I also sneaked in pointer size conversion functions in there, so helpers.go
seems appropriate for now.
Looks like Deepsource doesn't like having two cgo files in the same package and fails compiling, I'll convert this back to draft and fix this later. Maybe split this in another subpackage for the sake of deepsource 🤔
FYI, I noticed this was in prep of a possible use of wazero, and thanks for thinking of us.
wazero just cut its first beta tag (v1.0.0-beta.1) and also opened a gophers slack #wazero
channel for support, updates and conversation! Note: You may need an invite to join gophers.
We've also been working harder on our website for things people usually can't find https://wazero.io/languages/
Wish you well and hope to see you around.
Awesome @codefromthecrypt thanks for letting us know! We're probably a few months away from switching to wazero due to other priorities, but it's definitely something we would all like to jump to for sure!