From 5a7b474e7941c49d542e3066349fc5a7079bda45 Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Wed, 19 Jun 2024 21:43:01 +0700 Subject: [PATCH 1/3] Remove unneeded version guard --- Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ec5f641..dec0471 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ serde_json = "1.0.18" # This is the earliest version which supports 128-bit inte thiserror = "1" tokio = { version = "1.5", features = ["sync", "macros"] } tracing = "0.1.27" -wasmtime = { version = ">=16, <21", default-features = false, features = ["async"] } +wasmtime = { version = ">=16", default-features = false, features = ["async"] } # Loader tokio-tar = { version = "0.3", optional = true } @@ -32,7 +32,7 @@ base64 = { version = "0.22", optional = true } digest = { version = "0.10", optional = true } hex = { version = "0.4", optional = true } hmac = { version = "0.12", optional = true } -json-patch = { version = ">=0.2.3, <1.3.0", optional = true, default-features = false } +json-patch = { version = ">=0.2.3", optional = true, default-features = false } md-5 = { version = "0.10", optional = true } rand = { version = "0.8", optional = true } semver = { version = "1", optional = true } @@ -44,7 +44,7 @@ serde_yaml = { version = "0.9.1", optional = true } form_urlencoded = { version = "1", optional = true } urlencoding = { version = "2", optional = true } chrono = { version = "0.4.31", optional = true, default-features = false, features = ["std", "clock"] } -chrono-tz = { version = ">=0.6, <0.10.0", optional = true } +chrono-tz = { version = ">=0.6", optional = true } chronoutil = { version = "0.2", optional = true } duration-str = { version = "0.7", optional = true, default-features = false } @@ -53,7 +53,7 @@ version = "1.5" features = ["macros", "fs", "rt", "rt-multi-thread"] [dev-dependencies] -wasmtime = { version = ">=16, <21", default-features = false, features = ["cranelift"] } +wasmtime = { version = ">=16", default-features = false, features = ["cranelift"] } insta = { version = "1", features = ["yaml"] } [build-dependencies] From c7cd109dfe81f3fb194108559af5291ff59fbb42 Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Wed, 19 Jun 2024 21:49:55 +0700 Subject: [PATCH 2/3] Upgrade snprintf and duration-str version --- Cargo.toml | 4 ++-- src/builtins/impls/time.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dec0471..925cee8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ rand = { version = "0.8", optional = true } semver = { version = "1", optional = true } sha1 = { version = "0.10", optional = true } sha2 = { version = "0.10", optional = true } -sprintf = { version = "0.2", optional = true } +sprintf = { version = "0.3", optional = true } parse-size = { version = "1", features = ["std"], optional = true } serde_yaml = { version = "0.9.1", optional = true } form_urlencoded = { version = "1", optional = true } @@ -46,7 +46,7 @@ urlencoding = { version = "2", optional = true } chrono = { version = "0.4.31", optional = true, default-features = false, features = ["std", "clock"] } chrono-tz = { version = ">=0.6", optional = true } chronoutil = { version = "0.2", optional = true } -duration-str = { version = "0.7", optional = true, default-features = false } +duration-str = { version = "0.11", optional = true, default-features = false } [dev-dependencies.tokio] version = "1.5" diff --git a/src/builtins/impls/time.rs b/src/builtins/impls/time.rs index c6aadac..2ae8564 100644 --- a/src/builtins/impls/time.rs +++ b/src/builtins/impls/time.rs @@ -96,7 +96,7 @@ pub fn now_ns(ctx: &mut C) -> i64 { /// Returns the duration in nanoseconds represented by a string. #[tracing::instrument(name = "time.parse_duration_ns", err)] pub fn parse_duration_ns(duration: String) -> Result { - Ok(duration_str::parse(duration.as_str())?.as_nanos()) + Ok(duration_str::parse(duration.as_str()).map_err(|e| anyhow!("{e}"))?.as_nanos()) } /// Returns the time in nanoseconds parsed from the string in the given format. From 00a19421ae1e0b86e6a3a4f592ac9283e09fb9d2 Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Mon, 24 Jun 2024 17:54:52 +0700 Subject: [PATCH 3/3] upgrade wasmtime to the latest version --- Cargo.toml | 16 ++++++++-------- src/builtins/impls/time.rs | 4 +++- src/policy.rs | 34 ++++++++++------------------------ 3 files changed, 21 insertions(+), 33 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 925cee8..ca4d32e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,10 +10,10 @@ default-run = "opa-eval" [dependencies] anyhow = "1" serde = { version = "1", features = ["derive"] } -serde_json = "1.0.18" # This is the earliest version which supports 128-bit integers +serde_json = "1.0.117" thiserror = "1" -tokio = { version = "1.5", features = ["sync", "macros"] } -tracing = "0.1.27" +tokio = { version = "1.38", features = ["sync", "macros"] } +tracing = "0.1.40" wasmtime = { version = ">=16", default-features = false, features = ["async"] } # Loader @@ -24,7 +24,7 @@ futures-util = { version = "0.3", optional = true } # CLI camino = { version = "1", optional = true } clap = { version = "4", features = ["derive"], optional = true } -tracing-forest = { version = "0.1.4", optional = true } +tracing-forest = { version = "0.1.6", optional = true } tracing-subscriber = { version = "0.3", features = ["env-filter"], optional = true } # Builtins @@ -40,16 +40,16 @@ sha1 = { version = "0.10", optional = true } sha2 = { version = "0.10", optional = true } sprintf = { version = "0.3", optional = true } parse-size = { version = "1", features = ["std"], optional = true } -serde_yaml = { version = "0.9.1", optional = true } +serde_yaml = { version = "0.9.34", optional = true } form_urlencoded = { version = "1", optional = true } urlencoding = { version = "2", optional = true } -chrono = { version = "0.4.31", optional = true, default-features = false, features = ["std", "clock"] } +chrono = { version = "0.4.38", optional = true, default-features = false, features = ["std", "clock"] } chrono-tz = { version = ">=0.6", optional = true } chronoutil = { version = "0.2", optional = true } duration-str = { version = "0.11", optional = true, default-features = false } [dev-dependencies.tokio] -version = "1.5" +version = "1.38" features = ["macros", "fs", "rt", "rt-multi-thread"] [dev-dependencies] @@ -58,7 +58,7 @@ insta = { version = "1", features = ["yaml"] } [build-dependencies] # psm's (used by wasmtime) build-script uses a feature introduced in cc 1.0.2 -cc = "1.0.2" +cc = "1.0.99" indexmap = ">=1.9.1" [features] diff --git a/src/builtins/impls/time.rs b/src/builtins/impls/time.rs index 2ae8564..a2b4701 100644 --- a/src/builtins/impls/time.rs +++ b/src/builtins/impls/time.rs @@ -96,7 +96,9 @@ pub fn now_ns(ctx: &mut C) -> i64 { /// Returns the duration in nanoseconds represented by a string. #[tracing::instrument(name = "time.parse_duration_ns", err)] pub fn parse_duration_ns(duration: String) -> Result { - Ok(duration_str::parse(duration.as_str()).map_err(|e| anyhow!("{e}"))?.as_nanos()) + Ok(duration_str::parse(duration.as_str()) + .map_err(|e| anyhow!("{e}"))? + .as_nanos()) } /// Returns the time in nanoseconds parsed from the string in the given format. diff --git a/src/policy.rs b/src/policy.rs index 30b8ce2..995c502 100644 --- a/src/policy.rs +++ b/src/policy.rs @@ -262,10 +262,10 @@ impl Runtime { { let eventually_builtins = eventually_builtins.clone(); - linker.func_wrap2_async( + linker.func_wrap_async( "env", "opa_builtin0", - move |caller: Caller<'_, _>, builtin_id: i32, _ctx: i32| { + move |caller: Caller<'_, _>, (builtin_id, _ctx): (i32, i32)| { let eventually_builtins = eventually_builtins.clone(); Box::new(async move { eventually_builtins @@ -280,10 +280,10 @@ impl Runtime { { let eventually_builtins = eventually_builtins.clone(); - linker.func_wrap3_async( + linker.func_wrap_async( "env", "opa_builtin1", - move |caller: Caller<'_, _>, builtin_id: i32, _ctx: i32, param1: i32| { + move |caller: Caller<'_, _>, (builtin_id, _ctx, param1): (_, i32, _)| { let eventually_builtins = eventually_builtins.clone(); Box::new(async move { eventually_builtins @@ -298,14 +298,10 @@ impl Runtime { { let eventually_builtins = eventually_builtins.clone(); - linker.func_wrap4_async( + linker.func_wrap_async( "env", "opa_builtin2", - move |caller: Caller<'_, _>, - builtin_id: i32, - _ctx: i32, - param1: i32, - param2: i32| { + move |caller: Caller<'_, _>, (builtin_id, _ctx, param1, param2): (_, i32, _, _)| { let eventually_builtins = eventually_builtins.clone(); Box::new(async move { eventually_builtins @@ -320,15 +316,10 @@ impl Runtime { { let eventually_builtins = eventually_builtins.clone(); - linker.func_wrap5_async( + linker.func_wrap_async( "env", "opa_builtin3", - move |caller: Caller<'_, _>, - builtin_id: i32, - _ctx: i32, - param1: i32, - param2: i32, - param3: i32| { + move |caller: Caller<'_, _>, (builtin_id, _ctx, param1, param2, param3): (_, i32, _, _, _)| { let eventually_builtins = eventually_builtins.clone(); Box::new(async move { eventually_builtins @@ -343,16 +334,11 @@ impl Runtime { { let eventually_builtins = eventually_builtins.clone(); - linker.func_wrap6_async( + linker.func_wrap_async( "env", "opa_builtin4", move |caller: Caller<'_, _>, - builtin_id: i32, - _ctx: i32, - param1: i32, - param2: i32, - param3: i32, - param4: i32| { + (builtin_id, _ctx, param1, param2, param3, param4): (_, i32, _, _, _, _)| { let eventually_builtins = eventually_builtins.clone(); Box::new(async move { eventually_builtins