Skip to content

Commit

Permalink
chore: add CI 10
Browse files Browse the repository at this point in the history
  • Loading branch information
Riateche committed Jul 31, 2024
1 parent 872d1b2 commit 6982f90
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 20 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/pyth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Check Pythnet

on:
pull_request:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.60.0
components: clippy
override: true
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang cmake make libprotobuf-dev
- name: Run tests
run: cargo test -p solana-runtime pyth
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.60.0
components: clippy
override: true
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang cmake make libprotobuf-dev
- name: Check clippy
run: cargo clippy --bins --tests --examples -- --deny warnings
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2022-04-01
components: rustfmt
override: true
- name: Check formatting
run: cargo fmt -- --check
22 changes: 14 additions & 8 deletions runtime/src/bank/pyth_accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,19 @@ 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 = if let Ok(data) =
pyth_oracle::validator::validate_price_account(&mut price_account_data)
{
data
} else {
continue; // Not a price account.
};
let price_account =
match pyth_oracle::validator::validate_price_account(&mut price_account_data) {
Ok(data) => data,
Err(err) => match err {
AggregationError::NotPriceFeedAccount => {
continue;
}
AggregationError::V1AggregationMode | AggregationError::AlreadyAggregated => {
any_v1_aggregations = true;
continue;
}
},
};

let mut need_save =
pyth_batch_publish::apply_published_prices(price_account, &new_prices, bank.slot());
Expand All @@ -453,7 +459,7 @@ pub fn update_v2(bank: &Bank) -> std::result::Result<(), AccumulatorUpdateErrorV
need_save = true;
v2_messages.extend(messages);
}
Err(err) => match err {
Err(err) => match dbg!(err) {
AggregationError::NotPriceFeedAccount => {}
AggregationError::V1AggregationMode | AggregationError::AlreadyAggregated => {
any_v1_aggregations = true;
Expand Down
1 change: 1 addition & 0 deletions runtime/src/bank/pyth_accumulator_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ fn test_get_accumulator_keys() {
Pubkey::new_from_array(pythnet::ACCUMULATOR_SEQUENCE_ADDR),
Pubkey::new_from_array(pythnet::WORMHOLE_PID),
*ORACLE_PID,
*BATCH_PUBLISH_PID,
];
assert_eq!(accumulator_keys, expected_pyth_keys);
}
Expand Down
22 changes: 10 additions & 12 deletions validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3200,28 +3200,26 @@ fn process_account_indexes(matches: &ArgMatches) -> AccountSecondaryIndexes {
let exclude_keys = !account_indexes_exclude_keys.is_empty();
let include_keys = !account_indexes_include_keys.is_empty();

if include_keys {
if !account_indexes_include_keys.contains(&*ORACLE_PID)
if include_keys
&& (!account_indexes_include_keys.contains(&*ORACLE_PID)
|| !account_indexes_include_keys.contains(&*MESSAGE_BUFFER_PID)
|| !account_indexes_include_keys.contains(&*BATCH_PUBLISH_PID)
{
panic!(
|| !account_indexes_include_keys.contains(&*BATCH_PUBLISH_PID))
{
panic!(
"The oracle program id and message buffer program id must be included in the account index. Add the following flags\n\
--account-index-include-key {}\n\
--account-index-include-key {}\n\
--account-index-include-key {}\n",
&*ORACLE_PID, &*MESSAGE_BUFFER_PID, &*BATCH_PUBLISH_PID,
);
}
}

if exclude_keys {
if account_indexes_exclude_keys.contains(&*ORACLE_PID)
if exclude_keys
&& (account_indexes_exclude_keys.contains(&*ORACLE_PID)
|| account_indexes_exclude_keys.contains(&*MESSAGE_BUFFER_PID)
|| account_indexes_exclude_keys.contains(&*BATCH_PUBLISH_PID)
{
panic!("The oracle program id and message buffer program id must *not* be excluded from the account index.");
}
|| account_indexes_exclude_keys.contains(&*BATCH_PUBLISH_PID))
{
panic!("The oracle program id and message buffer program id must *not* be excluded from the account index.");
}

let keys = if !account_indexes.is_empty() && (exclude_keys || include_keys) {
Expand Down

0 comments on commit 6982f90

Please sign in to comment.