Skip to content

Conversation

@cmickeyb
Copy link
Contributor

Upgrade WAMR and WASI dependencies. The transition to WAMR 2.4.1 required several changes to module initialization and function invocation. The biggest barrier to the update, however, was figuring out the memory requirements since the memory layout of the interpreter changed significantly since version 1.3.

Not sure why we didn't support this a long time ago. But varargs
with printf format should work for exceptions.

Signed-off-by: Mic Bowman <[email protected]>
@cmickeyb cmickeyb requested a review from Copilot September 22, 2025 18:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Upgrades WAMR to version 2.4.1 and WASI SDK to v27, requiring significant changes to module initialization, function invocation, and memory management.

  • Updated WAMR submodule from version 1.3 to 2.4.1 and WASI SDK from v24 to v27
  • Refactored memory management with new size configuration system and StateFinalizer pattern
  • Modified WAMR initialization to use new APIs and removed deprecated function calls

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
interpreters/wasm-micro-runtime Updated WAMR submodule commit
eservice/lib/libpdo_enclave/contract_request.cpp Added StateFinalizer class for memory management
docker/pdo_base.dockerfile Updated WASI SDK version to v27
contracts/wawaka/contract-build.cmake Added new WASM export symbols and memory configuration options
contracts/wawaka/common/Util.cpp Added new delete operator overload
contracts/wawaka/common/Dispatch.cpp Removed deprecated constructor calls
common/tests/state/CMakeLists.txt Added state memory size definitions
common/state/data_node.h Made data block size configurable
common/state/cache.h Made cache size configurable
common/packages/parson/parson.h Removed SGX compilation flags and unused functions
common/packages/parson/parson.cpp Simplified JSON serialization and removed SGX-specific code
common/interpreter/wawaka_wasm/wamr_fixes.c Removed old fix file
common/interpreter/wawaka_wasm/wamr/wamr_fixes.c Added new WAMR memory consumption function
common/interpreter/wawaka_wasm/wamr/wamr.cmake Added new WAMR build configuration
common/interpreter/wawaka_wasm/wamr/patches/000_sgx_platform.patch Added SGX platform patch
common/interpreter/wawaka_wasm/wamr/patch.sh Added patch application script
common/interpreter/wawaka_wasm/WawakaInterpreter.h Refactored interpreter state management
common/interpreter/wawaka_wasm/WawakaInterpreter.cpp Updated WAMR API calls and memory management
common/interpreter/wawaka_wasm/WasmExtensions.h Added contract_abort function declaration
common/interpreter/wawaka_wasm/WasmExtensions.cpp Updated native function registration and added abort wrapper
common/interpreter/wawaka_wasm/CMakeLists.txt Refactored build system with new memory configuration
common/error.h Added variadic argument support to error functions
common/CMakeLists.txt Added state memory size definitions
build/tests/wawaka/memory-test.json Removed problematic deep recursion tests
build/template/eservice.toml Reduced default thread counts
build/cmake/SGX.cmake Moved memory configuration to separate file
build/cmake/ProjectVariables.cmake Moved memory configuration to Memory.cmake
build/cmake/Memory.cmake Added comprehensive memory configuration system

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Signed-off-by: Mic Bowman <[email protected]>
Includes clang v20.

Signed-off-by: Mic Bowman <[email protected]>
There appears to be some "incompatibilities" between the way parson
formats floats and the way WAMR handles indirect function calls
(parson uses a function pointer to allow specification of an
alternative way to format numbers). There did not appear an easy way
to keep parson (mostly) unmodified as has been for past
modifications. So... this update makes some more significant changes.

Signed-off-by: Mic Bowman <[email protected]>
Move the various memory configurations into a single cmake
configuration file in build/cmake/Memory.cmake. SGX, state, and wawaka
all derive their configurations from that single file.

The file also contains documentation for how the different variables
interrelate. For example, the sgx reserved memory configuration
depends on the heap and maximum contract size in wawaka.

Incorporating the configuration into state & wawaka will happen
in the next several commits.

Also dropped the number of enclaves created in an eservice down to
2 to ease the impact of the additional enclave memory requirements
placed on reserved memory.

Signed-off-by: Mic Bowman <[email protected]>
Make the state cache size and data node size configurable
based on the memory allocated to contracts.

Signed-off-by: Mic Bowman <[email protected]>
- Refactored `CMakeLists.txt` to support WAMR integration and updated
memory configuration.

- Added `wamr` directory with patching scripts and custom build
configurations. Copied the linux-sgx platform cmake build script from
wamr, modified to apply a set of patches which include zero-ing SGX
extended memory on deallocation.

- Introduced `contract_abort_wrapper` and improved exception handling
in `WasmExtensions.cpp`. Removed operations that are now supported
directly by WAMR libc.

- Replaced `RegisterNativeFunctions` with `InitializeNativeSymbols`
for runtime initialization. This incorporates native function
initialization into the single runtime initialization.

- Update `WawakaInterpreter` for wamr 2.4.1. Class variables now
conform to standard usage. Improved initialization and
cleanup (e.g. to release static heap memory). In general, improved
checks on memory usage.

- Removed redundant `__wasm_call_ctors` calls in `Dispatch.cpp`.

- Updated `contract-build.cmake` to export additional symbols for WAMR
compatibility. Specifically, exporting malloc and free symbols enables
wamr to adapt memory usage more easily.

Signed-off-by: Mic Bowman <[email protected]>
WAMR 2.4.1 changes the way memory sharing occurs between instances
of the interpreter running in different threads. The current integration
does not address this issue so reducing the number of threads to 1 until
the threading issue can be resolved.

Signed-off-by: Mic Bowman <[email protected]>
ensure that variables are initialized. remove unused variables.
provide additional information for state exeception

Signed-off-by: Mic Bowman <[email protected]>
move kvstore clean up into its own function. this replaces
the exception with a more thorough cleanup to ensure that the
memory is released.

make a few variables in the state extensions constant that should
have been constant from the start

Signed-off-by: Mic Bowman <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 32 out of 32 changed files in this pull request and generated 5 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@cmickeyb
Copy link
Contributor Author

Closing this PR. Moving it to a separate branch.

@cmickeyb cmickeyb closed this Sep 24, 2025
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.

1 participant