Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: switch to stable rust versions #2093

Merged
merged 8 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci-cosmwasm-contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ jobs:
working-directory: target_chains/cosmwasm/contracts/pyth
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.82.0
components: rustfmt, clippy
override: true
- name: Build
run: cargo build --verbose
- name: Run tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-fortuna.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2023-07-23
toolchain: 1.82.0
override: true
- name: Run executor tests
run: cargo test --manifest-path ./apps/fortuna/Cargo.toml
2 changes: 1 addition & 1 deletion .github/workflows/ci-hermes-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2024-03-26
toolchain: 1.82.0
components: rustfmt, clippy
override: true
- name: Install protoc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-message-buffer-idl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2023-03-01
toolchain: 1.66.1
components: rustfmt, clippy
- name: Install Solana
run: |
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/ci-pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ jobs:
profile: minimal
toolchain: nightly-2024-08-04
components: rustfmt, clippy
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.66.1
components: rustfmt, clippy
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.73.0
components: rustfmt, clippy
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.82.0
components: rustfmt, clippy
- name: Install protoc
uses: arduino/setup-protoc@v3
- uses: actions/checkout@v4
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ci-solana-contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jobs:
working-directory: target_chains/solana
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.73.0
override: true
- name: Install Solana
run: |
sh -c "$(curl -sSfL https://release.solana.com/v1.16.20/install)"
Expand Down
18 changes: 12 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 +1.66.1 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 +1.82.0 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 +1.82.0 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 @@ -66,6 +66,12 @@ repos:
entry: cargo +nightly-2023-07-23 fmt --manifest-path ./apps/fortuna/Cargo.toml --all -- --config-path rustfmt.toml
pass_filenames: false
files: apps/fortuna
- id: cargo-clippy-fortuna
name: Cargo clippy for Fortuna
language: "rust"
entry: cargo +1.82.0 clippy --manifest-path ./apps/fortuna/Cargo.toml --tests --fix --allow-dirty --allow-staged -- -D warnings
pass_filenames: false
files: apps/fortuna
# Hooks for message buffer contract
- id: cargo-fmt-message-buffer
name: Cargo format for message buffer contract
Expand All @@ -76,7 +82,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 +1.66.1 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 +95,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 +1.82.0 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 +108,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 +1.73.0 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
28 changes: 22 additions & 6 deletions apps/fortuna/Cargo.lock

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

5 changes: 1 addition & 4 deletions apps/fortuna/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
ARG RUST_VERSION=1.66.1
ARG RUST_VERSION=1.82.0

FROM rust:${RUST_VERSION} AS build

# Set default toolchain
RUN rustup default nightly-2023-07-23

# Build
WORKDIR /src
COPY apps/fortuna apps/fortuna
Expand Down
2 changes: 1 addition & 1 deletion apps/fortuna/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2023-07-23
1.82.0
4 changes: 2 additions & 2 deletions apps/fortuna/src/api/revelation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub async fn revelation(
let state = state
.chains
.get(&chain_id)
.ok_or_else(|| RestError::InvalidChainId)?;
.ok_or(RestError::InvalidChainId)?;

let maybe_request_fut = state.contract.get_request(state.provider_address, sequence);

Expand All @@ -85,7 +85,7 @@ pub async fn revelation(
);
RestError::Unknown
})?;
let encoded_value = Blob::new(encoding.unwrap_or(BinaryEncoding::Hex), value.clone());
let encoded_value = Blob::new(encoding.unwrap_or(BinaryEncoding::Hex), *value);

Ok(Json(GetRandomValueResponse {
value: encoded_value,
Expand Down
8 changes: 4 additions & 4 deletions apps/fortuna/src/chain/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ impl<T: JsonRpcClient + 'static + Clone> SignablePythContractInner<T> {
if let PythRandomEvents::RequestedFilter(r) = PythRandomEvents::decode_log(&l)? {
Ok(r.request.sequence_number)
} else {
Err(anyhow!("No log with sequence number").into())
Err(anyhow!("No log with sequence number"))
}
} else {
Err(anyhow!("Request failed").into())
Err(anyhow!("Request failed"))
}
}

Expand Down Expand Up @@ -238,10 +238,10 @@ impl<T: JsonRpcClient + 'static + Clone> SignablePythContractInner<T> {
{
Ok(r.random_number)
} else {
Err(anyhow!("No log with randomnumber").into())
Err(anyhow!("No log with randomnumber"))
}
} else {
Err(anyhow!("Request failed").into())
Err(anyhow!("Request failed"))
}
}

Expand Down
6 changes: 3 additions & 3 deletions apps/fortuna/src/chain/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ pub enum BlockStatus {
Safe,
}

impl Into<EthersBlockNumber> for BlockStatus {
fn into(self) -> EthersBlockNumber {
match self {
impl From<BlockStatus> for EthersBlockNumber {
fn from(val: BlockStatus) -> Self {
match val {
BlockStatus::Latest => EthersBlockNumber::Latest,
BlockStatus::Finalized => EthersBlockNumber::Finalized,
BlockStatus::Safe => EthersBlockNumber::Safe,
Expand Down
2 changes: 1 addition & 1 deletion apps/fortuna/src/command/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub async fn generate(opts: &GenerateOptions) -> Result<()> {
&provider,
sequence_number,
&user_randomness,
&provider_randomness,
provider_randomness,
)
.await?;

Expand Down
8 changes: 4 additions & 4 deletions apps/fortuna/src/command/register_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub async fn register_provider_from_config(

// Initialize a Provider to interface with the EVM contract.
let contract =
Arc::new(SignablePythContract::from_config(&chain_config, &private_key_string).await?);
Arc::new(SignablePythContract::from_config(chain_config, &private_key_string).await?);
// Create a new random hash chain.
let random = rand::random::<[u8; 32]>();
let secret = provider_config
Expand All @@ -68,7 +68,7 @@ pub async fn register_provider_from_config(
tracing::info!("Generating hash chain");
let chain = PebbleHashChain::from_config(
&secret,
&chain_id,
chain_id,
&private_key_string.parse::<LocalWallet>()?.address(),
&chain_config.contract_addr,
&random,
Expand All @@ -86,7 +86,7 @@ pub async fn register_provider_from_config(
seed: random,
chain_length: commitment_length,
};
let uri = get_register_uri(&provider_config.uri, &chain_id)?;
let uri = get_register_uri(&provider_config.uri, chain_id)?;
let call = contract.register(
fee_in_wei,
commitment,
Expand All @@ -98,7 +98,7 @@ pub async fn register_provider_from_config(
);
let mut gas_estimate = call.estimate_gas().await?;
let gas_multiplier = U256::from(2); //TODO: smarter gas estimation
gas_estimate = gas_estimate * gas_multiplier;
gas_estimate *= gas_multiplier;
let call_with_gas = call.gas(gas_estimate);
if let Some(r) = call_with_gas.send().await?.await? {
tracing::info!("Registered provider: {:?}", r);
Expand Down
16 changes: 8 additions & 8 deletions apps/fortuna/src/command/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub async fn run(opts: &RunOptions) -> Result<()> {
rpc_metrics.clone(),
));

run_api(opts.addr.clone(), chains, metrics_registry, rx_exit).await?;
run_api(opts.addr, chains, metrics_registry, rx_exit).await?;

Ok(())
}
Expand All @@ -251,11 +251,11 @@ async fn setup_chain_state(
rpc_metrics: Arc<RpcMetrics>,
) -> Result<BlockchainState> {
let contract = Arc::new(InstrumentedPythContract::from_config(
&chain_config,
chain_config,
chain_id.clone(),
rpc_metrics,
)?);
let mut provider_commitments = chain_config.commitments.clone().unwrap_or(Vec::new());
let mut provider_commitments = chain_config.commitments.clone().unwrap_or_default();
provider_commitments.sort_by(|c1, c2| {
c1.original_commitment_sequence_number
.cmp(&c2.original_commitment_sequence_number)
Expand Down Expand Up @@ -301,9 +301,9 @@ async fn setup_chain_state(
offsets.push(offset);

let pebble_hash_chain = PebbleHashChain::from_config(
&secret,
&chain_id,
&provider,
secret,
chain_id,
provider,
&chain_config.contract_addr,
&commitment.seed,
commitment.chain_length,
Expand All @@ -321,7 +321,7 @@ async fn setup_chain_state(
if chain_state.reveal(provider_info.original_commitment_sequence_number)?
!= provider_info.original_commitment
{
return Err(anyhow!("The root of the generated hash chain for chain id {} does not match the commitment. Are the secret and chain length configured correctly?", &chain_id).into());
return Err(anyhow!("The root of the generated hash chain for chain id {} does not match the commitment. Are the secret and chain length configured correctly?", &chain_id));
} else {
tracing::info!("Root of chain id {} matches commitment", &chain_id);
}
Expand All @@ -330,7 +330,7 @@ async fn setup_chain_state(
id: chain_id.clone(),
state: Arc::new(chain_state),
contract,
provider_address: provider.clone(),
provider_address: *provider,
reveal_delay_blocks: chain_config.reveal_delay_blocks,
confirmed_block_status: chain_config.confirmed_block_status,
};
Expand Down
Loading
Loading