Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
doitian committed Feb 23, 2021
2 parents 0caa637 + 6c0c375 commit db27543
Show file tree
Hide file tree
Showing 38 changed files with 2,053 additions and 1,670 deletions.
2,173 changes: 1,137 additions & 1,036 deletions Cargo.lock

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
[package]
name = "ckb-cli"
version = "0.38.0"
version = "0.40.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.38.0-rc1" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1", features = ["secp"] }
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-util = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-dao-utils = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-chain-spec = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2", features = ["secp"] }
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-util = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-dao-utils = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-chain-spec = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-sdk = { path = "ckb-sdk" }
ckb-index = { path = "ckb-index" }
plugin-protocol = { path = "plugin-protocol", package = "ckb-cli-plugin-protocol" }
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.17.0" }
jsonrpc-core-client = "17"
jsonrpc-core = "17"
jsonrpc-derive = "17"
jsonrpc-http-server = "17"
jsonrpc-server-utils = "17"
secp256k1 = { version = "0.19", features = ["recovery"] }
faster-hex = "0.4"
env_logger = "0.6"
crossbeam-channel = "0.3"
clap = "3.0.0-beta.1"
clap_generate = "3.0.0-beta.1"
clap = "=3.0.0-beta.1"
clap_generate = "=3.0.0-beta.1"
serde = { version = "1.0", features = ["rc"] }
serde_derive = "1.0"
serde_json = "1.0"
Expand Down Expand Up @@ -57,7 +57,7 @@ tui = "0.6.0"
termion = "1.5"

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

[workspace]
members = ["ckb-sdk", "ckb-index", "ckb-sdk-types", "plugin-protocol"]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fmt:

clippy:
RUSTFLAGS='-F warnings' cargo clippy --all --tests -- ${CLIPPY_OPTS}
cd test && RUSTFLAGS='-F warnings' cargo clippy --all -- ${CLIPPY_OPTS}
cp -f Cargo.lock test/Cargo.lock && cd test && RUSTFLAGS='-F warnings' cargo clippy --all -- ${CLIPPY_OPTS}

test:
RUSTFLAGS='-F warnings' RUST_BACKTRACE=full cargo test --all
Expand All @@ -15,7 +15,7 @@ ci: fmt clippy test security-audit
git diff --exit-code Cargo.lock

integration:
bash devtools/ci/integration.sh v0.38.0-rc1
bash devtools/ci/integration.sh v0.40.0-rc2

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.38.0"
version = "0.40.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.38.0-rc1" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-sdk = { path = "../ckb-sdk" }
rocksdb = { package = "ckb-rocksdb", version = "=0.13.0", features = ["snappy"] }
46 changes: 42 additions & 4 deletions ckb-index/src/index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{KVReader, KVTxn, RocksReader, RocksTxn};
pub use key::{Key, KeyMetrics, KeyType};
pub use types::{CellIndex, HashType, LiveCellInfo, TxInfo};

use types::BlockDeltaInfo;
use types::{BlockDeltaInfo, KEEP_RECENT_BLOCKS};

// NOTE: You should reopen to increase database size when processed enough blocks
// [reference]: https://stackoverflow.com/a/33571804
Expand Down Expand Up @@ -121,7 +121,7 @@ impl<'a> IndexDatabase<'a> {
reader
.get(&Key::BlockDelta(last_header.number()).to_bytes())
.map(|bytes| bincode::deserialize(&bytes).unwrap())
.unwrap()
.ok_or_else(|| IndexError::LongFork)?
};
let mut txn = RocksTxn::new(self.db, self.cf);
last_block_delta.rollback(&mut txn);
Expand Down Expand Up @@ -376,11 +376,11 @@ pub enum IndexError {
BlockImmature(u64),
IllegalBlock(Byte32),
InvalidBlockNumber(u64),
BlockInvalid(String),
NotInit,
IoError(String),
InvalidGenesis(String),
InvalidNetworkType(String),
LongFork,
}

impl From<io::Error> for IndexError {
Expand All @@ -391,6 +391,44 @@ impl From<io::Error> for IndexError {

impl fmt::Display for IndexError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "{:?}", self)
match self {
IndexError::BlockImmature(number) => {
write!(
f,
"Current applied block number {} greater than tip block number",
number
)?;
}
IndexError::IllegalBlock(_) => {
write!(f, "Current applied block number is 1, but the parent hash not match genesis block hash")?;
}
IndexError::InvalidBlockNumber(number) => {
write!(
f,
"Current applied block number {} is not the next block of lastest block",
number
)?;
}
IndexError::NotInit => {
write!(f, "Apply block before database initialization")?;
}
IndexError::IoError(msg) => {
write!(f, "IO error: {}", msg)?;
}
IndexError::InvalidGenesis(msg) => {
write!(f, "Genesis hash not match with DB, {}", msg)?;
}
IndexError::InvalidNetworkType(msg) => {
write!(f, "NetworkType not match with DB, {}", msg)?;
}
IndexError::LongFork => {
write!(
f,
"Already rollbacked {} blocks, long fork detected",
KEEP_RECENT_BLOCKS
)?;
}
}
Ok(())
}
}
4 changes: 2 additions & 2 deletions ckb-index/src/index/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use serde_derive::{Deserialize, Serialize};
use super::key::{Key, KeyType};
use crate::{KVReader, KVTxn};

const KEEP_RECENT_HEADERS: u64 = 10_000;
const KEEP_RECENT_BLOCKS: u64 = 200;
pub const KEEP_RECENT_HEADERS: u64 = 10_000;
pub const KEEP_RECENT_BLOCKS: u64 = 200;

#[derive(Hash, Eq, PartialEq, Debug, Clone, Copy, Serialize, Deserialize)]
#[repr(u8)]
Expand Down
1 change: 1 addition & 0 deletions ckb-index/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod error;
#[allow(clippy::mutable_key_type)]
mod index;
mod kvdb;
mod util;
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.38.0"
version = "0.40.0"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -9,11 +9,11 @@ license = "MIT"
serde = { version = "1.0", features = ["rc"] }
serde_derive = "1.0"

ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-traits = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-error = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-traits = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-error = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }

[dev-dependencies]
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1", features = ["secp"] }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2", features = ["secp"] }
17 changes: 13 additions & 4 deletions ckb-sdk-types/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,12 @@ impl Resource {
}

impl<'a> HeaderChecker for Resource {
fn check_valid(&self, block_hash: &Byte32) -> Result<(), ckb_error::Error> {
fn check_valid(
&self,
block_hash: &Byte32,
) -> Result<(), ckb_types::core::error::OutPointError> {
if !self.required_headers.contains_key(block_hash) {
return Err(OutPointError::InvalidHeader(block_hash.clone()).into());
return Err(OutPointError::InvalidHeader(block_hash.clone()));
}
Ok(())
}
Expand All @@ -221,18 +224,24 @@ impl CellProvider for Resource {
}

impl CellDataProvider for Resource {
fn load_cell_data(&self, cell: &CellMeta) -> Option<(Bytes, Byte32)> {
fn load_cell_data(&self, cell: &CellMeta) -> Option<Bytes> {
cell.mem_cell_data
.as_ref()
.map(ToOwned::to_owned)
.or_else(|| self.get_cell_data(&cell.out_point))
}

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

fn get_cell_data_hash(&self, out_point: &OutPoint) -> Option<Byte32> {
self.required_cells
.get(out_point)
.and_then(|cell_meta| cell_meta.mem_cell_data_hash.clone())
}
}

impl HeaderProvider for Resource {
Expand Down
21 changes: 11 additions & 10 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.38.0"
version = "0.40.0"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -11,11 +11,11 @@ serde_derive = "1.0"
serde_json = "1.0"
bech32 = "0.6.0"
log = "0.4.6"
reqwest = "0.9"
secp256k1 = "0.17.0"
reqwest = { version = "0.11", features = ["json", "blocking"] }
secp256k1 = { version = "0.19", features = ["recovery"] }
faster-hex = "0.4"
fnv = "1.0.3"
aes-ctr = "0.3.0"
aes-ctr = "0.6.0"
scrypt = "0.2.0"
rand = "0.6.5"
tiny-keccak = "1.4"
Expand All @@ -25,10 +25,11 @@ 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.38.0-rc1" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.38.0-rc1", features = ["secp"] }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-error = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2", features = ["secp"] }
ckb-sdk-types = { path = "../ckb-sdk-types" }
Loading

0 comments on commit db27543

Please sign in to comment.