Skip to content

Commit

Permalink
runtime: "normalize" VMKind as soon as it is parsed
Browse files Browse the repository at this point in the history
People with M1 Macs run the neard node too, not just the test suites.
Unfortunately a proper regression test for this is not obvious… I’ll
think about it.

(Possibly)
Fixes #9665
  • Loading branch information
nagisa committed Oct 16, 2023
1 parent 3a56da2 commit 0a29803
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 0 additions & 2 deletions core/primitives/src/runtime/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ impl RuntimeConfig {
let mut wasm_config = near_vm_runner::logic::Config::clone(
&config_store.get_config(PROTOCOL_VERSION).wasm_config,
);
wasm_config.vm_kind = wasm_config.vm_kind.normalize();
RuntimeConfig {
fees: RuntimeFeesConfig::test(),
wasm_config,
Expand All @@ -55,7 +54,6 @@ impl RuntimeConfig {
let mut wasm_config = near_vm_runner::logic::Config::clone(
&config_store.get_config(PROTOCOL_VERSION).wasm_config,
);
wasm_config.vm_kind = wasm_config.vm_kind.normalize();
wasm_config.make_free();
Self {
fees: RuntimeFeesConfig::free(),
Expand Down
7 changes: 4 additions & 3 deletions core/primitives/src/runtime/parameter_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ impl TryFrom<&ParameterValue> for VMKind {

fn try_from(value: &ParameterValue) -> Result<Self, Self::Error> {
match value {
ParameterValue::String(v) => {
v.parse().map_err(|e| ValueConversionError::ParseVmKind(e, value.to_string()))
}
ParameterValue::String(v) => v
.parse()
.map(|v: VMKind| v.replace_with_wasmtime_if_unsupported())
.map_err(|e| ValueConversionError::ParseVmKind(e, value.to_string())),
_ => {
Err(ValueConversionError::ParseType(std::any::type_name::<VMKind>(), value.clone()))
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/near-vm-runner/src/vm_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum VMKind {
}

impl VMKind {
pub fn normalize(self) -> Self {
pub fn replace_with_wasmtime_if_unsupported(self) -> Self {
if cfg!(not(target_arch = "x86_64")) {
Self::Wasmtime
} else {
Expand Down

0 comments on commit 0a29803

Please sign in to comment.