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 6f61673 commit f5bf24f
Show file tree
Hide file tree
Showing 20 changed files with 298 additions and 20 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/empty/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-callbacks/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.

1 change: 1 addition & 0 deletions packages/vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ sha2 = "0.10.3"
thiserror = "1.0.26"
wasmer = { version = "=4.3.3", default-features = false, features = ["singlepass"] }
wasmer-middlewares = "=4.3.3"
wasmer-types = "=4.3.3"
strum = { version = "0.26.2", default-features = false, features = ["derive"] }
# For heap profiling. Only used in the "heap_profiling" example. This has to be a non-dev dependency
# because cargo currently does not support optional dev-dependencies.
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 @@ -914,7 +914,7 @@ mod tests {

let report2 = instance.create_gas_report();
assert_eq!(report2.used_externally, 251);
assert_eq!(report2.used_internally, 16995280);
assert_eq!(report2.used_internally, 21059380);
assert_eq!(report2.limit, LIMIT);
assert_eq!(
report2.remaining,
Expand Down Expand Up @@ -1105,7 +1105,7 @@ mod tests {
.unwrap();

let init_used = orig_gas - instance.get_gas_left();
assert_eq!(init_used, 16995531);
assert_eq!(init_used, 21059631);
}

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

let execute_used = gas_before_execute - instance.get_gas_left();
assert_eq!(execute_used, 19589666);
assert_eq!(execute_used, 25160611);
}

#[test]
Expand Down Expand Up @@ -1173,6 +1173,6 @@ mod tests {
);

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

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

let mut globber = glob::glob(&format!(
"{}/v10-wasmer7/**/{}.module",
"{}/v13-wasmer7/**/{}.module",
tmp_dir.path().to_string_lossy(),
checksum
))
Expand Down Expand Up @@ -398,9 +404,9 @@ mod tests {
assert_eq!(
p.as_os_str(),
if cfg!(windows) {
"modules\\v10-wasmer17\\x86_64-nintendo-fuchsia-gnu-coff-01E9F9FE"
"modules\\v13-wasmer17\\x86_64-nintendo-fuchsia-gnu-coff-01E9F9FE"
} else {
"modules/v10-wasmer17/x86_64-nintendo-fuchsia-gnu-coff-01E9F9FE"
"modules/v13-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 @@ -3,12 +3,12 @@ use wasmer::NativeEngineExt;
use wasmer::{
sys::BaseTunables, wasmparser::Operator, 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 @@ -25,17 +25,10 @@ fn cost(operator: &Operator) -> u64 {
// precise enough to derive insights from it.
const GAS_PER_OPERATION: u64 = 115;

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 f5bf24f

Please sign in to comment.