From 514e0154762166dae38a3f66e47833aedb282313 Mon Sep 17 00:00:00 2001 From: Jayant Krishnamurthy Date: Thu, 10 Nov 2022 14:48:49 +0000 Subject: [PATCH 1/5] Set CI threshold to 3 --- program/rust/src/c_oracle_header.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/program/rust/src/c_oracle_header.rs b/program/rust/src/c_oracle_header.rs index e45f04a84..3cbf21e5e 100644 --- a/program/rust/src/c_oracle_header.rs +++ b/program/rust/src/c_oracle_header.rs @@ -21,8 +21,7 @@ pub const PERMISSIONS_SEED: &str = "permissions"; /// If ci > price / PC_MAX_CI_DIVISOR, set publisher status to unknown. /// (e.g., 20 means ci must be < 5% of price) -pub const MAX_CI_DIVISOR: i64 = 20; - +pub const MAX_CI_DIVISOR: i64 = 3; /// Bound on the range of the exponent in price accounts. This number is set such that the /// PD-based EMA computation does not lose too much precision. pub const MAX_NUM_DECIMALS: i32 = 8; From 16aa8089b5c0bc9fd9af6cf5708440a60097ddf4 Mon Sep 17 00:00:00 2001 From: Jayant Krishnamurthy Date: Thu, 10 Nov 2022 15:08:20 +0000 Subject: [PATCH 2/5] fix tests??? --- program/rust/src/tests/test_upd_price.rs | 4 ++-- program/rust/src/tests/test_upd_price_no_fail_on_error.rs | 2 +- program/rust/src/tests/test_upd_sma.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/program/rust/src/tests/test_upd_price.rs b/program/rust/src/tests/test_upd_price.rs index 59c69a4b5..9db331bca 100644 --- a/program/rust/src/tests/test_upd_price.rs +++ b/program/rust/src/tests/test_upd_price.rs @@ -214,7 +214,7 @@ fn test_upd_price() { assert_eq!(price_data.agg_.status_, PC_STATUS_TRADING); } - populate_instruction(&mut instruction_data, 50, 6, 5); + populate_instruction(&mut instruction_data, 50, 20, 5); update_clock_slot(&mut clock_account, 6); // Publishing a wide CI results in a status of unknown. @@ -239,7 +239,7 @@ fn test_upd_price() { { let price_data = load_checked::(&price_account, PC_VERSION).unwrap(); assert_eq!(price_data.comp_[0].latest_.price_, 50); - assert_eq!(price_data.comp_[0].latest_.conf_, 6); + assert_eq!(price_data.comp_[0].latest_.conf_, 20); assert_eq!(price_data.comp_[0].latest_.pub_slot_, 5); assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_UNKNOWN); assert_eq!(price_data.valid_slot_, 5); diff --git a/program/rust/src/tests/test_upd_price_no_fail_on_error.rs b/program/rust/src/tests/test_upd_price_no_fail_on_error.rs index 27e730e0f..65715d730 100644 --- a/program/rust/src/tests/test_upd_price_no_fail_on_error.rs +++ b/program/rust/src/tests/test_upd_price_no_fail_on_error.rs @@ -116,7 +116,7 @@ fn test_upd_price_no_fail_on_error_no_fail_on_error() { assert_eq!(price_data.comp_[0].latest_.price_, 42); assert_eq!(price_data.comp_[0].latest_.conf_, 9); assert_eq!(price_data.comp_[0].latest_.pub_slot_, 1); - assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_UNKNOWN); + assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_TRADING); assert_eq!(price_data.valid_slot_, 0); assert_eq!(price_data.agg_.pub_slot_, 1); assert_eq!(price_data.agg_.price_, 0); diff --git a/program/rust/src/tests/test_upd_sma.rs b/program/rust/src/tests/test_upd_sma.rs index 1d757d819..86305c14a 100644 --- a/program/rust/src/tests/test_upd_sma.rs +++ b/program/rust/src/tests/test_upd_sma.rs @@ -277,7 +277,7 @@ fn test_upd_sma() { assert_eq!(price_data.time_machine.current_epoch_denominator, 3 + 1 + 1); } - populate_instruction(&mut instruction_data, 50, 6, 5); + populate_instruction(&mut instruction_data, 50, 20, 5); update_clock_slot(&mut clock_account, 6); // Publishing a wide CI results in a status of unknown. @@ -305,7 +305,7 @@ fn test_upd_sma() { { let price_data = load_checked::(&price_account, PC_VERSION).unwrap(); assert_eq!(price_data.price_data.comp_[0].latest_.price_, 50); - assert_eq!(price_data.price_data.comp_[0].latest_.conf_, 6); + assert_eq!(price_data.price_data.comp_[0].latest_.conf_, 20); assert_eq!(price_data.price_data.comp_[0].latest_.pub_slot_, 5); assert_eq!( price_data.price_data.comp_[0].latest_.status_, From fd99b5d3d3caeadd4a1e9cfe04b645df9459a7ce Mon Sep 17 00:00:00 2001 From: Jayant Krishnamurthy Date: Thu, 10 Nov 2022 15:41:29 +0000 Subject: [PATCH 3/5] actually fix tests --- program/rust/src/tests/test_upd_price.rs | 4 ++-- program/rust/src/tests/test_upd_price_no_fail_on_error.rs | 2 +- program/rust/src/tests/test_upd_sma.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/program/rust/src/tests/test_upd_price.rs b/program/rust/src/tests/test_upd_price.rs index 9db331bca..3eb0d4f5b 100644 --- a/program/rust/src/tests/test_upd_price.rs +++ b/program/rust/src/tests/test_upd_price.rs @@ -249,7 +249,7 @@ fn test_upd_price() { } // Crank one more time and aggregate should be unknown - populate_instruction(&mut instruction_data, 50, 6, 6); + populate_instruction(&mut instruction_data, 50, 20, 6); update_clock_slot(&mut clock_account, 7); assert!(process_instruction( @@ -266,7 +266,7 @@ fn test_upd_price() { { let price_data = load_checked::(&price_account, PC_VERSION).unwrap(); assert_eq!(price_data.comp_[0].latest_.price_, 50); - assert_eq!(price_data.comp_[0].latest_.conf_, 6); + assert_eq!(price_data.comp_[0].latest_.conf_, 20); assert_eq!(price_data.comp_[0].latest_.pub_slot_, 6); assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_UNKNOWN); assert_eq!(price_data.valid_slot_, 6); diff --git a/program/rust/src/tests/test_upd_price_no_fail_on_error.rs b/program/rust/src/tests/test_upd_price_no_fail_on_error.rs index 65715d730..ef779e2b9 100644 --- a/program/rust/src/tests/test_upd_price_no_fail_on_error.rs +++ b/program/rust/src/tests/test_upd_price_no_fail_on_error.rs @@ -158,7 +158,7 @@ fn test_upd_price_no_fail_on_error_no_fail_on_error() { assert_eq!(price_data.comp_[0].latest_.price_, 42); assert_eq!(price_data.comp_[0].latest_.conf_, 9); assert_eq!(price_data.comp_[0].latest_.pub_slot_, 1); - assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_UNKNOWN); + assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_TRADING); assert_eq!(price_data.valid_slot_, 0); assert_eq!(price_data.agg_.pub_slot_, 1); assert_eq!(price_data.agg_.price_, 0); diff --git a/program/rust/src/tests/test_upd_sma.rs b/program/rust/src/tests/test_upd_sma.rs index 86305c14a..9cd499d41 100644 --- a/program/rust/src/tests/test_upd_sma.rs +++ b/program/rust/src/tests/test_upd_sma.rs @@ -328,7 +328,7 @@ fn test_upd_sma() { } // Crank one more time and aggregate should be unknown - populate_instruction(&mut instruction_data, 50, 6, 6); + populate_instruction(&mut instruction_data, 50, 20, 6); update_clock_slot(&mut clock_account, 7); assert!(process_instruction( @@ -345,7 +345,7 @@ fn test_upd_sma() { { let price_data = load_checked::(&price_account, PC_VERSION).unwrap(); assert_eq!(price_data.price_data.comp_[0].latest_.price_, 50); - assert_eq!(price_data.price_data.comp_[0].latest_.conf_, 6); + assert_eq!(price_data.price_data.comp_[0].latest_.conf_, 20); assert_eq!(price_data.price_data.comp_[0].latest_.pub_slot_, 6); assert_eq!( price_data.price_data.comp_[0].latest_.status_, From b85f67021727a4d359026ef9932d79f1a90df2a2 Mon Sep 17 00:00:00 2001 From: Jayant Krishnamurthy Date: Thu, 10 Nov 2022 17:11:46 +0000 Subject: [PATCH 4/5] fix this test also --- pyth/tests/test_update_price.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyth/tests/test_update_price.py b/pyth/tests/test_update_price.py index bc2dbe8f8..d1c1eb214 100644 --- a/pyth/tests/test_update_price.py +++ b/pyth/tests/test_update_price.py @@ -116,6 +116,6 @@ def get_publisher_acc(product_acc): assert publisher_acc['price'] == new_values[product]['price'] assert publisher_acc['conf'] == new_values[product]['conf'] - conf_threshold = new_values[product]['price'] / 20 + conf_threshold = new_values[product]['price'] / 3 expected_status = 'unknown' if new_values[product]['conf'] > conf_threshold else 'trading' assert publisher_acc['status'] == expected_status From a06232edf3836b0069cf15ba348a56e164254aee Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Alapont Date: Fri, 11 Nov 2022 12:02:41 +0000 Subject: [PATCH 5/5] Fix integer division --- pyth/tests/test_update_price.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyth/tests/test_update_price.py b/pyth/tests/test_update_price.py index d1c1eb214..44971ebe2 100644 --- a/pyth/tests/test_update_price.py +++ b/pyth/tests/test_update_price.py @@ -116,6 +116,6 @@ def get_publisher_acc(product_acc): assert publisher_acc['price'] == new_values[product]['price'] assert publisher_acc['conf'] == new_values[product]['conf'] - conf_threshold = new_values[product]['price'] / 3 + conf_threshold = new_values[product]['price'] // 3 expected_status = 'unknown' if new_values[product]['conf'] > conf_threshold else 'trading' assert publisher_acc['status'] == expected_status