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

[ci] update to rust stable #336

Merged
merged 6 commits into from
Jan 27, 2025
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/actions/build_env/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ runs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.78.0
toolchain: stable
override: true

- name: install rustfmt clippy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#![allow(clippy::unnecessary_wraps)]
#![allow(unused_imports)]
#![allow(dead_code)]
#![allow(clippy::doc_lazy_continuation)]
#![allow(clippy::empty_line_after_doc_comments)]

use crate::version_five::{
language_storage_v5::{ModuleIdV5 as ModuleId, TypeTagV5 as TypeTag},
legacy_address_v5::LegacyAddressV5 as AccountAddress,
Expand Down
24 changes: 9 additions & 15 deletions compatibility/src/sdk/v5_2_0_transaction_script_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#![allow(clippy::unnecessary_wraps)]
#![allow(unused_imports)]
#![allow(dead_code)]
// legacy code from diem, clippy warnings since 1.80
#![allow(clippy::doc_lazy_continuation)]
#![allow(clippy::empty_line_after_doc_comments)]
use crate::version_five::{
language_storage_v5::{ModuleIdV5 as ModuleId, TypeTagV5 as TypeTag},
legacy_address_v5::LegacyAddressV5 as AccountAddress,
Expand Down Expand Up @@ -4421,7 +4424,6 @@ pub fn encode_create_child_vasp_account_script_function(
/// | `human_name` | `vector<u8>` | ASCII-encoded human name for the Designated Dealer. |
/// | `add_all_currencies` | `bool` | Whether to publish preburn, balance, and tier info resources for all known (SCS) currencies or just `Currency` when the account is created. |
///

/// # Common Abort Conditions
/// | Error Category | Error Reason | Description |
/// | ---------------- | -------------- | ------------- |
Expand Down Expand Up @@ -4695,9 +4697,7 @@ pub fn encode_create_validator_account_script_function(
/// # Events
/// Successful execution will emit:
/// * A `DiemAccount::CreateAccountEvent` with the `created` field being `new_account_address`,
/// and the `rold_id` field being `Roles::VALIDATOR_OPERATOR_ROLE_ID`. This is emitted on the
/// `DiemAccount::AccountOperationsCapability` `creation_events` handle.
///
/// and the `rold_id` field being `Roles::VALIDATOR_OPERATOR_ROLE_ID`. This is emitted on the `DiemAccount::AccountOperationsCapability` `creation_events` handle.
/// # Parameters
/// | Name | Type | Description |
/// | ------ | ------ | ------------- |
Expand Down Expand Up @@ -5058,11 +5058,9 @@ pub fn encode_peer_to_peer_with_metadata_script_function(
///
/// # Events
/// Successful execution of this script emits two events:
/// * `DiemAccount::SentPaymentEvent ` on `account`'s `DiemAccount::DiemAccount` `sent_events`
/// handle with the `payee` and `payer` fields being `account`'s address; and
/// * `DiemAccount::SentPaymentEvent ` on `account`'s `DiemAccount::DiemAccount` `sent_events` handle with the `payee` and `payer` fields being `account`'s address; and
/// * A `Diem::PreburnEvent` with `Token`'s currency code on the
/// `Diem::CurrencyInfo<Token`'s `preburn_events` handle for `Token` and with
/// `preburn_address` set to `account`'s address.
/// `Diem::CurrencyInfo<Token`'s `preburn_events` handle for `Token` and with `preburn_address` set to `account`'s address.
///
/// # Parameters
/// | Name | Type | Description |
Expand Down Expand Up @@ -5504,9 +5502,7 @@ pub fn encode_rotate_authentication_key_with_recovery_address_script_function(
///
/// # Events
/// Successful execution of this transaction emits two events:
/// * A `DualAttestation::ComplianceKeyRotationEvent` containing the new compliance public key, and
/// the blockchain time at which the key was updated emitted on the `DualAttestation::Credential`
/// `compliance_key_rotation_events` handle published under `account`; and
/// * A `DualAttestation::ComplianceKeyRotationEvent` containing the new compliance public key, and the blockchain time at which the key was updated emitted on the `DualAttestation::Credential` `compliance_key_rotation_events` handle published under `account`; and
/// * A `DualAttestation::BaseUrlRotationEvent` containing the new base url to be used for
/// off-chain communication, and the blockchain time at which the url was updated emitted on the
/// `DualAttestation::Credential` `base_url_rotation_events` handle published under `account`.
Expand Down Expand Up @@ -6543,11 +6539,9 @@ pub fn encode_cancel_burn_script(token: TypeTag, preburn_address: AccountAddress
/// ## Events
/// Successful execution with a `child_initial_balance` greater than zero will emit:
/// * A `DiemAccount::SentPaymentEvent` with the `payer` field being the Parent VASP's address,
/// and payee field being `child_address`. This is emitted on the Parent VASP's
/// `DiemAccount::DiemAccount` `sent_events` handle.
/// and payee field being `child_address`. This is emitted on the Parent VASP's `DiemAccount::DiemAccount` `sent_events` handle.
/// * A `DiemAccount::ReceivedPaymentEvent` with the `payer` field being the Parent VASP's address,
/// and payee field being `child_address`. This is emitted on the new Child VASPS's
/// `DiemAccount::DiemAccount` `received_events` handle.
/// and payee field being `child_address`. This is emitted on the new Child VASPS's `DiemAccount::DiemAccount` `received_events` handle.
///
/// # Parameters
/// | Name | Type | Description |
Expand Down
2 changes: 2 additions & 0 deletions compatibility/src/sdk/v6_libra_framework_sdk_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
// legacy code from diem, clippy warnings since 1.80
#![allow(clippy::doc_lazy_continuation)]
use diem_types::{
account_address::AccountAddress,
transaction::{EntryFunction, TransactionPayload},
Expand Down
6 changes: 3 additions & 3 deletions compatibility/src/sdk/v7_libra_framework_sdk_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::too_many_arguments, clippy::doc_lazy_continuation)]
use diem_types::{
account_address::AccountAddress,
transaction::{EntryFunction, TransactionPayload},
Expand All @@ -44,8 +44,8 @@ type Bytes = Vec<u8>;
// explorer and data warehouse
//////// end ////////
#[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
#[cfg_attr(feature = "fuzzing", proptest(no_params))]
// #[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
// #[cfg_attr(feature = "fuzzing", proptest(no_params))]
pub enum EntryFunctionCall {
/// Offers rotation capability on behalf of `account` to the account at address `recipient_address`.
/// An account can delegate its rotation capability to only one other address at one time. If the account
Expand Down
244 changes: 4 additions & 240 deletions compatibility/src/version_five/hash_value_v5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ use std::{
};
use tiny_keccak::{Hasher, Sha3};

/// A prefix used to begin the salt of every diem hashable structure. The salt
/// consists in this global prefix, concatenated with the specified
/// serialization name of the struct.
// pub(crate) const DIEM_HASH_PREFIX: &[u8] = b"DIEM::";

/// Output value of our hash function. Intentionally opaque for safety and modularity.
#[derive(Clone, Copy, Eq, Hash, PartialEq, PartialOrd, Ord)]
pub struct HashValueV5 {
Expand Down Expand Up @@ -269,7 +264,7 @@ impl HashValueV5 {
/// generating basic mock hash values.
///
/// Ex: HashValue::from_u64(0x1234) => HashValue([0, .., 0, 0x12, 0x34])
#[cfg(any(test, feature = "fuzzing"))]
#[cfg(test)]
pub fn from_u64(v: u64) -> Self {
let mut hash = [0u8; Self::LENGTH];
let bytes = v.to_be_bytes();
Expand Down Expand Up @@ -439,7 +434,7 @@ impl<'a> HashValueBitIterator<'a> {
}
}

impl<'a> std::iter::Iterator for HashValueBitIterator<'a> {
impl std::iter::Iterator for HashValueBitIterator<'_> {
type Item = bool;

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -451,241 +446,10 @@ impl<'a> std::iter::Iterator for HashValueBitIterator<'a> {
}
}

impl<'a> std::iter::DoubleEndedIterator for HashValueBitIterator<'a> {
impl std::iter::DoubleEndedIterator for HashValueBitIterator<'_> {
fn next_back(&mut self) -> Option<Self::Item> {
self.pos.next_back().map(|x| self.get_bit(x))
}
}

impl<'a> std::iter::ExactSizeIterator for HashValueBitIterator<'a> {}

// /// A type that can be cryptographically hashed to produce a `HashValue`.
// ///
// /// In most cases, this trait should not be implemented manually but rather derived using
// /// the macros `serde::Serialize`, `CryptoHasher`, and `BCSCryptoHash`.
// pub trait CryptoHash {
// /// The associated `Hasher` type which comes with a unique salt for this type.
// type Hasher: CryptoHasher;

// /// Hashes the object and produces a `HashValue`.
// fn hash(&self) -> HashValue;
// }

// /// A trait for representing the state of a cryptographic hasher.
// pub trait CryptoHasher: Default + std::io::Write {
// /// the seed used to initialize hashing `Self` before the serialization bytes of the actual value
// fn seed() -> &'static [u8; 32];

// /// Write bytes into the hasher.
// fn update(&mut self, bytes: &[u8]);

// /// Finish constructing the [`HashValue`].
// fn finish(self) -> HashValue;

// /// Convenience method to compute the hash of a complete byte slice.
// fn hash_all(bytes: &[u8]) -> HashValue {
// let mut hasher = Self::default();
// hasher.update(bytes);
// hasher.finish()
// }
// }

// /// The default hasher underlying generated implementations of `CryptoHasher`.
// #[doc(hidden)]
// #[derive(Clone)]
// pub struct DefaultHasher {
// state: Sha3,
// }

// impl DefaultHasher {
// #[doc(hidden)]
// /// This function does not return a HashValue in the sense of our usual
// /// hashes, but a construction of initial bytes that are fed into any hash
// /// provided we're passed a (bcs) serialization name as argument.
// pub fn prefixed_hash(buffer: &[u8]) -> [u8; HashValue::LENGTH] {
// // The salt is initial material we prefix to actual value bytes for
// // domain separation. Its length is variable.
// let salt: Vec<u8> = [DIEM_HASH_PREFIX, buffer].concat();
// // The seed is a fixed-length hash of the salt, thereby preventing
// // suffix attacks on the domain separation bytes.
// HashValue::sha3_256_of(&salt[..]).hash
// }

// #[doc(hidden)]
// pub fn new(typename: &[u8]) -> Self {
// let mut state = Sha3::v256();
// if !typename.is_empty() {
// state.update(&Self::prefixed_hash(typename));
// }
// DefaultHasher { state }
// }

// #[doc(hidden)]
// pub fn update(&mut self, bytes: &[u8]) {
// self.state.update(bytes);
// }

// #[doc(hidden)]
// pub fn finish(self) -> HashValue {
// let mut hasher = HashValue::default();
// self.state.finalize(hasher.as_ref_mut());
// hasher
// }
// }

// impl fmt::Debug for DefaultHasher {
// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// write!(f, "DefaultHasher: state = Sha3")
// }
// }

// macro_rules! define_hasher {
// (
// $(#[$attr:meta])*
// ($hasher_type: ident, $hasher_name: ident, $seed_name: ident, $salt: expr)
// ) => {

// #[derive(Clone, Debug)]
// $(#[$attr])*
// pub struct $hasher_type(DefaultHasher);

// impl $hasher_type {
// fn new() -> Self {
// $hasher_type(DefaultHasher::new($salt))
// }
// }

// static $hasher_name: Lazy<$hasher_type> = Lazy::new(|| { $hasher_type::new() });
// static $seed_name: OnceCell<[u8; 32]> = OnceCell::new();

// impl Default for $hasher_type {
// fn default() -> Self {
// $hasher_name.clone()
// }
// }

// impl CryptoHasher for $hasher_type {
// fn seed() -> &'static [u8;32] {
// $seed_name.get_or_init(|| {
// DefaultHasher::prefixed_hash($salt)
// })
// }

// fn update(&mut self, bytes: &[u8]) {
// self.0.update(bytes);
// }

// fn finish(self) -> HashValue {
// self.0.finish()
// }
// }

// impl std::io::Write for $hasher_type {
// fn write(&mut self, bytes: &[u8]) -> std::io::Result<usize> {
// self.0.update(bytes);
// Ok(bytes.len())
// }
// fn flush(&mut self) -> std::io::Result<()> {
// Ok(())
// }
// }
// };
// }

// define_hasher! {
// /// The hasher used to compute the hash of an internal node in the transaction accumulator.
// (
// TransactionAccumulatorHasher,
// TRANSACTION_ACCUMULATOR_HASHER,
// TRANSACTION_ACCUMULATOR_SEED,
// b"TransactionAccumulator"
// )
// }

// define_hasher! {
// /// The hasher used to compute the hash of an internal node in the event accumulator.
// (
// EventAccumulatorHasher,
// EVENT_ACCUMULATOR_HASHER,
// EVENT_ACCUMULATOR_SEED,
// b"EventAccumulator"
// )
// }

// define_hasher! {
// /// The hasher used to compute the hash of an internal node in the Sparse Merkle Tree.
// (
// SparseMerkleInternalHasher,
// SPARSE_MERKLE_INTERNAL_HASHER,
// SPARSE_MERKLE_INTERNAL_SEED,
// b"SparseMerkleInternal"
// )
// }

// define_hasher! {
// /// The hasher used to compute the hash of an internal node in the transaction accumulator.
// (
// VoteProposalHasher,
// VOTE_PROPOSAL_HASHER,
// VOTE_PROPOSAL_SEED,
// b"VoteProposalHasher"
// )
// }

// define_hasher! {
// /// The hasher used only for testing. It doesn't have a salt.
// (TestOnlyHasher, TEST_ONLY_HASHER, TEST_ONLY_SEED, b"")
// }

// fn create_literal_hash(word: &str) -> HashValue {
// let mut s = word.as_bytes().to_vec();
// assert!(s.len() <= HashValue::LENGTH);
// s.resize(HashValue::LENGTH, 0);
// HashValue::from_slice(&s).expect("Cannot fail")
// }

// /// Placeholder hash of `Accumulator`.
// pub static ACCUMULATOR_PLACEHOLDER_HASH: Lazy<HashValue> =
// Lazy::new(|| create_literal_hash("ACCUMULATOR_PLACEHOLDER_HASH"));

// /// Placeholder hash of `SparseMerkleTree`.
// pub static SPARSE_MERKLE_PLACEHOLDER_HASH: Lazy<HashValue> =
// Lazy::new(|| create_literal_hash("SPARSE_MERKLE_PLACEHOLDER_HASH"));

// /// Block id reserved as the id of parent block of the genesis block.
// pub static PRE_GENESIS_BLOCK_ID: Lazy<HashValue> =
// Lazy::new(|| create_literal_hash("PRE_GENESIS_BLOCK_ID"));

// /// Genesis block id is used as a parent of the very first block executed by the executor.
// pub static GENESIS_BLOCK_ID: Lazy<HashValue> = Lazy::new(|| {
// // This maintains the invariant that block.id() == block.hash(), for
// // the genesis block and allows us to (de/)serialize it consistently
// HashValue::new([
// 0x5e, 0x10, 0xba, 0xd4, 0x5b, 0x35, 0xed, 0x92, 0x9c, 0xd6, 0xd2, 0xc7, 0x09, 0x8b, 0x13,
// 0x5d, 0x02, 0xdd, 0x25, 0x9a, 0xe8, 0x8a, 0x8d, 0x09, 0xf4, 0xeb, 0x5f, 0xba, 0xe9, 0xa6,
// 0xf6, 0xe4,
// ])
// });

// /// Provides a test_only_hash() method that can be used in tests on types that implement
// /// `serde::Serialize`.
// ///
// /// # Example
// /// ```
// /// use diem_crypto::hash::TestOnlyHash;
// ///
// /// b"hello world".test_only_hash();
// /// ```
// pub trait TestOnlyHash {
// /// Generates a hash used only for tests.
// fn test_only_hash(&self) -> HashValue;
// }

// impl<T: ser::Serialize + ?Sized> TestOnlyHash for T {
// fn test_only_hash(&self) -> HashValue {
// let bytes = bcs::to_bytes(self).expect("serialize failed during hash.");
// let mut hasher = TestOnlyHasher::default();
// hasher.update(&bytes);
// hasher.finish()
// }
// }
impl std::iter::ExactSizeIterator for HashValueBitIterator<'_> {}
Loading
Loading