Skip to content

Commit

Permalink
Bump Rust toolchain to 2023-01-16
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Jan 16, 2023
1 parent dbe2c6b commit 634a230
Show file tree
Hide file tree
Showing 20 changed files with 52 additions and 93 deletions.
2 changes: 1 addition & 1 deletion docker/oasis-core-dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARG GOLANGCILINT_VERSION=1.50.1
ARG GOCOVMERGE_VERSION=b5bfa59ec0adc420475f97f89b58045c721d761c
ARG GOFUMPT_VERSION=v0.4.0
ARG GOIMPORTS_VERSION=v0.3.0
ARG RUST_NIGHTLY_VERSION=2022-08-22
ARG RUST_NIGHTLY_VERSION=2023-01-16
ARG JEMALLOC_VERSION=5.2.1
ARG JEMALLOC_CHECKSUM=34330e5ce276099e2e8950d9335db5a875689a4c6a56751ef3b1d8c537f887f6

Expand Down
4 changes: 2 additions & 2 deletions docs/development-setup/prerequisites.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ Core:
active toolchain
----------------
nightly-2022-08-22-x86_64-unknown-linux-gnu (overridden by '/code/rust-toolchain.toml')
rustc 1.65.0-nightly (c0941dfb5 2022-08-21)
nightly-2023-01-16-x86_64-unknown-linux-gnu (overridden by '/code/rust-toolchain.toml')
rustc 1.68.0-nightly (9e75dddf6 2023-01-15)
```

* (**OPTIONAL**) [gofumpt] and [goimports].
Expand Down
3 changes: 1 addition & 2 deletions runtime/src/common/crypto/mrae/deoxysii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ fn derive_symmetric_key(public: &PublicKey, private: &StaticSecret) -> [u8; KEY_
/// Generates a public/private key pair suitable for use with
/// `derive_symmetric_key`, `box_seal`, and `box_open`.
pub fn generate_key_pair() -> (PublicKey, StaticSecret) {
let mut rng = OsRng {};
let sk = StaticSecret::new(&mut rng);
let sk = StaticSecret::new(OsRng);
let pk = PublicKey::from(&sk);

(pk, sk)
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/common/crypto/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl Signature {
let mut k: Sha512 = Sha512::new();
k.update(R_bits);
k.update(pk.as_ref());
k.update(&msg);
k.update(msg);
let k = Scalar::from_hash(k);

// Check the cofactored group equation ([8][S]B = [8]R + [8][k]A').
Expand Down
4 changes: 1 addition & 3 deletions runtime/src/common/crypto/x25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ pub struct PrivateKey(pub x25519_dalek::StaticSecret);
impl PrivateKey {
/// Generate a new private key.
pub fn generate() -> Self {
let mut rng = OsRng {};

PrivateKey(x25519_dalek::StaticSecret::new(&mut rng))
PrivateKey(x25519_dalek::StaticSecret::new(OsRng))
}

/// Compute corresponding public key.
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/common/sgx/ias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ pub fn verify(avr: &AVR, policy: &QuotePolicy) -> Result<VerifiedQuote> {
};

let quote_body = avr_body.isv_enclave_quote_body()?;
let quote_body = match base64::decode(&quote_body) {
let quote_body = match base64::decode(quote_body) {
Ok(quote_body) => quote_body,
_ => return Err(AVRError::MalformedQuote.into()),
};
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/common/sgx/pcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ struct Verifier {
}

impl quote::Quote3SignatureEcdsaP256Verifier for Verifier {
fn verify_certification_data<'a>(
fn verify_certification_data(
&mut self,
quote3signature: &'a quote::Quote3SignatureEcdsaP256,
quote3signature: &quote::Quote3SignatureEcdsaP256,
) -> quote::Result<Vec<u8>> {
// Only PCK certificate chain is supported as certification data.
let certs = quote3signature
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/consensus/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl Address {
impl fmt::LowerHex for Address {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for i in &self.0[..] {
write!(f, "{:02x}", i)?;
write!(f, "{i:02x}")?;
}
Ok(())
}
Expand Down
27 changes: 6 additions & 21 deletions runtime/src/consensus/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,23 +278,18 @@ impl Node {
}

/// Runtime kind.
#[derive(Clone, Debug, PartialEq, Eq, Hash, cbor::Encode, cbor::Decode)]
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, cbor::Encode, cbor::Decode)]
#[repr(u32)]
pub enum RuntimeKind {
/// Invalid runtime that should never be explicitly set.
#[default]
KindInvalid = 0,
/// Generic compute runtime.
KindCompute = 1,
/// Key manager runtime.
KindKeyManager = 2,
}

impl Default for RuntimeKind {
fn default() -> Self {
RuntimeKind::KindInvalid
}
}

/// Parameters for the executor committee.
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, cbor::Encode, cbor::Decode)]
pub struct ExecutorParameters {
Expand Down Expand Up @@ -453,10 +448,11 @@ impl Default for RuntimeAdmissionPolicy {
}

/// Runtime governance model.
#[derive(Clone, Debug, PartialEq, Eq, Hash, cbor::Encode, cbor::Decode)]
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, cbor::Encode, cbor::Decode)]
#[repr(u8)]
pub enum RuntimeGovernanceModel {
/// Invalid model that should never be explicitly set.
#[default]
GovernanceInvalid = 0,
/// Entity governance model.
GovernanceEntity = 1,
Expand All @@ -466,12 +462,6 @@ pub enum RuntimeGovernanceModel {
GovernanceConsensus = 3,
}

impl Default for RuntimeGovernanceModel {
fn default() -> Self {
RuntimeGovernanceModel::GovernanceInvalid
}
}

/// Per-runtime version information.
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, cbor::Encode, cbor::Decode)]
pub struct VersionInfo {
Expand Down Expand Up @@ -607,21 +597,16 @@ impl SGXAttestation {
}

/// TEE hardware implementation.
#[derive(Clone, Debug, PartialEq, Eq, Hash, cbor::Encode, cbor::Decode)]
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, cbor::Encode, cbor::Decode)]
#[repr(u8)]
pub enum TEEHardware {
/// Non-TEE implementation.
#[default]
TEEHardwareInvalid = 0,
/// Intel SGX TEE implementation.
TEEHardwareIntelSGX = 1,
}

impl Default for TEEHardware {
fn default() -> Self {
TEEHardware::TEEHardwareInvalid
}
}

/// The latest entity descriptor version that should be used for all new descriptors. Using earlier
/// versions may be rejected.
pub const LATEST_RUNTIME_DESCRIPTOR_VERSION: u16 = 3;
Expand Down
9 changes: 2 additions & 7 deletions runtime/src/consensus/roothash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,17 @@ pub struct AnnotatedBlock {
/// # Note
///
/// This should be kept in sync with go/roothash/api/block/header.go.
#[derive(Clone, Debug, PartialEq, Eq, Hash, cbor::Encode, cbor::Decode)]
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, cbor::Encode, cbor::Decode)]
#[repr(u8)]
pub enum HeaderType {
#[default]
Invalid = 0,
Normal = 1,
RoundFailed = 2,
EpochTransition = 3,
Suspended = 4,
}

impl Default for HeaderType {
fn default() -> Self {
HeaderType::Invalid
}
}

/// A message that can be emitted by the runtime to be processed by the consensus layer.
#[derive(Clone, Debug, PartialEq, Eq, cbor::Encode, cbor::Decode)]
pub enum Message {
Expand Down
22 changes: 8 additions & 14 deletions runtime/src/consensus/scheduler.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
//! Scheduler structures.

/// The role a given node plays in a committee.
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, cbor::Encode, cbor::Decode)]
#[derive(
Clone, Debug, Default, PartialEq, Eq, Hash, PartialOrd, Ord, cbor::Encode, cbor::Decode,
)]
#[repr(u8)]
pub enum Role {
/// An invalid role (should never appear on the wire).
#[default]
Invalid = 0,
/// Indicates the node is a worker.
Worker = 1,
/// Indicates the node is a backup worker.
BackupWorker = 2,
}

impl Default for Role {
fn default() -> Self {
Role::Invalid
}
}

/// The functionality a committee exists to provide.
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, cbor::Encode, cbor::Decode)]
#[derive(
Clone, Debug, Default, PartialEq, Eq, Hash, PartialOrd, Ord, cbor::Encode, cbor::Decode,
)]
#[repr(u8)]
pub enum CommitteeKind {
/// An invalid committee (should never appear on the wire).
#[default]
Invalid = 0,
/// A compute executor committee.
ComputeExecutor = 1,
}

impl Default for CommitteeKind {
fn default() -> Self {
CommitteeKind::Invalid
}
}
10 changes: 5 additions & 5 deletions runtime/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl From<tokio::task::JoinError> for Error {
Error::new(
"dispatcher",
1,
&format!("error while processing request: {}", e),
&format!("error while processing request: {e}"),
)
}
}
Expand Down Expand Up @@ -265,7 +265,7 @@ impl Dispatcher {
let post_init_state = initializer.init(pre_init_state);
let mut txn_dispatcher = post_init_state
.txn_dispatcher
.unwrap_or_else(|| Box::new(TxnNoopDispatcher::default()));
.unwrap_or_else(|| Box::<TxnNoopDispatcher>::default());
txn_dispatcher.set_abort_batch_flag(self.abort_batch.clone());

let state = State {
Expand Down Expand Up @@ -836,7 +836,7 @@ impl Dispatcher {
.process_frame(request, &mut buffer)
.map_err(|err| {
error!(self.logger, "Error while processing frame"; "err" => %err);
Error::new("rhp/dispatcher", 1, &format!("{}", err))
Error::new("rhp/dispatcher", 1, &format!("{err}"))
})?;

if let Some((session_id, session_info, message, untrusted_plaintext)) = result {
Expand Down Expand Up @@ -882,7 +882,7 @@ impl Dispatcher {
.write_message(session_id, response, &mut buffer)
.map_err(|err| {
error!(self.logger, "Error while writing response"; "err" => %err);
Error::new("rhp/dispatcher", 1, &format!("{}", err))
Error::new("rhp/dispatcher", 1, &format!("{err}"))
})
.map(|_| Body::RuntimeRPCCallResponse { response: buffer })
}
Expand All @@ -896,7 +896,7 @@ impl Dispatcher {
.close(session_id, &mut buffer)
.map_err(|err| {
error!(self.logger, "Error while closing session"; "err" => %err);
Error::new("rhp/dispatcher", 1, &format!("{}", err))
Error::new("rhp/dispatcher", 1, &format!("{err}"))
})
.map(|_| Body::RuntimeRPCCallResponse { response: buffer })
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/enclave_rpc/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl Dispatcher {
match self.dispatch_fallible(&mut ctx, request, kind) {
Ok(response) => response,
Err(error) => Response {
body: Body::Error(format!("{}", error)),
body: Body::Error(format!("{error}")),
},
}
}
Expand Down
6 changes: 2 additions & 4 deletions runtime/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,7 @@ impl Protocol {
// is no need to do anything more.
return Ok(());
}
Err(error) => {
Body::Error(Error::new("rhp/dispatcher", 1, &format!("{}", error)))
}
Err(error) => Body::Error(Error::new("rhp/dispatcher", 1, &format!("{error}"))),
};

// Send response back.
Expand Down Expand Up @@ -386,7 +384,7 @@ impl Protocol {
}

_ => {
warn!(self.logger, "Received unsupported request"; "req" => format!("{:?}", request));
warn!(self.logger, "Received unsupported request"; "req" => format!("{request:?}"));
Err(ProtocolError::MethodNotSupported.into())
}
}
Expand Down
8 changes: 4 additions & 4 deletions runtime/src/storage/mkvs/sync/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl ProofVerifier {
return Err(anyhow!("verifier: empty proof"));
}

let (idx, root_node) = self._verify_proof(proof, 0)?;
let (idx, root_node) = Self::_verify_proof(proof, 0)?;
// Make sure that all of the entries in the proof have been used. The returned index should
// point to just beyond the last element.
if idx != proof.entries.len() {
Expand All @@ -100,7 +100,7 @@ impl ProofVerifier {
Ok(root_node)
}

fn _verify_proof(&self, proof: &Proof, idx: usize) -> Result<(usize, NodePtrRef)> {
fn _verify_proof(proof: &Proof, idx: usize) -> Result<(usize, NodePtrRef)> {
if idx >= proof.entries.len() {
return Err(anyhow!("verifier: malformed proof"));
}
Expand All @@ -122,11 +122,11 @@ impl ProofVerifier {
let mut pos = idx + 1;
if let NodeBox::Internal(ref mut nd) = node {
// Left.
let result = self._verify_proof(proof, pos)?;
let result = Self::_verify_proof(proof, pos)?;
pos = result.0;
nd.left = result.1;
// Right.
let result = self._verify_proof(proof, pos)?;
let result = Self::_verify_proof(proof, pos)?;
pos = result.0;
nd.right = result.1;

Expand Down
6 changes: 1 addition & 5 deletions runtime/src/storage/mkvs/tree/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Tree {
// Remember where the path from root to target node ends (will end).
self.cache.borrow_mut().mark_position();

self._get(&ctx, pending_root, 0, &boxed_key, 0, check_only)
self._get(&ctx, pending_root, 0, &boxed_key, check_only)
}

fn _get(
Expand All @@ -74,7 +74,6 @@ impl Tree {
ptr: NodePtrRef,
bit_depth: Depth,
key: &Key,
depth: Depth,
check_only: bool,
) -> Result<Option<Value>> {
let node_ref = self.cache.borrow_mut().deref_node_ptr(
Expand Down Expand Up @@ -103,7 +102,6 @@ impl Tree {
n.leaf_node.clone(),
bit_depth + n.label_bit_length,
key,
depth,
check_only,
);
}
Expand All @@ -120,7 +118,6 @@ impl Tree {
n.right.clone(),
bit_depth + n.label_bit_length,
key,
depth + 1,
check_only,
);
} else {
Expand All @@ -129,7 +126,6 @@ impl Tree {
n.left.clone(),
bit_depth + n.label_bit_length,
key,
depth + 1,
check_only,
);
}
Expand Down
Loading

0 comments on commit 634a230

Please sign in to comment.