Skip to content

Commit

Permalink
Merge pull request #250 from TheWaWaR/upgrade-ckb-to-v0.30
Browse files Browse the repository at this point in the history
chore: Upgrade ckb to v0.30
  • Loading branch information
doitian authored Mar 19, 2020
2 parents a47ef29 + 91feaa5 commit 7534073
Show file tree
Hide file tree
Showing 27 changed files with 1,578 additions and 1,646 deletions.
3,032 changes: 1,489 additions & 1,543 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
[package]
name = "ckb-cli"
version = "0.27.1"
version = "0.30.0"
license = "MIT"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"

[dependencies]
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1", features = ["secp"] }
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-util = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1", features = ["secp"] }
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }
ckb-util = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }
ckb-sdk = { path = "ckb-sdk" }
ckb-index = { path = "ckb-index" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-dao-utils = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }
ckb-dao-utils = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }

jsonrpc-client-core = "0.5.0"
jsonrpc-core = "10.1"
jsonrpc-derive = "10.1"
jsonrpc-http-server = "10.1"
jsonrpc-server-utils = "10.1"
secp256k1 = {version = "0.15.0" }
faster-hex = "0.3"
faster-hex = "0.4"
env_logger = "0.6"
crossbeam-channel = "0.3"
clap = "2.33.0"
Expand Down Expand Up @@ -55,7 +55,7 @@ tui = "0.6.0"
termion = "1.5"

[build-dependencies]
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }

[workspace]
members = ["ckb-sdk", "ckb-index", "ckb-sdk-types"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ci: fmt clippy test security-audit
git diff --exit-code Cargo.lock

integration:
bash devtools/ci/integration.sh v0.27.1-rc1
bash devtools/ci/integration.sh v0.30.0-rc1

prod: ## Build binary with release profile.
cargo build --release
Expand Down
4 changes: 2 additions & 2 deletions ckb-index/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ckb-index"
version = "0.27.1"
version = "0.30.0"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -11,7 +11,7 @@ serde_derive = "1.0"
bincode = "1.1.4"
log = "0.4.6"
failure = "0.1.5"
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }
ckb-sdk = { path = "../ckb-sdk" }

[dependencies.rocksdb]
Expand Down
2 changes: 1 addition & 1 deletion ckb-index/src/index/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ impl Key {
Key::BlockDelta(number)
}
KeyType::LiveCellMap => {
let out_point = OutPoint::new_unchecked(args_bytes.into());
let out_point = OutPoint::new_unchecked(args_bytes.to_vec().into());
Key::LiveCellMap(out_point)
}
KeyType::LiveCellIndex => {
Expand Down
2 changes: 1 addition & 1 deletion ckb-index/src/index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl<'a> IndexDatabase<'a> {
log::debug!("Block: {} => {:x}", header.number(), block_hash);

// TODO: should forbid query when Init
self.last_header = Some(header.clone());
self.last_header = Some(header);
let blocks = if self.last_number().unwrap() < self.tip_header.number().saturating_sub(256) {
self.init_block_buf.push(block);
if self.init_block_buf.len() >= 200 {
Expand Down
12 changes: 6 additions & 6 deletions ckb-index/src/index/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl BlockDeltaInfo {
reader: &'r T,
clear_old: bool,
) -> BlockDeltaInfo {
let block_header: HeaderView = block.header().clone();
let block_header: HeaderView = block.header();
let block_number = block_header.number();
let timestamp = block_header.timestamp();

Expand Down Expand Up @@ -200,7 +200,7 @@ impl BlockDeltaInfo {
cell_removed += inputs.len();
cell_added += outputs.len();
RichTxInfo {
tx_hash: tx.hash().clone().unpack(),
tx_hash: tx.hash().unpack(),
tx_index: tx_index as u32,
block_number,
block_timestamp: timestamp,
Expand All @@ -225,7 +225,7 @@ impl BlockDeltaInfo {

let capacity_delta = (new_chain_capacity as i128 - old_chain_capacity as i128) as i64;
let header_info = HeaderInfo {
header: block_header.data().as_slice().into(),
header: block_header.data().as_slice().to_vec().into(),
txs_size: block.transactions().len() as u32,
uncles_size: block.uncle_hashes().len() as u32,
proposals_size: block.union_proposal_ids().len() as u32,
Expand Down Expand Up @@ -555,7 +555,7 @@ impl LockInfo {
}

fn set_script(&mut self, script: Script) {
self.script_opt = Some(script.as_slice().into());
self.script_opt = Some(script.as_slice().to_vec().into());
}

fn add_input(&mut self, input_capacity: u64) {
Expand Down Expand Up @@ -691,12 +691,12 @@ impl RichTxInfo {
inputs: self
.inputs
.iter()
.map(|info| info.out_point().as_slice().into())
.map(|info| info.out_point().as_slice().to_vec().into())
.collect::<Vec<_>>(),
outputs: self
.outputs
.iter()
.map(|info| info.out_point().as_slice().into())
.map(|info| info.out_point().as_slice().to_vec().into())
.collect::<Vec<_>>(),
}
}
Expand Down
14 changes: 7 additions & 7 deletions ckb-sdk-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ckb-sdk-types"
version = "0.27.1"
version = "0.30.0"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -9,14 +9,14 @@ license = "MIT"
serde = { version = "1.0", features = ["rc"] }
serde_derive = "1.0"

ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1", default-features = false }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-error = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1", default-features = false }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }
ckb-error = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }

[dev-dependencies]
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1", features = ["secp"] }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1", features = ["secp"] }

[features]
default = ["ckb-script/default"]
Expand Down
16 changes: 8 additions & 8 deletions ckb-sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ckb-sdk"
version = "0.27.1"
version = "0.30.0"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -14,7 +14,7 @@ log = "0.4.6"
jsonrpc-client-core = "0.5.0"
jsonrpc-client-http = "0.5.0"
secp256k1 = "0.15.0"
faster-hex = "0.3"
faster-hex = "0.4"
fnv = "1.0.3"
aes-ctr = "0.3.0"
scrypt = "0.2.0"
Expand All @@ -27,10 +27,10 @@ chrono = "0.4.6"
failure = "0.1.5"
lazy_static = "1.4.0"

ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.27.1-rc1", features = ["secp"] }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.30.0-rc1", features = ["secp"] }
ckb-sdk-types = { path = "../ckb-sdk-types" }
4 changes: 2 additions & 2 deletions ckb-sdk/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl<'a> MockTransactionHelper<'a> {
let mut message = [0u8; 32];
blake2b.finalize(&mut message);
let message = H256::from(message);
let sig = signer(&lock_arg, &message).map(|data| Bytes::from(data.as_ref()))?;
let sig = signer(&lock_arg, &message).map(|data| Bytes::from(data.to_vec()))?;
witnesses[idxs[0]] = WitnessArgs::new_builder()
.lock(Some(sig).pack())
.build()
Expand Down Expand Up @@ -356,7 +356,7 @@ mod test {
let lock_script = Script::new_builder()
.code_hash(genesis_info.sighash_type_hash().clone())
.hash_type(ScriptHashType::Type.into())
.args(Bytes::from(lock_arg.as_bytes()).pack())
.args(Bytes::from(lock_arg.as_bytes().to_vec()).pack())
.build();

let mut mock_tx = MockTransaction::default();
Expand Down
26 changes: 13 additions & 13 deletions ckb-sdk/src/tx_helper.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ckb_hash::{blake2b_256, new_blake2b};
use ckb_types::{
bytes::Bytes,
bytes::{Bytes, BytesMut},
core::{ScriptHashType, TransactionBuilder, TransactionView},
h256,
packed::{self, Byte32, CellDep, CellInput, CellOutput, OutPoint, Script, WitnessArgs},
Expand Down Expand Up @@ -141,16 +141,16 @@ impl TxHelper {
if lock_arg.len() != 20 && lock_arg.len() != 28 {
return Err(format!(
"Invalid lock_arg(0x{}) length({}) with signature(0x{})",
hex_string(lock_arg.as_ref()).unwrap(),
hex_string(lock_arg.as_ref()),
lock_arg.len(),
hex_string(signature.as_ref()).unwrap(),
hex_string(signature.as_ref()),
));
}
if signature.len() != SECP_SIGNATURE_SIZE {
return Err(format!(
"Invalid signature length({}) for lock_arg(0x{})",
signature.len(),
hex_string(lock_arg.as_ref()).unwrap(),
hex_string(lock_arg.as_ref()),
));
}

Expand Down Expand Up @@ -277,24 +277,24 @@ impl TxHelper {
let hash160 = H160::from_slice(&lock_arg[..20]).unwrap();
let multisig_config = self.multisig_configs.get(&hash160).unwrap();
let threshold = multisig_config.threshold() as usize;
let mut data = multisig_config.to_witness_data();
let mut data = BytesMut::from(&multisig_config.to_witness_data()[..]);
if signatures.len() != threshold {
return Err(format!(
"Invalid multisig signature length for lock_arg: 0x{}, got: {}, expected: {}",
hex_string(&lock_arg).unwrap(),
hex_string(&lock_arg),
signatures.len(),
threshold,
));
}
for signature in signatures {
data.extend_from_slice(signature.as_ref());
}
data
data.freeze()
} else {
if signatures.len() != 1 {
return Err(format!(
"Invalid secp signature length for lock_arg: 0x{}, got: {}, expected: 1",
hex_string(&lock_arg).unwrap(),
hex_string(&lock_arg),
signatures.len(),
));
}
Expand Down Expand Up @@ -442,9 +442,9 @@ impl MultisigConfig {
let hash160 = self.hash160();
if let Some(absolute_epoch_number) = since_absolute_epoch {
let since_value = Since::new_absolute_epoch(absolute_epoch_number).value();
let mut args = Bytes::from(hash160.as_bytes());
let mut args = BytesMut::from(hash160.as_bytes());
args.extend_from_slice(&since_value.to_le_bytes()[..]);
AddressPayload::new_full_type(MULTISIG_TYPE_HASH.pack(), args)
AddressPayload::new_full_type(MULTISIG_TYPE_HASH.pack(), args.freeze())
} else {
AddressPayload::new_short(CodeHashIndex::Multisig, hash160)
}
Expand Down Expand Up @@ -503,9 +503,9 @@ pub fn build_signature<S: FnMut(&H256) -> Result<[u8; SECP_SIGNATURE_SIZE], Stri
let init_witness = if let Some(multisig_config) = multisig_config_opt {
let lock_without_sig = {
let sig_len = (multisig_config.threshold() as usize) * SECP_SIGNATURE_SIZE;
let mut data = multisig_config.to_witness_data();
let mut data = BytesMut::from(&multisig_config.to_witness_data()[..]);
data.extend_from_slice(vec![0u8; sig_len].as_slice());
data
data.freeze()
};
init_witness
.as_builder()
Expand All @@ -530,5 +530,5 @@ pub fn build_signature<S: FnMut(&H256) -> Result<[u8; SECP_SIGNATURE_SIZE], Stri
let mut message = [0u8; 32];
blake2b.finalize(&mut message);
let message = H256::from(message);
signer(&message).map(|data| Bytes::from(&data[..]))
signer(&message).map(|data| Bytes::from(data.to_vec()))
}
4 changes: 2 additions & 2 deletions ckb-sdk/src/types/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl AddressPayload {

pub fn args(&self) -> Bytes {
match self {
AddressPayload::Short { hash, .. } => Bytes::from(hash.as_bytes()),
AddressPayload::Short { hash, .. } => Bytes::from(hash.as_bytes().to_vec()),
AddressPayload::Full { args, .. } => args.clone(),
}
}
Expand Down Expand Up @@ -284,7 +284,7 @@ impl FromStr for Address {
ScriptHashType::Type
};
let code_hash = Byte32::from_slice(&data[1..33]).unwrap();
let args = Bytes::from(&data[33..]);
let args = Bytes::from(data[33..].to_vec());
let payload = AddressPayload::Full {
hash_type,
code_hash,
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.38.0
1.41.0
7 changes: 1 addition & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,7 @@ fn main() -> Result<(), io::Error> {
}
let result = match matches.subcommand() {
#[cfg(unix)]
("tui", _) => TuiSubCommand::new(
api_uri.to_string(),
index_dir.clone(),
index_controller.clone(),
)
.start(),
("tui", _) => TuiSubCommand::new(api_uri, index_dir, index_controller.clone()).start(),
("rpc", Some(sub_matches)) => RpcSubCommand::new(&mut rpc_client, &mut raw_rpc_client)
.process(&sub_matches, output_format, color, debug),
("account", Some(sub_matches)) => get_key_store(&ckb_cli_dir).and_then(|mut key_store| {
Expand Down
10 changes: 5 additions & 5 deletions src/subcommands/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl<'a> CliSubCommand for AccountSubCommand<'a> {
"lock_hash": format!("{:#x}", lock_hash),
"address": {
"mainnet": Address::new(NetworkType::Mainnet, address_payload.clone()).to_string(),
"testnet": Address::new(NetworkType::Testnet, address_payload.clone()).to_string(),
"testnet": Address::new(NetworkType::Testnet, address_payload).to_string(),
},
})
})
Expand All @@ -192,7 +192,7 @@ impl<'a> CliSubCommand for AccountSubCommand<'a> {
"lock_hash": format!("{:#x}", lock_hash),
"address": {
"mainnet": Address::new(NetworkType::Mainnet, address_payload.clone()).to_string(),
"testnet": Address::new(NetworkType::Testnet, address_payload.clone()).to_string(),
"testnet": Address::new(NetworkType::Testnet, address_payload).to_string(),
},
});
Ok(resp.render(format, color))
Expand All @@ -218,7 +218,7 @@ impl<'a> CliSubCommand for AccountSubCommand<'a> {
"lock_arg": format!("{:x}", lock_arg),
"address": {
"mainnet": Address::new(NetworkType::Mainnet, address_payload.clone()).to_string(),
"testnet": Address::new(NetworkType::Testnet, address_payload.clone()).to_string(),
"testnet": Address::new(NetworkType::Testnet, address_payload).to_string(),
},
});
Ok(resp.render(format, color))
Expand All @@ -240,7 +240,7 @@ impl<'a> CliSubCommand for AccountSubCommand<'a> {
"lock_arg": format!("{:x}", lock_arg),
"address": {
"mainnet": Address::new(NetworkType::Mainnet, address_payload.clone()).to_string(),
"testnet": Address::new(NetworkType::Testnet, address_payload.clone()).to_string(),
"testnet": Address::new(NetworkType::Testnet, address_payload).to_string(),
},
});
Ok(resp.render(format, color))
Expand Down Expand Up @@ -354,7 +354,7 @@ impl<'a> CliSubCommand for AccountSubCommand<'a> {
"lock_arg": format!("{:#x}", H160::from_slice(address_payload.args().as_ref()).unwrap()),
"address": {
"mainnet": Address::new(NetworkType::Mainnet, address_payload.clone()).to_string(),
"testnet": Address::new(NetworkType::Testnet, address_payload.clone()).to_string(),
"testnet": Address::new(NetworkType::Testnet, address_payload).to_string(),
},
});
Ok(resp.render(format, color))
Expand Down
Loading

0 comments on commit 7534073

Please sign in to comment.