Skip to content

Commit

Permalink
Bump rust to 1.76.0 (#1720)
Browse files Browse the repository at this point in the history
* bump rust to `1.76.0`

* wip

* clippy

* update rust ver in ci

* upate dockerfile rust ver

* update ci image
  • Loading branch information
kariy authored Mar 29, 2024
1 parent defc01a commit 8d66222
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ENV LLVM_SYS_170_PREFIX=/usr/lib/llvm-17
ENV TABLEGEN_170_PREFIX=/usr/lib/llvm-17

# To allow independent workflow of the container, the rust-toolchain is explicitely given.
RUN echo "1.74.0" > rust_toolchain_version
RUN echo "1.76.0" > rust_toolchain_version

# Install cargo-binstall
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.github.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.74.0
RUST_VERSION: 1.76.0

jobs:
test:
runs-on: ubuntu-latest-16-cores
container:
image: nondeterministickari/dojo-dev:cc6554da
image: ghcr.io/dojoengine/dojo-dev:a884990
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
Expand All @@ -31,7 +31,7 @@ jobs:
ensure-wasm:
runs-on: ubuntu-latest
container:
image: nondeterministickari/dojo-dev:cc6554da
image: ghcr.io/dojoengine/dojo-dev:a884990
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
dojo-core-test:
runs-on: ubuntu-latest
container:
image: nondeterministickari/dojo-dev:cc6554da
image: ghcr.io/dojoengine/dojo-dev:a884990
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
Expand All @@ -75,7 +75,7 @@ jobs:
dojo-spawn-and-move-example-test:
runs-on: ubuntu-latest
container:
image: nondeterministickari/dojo-dev:cc6554da
image: ghcr.io/dojoengine/dojo-dev:a884990
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
Expand All @@ -84,7 +84,7 @@ jobs:
dojo-world-bindings-check:
runs-on: ubuntu-latest
container:
image: nondeterministickari/dojo-dev:cc6554da
image: ghcr.io/dojoengine/dojo-dev:a884990
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
Expand All @@ -93,7 +93,7 @@ jobs:
clippy:
runs-on: ubuntu-latest
container:
image: nondeterministickari/dojo-dev:cc6554da
image: ghcr.io/dojoengine/dojo-dev:a884990
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
Expand All @@ -102,7 +102,7 @@ jobs:
fmt:
runs-on: ubuntu-latest
container:
image: nondeterministickari/dojo-dev:cc6554da
image: ghcr.io/dojoengine/dojo-dev:a884990
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
Expand All @@ -111,7 +111,7 @@ jobs:
docs:
runs-on: ubuntu-latest
container:
image: nondeterministickari/dojo-dev:cc6554da
image: ghcr.io/dojoengine/dojo-dev:a884990
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.74.0
RUST_VERSION: 1.76.0
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}

jobs:
Expand Down
2 changes: 1 addition & 1 deletion crates/benches/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() {
}
}

let mut pairs = map.into_iter().map(|(name, runs)| (name, runs)).collect::<Vec<_>>();
let mut pairs = map.into_iter().collect::<Vec<_>>();
pairs.sort_by_key(|(key, _)| key.clone());

for (name, mut runs) in pairs {
Expand Down
4 changes: 2 additions & 2 deletions crates/dojo-types/src/packing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ mod tests {

#[test]
fn parse_simple_with_invalid_value() {
let data = &vec![FieldElement::default()];
assert!(matches!(super::parse_simple(data), Err(ParseError::InvalidSchema)));
let data = [FieldElement::default()];
assert!(matches!(super::parse_simple(&data), Err(ParseError::InvalidSchema)));
}
}
16 changes: 7 additions & 9 deletions crates/katana/core/src/service/messaging/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,18 @@ impl<EF: ExecutorFactory> MessagingService<EF> {
} else {
match messenger.as_ref() {
MessengerMode::Ethereum(inner) => {
let hashes = inner
.send_messages(&messages)
.await
.map(|hashes| hashes.iter().map(|h| format!("{h:#x}")).collect())?;
let hashes = inner.send_messages(&messages).await.map(|hashes| {
hashes.iter().map(|h| format!("{h:#x}")).collect::<Vec<_>>()
})?;
trace_msg_to_l1_sent(&messages, &hashes);
Ok(Some((block_num, hashes.len())))
}

#[cfg(feature = "starknet-messaging")]
MessengerMode::Starknet(inner) => {
let hashes = inner
.send_messages(&messages)
.await
.map(|hashes| hashes.iter().map(|h| format!("{h:#x}")).collect())?;
let hashes = inner.send_messages(&messages).await.map(|hashes| {
hashes.iter().map(|h| format!("{h:#x}")).collect::<Vec<_>>()
})?;
trace_msg_to_l1_sent(&messages, &hashes);
Ok(Some((block_num, hashes.len())))
}
Expand Down Expand Up @@ -251,7 +249,7 @@ fn interval_from_seconds(secs: u64) -> Interval {
interval
}

fn trace_msg_to_l1_sent(messages: &Vec<MessageToL1>, hashes: &Vec<String>) {
fn trace_msg_to_l1_sent(messages: &[MessageToL1], hashes: &[String]) {
assert_eq!(messages.len(), hashes.len());

#[cfg(feature = "starknet-messaging")]
Expand Down
68 changes: 34 additions & 34 deletions crates/katana/primitives/src/utils/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,40 @@ pub fn compute_l1_message_hash(
H256::from_slice(msg.hash().as_bytes())
}

fn encode_gas_bound(name: &[u8], bound: &ResourceBounds) -> FieldElement {
let mut buffer = [0u8; 32];
let (remainder, max_price) = buffer.split_at_mut(128 / 8);
let (gas_kind, max_amount) = remainder.split_at_mut(64 / 8);

let padding = gas_kind.len() - name.len();
gas_kind[padding..].copy_from_slice(name);
max_amount.copy_from_slice(&bound.max_amount.to_be_bytes());
max_price.copy_from_slice(&bound.max_price_per_unit.to_be_bytes());

FieldElement::from_bytes_be(&buffer).expect("Packed resource should fit into felt")
}

fn hash_fee_fields(
tip: u64,
l1_gas_bounds: &ResourceBounds,
l2_gas_bounds: &ResourceBounds,
) -> FieldElement {
poseidon_hash_many(&[
tip.into(),
encode_gas_bound(b"L1_GAS", l1_gas_bounds),
encode_gas_bound(b"L2_GAS", l2_gas_bounds),
])
}

fn encode_da_mode(
nonce_da_mode: &DataAvailabilityMode,
fee_da_mode: &DataAvailabilityMode,
) -> FieldElement {
let nonce = (*nonce_da_mode as u64) << 32;
let fee = *fee_da_mode as u64;
FieldElement::from(nonce + fee)
}

#[cfg(test)]
mod tests {
use starknet::core::chain_id;
Expand Down Expand Up @@ -334,37 +368,3 @@ mod tests {
);
}
}

fn encode_gas_bound(name: &[u8], bound: &ResourceBounds) -> FieldElement {
let mut buffer = [0u8; 32];
let (remainder, max_price) = buffer.split_at_mut(128 / 8);
let (gas_kind, max_amount) = remainder.split_at_mut(64 / 8);

let padding = gas_kind.len() - name.len();
gas_kind[padding..].copy_from_slice(name);
max_amount.copy_from_slice(&bound.max_amount.to_be_bytes());
max_price.copy_from_slice(&bound.max_price_per_unit.to_be_bytes());

FieldElement::from_bytes_be(&buffer).expect("Packed resource should fit into felt")
}

fn hash_fee_fields(
tip: u64,
l1_gas_bounds: &ResourceBounds,
l2_gas_bounds: &ResourceBounds,
) -> FieldElement {
poseidon_hash_many(&[
tip.into(),
encode_gas_bound(b"L1_GAS", l1_gas_bounds),
encode_gas_bound(b"L2_GAS", l2_gas_bounds),
])
}

fn encode_da_mode(
nonce_da_mode: &DataAvailabilityMode,
fee_da_mode: &DataAvailabilityMode,
) -> FieldElement {
let nonce = (*nonce_da_mode as u64) << 32;
let fee = *fee_da_mode as u64;
FieldElement::from(nonce + fee)
}
2 changes: 2 additions & 0 deletions crates/katana/rpc/rpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::blocks_in_conditions)]

pub mod config;
pub mod dev;
pub mod katana;
Expand Down
1 change: 1 addition & 0 deletions crates/torii/graphql/src/tests/models_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ mod tests {

// End to end test spins up a test sequencer and deploys types-test project, this takes a while
// to run so combine all related tests into one
#[allow(clippy::get_first)]
#[tokio::test(flavor = "multi_thread")]
async fn models_test() -> Result<()> {
let pool = spinup_types_test().await?;
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.74.0"
channel = "1.76.0"

0 comments on commit 8d66222

Please sign in to comment.