Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Sep 23, 2024
1 parent 3d91925 commit 16eabd6
Show file tree
Hide file tree
Showing 18 changed files with 299 additions and 32 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/burner/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/crypto-verify/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/cyberpunk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/floaty/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/hackatom/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/ibc-reflect-send/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/ibc-reflect/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/queue/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/reflect/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/staking/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/virus/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 11 additions & 12 deletions packages/vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ repository = "https://github.com/CosmWasm/cosmwasm/tree/main/packages/vm"
license = "Apache-2.0"

[package.metadata.release]
pre-release-hook = [
"../../devtools/release_checks.sh"
]
pre-release-hook = ["../../devtools/release_checks.sh"]
pre-release-replacements = [
{ file="../../CHANGELOG.md", search="## \\[Unreleased\\]", replace="## [{{version}}] - {{date}}", exactly=1 },
{ file="../../CHANGELOG.md", search="(U|u)nreleased", replace="{{version}}" },
{ file="../../CHANGELOG.md", search="<!-- next-header -->", replace="<!-- next-header -->\n\n## [Unreleased]", exactly=1 },
{ file="../../CHANGELOG.md", search="\\.\\.\\.HEAD", replace="...{{tag_name}}", exactly=1 },
{ file="../../CHANGELOG.md", search="<!-- next-url -->\n", replace="<!-- next-url -->\n\n[unreleased]: https://github.com/CosmWasm/cosmwasm/compare/{{tag_name}}...HEAD", exactly=1 },
{ file = "../../CHANGELOG.md", search = "## \\[Unreleased\\]", replace = "## [{{version}}] - {{date}}", exactly = 1 },
{ file = "../../CHANGELOG.md", search = "(U|u)nreleased", replace = "{{version}}" },
{ file = "../../CHANGELOG.md", search = "<!-- next-header -->", replace = "<!-- next-header -->\n\n## [Unreleased]", exactly = 1 },
{ file = "../../CHANGELOG.md", search = "\\.\\.\\.HEAD", replace = "...{{tag_name}}", exactly = 1 },
{ file = "../../CHANGELOG.md", search = "<!-- next-url -->\n", replace = "<!-- next-url -->\n\n[unreleased]: https://github.com/CosmWasm/cosmwasm/compare/{{tag_name}}...HEAD", exactly = 1 },
]

[features]
Expand Down Expand Up @@ -47,7 +45,7 @@ allow_interface_version_7 = []
bench = false

[dependencies]
bytes = "1.4.0" # need a higher version than the one required by Wasmer for the Bytes -> Vec<u8> implementation
bytes = "1.4.0" # need a higher version than the one required by Wasmer for the Bytes -> Vec<u8> implementation
clru = "0.6.1"
crc32fast = "1.3.2"
# Uses the path when built locally; uses the given version from crates.io when published
Expand All @@ -61,13 +59,14 @@ serde_json = "1.0.40"
sha2 = "0.10.3"
thiserror = "1.0.26"
wasmer = { version = "=4.2.2", default-features = false, features = ["cranelift", "singlepass"] }
wasmer-types = "=4.2.2"
wasmer-middlewares = "=4.2.2"

# Dependencies that we do not use ourself. We add those entries
# to bump the min version of them.
bytecheck = "0.6.3" # With this version the simdutf8 dependency became optional
enumset = "1.0.2" # Fixes https://github.com/Lymia/enumset/issues/17 (https://github.com/Lymia/enumset/commit/a430550cd6a3c9b1ef636d37f75dede7616f5b62)
bitflags = "1.1.0" # https://github.com/CensoredUsername/dynasm-rs/pull/74
enumset = "1.0.2" # Fixes https://github.com/Lymia/enumset/issues/17 (https://github.com/Lymia/enumset/commit/a430550cd6a3c9b1ef636d37f75dede7616f5b62)
bitflags = "1.1.0" # https://github.com/CensoredUsername/dynasm-rs/pull/74

# Wasmer git/local (used for quick local debugging or patching)
# wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "877ce1f7c44fad853c", default-features = false, features = ["cranelift", "singlepass"] }
Expand All @@ -76,7 +75,7 @@ bitflags = "1.1.0" # https://github.com/CensoredUsername/dynasm-rs/pull/74
# wasmer-middlewares = { path = "../../../wasmer/lib/middlewares" }

[dev-dependencies]
criterion = { version = "0.4", features = [ "html_reports" ] }
criterion = { version = "0.4", features = ["html_reports"] }
glob = "0.3.1"
hex-literal = "0.3.1"
tempfile = "3.1.0"
Expand Down
8 changes: 4 additions & 4 deletions packages/vm/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ mod tests {

let report2 = instance.create_gas_report();
assert_eq!(report2.used_externally, 73);
assert_eq!(report2.used_internally, 10795970198);
assert_eq!(report2.used_internally, 13062390198);
assert_eq!(report2.limit, LIMIT);
assert_eq!(
report2.remaining,
Expand Down Expand Up @@ -1075,7 +1075,7 @@ mod tests {
.unwrap();

let init_used = orig_gas - instance.get_gas_left();
assert_eq!(init_used, 10795970271);
assert_eq!(init_used, 13062390271);
}

#[test]
Expand All @@ -1098,7 +1098,7 @@ mod tests {
.unwrap();

let execute_used = gas_before_execute - instance.get_gas_left();
assert_eq!(execute_used, 16039958606);
assert_eq!(execute_used, 19772973606);
}

#[test]
Expand Down Expand Up @@ -1132,6 +1132,6 @@ mod tests {
assert_eq!(answer.as_slice(), b"{\"verifier\":\"verifies\"}");

let query_used = gas_before_query - instance.get_gas_left();
assert_eq!(query_used, 8306910006);
assert_eq!(query_used, 9954975006);
}
}
16 changes: 12 additions & 4 deletions packages/vm/src/modules/file_system_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ use super::CachedModule;
/// Module compatibility between Wasmer versions is not guaranteed.
/// - **v9**:<br>
/// New version because of Metering middleware change.
const MODULE_SERIALIZATION_VERSION: &str = "v9";
/// - **v10**:<br>
/// Reserved for 2.0.x and 2.1.x branches.
/// - **v11**:<br>
/// New version because of Metering middleware change.
/// - **v12**:<br>
/// Reserved for 2.0.x branch.
/// - **v13**:<br>
/// Reserved for 2.1.x branch.
const MODULE_SERIALIZATION_VERSION: &str = "v11";

/// Representation of a directory that contains compiled Wasm artifacts.
pub struct FileSystemCache {
Expand Down Expand Up @@ -317,7 +325,7 @@ mod tests {
cache.store(&checksum, &module).unwrap();

let mut globber = glob::glob(&format!(
"{}/v9-wasmer5/**/{}.module",
"{}/v11-wasmer5/**/{}.module",
tmp_dir.path().to_string_lossy(),
checksum
))
Expand Down Expand Up @@ -400,9 +408,9 @@ mod tests {
assert_eq!(
p.as_os_str(),
if cfg!(windows) {
"modules\\v9-wasmer17\\x86_64-nintendo-fuchsia-gnu-coff-01E9F9FE"
"modules\\v11-wasmer17\\x86_64-nintendo-fuchsia-gnu-coff-01E9F9FE"
} else {
"modules/v9-wasmer17/x86_64-nintendo-fuchsia-gnu-coff-01E9F9FE"
"modules/v11-wasmer17/x86_64-nintendo-fuchsia-gnu-coff-01E9F9FE"
}
);
}
Expand Down
17 changes: 5 additions & 12 deletions packages/vm/src/wasm_backend/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use wasmer::Singlepass;
use wasmer::{
wasmparser::Operator, BaseTunables, CompilerConfig, Engine, Pages, Target, WASM_PAGE_SIZE,
};
use wasmer_middlewares::Metering;

use crate::size::Size;

use super::gatekeeper::Gatekeeper;
use super::limiting_tunables::LimitingTunables;
use super::metering::{is_accounting, Metering};

/// WebAssembly linear memory objects have sizes measured in pages. Each page
/// is 65536 (2^16) bytes. In WebAssembly version 1, a linear memory can have at
Expand All @@ -29,17 +29,10 @@ fn cost(operator: &Operator) -> u64 {
// precise enough to derive insights from it.
const GAS_PER_OPERATION: u64 = 115_000;

match operator {
Operator::Loop { .. }
| Operator::End
| Operator::Else
| Operator::Br { .. }
| Operator::BrTable { .. }
| Operator::BrIf { .. }
| Operator::Call { .. }
| Operator::CallIndirect { .. }
| Operator::Return => GAS_PER_OPERATION * 14,
_ => GAS_PER_OPERATION,
if is_accounting(operator) {
GAS_PER_OPERATION * 14
} else {
GAS_PER_OPERATION
}
}

Expand Down
Loading

0 comments on commit 16eabd6

Please sign in to comment.