Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
317 changes: 202 additions & 115 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions light-client-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ homepage = "https://github.com/nervosnetwork/ckb-light-client"
repository = "https://github.com/nervosnetwork/ckb-light-client"

[dependencies]
ckb-async-runtime = "0.202.0"
ckb-chain-spec = "0.202.0"
ckb-network = "0.202.0"
ckb-stop-handler = "0.202.0"
ckb-resource = "0.202.0"
ckb-jsonrpc-types = "0.202.0"
ckb-types = "0.202.0"
ckb-traits = "0.202.0"
ckb-systemtime = "0.202.0"
ckb-async-runtime = "1"
ckb-chain-spec = "1"
ckb-network = "1"
ckb-stop-handler = "1"
ckb-resource = "1"
ckb-jsonrpc-types = "1"
ckb-types = "1"
ckb-traits = "1"
ckb-systemtime = "1"

ckb-light-client-lib = { path = "../light-client-lib" }
clap = { version = "4", features = ["cargo"] }
Expand Down
50 changes: 25 additions & 25 deletions light-client-bin/src/tests/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,31 @@ fn rpc() {
// setup test data
let lock_script1 = ScriptBuilder::default()
.code_hash(H256(rand::random()).pack())
.hash_type(ScriptHashType::Data.into())
.hash_type(ScriptHashType::Data)
.args(Bytes::from(b"lock_script1".to_vec()).pack())
.build();

let lock_script2 = ScriptBuilder::default()
.code_hash(H256(rand::random()).pack())
.hash_type(ScriptHashType::Type.into())
.hash_type(ScriptHashType::Type)
.args(Bytes::from(b"lock_script2".to_vec()).pack())
.build();

let lock_script3 = ScriptBuilder::default()
.code_hash(H256(rand::random()).pack())
.hash_type(ScriptHashType::Type.into())
.hash_type(ScriptHashType::Type)
.args(Bytes::from(b"lock_script3".to_vec()).pack())
.build();

let type_script1 = ScriptBuilder::default()
.code_hash(H256(rand::random()).pack())
.hash_type(ScriptHashType::Data.into())
.hash_type(ScriptHashType::Data)
.args(Bytes::from(b"type_script1".to_vec()).pack())
.build();

let type_script2 = ScriptBuilder::default()
.code_hash(H256(rand::random()).pack())
.hash_type(ScriptHashType::Type.into())
.hash_type(ScriptHashType::Type)
.args(Bytes::from(b"type_script2".to_vec()).pack())
.build();

Expand Down Expand Up @@ -112,7 +112,7 @@ fn rpc() {
.header(
HeaderBuilder::default()
.epoch(EpochNumberWithFraction::new(0, 0, 1000).pack())
.number(0.pack())
.number(0)
.build(),
)
.build();
Expand Down Expand Up @@ -213,7 +213,7 @@ fn rpc() {
.header(
HeaderBuilder::default()
.epoch(EpochNumberWithFraction::new(0, pre_block.number() + 1, 1000).pack())
.number((pre_block.number() + 1).pack())
.number(pre_block.number() + 1)
.parent_hash(pre_block.hash())
.build(),
)
Expand Down Expand Up @@ -752,14 +752,14 @@ fn rpc() {
// test get_header rpc
let extra_header = HeaderBuilder::default()
.epoch(EpochNumberWithFraction::new(0, 500, 1000).pack())
.number(500.pack())
.number(500)
.build();
let fetched_headers: Vec<H256> = [0xaa11, 0xaa77, 0xaa88]
.into_iter()
.map(|nonce| {
let header = Header::new_builder().nonce(nonce.pack()).build();
let header = Header::new_builder().nonce(nonce).build();
let hash = header.calc_header_hash().unpack();
let extension = (nonce + 1).to_le_bytes().to_vec();
let extension = (nonce + 1u128).to_le_bytes().to_vec();
storage.add_fetched_header(&HeaderWithExtension {
header: header,
extension: Some(extension.pack()),
Expand Down Expand Up @@ -827,7 +827,7 @@ fn rpc() {
rv,
FetchStatus::Fetched {
data: Header::new_builder()
.nonce(0xaa11.pack())
.nonce(0xaa11)
.build()
.into_view()
.into()
Expand Down Expand Up @@ -1075,7 +1075,7 @@ fn get_cells_capacity_bug() {
// setup test data
let lock_script1 = ScriptBuilder::default()
.code_hash(H256(rand::random()).pack())
.hash_type(ScriptHashType::Data.into())
.hash_type(ScriptHashType::Data)
.args(Bytes::from(b"lock_script1".to_vec()).pack())
.build();

Expand All @@ -1101,7 +1101,7 @@ fn get_cells_capacity_bug() {
.header(
HeaderBuilder::default()
.epoch(EpochNumberWithFraction::new(0, 0, 1000).pack())
.number(0.pack())
.number(0)
.build(),
)
.build();
Expand All @@ -1117,7 +1117,7 @@ fn get_cells_capacity_bug() {

let lock_script2 = ScriptBuilder::default()
.code_hash(H256(rand::random()).pack())
.hash_type(ScriptHashType::Data.into())
.hash_type(ScriptHashType::Data)
.args(Bytes::from(b"lock_script2".to_vec()).pack())
.build();

Expand All @@ -1143,7 +1143,7 @@ fn get_cells_capacity_bug() {
.header(
HeaderBuilder::default()
.epoch(EpochNumberWithFraction::new(0, 1, 1000).pack())
.number(1.pack())
.number(1)
.build(),
)
.build();
Expand Down Expand Up @@ -1173,7 +1173,7 @@ fn get_cells_capacity_bug() {
.header(
HeaderBuilder::default()
.epoch(EpochNumberWithFraction::new(0, 2, 1000).pack())
.number(2.pack())
.number(2)
.build(),
)
.build();
Expand All @@ -1200,13 +1200,13 @@ fn get_cells_after_rollback_bug() {
// setup test data
let lock_script1 = ScriptBuilder::default()
.code_hash(H256(rand::random()).pack())
.hash_type(ScriptHashType::Data.into())
.hash_type(ScriptHashType::Data)
.args(Bytes::from(b"lock_script1".to_vec()).pack())
.build();

let lock_script2 = ScriptBuilder::default()
.code_hash(H256(rand::random()).pack())
.hash_type(ScriptHashType::Data.into())
.hash_type(ScriptHashType::Data)
.args(Bytes::from(b"lock_script2".to_vec()).pack())
.build();

Expand All @@ -1232,7 +1232,7 @@ fn get_cells_after_rollback_bug() {
.header(
HeaderBuilder::default()
.epoch(EpochNumberWithFraction::new(0, 0, 1000).pack())
.number(0.pack())
.number(0)
.build(),
)
.build();
Expand Down Expand Up @@ -1275,7 +1275,7 @@ fn get_cells_after_rollback_bug() {
.header(
HeaderBuilder::default()
.epoch(EpochNumberWithFraction::new(0, 1, 1000).pack())
.number(1.pack())
.number(1)
.build(),
)
.build();
Expand Down Expand Up @@ -1306,7 +1306,7 @@ fn get_cells_after_rollback_bug() {
.header(
HeaderBuilder::default()
.epoch(EpochNumberWithFraction::new(0, 2, 1000).pack())
.number(2.pack())
.number(2)
.build(),
)
.build();
Expand Down Expand Up @@ -1627,13 +1627,13 @@ fn test_chain_txs_in_same_block_bug() {
// setup test data
let lock_script1 = ScriptBuilder::default()
.code_hash(H256(rand::random()).pack())
.hash_type(ScriptHashType::Data.into())
.hash_type(ScriptHashType::Data)
.args(Bytes::from(b"lock_script1".to_vec()).pack())
.build();

let lock_script2 = ScriptBuilder::default()
.code_hash(H256(rand::random()).pack())
.hash_type(ScriptHashType::Data.into())
.hash_type(ScriptHashType::Data)
.args(Bytes::from(b"lock_script2".to_vec()).pack())
.build();

Expand All @@ -1659,7 +1659,7 @@ fn test_chain_txs_in_same_block_bug() {
.header(
HeaderBuilder::default()
.epoch(EpochNumberWithFraction::new(0, 0, 1000).pack())
.number(0.pack())
.number(0)
.build(),
)
.build();
Expand Down Expand Up @@ -1707,7 +1707,7 @@ fn test_chain_txs_in_same_block_bug() {
.header(
HeaderBuilder::default()
.epoch(EpochNumberWithFraction::new(0, 1, 1000).pack())
.number(1.pack())
.number(1)
.build(),
)
.build();
Expand Down
44 changes: 22 additions & 22 deletions light-client-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ repository = "https://github.com/nervosnetwork/ckb-light-client"
crate-type = ["cdylib", "rlib"]

[dependencies]
ckb-app-config = "0.202.0"
ckb-constant = "0.202.0"
ckb-types = "0.202.0"
ckb-network = "0.202.0"
ckb-jsonrpc-types = "0.202.0"
ckb-error = "0.202.0"
ckb-script = "0.202.0"
ckb-chain-spec = "0.202.0"
ckb-traits = "0.202.0"
ckb-resource = "0.202.0"
ckb-verification = "0.202.0"
ckb-hash = "0.202.0"
ckb-systemtime = "0.202.0"
ckb-dao-utils = "0.202.0"
ckb-dao = "0.202.0"
ckb-app-config = "1"
ckb-constant = "1"
ckb-types = "1"
ckb-network = "1"
ckb-jsonrpc-types = "1"
ckb-error = "1"
ckb-script = "1"
ckb-chain-spec = "1"
ckb-traits = "1"
ckb-resource = "1"
ckb-verification = "1"
ckb-hash = "1"
ckb-systemtime = "1"
ckb-dao-utils = "1"
ckb-dao = "1"

log = "0.4.14"
path-clean = "0.1.0"
Expand Down Expand Up @@ -67,15 +67,15 @@ serde_json = "1.0.134"
wasm-bindgen-test = "0.3.45"

[dev-dependencies]
ckb-shared = "0.202.0"
ckb-chain = "0.202.0"
ckb-tx-pool = "0.202.0"
ckb-store = "0.202.0"
ckb-systemtime = { version = "0.202.0", features = ["enable_faketime"] }
ckb-shared = "1"
ckb-chain = "1"
ckb-tx-pool = "1"
ckb-store = "1"
ckb-systemtime = { version = "1", features = ["enable_faketime"] }
tempfile = "3.0"
rand = "0.8"
serde_json = "1.0"
lazy_static = "1.3.0"
env_logger = "0.11"
ckb-db = "0.202.0"
ckb-db-schema = "0.202.0"
ckb-db = "1"
ckb-db-schema = "1"
6 changes: 3 additions & 3 deletions light-client-lib/src/protocols/filter/block_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl FilterProtocol {
start_number
);
let content = packed::GetBlockFilters::new_builder()
.start_number(start_number.pack())
.start_number(start_number)
.build();
let message = packed::BlockFilterMessage::new_builder()
.set(content)
Expand All @@ -291,7 +291,7 @@ impl FilterProtocol {
start_number
);
let content = packed::GetBlockFilterHashes::new_builder()
.start_number(start_number.pack())
.start_number(start_number)
.build();
let message = packed::BlockFilterMessage::new_builder()
.set(content)
Expand All @@ -314,7 +314,7 @@ impl FilterProtocol {
start_number
);
let content = packed::GetBlockFilterCheckPoints::new_builder()
.start_number(start_number.pack())
.start_number(start_number)
.build();
let message = packed::BlockFilterMessage::new_builder()
.set(content)
Expand Down
10 changes: 5 additions & 5 deletions light-client-lib/src/protocols/light_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ impl LightClientProtocol {
}
let builder = packed::GetLastStateProof::new_builder()
.last_hash(last_header.header().hash())
.last_n_blocks(last_n_blocks.pack());
.last_n_blocks(last_n_blocks);
let content = if last_number - start_number <= last_n_blocks {
let last_n_headers = self.storage.get_last_n_headers();

Expand All @@ -868,7 +868,7 @@ impl LightClientProtocol {

builder
.start_hash(real_start_hash)
.start_number(real_start_number.pack())
.start_number(real_start_number)
.difficulty_boundary(start_total_difficulty.pack())
} else {
let (difficulty_boundary, difficulties) = sampling::sample_blocks(
Expand All @@ -880,7 +880,7 @@ impl LightClientProtocol {
);
builder
.start_hash(start_hash)
.start_number(start_number.pack())
.start_number(start_number)
.difficulty_boundary(difficulty_boundary.pack())
.difficulties(difficulties.into_iter().map(|inner| inner.pack()).pack())
}
Expand All @@ -905,8 +905,8 @@ impl LightClientProtocol {
let builder = packed::GetLastStateProof::new_builder()
.last_hash(last_header.header().hash())
.start_hash(start_hash)
.start_number(start_number.pack())
.last_n_blocks(last_n_blocks.pack());
.start_number(start_number)
.last_n_blocks(last_n_blocks);
let content = if last_number - start_number <= last_n_blocks {
builder.difficulty_boundary(start_total_difficulty.pack())
} else {
Expand Down
2 changes: 1 addition & 1 deletion light-client-lib/src/protocols/relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl CKBProtocolHandler for RelayProtocol {
.map(|(tx, cycles, _)| {
packed::RelayTransaction::new_builder()
.transaction(tx)
.cycles(cycles.pack())
.cycles(cycles)
.build()
})
})
Expand Down
2 changes: 1 addition & 1 deletion light-client-lib/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub const ALWAYS_SUCCESS_BIN: &[u8] = include_bytes!("specs/cells/always_success

lazy_static::lazy_static! {
pub static ref ALWAYS_SUCCESS_SCRIPT: Script = Script::new_builder()
.hash_type(ScriptHashType::Data.into())
.hash_type(ScriptHashType::Data)
.code_hash(CellOutput::calc_data_hash(ALWAYS_SUCCESS_BIN))
.build();
}
6 changes: 3 additions & 3 deletions light-client-lib/src/tests/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ pub(crate) trait RunningChainExt: ChainExt {
.map(|(idx, _)| {
let out_point = packed::OutPoint::new_builder()
.tx_hash(tx.hash())
.index((idx as u32).pack())
.index(idx as u32)
.build();
packed::CellDep::new_builder().out_point(out_point).build()
})
Expand Down Expand Up @@ -387,8 +387,8 @@ pub(crate) trait RunningChainExt: ChainExt {
packed::GetLastStateProof::new_builder()
.last_hash(last_header.header().hash())
.start_hash(start_header.hash())
.start_number(start_header.number().pack())
.last_n_blocks(last_n_blocks.pack())
.start_number(start_header.number())
.last_n_blocks(last_n_blocks)
.difficulty_boundary(difficulty_boundary.pack())
.difficulties(difficulties.pack())
.build()
Expand Down
Loading