Skip to content

Commit

Permalink
Merge pull request #326 from TheWaWaR/update-ckb-to-v0.35
Browse files Browse the repository at this point in the history
chore: Update ckb to v0.35
  • Loading branch information
TheWaWaR authored Aug 11, 2020
2 parents 6622443 + 1d7712d commit 3875086
Show file tree
Hide file tree
Showing 13 changed files with 375 additions and 318 deletions.
274 changes: 61 additions & 213 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[package]
name = "ckb-cli"
version = "0.34.0"
version = "0.35.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.34.0-rc1" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.34.0-rc1" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.34.0-rc1", features = ["secp"] }
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.34.0-rc1" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.34.0-rc1" }
ckb-util = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.34.0-rc1" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.34.0-rc1" }
ckb-dao-utils = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.34.0-rc1" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1", features = ["secp"] }
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1" }
ckb-util = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1" }
ckb-dao-utils = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1" }
ckb-sdk = { path = "ckb-sdk" }
ckb-index = { path = "ckb-index" }
plugin-protocol = { path = "plugin-protocol", package = "ckb-cli-plugin-protocol" }
Expand Down Expand Up @@ -56,7 +56,7 @@ tui = "0.6.0"
termion = "1.5"

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

[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 @@ -13,7 +13,7 @@ ci: fmt clippy test security-audit
git diff --exit-code Cargo.lock

integration:
bash devtools/ci/integration.sh v0.34.0-rc1
bash devtools/ci/integration.sh v0.35.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.34.0"
version = "0.35.0"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -11,6 +11,6 @@ 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.34.0-rc1" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1" }
ckb-sdk = { path = "../ckb-sdk" }
rocksdb = { package = "ckb-rocksdb", version = "=0.13.0", features = ["snappy"] }
19 changes: 7 additions & 12 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.34.0"
version = "0.35.0"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -9,16 +9,11 @@ license = "MIT"
serde = { version = "1.0", features = ["rc"] }
serde_derive = "1.0"

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

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

[features]
default = ["ckb-script/default"]
asm = ["ckb-script/asm"]
logging = ["ckb-script/logging"]
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1", features = ["secp"] }
36 changes: 17 additions & 19 deletions ckb-sdk-types/src/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use ckb_jsonrpc_types as json_types;
use ckb_script::DataLoader;
use ckb_traits::{CellDataProvider, HeaderProvider};
use ckb_types::{
bytes::Bytes,
core::{
cell::{CellMeta, CellMetaBuilder, CellProvider, CellStatus, HeaderChecker},
error::OutPointError,
BlockExt, DepType, EpochExt, EpochNumberWithFraction, HeaderView, TransactionInfo,
TransactionView,
DepType, EpochNumberWithFraction, HeaderView, TransactionInfo, TransactionView,
},
packed::{Byte32, CellDep, CellInput, CellOutput, OutPoint, OutPointVec, Transaction},
prelude::*,
Expand Down Expand Up @@ -221,25 +220,24 @@ impl CellProvider for Resource {
}
}

impl DataLoader for Resource {
// load CellOutput
impl CellDataProvider for Resource {
fn load_cell_data(&self, cell: &CellMeta) -> Option<(Bytes, Byte32)> {
cell.mem_cell_data.clone().or_else(|| {
self.required_cells
.get(&cell.out_point)
.and_then(|cell_meta| cell_meta.mem_cell_data.clone())
})
}
// load BlockExt
fn get_block_ext(&self, _block_hash: &Byte32) -> Option<BlockExt> {
// TODO: visit this later
None
cell.mem_cell_data
.as_ref()
.map(ToOwned::to_owned)
.or_else(|| self.get_cell_data(&cell.out_point))
}
fn get_block_epoch(&self, _block_hash: &Byte32) -> Option<EpochExt> {
None

fn get_cell_data(&self, out_point: &OutPoint) -> Option<(Bytes, Byte32)> {
self.required_cells
.get(out_point)
.and_then(|cell_meta| cell_meta.mem_cell_data.clone())
}
fn get_header(&self, block_hash: &Byte32) -> Option<HeaderView> {
self.required_headers.get(block_hash).cloned()
}

impl HeaderProvider for Resource {
fn get_header(&self, hash: &Byte32) -> Option<HeaderView> {
self.required_headers.get(hash).cloned()
}
}

Expand Down
14 changes: 7 additions & 7 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.34.0"
version = "0.35.0"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -25,10 +25,10 @@ uuid = { version = "0.7.4", features = ["v4"] }
chrono = "0.4.6"
failure = "0.1.5"

ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.34.0-rc1" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.34.0-rc1" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.34.0-rc1" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.34.0-rc1" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.34.0-rc1" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.34.0-rc1", features = ["secp"] }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.35.0-rc1", features = ["secp"] }
ckb-sdk-types = { path = "../ckb-sdk-types" }
118 changes: 93 additions & 25 deletions ckb-sdk/src/rpc/client.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use ckb_jsonrpc_types::{
BannedAddr, Block, BlockNumber, BlockReward, BlockTemplate, BlockView, CellOutputWithOutPoint,
CellTransaction, CellWithStatus, ChainInfo, EpochNumber, EpochView, HeaderView, LiveCell,
LocalNode, LockHashIndexState, OutPoint, PeerState, RemoteNode, Timestamp, Transaction,
TransactionWithStatus, TxPoolInfo, Uint64, Version,
CellTransaction, CellWithStatus, ChainInfo, EpochNumber, EpochView, ExtraLoggerConfig,
HeaderView, JsonBytes, LiveCell, LocalNode, LockHashIndexState, MainLoggerConfig, OutPoint,
PeerState, RemoteNode, Script, Timestamp, Transaction, TransactionWithStatus, TxPoolInfo,
Uint64, Version,
};

use super::types;
Expand Down Expand Up @@ -114,6 +115,10 @@ jsonrpc!(pub struct RawHttpRpcClient {
absolute: Option<bool>,
reason: Option<String>
) -> ();
pub fn sync_state(&mut self) -> types::PeerSyncState;
pub fn set_network_active(&mut self, state: bool) -> ();
pub fn add_node(&mut self, peer_id: String, address: String) -> ();
pub fn remove_node(&mut self, peer_id: String) -> ();

// Pool
pub fn send_transaction(&mut self, tx: Transaction) -> H256;
Expand All @@ -123,14 +128,21 @@ jsonrpc!(pub struct RawHttpRpcClient {
pub fn get_blockchain_info(&mut self) -> ChainInfo;
pub fn get_peers_state(&mut self) -> Vec<PeerState>;

// IntegrationTest
pub fn add_node(&mut self, peer_id: String, address: String) -> ();
pub fn remove_node(&mut self, peer_id: String) -> ();
pub fn broadcast_transaction(&mut self, tx: Transaction) -> H256;

// Miner
pub fn get_block_template(&mut self, bytes_limit: Option<Uint64>, proposals_limit: Option<Uint64>, max_version: Option<Version>) -> BlockTemplate;
pub fn submit_block(&mut self, _work_id: String, _data: Block) -> H256;

// IntegrationTest
pub fn process_block_without_verify(&mut self, data: Block, broadcast: bool) -> Option<H256>;
pub fn truncate(&mut self, target_tip_hash: H256) -> ();
pub fn generate_block(&mut self, block_assembler_script: Option<Script>, block_assembler_message: Option<JsonBytes>) -> H256;
pub fn broadcast_transaction(&mut self, tx: Transaction) -> H256;
pub fn get_fork_block(&mut self, _hash: H256) -> Option<BlockView>;

// Debug
pub fn jemalloc_profiling_dump(&mut self) -> String;
pub fn update_main_logger(&mut self, config: MainLoggerConfig) -> ();
pub fn set_extra_logger(&mut self, name: String, config_opt: Option<ExtraLoggerConfig>) -> ();
});

pub struct HttpRpcClient {
Expand Down Expand Up @@ -333,6 +345,27 @@ impl HttpRpcClient {
.set_ban(address, command, ban_time.map(Into::into), absolute, reason)
.map_err(|err| err.to_string())
}
pub fn sync_state(&mut self) -> Result<types::PeerSyncState, String> {
self.client
.sync_state()
.map(Into::into)
.map_err(|err| err.to_string())
}
pub fn set_network_active(&mut self, state: bool) -> Result<(), String> {
self.client
.set_network_active(state)
.map_err(|err| err.to_string())
}
pub fn add_node(&mut self, peer_id: String, address: String) -> Result<(), String> {
self.client
.add_node(peer_id, address)
.map_err(|err| err.to_string())
}
pub fn remove_node(&mut self, peer_id: String) -> Result<(), String> {
self.client
.remove_node(peer_id)
.map_err(|err| err.to_string())
}

// Pool
pub fn send_transaction(&mut self, tx: packed::Transaction) -> Result<H256, String> {
Expand All @@ -358,23 +391,6 @@ impl HttpRpcClient {
self.client.get_peers_state().map_err(|err| err.to_string())
}

// IntegrationTest
pub fn add_node(&mut self, peer_id: String, address: String) -> Result<(), String> {
self.client
.add_node(peer_id, address)
.map_err(|err| err.to_string())
}
pub fn remove_node(&mut self, peer_id: String) -> Result<(), String> {
self.client
.remove_node(peer_id)
.map_err(|err| err.to_string())
}
pub fn broadcast_transaction(&mut self, tx: packed::Transaction) -> Result<H256, String> {
self.client
.broadcast_transaction(tx.into())
.map_err(|err| err.to_string())
}

// Miner
pub fn get_block_template(
&mut self,
Expand All @@ -395,4 +411,56 @@ impl HttpRpcClient {
.submit_block(work_id, data.into())
.map_err(|err| err.to_string())
}

// IntegrationTest
pub fn broadcast_transaction(&mut self, tx: packed::Transaction) -> Result<H256, String> {
self.client
.broadcast_transaction(tx.into())
.map_err(|err| err.to_string())
}

pub fn process_block_without_verify(
&mut self,
data: Block,
broadcast: bool,
) -> Result<Option<H256>, String> {
self.client
.process_block_without_verify(data, broadcast)
.map_err(|err| err.to_string())
}
pub fn truncate(&mut self, target_tip_hash: H256) -> Result<(), String> {
self.client
.truncate(target_tip_hash)
.map_err(|err| err.to_string())
}
pub fn generate_block(
&mut self,
block_assembler_script: Option<Script>,
block_assembler_message: Option<JsonBytes>,
) -> Result<H256, String> {
self.client
.generate_block(block_assembler_script, block_assembler_message)
.map_err(|err| err.to_string())
}

// Debug
pub fn jemalloc_profiling_dump(&mut self) -> Result<String, String> {
self.client
.jemalloc_profiling_dump()
.map_err(|err| err.to_string())
}
pub fn update_main_logger(&mut self, config: MainLoggerConfig) -> Result<(), String> {
self.client
.update_main_logger(config)
.map_err(|err| err.to_string())
}
pub fn set_extra_logger(
&mut self,
name: String,
config_opt: Option<ExtraLoggerConfig>,
) -> Result<(), String> {
self.client
.set_extra_logger(name, config_opt)
.map_err(|err| err.to_string())
}
}
Loading

0 comments on commit 3875086

Please sign in to comment.