Skip to content

Commit 319adab

Browse files
committed
chore(apps/fortuna): update to stable rust
1 parent f7595c0 commit 319adab

File tree

17 files changed

+85
-73
lines changed

17 files changed

+85
-73
lines changed

.github/workflows/ci-fortuna.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions-rs/toolchain@v1
1515
with:
1616
profile: minimal
17-
toolchain: nightly-2023-07-23
17+
toolchain: 1.82.0
1818
override: true
1919
- name: Run executor tests
2020
run: cargo test --manifest-path ./apps/fortuna/Cargo.toml

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ repos:
6666
entry: cargo +nightly-2023-07-23 fmt --manifest-path ./apps/fortuna/Cargo.toml --all -- --config-path rustfmt.toml
6767
pass_filenames: false
6868
files: apps/fortuna
69+
- id: cargo-clippy-fortuna
70+
name: Cargo clippy for Fortuna
71+
language: "rust"
72+
entry: cargo +1.82.0 clippy --manifest-path ./apps/fortuna/Cargo.toml --tests --fix --allow-dirty --allow-staged -- -D warnings
73+
pass_filenames: false
74+
files: apps/fortuna
6975
# Hooks for message buffer contract
7076
- id: cargo-fmt-message-buffer
7177
name: Cargo format for message buffer contract

apps/fortuna/Cargo.lock

Lines changed: 22 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/fortuna/Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
ARG RUST_VERSION=1.66.1
1+
ARG RUST_VERSION=1.82.0
22

33
FROM rust:${RUST_VERSION} AS build
44

5-
# Set default toolchain
6-
RUN rustup default nightly-2023-07-23
7-
85
# Build
96
WORKDIR /src
107
COPY apps/fortuna apps/fortuna

apps/fortuna/rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2023-07-23
1+
1.82.0

apps/fortuna/src/api/revelation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub async fn revelation(
5858
let state = state
5959
.chains
6060
.get(&chain_id)
61-
.ok_or_else(|| RestError::InvalidChainId)?;
61+
.ok_or(RestError::InvalidChainId)?;
6262

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

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

9090
Ok(Json(GetRandomValueResponse {
9191
value: encoded_value,

apps/fortuna/src/chain/ethereum.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ impl<T: JsonRpcClient + 'static + Clone> SignablePythContractInner<T> {
204204
if let PythRandomEvents::RequestedFilter(r) = PythRandomEvents::decode_log(&l)? {
205205
Ok(r.request.sequence_number)
206206
} else {
207-
Err(anyhow!("No log with sequence number").into())
207+
Err(anyhow!("No log with sequence number"))
208208
}
209209
} else {
210-
Err(anyhow!("Request failed").into())
210+
Err(anyhow!("Request failed"))
211211
}
212212
}
213213

@@ -238,10 +238,10 @@ impl<T: JsonRpcClient + 'static + Clone> SignablePythContractInner<T> {
238238
{
239239
Ok(r.random_number)
240240
} else {
241-
Err(anyhow!("No log with randomnumber").into())
241+
Err(anyhow!("No log with randomnumber"))
242242
}
243243
} else {
244-
Err(anyhow!("Request failed").into())
244+
Err(anyhow!("Request failed"))
245245
}
246246
}
247247

apps/fortuna/src/chain/reader.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ pub enum BlockStatus {
2323
Safe,
2424
}
2525

26-
impl Into<EthersBlockNumber> for BlockStatus {
27-
fn into(self) -> EthersBlockNumber {
28-
match self {
26+
impl From<BlockStatus> for EthersBlockNumber {
27+
fn from(val: BlockStatus) -> Self {
28+
match val {
2929
BlockStatus::Latest => EthersBlockNumber::Latest,
3030
BlockStatus::Finalized => EthersBlockNumber::Finalized,
3131
BlockStatus::Safe => EthersBlockNumber::Safe,

apps/fortuna/src/command/generate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub async fn generate(opts: &GenerateOptions) -> Result<()> {
5656
&provider,
5757
sequence_number,
5858
&user_randomness,
59-
&provider_randomness,
59+
provider_randomness,
6060
)
6161
.await?;
6262

apps/fortuna/src/command/register_provider.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub async fn register_provider_from_config(
5656

5757
// Initialize a Provider to interface with the EVM contract.
5858
let contract =
59-
Arc::new(SignablePythContract::from_config(&chain_config, &private_key_string).await?);
59+
Arc::new(SignablePythContract::from_config(chain_config, &private_key_string).await?);
6060
// Create a new random hash chain.
6161
let random = rand::random::<[u8; 32]>();
6262
let secret = provider_config
@@ -68,7 +68,7 @@ pub async fn register_provider_from_config(
6868
tracing::info!("Generating hash chain");
6969
let chain = PebbleHashChain::from_config(
7070
&secret,
71-
&chain_id,
71+
chain_id,
7272
&private_key_string.parse::<LocalWallet>()?.address(),
7373
&chain_config.contract_addr,
7474
&random,
@@ -86,7 +86,7 @@ pub async fn register_provider_from_config(
8686
seed: random,
8787
chain_length: commitment_length,
8888
};
89-
let uri = get_register_uri(&provider_config.uri, &chain_id)?;
89+
let uri = get_register_uri(&provider_config.uri, chain_id)?;
9090
let call = contract.register(
9191
fee_in_wei,
9292
commitment,
@@ -98,7 +98,7 @@ pub async fn register_provider_from_config(
9898
);
9999
let mut gas_estimate = call.estimate_gas().await?;
100100
let gas_multiplier = U256::from(2); //TODO: smarter gas estimation
101-
gas_estimate = gas_estimate * gas_multiplier;
101+
gas_estimate *= gas_multiplier;
102102
let call_with_gas = call.gas(gas_estimate);
103103
if let Some(r) = call_with_gas.send().await?.await? {
104104
tracing::info!("Registered provider: {:?}", r);

0 commit comments

Comments
 (0)