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

Lock rust nightly versions #6

Merged
merged 14 commits into from
Jul 19, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/mips.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: nightly-2023-05-03
default: true
override: true
components: rust-src
Expand Down
24 changes: 3 additions & 21 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ on:
pull_request:
branches:
- main
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"

jobs:
build-mips:
Expand All @@ -24,19 +21,14 @@ jobs:
uses: actions/checkout@v3
with:
lfs: true
- uses: Swatinem/rust-cache@v2
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install development tools
uses: taiki-e/[email protected]
with:
tool: cargo-nextest,just
- name: Install `rust` toolchain
run: |
rustup toolchain install nightly --no-self-update --profile minimal
rustup default nightly
rustup toolchain install nightly-2023-05-03 --no-self-update --profile minimal
rustup default nightly-2023-05-03
- name: Setup protoc
uses: arduino/[email protected]
- name: Download consensus-spec-tests
Expand All @@ -60,11 +52,6 @@ jobs:
steps:
- name: Checkout Source
uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup protoc
uses: arduino/[email protected]
- uses: actions-rs/cargo@v1
Expand All @@ -76,15 +63,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: nightly-2023-05-03
override: true
components: clippy,rustfmt
- name: Run cargo fmt
Expand Down
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ exclude = [
"zipline-state-transition-mips"
]

[workspace.dependencies]
ssz-rs = { path = "./finality-client/libs/ssz-rs/ssz-rs", default-features = false }
ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus" }

[patch.crates-io]
blst = { git = "https://github.com/ec2/blst", rev = "179bf0e" }
[patch."https://github.com/ralexstokes/ethereum-consensus"]
# ethereum-consensus = { git = "https://github.com/ralexstokes//ethereum-consensus", rev = "ef89b4a4ef97cdd53a66ddb52e554667aca0beb2" }
ethereum-consensus = { git = "https://github.com/ralexstokes//ethereum-consensus", rev = "ef89b4a4ef97cdd53a66ddb52e554667aca0beb2" }
[patch."https://github.com/ralexstokes/ssz-rs"]
# patched version to build in restricted_std. Compatible with version of ethereum-consensus above
ssz-rs = { path = "./finality-client/libs/ssz-rs/ssz-rs" }
Expand Down
4 changes: 2 additions & 2 deletions finality-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ crypto = { path = "libs/crypto" }
zipline-spec = { path = "libs/zipline-spec" }
validator-shuffling = { path = "libs/validator-shuffling" }
log = "0.4.17"
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", default-features = false }
ssz-rs = { workspace = true }
hex = { version = "0.4.3", default-features = false }
typenum = {version = "1.16.0", feature=["no_std"]}
# snap = "1.1.0" # breaks MIPS build. We could easily patch it though once we need it
once_cell = {version = "1.17", default-features = false}

[dev-dependencies]
env_logger = "0.10.0"
ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus" }
ethereum-consensus = { workspace = true }
serde = "1.0.158"

test-utils = { path = "libs/test-utils" }
Expand Down
2 changes: 1 addition & 1 deletion finality-client/libs/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sha2 = { version = "0.10.6", default-features = false }

[dev-dependencies]
test-utils = { path = "../test-utils" }
ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus" }
ethereum-consensus = { workspace = true }
serde = "1.0.158"
serde_with = "1.13.0"

6 changes: 2 additions & 4 deletions finality-client/libs/ssz-rs/ssz-rs-derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::all)]
//! `SimpleSerialize` provides a macro to derive SSZ containers and union types from
//! native Rust structs and enums.
//! Refer to the `examples` in the `ssz_rs` crate for a better idea on how to use this derive macro.
Expand Down Expand Up @@ -180,7 +181,7 @@ fn derive_deserialize_impl(data: &Data) -> TokenStream {

Ok(container)
}
};
}
}
_ => unimplemented!(
"this type of struct is currently not supported by this derive macro"
Expand Down Expand Up @@ -469,12 +470,9 @@ fn derive_treeify_impl(data: &Data) -> TokenStream {
quote_spanned! { variant.span() =>
Self::#variant_name(value) => {
let mut tree = value.to_merkle_tree()?;

let selector = #i;
let data_root = value.hash_tree_root()?;
tree.push(ssz_rs::__internal::mix_in_selector_tree(&data_root, selector));


Ok(tree)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ fn main() {
Ok(encoding) => encoding,
Err(err) => {
eprintln!("some error encoding: {err}");
return;
return
}
};

let mut restored_example = match Foo::<4>::deserialize(&encoding) {
Ok(value) => value,
Err(err) => {
eprintln!("some error decoding: {err}");
return;
return
}
};

Expand Down
8 changes: 4 additions & 4 deletions finality-client/libs/ssz-rs/ssz-rs/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ macro_rules! define_ssz_for_array_of_size {
{
fn serialize(&self, buffer: &mut Vec<u8>) -> Result<usize, SerializeError> {
if $n == 0 {
return Err(TypeError::InvalidBound($n).into());
return Err(TypeError::InvalidBound($n).into())
}
serialize_composite(self, buffer)
}
Expand All @@ -47,7 +47,7 @@ macro_rules! define_ssz_for_array_of_size {
{
fn deserialize(encoding: &[u8]) -> Result<Self, DeserializeError> {
if $n == 0 {
return Err(TypeError::InvalidBound($n).into());
return Err(TypeError::InvalidBound($n).into())
}

if !T::is_variable_size() {
Expand All @@ -56,13 +56,13 @@ macro_rules! define_ssz_for_array_of_size {
return Err(DeserializeError::ExpectedFurtherInput {
provided: encoding.len(),
expected: expected_length,
});
})
}
if encoding.len() > expected_length {
return Err(DeserializeError::AdditionalInput {
provided: encoding.len(),
expected: expected_length,
});
})
}
}
let elements = deserialize_homogeneous_composite(encoding)?;
Expand Down
10 changes: 5 additions & 5 deletions finality-client/libs/ssz-rs/ssz-rs/src/bitlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<const N: usize> Bitlist<N> {
with_length_bit: bool,
) -> Result<usize, SerializeError> {
if self.len() > N {
return Err(InstanceError::Bounded { bound: N, provided: self.len() }.into());
return Err(InstanceError::Bounded { bound: N, provided: self.len() }.into())
}
let start_len = buffer.len();
buffer.extend_from_slice(self.as_raw_slice());
Expand Down Expand Up @@ -151,14 +151,14 @@ impl<const N: usize> Deserialize for Bitlist<N> {
fn deserialize(encoding: &[u8]) -> Result<Self, DeserializeError> {
let max_len = byte_length(N);
if encoding.is_empty() {
return Err(DeserializeError::ExpectedFurtherInput { provided: 0, expected: max_len });
return Err(DeserializeError::ExpectedFurtherInput { provided: 0, expected: max_len })
}

if encoding.len() > max_len {
return Err(DeserializeError::AdditionalInput {
provided: encoding.len(),
expected: max_len,
});
})
}

let (last_byte, prefix) = encoding.split_last().unwrap();
Expand All @@ -167,15 +167,15 @@ impl<const N: usize> Deserialize for Bitlist<N> {
let high_bit_index = 8 - last.trailing_zeros();

if !last[high_bit_index - 1] {
return Err(DeserializeError::InvalidByte(*last_byte));
return Err(DeserializeError::InvalidByte(*last_byte))
}

for bit in last.iter().take(high_bit_index - 1) {
result.push(*bit);
}
// TODO: this seems redundant...
if result.len() > N {
return Err(InstanceError::Bounded { bound: N, provided: result.len() }.into());
return Err(InstanceError::Bounded { bound: N, provided: result.len() }.into())
}
Ok(Self(result))
}
Expand Down
10 changes: 5 additions & 5 deletions finality-client/libs/ssz-rs/ssz-rs/src/bitvector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl<const N: usize> Sized for Bitvector<N> {
impl<const N: usize> Serialize for Bitvector<N> {
fn serialize(&self, buffer: &mut Vec<u8>) -> Result<usize, SerializeError> {
if N == 0 {
return Err(TypeError::InvalidBound(N).into());
return Err(TypeError::InvalidBound(N).into())
}
let bytes_to_write = Self::size_hint();
buffer.reserve(bytes_to_write);
Expand All @@ -141,21 +141,21 @@ impl<const N: usize> Serialize for Bitvector<N> {
impl<const N: usize> Deserialize for Bitvector<N> {
fn deserialize(encoding: &[u8]) -> Result<Self, DeserializeError> {
if N == 0 {
return Err(TypeError::InvalidBound(N).into());
return Err(TypeError::InvalidBound(N).into())
}

let expected_length = byte_length(N);
if encoding.len() < expected_length {
return Err(DeserializeError::ExpectedFurtherInput {
provided: encoding.len(),
expected: expected_length,
});
})
}
if encoding.len() > expected_length {
return Err(DeserializeError::AdditionalInput {
provided: encoding.len(),
expected: expected_length,
});
})
}

let mut result = Self::default();
Expand All @@ -167,7 +167,7 @@ impl<const N: usize> Deserialize for Bitvector<N> {
let last_byte = encoding.last().unwrap();
let remainder_bits = last_byte >> remainder_count;
if remainder_bits != 0 {
return Err(DeserializeError::InvalidByte(*last_byte));
return Err(DeserializeError::InvalidByte(*last_byte))
}
}
Ok(result)
Expand Down
6 changes: 3 additions & 3 deletions finality-client/libs/ssz-rs/ssz-rs/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ where
return Err(DeserializeError::AdditionalInput {
provided: encoding.len(),
expected: encoding.len() - remainder,
});
})
}

let mut elements = vec![];
Expand All @@ -77,7 +77,7 @@ where
T: SimpleSerialize,
{
if encoding.is_empty() {
return Ok(vec![]);
return Ok(vec![])
}

let data_pointer = u32::deserialize(&encoding[..BYTES_PER_LENGTH_OFFSET])?;
Expand All @@ -86,7 +86,7 @@ where
return Err(DeserializeError::ExpectedFurtherInput {
provided: encoding.len(),
expected: data_pointer,
});
})
}

let offsets = &mut encoding[..data_pointer]
Expand Down
3 changes: 2 additions & 1 deletion finality-client/libs/ssz-rs/ssz-rs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::all)]
#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(not(feature = "std"))]
Expand Down Expand Up @@ -26,7 +27,7 @@ pub use crate::{
de::{Deserialize, DeserializeError},
error::{Error as SimpleSerializeError, InstanceError, TypeError},
list::List,
merkleization::{is_valid_merkle_branch, compute_proof, MerkleizationError, Merkleized, Node},
merkleization::{compute_proof, is_valid_merkle_branch, MerkleizationError, Merkleized, Node},
ser::{Serialize, SerializeError},
uint::U256,
utils::{deserialize, serialize},
Expand Down
4 changes: 2 additions & 2 deletions finality-client/libs/ssz-rs/ssz-rs/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ where
{
fn serialize(&self, buffer: &mut Vec<u8>) -> Result<usize, SerializeError> {
if self.len() > N {
return Err(InstanceError::Bounded { bound: N, provided: self.len() }.into());
return Err(InstanceError::Bounded { bound: N, provided: self.len() }.into())
}
serialize_composite(&self.data, buffer)
}
Expand All @@ -201,7 +201,7 @@ where
fn deserialize(encoding: &[u8]) -> Result<Self, DeserializeError> {
let result = deserialize_homogeneous_composite(encoding)?;
if result.len() > N {
return Err(InstanceError::Bounded { bound: N, provided: result.len() }.into());
return Err(InstanceError::Bounded { bound: N, provided: result.len() }.into())
}
let result = result.try_into().map_err(|(_, err)| match err {
Error::Instance(err) => DeserializeError::InvalidInstance(err),
Expand Down
10 changes: 5 additions & 5 deletions finality-client/libs/ssz-rs/ssz-rs/src/merkleization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use sha2::{Digest, Sha256};

pub use cache::Cache as MerkleCache;
pub use node::Node;
pub use proofs::{is_valid_merkle_branch, compute_proof};
pub use proofs::{compute_proof, is_valid_merkle_branch};

pub(crate) const BYTES_PER_CHUNK: usize = 32;

Expand Down Expand Up @@ -118,7 +118,7 @@ fn merkleize_chunks_with_virtual_padding(

if chunk_count == 0 {
let depth = height - 1;
return Ok(CONTEXT[depth as usize].try_into().expect("can produce a single root chunk"));
return Ok(CONTEXT[depth as usize].try_into().expect("can produce a single root chunk"))
}

let mut layer = chunks.to_vec();
Expand Down Expand Up @@ -193,7 +193,7 @@ fn treeify_chunks_with_virtual_padding(
let mut ret = vec![];

if chunk_count == 0 {
return Ok(ret);
return Ok(ret)
}

let mut layer = chunks.to_vec();
Expand Down Expand Up @@ -281,7 +281,7 @@ pub fn merkleize(chunks: &[u8], limit: Option<usize>) -> Result<Node, Merkleizat
let mut leaf_count = chunk_count.next_power_of_two();
if let Some(limit) = limit {
if limit < chunk_count {
return Err(MerkleizationError::InputExceedsLimit(limit));
return Err(MerkleizationError::InputExceedsLimit(limit))
}
leaf_count = limit.next_power_of_two();
}
Expand All @@ -297,7 +297,7 @@ pub fn treeify(
let mut leaf_count = chunk_count.next_power_of_two();
if let Some(limit) = limit {
if limit < chunk_count {
return Err(MerkleizationError::InputExceedsLimit(limit));
return Err(MerkleizationError::InputExceedsLimit(limit))
}
leaf_count = limit.next_power_of_two();
}
Expand Down
Loading
Loading