Skip to content

Commit

Permalink
fix lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
harryliisme3 committed Feb 6, 2023
1 parent 7965b50 commit 1d812ce
Show file tree
Hide file tree
Showing 60 changed files with 263 additions and 305 deletions.
2 changes: 1 addition & 1 deletion src/components/abciapp/src/abci/server/callback/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ pub fn deliver_tx(

resp.code = 1;
resp.log =
format!("deliver convert account tx failed: {:?}", err);
format!("deliver convert account tx failed: {err:?}");
return resp;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/abciapp/src/abci/server/tx_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn forward_txn_with_mode(
)
};

let tendermint_reply = format!("http://{}", url);
let tendermint_reply = format!("http://{url}");
if 2000 > TX_PENDING_CNT.fetch_add(1, Ordering::Relaxed) {
POOL.spawn_ok(async move {
ruc::info_omit!(attohttpc::post(&tendermint_reply)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ impl QueryApi {
});

for (host, port) in addrs.iter() {
hdr = hdr.bind(&format!("{}:{}", host, port)).c(d!())?
hdr = hdr.bind(&format!("{host}:{port}")).c(d!())?
}

hdr.run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl SubmissionApi {
web::get().to(txn_status::<RNG, TF>),
)
})
.bind(&format!("{}:{}", host, port))
.bind(&format!("{host}:{port}"))
.c(d!())?
.run();

Expand Down
6 changes: 3 additions & 3 deletions src/components/abciapp/src/bins/findorad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ fn node_command() -> Result<()> {
ctrlc::set_handler(move || {
//info_omit!(kill(Pid::from_raw(0), Signal::SIGINT));
pnk!(abcid_child.kill().c(d!()));
pnk!(abcid_child.wait().c(d!()).map(|s| println!("{}", s)));
pnk!(abcid_child.wait().c(d!()).map(|s| println!("{s}")));

pnk!(tendermint_child.kill());
pnk!(tendermint_child.wait().c(d!()).map(|s| println!("{}", s)));
pnk!(tendermint_child.wait().c(d!()).map(|s| println!("{s}")));

pnk!(send.send(()));
})
Expand Down Expand Up @@ -163,7 +163,7 @@ fn init_command() -> Result<()> {
fn pack() -> Result<()> {
let bin_path_orig = get_bin_path().c(d!())?;
let bin_name = bin_path_orig.file_name().c(d!())?.to_str().c(d!())?;
let bin_path = format!("/tmp/{}", bin_name);
let bin_path = format!("/tmp/{bin_name}");
fs::copy(bin_path_orig, &bin_path).c(d!())?;

let mut f = OpenOptions::new().append(true).open(bin_path).c(d!())?;
Expand Down
10 changes: 5 additions & 5 deletions src/components/config/src/abci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ impl CheckPointConfig {
return Some(config);
}
Err(error) => {
panic!("failed to create file: {:?}", error)
panic!("failed to create file: {error:?}")
}
};
} else {
panic!("failed to open file: {:?}", error)
panic!("failed to open file: {error:?}")
}
}
};
Expand Down Expand Up @@ -455,7 +455,7 @@ pub mod global_cfg {
.value_of("checkpoint-file")
.map(|v| v.to_owned())
.unwrap_or_else(|| String::from("./checkpoint.toml"));
println!("{}", checkpoint_path);
println!("{checkpoint_path}");

let res = Config {
abci_host: ah,
Expand Down Expand Up @@ -562,7 +562,7 @@ pub mod global_cfg {
.into_iter()
.rev()
.for_each(|h| {
println!(" {}", h);
println!(" {h}");
});
exit(0);
}
Expand All @@ -580,7 +580,7 @@ pub mod global_cfg {
|| m.is_present("snapshot-rollback-to")
|| m.is_present("snapshot-rollback-to-exact")
{
println!("\x1b[31;01m\n{}\x1b[00m", HINTS);
println!("\x1b[31;01m\n{HINTS}\x1b[00m");

let (h, strict) = m
.value_of("snapshot-rollback-to-exact")
Expand Down
12 changes: 6 additions & 6 deletions src/components/contracts/baseapp/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl crate::BaseApp {

let ctx = self.create_query_context(Some(req.height as u64), req.prove);
if let Err(e) = ctx {
return err_resp(format!("Cannot create query context with err: {}!", e));
return err_resp(format!("Cannot create query context with err: {e}!"));
}

match path.remove(0) {
Expand Down Expand Up @@ -151,7 +151,7 @@ impl crate::BaseApp {
Err(e) => {
info!(target: "baseapp", "Transaction check error: {}", e);
resp.code = 1;
resp.log = format!("Transaction check error: {}", e);
resp.log = format!("Transaction check error: {e}");
}
}
};
Expand Down Expand Up @@ -296,7 +296,7 @@ impl crate::BaseApp {
Err(e) => {
error!(target: "baseapp", "Ethereum transaction deliver error: {}", e);
resp.code = 1;
resp.log = format!("Ethereum transaction deliver error: {}", e);
resp.log = format!("Ethereum transaction deliver error: {e}");
resp
}
}
Expand Down Expand Up @@ -334,8 +334,8 @@ impl crate::BaseApp {
.write()
.commit(block_height)
.unwrap_or_else(|e| {
println!("{:?}", e);
panic!("Failed to commit chain state at height: {}", block_height)
println!("{e:?}");
panic!("Failed to commit chain state at height: {block_height}")
});

// Commit module data based on root_hash
Expand All @@ -347,7 +347,7 @@ impl crate::BaseApp {
.write()
.commit(block_height)
.unwrap_or_else(|_| {
panic!("Failed to commit chain db at height: {}", block_height)
panic!("Failed to commit chain db at height: {block_height}")
});

// Reset the deliver state, but keep the ethereum cache
Expand Down
6 changes: 3 additions & 3 deletions src/components/contracts/baseapp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ impl BaseApp {
}

fn validate_height(&self, height: i64) -> Result<()> {
ensure!(height >= 1, format!("invalid height: {}", height));
ensure!(height >= 1, format!("invalid height: {height}"));
let mut expected_height =
self.chain_state.read().height().unwrap_or_default() as i64;
if expected_height == 0 {
Expand All @@ -320,7 +320,7 @@ impl BaseApp {
}
ensure!(
height == expected_height,
format!("invalid height: {}; expected: {}", height, expected_height)
format!("invalid height: {height}; expected: {expected_height}")
);
Ok(())
}
Expand Down Expand Up @@ -386,7 +386,7 @@ impl BaseProvider for BaseApp {
fn account_of(&self, who: &Address, height: Option<u64>) -> Result<SmartAccount> {
let ctx = self.create_query_context(height, false)?;
module_account::App::<Self>::account_of(&ctx, who, height)
.ok_or(eg!(format!("account does not exist: {}", who)))
.ok_or(eg!(format!("account does not exist: {who}")))
}

fn current_block(&self, id: Option<BlockId>) -> Option<Block> {
Expand Down
2 changes: 1 addition & 1 deletion src/components/contracts/baseapp/src/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl ModuleManager {
self.template_module.query_route(ctx, path, req)
} else {
resp.code = 1;
resp.log = format!("Invalid query module route: {}!", module_name);
resp.log = format!("Invalid query module route: {module_name}!");
resp
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/contracts/modules/account/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl<C: Config> AccountAsset<Address> for App<C> {
}

let mut target_account = Self::account_of(ctx, target, None)
.c(d!(format!("account: {} does not exist", target)))?;
.c(d!(format!("account: {target} does not exist")))?;
target_account.balance = target_account
.balance
.checked_sub(balance)
Expand Down
4 changes: 2 additions & 2 deletions src/components/contracts/modules/account/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn setup() -> Context {
.unwrap()
.as_nanos();
let mut path = temp_dir();
path.push(format!("temp-findora-db–{}", time));
path.push(format!("temp-findora-db–{time}"));

let fdb = FinDB::open(path).unwrap();
let chain_state = Arc::new(RwLock::new(ChainState::new(
Expand All @@ -29,7 +29,7 @@ fn setup() -> Context {
)));

let mut rocks_path = temp_dir();
rocks_path.push(format!("temp-rocks-db–{}", time));
rocks_path.push(format!("temp-rocks-db–{time}"));

let rdb = RocksDB::open(rocks_path).unwrap();
let chain_db = Arc::new(RwLock::new(ChainState::new(
Expand Down
4 changes: 2 additions & 2 deletions src/components/contracts/modules/ethereum/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl<C: Config> App<C> {
return Ok(ActionResult {
code: 1,
data: vec![],
log: format!("{}", e),
log: format!("{e}"),
gas_wanted: gas_limit.low_u64(),
gas_used: 0,
events,
Expand Down Expand Up @@ -343,7 +343,7 @@ impl<C: Config> App<C> {
let message_len = data[36..68].iter().sum::<u8>();
let body: &[u8] = &data[68..68 + message_len as usize];
if let Ok(reason) = std::str::from_utf8(body) {
message = format!("{} {}", message, reason);
message = format!("{message} {reason}");
}
}
(3, message)
Expand Down
3 changes: 1 addition & 2 deletions src/components/contracts/modules/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ impl<C: Config> ValidateUnsigned for App<C> {
let total_payment = transaction.value.saturating_add(fee);
if balance < total_payment {
return Err(eg!(format!(
"InsufficientBalance, origin: {:?}, actual balance {}, but expected payment {}",
origin, balance, total_payment
"InsufficientBalance, origin: {origin:?}, actual balance {balance}, but expected payment {total_payment}"
)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn setup() -> Context {
.unwrap()
.as_nanos();
let mut path = temp_dir();
path.push(format!("temp-findora-db–{}", time));
path.push(format!("temp-findora-db–{time}"));

let fdb = FinDB::open(path).unwrap();
let chain_state = Arc::new(RwLock::new(ChainState::new(
Expand All @@ -28,7 +28,7 @@ fn setup() -> Context {
)));

let mut rocks_path = temp_dir();
rocks_path.push(format!("temp-rocks-db–{}", time));
rocks_path.push(format!("temp-rocks-db–{time}"));

let rdb = RocksDB::open(rocks_path).unwrap();
let chain_db = Arc::new(RwLock::new(ChainState::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn test_abci_deliver_tx() {
resp.code, resp.log
);

println!("transfer resp: {:?}", resp);
println!("transfer resp: {resp:?}");

// initial balance = 100_0000_0000_0000_0000_u64, gas limit = 21000, transfer balance = 10
assert_eq!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ impl<C: Config> FRC20<C> {
);

C::AccountAsset::approve(state, &caller, &spender_id, amount)
.map_err(|e| error(format!("{:?}", e)))?;
.map_err(|e| error(format!("{e:?}")))?;

Ok(PrecompileOutput {
exit_status: ExitSucceed::Returned,
Expand Down Expand Up @@ -349,7 +349,7 @@ impl<C: Config> FRC20<C> {
);

C::AccountAsset::transfer(state, &caller, &recipient_id, amount)
.map_err(|e| error(format!("{:?}", e)))?;
.map_err(|e| error(format!("{e:?}")))?;

Ok(PrecompileOutput {
exit_status: ExitSucceed::Returned,
Expand Down Expand Up @@ -405,15 +405,15 @@ impl<C: Config> FRC20<C> {
);

C::AccountAsset::transfer(state, &from_id, &recipient_id, amount)
.map_err(|e| error(format!("{:?}", e)))?;
.map_err(|e| error(format!("{e:?}")))?;

C::AccountAsset::approve(
state,
&from_id,
&caller,
allowance.saturating_sub(amount),
)
.map_err(|e| error(format!("{:?}", e)))?;
.map_err(|e| error(format!("{e:?}")))?;

Ok(PrecompileOutput {
exit_status: ExitSucceed::Returned,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ mod tests {
Ok(())
}
Err(e) => {
panic!("Test not expected to fail: {:?}", e);
panic!("Test not expected to fail: {e:?}");
}
}
}
Expand All @@ -110,7 +110,7 @@ mod tests {
Ok(())
}
Err(e) => {
panic!("Test not expected to fail: {:?}", e);
panic!("Test not expected to fail: {e:?}");
}
}
}
Expand All @@ -131,7 +131,7 @@ mod tests {
Ok(())
}
Err(e) => {
panic!("Test not expected to fail: {:?}", e);
panic!("Test not expected to fail: {e:?}");
}
}
}
Expand All @@ -154,7 +154,7 @@ mod tests {
Ok(())
}
Err(e) => {
panic!("Test not expected to fail: {:?}", e);
panic!("Test not expected to fail: {e:?}");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ fn write_address_nested_array() {
writer_output
.chunks_exact(32)
.map(H256::from_slice)
.for_each(|hash| println!("{:?}", hash));
.for_each(|hash| println!("{hash:?}"));

// We can read this "manualy" using simpler functions since arrays are 32-byte aligned.
let mut reader = EvmDataReader::new(&writer_output);
Expand Down
8 changes: 4 additions & 4 deletions src/components/contracts/modules/evm/src/precompile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ pub trait PrecompileSet {
/// Otherwise, calculate the amount of gas needed with given `input` and
/// `target_gas`. Return `Some(Ok(status, output, gas_used))` if the execution
/// is successful. Otherwise return `Some(Err(_))`.
fn execute<'context, 'vicinity, 'config, T>(
fn execute<T>(
address: H160,
input: &[u8],
target_gas: Option<u64>,
context: &Context,
state: &mut FindoraStackState<'context, 'vicinity, 'config, T>,
state: &mut FindoraStackState<'_, '_, '_, T>,
is_static: bool,
) -> Option<PrecompileResult>;
}
Expand Down Expand Up @@ -53,12 +53,12 @@ pub trait PrecompileId {
impl PrecompileSet for Tuple {
for_tuples!( where #( Tuple: Precompile + PrecompileId )* );

fn execute<'context, 'vicinity, 'config, T>(
fn execute<T>(
address: H160,
input: &[u8],
target_gas: Option<u64>,
context: &Context,
state: &mut FindoraStackState<'context, 'vicinity, 'config, T>,
state: &mut FindoraStackState<'_, '_, '_, T>,
_is_static: bool,
) -> Option<PrecompileResult> {
for_tuples!( #(
Expand Down
Loading

0 comments on commit 1d812ce

Please sign in to comment.