Skip to content

Commit 6982f90

Browse files
committed
chore: add CI 10
1 parent 872d1b2 commit 6982f90

File tree

4 files changed

+76
-20
lines changed

4 files changed

+76
-20
lines changed

.github/workflows/pyth.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Check Pythnet
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions-rs/toolchain@v1
13+
with:
14+
profile: minimal
15+
toolchain: 1.60.0
16+
components: clippy
17+
override: true
18+
- name: Install dependencies
19+
run: |
20+
sudo apt-get update
21+
sudo apt-get install -y libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang cmake make libprotobuf-dev
22+
- name: Run tests
23+
run: cargo test -p solana-runtime pyth
24+
clippy:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v2
28+
- uses: actions-rs/toolchain@v1
29+
with:
30+
profile: minimal
31+
toolchain: 1.60.0
32+
components: clippy
33+
override: true
34+
- name: Install dependencies
35+
run: |
36+
sudo apt-get update
37+
sudo apt-get install -y libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang cmake make libprotobuf-dev
38+
- name: Check clippy
39+
run: cargo clippy --bins --tests --examples -- --deny warnings
40+
format:
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v2
44+
- uses: actions-rs/toolchain@v1
45+
with:
46+
profile: minimal
47+
toolchain: nightly-2022-04-01
48+
components: rustfmt
49+
override: true
50+
- name: Check formatting
51+
run: cargo fmt -- --check

runtime/src/bank/pyth_accumulator.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,19 @@ pub fn update_v2(bank: &Bank) -> std::result::Result<(), AccumulatorUpdateErrorV
431431

432432
for (pubkey, mut account) in accounts {
433433
let mut price_account_data = account.data().to_owned();
434-
let price_account = if let Ok(data) =
435-
pyth_oracle::validator::validate_price_account(&mut price_account_data)
436-
{
437-
data
438-
} else {
439-
continue; // Not a price account.
440-
};
434+
let price_account =
435+
match pyth_oracle::validator::validate_price_account(&mut price_account_data) {
436+
Ok(data) => data,
437+
Err(err) => match err {
438+
AggregationError::NotPriceFeedAccount => {
439+
continue;
440+
}
441+
AggregationError::V1AggregationMode | AggregationError::AlreadyAggregated => {
442+
any_v1_aggregations = true;
443+
continue;
444+
}
445+
},
446+
};
441447

442448
let mut need_save =
443449
pyth_batch_publish::apply_published_prices(price_account, &new_prices, bank.slot());
@@ -453,7 +459,7 @@ pub fn update_v2(bank: &Bank) -> std::result::Result<(), AccumulatorUpdateErrorV
453459
need_save = true;
454460
v2_messages.extend(messages);
455461
}
456-
Err(err) => match err {
462+
Err(err) => match dbg!(err) {
457463
AggregationError::NotPriceFeedAccount => {}
458464
AggregationError::V1AggregationMode | AggregationError::AlreadyAggregated => {
459465
any_v1_aggregations = true;

runtime/src/bank/pyth_accumulator_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ fn test_get_accumulator_keys() {
902902
Pubkey::new_from_array(pythnet::ACCUMULATOR_SEQUENCE_ADDR),
903903
Pubkey::new_from_array(pythnet::WORMHOLE_PID),
904904
*ORACLE_PID,
905+
*BATCH_PUBLISH_PID,
905906
];
906907
assert_eq!(accumulator_keys, expected_pyth_keys);
907908
}

validator/src/main.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3200,28 +3200,26 @@ fn process_account_indexes(matches: &ArgMatches) -> AccountSecondaryIndexes {
32003200
let exclude_keys = !account_indexes_exclude_keys.is_empty();
32013201
let include_keys = !account_indexes_include_keys.is_empty();
32023202

3203-
if include_keys {
3204-
if !account_indexes_include_keys.contains(&*ORACLE_PID)
3203+
if include_keys
3204+
&& (!account_indexes_include_keys.contains(&*ORACLE_PID)
32053205
|| !account_indexes_include_keys.contains(&*MESSAGE_BUFFER_PID)
3206-
|| !account_indexes_include_keys.contains(&*BATCH_PUBLISH_PID)
3207-
{
3208-
panic!(
3206+
|| !account_indexes_include_keys.contains(&*BATCH_PUBLISH_PID))
3207+
{
3208+
panic!(
32093209
"The oracle program id and message buffer program id must be included in the account index. Add the following flags\n\
32103210
--account-index-include-key {}\n\
32113211
--account-index-include-key {}\n\
32123212
--account-index-include-key {}\n",
32133213
&*ORACLE_PID, &*MESSAGE_BUFFER_PID, &*BATCH_PUBLISH_PID,
32143214
);
3215-
}
32163215
}
32173216

3218-
if exclude_keys {
3219-
if account_indexes_exclude_keys.contains(&*ORACLE_PID)
3217+
if exclude_keys
3218+
&& (account_indexes_exclude_keys.contains(&*ORACLE_PID)
32203219
|| account_indexes_exclude_keys.contains(&*MESSAGE_BUFFER_PID)
3221-
|| account_indexes_exclude_keys.contains(&*BATCH_PUBLISH_PID)
3222-
{
3223-
panic!("The oracle program id and message buffer program id must *not* be excluded from the account index.");
3224-
}
3220+
|| account_indexes_exclude_keys.contains(&*BATCH_PUBLISH_PID))
3221+
{
3222+
panic!("The oracle program id and message buffer program id must *not* be excluded from the account index.");
32253223
}
32263224

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

0 commit comments

Comments
 (0)