diff --git a/attestation_tree/src/lib.rs b/attestation_tree/src/lib.rs index 020ac99d..c97db081 100644 --- a/attestation_tree/src/lib.rs +++ b/attestation_tree/src/lib.rs @@ -1,8 +1,10 @@ #![doc = include_str!("../README.md")] +/// Hash and key types for attestation tree nodes. mod hash_and_key; pub use hash_and_key::{HashAndKey, HashAndKeyTuple}; +/// Prefix foliate implementation for storage key iteration. mod prefix_foliate; pub use prefix_foliate::{ decode_storage_key_and_value, @@ -11,9 +13,11 @@ pub use prefix_foliate::{ PrefixFoliate, }; +/// Commitment map prefix foliate implementation. mod commitment_map_prefix_foliate; pub use commitment_map_prefix_foliate::CommitmentMapPrefixFoliate; +/// Core attestation tree construction and proof generation. mod attestation_tree; pub use attestation_tree::{ attestation_tree_from_prefixes, diff --git a/canaries/src/main.rs b/canaries/src/main.rs index e7c181e8..0eb8c2ff 100644 --- a/canaries/src/main.rs +++ b/canaries/src/main.rs @@ -1,7 +1,11 @@ //! Canary prototype +/// Prometheus metrics collection and serving. mod metrics; +/// Parsing utilities for canary data. mod parsing; +/// RPC communication utilities. mod rpc; +/// Storage operations for canary state. mod storage; use std::net::SocketAddr; @@ -81,12 +85,15 @@ async fn main() -> Result<(), CanaryError> { Ok(()) } +/// Simple block processor for canary monitoring. struct SimpleProcessor { + /// The RPC URL to connect to. pub rpc_url: Url, } impl SimpleProcessor { - fn get_http_url(&self) -> Result { + /// Converts the WebSocket URL to an HTTP URL. + fn _get_http_url(&self) -> Result { let mut out = self.rpc_url.clone(); match self.rpc_url.scheme() { "wss" => { diff --git a/canaries/src/metrics.rs b/canaries/src/metrics.rs index 6007c060..00da49ec 100644 --- a/canaries/src/metrics.rs +++ b/canaries/src/metrics.rs @@ -108,6 +108,7 @@ pub(crate) fn record_staking(e: &StakingEvent) { .inc_by(e.amount.saturated_into()); } +/// Records attestation metrics for a given block. pub(crate) fn record_attestations(block_number: u32, attestations: Vec>) { // Count the total attestations for this block BEST_ATTESTATION_COUNTER @@ -138,18 +139,21 @@ pub(crate) fn record_balance(e: &BalanceEvent) { .inc_by(e.amount.saturated_into()); } +/// Records the count of claimed unstakes for a given block. pub(crate) fn record_claimed_unstake_count(block_number: u32, count: u64) { UNSTAKE_CLAIMED_COUNTER .with_label_values(&[block_number.to_string()]) .inc_by(count); } +/// Records the total validator rewards for a given era. pub(crate) fn record_era_rewards(era: u32, amount: u128) { VALIDATOR_REWARD .with_label_values(&[era.to_string()]) .set(amount as f64); } +/// Records the total staked amount for a given era. pub(crate) fn record_era_total_stake(era: u32, amount: u128) { TOTAL_STAKED .with_label_values(&[era.to_string()]) diff --git a/canaries/src/parsing.rs b/canaries/src/parsing.rs index 92f1afa5..122e014b 100644 --- a/canaries/src/parsing.rs +++ b/canaries/src/parsing.rs @@ -10,9 +10,12 @@ pub(crate) fn parse_event_names(events: &[EventDetails]) -> Vec< .collect::>() } +/// A staking event with its label and amount. #[derive(Debug, Eq, PartialEq, Clone, Copy)] pub(crate) struct StakingEvent<'a> { + /// The event variant name. pub label: &'a str, + /// The staking amount. pub amount: u128, } @@ -54,9 +57,12 @@ pub(crate) fn parse_staking_stats(events: &[EventDetails]) -> Ve .collect::>() } +/// A balance event with its label and amount. #[derive(Debug, Eq, PartialEq, Clone, Copy)] pub(crate) struct BalanceEvent<'a> { + /// The event variant name. pub label: &'a str, + /// The balance amount. pub amount: u128, } diff --git a/canaries/src/rpc.rs b/canaries/src/rpc.rs index cd627c90..70405ceb 100644 --- a/canaries/src/rpc.rs +++ b/canaries/src/rpc.rs @@ -1,6 +1,5 @@ use anyhow::Result; use reqwest::Url; -use serde::{Deserialize, Serialize}; use sxt_core::attestation::Attestation; use sxt_core::keystore::H256; diff --git a/canaries/src/storage.rs b/canaries/src/storage.rs index 4aebf16b..1b75fa70 100644 --- a/canaries/src/storage.rs +++ b/canaries/src/storage.rs @@ -20,6 +20,7 @@ pub(crate) async fn read_active_era(block: &Block, api: &API) -> Result Result> { let era_reward_query = sxt_chain_runtime::api::storage() .staking() @@ -36,6 +37,7 @@ pub(crate) async fn read_era_rewards(era: u32, block: &Block, api: &API) -> Resu } } +/// Reads the total staked amount for the specified era. pub(crate) async fn read_total_staked(era: u32, block: &Block, api: &API) -> Result> { let total_staked_query = sxt_chain_runtime::api::storage() .staking() @@ -52,6 +54,7 @@ pub(crate) async fn read_total_staked(era: u32, block: &Block, api: &API) -> Res } } +/// Reads the count of claimed unstakes for the given block. pub(crate) async fn read_unstaked_claims_count(block: &Block, api: &API) -> Result { let claims = api .runtime_api() diff --git a/eth-ecdsa/src/lib.rs b/eth-ecdsa/src/lib.rs index 64098987..b07b8025 100644 --- a/eth-ecdsa/src/lib.rs +++ b/eth-ecdsa/src/lib.rs @@ -1,8 +1,10 @@ #![doc = include_str!("../README.md")] #![cfg_attr(not(feature = "std"), no_std)] +/// Ethereum-compatible ECDSA signature implementation. mod signature; pub use signature::{EthEcdsaSignature, EthEcdsaSigner}; +/// Multi-signature support for combining multiple signature types. mod multi_signature; pub use multi_signature::MultiSignature; diff --git a/event-forwarder/src/block_processing.rs b/event-forwarder/src/block_processing.rs index c0598061..d32dd4ab 100644 --- a/event-forwarder/src/block_processing.rs +++ b/event-forwarder/src/block_processing.rs @@ -48,9 +48,7 @@ use subxt::PolkadotConfig; use subxt_signer::sr25519::Keypair; use sxt_core::sxt_chain_runtime::api::attestations::events::BlockAttested; use sxt_core::sxt_chain_runtime::api::runtime_types::sxt_core::attestation::Attestation::EthereumAttestation; -use sxt_core::sxt_chain_runtime::api::runtime_types::sxt_runtime::RuntimeEvent; use sxt_core::sxt_chain_runtime::api::staking::events::Unbonded; -use sxt_core::sxt_chain_runtime::api::Event; use sxt_core::sxt_chain_runtime::{self}; use tokio::sync::mpsc; use tokio::time::{sleep, Duration}; diff --git a/event-forwarder/src/chain_listener.rs b/event-forwarder/src/chain_listener.rs index c992c15f..3d356c92 100644 --- a/event-forwarder/src/chain_listener.rs +++ b/event-forwarder/src/chain_listener.rs @@ -34,8 +34,6 @@ use async_trait::async_trait; use jsonrpsee::core::client::ClientT; use jsonrpsee::ws_client::WsClientBuilder; use log::{error, info}; -use reqwest::Client; -use serde_json::json; use subxt::backend::StreamOf; use subxt::utils::H256; use subxt::{OnlineClient, PolkadotConfig}; @@ -302,7 +300,7 @@ impl BlockStreamProvider for IncrementingBlockStream { } } -fn convert_ws_to_https(url: &str) -> String { +fn _convert_ws_to_https(url: &str) -> String { url.replacen("ws://", "http://", 1) .replacen("wss://", "https://", 1) } diff --git a/native/src/sxt.rs b/native/src/sxt.rs index 6b69f3e8..ce43f10f 100644 --- a/native/src/sxt.rs +++ b/native/src/sxt.rs @@ -1,14 +1,5 @@ #[cfg(feature = "std")] -use std::sync::Arc; - -#[cfg(feature = "std")] -use arrow::{ - array::{ArrayRef, StringArray}, - datatypes::{DataType, Field, Schema}, - ipc::reader::StreamReader, - ipc::writer::StreamWriter, - record_batch::RecordBatch, -}; +use arrow::ipc::reader::StreamReader; #[cfg(feature = "std")] use commitment_sql::InsertAndCommitmentMetadata; use proof_of_sql_commitment_map::{ @@ -18,7 +9,6 @@ use proof_of_sql_commitment_map::{ }; #[cfg(feature = "std")] use proof_of_sql_static_setups::io::PUBLIC_SETUPS; -use sp_runtime::BoundedVec; use sp_runtime_interface::runtime_interface; use sxt_core::native::{ CreateStatementPassBy, diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index 2b814bd5..c1f1efde 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -24,8 +24,10 @@ mod test_insert; #[cfg(test)] mod test_table_commitments; +/// Error type conversions for commitment operations. mod error_conversions; +/// Simulates end row insertion for commitment calculations. mod end_row_insert_simulation; pub mod runtime_api; diff --git a/pallets/commitments/src/runtime_api.rs b/pallets/commitments/src/runtime_api.rs index c8ecc6b7..fbc6d1dd 100644 --- a/pallets/commitments/src/runtime_api.rs +++ b/pallets/commitments/src/runtime_api.rs @@ -1,10 +1,6 @@ //! Runtime APIs for reading from pallet-commitments. -use alloc::vec::Vec; - use frame_support::BoundedVec; -use proof_of_sql_commitment_map::generic_over_commitment::ConcreteType; -use proof_of_sql_commitment_map::{AnyCommitmentScheme, TableCommitmentBytes}; use sp_core::ConstU32; use sxt_core::tables::TableIdentifier; diff --git a/pallets/indexing/src/lib.rs b/pallets/indexing/src/lib.rs index 34f6dcce..cbc72731 100644 --- a/pallets/indexing/src/lib.rs +++ b/pallets/indexing/src/lib.rs @@ -34,31 +34,16 @@ pub mod native_pallet; #[allow(clippy::manual_inspect)] #[frame_support::pallet] pub mod pallet { - use alloc::string::String; - use alloc::vec::Vec; - - use codec::Decode; use commitment_sql::InsertAndCommitmentMetadata; - use frame_support::dispatch::RawOrigin; use frame_support::pallet_prelude::*; - use frame_support::{Blake2_128, Blake2_128Concat}; + use frame_support::Blake2_128Concat; use frame_system::pallet_prelude::*; - use hex::FromHex; use native_api::NativeApi; use on_chain_table::OnChainTable; - use sp_core::crypto::Ss58Codec; - use sp_core::{H256, U256}; - use sp_runtime::traits::{Bounded, Hash, StaticLookup, UniqueSaturatedInto}; - use sp_runtime::{BoundedVec, SaturatedConversion}; + use sp_runtime::traits::Hash; + use sp_runtime::BoundedVec; use sxt_core::permissions::{IndexingPalletPermission, PermissionLevel}; - use sxt_core::tables::{ - InsertQuorumSize, - QuorumScope, - TableIdentifier, - TableName, - TableNamespace, - }; - use sxt_core::IdentLength; + use sxt_core::tables::{InsertQuorumSize, QuorumScope, TableIdentifier}; use super::*; diff --git a/pallets/indexing/src/mock.rs b/pallets/indexing/src/mock.rs index 223eedcd..5759c225 100644 --- a/pallets/indexing/src/mock.rs +++ b/pallets/indexing/src/mock.rs @@ -1,14 +1,14 @@ use frame_election_provider_support::bounds::{ElectionBounds, ElectionBoundsBuilder}; use frame_election_provider_support::{onchain, SequentialPhragmen}; use frame_support::pallet_prelude::ConstU32; -use frame_support::traits::{ConstU128, VariantCountOf}; +use frame_support::traits::ConstU128; use frame_support::{derive_impl, parameter_types}; use native_api::Api; use proof_of_sql_commitment_map::generic_over_commitment::ConcreteType; use proof_of_sql_commitment_map::PerCommitmentScheme; use proof_of_sql_static_setups::io::get_or_init_from_files_with_four_points_unchecked; use sp_core::{ConstU64, H256}; -use sp_runtime::traits::{ConvertInto, IdentityLookup, MaybeConvert, OpaqueKeys, TryConvertInto}; +use sp_runtime::traits::{IdentityLookup, OpaqueKeys}; use sp_runtime::{BuildStorage, KeyTypeId}; use crate as pallet_indexing; diff --git a/pallets/indexing/src/tests.rs b/pallets/indexing/src/tests.rs index c3bf3e35..7d867ed0 100644 --- a/pallets/indexing/src/tests.rs +++ b/pallets/indexing/src/tests.rs @@ -19,11 +19,9 @@ use sp_core::Hasher; use sp_runtime::BoundedVec; use sxt_core::permissions::{IndexingPalletPermission, PermissionLevel, PermissionList}; use sxt_core::tables::{ - CommitmentScheme, CreateStatement, InsertQuorumSize, QuorumScope, - SourceAndMode, TableIdentifier, TableName, TableNamespace, @@ -579,7 +577,7 @@ fn inserting_data_fails_when_table_name_is_empty() { .unwrap(); pallet_permissions::Permissions::::insert(who, permissions.clone()); - let (table_id, create_statement) = sample_table_definition(); + let (table_id, _create_statement) = sample_table_definition(); let test_identifier = TableIdentifier { // Create an empty table name name: TableName::try_from(b"".to_vec()).unwrap(), @@ -1556,11 +1554,11 @@ fn we_can_submit_to_permissionless_table_with_no_permissions() { batch_id: BatchId::try_from(b"test_batch".to_vec()).unwrap(), data: row_data(), }; - let test_data_hash = + let _test_data_hash = <::Hashing as Hasher>::hash(&test_submission.data); let public_submitter = RuntimeOrigin::signed(sp_runtime::AccountId32::new([1; 32])); - let who = ensure_signed(public_submitter.clone()).unwrap(); + let _who = ensure_signed(public_submitter.clone()).unwrap(); // permissionless submission assert_ok!(submit_test_data(public_submitter, test_submission.clone())); diff --git a/pallets/rewards/src/lib.rs b/pallets/rewards/src/lib.rs index 79ba7e2f..f1b797e0 100644 --- a/pallets/rewards/src/lib.rs +++ b/pallets/rewards/src/lib.rs @@ -8,7 +8,6 @@ extern crate alloc; extern crate core; -use alloc::vec::Vec; #[cfg(test)] mod mock; @@ -131,7 +130,7 @@ pub mod pallet { /// payouts across a number of blocks until all payouts for the previous eras have been /// paid. fn on_initialize(_: BlockNumberFor) -> Weight { - let mut total_weight: Weight = Weight::zero(); + let total_weight: Weight = Weight::zero(); // Start by getting the last era we've paid out let active_era = NextPaidEra::::get(); @@ -188,11 +187,11 @@ pub mod pallet { let reward_weight = rewards_for_era .individual .into_iter() - .filter(|(validator, points)| { + .filter(|(validator, _points)| { pallet_staking::EraInfo::::pending_rewards(active_era, validator) }) .take(max_payouts) - .map(|(validator, points)| { + .map(|(validator, _points)| { let origin = frame_system::RawOrigin::Signed(payer.clone()).into(); match pallet_staking::Pallet::::payout_stakers( origin, diff --git a/pallets/rewards/src/mock.rs b/pallets/rewards/src/mock.rs index ed656956..83f38b88 100644 --- a/pallets/rewards/src/mock.rs +++ b/pallets/rewards/src/mock.rs @@ -2,25 +2,15 @@ use frame_election_provider_support::bounds::{ElectionBounds, ElectionBoundsBuil use frame_election_provider_support::private::sp_arithmetic::FixedU128; use frame_election_provider_support::{onchain, SequentialPhragmen}; use frame_support::pallet_prelude::ConstU32; -use frame_support::traits::{ConstU128, KeyOwnerProofSystem, VariantCountOf}; +use frame_support::traits::{ConstU128, KeyOwnerProofSystem}; use frame_support::{derive_impl, parameter_types}; -use pallet_grandpa::AuthorityId as GrandpaId; use proof_of_sql_commitment_map::generic_over_commitment::ConcreteType; use proof_of_sql_commitment_map::PerCommitmentScheme; use proof_of_sql_static_setups::io::get_or_init_from_files_with_four_points_unchecked; -use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_babe::AuthorityId as BabeId; use sp_core::{ConstU64, H256}; -use sp_runtime::traits::{ - ConvertInto, - IdentityLookup, - MaybeConvert, - OpaqueKeys, - TryConvertInto, - UniqueSaturatedInto, - Zero, -}; -use sp_runtime::{generic, BuildStorage, FixedPointNumber, KeyTypeId}; +use sp_runtime::traits::{IdentityLookup, OpaqueKeys, UniqueSaturatedInto, Zero}; +use sp_runtime::{BuildStorage, FixedPointNumber, KeyTypeId}; use crate as pallet_rewards; diff --git a/pallets/rewards/src/tests.rs b/pallets/rewards/src/tests.rs index 9257dac5..48c5d987 100644 --- a/pallets/rewards/src/tests.rs +++ b/pallets/rewards/src/tests.rs @@ -1,4 +1,4 @@ -use crate::mock::{new_test_ext, Staking, System}; +use crate::mock::new_test_ext; #[test] fn staking_rewards_pay_out() { diff --git a/pallets/system_tables/src/lib.rs b/pallets/system_tables/src/lib.rs index 5522eedf..e3c3bcda 100644 --- a/pallets/system_tables/src/lib.rs +++ b/pallets/system_tables/src/lib.rs @@ -17,6 +17,7 @@ mod mock; mod tests; mod messages; +/// Templates for system table SQL statements. mod templates; pub mod runtime_api; @@ -29,16 +30,15 @@ pub mod pallet { use frame_support::dispatch::{DispatchResult, RawOrigin}; use frame_support::pallet_prelude::*; - use frame_support::traits::StoredMap; use frame_system::pallet_prelude::{BlockNumberFor, *}; use itertools::Itertools; use on_chain_table::OnChainTable; use pallet_session::historical::IdentificationTuple; use sp_core::U256; - use sp_runtime::traits::{StaticLookup, UniqueSaturatedInto, Zero}; - use sp_runtime::{DispatchErrorWithPostInfo, Perbill, SaturatedConversion}; + use sp_runtime::traits::{StaticLookup, UniqueSaturatedInto}; + use sp_runtime::{Perbill, SaturatedConversion}; use sp_staking::offence::{OffenceDetails, OnOffenceHandler}; - use sp_staking::{SessionIndex, StakingInterface}; + use sp_staking::SessionIndex; use sxt_core::parse::{ MessageSystemRequest, StakingSystemRequest, @@ -47,7 +47,7 @@ pub mod pallet { SystemRequestType, }; use sxt_core::system_tables::ClaimedUnstake; - use sxt_core::tables::{TableIdentifier, TableName, TableNamespace}; + use sxt_core::tables::TableIdentifier; use sxt_core::utils::eth_address_to_substrate_account_id; use super::*; @@ -176,9 +176,9 @@ pub mod pallet { } } - /// The Lock Identifier used by the staking pallet to lock funds in the balances pallet - /// We use it to retrieve someone's staked balance - pub(crate) const STAKING_ID: frame_support::traits::LockIdentifier = *b"staking "; + /// The Lock Identifier used by the staking pallet to lock funds in the balances pallet. + /// We use it to retrieve someone's staked balance. + pub(crate) const _STAKING_ID: frame_support::traits::LockIdentifier = *b"staking "; /// Process all state changes for a given SystemRequest pub fn process_request(request: SystemRequest) -> DispatchResult { @@ -442,7 +442,7 @@ pub mod pallet { // How much will be active after the unbonding. Is it less than the let remaining_active = staking_ledger.active - unstake_amount; - if let Some(nominations) = pallet_staking::Nominators::::get(&staker_id) + if let Some(_nominations) = pallet_staking::Nominators::::get(&staker_id) { if remaining_active < pallet_staking::MinNominatorBond::::get() { pallet_staking::Pallet::::chill(staker_signer.clone())?; @@ -634,7 +634,7 @@ pub mod pallet { validator: validator_account.clone(), }); - let result = + let _result = pallet_staking::Pallet::::chill(RawOrigin::Signed(validator_account).into()); weight += Weight::from_parts(10_000, 0) } diff --git a/pallets/system_tables/src/tests.rs b/pallets/system_tables/src/tests.rs index c4f5b031..f9e0d5a7 100644 --- a/pallets/system_tables/src/tests.rs +++ b/pallets/system_tables/src/tests.rs @@ -200,7 +200,7 @@ fn bonding_extra_with_an_account_works() { // Make sure there are no errors in the events let events = System::events(); - if let Some(RuntimeEvent::SystemTables(crate::Event::MessageProcessingError { error })) = + if let Some(RuntimeEvent::SystemTables(crate::Event::MessageProcessingError { error: _ })) = events.last().map(|e| &e.event) { panic!("Expected no errors!"); @@ -272,7 +272,7 @@ fn set_nominations_works_if_stash_is_bonded() { let nominate = get_nominate_message(ETH_TEST_WALLET, &nomination_targets); assert_ok!(crate::process_nominating::(nominate)); - let found = pallet_staking::Nominators::::drain().any(|(nominator, _)| true); + let found = pallet_staking::Nominators::::drain().any(|(_nominator, _)| true); assert!(found, "Expected nominator not found in staking nominators"); }); diff --git a/pallets/tables/src/lib.rs b/pallets/tables/src/lib.rs index 2e506736..b5550acb 100644 --- a/pallets/tables/src/lib.rs +++ b/pallets/tables/src/lib.rs @@ -23,6 +23,7 @@ pub mod runtime_api; pub mod weights; pub use weights::*; +/// Metadata prefix utilities for table storage keys. mod metadata_prefix; #[allow(clippy::manual_inspect)] @@ -60,8 +61,6 @@ pub mod pallet { update_uuid_in_create_table_statement, uuids_from_sqlparser, ColumnUuidList, - CommitmentBytes, - CommitmentScheme, CreateStatement, GetTableSchemaError, IdentifierList, @@ -1109,8 +1108,8 @@ pub mod pallet { )? } CommitmentCreationCmd::FromSnapshot( - ref snapshot_url, - ref per_commitment_scheme, + ref _snapshot_url, + ref _per_commitment_scheme, ) => Err(DispatchError::Other( "Snapshot commitments are deprecated in this extrinsic", ))?, @@ -1192,8 +1191,10 @@ pub mod pallet { } } - // Check if a public table has a safe name. Accepts an account ID and a table Identifier and determines if the table identifier is - // valid for the provided table owner. + /// Checks if a public table has a safe namespace. + /// + /// Accepts an account ID and a table identifier and determines if the table identifier is + /// valid for the provided table owner. pub(crate) fn ensure_safe_namespace( who: &T::AccountId, namespace: &ByteString, @@ -1233,7 +1234,7 @@ pub mod pallet { zero_table_weight + (table_weight * num_tables as u64) } - // Returns true if the provided bytes coule be a valid ethereum address + /// Returns true if the provided account could be a valid Ethereum address. pub(crate) fn is_ethereum_address(account: T::AccountId) -> bool { let eth_bytes = account.encode(); // Remove the leiading 0s from the bytes before comparing diff --git a/pallets/zkpay/src/lib.rs b/pallets/zkpay/src/lib.rs index b66aaaa4..d0632fa5 100644 --- a/pallets/zkpay/src/lib.rs +++ b/pallets/zkpay/src/lib.rs @@ -2,6 +2,8 @@ //! This pallet contains types, utilities, and logic related to processing ZKpay // We make sure this pallet uses `no_std` for compiling to Wasm. #![cfg_attr(not(feature = "std"), no_std)] +// deposit_event is auto-generated by the pallet macro and cannot have docs added +#![allow(missing_docs)] // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; @@ -34,7 +36,6 @@ pub mod pallet { use sxt_core::ByteString; use super::*; - use crate::Error::*; use crate::Event::*; // The `Pallet` struct serves as a placeholder to implement traits, methods and dispatchables @@ -259,11 +260,11 @@ pub mod pallet { row.get("STALEPRICETHRESHOLDINSECONDS"), ) { ( - Some(SystemFieldValue::Bytes(asset)), // The asset address - Some(SystemFieldValue::Bytes(allowed_payment_types)), // The allowed payment types presented as a bytes1 bitmask - Some(SystemFieldValue::Bytes(price_feed)), // The price feed address - Some(SystemFieldValue::SmallInt(token_decimals)), //The token decimals - Some(SystemFieldValue::Decimal(stale_price_threshold_in_seconds)), + Some(SystemFieldValue::Bytes(_asset)), // The asset address + Some(SystemFieldValue::Bytes(_allowed_payment_types)), // The allowed payment types presented as a bytes1 bitmask + Some(SystemFieldValue::Bytes(_price_feed)), // The price feed address + Some(SystemFieldValue::SmallInt(_token_decimals)), //The token decimals + Some(SystemFieldValue::Decimal(_stale_price_threshold_in_seconds)), ) => { // Not yet supported Ok(()) @@ -282,7 +283,7 @@ pub mod pallet { .rows() .map(|row| -> DispatchResult { match row.get("ASSET") { - Some(SystemFieldValue::Bytes(asset)) => { + Some(SystemFieldValue::Bytes(_asset)) => { // Not yet supported Ok(()) } @@ -304,8 +305,8 @@ pub mod pallet { row.get("CALLBACKCLIENTCONTRACTADDRESS"), ) { ( - Some(SystemFieldValue::Bytes(query_hash)), - Some(SystemFieldValue::Bytes(callback_client_contract_address)), + Some(SystemFieldValue::Bytes(_query_hash)), + Some(SystemFieldValue::Bytes(_callback_client_contract_address)), ) => { // Not yet supported Ok(()) @@ -328,8 +329,8 @@ pub mod pallet { row.get("CALLBACKCLIENTCONTRACTADDRESS"), ) { ( - Some(SystemFieldValue::Bytes(query_hash)), - Some(SystemFieldValue::Bytes(callback_client_contract_address)), + Some(SystemFieldValue::Bytes(_query_hash)), + Some(SystemFieldValue::Bytes(_callback_client_contract_address)), ) => { // Not yet supported Ok(()) @@ -349,7 +350,7 @@ pub mod pallet { .rows() .map(|row| -> DispatchResult { match row.get("VERSION") { - Some(SystemFieldValue::Decimal(asset)) => { + Some(SystemFieldValue::Decimal(_version)) => { // Not yet supported Ok(()) } @@ -374,11 +375,11 @@ pub mod pallet { row.get("AMOUNTINUSD"), ) { ( - Some(SystemFieldValue::Bytes(query_hash)), - Some(SystemFieldValue::Bytes(asset)), - Some(SystemFieldValue::Decimal(amount)), - Some(SystemFieldValue::Bytes(source_)), - Some(SystemFieldValue::Decimal(amount_in_usd)), + Some(SystemFieldValue::Bytes(_query_hash)), + Some(SystemFieldValue::Bytes(_asset)), + Some(SystemFieldValue::Decimal(_amount)), + Some(SystemFieldValue::Bytes(_source)), + Some(SystemFieldValue::Decimal(_amount_in_usd)), ) => { // Not yet supported Ok(()) @@ -403,10 +404,10 @@ pub mod pallet { row.get("AMOUNT"), ) { ( - Some(SystemFieldValue::Bytes(query_hash)), - Some(SystemFieldValue::Bytes(asset)), - Some(SystemFieldValue::Bytes(source_)), - Some(SystemFieldValue::Decimal(amount)), + Some(SystemFieldValue::Bytes(_query_hash)), + Some(SystemFieldValue::Bytes(_asset)), + Some(SystemFieldValue::Bytes(_source)), + Some(SystemFieldValue::Decimal(_amount)), ) => { // Not yet supported Ok(()) @@ -430,9 +431,9 @@ pub mod pallet { row.get("REMAININGAMOUNT"), ) { ( - Some(SystemFieldValue::Bytes(query_hash)), - Some(SystemFieldValue::Decimal(used_amount)), - Some(SystemFieldValue::Decimal(remaining_amount)), + Some(SystemFieldValue::Bytes(_query_hash)), + Some(SystemFieldValue::Decimal(_used_amount)), + Some(SystemFieldValue::Decimal(_remaining_amount)), ) => { // Not yet supported Ok(()) @@ -452,8 +453,8 @@ pub mod pallet { .map(|row| -> DispatchResult { match (row.get("QUERYHASH"), row.get("CALLER")) { ( - Some(SystemFieldValue::Bytes(query_hash)), - Some(SystemFieldValue::Bytes(caller)), + Some(SystemFieldValue::Bytes(_query_hash)), + Some(SystemFieldValue::Bytes(_caller)), ) => { // Not yet supported Ok(()) @@ -472,7 +473,7 @@ pub mod pallet { .rows() .map(|row| -> DispatchResult { match row.get("QUERYHASH") { - Some(SystemFieldValue::Bytes(query_hash)) => { + Some(SystemFieldValue::Bytes(_query_hash)) => { // Not yet supported Ok(()) } @@ -502,16 +503,16 @@ pub mod pallet { row.get("QUERYHASH"), ) { ( - Some(SystemFieldValue::Decimal(query_nonce)), - Some(SystemFieldValue::Bytes(sender)), - Some(SystemFieldValue::Bytes(query)), - Some(SystemFieldValue::Bytes(query_parameters)), - Some(SystemFieldValue::Decimal(timeout)), - Some(SystemFieldValue::Bytes(callback_client_contract_address)), - Some(SystemFieldValue::Decimal(callback_gas_limit)), - Some(SystemFieldValue::Bytes(callback_data)), - Some(SystemFieldValue::Bytes(custom_logic_contract_address)), - Some(SystemFieldValue::Bytes(query_hash)), + Some(SystemFieldValue::Decimal(_query_nonce)), + Some(SystemFieldValue::Bytes(_sender)), + Some(SystemFieldValue::Bytes(_query)), + Some(SystemFieldValue::Bytes(_query_parameters)), + Some(SystemFieldValue::Decimal(_timeout)), + Some(SystemFieldValue::Bytes(_callback_client_contract_address)), + Some(SystemFieldValue::Decimal(_callback_gas_limit)), + Some(SystemFieldValue::Bytes(_callback_data)), + Some(SystemFieldValue::Bytes(_custom_logic_contract_address)), + Some(SystemFieldValue::Bytes(_query_hash)), ) => { // Not yet supported Ok(()) @@ -543,8 +544,8 @@ pub mod pallet { Some(SystemFieldValue::Decimal(amount)), Some(SystemFieldValue::Bytes(on_behalf_of)), Some(SystemFieldValue::Bytes(target)), - Some(SystemFieldValue::Bytes(memo)), - Some(SystemFieldValue::Decimal(amount_in_usd)), + Some(SystemFieldValue::Bytes(_memo)), + Some(SystemFieldValue::Decimal(_amount_in_usd)), Some(SystemFieldValue::Bytes(sender)), ) => { let asset_address = AssetAddress::try_from(asset.to_vec()) @@ -576,7 +577,7 @@ pub mod pallet { .rows() .map(|row| -> DispatchResult { match row.get("TREASURY") { - Some(SystemFieldValue::Bytes(treasury)) => { + Some(SystemFieldValue::Bytes(_treasury)) => { // Not yet supported Ok(()) } diff --git a/pallets/zkpay/src/mock.rs b/pallets/zkpay/src/mock.rs index 547ef940..66dde444 100644 --- a/pallets/zkpay/src/mock.rs +++ b/pallets/zkpay/src/mock.rs @@ -1,9 +1,8 @@ -use frame_support::pallet_prelude::ConstU32; -use frame_support::traits::{ConstU128, KeyOwnerProofSystem, VariantCountOf}; -use frame_support::{derive_impl, parameter_types}; -use sp_core::{ConstU64, H256}; -use sp_runtime::traits::{ConvertInto, IdentityLookup, MaybeConvert, OpaqueKeys, TryConvertInto}; -use sp_runtime::{generic, BuildStorage, KeyTypeId}; +use frame_support::derive_impl; +use frame_support::traits::ConstU128; +use sp_core::H256; +use sp_runtime::traits::IdentityLookup; +use sp_runtime::BuildStorage; use crate as pallet_zkpay; diff --git a/proof-of-sql/commitment-column-mapping/src/lib.rs b/proof-of-sql/commitment-column-mapping/src/lib.rs index b4d93b33..badd770c 100644 --- a/proof-of-sql/commitment-column-mapping/src/lib.rs +++ b/proof-of-sql/commitment-column-mapping/src/lib.rs @@ -3,16 +3,22 @@ extern crate alloc; +/// Maps column commitment metadata between representations. mod map_column_commitment_metadata; +/// Tries to map on-chain columns with error handling. mod try_map_on_chain_column; +/// Combinator utilities for mapping operations. mod combinator; +/// Maps table commitments between representations. mod map_table_commitment; +/// Maps on-chain tables to their commitment representations. mod map_on_chain_table; +/// Workaround for varchar/varbinary column type handling. mod varchar_workaround; pub use varchar_workaround::{ convert_selected_varbinary_columns_to_varchar, diff --git a/proof-of-sql/commitment-map/src/lib.rs b/proof-of-sql/commitment-map/src/lib.rs index 30550cf5..dd34f99f 100644 --- a/proof-of-sql/commitment-map/src/lib.rs +++ b/proof-of-sql/commitment-map/src/lib.rs @@ -6,9 +6,11 @@ extern crate alloc; pub mod generic_over_commitment; +/// Function trait for operations generic over commitment schemes. mod generic_over_commitment_fn; pub use generic_over_commitment_fn::GenericOverCommitmentFn; +/// Commitment scheme types and configuration. mod commitment_scheme; pub use commitment_scheme::{ AnyCommitmentScheme, @@ -18,8 +20,10 @@ pub use commitment_scheme::{ PerCommitmentScheme, }; +/// Implementation details for commitment maps. mod commitment_map_implementor; +/// Core commitment map trait and implementations. mod commitment_map; pub use commitment_map::{CommitmentMap, CommitmentSchemesMismatchError, KeyExistsError}; diff --git a/proof-of-sql/commitment-sql/src/lib.rs b/proof-of-sql/commitment-sql/src/lib.rs index ed6886b5..a7b7e1f8 100644 --- a/proof-of-sql/commitment-sql/src/lib.rs +++ b/proof-of-sql/commitment-sql/src/lib.rs @@ -3,11 +3,14 @@ extern crate alloc; +/// Internal map types with no_std-compatible hashers. mod map; +/// Column options parsing and validation. mod column_options; pub use column_options::InvalidColumnOptions; +/// Type conversion between SQLParser and proof-of-sql types. mod column_type_conversion { proof_of_sql_unversioned::impl_sqlparser_proof_of_sql_type_conversion!(); } @@ -16,12 +19,15 @@ pub use column_type_conversion::{ UnsupportedColumnType, }; +/// Row number column definition utilities. mod row_number_column; pub use row_number_column::row_number_column_def; +/// Create table statement validation. mod validated_create_table; pub use validated_create_table::{InvalidCreateTable, ValidatedCreateTable}; +/// Create table processing and commitment generation. mod create_table; pub use create_table::{ process_create_table, @@ -29,12 +35,14 @@ pub use create_table::{ OnChainTableToTableCommitmentFn, }; +/// Create table from snapshot processing. mod create_table_from_snapshot; pub use create_table_from_snapshot::{ process_create_table_from_snapshot, ProcessCreateTableFromSnapshotError, }; +/// Insert statement processing and commitment updates. mod insert; pub use insert::{ process_insert, diff --git a/proof-of-sql/commitment-sql/src/map.rs b/proof-of-sql/commitment-sql/src/map.rs index df8de389..e6a39ff8 100644 --- a/proof-of-sql/commitment-sql/src/map.rs +++ b/proof-of-sql/commitment-sql/src/map.rs @@ -1,4 +1,2 @@ /// IndexMap with a default `AHasher`, for `no_std` usage pub type IndexMap = indexmap::IndexMap>; -/// IndexSet with a default `AHasher`, for `no_std` usage -pub type IndexSet = indexmap::IndexSet>; diff --git a/proof-of-sql/commitment-sql/src/row_number_column.rs b/proof-of-sql/commitment-sql/src/row_number_column.rs index 808374f1..29491ad6 100644 --- a/proof-of-sql/commitment-sql/src/row_number_column.rs +++ b/proof-of-sql/commitment-sql/src/row_number_column.rs @@ -1,7 +1,6 @@ use alloc::vec; use alloc::vec::Vec; -use const_format::formatcp; use on_chain_table::{OnChainColumn, OnChainTable}; use snafu::Snafu; use sqlparser::ast::helpers::stmt_create_table::CreateTableBuilder; diff --git a/proof-of-sql/unversioned/src/lib.rs b/proof-of-sql/unversioned/src/lib.rs index f70350f9..ae7a750c 100644 --- a/proof-of-sql/unversioned/src/lib.rs +++ b/proof-of-sql/unversioned/src/lib.rs @@ -1,4 +1,5 @@ #![doc = include_str!("../README.md")] #![no_std] +/// Conversion utilities between SQLParser types and proof-of-sql types. mod sqlparser_type_conversion; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index bf9a258f..ad0f6908 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -3,6 +3,7 @@ // runtime construction via `frame_support::runtime` does a lot of recursion and requires us to increase the limit. #![recursion_limit = "512"] +#[cfg(test)] mod tests; #[cfg(feature = "std")] @@ -45,12 +46,12 @@ pub use pallet_im_online::sr25519::AuthorityId as ImOnlineId; pub use pallet_timestamp::Call as TimestampCall; use pallet_transaction_payment::{CurrencyAdapter, Multiplier}; use proof_of_sql_commitment_map::generic_over_commitment::ConcreteType; -use proof_of_sql_commitment_map::{AnyCommitmentScheme, PerCommitmentScheme, TableCommitmentBytes}; +use proof_of_sql_commitment_map::PerCommitmentScheme; use sp_api::impl_runtime_apis; use sp_arithmetic::traits::UniqueSaturatedInto; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_babe::AuthorityId as BabeId; -use sp_core::crypto::{AccountId32, KeyTypeId}; +use sp_core::crypto::KeyTypeId; use sp_core::OpaqueMetadata; use sp_runtime::traits::{ AccountIdLookup, @@ -59,7 +60,6 @@ use sp_runtime::traits::{ Bounded, IdentifyAccount, NumberFor, - One, OpaqueKeys, Verify, Zero, @@ -78,7 +78,6 @@ use sp_runtime::{ ApplyExtrinsicResult, FixedPointNumber, FixedU128, - MultiSignature, Perquintill, }; pub use sp_runtime::{Perbill, Percent, Permill}; @@ -485,7 +484,7 @@ pub struct EraPayout; impl pallet_staking::EraPayout for EraPayout { fn era_payout( total_staked: Balance, - total_issuance: Balance, + _total_issuance: Balance, era_duration_millis: u64, ) -> (Balance, Balance) { const MILLISECONDS_PER_YEAR: u64 = (1000 * 3600 * 24 * 36525) / 100; diff --git a/runtime/src/tests.rs b/runtime/src/tests.rs index c053659d..9878dbb7 100644 --- a/runtime/src/tests.rs +++ b/runtime/src/tests.rs @@ -1,14 +1,7 @@ use pallet_staking::EraPayout; use sp_runtime::traits::Zero; -use crate::{ - Balance, - EraPayout as SXTPayout, - SessionsPerEra, - DOLLARS, - EPOCH_DURATION_IN_BLOCKS, - MILLISECS_PER_BLOCK, -}; +use crate::{Balance, EraPayout as SXTPayout, DOLLARS}; #[test] fn era_payout_calculation_works() { diff --git a/sxt-core/src/indexing.rs b/sxt-core/src/indexing.rs index 2d56a271..ee697fc0 100644 --- a/sxt-core/src/indexing.rs +++ b/sxt-core/src/indexing.rs @@ -5,7 +5,7 @@ use frame_support::pallet_prelude::{ConstU32, TypeInfo}; use sp_core::U256; use sp_runtime::BoundedBTreeSet; -use crate::tables::{QuorumScope, TableIdentifier, TableUuid}; +use crate::tables::{QuorumScope, TableIdentifier}; /// Maximum length of submitted Record Batch Data pub const DATA_MAX_LEN: u32 = 8_000_000; diff --git a/sxt-core/src/tables.rs b/sxt-core/src/tables.rs index 1c64862b..e2d21b78 100644 --- a/sxt-core/src/tables.rs +++ b/sxt-core/src/tables.rs @@ -2,7 +2,6 @@ extern crate alloc; use alloc::string::{String, ToString}; use alloc::vec::Vec; use alloc::{format, vec}; -use core::fmt::Display; use core::str::{from_utf8, Utf8Error}; use codec::{Decode, Encode, MaxEncodedLen}; @@ -571,7 +570,7 @@ pub fn update_uuid_in_create_table_statement( let table: CreateTableBuilder = create_statement_to_sqlparser(statement) .map_err(|error| UpdateUuidError::ParseError { error })?; - let table_uuid_str = from_utf8(uuid.as_slice()).map_err(|e| UpdateUuidError::InvalidUuid)?; + let table_uuid_str = from_utf8(uuid.as_slice()).map_err(|_| UpdateUuidError::InvalidUuid)?; // Turn the UUID entries into SqlOption let table_entry = SqlOption { @@ -1431,7 +1430,6 @@ mod tests { let create_statement: CreateStatement = BoundedVec::try_from(test_val.as_bytes().to_vec()).unwrap(); let test_uuid: TableUuid = BoundedVec::try_from("TESTUUID".as_bytes().to_vec()).unwrap(); - let expoected_val = ""; let r = update_uuid_in_create_table_statement( test_uuid, ColumnUuidList::default(), @@ -1450,7 +1448,6 @@ mod tests { let create_statement: CreateStatement = BoundedVec::try_from(test_val.as_bytes().to_vec()).unwrap(); let test_uuid: TableUuid = BoundedVec::try_from("TESTUUID".as_bytes().to_vec()).unwrap(); - let expoected_val = ""; let r = update_uuid_in_create_table_statement( test_uuid, ColumnUuidList::default(), @@ -1469,7 +1466,6 @@ mod tests { let create_statement: CreateStatement = BoundedVec::try_from(test_val.as_bytes().to_vec()).unwrap(); let test_uuid: TableUuid = BoundedVec::try_from("TESTUUID".as_bytes().to_vec()).unwrap(); - let expoected_val = ""; let r = update_uuid_in_create_table_statement( test_uuid, ColumnUuidList::default(), diff --git a/translation-layer/src/api/smartcontracts.rs b/translation-layer/src/api/smartcontracts.rs index 13e366fa..560bf151 100644 --- a/translation-layer/src/api/smartcontracts.rs +++ b/translation-layer/src/api/smartcontracts.rs @@ -15,7 +15,6 @@ use crate::model::{ GetContractResponse, GetContractsResponse, RemoveContractRequest, - TableRequest, }; use crate::state::TranslationLayerState; use crate::table_builder::TableCreator; @@ -266,7 +265,7 @@ pub async fn get_smartcontract( .storage() .at_latest() .await - .map_err(|err| internal_server_error("Failed to access storage"))?; + .map_err(|_err| internal_server_error("Failed to access storage"))?; let contract = storage .fetch(&query) @@ -344,7 +343,7 @@ pub async fn get_smartcontracts( .storage() .at_latest() .await - .map_err(|err| internal_server_error("Failed to access storage"))?; + .map_err(|_err| internal_server_error("Failed to access storage"))?; let mut contract_stream = storage.iter(query).await.map_err(|err| { internal_server_error(&format!("Failed to get storage iterator: {}", err)) diff --git a/translation-layer/src/api/tables.rs b/translation-layer/src/api/tables.rs index 81c28bb5..8ca76885 100644 --- a/translation-layer/src/api/tables.rs +++ b/translation-layer/src/api/tables.rs @@ -4,15 +4,11 @@ use axum::extract::State; use axum::Json; use sxt_core::sxt_chain_runtime; use sxt_core::sxt_chain_runtime::api::runtime_types::bounded_collections::bounded_vec::BoundedVec; -use sxt_core::sxt_chain_runtime::api::runtime_types::sxt_core::tables::{ - SourceAndMode, - TableIdentifier, -}; +use sxt_core::sxt_chain_runtime::api::runtime_types::sxt_core::tables::TableIdentifier; use crate::model::{ApiResponse, CreateTableRequest, DropTableRequest, TableRequest}; use crate::state::TranslationLayerState; use crate::table_builder::TableCreator; -use crate::utils::{string_to_mode, string_to_source}; /// Submits a transaction to create a new table in the indexing system. /// diff --git a/utils/commit-grouper/src/lib.rs b/utils/commit-grouper/src/lib.rs index 8806c752..8e79e284 100644 --- a/utils/commit-grouper/src/lib.rs +++ b/utils/commit-grouper/src/lib.rs @@ -13,7 +13,7 @@ use proof_of_sql_commitment_map::{ }; use scale_info::TypeInfo; use serde::Deserialize; -use snafu::{OptionExt, ResultExt, Snafu}; +use snafu::{OptionExt, Snafu}; use sxt_core::tables::{TableIdentifier, TableName, TableNamespace}; /// TODO