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

Update rust-toolchain version #1613

Merged
merged 21 commits into from
Mar 18, 2022
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ The crates in this repository do not adhere to [Semantic Versioning](https://sem
### Changed

### Rust Dependencies
* Updated `rust-toolchain` version to newer nightly
* enables use of [Generic Associated Types](https://github.com/rust-lang/rust/issues/44265) and [static async fn in traits](https://github.com/rust-lang/rust/issues/91611)
* Replaced `datatest` with a custom `test_with_data` macro.
* Updated grpcio from 0.9 to 0.10.

## [1.2.0] 2022-02-22
Expand Down
25 changes: 13 additions & 12 deletions Cargo.lock

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

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,6 @@ ed25519-dalek = { git = "https://github.com/mobilecoinfoundation/ed25519-dalek.g
mbedtls = { git = "https://github.com/mobilecoinofficial/rust-mbedtls.git", rev = "49a293a5f4b1ef571c71174e3fa1f301925f3915" }
mbedtls-sys-auto = { git = "https://github.com/mobilecoinofficial/rust-mbedtls.git", rev = "49a293a5f4b1ef571c71174e3fa1f301925f3915" }

# Pin packed_simd_2 to the commit right before they renamed the `const_generics` feature override.
# TODO: Remove when we upgrade to a newer rust version (where const_generics was renamed to `adt_const_params`)
packed_simd_2 = { git = "https://github.com/rust-lang/packed_simd.git", rev = "064df9b1869b942fa768bfa83596f6965fa858c8" }

# Override lmdb-rkv for a necessary bugfix (see https://github.com/mozilla/lmdb-rs/pull/80)
lmdb-rkv = { git = "https://github.com/mozilla/lmdb-rs", rev = "df1c2f5" }

Expand Down
1 change: 1 addition & 0 deletions android-bindings/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build
.gradle
30 changes: 18 additions & 12 deletions android-bindings/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Working directory is the root of the project
pwd=$(shell pwd)/../

.PHONY : build test libs docker_image clean setup all default strip copy_artifacts dist
.PHONY : build test libs docker_image clean setup-docker all default strip copy_artifacts dist
default: build

export SGX_MODE ?= HW
Expand All @@ -18,6 +18,12 @@ MIN_API_LEVEL = 19
MIN_API_LEVEL_64_BIT = 21
JNI_LIBS_PATH = lib-wrapper/android-bindings/src/main/jniLibs

setup-rust:
rustup toolchain install $(file < ../rust-toolchain)
rustup component add rustfmt
rustup target add $(ARCHS)
rustup update

aarch64-linux-android: CARGO_ENV_FLAGS += \
ISYSROOT=$(NDK_HOME)/toolchains/llvm/prebuilt/linux-x86_64/sysroot \
ISYSTEM=$(NDK_HOME)/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/aarch64-linux-android \
Expand Down Expand Up @@ -54,19 +60,19 @@ x86_64-linux-android: CARGO_ENV_FLAGS += \
CARGO_TARGET_X86_64_LINUX_ANDROID_AR=x86_64-linux-android-ar \
CMAKE_TARGET_OVERRIDE=x86_64-linux-android$(MIN_API_LEVEL_64_BIT)

$(ARCHS):
$(ARCHS): setup-rust
$(CARGO_ENV_FLAGS) cargo build \
$(CARGO_BUILD_FLAGS) \
--target $@

libs: $(ARCHS) strip copy_artifacts

publish: $(ARCHS) strip copy_artifacts
cd lib-wrapper; \
./gradlew build; \
publish: libs
cd lib-wrapper && \
./gradlew build && \
./gradlew publish

ci: setup
ci: setup-docker
docker run \
--rm \
-e MAVEN_USER \
Expand Down Expand Up @@ -108,7 +114,7 @@ strip:
i686-linux-android-strip ../target/i686-linux-android/$(CARGO_PROFILE)/libmobilecoin_android.so
x86_64-linux-android-strip ../target/x86_64-linux-android/$(CARGO_PROFILE)/libmobilecoin_android.so

build: setup
build: setup-docker
docker run \
--rm \
-v $(pwd):/home/rust/ \
Expand All @@ -132,22 +138,22 @@ clean:
docker run \
--rm \
-v $(pwd):/home/rust/ \
-v /tmp/deps:/usr/local/cargo/git \
-v $(BUILD_DEPS_FOLDER):/usr/local/cargo/git \
-w /home/rust/android-bindings \
$(DOCKER_BUILDER_IMAGE_TAG) \
cargo clean

bash: setup
bash: setup-docker
docker run \
--rm \
-it \
-v $(pwd):/home/rust/ \
-v /tmp/deps:/usr/local/cargo/git \
-v $(BUILD_DEPS_FOLDER):/usr/local/cargo/git \
-w /home/rust/android-bindings \
$(DOCKER_BUILDER_IMAGE_TAG) \
bash

setup: docker_image
setup-docker: docker_image
mkdir -p $(BUILD_DEPS_FOLDER)

all: setup clean dist
all: setup-docker clean dist
8 changes: 1 addition & 7 deletions attest/core/src/types/epid_group_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const EPID_GROUP_ID_SIZE: usize = 4;
/// This type exists because of the lack of non-type polymorphism, and
/// should be removed once https://github.com/rust-lang/rust/issues/44580
/// has been completed.
#[derive(Clone, Copy)]
#[derive(Clone, Copy, Default)]
#[repr(transparent)]
pub struct EpidGroupId(sgx_epid_group_id_t);

Expand All @@ -40,12 +40,6 @@ impl AsMut<[u8]> for EpidGroupId {
}
}

impl Default for EpidGroupId {
fn default() -> Self {
Self([0u8; 4])
}
}

impl Debug for EpidGroupId {
fn fmt(&self, formatter: &mut Formatter) -> FmtResult {
write!(formatter, "{}: {:?}", stringify!(EpidGroupId), &self.0[..])
Expand Down
30 changes: 15 additions & 15 deletions common/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub trait TimeProvider: Sync + Send {
type Error: Clone + Debug;

/// Get the duration of time passed since the unix epoch.
fn from_epoch(&self) -> Result<Duration, Self::Error>;
fn since_epoch(&self) -> Result<Duration, Self::Error>;
}

cfg_if::cfg_if! {
Expand All @@ -27,24 +27,24 @@ cfg_if::cfg_if! {
impl TimeProvider for SystemTimeProvider {
type Error = SystemTimeError;

fn from_epoch(&self) -> Result<Duration, Self::Error> {
fn since_epoch(&self) -> Result<Duration, Self::Error> {
SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)
}
}

/// A mock time provider that always returns the same value.
#[derive(Clone, Debug)]
pub struct MockTimeProvider {
cur_from_epoch: Arc<Mutex<Duration>>,
cur_since_epoch: Arc<Mutex<Duration>>,
}

impl Default for MockTimeProvider {
fn default() -> Self {
Self {
cur_from_epoch: Arc::new(Mutex::new(
cur_since_epoch: Arc::new(Mutex::new(
SystemTimeProvider::default()
.from_epoch()
.expect("failed getting initial value for cur_from_epoch"),
.since_epoch()
.expect("failed getting initial value for cur_since_epoch"),
)),
}
}
Expand All @@ -53,15 +53,15 @@ cfg_if::cfg_if! {
impl TimeProvider for MockTimeProvider {
type Error = ();

fn from_epoch(&self) -> Result<Duration, Self::Error> {
Ok(*self.cur_from_epoch.lock().expect("mutex poisoned"))
fn since_epoch(&self) -> Result<Duration, Self::Error> {
Ok(*self.cur_since_epoch.lock().expect("mutex poisoned"))
}
}

impl MockTimeProvider {
pub fn set_cur_from_epoch(&self, new_cur_from_epoch: Duration) {
let mut inner = self.cur_from_epoch.lock().expect("mutex poisoned");
*inner = new_cur_from_epoch;
pub fn set_cur_since_epoch(&self, new_cur_since_epoch: Duration) {
let mut inner = self.cur_since_epoch.lock().expect("mutex poisoned");
*inner = new_cur_since_epoch;
}
}
}
Expand All @@ -72,15 +72,15 @@ cfg_if::cfg_if! {
impl<TP: TimeProvider> TimeProvider for Arc<TP> {
type Error = TP::Error;

fn from_epoch(&self) -> Result<Duration, Self::Error> {
(**self).from_epoch()
fn since_epoch(&self) -> Result<Duration, Self::Error> {
(**self).since_epoch()
}
}

impl<TP: TimeProvider> TimeProvider for Box<TP> {
type Error = TP::Error;

fn from_epoch(&self) -> Result<Duration, Self::Error> {
(**self).from_epoch()
fn since_epoch(&self) -> Result<Duration, Self::Error> {
(**self).since_epoch()
}
}
5 changes: 3 additions & 2 deletions consensus/enclave/trusted/Cargo.lock

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

4 changes: 0 additions & 4 deletions consensus/enclave/trusted/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ ed25519-dalek = { git = "https://github.com/mobilecoinfoundation/ed25519-dalek.g
mbedtls = { git = "https://github.com/mobilecoinofficial/rust-mbedtls.git", rev = "49a293a5f4b1ef571c71174e3fa1f301925f3915" }
mbedtls-sys-auto = { git = "https://github.com/mobilecoinofficial/rust-mbedtls.git", rev = "49a293a5f4b1ef571c71174e3fa1f301925f3915" }

# Pin packed_simd_2 to the commit right before they renamed the `const_generics` feature override.
# TODO: Remove when we upgrade to a newer rust version (where const_generics was renamed to `adt_const_params`)
packed_simd_2 = { git = "https://github.com/rust-lang/packed_simd.git", rev = "064df9b1869b942fa768bfa83596f6965fa858c8" }

# Fork and rename to use "OG" dalek-cryptography.
schnorrkel-og = { git = "https://github.com/mobilecoinfoundation/schnorrkel.git", rev = "5c98ae068ee4652d6df6463b549fbf2d5d132faa" }

Expand Down
6 changes: 3 additions & 3 deletions consensus/scp/src/slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl<V: Value, ValidationError: Display> ScpSlot<V> for Slot<V, ValidationError>
// Omit any invalid values.
let valid_values: Vec<V> = values
.iter()
.filter(|value| self.is_valid(value).is_ok())
.filter(|value| self.validate(value).is_ok())
.cloned()
.collect();

Expand Down Expand Up @@ -366,7 +366,7 @@ impl<V: Value, ValidationError: Display> ScpSlot<V> for Slot<V, ValidationError>
// because this node no longer changes its ballot values.
if self.phase != Phase::Externalize {
for value in msg.values() {
if self.is_valid(&value).is_err() {
if self.validate(&value).is_err() {
// Ignore this msg because it contains an invalid value.
continue 'msg_loop;
}
Expand Down Expand Up @@ -447,7 +447,7 @@ impl<V: Value, ValidationError: Display> Slot<V, ValidationError> {
slot
}

fn is_valid(&mut self, value: &V) -> Result<(), String> {
fn validate(&mut self, value: &V) -> Result<(), String> {
if self.valid_values.contains(value) {
return Ok(());
}
Expand Down
6 changes: 1 addition & 5 deletions consensus/scp/tests/mock_network/cyclic_topology.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright (c) 2018-2021 The MobileCoin Foundation

// Ring style network topologies.

// We allow dead code because not all integration tests use all of the common
// code. https://github.com/rust-lang/rust/issues/46379
#![allow(dead_code)]
//! Ring style network topologies.

use crate::mock_network;
use mc_common::NodeID;
Expand Down
6 changes: 1 addition & 5 deletions consensus/scp/tests/mock_network/mesh_topology.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright (c) 2018-2021 The MobileCoin Foundation

// Mesh style network topologies.

// We allow dead code because not all integration tests use all of the common
// code. https://github.com/rust-lang/rust/issues/46379
#![allow(dead_code)]
//! Mesh style network topologies.

use crate::mock_network;
use mc_common::NodeID;
Expand Down
6 changes: 1 addition & 5 deletions consensus/scp/tests/mock_network/metamesh_topology.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2018-2021 The MobileCoin Foundation

// "Metamesh" network topologies.
//! "Metamesh" network topologies.

// A metamesh consists of a set of (n) "organizations", each comprising (m)
// servers. Quorum is configured with hierarchy, such that each node requires
Expand All @@ -16,10 +16,6 @@
// ([k_n], ([k_m], 0/0, 0/1, 0/2]), ([k_m - 1], 1/0, 1/1]), ([k_m], 2/0, 2/1,
// 2/2]])

// We allow dead code because not all integration tests use all of the common
// code. https://github.com/rust-lang/rust/issues/46379
#![allow(dead_code)]

use crate::mock_network;
use mc_common::NodeID;
use mc_consensus_scp::{test_utils, QuorumSet};
Expand Down
6 changes: 5 additions & 1 deletion consensus/scp/tests/mock_network/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Copyright (c) 2018-2021 The MobileCoin Foundation

// Thread-based simulation for consensus networks.
//! Thread-based simulation for consensus networks.

// We allow dead code because not all integration tests use all of the common
// code. https://github.com/rust-lang/rust/issues/46379
#![allow(dead_code)]

use mc_common::{
logger::{log, Logger},
Expand Down
2 changes: 1 addition & 1 deletion consensus/service/src/api/blockchain_api_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<L: Ledger + Clone> BlockchainApiService<L> {
}

// Set the maximum number of items returned for a single request.
#[allow(dead_code)]
#[cfg(test)]
pub fn set_max_page_size(&mut self, max_page_size: u16) {
self.max_page_size = max_page_size;
}
Expand Down
Loading