diff --git a/Cargo.lock b/Cargo.lock index 3282e1ee78..f3314cc104 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -519,7 +519,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" dependencies = [ "borsh-derive 0.10.3", - "hashbrown 0.11.2", + "hashbrown 0.12.3", ] [[package]] diff --git a/runtime/src/bank/pyth_accumulator.rs b/runtime/src/bank/pyth_accumulator.rs index 46c5524b83..ee30aca37c 100644 --- a/runtime/src/bank/pyth_accumulator.rs +++ b/runtime/src/bank/pyth_accumulator.rs @@ -447,17 +447,11 @@ pub fn update_v2(bank: &Bank) -> std::result::Result<(), AccumulatorUpdateErrorV for (pubkey, mut account) in accounts { let mut price_account_data = account.data().to_owned(); let price_account = - match pyth_oracle::validator::validate_price_account(&mut price_account_data) { + match pyth_oracle::validator::checked_load_price_account_mut(&mut price_account_data) { Ok(data) => data, - Err(err) => match err { - AggregationError::NotPriceFeedAccount => { - continue; - } - AggregationError::V1AggregationMode | AggregationError::AlreadyAggregated => { - any_v1_aggregations = true; - continue; - } - }, + Err(_err) => { + continue; + } }; let mut need_save = @@ -474,7 +468,7 @@ pub fn update_v2(bank: &Bank) -> std::result::Result<(), AccumulatorUpdateErrorV need_save = true; v2_messages.extend(messages); } - Err(err) => match dbg!(err) { + Err(err) => match err { AggregationError::NotPriceFeedAccount => {} AggregationError::V1AggregationMode | AggregationError::AlreadyAggregated => { any_v1_aggregations = true; diff --git a/runtime/src/bank/pyth_accumulator_tests.rs b/runtime/src/bank/pyth_accumulator_tests.rs index f55260a9b5..5c3673a131 100644 --- a/runtime/src/bank/pyth_accumulator_tests.rs +++ b/runtime/src/bank/pyth_accumulator_tests.rs @@ -1228,7 +1228,7 @@ fn test_batch_publish() { price_account.flags.insert( PriceAccountFlags::ACCUMULATOR_V2 | PriceAccountFlags::MESSAGE_BUFFER_CLEARED, ); - price_account.unused_3_ = index; + price_account.feed_index = index; price_account.comp_[0].pub_ = publishers[0].pubkey().to_bytes().into(); price_account.comp_[1].pub_ = publishers[1].pubkey().to_bytes().into(); price_account.num_ = 2; diff --git a/runtime/src/bank/pyth_batch_publish.rs b/runtime/src/bank/pyth_batch_publish.rs index 68a0dec0aa..406a313551 100644 --- a/runtime/src/bank/pyth_batch_publish.rs +++ b/runtime/src/bank/pyth_batch_publish.rs @@ -11,6 +11,7 @@ use { thiserror::Error, }; +// TODO: move to the publish program #[allow(dead_code)] pub mod publisher_prices_account { use { @@ -224,15 +225,16 @@ pub fn extract_batch_publish_prices( } let publisher = header.publisher.into(); for price in prices { + let value = PublisherPriceValue { + publisher, + trading_status: price.trading_status(), + price: price.price, + confidence: price.confidence, + }; all_prices .entry(price.feed_index()) .or_default() - .push(PublisherPriceValue { - publisher, - trading_status: price.trading_status(), - price: price.price, - confidence: price.confidence, - }); + .push(value); } } Ok(all_prices) @@ -243,8 +245,7 @@ pub fn apply_published_prices( new_prices: &HashMap>, slot: Slot, ) -> bool { - // TODO: store index here or somewhere else? - let price_feed_index = price_data.unused_3_ as u32; + let price_feed_index = price_data.feed_index as u32; let mut any_update = false; for new_price in new_prices.get(&price_feed_index).unwrap_or(&Vec::new()) { match apply_published_price(price_data, new_price, slot) { @@ -254,7 +255,7 @@ pub fn apply_published_prices( Err(err) => { warn!( "failed to apply publisher price to price feed {}: {}", - price_data.unused_3_ as u32, err + price_data.feed_index as u32, err ); } } @@ -285,7 +286,7 @@ fn apply_published_price( .ok_or(ApplyPublishedPriceError::InvalidPublishersNum)?; let publisher_index = find_publisher_index(publishers, &new_price.publisher).ok_or( - ApplyPublishedPriceError::NoPermission(price_data.unused_3_ as u32, new_price.publisher), + ApplyPublishedPriceError::NoPermission(price_data.feed_index as u32, new_price.publisher), )?; // IMPORTANT: If the publisher does not meet the price/conf