Skip to content

Commit c0bb42c

Browse files
committed
chore: add CI 10
1 parent 0fb5ef4 commit c0bb42c

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
@@ -446,13 +446,19 @@ pub fn update_v2(bank: &Bank) -> std::result::Result<(), AccumulatorUpdateErrorV
446446
let mut measure = Measure::start("update_v2_aggregate_price");
447447
for (pubkey, mut account) in accounts {
448448
let mut price_account_data = account.data().to_owned();
449-
let price_account = if let Ok(data) =
450-
pyth_oracle::validator::validate_price_account(&mut price_account_data)
451-
{
452-
data
453-
} else {
454-
continue; // Not a price account.
455-
};
449+
let price_account =
450+
match pyth_oracle::validator::validate_price_account(&mut price_account_data) {
451+
Ok(data) => data,
452+
Err(err) => match err {
453+
AggregationError::NotPriceFeedAccount => {
454+
continue;
455+
}
456+
AggregationError::V1AggregationMode | AggregationError::AlreadyAggregated => {
457+
any_v1_aggregations = true;
458+
continue;
459+
}
460+
},
461+
};
456462

457463
let mut need_save =
458464
pyth_batch_publish::apply_published_prices(price_account, &new_prices, bank.slot());
@@ -468,7 +474,7 @@ pub fn update_v2(bank: &Bank) -> std::result::Result<(), AccumulatorUpdateErrorV
468474
need_save = true;
469475
v2_messages.extend(messages);
470476
}
471-
Err(err) => match err {
477+
Err(err) => match dbg!(err) {
472478
AggregationError::NotPriceFeedAccount => {}
473479
AggregationError::V1AggregationMode | AggregationError::AlreadyAggregated => {
474480
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
@@ -1142,6 +1142,7 @@ fn test_get_accumulator_keys() {
11421142
Pubkey::new_from_array(pythnet::WORMHOLE_PID),
11431143
*ORACLE_PID,
11441144
*STAKE_CAPS_PARAMETERS_ADDR,
1145+
*BATCH_PUBLISH_PID,
11451146
];
11461147
assert_eq!(accumulator_keys, expected_pyth_keys);
11471148
}

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)