Skip to content

Commit

Permalink
Feat: update clippy requirements to nightly-2023-08-24 without chan…
Browse files Browse the repository at this point in the history
…ging toolchain (#832)

# Description

Currently impossible to update toolchain, it's related to [NEAR
issue](near/nearcore#9143).

And it is impossible to do `cargo update`, because
[issue](rust-cli/anstyle#118 (comment)).

- Updated clippy requirements to `nightly-2023-08-24`, without updating
`rust-toolchain`.
- Fixed clippy issues, related to clippy requirements for
`nightly-2023-08-24` version.
  • Loading branch information
mrLSD authored and aleksuss committed Sep 25, 2023
1 parent 129c337 commit 7f90566
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 42 deletions.
5 changes: 4 additions & 1 deletion engine-hashchain/src/bloom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
//! Link: <https://github.com/paritytech/parity-common/blob/master/ethbloom/src/lib.rs>
//!
//! Reimplemented here since there is a large mismatch in types and dependencies.
#![allow(clippy::expl_impl_clone_on_copy)]
#![allow(
clippy::expl_impl_clone_on_copy,
// TODO: rust-2023-08-24 clippy::incorrect_clone_impl_on_copy_type
)]

use aurora_engine_sdk::keccak;
use aurora_engine_types::borsh::{self, BorshDeserialize, BorshSerialize};
Expand Down
12 changes: 6 additions & 6 deletions engine-precompiles/src/alt_bn256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ impl<HF: HardFork> Bn256Add<HF> {
pub const ADDRESS: Address = make_address(0, 6);

#[must_use]
pub fn new() -> Self {
Self(PhantomData::default())
pub const fn new() -> Self {
Self(PhantomData)
}
}

Expand Down Expand Up @@ -294,8 +294,8 @@ impl<HF: HardFork> Bn256Mul<HF> {
pub const ADDRESS: Address = make_address(0, 7);

#[must_use]
pub fn new() -> Self {
Self(PhantomData::default())
pub const fn new() -> Self {
Self(PhantomData)
}
}

Expand Down Expand Up @@ -402,8 +402,8 @@ impl<HF: HardFork> Bn256Pair<HF> {
pub const ADDRESS: Address = make_address(0, 8);

#[must_use]
pub fn new() -> Self {
Self(PhantomData::default())
pub const fn new() -> Self {
Self(PhantomData)
}
}

Expand Down
2 changes: 1 addition & 1 deletion engine-precompiles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl<'a, I: IO + Copy, E: Env, H: ReadOnlyPromiseHandler> executor::stack::Preco

fn process_precompile(
p: &dyn Precompile,
handle: &mut impl PrecompileHandle,
handle: &impl PrecompileHandle,
) -> Result<PrecompileOutput, PrecompileFailure> {
let input = handle.input();
let gas_limit = handle.gas_limit();
Expand Down
4 changes: 2 additions & 2 deletions engine-precompiles/src/modexp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ impl<HF: HardFork, M: ModExpAlgorithm> ModExp<HF, M> {
pub const ADDRESS: Address = make_address(0, 5);

#[must_use]
pub fn new() -> Self {
Self(PhantomData::default(), PhantomData::default())
pub const fn new() -> Self {
Self(PhantomData, PhantomData)
}
}

Expand Down
6 changes: 3 additions & 3 deletions engine-standalone-storage/src/json_snapshot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub mod types;
/// Write engine state directly into the Storage from a
/// JSON snapshot (which can be extracted from a NEAR RPC node).
pub fn initialize_engine_state(
storage: &mut Storage,
storage: &Storage,
snapshot: types::JsonSnapshot,
) -> Result<(), error::Error> {
// The snapshot is giving us a post-state, so we insert it right at the end of its block height.
Expand Down Expand Up @@ -64,7 +64,7 @@ mod test {
"contract.aurora.block51077328.json",
)
.unwrap();
let mut storage = crate::Storage::open("rocks_tmp/").unwrap();
super::initialize_engine_state(&mut storage, snapshot).unwrap();
let storage = crate::Storage::open("rocks_tmp/").unwrap();
super::initialize_engine_state(&storage, snapshot).unwrap();
}
}
2 changes: 1 addition & 1 deletion engine-standalone-tracing/src/sputnik.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl evm_runtime::tracing::EventListener for TransactionTraceBuilder {
return_value,
} => {
match result {
Ok(_) => {
Ok(()) => {
// Step completed, push current log into the record
self.logs.push(self.current.clone());
}
Expand Down
24 changes: 12 additions & 12 deletions engine-tests/src/tests/erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn erc20_mint() {
// Validate pre-state
assert_eq!(
U256::zero(),
get_address_erc20_balance(&mut runner, &source_account, dest_address, &contract)
get_address_erc20_balance(&runner, &source_account, dest_address, &contract)
);

// Do mint transaction
Expand All @@ -35,7 +35,7 @@ fn erc20_mint() {
// Validate post-state
assert_eq!(
U256::from(mint_amount),
get_address_erc20_balance(&mut runner, &source_account, dest_address, &contract)
get_address_erc20_balance(&runner, &source_account, dest_address, &contract)
);
}

Expand All @@ -49,7 +49,7 @@ fn erc20_mint_out_of_gas() {
// Validate pre-state
assert_eq!(
U256::zero(),
get_address_erc20_balance(&mut runner, &source_account, dest_address, &contract)
get_address_erc20_balance(&runner, &source_account, dest_address, &contract)
);

// Try mint transaction
Expand Down Expand Up @@ -131,11 +131,11 @@ fn erc20_transfer_success() {
// Validate pre-state
assert_eq!(
U256::from(INITIAL_BALANCE),
get_address_erc20_balance(&mut runner, &source_account, source_address, &contract)
get_address_erc20_balance(&runner, &source_account, source_address, &contract)
);
assert_eq!(
U256::zero(),
get_address_erc20_balance(&mut runner, &source_account, dest_address, &contract)
get_address_erc20_balance(&runner, &source_account, dest_address, &contract)
);

// Do transfer
Expand All @@ -149,11 +149,11 @@ fn erc20_transfer_success() {
// Validate post-state
assert_eq!(
U256::from(INITIAL_BALANCE - TRANSFER_AMOUNT),
get_address_erc20_balance(&mut runner, &source_account, source_address, &contract)
get_address_erc20_balance(&runner, &source_account, source_address, &contract)
);
assert_eq!(
U256::from(TRANSFER_AMOUNT),
get_address_erc20_balance(&mut runner, &source_account, dest_address, &contract)
get_address_erc20_balance(&runner, &source_account, dest_address, &contract)
);
}

Expand All @@ -170,11 +170,11 @@ fn erc20_transfer_insufficient_balance() {
// Validate pre-state
assert_eq!(
U256::from(INITIAL_BALANCE),
get_address_erc20_balance(&mut runner, &source_account, source_address, &contract)
get_address_erc20_balance(&runner, &source_account, source_address, &contract)
);
assert_eq!(
U256::zero(),
get_address_erc20_balance(&mut runner, &source_account, dest_address, &contract)
get_address_erc20_balance(&runner, &source_account, dest_address, &contract)
);

// Do transfer
Expand All @@ -189,11 +189,11 @@ fn erc20_transfer_insufficient_balance() {
// Validate post-state
assert_eq!(
U256::from(INITIAL_BALANCE),
get_address_erc20_balance(&mut runner, &source_account, source_address, &contract)
get_address_erc20_balance(&runner, &source_account, source_address, &contract)
);
assert_eq!(
U256::zero(),
get_address_erc20_balance(&mut runner, &source_account, dest_address, &contract)
get_address_erc20_balance(&runner, &source_account, dest_address, &contract)
);
}

Expand Down Expand Up @@ -238,7 +238,7 @@ fn deploy_erc_20_out_of_gas() {
}

fn get_address_erc20_balance(
runner: &mut utils::AuroraRunner,
runner: &utils::AuroraRunner,
signer: &Signer,
address: Address,
contract: &ERC20,
Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/tests/repro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ fn repro_common(context: &ReproContext) {

// Also validate the SubmitResult in the standalone engine
let mut standalone = standalone::StandaloneRunner::default();
json_snapshot::initialize_engine_state(&mut standalone.storage, snapshot).unwrap();
json_snapshot::initialize_engine_state(&standalone.storage, snapshot).unwrap();
let standalone_result = standalone
.submit_raw("submit", &runner.context, &[])
.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions engine-tests/src/tests/standalone/json_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn test_consume_snapshot() {
)
.unwrap();
let mut runner = standalone::StandaloneRunner::default();
json_snapshot::initialize_engine_state(&mut runner.storage, snapshot.clone()).unwrap();
json_snapshot::initialize_engine_state(&runner.storage, snapshot.clone()).unwrap();

// check accounts to see they were written properly
runner.env.block_height = snapshot.result.block_height + 1;
Expand Down Expand Up @@ -53,7 +53,7 @@ fn test_produce_snapshot() {
.storage
.set_engine_account_id(&"aurora".parse().unwrap())
.unwrap();
json_snapshot::initialize_engine_state(&mut runner.storage, snapshot.clone()).unwrap();
json_snapshot::initialize_engine_state(&runner.storage, snapshot.clone()).unwrap();

// add a couple more transactions that write some extra keys
runner.env.block_height = snapshot.result.block_height + 1;
Expand Down
4 changes: 2 additions & 2 deletions engine-tests/src/tests/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn test_access_list_tx_encoding_decoding() {

let signed_tx = utils::sign_access_list_transaction(transaction, &secret_key);
let bytes: Vec<u8> = iter::once(eip_2930::TYPE_BYTE)
.chain(rlp::encode(&signed_tx).into_iter())
.chain(rlp::encode(&signed_tx))
.collect();
let expected_bytes = hex::decode("01f8f901800a83061a8094095e7baea6a6c7c4c2dfeb977efac326af552d87830186a000f893f85994095e7baea6a6c7c4c2dfeb977efac326af552d87f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001f794195e7baea6a6c7c4c2dfeb977efac326af552d87e1a0000000000000000000000000000000000000000000000000000000000000000080a011c97e0bb8a356fe4f49b37863d059c6fe8cd3214a6ac06a8387a2f6f0b75f60a0212368a1097da30806edfd13d9c35662e1baee939235eb25de867980bd0eda26").unwrap();

Expand All @@ -163,7 +163,7 @@ fn test_access_list_tx_encoding_decoding() {

fn encode_tx(signed_tx: &SignedTransaction1559) -> Vec<u8> {
iter::once(eip_1559::TYPE_BYTE)
.chain(rlp::encode(signed_tx).into_iter())
.chain(rlp::encode(signed_tx))
.collect()
}

Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/tests/uniswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl UniswapTestContext {
token_path: &[ERC20],
amount_in: U256,
) -> (U256, u64, ExecutionProfile) {
for token in token_path.iter() {
for token in token_path {
self.approve_erc20(token, self.swap_router.0.address, U256::MAX);
}
let params = Self::exact_input_params(amount_in, token_path);
Expand Down
4 changes: 2 additions & 2 deletions engine-tests/src/tests/xcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn test_xcc_eth_gas_cost() {
let mut baseline_signer = utils::Signer::random();
runner.context.block_height = aurora_engine::engine::ZERO_ADDRESS_FIX_HEIGHT + 1;
// Need to use for engine's deployment!
let wnear_erc20 = deploy_erc20(&mut runner, &mut signer);
let wnear_erc20 = deploy_erc20(&mut runner, &signer);
approve_erc20(
&wnear_erc20,
cross_contract_call::ADDRESS,
Expand Down Expand Up @@ -295,7 +295,7 @@ fn deploy_router() -> AuroraRunner {
router
}

fn deploy_erc20(runner: &mut AuroraRunner, signer: &mut utils::Signer) -> ERC20 {
fn deploy_erc20(runner: &mut AuroraRunner, signer: &utils::Signer) -> ERC20 {
let engine_account = runner.aurora_account_id.clone();
let args = aurora_engine::parameters::DeployErc20TokenArgs {
nep141: "wrap.near".parse().unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ pub fn create_deploy_transaction(contract_bytes: Vec<u8>, nonce: U256) -> Transa
let data = hex::decode(init_code)
.unwrap()
.into_iter()
.chain(contract_bytes.into_iter())
.chain(contract_bytes)
.collect();

TransactionLegacy {
Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/utils/standalone/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ impl StandaloneRunner {
transaction_bytes: &[u8],
transaction_position: u16,
storage: &mut Storage,
env: &mut env::Fixed,
env: &env::Fixed,
cumulative_diff: &mut Diff,
promise_results: &[PromiseResult],
) -> Result<SubmitResult, sync::error::Error> {
Expand Down
2 changes: 1 addition & 1 deletion engine-types/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub mod fee;
pub mod gas;
pub mod wei;

pub use address::*;
pub use address::{make_address, Address};
pub use balance::*;
pub use fee::*;
pub use gas::*;
Expand Down
10 changes: 5 additions & 5 deletions engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ impl<'env, I: IO + Copy, E: Env, M: ModExpAlgorithm> Engine<'env, I, E, M> {
account_info_cache: RefCell::new(FullCache::default()),
contract_code_cache: RefCell::new(FullCache::default()),
contract_storage_cache: RefCell::new(FullCache::default()),
modexp_algorithm: PhantomData::default(),
modexp_algorithm: PhantomData,
}
}

Expand Down Expand Up @@ -591,9 +591,9 @@ impl<'env, I: IO + Copy, E: Env, M: ModExpAlgorithm> Engine<'env, I, E, M> {
let contract = &args.address;
let value = U256::from_big_endian(&args.amount);
// View calls cannot interact with promises
let mut handler = aurora_engine_sdk::promise::Noop;
let handler = aurora_engine_sdk::promise::Noop;
let pause_flags = EnginePrecompilesPauser::from_io(self.io).paused();
let precompiles = self.create_precompiles(pause_flags, &mut handler);
let precompiles = self.create_precompiles(pause_flags, &handler);

let executor_params = StackExecutorParams::new(u64::MAX, precompiles);
self.view(
Expand Down Expand Up @@ -787,7 +787,7 @@ impl<'env, I: IO + Copy, E: Env, M: ModExpAlgorithm> Engine<'env, I, E, M> {
fn create_precompiles<P: PromiseHandler>(
&self,
pause_flags: PrecompileFlags,
handler: &mut P,
handler: &P,
) -> Precompiles<'env, I, E, P::ReadOnly> {
let current_account_id = self.current_account_id.clone();
let random_seed = self.env.random_seed();
Expand Down Expand Up @@ -998,7 +998,7 @@ pub fn refund_on_error<I: IO + Copy, E: Env, P: PromiseHandler>(
let erc20_admin_address = current_address(&current_account_id);
let mut engine: Engine<_, _> =
Engine::new_with_state(state, erc20_admin_address, current_account_id, io, env);
let erc20_address = erc20_address;

let refund_address = args.recipient_address;
let amount = U256::from_big_endian(&args.amount);
let input = setup_refund_on_error_input(amount, refund_address);
Expand Down
3 changes: 3 additions & 0 deletions engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ mod contract {
const CODE_KEY: &[u8; 4] = b"CODE";
const CODE_STAGE_KEY: &[u8; 10] = b"CODE_STAGE";

// TODO: rust-2023-08-24 #[allow(clippy::empty_line_after_doc_comments)]
///
/// ADMINISTRATIVE METHODS
///
Expand Down Expand Up @@ -278,6 +279,7 @@ mod contract {
.sdk_unwrap();
}

// TODO: rust-2023-08-24 #[allow(clippy::empty_line_after_doc_comments)]
///
/// MUTATIVE METHODS
///
Expand Down Expand Up @@ -879,6 +881,7 @@ mod contract {
};
}

// TODO: rust-2023-08-24#[allow(clippy::empty_line_after_doc_comments)]
///
/// Utility methods.
///
Expand Down

0 comments on commit 7f90566

Please sign in to comment.