From 9f35588b933ee6a0764edc07d4188085582d681f Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Sun, 13 Nov 2022 21:00:51 +0800 Subject: [PATCH] 1.add move stdlib nursery GasParam 2.fix starcoin_vm gas_meter 3.fix fmt and clippy warnning --- .github/workflows/build_test.yml | 14 +- Cargo.lock | 80 ++++----- abi/decoder/Cargo.toml | 2 +- abi/resolver/Cargo.toml | 2 +- cmd/db-exporter/Cargo.toml | 4 +- cmd/starcoin/Cargo.toml | 4 +- commons/proptest-helpers/Cargo.toml | 2 +- config/src/genesis_config.rs | 26 ++- rpc/api/src/types.rs | 2 +- state/api/Cargo.toml | 2 +- state/statedb/Cargo.toml | 2 +- state/statedb/src/lib.rs | 6 +- vm/compiler/Cargo.toml | 6 +- vm/gas-algebra-ext/Cargo.toml | 9 +- vm/gas-algebra-ext/src/lib.rs | 27 +-- vm/gas-algebra-ext/src/move_stdlib.rs | 30 ++-- vm/gas-algebra-ext/src/nursery.rs | 10 ++ vm/gas-algebra-ext/src/starcoin_framework.rs | 19 ++- vm/gas-algebra-ext/src/table.rs | 22 +-- vm/move-coverage/Cargo.toml | 8 +- vm/move-explain/Cargo.toml | 2 +- vm/move-package-manager/Cargo.toml | 25 +-- vm/move-package-manager/src/main.rs | 19 ++- vm/move-package-manager/src/release.rs | 2 +- vm/move-prover/Cargo.toml | 6 +- vm/natives/Cargo.toml | 20 +-- vm/resource-viewer/Cargo.toml | 4 +- vm/starcoin-gas/Cargo.toml | 10 +- vm/starcoin-gas/src/gas_meter.rs | 160 +++++++++--------- .../Cargo.toml | 14 +- vm/stdlib/Cargo.toml | 6 +- vm/transaction-builder-generator/Cargo.toml | 2 +- vm/types/Cargo.toml | 14 +- vm/types/src/on_chain_config/gas_schedule.rs | 22 ++- .../on_chain_config/genesis_gas_schedule.rs | 1 + vm/types/src/on_chain_config/mod.rs | 8 +- vm/types/src/on_chain_config/vm_config.rs | 2 +- vm/vm-runtime/Cargo.toml | 8 +- vm/vm-runtime/src/data_cache.rs | 4 +- vm/vm-runtime/src/move_vm_ext/session.rs | 2 +- vm/vm-runtime/src/move_vm_ext/vm.rs | 2 - vm/vm-runtime/src/natives.rs | 14 +- vm/vm-runtime/src/starcoin_vm.rs | 64 ++----- 43 files changed, 338 insertions(+), 350 deletions(-) create mode 100644 vm/gas-algebra-ext/src/nursery.rs diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 85d4524227..8b7ae8ca93 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -26,13 +26,6 @@ jobs: uses: actions-rs/cargo@v1 with: command: clean - - name: build - uses: actions-rs/cargo@v1 - with: - command: build - args: --all - - name: test - run: ./scripts/nextest.sh - name: run cargo check uses: actions-rs/cargo@v1 env: @@ -40,6 +33,13 @@ jobs: with: command: clippy args: --all-targets + - name: build + uses: actions-rs/cargo@v1 + with: + command: build + args: --all + - name: test + run: ./scripts/nextest.sh # - name: check changed files # run: bash ./scripts/changed_files.sh - name: Doc Tests diff --git a/Cargo.lock b/Cargo.lock index 7c8a2d5c10..2e3a69e64a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -837,7 +837,7 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytecode-interpreter-crypto" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "curve25519-dalek-fiat", @@ -2590,6 +2590,7 @@ dependencies = [ "move-core-types", "move-stdlib", "move-table-extension", + "move-vm-test-utils", "serde 1.0.140", "starcoin-natives", ] @@ -4670,7 +4671,7 @@ checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" [[package]] name = "move-abigen" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "bcs", @@ -4687,7 +4688,7 @@ dependencies = [ [[package]] name = "move-binary-format" version = "0.0.3" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "move-core-types", @@ -4702,12 +4703,12 @@ dependencies = [ [[package]] name = "move-borrow-graph" version = "0.0.1" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" [[package]] name = "move-bytecode-source-map" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "bcs", @@ -4722,7 +4723,7 @@ dependencies = [ [[package]] name = "move-bytecode-utils" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "move-binary-format", @@ -4734,7 +4735,7 @@ dependencies = [ [[package]] name = "move-bytecode-verifier" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "move-binary-format", @@ -4746,7 +4747,7 @@ dependencies = [ [[package]] name = "move-bytecode-viewer" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "clap 3.2.15", @@ -4763,7 +4764,7 @@ dependencies = [ [[package]] name = "move-cli" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "bcs", @@ -4809,7 +4810,7 @@ dependencies = [ [[package]] name = "move-command-line-common" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "difference", @@ -4826,7 +4827,7 @@ dependencies = [ [[package]] name = "move-compiler" version = "0.0.1" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "bcs", @@ -4855,7 +4856,7 @@ dependencies = [ [[package]] name = "move-core-types" version = "0.0.4" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "bcs", @@ -4874,7 +4875,7 @@ dependencies = [ [[package]] name = "move-coverage" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "bcs", @@ -4911,7 +4912,7 @@ dependencies = [ [[package]] name = "move-disassembler" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "clap 3.2.15", @@ -4929,7 +4930,7 @@ dependencies = [ [[package]] name = "move-docgen" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "codespan 0.11.1", @@ -4947,7 +4948,7 @@ dependencies = [ [[package]] name = "move-errmapgen" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "bcs", @@ -4961,7 +4962,7 @@ dependencies = [ [[package]] name = "move-ir-compiler" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "bcs", @@ -4980,7 +4981,7 @@ dependencies = [ [[package]] name = "move-ir-to-bytecode" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "codespan-reporting", @@ -4999,7 +5000,7 @@ dependencies = [ [[package]] name = "move-ir-to-bytecode-syntax" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "hex", @@ -5012,7 +5013,7 @@ dependencies = [ [[package]] name = "move-ir-types" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "hex", @@ -5026,7 +5027,7 @@ dependencies = [ [[package]] name = "move-model" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "codespan 0.11.1", @@ -5052,7 +5053,7 @@ dependencies = [ [[package]] name = "move-package" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "bcs", @@ -5112,6 +5113,7 @@ dependencies = [ "move-package", "move-unit-test", "move-vm-runtime", + "move-vm-test-utils", "once_cell", "starcoin-account-provider", "starcoin-cmd", @@ -5137,7 +5139,7 @@ dependencies = [ [[package]] name = "move-prover" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "async-trait", @@ -5174,7 +5176,7 @@ dependencies = [ [[package]] name = "move-prover-boogie-backend" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "async-trait", @@ -5202,7 +5204,7 @@ dependencies = [ [[package]] name = "move-prover-test-utils" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "move-command-line-common", @@ -5213,7 +5215,7 @@ dependencies = [ [[package]] name = "move-read-write-set-types" version = "0.0.3" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "move-binary-format", @@ -5224,7 +5226,7 @@ dependencies = [ [[package]] name = "move-resource-viewer" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "bcs", @@ -5239,7 +5241,7 @@ dependencies = [ [[package]] name = "move-stackless-bytecode" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "codespan 0.11.1", "codespan-reporting", @@ -5266,7 +5268,7 @@ dependencies = [ [[package]] name = "move-stackless-bytecode-interpreter" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "bytecode-interpreter-crypto", @@ -5284,7 +5286,7 @@ dependencies = [ [[package]] name = "move-stdlib" version = "0.1.1" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "log 0.4.17", @@ -5306,7 +5308,7 @@ dependencies = [ [[package]] name = "move-symbol-pool" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "once_cell", "serde 1.0.140", @@ -5315,7 +5317,7 @@ dependencies = [ [[package]] name = "move-table-extension" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "bcs", @@ -5332,7 +5334,7 @@ dependencies = [ [[package]] name = "move-transactional-test-runner" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "clap 3.2.15", @@ -5366,7 +5368,7 @@ dependencies = [ [[package]] name = "move-unit-test" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "better_any", @@ -5397,7 +5399,7 @@ dependencies = [ [[package]] name = "move-vm-runtime" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "better_any", "fail", @@ -5414,7 +5416,7 @@ dependencies = [ [[package]] name = "move-vm-test-utils" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "move-binary-format", @@ -5428,7 +5430,7 @@ dependencies = [ [[package]] name = "move-vm-types" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "bcs", "move-binary-format", @@ -7253,7 +7255,7 @@ dependencies = [ [[package]] name = "read-write-set" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "move-binary-format", @@ -7268,7 +7270,7 @@ dependencies = [ [[package]] name = "read-write-set-dynamic" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=e2282776b8a6642a68e7ac1a0c819bda76d64d95#e2282776b8a6642a68e7ac1a0c819bda76d64d95" +source = "git+https://github.com/starcoinorg/move?rev=54a90b627e38875bda8b8b4809faa21e88df10a2#54a90b627e38875bda8b8b4809faa21e88df10a2" dependencies = [ "anyhow", "move-binary-format", diff --git a/abi/decoder/Cargo.toml b/abi/decoder/Cargo.toml index 32442aaea7..7ebe7b9b4f 100644 --- a/abi/decoder/Cargo.toml +++ b/abi/decoder/Cargo.toml @@ -10,7 +10,7 @@ version = "1.12.5" [dependencies] anyhow = "1.0.41" hex = "0.4.3" -move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } starcoin-resource-viewer = { path = "../../vm/resource-viewer" } starcoin-vm-types = { path = "../../vm/types" } starcoin-abi-types = { path = "../types" } diff --git a/abi/resolver/Cargo.toml b/abi/resolver/Cargo.toml index a211ac1fb1..55bb8433a6 100644 --- a/abi/resolver/Cargo.toml +++ b/abi/resolver/Cargo.toml @@ -11,7 +11,7 @@ starcoin-vm-types = { path = "../../vm/types" } starcoin-abi-types = { path = "../types" } anyhow = "~1" starcoin-resource-viewer = { path = "../../vm/resource-viewer" } -move-model = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-model = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } [dev-dependencies] stdlib = { path = "../../vm/stdlib" } serde_json = "1" diff --git a/cmd/db-exporter/Cargo.toml b/cmd/db-exporter/Cargo.toml index f8547d3fbb..8a1499c44d 100644 --- a/cmd/db-exporter/Cargo.toml +++ b/cmd/db-exporter/Cargo.toml @@ -33,8 +33,8 @@ logger = { path = "../../commons/logger", package = "starcoin-logger" } clap = { version = "3", features = ["derive"] } atomic-counter = "1.0.1" tokio = { version = "^1", features = ["full"] } -move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-bytecode-verifier = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-bytecode-verifier = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } starcoin-resource-viewer = { path = "../../vm/resource-viewer" } starcoin-state-tree = { path = "../../state/state-tree" } [target."cfg(target_os=\"linux\")".dependencies] diff --git a/cmd/starcoin/Cargo.toml b/cmd/starcoin/Cargo.toml index 64a78e39f5..c76d1a0776 100644 --- a/cmd/starcoin/Cargo.toml +++ b/cmd/starcoin/Cargo.toml @@ -49,13 +49,13 @@ starcoin-resource-viewer = { path = "../../vm/resource-viewer" } starcoin-service-registry = { path = "../../commons/service-registry" } starcoin-move-explain = { path = "../../vm/move-explain" } vm-status-translator = { path = "../../vm/vm-status-translator" } -move-errmapgen = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-errmapgen = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } network-api = { path = "../../network/api", package = "network-api" } starcoin-network-rpc-api = { path = "../../network-rpc/api" } starcoin-abi-decoder = { path = "../../abi/decoder" } starcoin-abi-resolver = { path = "../../abi/resolver" } starcoin-abi-types = { path = "../../abi/types" } -move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } [dev-dependencies] test-helper = { path = "../../test-helper" } diff --git a/commons/proptest-helpers/Cargo.toml b/commons/proptest-helpers/Cargo.toml index 9398c7701f..b6db9646b3 100644 --- a/commons/proptest-helpers/Cargo.toml +++ b/commons/proptest-helpers/Cargo.toml @@ -8,6 +8,6 @@ version = "1.12.5" [dependencies] crossbeam = "0.7.3" -diem-proptest-helpers = { package = "diem-proptest-helpers", git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +diem-proptest-helpers = { package = "diem-proptest-helpers", git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } proptest = "1.0.0" proptest-derive = "0.3.0" diff --git a/config/src/genesis_config.rs b/config/src/genesis_config.rs index b4f74800d1..ded86289f5 100644 --- a/config/src/genesis_config.rs +++ b/config/src/genesis_config.rs @@ -27,10 +27,9 @@ use starcoin_vm_types::gas_schedule::{ use starcoin_vm_types::genesis_config::{ChainId, ConsensusStrategy, StdlibVersion}; use starcoin_vm_types::on_chain_config::{ instruction_gas_schedule_v1, instruction_gas_schedule_v2, instruction_table_v1, - move_stdlib_native_gas_schedule_v4, native_gas_schedule_v1, native_gas_schedule_v2, - native_table_v1, native_table_v2, txn_gas_schedule_test, txn_gas_schedule_v1, - txn_gas_schedule_v2, txn_gas_schedule_v3, ConsensusConfig, DaoConfig, TransactionPublishOption, - VMConfig, Version, + native_gas_schedule_v1, native_gas_schedule_v2, native_gas_schedule_v4, native_table_v1, + native_table_v2, txn_gas_schedule_test, txn_gas_schedule_v1, txn_gas_schedule_v2, + txn_gas_schedule_v3, ConsensusConfig, DaoConfig, TransactionPublishOption, VMConfig, Version, }; use starcoin_vm_types::on_chain_resource::Epoch; use starcoin_vm_types::token::stc::STCUnit; @@ -592,7 +591,7 @@ pub enum GenesisBlockParameterConfig { } /// GenesisConfig is a config for initialize a chain genesis. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] pub struct GenesisConfig { /// Parameter for init genesis block pub genesis_block_parameter: GenesisBlockParameterConfig, @@ -787,7 +786,7 @@ pub static G_TEST_CONFIG: Lazy = Lazy::new(|| { pub static G_TEST_GAS_PARAMS: Lazy = Lazy::new(|| { let params = concat_map( instruction_gas_schedule_v2(), - move_stdlib_native_gas_schedule_v4(), + native_gas_schedule_v4(), txn_gas_schedule_test(), ); StarcoinGasParameters::from_on_chain_gas_schedule(¶ms).unwrap() @@ -845,7 +844,7 @@ pub static G_DEV_CONFIG: Lazy = Lazy::new(|| { pub static G_DEV_GAS_PARAMS: Lazy = Lazy::new(|| { let params = concat_map( instruction_gas_schedule_v2(), - move_stdlib_native_gas_schedule_v4(), + native_gas_schedule_v4(), txn_gas_schedule_test(), ); StarcoinGasParameters::from_on_chain_gas_schedule(¶ms).unwrap() @@ -910,7 +909,7 @@ pub static G_HALLEY_CONFIG: Lazy = Lazy::new(|| { pub static G_HALLEY_GAS_PARAMS: Lazy = Lazy::new(|| { let params = concat_map( instruction_gas_schedule_v2(), - move_stdlib_native_gas_schedule_v4(), + native_gas_schedule_v4(), txn_gas_schedule_v3(), ); StarcoinGasParameters::from_on_chain_gas_schedule(¶ms).unwrap() @@ -975,7 +974,7 @@ pub static G_PROXIMA_CONFIG: Lazy = Lazy::new(|| { pub static G_PROXIMA_GAS_PARAMS: Lazy = Lazy::new(|| { let params = concat_map( instruction_gas_schedule_v2(), - move_stdlib_native_gas_schedule_v4(), + native_gas_schedule_v4(), txn_gas_schedule_v3(), ); StarcoinGasParameters::from_on_chain_gas_schedule(¶ms).unwrap() @@ -1122,3 +1121,12 @@ pub static G_MAIN_GAS_PARAMS: Lazy = Lazy::new(|| { ); StarcoinGasParameters::from_on_chain_gas_schedule(¶ms).unwrap() }); + +pub static G_LATEST_GAS_PARASM: Lazy = Lazy::new(|| { + let params = concat_map( + instruction_gas_schedule_v2(), + native_gas_schedule_v4(), + txn_gas_schedule_v3(), + ); + StarcoinGasParameters::from_on_chain_gas_schedule(¶ms).unwrap() +}); diff --git a/rpc/api/src/types.rs b/rpc/api/src/types.rs index 53d7b6e85a..d8ac41eb41 100644 --- a/rpc/api/src/types.rs +++ b/rpc/api/src/types.rs @@ -1914,7 +1914,7 @@ impl From for StateKeyView { match state_key { StateKey::AccessPath(access_path) => Self::AccessPath(access_path), StateKey::TableItem(table_item) => Self::TableItem(TableItemView { - handle: table_item.handle.into(), + handle: table_item.handle, key: table_item.key, }), } diff --git a/state/api/Cargo.toml b/state/api/Cargo.toml index cf6cfe6204..8e069ebfee 100644 --- a/state/api/Cargo.toml +++ b/state/api/Cargo.toml @@ -17,6 +17,6 @@ merkle-tree = { package = "forkable-jellyfish-merkle", path = "../../commons/for starcoin-state-tree = { path = "../state-tree" } bcs-ext = { package = "bcs-ext", path = "../../commons/bcs_ext" } starcoin-service-registry = { path = "../../commons/service-registry" } -move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } once_cell = "1.12.0" [dev-dependencies] diff --git a/state/statedb/Cargo.toml b/state/statedb/Cargo.toml index caebf40c83..aa516cc7ea 100644 --- a/state/statedb/Cargo.toml +++ b/state/statedb/Cargo.toml @@ -18,7 +18,7 @@ starcoin-state-tree = { path = "../state-tree" } bcs-ext = { package = "bcs-ext", path = "../../commons/bcs_ext" } serde = { version = "1.0.130" } forkable-jellyfish-merkle = { path = "../../commons/forkable-jellyfish-merkle" } -move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } once_cell = "1.12.0" parking_lot = "0.12.1" thiserror = "1.0" diff --git a/state/statedb/src/lib.rs b/state/statedb/src/lib.rs index e2af1fbd21..f177627306 100644 --- a/state/statedb/src/lib.rs +++ b/state/statedb/src/lib.rs @@ -619,10 +619,8 @@ impl ChainStateWriter for ChainStateDB { let table_handle_state_object = self.get_table_handle_state_object(handle)?; table_handle_state_object.commit()?; // put table_handle_state_object commit - self.state_tree_table_handles.put( - handle.clone(), - table_handle_state_object.root_hash().to_vec(), - ); + self.state_tree_table_handles + .put(*handle, table_handle_state_object.root_hash().to_vec()); } if len > 0 { self.state_tree_table_handles.commit()?; diff --git a/vm/compiler/Cargo.toml b/vm/compiler/Cargo.toml index 85bed8b6cb..3899cb1fe0 100644 --- a/vm/compiler/Cargo.toml +++ b/vm/compiler/Cargo.toml @@ -14,9 +14,9 @@ regex = { version = "1.6.0", default-features = false, features = [ "std", "perf", ] } -move-compiler = { package = "move-compiler", git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-compiler = { package = "move-compiler", git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } petgraph = "0.5.1" starcoin-crypto = { git = "https://github.com/starcoinorg/starcoin-crypto", rev = "d871dfb4216f034ee334a575926c101574d9d6dc" } starcoin-logger = { path = "../../commons/logger" } diff --git a/vm/gas-algebra-ext/Cargo.toml b/vm/gas-algebra-ext/Cargo.toml index f4b295ab39..428bc1cebb 100644 --- a/vm/gas-algebra-ext/Cargo.toml +++ b/vm/gas-algebra-ext/Cargo.toml @@ -7,9 +7,10 @@ publish = false version = "1.12.5" [dependencies] -move-core-types = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-stdlib = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-core-types = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-stdlib = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-vm-test-utils = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } starcoin-natives = { path = "../natives" } serde = { version = "1.0.130", default-features = false } \ No newline at end of file diff --git a/vm/gas-algebra-ext/src/lib.rs b/vm/gas-algebra-ext/src/lib.rs index 54d3002c58..7512e5e167 100644 --- a/vm/gas-algebra-ext/src/lib.rs +++ b/vm/gas-algebra-ext/src/lib.rs @@ -5,8 +5,8 @@ use crate::algebra::GasScalingFactor; use move_core_types::gas_algebra::{ Arg, GasQuantity, InternalGas, InternalGasPerByte, InternalGasUnit, NumBytes, UnitDiv, }; +pub use move_vm_test_utils::gas_schedule::GasCost; use serde::{Deserialize, Serialize}; -use std::{ops::Add, u64}; #[macro_use] pub mod natives; @@ -20,6 +20,7 @@ mod starcoin_framework; //pub mod gen; mod instr; mod move_stdlib; +mod nursery; mod table; mod transaction; @@ -37,30 +38,6 @@ pub type InternalGasPerAbstractValueUnit = GasQuantity>; -/// The `GasCost` tracks: -/// - instruction cost: how much time/computational power is needed to perform the instruction -/// - memory cost: how much memory is required for the instruction, and storage overhead -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] -pub struct GasCost { - pub instruction_gas: u64, - pub memory_gas: u64, -} - -impl GasCost { - pub fn new(instruction_gas: u64, memory_gas: u64) -> Self { - Self { - instruction_gas, - memory_gas, - } - } - - /// Convert a GasCost to a total gas charge in `InternalGas`. - #[inline] - pub fn total(&self) -> u64 { - self.instruction_gas.add(self.memory_gas) - } -} - #[derive(Clone, Debug, Serialize, PartialEq, Eq, Deserialize)] pub struct GasConstants { /// The cost per-byte read from global storage. diff --git a/vm/gas-algebra-ext/src/move_stdlib.rs b/vm/gas-algebra-ext/src/move_stdlib.rs index c9724f023e..95b7990eef 100644 --- a/vm/gas-algebra-ext/src/move_stdlib.rs +++ b/vm/gas-algebra-ext/src/move_stdlib.rs @@ -6,19 +6,32 @@ use move_stdlib::natives::GasParameters; // see starcoin/vm/types/src/on_chain_config/genesis_gas_schedule.rs // convert from https://github.com/starcoinorg/starcoin-framework/blob/main/sources/VMConfig.move#native_schedule -// XXX FIXME YSG diff native_gas_schedule crate::natives::define_gas_parameters_for_natives!(GasParameters, "move_stdlib", [ - [.bcs.to_bytes.per_byte_serialized, "bcs.to_bytes.per_byte_serialized", 10 * MUL], - [.bcs.to_bytes.failure, "bcs.to_bytes.failure", 1000 * MUL], + [.hash.sha2_256.base, "hash.sha2_256.base", 21 * MUL], [.hash.sha2_256.per_byte, "hash.sha2_256.per_byte", MUL], [.hash.sha3_256.base, "hash.sha3_256.base", 64 * MUL], [.hash.sha3_256.per_byte, "hash.sha3_256.per_byte", MUL], + [.bcs.to_bytes.per_byte_serialized, "bcs.to_bytes.per_byte_serialized", 10 * MUL], + [.bcs.to_bytes.failure, "bcs.to_bytes.failure", 1000 * MUL], + + [.vector.length.base, "vector.length.base", 98 * MUL], + [.vector.empty.base, "vector.empty.base", 84 * MUL], + [.vector.borrow.base, "vector.borrow.base", 1334 * MUL], + [.vector.push_back.base, "vector.push_back.base", 53 * MUL], + [.vector.pop_back.base, "vector.pop_back.base", 227 * MUL], + [.vector.destroy_empty.base, "vector.destroy_empty.base", 572 * MUL], + [.vector.swap.base, "vector.swap.base", 1436 * MUL], + // Note(Gas): this initial value is guesswork. [.signer.borrow_address.base, "signer.borrow_address.base", 353 * MUL], + [.vector.append.base, "vector.append.base", 40 * MUL], + [.vector.remove.base, "vector.remove.base", 20 * MUL], + [.vector.reverse.base, "vector.reverse.base", 10 * MUL], + // Note(Gas): these initial values are guesswork. [.string.check_utf8.base, "string.check_utf8.base", 4 * MUL], [.string.check_utf8.per_byte, "string.check_utf8.per_byte", MUL], @@ -26,11 +39,6 @@ crate::natives::define_gas_parameters_for_natives!(GasParameters, "move_stdlib", [.string.sub_string.base, "string.sub_string.base", 4 * MUL], [.string.sub_string.per_byte, "string.sub_string.per_byte", MUL], [.string.index_of.base, "string.index_of.base", 4 * MUL], - [.string.index_of.per_byte_pattern, "string.index_of.per_byte_pattern", 1 * MUL], - [.string.index_of.per_byte_searched, "string.index_of.per_byte_searched", 1 * MUL], - - // TODO(Gas): these should only be enabled when feature "testing" is present - // TODO(Gas): rename these in the move repo - [test_only .unit_test.create_signers_for_testing.base_cost, "unit_test.create_signers_for_testing.base", 1], - [test_only .unit_test.create_signers_for_testing.unit_cost, "unit_test.create_signers_for_testing.unit", 1] -], allow_unmapped = 1 /* bcs */ + 2 /* hash */ + 8 /* vector */); + [.string.index_of.per_byte_pattern, "string.index_of.per_byte_pattern", MUL], + [.string.index_of.per_byte_searched, "string.index_of.per_byte_searched", MUL], +]); diff --git a/vm/gas-algebra-ext/src/nursery.rs b/vm/gas-algebra-ext/src/nursery.rs new file mode 100644 index 0000000000..42552d17f2 --- /dev/null +++ b/vm/gas-algebra-ext/src/nursery.rs @@ -0,0 +1,10 @@ +use crate::gas_meter::EXECUTION_GAS_MULTIPLIER as MUL; +use move_stdlib::natives::NurseryGasParameters; + +// see starcoin/vm/types/src/on_chain_config/genesis_gas_schedule.rs +// convert from https://github.com/starcoinorg/starcoin-framework/blob/main/sources/VMConfig.move#native_schedule +crate::natives::define_gas_parameters_for_natives!(NurseryGasParameters, "nursery", [ + [.event.write_to_event_store.unit_cost, "event.write_to_event_store.unit_cost", 52 * MUL], + [.debug.print.base_cost, "debug.print.base_cost", MUL], + [.debug.print_stack_trace.base_cost, "debug.print_stack_trace.base_cost", MUL], +]); diff --git a/vm/gas-algebra-ext/src/starcoin_framework.rs b/vm/gas-algebra-ext/src/starcoin_framework.rs index 1e94a89cc0..a678119ff1 100644 --- a/vm/gas-algebra-ext/src/starcoin_framework.rs +++ b/vm/gas-algebra-ext/src/starcoin_framework.rs @@ -7,23 +7,26 @@ use starcoin_natives::GasParameters; // see starcoin/vm/types/src/on_chain_config/genesis_gas_schedule.rs // convert from https://github.com/starcoinorg/starcoin-framework/blob/main/sources/VMConfig.move#native_schedule crate::natives::define_gas_parameters_for_natives!(GasParameters, "starcoin_natives", [ + [.signature.ed25519_verify.base, "signature.ed25519_validate_key.base", 61 * MUL], + [.signature.ed25519_verify.per_byte, optional "signature.ed25519_validate_key.per_byte", MUL], + [.signature.ed25519_validate_key.base, "signature.ed25519_verify.base", 61 * MUL], + [.signature.ed25519_validate_key.per_byte, optional "signature.ed25519_verify.per_byte", MUL], + [.account.create_signer.base, "account.create_signer.base", 24 * MUL], [.account.destroy_signer.base, "account.destroy_signer.base", 212* MUL], - [.hash.keccak256.base, "hash.keccak256.base", 64 * MUL], - [.hash.keccak256.per_byte, optional "hash.keccak256.per_byte", MUL], + [.hash.ripemd160.base, "hash.ripemd160.base", 64 * MUL], [.hash.ripemd160.per_byte, optional "hash.ripemd160.per_byte", MUL], - [.signature.ed25519_validate_key.base, "signature.ed25519_validate_key.base", 26 * MUL], - [.signature.ed25519_validate_key.per_byte, optional "signature.ed25519_validate_key.per_byte", MUL], - [.signature.ed25519_verify.base, "signature.ed25519_verify.base", 61 * MUL], - [.signature.ed25519_verify.per_byte, optional "signature.ed25519_verify.per_byte", MUL], - [.signature.ec_recover.base, "signature.ec_recover.base", 128 * MUL], + [.hash.keccak256.base, "hash.keccak256.base", 64 * MUL], + [.hash.keccak256.per_byte, optional "hash.keccak256.per_byte", MUL], + [.hash.keccak256.base, "hash.ec_recover.base", 128 * MUL], [.token.token_name_of.base, "token.token_name_of.base", 2002 * MUL], + [.u256.add.base, "u256.add.base", 4 * MUL], [.u256.sub.base, "u256.sub.base", 4 * MUL], [.u256.mul.base, "u256.mul.base", 4 * MUL], [.u256.div.base, "u256.div.base", 4 * MUL], [.u256.rem.base, "u256.rem.base", 4 * MUL], [.u256.pow.base, "u256.pow.base", 4 * MUL], - [.u256.from_bytes.base, optional "u256.from_bytes.base", 4 * MUL], + [.u256.from_bytes.base, "u256.from_bytes.base", 4 * MUL], ]); diff --git a/vm/gas-algebra-ext/src/table.rs b/vm/gas-algebra-ext/src/table.rs index 052b175171..9d06f9a088 100644 --- a/vm/gas-algebra-ext/src/table.rs +++ b/vm/gas-algebra-ext/src/table.rs @@ -11,21 +11,21 @@ crate::natives::define_gas_parameters_for_natives!(GasParameters, "table", [ [.common.load_per_byte, "common.load.per_byte", 1000], [.common.load_failure, "common.load.failure", 0], - [.new_table_handle.base, "new_table_handle.base", 1000 * MUL], + [.new_table_handle.base, "new_table_handle.base", 4 * MUL], - [.add_box.base, "add_box.base", 1200 * MUL], - [.add_box.per_byte_serialized, "add_box.per_byte_serialized", 10 * MUL], + [.add_box.base, "add_box.base", 4 * MUL], + [.add_box.per_byte_serialized, "add_box.per_byte_serialized", MUL], - [.borrow_box.base, "borrow_box.base", 1200 * MUL], - [.borrow_box.per_byte_serialized, "borrow_box.per_byte_serialized", 10 * MUL], + [.borrow_box.base, "borrow_box.base", 4 * MUL], + [.borrow_box.per_byte_serialized, "borrow_box.per_byte_serialized", MUL], - [.contains_box.base, "contains_box.base", 1200 * MUL], - [.contains_box.per_byte_serialized, "contains_box.per_byte_serialized", 10 * MUL], + [.contains_box.base, "contains_box.base", 4 * MUL], + [.contains_box.per_byte_serialized, "contains_box.per_byte_serialized", MUL], - [.remove_box.base, "remove_box.base", 1200 * MUL], - [.remove_box.per_byte_serialized, "remove_box.per_byte_serialized", 10 * MUL], + [.remove_box.base, "remove_box.base", 4 * MUL], + [.remove_box.per_byte_serialized, "remove_box.per_byte_serialized", MUL], - [.destroy_empty_box.base, "destroy_empty_box.base", 1200 * MUL], + [.destroy_empty_box.base, "destroy_empty_box.base", 4 * MUL], - [.drop_unchecked_box.base, "drop_unchecked_box.base", 100 * MUL], + [.drop_unchecked_box.base, "drop_unchecked_box.base", 4 * MUL], ]); diff --git a/vm/move-coverage/Cargo.toml b/vm/move-coverage/Cargo.toml index d9237c7764..5b404c233e 100644 --- a/vm/move-coverage/Cargo.toml +++ b/vm/move-coverage/Cargo.toml @@ -18,9 +18,9 @@ codespan = {version = "0.8.0", features = ["serialization"]} colored = "2.0.0" petgraph = "0.5.1" serde = {version = "1.0.130", default-features = false} -move-bytecode-source-map = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-coverage = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-bytecode-source-map = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-coverage = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } [features] default = [] diff --git a/vm/move-explain/Cargo.toml b/vm/move-explain/Cargo.toml index 5f5f2db18c..af3d755ef7 100644 --- a/vm/move-explain/Cargo.toml +++ b/vm/move-explain/Cargo.toml @@ -12,7 +12,7 @@ version = "1.12.5" [dependencies] clap = { version = "3", features = ["derive"] } stdlib = { package = "stdlib", path = "../stdlib" } -move-core-types = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-core-types = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } bcs-ext = { package = "bcs-ext", path = "../../commons/bcs_ext" } [features] diff --git a/vm/move-package-manager/Cargo.toml b/vm/move-package-manager/Cargo.toml index 22c1369b60..fdfec6976c 100644 --- a/vm/move-package-manager/Cargo.toml +++ b/vm/move-package-manager/Cargo.toml @@ -34,19 +34,20 @@ jsonrpc-client-transports = { version = "18", features = [ futures = "0.3" tokio = { version = "^1", features = ["full"] } tempfile = "~3" -move-cli = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-package = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-bytecode-verifier = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-disassembler = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-errmapgen = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-coverage = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-compiler = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-core-types = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-vm-runtime = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-cli = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-package = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-bytecode-verifier = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-disassembler = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-errmapgen = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-coverage = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-compiler = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-core-types = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-vm-runtime = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } resource-viewer = { path = "../resource-viewer", package = "starcoin-resource-viewer" } -move-unit-test = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95", features = ["table-extension"] } -move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-unit-test = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2", features = ["table-extension"] } +move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-vm-test-utils = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } datatest-stable = { git = "https://github.com/starcoinorg/diem-devtools", branch = "feature/pub-test-opts" } starcoin-vm-types = { path = "../../vm/types" } starcoin-logger = { path = "../../commons/logger" } diff --git a/vm/move-package-manager/src/main.rs b/vm/move-package-manager/src/main.rs index b2b7a82409..36a7d68cbc 100644 --- a/vm/move-package-manager/src/main.rs +++ b/vm/move-package-manager/src/main.rs @@ -12,8 +12,10 @@ use move_package_manager::compatibility_check_cmd::{ use move_package_manager::deployment::{handle_deployment, DeploymentCommand}; use move_package_manager::release::{handle_release, Release}; use move_package_manager::{run_integration_test, IntegrationTestCommand}; +use move_vm_test_utils::gas_schedule::CostTable; +use starcoin_config::genesis_config::G_LATEST_GAS_PARASM; use starcoin_vm_runtime::natives::starcoin_natives; -use starcoin_vm_types::gas_schedule::G_LATEST_GAS_SCHEDULE; +use starcoin_vm_types::on_chain_config::G_LATEST_INSTRUCTION_TABLE; use std::path::PathBuf; #[derive(Parser)] @@ -78,28 +80,31 @@ fn main() -> Result<()> { let args: CliOptions = CliOptions::parse(); let move_args = &args.move_args; - // let natives = starcoin_natives(starcoin_gas::NativeGasParameters::zeros()); + let gas_params = G_LATEST_GAS_PARASM.clone(); + let natives = starcoin_natives(gas_params.natives); + let cost_table = CostTable { + instruction_table: G_LATEST_INSTRUCTION_TABLE.clone(), + }; match args.cmd { Commands::IntegrationTest(cmd) => run_integration_test(args.move_args, cmd), - // XXX FIXME YSG + // XXX FIXME YSG, no Package command /* Commands::Package { cmd } => handle_package_commands( &move_args.package_path, move_args.build_config.clone(), &cmd, natives, - ), + ),*/ Commands::Sandbox { storage_dir, cmd } => cmd.handle_command( natives, - &G_LATEST_GAS_SCHEDULE, + &cost_table, &error_descriptions, move_args, &storage_dir, - ),*/ + ), Commands::Experimental { storage_dir, cmd } => cmd.handle_command(move_args, &storage_dir), Commands::Release(release) => handle_release(move_args, release), Commands::CompatibilityCheck(cmd) => handle_compatibility_check(move_args, cmd), Commands::Deploy(cmd) => handle_deployment(move_args, cmd), - _ => Ok(()), } } diff --git a/vm/move-package-manager/src/release.rs b/vm/move-package-manager/src/release.rs index 617c940c9c..ac9ae291d2 100644 --- a/vm/move-package-manager/src/release.rs +++ b/vm/move-package-manager/src/release.rs @@ -64,7 +64,7 @@ pub fn handle_release( let pkg_version = move_args .build_config .clone() - .resolution_graph_for_package(&move_args.package_path.as_ref().unwrap()) + .resolution_graph_for_package(move_args.package_path.as_ref().unwrap()) .unwrap() .root_package .package diff --git a/vm/move-prover/Cargo.toml b/vm/move-prover/Cargo.toml index c33a1ee363..c7b1b4d2c2 100644 --- a/vm/move-prover/Cargo.toml +++ b/vm/move-prover/Cargo.toml @@ -8,7 +8,7 @@ version = "1.12.5" [dependencies] ## move dependencies -move-prover = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-prover = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } # external dependencies anyhow = "1.0.41" @@ -18,8 +18,8 @@ tempfile = "3.2.0" [dev-dependencies] datatest-stable = "0.1.1" -move-prover-test-utils = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-prover-test-utils = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } shell-words = "1.0.0" walkdir = "2.3" once_cell = "1.13.0" diff --git a/vm/natives/Cargo.toml b/vm/natives/Cargo.toml index 5214f31f29..1bea753243 100644 --- a/vm/natives/Cargo.toml +++ b/vm/natives/Cargo.toml @@ -7,15 +7,15 @@ version = "1.12.5" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -move-errmapgen = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-docgen = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-prover = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-stdlib = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-vm-types = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-vm-runtime = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-core-types = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-errmapgen = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-docgen = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-prover = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-stdlib = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-vm-types = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-vm-runtime = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-core-types = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } starcoin-crypto = { git = "https://github.com/starcoinorg/starcoin-crypto", rev = "d871dfb4216f034ee334a575926c101574d9d6dc" } log = "0.4.14" walkdir = "2.3.1" @@ -25,7 +25,7 @@ libsecp256k1 = "0.7.1" arrayref = "0.3" num_enum = "0.5.7" starcoin-uint = { path = "../../types/uint" } -move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } ripemd160 = "0.9.1" [dev-dependencies] diff --git a/vm/resource-viewer/Cargo.toml b/vm/resource-viewer/Cargo.toml index 8bb7a6717e..8b40a8e767 100644 --- a/vm/resource-viewer/Cargo.toml +++ b/vm/resource-viewer/Cargo.toml @@ -8,8 +8,8 @@ version = "1.12.5" [dependencies] starcoin-vm-types = { path = "../types" } -move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-core-types = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-core-types = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } serde_json = "1.0" serde = { version = "1.0.130", features = ["derive", "rc"] } anyhow = "1.0.41" diff --git a/vm/starcoin-gas/Cargo.toml b/vm/starcoin-gas/Cargo.toml index 36af5d096c..71aeb910ed 100644 --- a/vm/starcoin-gas/Cargo.toml +++ b/vm/starcoin-gas/Cargo.toml @@ -9,9 +9,9 @@ version = "1.12.5" [dependencies] gas-algebra-ext = { path = "../gas-algebra-ext" } clap = { version = "3", features = ["derive"] } -move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-core-types = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-stdlib = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-vm-types = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-core-types = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-stdlib = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-vm-types = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } starcoin-natives = { path = "../natives" } \ No newline at end of file diff --git a/vm/starcoin-gas/src/gas_meter.rs b/vm/starcoin-gas/src/gas_meter.rs index 5b1d2fd39f..79bd7ca498 100644 --- a/vm/starcoin-gas/src/gas_meter.rs +++ b/vm/starcoin-gas/src/gas_meter.rs @@ -37,15 +37,16 @@ use gas_algebra_ext::TransactionGasParameters; #[derive(Debug, Clone)] pub struct NativeGasParameters { pub move_stdlib: move_stdlib::natives::GasParameters, + pub nursery: move_stdlib::natives::NurseryGasParameters, pub starcoin_natives: starcoin_natives::GasParameters, pub table: move_table_extension::GasParameters, - // XXX FIXME YSG add nursely } impl FromOnChainGasSchedule for NativeGasParameters { fn from_on_chain_gas_schedule(gas_schedule: &BTreeMap) -> Option { Some(Self { move_stdlib: FromOnChainGasSchedule::from_on_chain_gas_schedule(gas_schedule)?, + nursery: FromOnChainGasSchedule::from_on_chain_gas_schedule(gas_schedule)?, starcoin_natives: FromOnChainGasSchedule::from_on_chain_gas_schedule(gas_schedule)?, table: FromOnChainGasSchedule::from_on_chain_gas_schedule(gas_schedule)?, }) @@ -55,6 +56,7 @@ impl FromOnChainGasSchedule for NativeGasParameters { impl ToOnChainGasSchedule for NativeGasParameters { fn to_on_chain_gas_schedule(&self) -> Vec<(String, u64)> { let mut entries = self.move_stdlib.to_on_chain_gas_schedule(); + entries.extend(self.nursery.to_on_chain_gas_schedule()); entries.extend(self.starcoin_natives.to_on_chain_gas_schedule()); entries.extend(self.table.to_on_chain_gas_schedule()); entries @@ -65,6 +67,7 @@ impl NativeGasParameters { pub fn zeros() -> Self { Self { move_stdlib: move_stdlib::natives::GasParameters::zeros(), + nursery: move_stdlib::natives::NurseryGasParameters::zeros(), starcoin_natives: starcoin_natives::GasParameters::zeros(), table: move_table_extension::GasParameters::zeros(), } @@ -75,6 +78,7 @@ impl InitialGasSchedule for NativeGasParameters { fn initial() -> Self { Self { move_stdlib: InitialGasSchedule::initial(), + nursery: InitialGasSchedule::initial(), starcoin_natives: InitialGasSchedule::initial(), table: InitialGasSchedule::initial(), } @@ -110,6 +114,8 @@ impl ToOnChainGasSchedule for StarcoinGasParameters { } impl StarcoinGasParameters { + // Only used for genesis and for tests where we need a cost table and + // don't have a genesis storage state. pub fn zeros() -> Self { Self { instr: InstructionGasParameters::zeros(), @@ -185,171 +191,171 @@ impl StarcoinGasMeter { } } -// XXX FIXME YSG +// XXX FIXME YSG, wheather need see language/move-vm/test-utils/src/gas_schedule.rs impl GasMeter for StarcoinGasMeter { - fn charge_simple_instr(&mut self, instr: SimpleInstruction) -> PartialVMResult<()> { - todo!() + fn charge_simple_instr(&mut self, _instr: SimpleInstruction) -> PartialVMResult<()> { + Ok(()) } fn charge_call( &mut self, - module_id: &ModuleId, - func_name: &str, - args: impl ExactSizeIterator, + _module_id: &ModuleId, + _func_name: &str, + _args: impl ExactSizeIterator, ) -> PartialVMResult<()> { - todo!() + Ok(()) } fn charge_call_generic( &mut self, - module_id: &ModuleId, - func_name: &str, - ty_args: impl ExactSizeIterator, - args: impl ExactSizeIterator, + _module_id: &ModuleId, + _func_name: &str, + _ty_args: impl ExactSizeIterator, + _args: impl ExactSizeIterator, ) -> PartialVMResult<()> { - todo!() + Ok(()) } - fn charge_ld_const(&mut self, size: NumBytes) -> PartialVMResult<()> { - todo!() + fn charge_ld_const(&mut self, _size: NumBytes) -> PartialVMResult<()> { + Ok(()) } - fn charge_copy_loc(&mut self, val: impl ValueView) -> PartialVMResult<()> { - todo!() + fn charge_copy_loc(&mut self, _val: impl ValueView) -> PartialVMResult<()> { + Ok(()) } - fn charge_move_loc(&mut self, val: impl ValueView) -> PartialVMResult<()> { - todo!() + fn charge_move_loc(&mut self, _val: impl ValueView) -> PartialVMResult<()> { + Ok(()) } - fn charge_store_loc(&mut self, val: impl ValueView) -> PartialVMResult<()> { - todo!() + fn charge_store_loc(&mut self, _val: impl ValueView) -> PartialVMResult<()> { + Ok(()) } fn charge_pack( &mut self, - is_generic: bool, - args: impl ExactSizeIterator, + _is_generic: bool, + _args: impl ExactSizeIterator, ) -> PartialVMResult<()> { - todo!() + Ok(()) } fn charge_unpack( &mut self, - is_generic: bool, - args: impl ExactSizeIterator, + _is_generic: bool, + _args: impl ExactSizeIterator, ) -> PartialVMResult<()> { - todo!() + Ok(()) } - fn charge_read_ref(&mut self, val: impl ValueView) -> PartialVMResult<()> { - todo!() + fn charge_read_ref(&mut self, _val: impl ValueView) -> PartialVMResult<()> { + Ok(()) } - fn charge_write_ref(&mut self, val: impl ValueView) -> PartialVMResult<()> { - todo!() + fn charge_write_ref(&mut self, _val: impl ValueView) -> PartialVMResult<()> { + Ok(()) } - fn charge_eq(&mut self, lhs: impl ValueView, rhs: impl ValueView) -> PartialVMResult<()> { - todo!() + fn charge_eq(&mut self, _lhs: impl ValueView, _rhs: impl ValueView) -> PartialVMResult<()> { + Ok(()) } - fn charge_neq(&mut self, lhs: impl ValueView, rhs: impl ValueView) -> PartialVMResult<()> { - todo!() + fn charge_neq(&mut self, _lhs: impl ValueView, _rhs: impl ValueView) -> PartialVMResult<()> { + Ok(()) } fn charge_borrow_global( &mut self, - is_mut: bool, - is_generic: bool, - ty: impl TypeView, - is_success: bool, + _is_mut: bool, + _is_generic: bool, + _ty: impl TypeView, + _is_success: bool, ) -> PartialVMResult<()> { - todo!() + Ok(()) } fn charge_exists( &mut self, - is_generic: bool, - ty: impl TypeView, - exists: bool, + _is_generic: bool, + _ty: impl TypeView, + _exists: bool, ) -> PartialVMResult<()> { - todo!() + Ok(()) } fn charge_move_from( &mut self, - is_generic: bool, - ty: impl TypeView, - val: Option, + _is_generic: bool, + _ty: impl TypeView, + _val: Option, ) -> PartialVMResult<()> { - todo!() + Ok(()) } fn charge_move_to( &mut self, - is_generic: bool, - ty: impl TypeView, - val: impl ValueView, - is_success: bool, + _is_generic: bool, + _ty: impl TypeView, + _val: impl ValueView, + _is_success: bool, ) -> PartialVMResult<()> { - todo!() + Ok(()) } fn charge_vec_pack<'a>( &mut self, - ty: impl TypeView + 'a, - args: impl ExactSizeIterator, + _ty: impl TypeView + 'a, + _args: impl ExactSizeIterator, ) -> PartialVMResult<()> { - todo!() + Ok(()) } - fn charge_vec_len(&mut self, ty: impl TypeView) -> PartialVMResult<()> { - todo!() + fn charge_vec_len(&mut self, _ty: impl TypeView) -> PartialVMResult<()> { + Ok(()) } fn charge_vec_borrow( &mut self, - is_mut: bool, - ty: impl TypeView, - is_success: bool, + _is_mut: bool, + _ty: impl TypeView, + _is_success: bool, ) -> PartialVMResult<()> { - todo!() + Ok(()) } fn charge_vec_push_back( &mut self, - ty: impl TypeView, - val: impl ValueView, + _ty: impl TypeView, + _val: impl ValueView, ) -> PartialVMResult<()> { - todo!() + Ok(()) } fn charge_vec_pop_back( &mut self, - ty: impl TypeView, - val: Option, + _ty: impl TypeView, + _val: Option, ) -> PartialVMResult<()> { - todo!() + Ok(()) } fn charge_vec_unpack( &mut self, - ty: impl TypeView, - expect_num_elements: NumArgs, + _ty: impl TypeView, + _expect_num_elements: NumArgs, ) -> PartialVMResult<()> { - todo!() + Ok(()) } - fn charge_vec_swap(&mut self, ty: impl TypeView) -> PartialVMResult<()> { - todo!() + fn charge_vec_swap(&mut self, _ty: impl TypeView) -> PartialVMResult<()> { + Ok(()) } - fn charge_load_resource(&mut self, loaded: Option) -> PartialVMResult<()> { - todo!() + fn charge_load_resource(&mut self, _loaded: Option) -> PartialVMResult<()> { + Ok(()) } - fn charge_native_function(&mut self, amount: InternalGas) -> PartialVMResult<()> { - todo!() + fn charge_native_function(&mut self, _amount: InternalGas) -> PartialVMResult<()> { + Ok(()) } } diff --git a/vm/starcoin-transactional-test-harness/Cargo.toml b/vm/starcoin-transactional-test-harness/Cargo.toml index 1bf9963066..b2e5c62341 100644 --- a/vm/starcoin-transactional-test-harness/Cargo.toml +++ b/vm/starcoin-transactional-test-harness/Cargo.toml @@ -32,12 +32,12 @@ dashmap = "~5" serde = { version = "1" } serde_json = { version = "1" } log = { version = "0.4.16" } -move-transactional-test-runner = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-compiler = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-core-types = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-transactional-test-runner = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-compiler = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-core-types = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } bcs-ext = { path = "../../commons/bcs_ext" } starcoin-crypto = { git = "https://github.com/starcoinorg/starcoin-crypto", rev = "d871dfb4216f034ee334a575926c101574d9d6dc" } @@ -52,7 +52,7 @@ starcoin-rpc-api = { path = "../../rpc/api" } starcoin-vm-runtime = { path = "../../vm/vm-runtime" } starcoin-dev = { path = "../dev" } starcoin-resource-viewer = { path = "../resource-viewer" } -move-resource-viewer = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-resource-viewer = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } once_cell = "~1" tempfile = "3.2.0" async-trait = "0.1" diff --git a/vm/stdlib/Cargo.toml b/vm/stdlib/Cargo.toml index ab298d7696..28d8779a6c 100644 --- a/vm/stdlib/Cargo.toml +++ b/vm/stdlib/Cargo.toml @@ -8,13 +8,13 @@ version = "1.12.5" [dependencies] anyhow = "1.0.41" -move-bytecode-verifier = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-bytecode-verifier = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } starcoin-crypto = { git = "https://github.com/starcoinorg/starcoin-crypto", rev = "d871dfb4216f034ee334a575926c101574d9d6dc" } starcoin-vm-types = { path = "../types" } bcs-ext = { package = "bcs-ext", path = "../../commons/bcs_ext" } starcoin-move-compiler = { path = "../../vm/compiler" } -move-prover = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-compiler = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-prover = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-compiler = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } once_cell = "1.13.0" clap = {version = "3", features = ["derive"]} fs_extra = "1.2.0" diff --git a/vm/transaction-builder-generator/Cargo.toml b/vm/transaction-builder-generator/Cargo.toml index 0fe5e86edd..4757b109a6 100644 --- a/vm/transaction-builder-generator/Cargo.toml +++ b/vm/transaction-builder-generator/Cargo.toml @@ -18,7 +18,7 @@ serde_yaml = "0.8.26" serde-generate = { git = "https://github.com/starcoinorg/serde-reflection", rev = "694048797338ff7385006d968e786b6d9dbdeb8b" } serde-reflection = { git = "https://github.com/starcoinorg/serde-reflection", rev = "694048797338ff7385006d968e786b6d9dbdeb8b" } starcoin-vm-types = { path = "../types" } -move-core-types = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-core-types = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } bcs = "0.1.3" [dev-dependencies] tempfile = "3.2.0" diff --git a/vm/types/Cargo.toml b/vm/types/Cargo.toml index 76e3f2f438..e1e01a647e 100644 --- a/vm/types/Cargo.toml +++ b/vm/types/Cargo.toml @@ -21,12 +21,12 @@ serde-helpers = { path = "../../commons/serde-helpers" } chrono = { version = "0.4.19", default-features = false, features = ["clock"] } proptest = { version = "1.0.0", default-features = false, optional = true } proptest-derive = { version = "0.3.0", default-features = false, optional = true } -move-core-types = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-vm-types = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-bytecode-verifier = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -vm = { package = "move-binary-format", git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-ir-types = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-core-types = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-vm-types = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-bytecode-verifier = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +vm = { package = "move-binary-format", git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-ir-types = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } serde_json = {version = "1.0", features = ["arbitrary_precision"]} starcoin-time-service = {path = "../../commons/time-service", optional = true} bcs-ext = {package = "bcs-ext", path = "../../commons/bcs_ext"} @@ -40,7 +40,7 @@ gas-algebra-ext = { path = "../gas-algebra-ext" } [dev-dependencies] proptest = "1.0.0" proptest-derive = "0.3.0" -vm = { package = "move-binary-format", git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95", features = [ +vm = { package = "move-binary-format", git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2", features = [ "fuzzing", ] } starcoin-crypto = { git = "https://github.com/starcoinorg/starcoin-crypto", rev = "d871dfb4216f034ee334a575926c101574d9d6dc" } diff --git a/vm/types/src/on_chain_config/gas_schedule.rs b/vm/types/src/on_chain_config/gas_schedule.rs index feb29a88af..e4b7f62fc7 100644 --- a/vm/types/src/on_chain_config/gas_schedule.rs +++ b/vm/types/src/on_chain_config/gas_schedule.rs @@ -2,7 +2,7 @@ use crate::on_chain_config::{OnChainConfig, VMConfig}; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; -#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)] pub struct GasSchedule { pub entries: Vec<(String, u64)>, } @@ -105,7 +105,10 @@ pub fn native_gas_schedule_v1() -> BTreeMap { BTreeMap::from([ ("move_stdlib.hash.sha2_256.base".to_string(), 21), ("move_stdlib.hash.sha3_256.base".to_string(), 64), - ("starcoin_natives.signature.ed25519_verify.base".to_string(), 61), + ( + "starcoin_natives.signature.ed25519_verify.base".to_string(), + 61, + ), // ED25519_THRESHOLD_VERIFY 3 this native funciton is deprecated ( "move_stdlib.bcs.to_bytes.per_byte_serialized".to_string(), @@ -118,7 +121,10 @@ pub fn native_gas_schedule_v1() -> BTreeMap { ("move_stdlib.vec.pop_back.base".to_string(), 227), ("move_stdlib.vec.destroy_empty.base".to_string(), 572), ("move_stdlib.vec.swap.base".to_string(), 1436), - ("starcoin_natives.signature.ed25519_validate_key.base".to_string(),26), + ( + "starcoin_natives.signature.ed25519_validate_key.base".to_string(), + 26, + ), ("move_stdlib.signer.borrow_address.base".to_string(), 353), ( "starcoin_natives.account.create_signer.base".to_string(), @@ -133,7 +139,10 @@ pub fn native_gas_schedule_v1() -> BTreeMap { 52, ), ("move_stdlib.bcs.to_address.base".to_string(), 26), - ("starcoin_natives.token.token_name_of.base".to_string(), 2002), + ( + "starcoin_natives.token.token_name_of.base".to_string(), + 2002, + ), ]) } @@ -168,7 +177,7 @@ pub fn native_gas_schedule_v3() -> BTreeMap { } // v4_native_table -pub fn move_stdlib_native_gas_schedule_v4() -> BTreeMap { +pub fn native_gas_schedule_v4() -> BTreeMap { let mut natives = native_gas_schedule_v3(); let mut natives_delta = BTreeMap::from([ ("table.new_table_handle.base".to_string(), 4), @@ -276,7 +285,8 @@ impl OnChainConfig for GasSchedule { const CONF_IDENTIFIER: &'static str = "GasScheduleConfig"; } -// XXX FIXME YSG +// XXX FIXME YSG, see genesis_gas_schedule.rs gas-algebra-ext/{instr.rs move_stdlib.rs nursery.rs starcoin_framework.rs} +// https://github.com/starcoinorg/starcoin-framework/blob/main/sources/VMConfig.move impl From for GasSchedule { fn from(_vm_config: VMConfig) -> Self { let entries: Vec<(String, u64)> = vec![("hello".to_owned(), 1)]; diff --git a/vm/types/src/on_chain_config/genesis_gas_schedule.rs b/vm/types/src/on_chain_config/genesis_gas_schedule.rs index 7125b60239..55d84b96eb 100644 --- a/vm/types/src/on_chain_config/genesis_gas_schedule.rs +++ b/vm/types/src/on_chain_config/genesis_gas_schedule.rs @@ -331,6 +331,7 @@ pub fn native_table_v2() -> Vec { .collect::>() } +#[allow(dead_code)] pub fn v3_native_table() -> Vec { let mut raw_native_table = vec![ (N::SHA2_256, GasCost::new(21, 1)), diff --git a/vm/types/src/on_chain_config/mod.rs b/vm/types/src/on_chain_config/mod.rs index 40d469c06c..5aaef24afb 100644 --- a/vm/types/src/on_chain_config/mod.rs +++ b/vm/types/src/on_chain_config/mod.rs @@ -28,10 +28,10 @@ pub use self::{ consensus_config::{consensus_config_type_tag, ConsensusConfig, G_CONSENSUS_CONFIG_IDENTIFIER}, dao_config::DaoConfig, gas_schedule::{ - instruction_gas_schedule_v1, instruction_gas_schedule_v2, - move_stdlib_native_gas_schedule_v4, native_gas_schedule_v1, native_gas_schedule_v2, - native_gas_schedule_v3, txn_gas_schedule_test, txn_gas_schedule_v1, txn_gas_schedule_v2, - txn_gas_schedule_v3, GasSchedule, + instruction_gas_schedule_v1, instruction_gas_schedule_v2, native_gas_schedule_v1, + native_gas_schedule_v2, native_gas_schedule_v3, native_gas_schedule_v4, + txn_gas_schedule_test, txn_gas_schedule_v1, txn_gas_schedule_v2, txn_gas_schedule_v3, + GasSchedule, }, genesis_gas_schedule::{ instruction_table_v1, instruction_table_v2, native_table_v1, native_table_v2, diff --git a/vm/types/src/on_chain_config/vm_config.rs b/vm/types/src/on_chain_config/vm_config.rs index d7e97f763d..97dff38b44 100644 --- a/vm/types/src/on_chain_config/vm_config.rs +++ b/vm/types/src/on_chain_config/vm_config.rs @@ -81,7 +81,7 @@ impl OnChainConfig for TransactionPublishOption { } /// Defines all the on chain configuration data needed by VM. -#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)] #[allow(clippy::upper_case_acronyms)] pub struct VMConfig { pub gas_schedule: CostTable, diff --git a/vm/vm-runtime/Cargo.toml b/vm/vm-runtime/Cargo.toml index f69178bdf5..afa6ce2d0a 100644 --- a/vm/vm-runtime/Cargo.toml +++ b/vm/vm-runtime/Cargo.toml @@ -10,10 +10,10 @@ version = "1.12.5" anyhow = "1.0.41" once_cell = "1.13.0" starcoin-types = { path = "../../types" } -move-core-types = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-vm-runtime = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-stdlib = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } -move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "e2282776b8a6642a68e7ac1a0c819bda76d64d95" } +move-core-types = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-vm-runtime = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-stdlib = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } +move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "54a90b627e38875bda8b8b4809faa21e88df10a2" } tracing = "0.1.34" starcoin-config = { path = "../../config" } starcoin-logger = { path = "../../commons/logger" } diff --git a/vm/vm-runtime/src/data_cache.rs b/vm/vm-runtime/src/data_cache.rs index c61349cca6..00ea636155 100644 --- a/vm/vm-runtime/src/data_cache.rs +++ b/vm/vm-runtime/src/data_cache.rs @@ -5,10 +5,10 @@ use crate::create_access_path; use anyhow::Error; use move_core_types::resolver::{ModuleResolver, ResourceResolver}; -use move_table_extension::{TableHandle, TableOperation, TableResolver}; +use move_table_extension::{TableHandle, TableResolver}; use starcoin_logger::prelude::*; use starcoin_types::account_address::AccountAddress; -use starcoin_vm_types::state_store::state_key::{StateKey, TableItem}; +use starcoin_vm_types::state_store::state_key::StateKey; use starcoin_vm_types::{ access_path::AccessPath, errors::*, diff --git a/vm/vm-runtime/src/move_vm_ext/session.rs b/vm/vm-runtime/src/move_vm_ext/session.rs index e6925da53e..c427d4c188 100644 --- a/vm/vm-runtime/src/move_vm_ext/session.rs +++ b/vm/vm-runtime/src/move_vm_ext/session.rs @@ -16,7 +16,7 @@ use starcoin_vm_types::state_store::state_key::StateKey; use starcoin_vm_types::transaction::SignatureCheckedTransaction; use starcoin_vm_types::transaction_metadata::TransactionMetadata; use starcoin_vm_types::write_set::{WriteOp, WriteSet, WriteSetMut}; -use std::convert::{TryFrom, TryInto}; +use std::convert::TryFrom; #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, CryptoHasher, CryptoHash)] pub enum SessionId { diff --git a/vm/vm-runtime/src/move_vm_ext/vm.rs b/vm/vm-runtime/src/move_vm_ext/vm.rs index b2c1cb914b..73863101df 100644 --- a/vm/vm-runtime/src/move_vm_ext/vm.rs +++ b/vm/vm-runtime/src/move_vm_ext/vm.rs @@ -30,9 +30,7 @@ impl MoveVmExt { session_id: SessionId, ) -> Session<'r, '_, S> { let mut extensions = NativeContextExtensions::default(); - // XXX FIXME YSG extensions.add(NativeTableContext::new(*session_id.as_uuid(), remote)); - self.inner.new_session_with_extensions(remote, extensions) } } diff --git a/vm/vm-runtime/src/natives.rs b/vm/vm-runtime/src/natives.rs index 8de6bc65b6..48b452d84d 100644 --- a/vm/vm-runtime/src/natives.rs +++ b/vm/vm-runtime/src/natives.rs @@ -1,10 +1,7 @@ // Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 -use move_core_types::identifier::Identifier; use move_core_types::language_storage::CORE_CODE_ADDRESS; -use move_vm_runtime::native_functions::{ - make_table_from_iter, NativeFunction, NativeFunctionTable, -}; +use move_vm_runtime::native_functions::{make_table_from_iter, NativeFunctionTable}; use starcoin_gas::NativeGasParameters; /// The function returns all native functions supported by Starcoin. @@ -12,7 +9,6 @@ use starcoin_gas::NativeGasParameters; /// - mostly re-use natives defined in move-stdlib. /// - be careful with the native cost table index used in the implementation pub fn starcoin_natives(gas_params: NativeGasParameters) -> NativeFunctionTable { - // XXX FIXME YSG let mut natives = vec![]; macro_rules! add_natives_from_module { @@ -70,12 +66,10 @@ pub fn starcoin_natives(gas_params: NativeGasParameters) -> NativeFunctionTable ); let natives = make_table_from_iter(CORE_CODE_ADDRESS, natives); natives - .into_iter(). - chain( - move_stdlib::natives::nursery_natives( + .into_iter() + .chain(move_stdlib::natives::nursery_natives( CORE_CODE_ADDRESS, - // XXX FIXME YSG - move_stdlib::natives::NurseryGasParameters::zeros(), + gas_params.nursery, )) .chain(move_table_extension::table_natives( CORE_CODE_ADDRESS, diff --git a/vm/vm-runtime/src/starcoin_vm.rs b/vm/vm-runtime/src/starcoin_vm.rs index 2d342a34b9..6193aa8643 100644 --- a/vm/vm-runtime/src/starcoin_vm.rs +++ b/vm/vm-runtime/src/starcoin_vm.rs @@ -9,11 +9,11 @@ use crate::errors::{ use crate::move_vm_ext::{MoveResolverExt, MoveVmExt, SessionId, SessionOutput}; use anyhow::{format_err, Error, Result}; use gas_algebra_ext::{CostTable, FromOnChainGasSchedule, Gas, GasConstants, GasCost}; -use move_core_types::gas_algebra::{GasQuantity, InternalGas, InternalGasPerByte, NumBytes}; +use move_core_types::gas_algebra::{InternalGasPerByte, NumBytes}; use move_table_extension::NativeTableContext; use move_vm_runtime::move_vm_adapter::{PublishModuleBundleOption, SessionAdapter}; use move_vm_runtime::session::Session; -use once_cell::sync::Lazy; +use starcoin_config::genesis_config::G_LATEST_GAS_PARASM; use starcoin_crypto::HashValue; use starcoin_gas::{StarcoinGasMeter, StarcoinGasParameters}; use starcoin_logger::prelude::*; @@ -38,7 +38,6 @@ use starcoin_vm_types::account_config::{ G_EPILOGUE_NAME, G_EPILOGUE_V2_NAME, G_PROLOGUE_NAME, }; use starcoin_vm_types::file_format::{CompiledModule, CompiledScript}; -use starcoin_vm_types::gas_schedule::NativeCostIndex; use starcoin_vm_types::gas_schedule::G_LATEST_GAS_SCHEDULE; use starcoin_vm_types::genesis_config::StdlibVersion; use starcoin_vm_types::identifier::IdentStr; @@ -55,7 +54,6 @@ use starcoin_vm_types::value::{serialize_values, MoveValue}; use starcoin_vm_types::vm_status::KeptVMStatus; use starcoin_vm_types::{ errors::Location, - gas_schedule, language_storage::TypeTag, on_chain_config::{OnChainConfig, VMConfig, Version}, state_view::StateView, @@ -68,12 +66,6 @@ use std::sync::Arc; #[cfg(feature = "metrics")] use crate::metrics::VMMetrics; -// XXX FIXME YSG - -/* -static G_ZERO_COST_SCHEDULE: Lazy = - Lazy::new(|| zero_cost_schedule(NativeCostIndex::NUMBER_OF_NATIVE_FUNCTIONS)); */ - #[derive(Clone)] #[allow(clippy::upper_case_acronyms)] /// Wrapper of MoveVM @@ -816,10 +808,7 @@ impl StarcoinVM { let txn_sender = account_config::genesis_address(); // always use 0 gas for system. let max_gas_amount: Gas = 0.into(); - // XXX FIXME YSG - // let cost_table = &G_ZERO_COST_SCHEDULE; - let gas_params = self.get_gas_parameters()?; - let mut gas_meter = StarcoinGasMeter::new(gas_params.clone(), max_gas_amount.clone()); + let mut gas_meter = StarcoinGasMeter::new(StarcoinGasParameters::zeros(), max_gas_amount); gas_meter.set_metering(false); let session_id = SessionId::block_meta(&block_metadata); let ( @@ -881,25 +870,16 @@ impl StarcoinVM { return discard_error_vm_status(e); } }; - // XXX FIXME YSG - /* - let gas_schedule = match self.get_gas_schedule() { - Ok(gas_schedule) => gas_schedule, + let gas_params = match self.get_gas_parameters() { + Ok(gas_params) => gas_params, Err(e) => { if remote_cache.is_genesis() { - &G_LATEST_GAS_SCHEDULE + &G_LATEST_GAS_PARASM } else { return discard_error_vm_status(e); } } }; - */ - let gas_params = match self.get_gas_parameters() { - Ok(gas_params) => gas_params, - Err(e) => { - return discard_error_vm_status(e); - } - }; let mut gas_meter = StarcoinGasMeter::new(gas_params.clone(), txn_data.max_gas_amount()); gas_meter.set_metering(false); @@ -963,19 +943,16 @@ impl StarcoinVM { let remote_cache = StateViewCache::new(state_view); //TODO load config by config change event. self.load_configs(&remote_cache)?; - - // XXX FIXME YSG - /* - let gas_schedule = match self.get_gas_schedule() { - Ok(gas_schedule) => gas_schedule, + let gas_params = match self.get_gas_parameters() { + Ok(gas_params) => gas_params, Err(e) => { if remote_cache.is_genesis() { - &G_LATEST_GAS_SCHEDULE + &G_LATEST_GAS_PARASM } else { return Ok(discard_error_vm_status(e)); } } - }; */ + }; let txn_data = match TransactionMetadata::from_raw_txn_and_preimage( &txn.raw_txn, txn.public_key.authentication_key_preimage(), @@ -983,7 +960,6 @@ impl StarcoinVM { Ok(txn_data) => txn_data, Err(e) => return Ok(discard_error_vm_status(e)), }; - let gas_params = self.get_gas_parameters()?; let mut gas_meter = StarcoinGasMeter::new(gas_params.clone(), txn_data.max_gas_amount()); gas_meter.set_metering(false); let result = match txn.raw_txn.payload() { @@ -1188,26 +1164,17 @@ impl StarcoinVM { ); return Err(VMStatus::Error(StatusCode::VM_STARTUP_FAILURE)); } - // XXX FIXME YSG - /* - let gas_constants = &self.get_gas_schedule()?.gas_constants; - let mut gas_meter = GasStatus::new( - &G_LATEST_GAS_SCHEDULE, - GasUnits::new(gas_constants.maximum_number_of_gas_units.get()), - );*/ let gas_params = self.get_gas_parameters()?; let mut gas_meter = StarcoinGasMeter::new( - gas_params.clone(), + G_LATEST_GAS_PARASM.clone(), gas_params.txn.maximum_number_of_gas_units, ); gas_meter.set_metering(true); gas_meter } else { - // let mut gas_meter = GasStatus::new(&G_ZERO_COST_SCHEDULE, GasUnits::new(0)); - // XXX FIXME YSG - let gas_params = self.get_gas_parameters()?; let max_gas_amount: Gas = 0.into(); - let mut gas_meter = StarcoinGasMeter::new(gas_params.clone(), max_gas_amount); + let mut gas_meter = + StarcoinGasMeter::new(StarcoinGasParameters::zeros(), max_gas_amount); gas_meter.set_metering(false); gas_meter }; @@ -1274,7 +1241,7 @@ impl StarcoinVM { txn_data: &TransactionMetadata, remote_cache: &StateViewCache<'_, S>, ) -> (VMStatus, TransactionOutput) { - // XXX FIXME YSG + // XXX FIXME YSG, confirm whether is right gas_meter.set_metering(false); let data_cache = remote_cache.as_move_resolver(); let mut session: SessionAdapter<_> = self @@ -1354,7 +1321,6 @@ pub fn chunk_block_transactions(txns: Vec) -> Vec blocks } -// XXX FIXME YSG pub(crate) fn charge_global_write_gas_usage( gas_meter: &mut StarcoinGasMeter, session: &SessionAdapter, @@ -1399,7 +1365,7 @@ pub(crate) fn get_transaction_output( max_gas_amount: Gas, status: KeptVMStatus, ) -> Result { - // XXX FIXME YSG, confirm these code + // original code use sub, now we use checked_sub let gas_used = max_gas_amount .checked_sub(gas_left) .expect("Balance should always be less than or equal to max gas amount");