Skip to content

Commit

Permalink
chore: transition crates to stable rust, unify version
Browse files Browse the repository at this point in the history
  • Loading branch information
Riateche committed Oct 30, 2024
1 parent 28aff03 commit 92e5c5b
Show file tree
Hide file tree
Showing 25 changed files with 231 additions and 253 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repos:
- id: cargo-clippy-remote-executor
name: Cargo clippy for remote executor
language: "rust"
entry: cargo +nightly-2023-03-01 clippy --manifest-path ./governance/remote_executor/Cargo.toml --tests --fix --allow-dirty --allow-staged -- -D warnings
entry: cargo clippy --manifest-path ./governance/remote_executor/Cargo.toml --tests --fix --allow-dirty --allow-staged -- -D warnings
pass_filenames: false
files: governance/remote_executor
# Hooks for cosmwasm contract
Expand All @@ -43,7 +43,7 @@ repos:
- id: cargo-clippy-cosmwasm
name: Cargo clippy for cosmwasm contract
language: "rust"
entry: cargo +nightly-2023-03-01 clippy --manifest-path ./target_chains/cosmwasm/Cargo.toml --tests --fix --allow-dirty --allow-staged -- -D warnings
entry: cargo clippy --manifest-path ./target_chains/cosmwasm/Cargo.toml --tests --fix --allow-dirty --allow-staged -- -D warnings
pass_filenames: false
files: target_chains/cosmwasm
# Hooks for Hermes
Expand All @@ -56,7 +56,7 @@ repos:
- id: cargo-clippy-hermes
name: Cargo clippy for Hermes
language: "rust"
entry: cargo +nightly-2024-03-26 clippy --manifest-path ./apps/hermes/server/Cargo.toml --tests --fix --allow-dirty --allow-staged -- -D warnings
entry: cargo clippy --manifest-path ./apps/hermes/server/Cargo.toml --tests --fix --allow-dirty --allow-staged -- -D warnings
pass_filenames: false
files: apps/hermes
# Hooks for Fortuna
Expand All @@ -76,7 +76,7 @@ repos:
- id: cargo-clippy-message-buffer
name: Cargo clippy for message buffer contract
language: "rust"
entry: cargo +nightly-2023-03-01 clippy --manifest-path ./pythnet/message_buffer/Cargo.toml --tests --fix --allow-dirty --allow-staged --features test-bpf -- -D warnings
entry: cargo clippy --manifest-path ./pythnet/message_buffer/Cargo.toml --tests --fix --allow-dirty --allow-staged --features test-bpf -- -D warnings
pass_filenames: false
files: pythnet/message_buffer
# Hooks for pythnet_sdk
Expand All @@ -89,7 +89,7 @@ repos:
- id: cargo-clippy-pythnet-sdk
name: Cargo clippy for pythnet SDK
language: "rust"
entry: cargo +nightly-2024-08-04 clippy --manifest-path ./pythnet/pythnet_sdk/Cargo.toml --tests --fix --allow-dirty --allow-staged -- -D warnings
entry: cargo clippy --manifest-path ./pythnet/pythnet_sdk/Cargo.toml --tests --fix --allow-dirty --allow-staged -- -D warnings
pass_filenames: false
files: pythnet/pythnet_sdk
# Hooks for solana receiver contract
Expand All @@ -102,7 +102,7 @@ repos:
- id: cargo-clippy-pyth-solana-receiver
name: Cargo clippy for solana target chain contract
language: "rust"
entry: cargo +nightly-2023-03-01 clippy --manifest-path ./target_chains/solana/Cargo.toml --tests --fix --allow-dirty --allow-staged -- -D warnings
entry: cargo clippy --manifest-path ./target_chains/solana/Cargo.toml --tests --fix --allow-dirty --allow-staged -- -D warnings
pass_filenames: false
files: target_chains/solana
# For express relay python files
Expand Down
1 change: 0 additions & 1 deletion apps/fortuna/rust-toolchain

This file was deleted.

8 changes: 4 additions & 4 deletions apps/hermes/server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions apps/hermes/server/rust-toolchain

This file was deleted.

3 changes: 0 additions & 3 deletions apps/hermes/server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#![feature(never_type)]
#![feature(btree_cursors)]

use {
anyhow::Result,
clap::{
Expand Down
66 changes: 14 additions & 52 deletions apps/hermes/server/src/network/pythnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,30 @@
use {
crate::{
api::types::{
PriceFeedMetadata,
RpcPriceIdentifier,
},
api::types::{PriceFeedMetadata, RpcPriceIdentifier},
config::RunOptions,
network::wormhole::{
BridgeData,
GuardianSet,
GuardianSetData,
},
network::wormhole::{BridgeData, GuardianSet, GuardianSetData},
state::{
aggregate::{
AccumulatorMessages,
Aggregates,
Update,
},
price_feeds_metadata::{
PriceFeedMeta,
DEFAULT_PRICE_FEEDS_CACHE_UPDATE_INTERVAL,
},
aggregate::{AccumulatorMessages, Aggregates, Update},
price_feeds_metadata::{PriceFeedMeta, DEFAULT_PRICE_FEEDS_CACHE_UPDATE_INTERVAL},
wormhole::Wormhole,
},
},
anyhow::{
anyhow,
Result,
},
anyhow::{anyhow, Result},
borsh::BorshDeserialize,
futures::stream::StreamExt,
pyth_sdk::PriceIdentifier,
pyth_sdk_solana::state::{
load_mapping_account,
load_product_account,
},
pyth_sdk_solana::state::{load_mapping_account, load_product_account},
solana_account_decoder::UiAccountEncoding,
solana_client::{
nonblocking::{
pubsub_client::PubsubClient,
rpc_client::RpcClient,
},
rpc_config::{
RpcAccountInfoConfig,
RpcProgramAccountsConfig,
},
rpc_filter::{
Memcmp,
MemcmpEncodedBytes,
RpcFilterType,
},
nonblocking::{pubsub_client::PubsubClient, rpc_client::RpcClient},
rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig},
rpc_filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType},
},
solana_sdk::{
account::Account,
bs58,
commitment_config::CommitmentConfig,
pubkey::Pubkey,
system_program,
},
std::{
collections::BTreeMap,
sync::Arc,
time::Duration,
account::Account, bs58, commitment_config::CommitmentConfig, pubkey::Pubkey, system_program,
},
std::{collections::BTreeMap, sync::Arc, time::Duration},
tokio::time::Instant,
};

Expand Down Expand Up @@ -141,7 +103,7 @@ async fn fetch_bridge_data(
}
}

pub async fn run<S>(store: Arc<S>, pythnet_ws_endpoint: String) -> Result<!>
pub async fn run<S>(store: Arc<S>, pythnet_ws_endpoint: String) -> Result<()>
where
S: Aggregates,
S: Wormhole,
Expand All @@ -155,11 +117,11 @@ where
encoding: Some(UiAccountEncoding::Base64Zstd),
..Default::default()
},
filters: Some(vec![RpcFilterType::Memcmp(Memcmp::new(
filters: Some(vec![RpcFilterType::Memcmp(Memcmp::new(
0, // offset
MemcmpEncodedBytes::Bytes(b"PAS1".to_vec()), // bytes
))]),
with_context: Some(true),
with_context: Some(true),
};

// Listen for all PythNet accounts, we will filter down to the Accumulator related accounts.
Expand Down
2 changes: 1 addition & 1 deletion apps/hermes/server/src/network/wormhole.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ where
}

#[tracing::instrument(skip(opts, state))]
async fn run<S>(opts: RunOptions, state: Arc<S>) -> Result<!>
async fn run<S>(opts: RunOptions, state: Arc<S>) -> Result<()>
where
S: Wormhole,
S: Send + Sync + 'static,
Expand Down
6 changes: 2 additions & 4 deletions apps/hermes/server/src/state/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use {
HashMap,
HashSet,
},
ops::Bound,
sync::Arc,
},
strum::IntoEnumIterator,
Expand Down Expand Up @@ -300,8 +299,8 @@ async fn retrieve_message_state(

// Get the first element that is greater than or equal to the lookup time.
key_cache
.lower_bound(Bound::Included(&lookup_time))
.peek_next()
.range(lookup_time..)
.next()
.map(|(_, v)| v)
.cloned()
}
Expand Down Expand Up @@ -594,7 +593,6 @@ mod test {
);
}


#[tokio::test]
pub async fn test_store_and_retrieve_first_after_message_state_fails_for_past_time() {
// Initialize state with a cache size of 2 per key.
Expand Down
1 change: 1 addition & 0 deletions governance/remote_executor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"programs/*",
"cli/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,9 @@ impl From<ExecutorError> for TransactionError {
fn from(val: ExecutorError) -> Self {
TransactionError::InstructionError(
0,
InstructionError::try_from(u64::from(ProgramError::from(
InstructionError::from(u64::from(ProgramError::from(
anchor_lang::prelude::Error::from(val),
)))
.unwrap(),
))),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,9 @@ impl IntoTransactionError for ErrorCode {
fn into_transation_error(self) -> TransactionError {
TransactionError::InstructionError(
0,
InstructionError::try_from(u64::from(ProgramError::from(
InstructionError::from(u64::from(ProgramError::from(
anchor_lang::prelude::Error::from(self),
)))
.unwrap(),
))),
)
}
}
Expand Down
2 changes: 0 additions & 2 deletions governance/remote_executor/rust-toolchain.toml

This file was deleted.

Loading

0 comments on commit 92e5c5b

Please sign in to comment.