Skip to content

Commit

Permalink
Merge pull request #415 from TheWaWaR/update-ckb-to-v0.100
Browse files Browse the repository at this point in the history
chore: Update ckb to v0.100
  • Loading branch information
TheWaWaR authored Aug 4, 2021
2 parents cf8ff98 + 9c6bc3d commit 17a5ab2
Show file tree
Hide file tree
Showing 22 changed files with 207 additions and 155 deletions.
158 changes: 84 additions & 74 deletions Cargo.lock

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
[package]
name = "ckb-cli"
version = "0.43.0"
version = "0.100.0-rc2"
license = "MIT"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
description = "ckb command line interface"

[dependencies]
ckb-jsonrpc-types = "=0.43.0"
ckb-hash = "=0.43.0"
ckb-crypto = { version = "=0.43.0", features = ["secp"] }
ckb-build-info = "=0.43.0"
ckb-types = "=0.43.0"
ckb-util = "=0.43.0"
ckb-resource = "=0.43.0"
ckb-dao-utils = "=0.43.0"
ckb-chain-spec = "=0.43.0"
ckb-sdk = { path = "ckb-sdk", version = "=0.43.0" }
ckb-index = { path = "ckb-index", version = "=0.43.0" }
plugin-protocol = { path = "plugin-protocol", package = "ckb-cli-plugin-protocol", version = "=0.43.0" }
ckb-jsonrpc-types = "=0.100.0-rc2"
ckb-hash = "=0.100.0-rc2"
ckb-crypto = { version = "=0.100.0-rc2", features = ["secp"] }
ckb-build-info = "=0.100.0-rc2"
ckb-types = "=0.100.0-rc2"
ckb-util = "=0.100.0-rc2"
ckb-resource = "=0.100.0-rc2"
ckb-dao-utils = "=0.100.0-rc2"
ckb-chain-spec = "=0.100.0-rc2"
ckb-sdk = { path = "ckb-sdk", version = "=0.100.0-rc2" }
ckb-index = { path = "ckb-index", version = "=0.100.0-rc2" }
plugin-protocol = { path = "plugin-protocol", package = "ckb-cli-plugin-protocol", version = "=0.100.0-rc2" }
jsonrpc-core-client = "17"
jsonrpc-core = "17"
jsonrpc-derive = "17"
Expand Down Expand Up @@ -61,7 +61,7 @@ tui = "0.6.0"
termion = "1.5"

[build-dependencies]
ckb-build-info = "=0.43.0"
ckb-build-info = "=0.100.0-rc2"

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

integration:
bash devtools/ci/integration.sh v0.42.0-rc1
bash devtools/ci/integration.sh v0.100.0-rc2

prod: ## Build binary with release profile.
cargo build --release
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ transactions_root: 0xc4991d3e261c27a0ce7ea9801de5f0a5f56ffb82a29d7a6e8e7cf44dbb2
witnesses_root: 0x39116bc1a56f5ca82cf5226f172f97ff8a8d9626ca7e41d8cd92e76666e069f8
proposals_hash: 0x0000000000000000000000000000000000000000000000000000000000000000
difficulty: 0x4000000
uncles_hash: 0x0000000000000000000000000000000000000000000000000000000000000000
extra_hash: 0x0000000000000000000000000000000000000000000000000000000000000000
uncles_count: "0"
dao: 0x0100000000000000af9a31ce318a230000cc083d71c4350000d774f0356a0000
nonce: "1876243812404095811"
Expand Down
6 changes: 3 additions & 3 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.43.0"
version = "0.100.0-rc2"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -12,6 +12,6 @@ serde_derive = "1.0"
bincode = "1.1.4"
log = "0.4.6"
failure = "0.1.5"
ckb-types = "=0.43.0"
ckb-sdk = { path = "../ckb-sdk", version = "=0.43.0" }
ckb-types = "=0.100.0-rc2"
ckb-sdk = { path = "../ckb-sdk", version = "=0.100.0-rc2" }
rocksdb = { package = "ckb-rocksdb", version = "=0.15.1", features = ["snappy"] }
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.43.0"
version = "0.100.0-rc2"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -10,11 +10,11 @@ description = "ckb-cli sdk common types"
serde = { version = "1.0", features = ["derive"] }
serde_derive = "1.0"

ckb-types = "=0.43.0"
ckb-traits = "=0.43.0"
ckb-jsonrpc-types = "=0.43.0"
ckb-hash = "=0.43.0"
ckb-error = "=0.43.0"
ckb-types = "=0.100.0-rc2"
ckb-traits = "=0.100.0-rc2"
ckb-jsonrpc-types = "=0.100.0-rc2"
ckb-hash = "=0.100.0-rc2"
ckb-error = "=0.100.0-rc2"

[dev-dependencies]
ckb-crypto = { version = "=0.43.0", features = ["secp"] }
ckb-crypto = { version = "=0.100.0-rc2", features = ["secp"] }
20 changes: 11 additions & 9 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.43.0"
version = "0.100.0-rc2"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand Down Expand Up @@ -29,12 +29,14 @@ tokio-util = { version = "0.6", features = ["codec"] }
tokio = { version = "1" }
bytes = "1"
futures = "0.3"
jsonrpc-core = "17"

ckb-types = "=0.43.0"
ckb-error = "=0.43.0"
ckb-script = "=0.43.0"
ckb-jsonrpc-types = "=0.43.0"
ckb-hash = "=0.43.0"
ckb-resource = "=0.43.0"
ckb-crypto = { version = "=0.43.0", features = ["secp"] }
ckb-sdk-types = { path = "../ckb-sdk-types", version="=0.43.0" }
ckb-types = "=0.100.0-rc2"
ckb-error = "=0.100.0-rc2"
ckb-script = "=0.100.0-rc2"
ckb-jsonrpc-types = "=0.100.0-rc2"
ckb-chain-spec = "=0.100.0-rc2"
ckb-hash = "=0.100.0-rc2"
ckb-resource = "=0.100.0-rc2"
ckb-crypto = { version = "=0.100.0-rc2", features = ["secp"] }
ckb-sdk-types = { path = "../ckb-sdk-types", version="=0.100.0-rc2" }
14 changes: 7 additions & 7 deletions ckb-sdk/src/pubsub/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,18 @@ where

// Since the current subscription state, the return value may be a notification,
// we need to ensure that the unsubscribed message returns before jumping out
match serde_json::from_slice::<ckb_jsonrpc_types::response::Output>(&resp) {
match serde_json::from_slice::<jsonrpc_core::response::Output>(&resp) {
Ok(output) => break output,
Err(_) => self.pending_recv.push_back(resp),
}
};

match output {
ckb_jsonrpc_types::response::Output::Success(_) => {
jsonrpc_core::response::Output::Success(_) => {
self.topic_list.remove(&id);
Ok(())
}
ckb_jsonrpc_types::response::Output::Failure(e) => {
jsonrpc_core::response::Output::Failure(e) => {
Err(io::Error::new(io::ErrorKind::InvalidData, e.error))
}
}
Expand Down Expand Up @@ -251,7 +251,7 @@ where
let parse = |data: bytes::BytesMut,
topic_list: &HashMap<String, String>|
-> io::Result<(String, F)> {
let output = serde_json::from_slice::<ckb_jsonrpc_types::request::Notification>(&data)
let output = serde_json::from_slice::<jsonrpc_core::request::Notification>(&data)
.expect("must parse to notification");
let message = output
.params
Expand Down Expand Up @@ -309,14 +309,14 @@ async fn subscribe<T: tokio::io::AsyncWrite + tokio::io::AsyncRead + Unpin>(
loop {
let resp = io.next().await;
let resp = resp.ok_or_else::<io::Error, _>(|| io::ErrorKind::BrokenPipe.into())??;
match serde_json::from_slice::<ckb_jsonrpc_types::response::Output>(&resp) {
match serde_json::from_slice::<jsonrpc_core::response::Output>(&resp) {
Ok(output) => match output {
ckb_jsonrpc_types::response::Output::Success(success) => {
jsonrpc_core::response::Output::Success(success) => {
let res = serde_json::from_value::<String>(success.result).unwrap();
topic_list.insert(res, topic.as_ref().to_owned());
break Ok(());
}
ckb_jsonrpc_types::response::Output::Failure(e) => {
jsonrpc_core::response::Output::Failure(e) => {
return Err(io::Error::new(io::ErrorKind::InvalidData, e.error))
}
},
Expand Down
20 changes: 12 additions & 8 deletions ckb-sdk/src/rpc/client.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use ckb_jsonrpc_types::{
BannedAddr, Block, BlockNumber, BlockTemplate, BlockView, CellWithStatus, ChainInfo, Consensus,
Cycle, EpochNumber, EpochView, ExtraLoggerConfig, HeaderView, JsonBytes, LocalNode,
MainLoggerConfig, OutPoint, RawTxPool, RemoteNode, Script, Timestamp, Transaction,
TransactionProof, TransactionWithStatus, TxPoolInfo, Uint64, Version,
MainLoggerConfig, OutPoint, OutputsValidator, RawTxPool, RemoteNode, Script, Timestamp,
Transaction, TransactionProof, TransactionWithStatus, TxPoolInfo, Uint64, Version,
};

use super::primitive;
Expand Down Expand Up @@ -45,12 +45,12 @@ macro_rules! jsonrpc {
req_json.insert("params".to_owned(), params);

let resp = $selff.client.post($selff.url.clone()).json(&req_json).send()?;
let output = resp.json::<ckb_jsonrpc_types::response::Output>()?;
let output = resp.json::<jsonrpc_core::response::Output>()?;
match output {
ckb_jsonrpc_types::response::Output::Success(success) => {
jsonrpc_core::response::Output::Success(success) => {
serde_json::from_value(success.result).map_err(Into::into)
},
ckb_jsonrpc_types::response::Output::Failure(failure) => {
jsonrpc_core::response::Output::Failure(failure) => {
Err(failure.error.into())
}
}
Expand Down Expand Up @@ -108,7 +108,7 @@ jsonrpc!(pub struct RawHttpRpcClient {
pub fn ping_peers(&mut self) -> ();

// Pool
pub fn send_transaction(&mut self, tx: Transaction) -> H256;
pub fn send_transaction(&mut self, tx: Transaction, outputs_validator: Option<OutputsValidator>) -> H256;
pub fn tx_pool_info(&mut self) -> TxPoolInfo;
pub fn get_raw_tx_pool(&mut self, verbose: Option<bool>) -> RawTxPool;

Expand Down Expand Up @@ -330,9 +330,13 @@ impl HttpRpcClient {
}

// Pool
pub fn send_transaction(&mut self, tx: packed::Transaction) -> Result<H256, String> {
pub fn send_transaction(
&mut self,
tx: packed::Transaction,
outputs_validator: Option<OutputsValidator>,
) -> Result<H256, String> {
self.client
.send_transaction(tx.into())
.send_transaction(tx.into(), outputs_validator)
.map_err(|err| err.to_string())
}
pub fn tx_pool_info(&mut self) -> Result<types::TxPoolInfo, String> {
Expand Down
8 changes: 4 additions & 4 deletions ckb-sdk/src/rpc/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ pub struct Header {
pub parent_hash: H256,
pub transactions_root: H256,
pub proposals_hash: H256,
pub uncles_hash: H256,
pub extra_hash: H256,
pub dao: Byte32,
pub nonce: Uint128,
}
Expand All @@ -371,7 +371,7 @@ impl From<rpc_types::Header> for Header {
parent_hash: json.parent_hash,
transactions_root: json.transactions_root,
proposals_hash: json.proposals_hash,
uncles_hash: json.uncles_hash,
extra_hash: json.extra_hash,
dao: json.dao,
nonce: json.nonce,
}
Expand All @@ -388,7 +388,7 @@ impl From<Header> for packed::Header {
transactions_root,
proposals_hash,
compact_target,
uncles_hash,
extra_hash,
dao,
nonce,
} = json;
Expand All @@ -401,7 +401,7 @@ impl From<Header> for packed::Header {
.transactions_root(transactions_root.pack())
.proposals_hash(proposals_hash.pack())
.compact_target(compact_target.pack())
.uncles_hash(uncles_hash.pack())
.extra_hash(extra_hash.pack())
.dao(dao.into())
.build();
packed::Header::new_builder()
Expand Down
2 changes: 1 addition & 1 deletion ckb-sdk/src/test-data/genesis_block.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0x16d9a80e052",
"transactions_root": "0x4338ea13c6eabc6392a31562131990996c9cd8df9e6c8f890a5799f2a73ec208",
"uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"version": "0x0"
},
"proposals": [],
Expand Down
32 changes: 28 additions & 4 deletions ckb-sdk/src/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
use ckb_chain_spec::consensus::ConsensusBuilder;
use ckb_error::OtherError;
use ckb_hash::new_blake2b;
use ckb_jsonrpc_types as rpc_types;
use ckb_script::TransactionScriptsVerifier;
use ckb_script::{TransactionScriptsVerifier, TxVerifyEnv};
use ckb_types::{
bytes::Bytes,
core::{cell::resolve_transaction, Capacity, Cycle, ScriptHashType},
core::{
cell::resolve_transaction, hardfork::HardForkSwitch, Capacity, Cycle,
EpochNumberWithFraction, HeaderView, ScriptHashType,
},
packed::{Byte32, CellInput, CellOutput, OutPoint, Script, WitnessArgs},
prelude::*,
H160, H256,
};

use fnv::FnvHashSet;
use std::collections::{HashMap, HashSet};
use std::convert::TryInto;
Expand Down Expand Up @@ -157,7 +162,7 @@ impl<'a> MockTransactionHelper<'a> {
let sighash_type_hash = genesis_info.sighash_type_hash();
let mut insert_dep = |hash_type, code_hash: &Byte32| -> Result<(), String> {
match (hash_type, code_hash) {
(ScriptHashType::Data, data_hash) => {
(ScriptHashType::Data, data_hash) | (ScriptHashType::Data1, data_hash) => {
let dep = data_deps.get(data_hash).cloned().ok_or_else(|| {
format!("Can not find data hash in mock deps: {}", data_hash)
})?;
Expand Down Expand Up @@ -317,6 +322,25 @@ impl<'a> MockTransactionHelper<'a> {
max_cycle: Cycle,
loader: L,
) -> Result<Cycle, String> {
let (consensus, tx_env) = {
let enable_epoch_number = 200;
let commit_epoch_number = 200 + 100;
let epoch = EpochNumberWithFraction::new(commit_epoch_number, 0, 1);
let header = HeaderView::new_advanced_builder()
.epoch(epoch.pack())
.build();
let tx_env = TxVerifyEnv::new_commit(&header);
let hardfork_switch = HardForkSwitch::new_without_any_enabled()
.as_builder()
.rfc_0232(enable_epoch_number)
.build()
.unwrap();
let consensus = ConsensusBuilder::default()
.hardfork_switch(hardfork_switch)
.build();
(consensus, tx_env)
};

let resource = Resource::from_both(self.mock_tx, loader)?;
let tx = self.mock_tx.core_transaction();
let rtx = {
Expand All @@ -325,7 +349,7 @@ impl<'a> MockTransactionHelper<'a> {
.map_err(|err| format!("Resolve transaction error: {:?}", err))?
};

let mut verifier = TransactionScriptsVerifier::new(&rtx, &resource);
let mut verifier = TransactionScriptsVerifier::new(&rtx, &consensus, &resource, &tx_env);
verifier.set_debug_printer(|script_hash, message| {
println!("script: {:x}, debug: {}", script_hash, message);
});
Expand Down
2 changes: 1 addition & 1 deletion ckb-sdk/src/types/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl AddressPayload {
match self {
AddressPayload::Short { .. } => AddressType::Short,
AddressPayload::Full { hash_type, .. } => match hash_type {
ScriptHashType::Data => AddressType::FullData,
ScriptHashType::Data | ScriptHashType::Data1 => AddressType::FullData,
ScriptHashType::Type => AddressType::FullType,
},
}
Expand Down
8 changes: 4 additions & 4 deletions plugin-protocol/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ckb-cli-plugin-protocol"
version = "0.43.0"
version = "0.100.0-rc2"
authors = ["Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -9,9 +9,9 @@ description = "ckb-cli plugin protocol"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ckb-index = { path = "../ckb-index", version = "=0.43.0" }
ckb-types = "=0.43.0"
ckb-jsonrpc-types = "=0.43.0"
ckb-index = { path = "../ckb-index", version = "=0.100.0-rc2" }
ckb-types = "=0.100.0-rc2"
ckb-jsonrpc-types = "=0.100.0-rc2"
serde = { version = "1.0", features = ["derive"] }
serde_derive = "1.0"
serde_json = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/subcommands/dao/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub(crate) fn send_transaction(
);
}

let resp = rpc_client.send_transaction(transaction.data())?;
let resp = rpc_client.send_transaction(transaction.data(), None)?;
Ok(Output::new_output(resp))
}

Expand Down
Loading

0 comments on commit 17a5ab2

Please sign in to comment.