From 7d806466cb17d612b0ada9ec5d3b68027b41fdab Mon Sep 17 00:00:00 2001 From: GroovieGermanikus Date: Wed, 20 Sep 2023 13:50:41 +0200 Subject: [PATCH 1/3] update dep 'fixed' fixed has been patched and was moved to blockworks repo s Please enter the commit message for your changes. Lines starting --- .gitmodules | 3 --- 3rdparty/fixed | 1 - Cargo.lock | 5 ++--- Cargo.toml | 5 ++++- 4 files changed, 6 insertions(+), 8 deletions(-) delete mode 160000 3rdparty/fixed diff --git a/.gitmodules b/.gitmodules index 094afd43f..e79e14fd3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "3rdparty/fixed"] - path = 3rdparty/fixed - url = https://gitlab.com/ckamm/fixed.git [submodule "3rdparty/anchor"] path = 3rdparty/anchor url = https://github.com/openbook-dex/anchor.git diff --git a/3rdparty/fixed b/3rdparty/fixed deleted file mode 160000 index 95bf614b0..000000000 --- a/3rdparty/fixed +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 95bf614b09742333451e073704f11ea502d4563b diff --git a/Cargo.lock b/Cargo.lock index ee5fed424..41cd1f89d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1824,13 +1824,12 @@ dependencies = [ [[package]] name = "fixed" version = "1.11.0" +source = "git+https://github.com/blockworks-foundation/fixed.git?branch=v1.11.0-borsh0_10-mango#01516ae3e29418feb066b67830540aa81d04df05" dependencies = [ - "arbitrary", "az", - "borsh 0.9.3", + "borsh 0.10.3", "bytemuck", "half", - "num-traits", "serde", "typenum", ] diff --git a/Cargo.toml b/Cargo.toml index c22211362..9ed4e24cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ members = [ anchor-client = "0.28.0" anchor-lang = "0.28.0" anchor-spl = "0.28.0" -fixed = {path = "./3rdparty/fixed", version = "1.11.0"} +fixed = { git = "https://github.com/blockworks-foundation/fixed.git", branch = "v1.11.0-borsh0_10-mango" } pyth-sdk-solana = "0.8.0" solana-account-decoder = "~1.16.1" solana-client = "~1.16.1" @@ -27,3 +27,6 @@ overflow-checks = true codegen-units = 1 incremental = false opt-level = 3 + +[patch.crates-io] +fixed = { git = "https://github.com/blockworks-foundation/fixed.git", branch = "v1.11.0-borsh0_10-mango" } \ No newline at end of file From 4e1e50fb6d95186e6af975c2608f1cee27c49648 Mon Sep 17 00:00:00 2001 From: GroovieGermanikus Date: Wed, 20 Sep 2023 13:51:54 +0200 Subject: [PATCH 2/3] cleanup --- Cargo.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9ed4e24cb..3d7f8c50f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,4 @@ overflow-checks = true codegen-units = 1 incremental = false opt-level = 3 - -[patch.crates-io] -fixed = { git = "https://github.com/blockworks-foundation/fixed.git", branch = "v1.11.0-borsh0_10-mango" } \ No newline at end of file +g \ No newline at end of file From 2a8061b0763d199322f33107be4f9b879808af87 Mon Sep 17 00:00:00 2001 From: GroovieGermanikus Date: Wed, 20 Sep 2023 17:42:24 +0200 Subject: [PATCH 3/3] add regression test for fixed bug https://gitlab.com/tspiteri/fixed/-/issues/57 --- Cargo.toml | 1 - programs/openbook-v2/src/i80f48.rs | 10 ++++++++++ programs/openbook-v2/src/lib.rs | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 programs/openbook-v2/src/i80f48.rs diff --git a/Cargo.toml b/Cargo.toml index 3d7f8c50f..c7fa3207f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,4 +27,3 @@ overflow-checks = true codegen-units = 1 incremental = false opt-level = 3 -g \ No newline at end of file diff --git a/programs/openbook-v2/src/i80f48.rs b/programs/openbook-v2/src/i80f48.rs new file mode 100644 index 000000000..75da25df6 --- /dev/null +++ b/programs/openbook-v2/src/i80f48.rs @@ -0,0 +1,10 @@ +use fixed::types::I80F48; + +// regression test for https://gitlab.com/tspiteri/fixed/-/issues/57 +// see https://github.com/blockworks-foundation/fixed/issues/1 +#[test] +fn bug_fixed_comparison_u64() { + let a: u64 = 66000; + let b: u64 = 1000; + assert!(I80F48::from(a) > b); // fails! +} diff --git a/programs/openbook-v2/src/lib.rs b/programs/openbook-v2/src/lib.rs index d6a911332..e3deb4d01 100644 --- a/programs/openbook-v2/src/lib.rs +++ b/programs/openbook-v2/src/lib.rs @@ -18,6 +18,7 @@ pub mod pubkey_option; pub mod state; pub mod token_utils; pub mod types; +mod i80f48; #[cfg(feature = "enable-gpl")] pub mod instructions;