Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
3778: chroe: Upgrade deps r=driftluo a=driftluo

### What problem does this PR solve?

Issue Number: close nervosnetwork#3708 

upgrade clap and tentacle

### Check List 

Tests 

- Unit test
- Integration test

### Release note

```release-note
None: Exclude this PR from the release note.
```



Co-authored-by: driftluo <[email protected]>
  • Loading branch information
bors[bot] and driftluo authored Jan 6, 2023
2 parents 2e96570 + e74887f commit b57e813
Show file tree
Hide file tree
Showing 51 changed files with 448 additions and 278 deletions.
203 changes: 166 additions & 37 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn rerun_if_changed(path_str: &str) -> bool {
#[allow(clippy::manual_strip)]
fn main() {
let files_stdout = std::process::Command::new("git")
.args(&["ls-tree", "-r", "--name-only", "HEAD"])
.args(["ls-tree", "-r", "--name-only", "HEAD"])
.output()
.ok()
.and_then(|r| String::from_utf8(r.stdout).ok());
Expand All @@ -48,7 +48,7 @@ fn main() {
println!("cargo:rerun-if-changed=build.rs");

let git_head = std::process::Command::new("git")
.args(&["rev-parse", "--git-dir"])
.args(["rev-parse", "--git-dir"])
.output()
.ok()
.and_then(|r| String::from_utf8(r.stdout).ok())
Expand Down
2 changes: 1 addition & 1 deletion ckb-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ homepage = "https://github.com/nervosnetwork/ckb"
repository = "https://github.com/nervosnetwork/ckb"

[dependencies]
clap = { version = "=3.2.21" }
clap = { version = "4" }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
serde_plain = "0.3.0"
Expand Down
3 changes: 1 addition & 2 deletions ckb-bin/src/subcommand/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ pub fn init(args: InitArgs) -> Result<(), ExitCode> {
args.block_assembler_code_hash = Some(in_block_assembler_code_hash.trim().to_string());

args.block_assembler_args = in_args
.trim()
.split_whitespace()
.map(|s| s.to_string())
.collect::<Vec<String>>();
Expand Down Expand Up @@ -180,7 +179,7 @@ pub fn init(args: InitArgs) -> Result<(), ExitCode> {
let mut encoded_content = String::new();
io::stdin().read_to_string(&mut encoded_content)?;
let spec_content = base64::decode_config(
&encoded_content.trim(),
encoded_content.trim(),
base64::STANDARD.decode_allow_trailing_bits(true),
)
.map_err(|err| {
Expand Down
4 changes: 2 additions & 2 deletions ckb-bin/src/subcommand/list_hashes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ impl TryFrom<ChainSpec> for SpecHashes {
pub fn list_hashes(root_dir: PathBuf, matches: &ArgMatches) -> Result<(), ExitCode> {
let mut specs = Vec::new();

let output_format = matches.value_of(cli::ARG_FORMAT).unwrap_or("toml");
let output_format = matches.get_one::<String>(cli::ARG_FORMAT).unwrap().as_str();

if matches.is_present(cli::ARG_BUNDLED) {
if matches.contains_id(cli::ARG_BUNDLED) {
if output_format == "toml" {
println!("# Generated by: ckb list-hashes -b\n");
}
Expand Down
4 changes: 2 additions & 2 deletions db/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ impl RocksDB {
/// so as to avoid unnecessary memory copy.
pub fn get_pinned(&self, col: Col, key: &[u8]) -> Result<Option<DBPinnableSlice>> {
let cf = cf_handle(&self.inner, col)?;
self.inner.get_pinned_cf(cf, &key).map_err(internal_error)
self.inner.get_pinned_cf(cf, key).map_err(internal_error)
}

/// Return the value associated with a key using RocksDB's PinnableSlice from the default column
/// so as to avoid unnecessary memory copy.
pub fn get_pinned_default(&self, key: &[u8]) -> Result<Option<DBPinnableSlice>> {
self.inner.get_pinned(&key).map_err(internal_error)
self.inner.get_pinned(key).map_err(internal_error)
}

/// Insert a value into the database under the given key.
Expand Down
2 changes: 1 addition & 1 deletion db/src/db_with_ttl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl DBWithTTL {
.inner
.cf_handle(col)
.ok_or_else(|| internal_error(format!("column {} not found", col)))?;
self.inner.get_pinned_cf(cf, &key).map_err(internal_error)
self.inner.get_pinned_cf(cf, key).map_err(internal_error)
}

/// Insert a value into the database under the given key.
Expand Down
4 changes: 2 additions & 2 deletions db/src/read_only_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl ReadOnlyDB {
/// Return the value associated with a key using RocksDB's PinnableSlice from the default column
/// so as to avoid unnecessary memory copy.
pub fn get_pinned_default(&self, key: &[u8]) -> Result<Option<DBPinnableSlice>> {
self.inner.get_pinned(&key).map_err(internal_error)
self.inner.get_pinned(key).map_err(internal_error)
}

/// Return the value associated with a key using RocksDB's PinnableSlice from the given column
Expand All @@ -70,6 +70,6 @@ impl ReadOnlyDB {
.inner
.cf_handle(col)
.ok_or_else(|| internal_error(format!("column {} not found", col)))?;
self.inner.get_pinned_cf(cf, &key).map_err(internal_error)
self.inner.get_pinned_cf(cf, key).map_err(internal_error)
}
}
2 changes: 1 addition & 1 deletion db/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl RocksDBSnapshot {
/// so as to avoid unnecessary memory copy.
pub fn get_pinned(&self, col: Col, key: &[u8]) -> Result<Option<DBPinnableSlice>> {
let cf = cf_handle(&self.db, col)?;
self.get_pinned_cf_full(Some(cf), &key, None)
self.get_pinned_cf_full(Some(cf), key, None)
.map_err(internal_error)
}
}
Expand Down
4 changes: 2 additions & 2 deletions db/src/tests/db_with_ttl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn test_open_db_with_ttl() {
let mut db = db.unwrap();

for i in 0..1000u64 {
db.put("1", &i.to_le_bytes(), &[2]).unwrap();
db.put("1", i.to_le_bytes(), [2]).unwrap();
assert_eq!(
db.get_pinned("1", &i.to_le_bytes())
.unwrap()
Expand All @@ -33,6 +33,6 @@ fn test_open_db_with_ttl() {

db.create_cf_with_ttl("1", 50).unwrap();
assert!(db.get_pinned("1", &[1]).unwrap().is_none());
db.put("1", &[1], &[3]).unwrap();
db.put("1", [1], [3]).unwrap();
assert_eq!(db.get_pinned("1", &[1]).unwrap().unwrap().as_ref(), &[3]);
}
2 changes: 1 addition & 1 deletion miner/src/worker/eaglesong_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl EaglesongSimple {
let mut output_tmp = [0u8; 32];
eaglesong(&input, &mut output_tmp);
match self.extra_hash_function {
Some(ExtraHashFunction::Blake2b) => blake2b_256(&output_tmp),
Some(ExtraHashFunction::Blake2b) => blake2b_256(output_tmp),
None => output_tmp,
}
};
Expand Down
2 changes: 1 addition & 1 deletion network/src/protocols/discovery/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl DiscoveryMessage {
.build()
}
DiscoveryMessage::Nodes(Nodes { announce, items }) => {
let bool_ = if announce { 1u8 } else { 0 };
let bool_ = u8::from(announce);
let announce = packed::Bool::new_builder().set([bool_.into()]).build();
let mut item_vec = Vec::with_capacity(items.len());
for item in items {
Expand Down
4 changes: 2 additions & 2 deletions network/src/tests/peer_store_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ fn test_peer_store_persistent() {

// dump and load
let dir = tempfile::tempdir().unwrap();
peer_store.dump_to_dir(&dir.path()).unwrap();
let peer_store2 = PeerStore::load_from_dir_or_default(&dir.path());
peer_store.dump_to_dir(dir.path()).unwrap();
let peer_store2 = PeerStore::load_from_dir_or_default(dir.path());

// check addr manager
let addr_manager2 = peer_store2.addr_manager();
Expand Down
2 changes: 1 addition & 1 deletion pow/src/eaglesong_blake2b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl PowEngine for EaglesongBlake2bPowEngine {
let output = {
let mut output_tmp = [0u8; 32];
eaglesong(&input, &mut output_tmp);
blake2b_256(&output_tmp)
blake2b_256(output_tmp)
};

let (block_target, overflow) = compact_to_target(header.raw().compact_target().unpack());
Expand Down
2 changes: 1 addition & 1 deletion pow/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use ckb_types::prelude::*;

#[test]
fn test_pow_message() {
let zero_hash = blake2b_256(&[]).pack();
let zero_hash = blake2b_256([]).pack();
let nonce = u128::max_value();
let message = pow_message(&zero_hash, nonce);
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::fmt::{Debug, Display};
///
/// Unless otherwise noted, all the errors return optional detailed information as `string` in the error
/// object `data` field.
#[derive(Debug, PartialEq, Clone, Copy)]
#[derive(Debug, PartialEq, Clone, Copy, Eq)]
pub enum RPCError {
/// (-1): CKB internal errors are considered to never happen or only happen when the system
/// resources are exhausted.
Expand Down
4 changes: 2 additions & 2 deletions script/src/syscalls/tests/vm_latest/syscalls_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ fn _test_load_header(
machine.set_register(A4, source); //source: 4 header
machine.set_register(A7, LOAD_HEADER_SYSCALL_NUMBER); // syscall number

let data_hash = blake2b_256(&data).pack();
let data_hash = blake2b_256(data).pack();
let header = HeaderBuilder::default()
.transactions_root(data_hash)
.build();
Expand Down Expand Up @@ -768,7 +768,7 @@ fn _test_load_header_by_field(data: &[u8], field: HeaderField) -> Result<(), Tes
machine.set_register(A5, field as u64);
machine.set_register(A7, LOAD_HEADER_BY_FIELD_SYSCALL_NUMBER); // syscall number

let data_hash: H256 = blake2b_256(&data).into();
let data_hash: H256 = blake2b_256(data).into();
let epoch = EpochNumberWithFraction::new(1, 40, 1000);
let header = HeaderBuilder::default()
.transactions_root(data_hash.pack())
Expand Down
2 changes: 1 addition & 1 deletion script/src/type_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<'a> TypeIdSystemScript<'a> {
let first_output_index: u64 = self
.script_group
.output_indices
.get(0)
.first()
.map(|output_index| *output_index as u64)
.ok_or_else(|| self.validation_failure(ERROR_ARGS))?;

Expand Down
4 changes: 3 additions & 1 deletion script/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,16 @@ impl Binaries {
}
}

type DebugPrinter = Box<dyn Fn(&Byte32, &str)>;

/// This struct leverages CKB VM to verify transaction inputs.
///
/// FlatBufferBuilder owned `Vec<u8>` that grows as needed, in the
/// future, we might refactor this to share buffer to achieve zero-copy
pub struct TransactionScriptsVerifier<'a, DL> {
data_loader: &'a DL,

debug_printer: Box<dyn Fn(&Byte32, &str)>,
debug_printer: DebugPrinter,

outputs: Vec<CellMeta>,
rtx: &'a ResolvedTransaction,
Expand Down
4 changes: 2 additions & 2 deletions script/src/verify/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ pub(super) fn random_2_in_2_out_rtx() -> ResolvedTransaction {
let mut generator = Generator::non_crypto_safe_prng(42);
let privkey = generator.gen_privkey();
let pubkey_data = privkey.pubkey().expect("Get pubkey failed").serialize();
let lock_arg = Bytes::from((&blake2b_256(&pubkey_data)[0..20]).to_owned());
let lock_arg = Bytes::from((blake2b_256(&pubkey_data)[0..20]).to_owned());
let privkey2 = generator.gen_privkey();
let pubkey_data2 = privkey2.pubkey().expect("Get pubkey failed").serialize();
let lock_arg2 = Bytes::from((&blake2b_256(&pubkey_data2)[0..20]).to_owned());
let lock_arg2 = Bytes::from((blake2b_256(&pubkey_data2)[0..20]).to_owned());

let lock = Script::new_builder()
.args(lock_arg.pack())
Expand Down
2 changes: 1 addition & 1 deletion spec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ impl SystemCell {

fn secp_lock_arg(privkey: &Privkey) -> Bytes {
let pubkey_data = privkey.pubkey().expect("Get pubkey failed").serialize();
Bytes::from((&blake2b_256(&pubkey_data)[0..20]).to_owned())
Bytes::from((blake2b_256(&pubkey_data)[0..20]).to_owned())
}

/// Shortcut for build genesis type_id script from specified output_index
Expand Down
2 changes: 1 addition & 1 deletion sync/src/net_time_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl NetTimeChecker {
Some(offset) => offset,
None => return Ok(()),
};
if network_offset.abs() as u64 > self.tolerant_offset {
if network_offset.unsigned_abs() > self.tolerant_offset {
return Err(network_offset);
}
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ fn print_panicked_logs(node_log_paths: &[PathBuf]) {
from_ln + print_lns,
node_log.display(),
);
BufReader::new(File::open(&node_log).expect("failed to read node's log"))
BufReader::new(File::open(node_log).expect("failed to read node's log"))
.lines()
.skip(from_ln)
.take(print_lns)
Expand Down
12 changes: 6 additions & 6 deletions test/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,9 @@ impl Node {
pub fn start(&mut self) {
let mut child_process = Command::new(binary())
.env("RUST_BACKTRACE", "full")
.args(&[
.args([
"-C",
&self.working_dir().to_string_lossy().to_string(),
&self.working_dir().to_string_lossy(),
"run",
"--ba-advanced",
])
Expand Down Expand Up @@ -655,10 +655,10 @@ impl Node {

pub fn export(&self, target: String) {
Command::new(binary())
.args(&[
.args([
"export",
"-C",
&self.working_dir().to_string_lossy().to_string(),
&self.working_dir().to_string_lossy(),
&target,
])
.stdin(Stdio::null())
Expand All @@ -670,10 +670,10 @@ impl Node {

pub fn import(&self, target: String) {
Command::new(binary())
.args(&[
.args([
"import",
"-C",
&self.working_dir().to_string_lossy().to_string(),
&self.working_dir().to_string_lossy(),
&target,
])
.stdin(Stdio::null())
Expand Down
6 changes: 3 additions & 3 deletions test/src/specs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ impl Default for Setup {
#[macro_export]
macro_rules! setup {
($($setup:tt)*) => {
fn setup(&self) -> $crate::Setup{ crate::setup_internal!($($setup)*) }
fn setup(&self) -> $crate::Setup{ $crate::setup_internal!($($setup)*) }
};
}

#[macro_export]
macro_rules! setup_internal {
($field:ident: $value:expr,) => {
crate::setup_internal!($field: $value)
$crate::setup_internal!($field: $value)
};
($field:ident: $value:expr) => {
$crate::Setup{ $field: $value, ..Default::default() }
};
($field:ident: $value:expr, $($rest:tt)*) => {
$crate::Setup{ $field: $value, ..crate::setup_internal!($($rest)*) }
$crate::Setup{ $field: $value, ..$crate::setup_internal!($($rest)*) }
};
}
2 changes: 1 addition & 1 deletion test/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::thread::{self, JoinHandle};
use std::time::Instant;

/// Commands
#[derive(PartialEq)]
#[derive(PartialEq, Eq)]
pub enum Command {
Shutdown,
}
Expand Down
6 changes: 3 additions & 3 deletions tx-pool/src/component/tests/recent_reject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ fn test_basic() {
let mut recent_reject = RecentReject::build(tmp_dir.path(), shard_num, limit, ttl).unwrap();

for i in 0..80u64 {
let key = Byte32::new(blake2b_256(&i.to_le_bytes()));
let key = Byte32::new(blake2b_256(i.to_le_bytes()));
recent_reject
.put(&key, Reject::Malformed(i.to_string()))
.unwrap();
}

for i in 0..80u64 {
let key = Byte32::new(blake2b_256(&i.to_le_bytes()));
let key = Byte32::new(blake2b_256(i.to_le_bytes()));
let reject: ckb_jsonrpc_types::PoolTransactionReject =
Reject::Malformed(i.to_string()).into();
assert_eq!(
Expand All @@ -30,7 +30,7 @@ fn test_basic() {
}

for i in 0..80u64 {
let key = Byte32::new(blake2b_256(&i.to_le_bytes()));
let key = Byte32::new(blake2b_256(i.to_le_bytes()));
recent_reject
.put(&key, Reject::Malformed(i.to_string()))
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion util/app-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ homepage = "https://github.com/nervosnetwork/ckb"
repository = "https://github.com/nervosnetwork/ckb"

[dependencies]
clap = { version = "=3.2.21" }
clap = { version = "4", features = ["string"] }
serde = { version = "1.0", features = ["derive"] }
serde_plain = "0.3.0"
serde_json = "1.0"
Expand Down
Loading

0 comments on commit b57e813

Please sign in to comment.