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

LoaderV2 integration #139

Merged
merged 36 commits into from
Oct 30, 2024
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7026441
wip: apply loader v2, need to fix move to json error
sh-cha Oct 4, 2024
beec7b4
copy type conversion functions from runtime loader & handle json pars…
sh-cha Oct 7, 2024
72e80a9
bump aptos core loader v2 version
sh-cha Oct 7, 2024
95c50af
introduce InitiaModuleStorage using LRU module cache
sh-cha Oct 10, 2024
2846e87
Merge branch 'main' into feat/vm-loaderv2
sh-cha Oct 10, 2024
f508c7d
introduce InitiaCodeStorage to connect InitiaModuleStorage
sh-cha Oct 10, 2024
4c2b6ae
manage module cache as a single unit within the Initia VM
sh-cha Oct 11, 2024
b883063
manage script cache as a single unit within the Initia VM
sh-cha Oct 11, 2024
f61941c
fmt and clippy
sh-cha Oct 11, 2024
574329b
compiled module & script interface change
sh-cha Oct 14, 2024
4db894c
use custom move (#140)
beer-1 Oct 14, 2024
19859b3
update rust version
beer-1 Oct 14, 2024
efef800
clone runtime_environment on every call
beer-1 Oct 14, 2024
5bda0a3
introduce lock on cache (#141)
beer-1 Oct 15, 2024
c131df7
use aptor-core move & flush type_cache every vm call
sh-cha Oct 15, 2024
af0ca61
not cloning environment with flushed ty_cache
sh-cha Oct 15, 2024
2e77522
fix coderabbit audit
beer-1 Oct 15, 2024
c6abc73
feat: deps code upgrade policy check (#144)
sh-cha Oct 21, 2024
9e49a92
apply recent aptos update making struct index map to arc
sh-cha Oct 24, 2024
9fa398c
calculate cache size using real heap size
sh-cha Oct 28, 2024
bee348d
fmt clippy
sh-cha Oct 28, 2024
9e78fde
add storage & code conversion test
sh-cha Oct 28, 2024
ee4f7e8
fix script access specifier
sh-cha Oct 29, 2024
e2cf136
add code scale test code to be used in e2e test & debug code to ident…
sh-cha Oct 29, 2024
dbe9785
add panic handling when fetching size
sh-cha Oct 29, 2024
34c4c8d
Merge branch 'main' into feat/vm-loaderv2
beer-1 Oct 29, 2024
bf1b2c6
apply merged version
sh-cha Oct 30, 2024
4e72f5f
Feat/refactor native code (#154)
sh-cha Oct 30, 2024
73e625f
nit error message change
sh-cha Oct 30, 2024
7a51d5d
cleanup module cache code
sh-cha Oct 30, 2024
9ea7d92
nit error message
sh-cha Oct 30, 2024
f17410f
delete type conversion funcs from sessionExt & use them from session …
sh-cha Oct 30, 2024
1ab2947
use 1 as cache weight for all cache items
beer-1 Oct 30, 2024
4ff217c
Merge branch 'main' of https://github.com/initia-labs/movevm into fea…
beer-1 Oct 30, 2024
5060f4c
minor lint fix
beer-1 Oct 30, 2024
7c1ede3
feat: use constant cache weight for all modules & scripts (#156)
beer-1 Oct 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[env]

RUST_BIGDECIMAL_FMT_EXPONENTIAL_UPPER_THRESHOLD="100"
RUST_BIGDECIMAL_FMT_EXPONENTIAL_LOWER_THRESHOLD="100"
RUST_BIGDECIMAL_FMT_EXPONENTIAL_LOWER_THRESHOLD="100"
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ jobs:
- name: Install latest rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.77.1
toolchain: 1.80.1
override: true
components: rustfmt, clippy
- uses: actions/setup-go@v4
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ jobs:
- name: Install latest rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.77.1
toolchain: 1.80.1
- name: Build Rust
run: make build-rust
- uses: actions/setup-go@v4
105 changes: 54 additions & 51 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ license = "BUSL-1.1"
license-file = "LICENSE"
homepage = "https://initia.xyz"
repository = "https://github.com/initia-labs/movevm"
rust-version = "1.77.1"
rust-version = "1.80.1"

[workspace.dependencies]
# Internal crate dependencies.
@@ -65,9 +65,11 @@ initia-move-resource-viewer = { path = "crates/resource-viewer" }

# External crate dependencies.
# Please do not add any test features here: they should be declared by the individual crate.
anyhow = "1.0.41"
bcs = "0.1.5"
ambassador = "0.4.1"
anyhow = "1.0.71"
bcs = { git = "https://github.com/aptos-labs/bcs.git", rev = "d31fab9d81748e2594be5cd5cdf845786a30562d" }
better_any = "0.1.1"
claims = "0.7"
clru = "^0.6.2"
cbindgen = "0.26.0"
clap = { version = "4.3.9", features = ["derive", "env", "suggestions"] }
@@ -76,7 +78,7 @@ dialoguer = "0.10.2"
ed25519-consensus = { version = "2.0.1", features = ["serde"] }
errno = "0.3.0"
hex = { version = "0.4.3", default-features = false }
itertools = "0.10.3"
itertools = "0.13"
libsecp256k1 = { version = "0.7.1" }
log = { version = "0.4.17", features = [
"max_level_debug",
@@ -95,16 +97,17 @@ serde-generate = { git = "https://github.com/aptos-labs/serde-reflection", rev =
serde-reflection = { git = "https://github.com/aptos-labs/serde-reflection", rev = "73b6bbf748334b71ff6d7d09d06a29e3062ca075" }
sha2 = "0.10.8"
sha3 = "0.10.6"
smallvec = "1.6.1"
smallvec = "1.8.0"
smallbitvec = "2.5.1"
tempfile = "3.2.0"
tempfile = "3.3.0"
serial_test = "1.0.0"
thiserror = "1.0.34"
thiserror = "1.0.37"
tsu = "1.0.1"
bytes = "1.4.0"
parking_lot = "0.12.1"
base64 = "0.21.7"
bigdecimal = ">=0.4.5"
primitive-types = { version = "0.10" }
bech32 = "0.11"
triomphe = "0.1.9"
ripemd = "0.1.1"
@@ -113,51 +116,51 @@ tiny-keccak = { version = "2.0.2", features = ["keccak", "sha3"] }
# Note: the BEGIN and END comments below are required for external tooling. Do not remove.
# BEGIN MOVE DEPENDENCIES

move-binary-format = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-bytecode-verifier = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-bytecode-utils = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-cli = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-command-line-common = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-compiler = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-coverage = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-core-types = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-docgen = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-model = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-package = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-prover = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-prover-boogie-backend = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-prover-bytecode-pipeline = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-resource-viewer = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-stackless-bytecode = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-stdlib = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-symbol-pool = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-unit-test = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-vm-runtime = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-vm-test-utils = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-vm-types = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "85966af7ddcf971f3f04f4f409c3e67c9d9b11cb" }
move-binary-format = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-bytecode-verifier = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-bytecode-utils = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-cli = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-command-line-common = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-compiler = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-coverage = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-core-types = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-docgen = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-model = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-package = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-prover = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-prover-boogie-backend = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-prover-bytecode-pipeline = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-resource-viewer = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-stackless-bytecode = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-stdlib = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-symbol-pool = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-unit-test = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-vm-runtime = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-vm-test-utils = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-vm-types = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }

# END MOVE DEPENDENCIES

# FOR LOCAL DEVELOPMENNT
# move-binary-format = { path = "../aptos-core/third_party/move/move-binary-format" }
# move-bytecode-verifier = { path = "../aptos-core/third_party/move/move-bytecode-verifier" }
# move-bytecode-utils = { path = "../aptos-core/third_party/move/tools/move-bytecode-utils" }
# move-cli = { path = "../aptos-core/third_party/move/tools/move-cli" }
# move-command-line-common = { path = "../aptos-core/third_party/move/move-command-line-common" }
# move-compiler = { path = "../aptos-core/third_party/move/move-compiler" }
# move-coverage ={ path = "../aptos-core/third_party/move/tools/move-coverage" }
# move-core-types = { path = "../aptos-core/third_party/move/move-core/types" }
# move-docgen = { path = "../aptos-core/third_party/move/move-prover/move-docgen" }
# move-model = { path = "../aptos-core/third_party/move/move-model" }
# move-package = { path = "../aptos-core/third_party/move/tools/move-package" }
# move-prover = { path = "../aptos-core/third_party/move/move-prover" }
# move-prover-boogie-backend = { path = "../aptos-core/third_party/move/move-prover/boogie-backend" }
# move-prover-bytecode-pipeline = { path = "../aptos-core/third_party/move/move-prover/bytecode-pipeline" }
# move-resource-viewer = { path = "../aptos-core/third_party/move/tools/move-resource-viewer" }
# move-stackless-bytecode = { path = "../aptos-core/third_party/move/move-model/bytecode" }
# move-stdlib = { path = "../aptos-core/third_party/move/move-stdlib" }
# move-symbol-pool = { path = "../aptos-core/third_party/move/move-symbol-pool" }
# move-unit-test = { path = "../aptos-core/third_party/move/tools/move-unit-test" }
# move-vm-runtime = { path = "../aptos-core/third_party/move/move-vm/runtime" }
# move-vm-test-utils = { path = "../aptos-core/third_party/move/move-vm/test-utils" }
# move-vm-types = { path = "../aptos-core/third_party/move/move-vm/types" }
# move-binary-format = { path = "../move/move-binary-format" }
# move-bytecode-verifier = { path = "../move/move-bytecode-verifier" }
# move-bytecode-utils = { path = "../move/tools/move-bytecode-utils" }
# move-cli = { path = "../move/tools/move-cli" }
# move-command-line-common = { path = "../move/move-command-line-common" }
# move-compiler = { path = "../move/move-compiler" }
# move-coverage ={ path = "../move/tools/move-coverage" }
# move-core-types = { path = "../move/move-core/types" }
# move-docgen = { path = "../move/move-prover/move-docgen" }
# move-model = { path = "../move/move-model" }
# move-package = { path = "../move/tools/move-package" }
# move-prover = { path = "../move/move-prover" }
# move-prover-boogie-backend = { path = "../move/move-prover/boogie-backend" }
# move-prover-bytecode-pipeline = { path = "../move/move-prover/bytecode-pipeline" }
# move-resource-viewer = { path = "../move/tools/move-resource-viewer" }
# move-stackless-bytecode = { path = "../move/move-model/bytecode" }
# move-stdlib = { path = "../move/move-stdlib" }
# move-symbol-pool = { path = "../move/move-symbol-pool" }
# move-unit-test = { path = "../move/tools/move-unit-test" }
# move-vm-runtime = { path = "../move/move-vm/runtime" }
# move-vm-test-utils = { path = "../move/move-vm/test-utils" }
# move-vm-types = { path = "../move/move-vm/types" }
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ test-safety:
# Use package list mode to include all subdirectores. The -count=1 turns off caching.
GODEBUG=cgocheck=2 go test -race -v -count=1 -parallel=1 ./...

test-rust: test-compiler test-lib test-e2e test-movevm test-json
test-rust: test-compiler test-lib test-e2e test-movevm test-json test-storage

test-compiler:
cargo test -p initia-move-compiler
@@ -67,6 +67,9 @@ test-json:
test-lib:
cargo test -p initia-move-vm

test-storage:
cargo test -p initia-move-storage

test-e2e:
cargo test -p e2e-move-tests --features testing

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Initia MoveVM

The Initia MoveVM is forked from [wasmvm](https://github.com/CosmWasm/wasmvm) with some modifications to support ([Aptos](https://github.com/aptos-labs/aptos-core)) MoveVM.
This mechanism allows the users to compile, initialize, and execute Move Smart Contracts from Go applications, in particular from [x/move](https://github.com/initia-labs/initia/tree/main/x/move).

@@ -8,7 +9,7 @@ This repo contains both Rust and Go codes. The rust code is compiled into a dll/

## Supported Platform

Requires **Rust 1.77+ and Go 1.22+.**
Requires **Rust 1.80+ and Go 1.22+.**

The Rust implementation of the VM is compiled to a library called libmovevm. This is then linked to the Go code when the final binary is built. For that reason not all systems supported by Go are supported by this project.

@@ -44,4 +45,4 @@ There are two parts to this code - go and rust. The first step is to ensure that

If this is present, then `make test` will run the Go test suite and you can import this code freely. If it is not present you will have to build it for your system, and ideally add it to this repo with a PR (on your fork). We will set up a proper CI system for building these binaries, but we are not there yet.

To build the rust side, try make `build-rust` and wait for it to compile. This depends on `cargo` being installed with rustc version 1.77+. Generally, you can just use rustup to install all this with no problems.
To build the rust side, try make `build-rust` and wait for it to compile. This depends on `cargo` being installed with rustc version 1.80+. Generally, you can just use rustup to install all this with no problems.
2 changes: 1 addition & 1 deletion builders/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ RUN set -eux \

RUN wget "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-musl/rustup-init" \
&& chmod +x rustup-init \
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.77.1 \
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.80.1 \
&& rm rustup-init \
&& chmod -R a+w $RUSTUP_HOME $CARGO_HOME

2 changes: 1 addition & 1 deletion builders/Dockerfile.centos7
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ ENV RUSTUP_HOME=/usr/local/rustup \

RUN wget "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init" \
&& chmod +x rustup-init \
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.77.1 \
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.80.1 \
&& rm rustup-init \
&& chmod -R a+w $RUSTUP_HOME $CARGO_HOME \
&& rustup --version \
2 changes: 1 addition & 1 deletion builders/Dockerfile.cross
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.77.1-bullseye
FROM rust:1.80.1-bullseye

# Install build dependencies
RUN apt-get update \
11 changes: 6 additions & 5 deletions crates/compiler/src/unit_test_factory.rs
Original file line number Diff line number Diff line change
@@ -27,11 +27,12 @@ impl InitiaUnitTestFactory {
let table_change_set = table_context
.into_change_set()
.map_err(|e| e.finish(Location::Undefined))?;
let write_set = WriteSet::new(changes.clone(), table_change_set).map_err(|e| {
PartialVMError::new(StatusCode::FAILED_TO_SERIALIZE_WRITE_SET_CHANGES)
.with_message(e.to_string())
.finish(Location::Undefined)
})?;
let write_set =
WriteSet::new_with_change_set(changes.clone(), table_change_set).map_err(|e| {
PartialVMError::new(StatusCode::FAILED_TO_SERIALIZE_WRITE_SET_CHANGES)
.with_message(e.to_string())
.finish(Location::Undefined)
})?;

gas_meter.charge_write_set_gas(&write_set)?;

1 change: 1 addition & 0 deletions crates/e2e-move-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -45,5 +45,6 @@ default = []
testing = [
"initia-move-gas/testing",
"initia-move-natives/testing",
"initia-move-storage/testing",
"move-vm-runtime/testing",
]
Loading