From c60d73012a12cbcb665d296e3cd11c40ee5ef935 Mon Sep 17 00:00:00 2001 From: shaojunda Date: Sun, 29 Sep 2019 10:47:54 +0800 Subject: [PATCH 1/8] chore: update get_block_template rpc doc --- rpc/README.md | 2 +- rpc/json/rpc.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rpc/README.md b/rpc/README.md index b747d3c7d6d..f320db98597 100644 --- a/rpc/README.md +++ b/rpc/README.md @@ -1232,10 +1232,10 @@ http://localhost:8114 }, "hash": "0x076049e2cc6b9f1ed4bb27b2337c55071dabfaf0183b1b17a4965bd0372d8dec" }, + "compact_target": "0x100", "current_time": "0x16d6269e84f", "cycles_limit": "0x2540be400", "dao": "0x004fb9e277860700b2f80165348723003d1862ec960000000028eb3d7e7a0100", - "difficulty": "0x100", "epoch": "0x3e80001000000", "number": "0x1", "parent_hash": "0xd5c495b7dd4d9d066a6a4d4356bc31955ad3199e0d856f34cfbe159c46ee335b", diff --git a/rpc/json/rpc.json b/rpc/json/rpc.json index 5b619dd8695..2d63c20ce5d 100644 --- a/rpc/json/rpc.json +++ b/rpc/json/rpc.json @@ -1003,7 +1003,7 @@ "current_time": "0x16d6269e84f", "cycles_limit": "0x2540be400", "dao": "0x004fb9e277860700b2f80165348723003d1862ec960000000028eb3d7e7a0100", - "difficulty": "0x100", + "compact_target": "0x100", "epoch": "0x3e80001000000", "number": "0x1", "parent_hash": "0xd5c495b7dd4d9d066a6a4d4356bc31955ad3199e0d856f34cfbe159c46ee335b", From d6aa09a042fe4ad95ae107a3ffdeda35967322d0 Mon Sep 17 00:00:00 2001 From: keroro520 Date: Mon, 30 Sep 2019 15:16:17 +0800 Subject: [PATCH 2/8] chore(test): Allow CI debug logs --- test/src/node.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/src/node.rs b/test/src/node.rs index d5e0676d14b..18038401f3c 100644 --- a/test/src/node.rs +++ b/test/src/node.rs @@ -435,11 +435,6 @@ impl Node { hash_type: ScriptHashType::Data.into(), }); - if ::std::env::var("CI").is_ok() { - ckb_config.logger.filter = - Some(::std::env::var("CKB_LOG").unwrap_or_else(|_| "info".to_string())); - } - modify_ckb_config(&mut ckb_config); fs::write( &ckb_config_path, From 1946d8957658c0267c7c23c32d6cf68e4d225ba4 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 2 Oct 2019 16:42:34 +0900 Subject: [PATCH 3/8] docs: Update PoW mining algorithm description --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eec44bb946b..fc1e12f287c 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ TBD. ## Mining -Mining on testnet Rylai is for testing purpose only, the mining algorithm **WILL BE CHANGED SOON**. +Testnet Rylai uses the [Eaglesong](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0010-eaglesong/0010-eaglesong.md) mining algorithm, which the mainnet is going to use too. Mining on testnet is for testing purpose only. At this time Rylai will be **RESET** every two weeks. From 1498d48b9aec6d5f43a781f00de9bbdb8f64de3f Mon Sep 17 00:00:00 2001 From: driftluo Date: Tue, 8 Oct 2019 21:56:49 +0800 Subject: [PATCH 4/8] test: disconncet check by all part --- test/src/specs/sync/ibd_process.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/src/specs/sync/ibd_process.rs b/test/src/specs/sync/ibd_process.rs index ee2b02c7c59..a5176c9dca7 100644 --- a/test/src/specs/sync/ibd_process.rs +++ b/test/src/specs/sync/ibd_process.rs @@ -139,6 +139,17 @@ impl Spec for IBDProcessWithWhiteList { } node6.disconnect(node0); + + // Make sure both sides are disconnected + let is_disconnect_already = wait_until(10, || { + let peers = rpc_client0.get_peers(); + peers.iter().any(|peer| peer.node_id == node6.node_id()) + }); + + if is_disconnect_already { + panic!("node6 can't disconnect with node0"); + } + node6.generate_blocks(2); let generate_res = wait_until(10, || net.nodes[6].get_tip_block_number() == 2); @@ -147,7 +158,8 @@ impl Spec for IBDProcessWithWhiteList { panic!("node6 can't generate blocks to 2"); } - node0.connect_uncheck(node6); + // Make sure node0 re-connect with node6 + node0.connect(node6); // IBD only with outbound/whitelist node let rpc_client1 = node1.rpc_client(); From 799b57f5f69b794317e2e8987c1a5511efa2c80e Mon Sep 17 00:00:00 2001 From: zhangsoledad <787953403@qq.com> Date: Fri, 4 Oct 2019 21:22:29 +0800 Subject: [PATCH 5/8] test: get_block_transactions_process should fill missing uncle in response --- test/src/main.rs | 1 + .../relay/get_block_transactions_process.rs | 77 +++++++++++++++++++ test/src/specs/relay/mod.rs | 2 + 3 files changed, 80 insertions(+) create mode 100644 test/src/specs/relay/get_block_transactions_process.rs diff --git a/test/src/main.rs b/test/src/main.rs index 745d6ec03fe..fa4f4c620bb 100644 --- a/test/src/main.rs +++ b/test/src/main.rs @@ -286,6 +286,7 @@ fn all_specs() -> SpecMap { Box::new(ProposeButNotCommit), Box::new(ProposeDuplicated), Box::new(ForkedTransaction), + Box::new(MissingUncleRequest), ]; specs.into_iter().map(|spec| (spec.name(), spec)).collect() } diff --git a/test/src/specs/relay/get_block_transactions_process.rs b/test/src/specs/relay/get_block_transactions_process.rs new file mode 100644 index 00000000000..65334d30549 --- /dev/null +++ b/test/src/specs/relay/get_block_transactions_process.rs @@ -0,0 +1,77 @@ +use crate::{Net, Spec, TestProtocol}; +use ckb_sync::NetworkProtocol; +use ckb_types::{ + core::UncleBlockView, + packed::{self, RelayMessage}, + prelude::*, +}; + +pub struct MissingUncleRequest; + +impl Spec for MissingUncleRequest { + crate::name!("missing_uncle_request"); + + crate::setup!(protocols: vec![TestProtocol::sync(), TestProtocol::relay()]); + + // Case: Send to node GetBlockTransactions with missing uncle index, node should response BlockTransactions with uncles + fn run(&self, net: &mut Net) { + net.exit_ibd_mode(); + let node = &net.nodes[0]; + net.connect(node); + let (peer_id, _, _) = net.receive(); + + node.generate_block(); + let _ = net.receive(); + + let builder = node.new_block_builder(None, None, None); + let block1 = builder.clone().nonce(0.pack()).build(); + let block2 = builder.clone().nonce(1.pack()).build(); + node.submit_block(&block1.data()); + node.submit_block(&block2.data()); + + let builder = node.new_block_builder(None, None, None); + let block = builder + .clone() + .set_uncles(vec![block2.as_uncle()]) + .nonce(0.pack()) + .build(); + node.submit_block(&block.data()); + + let content = packed::GetBlockTransactions::new_builder() + .block_hash(block.hash()) + .uncle_indexes(vec![0u32].pack()) + .build(); + let message = packed::RelayMessage::new_builder().set(content).build(); + + (0..3).for_each(|_| { + net.receive(); // ignore three new block announce + }); + + net.send( + NetworkProtocol::RELAY.into(), + peer_id, + message.as_slice().into(), + ); + + let (_, _, data) = net.receive(); + let message = RelayMessage::from_slice(&data).unwrap(); + + assert_eq!( + message.to_enum().item_name(), + packed::BlockTransactions::NAME, + "Node should reponse BlockTransactions message", + ); + + if let packed::RelayMessageUnionReader::BlockTransactions(reader) = + message.to_enum().as_reader() + { + let block_transactions = reader.to_entity(); + let received_uncles: Vec = block_transactions + .uncles() + .into_iter() + .map(|uncle| uncle.into_view()) + .collect(); + assert_eq!(received_uncles[0], block2.as_uncle()); + } + } +} diff --git a/test/src/specs/relay/mod.rs b/test/src/specs/relay/mod.rs index 2f47d792f8b..a07082d0b6c 100644 --- a/test/src/specs/relay/mod.rs +++ b/test/src/specs/relay/mod.rs @@ -1,7 +1,9 @@ mod block_relay; mod compact_block; +mod get_block_transactions_process; mod transaction_relay; pub use block_relay::*; pub use compact_block::*; +pub use get_block_transactions_process::*; pub use transaction_relay::*; From e34637188837f544b9f3cf4e847ee0082f159815 Mon Sep 17 00:00:00 2001 From: zhangsoledad <787953403@qq.com> Date: Wed, 9 Oct 2019 11:43:38 +0800 Subject: [PATCH 6/8] chore: issuance comment --- spec/src/consensus.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/src/consensus.rs b/spec/src/consensus.rs index 90ac1daff13..91b55e5217d 100644 --- a/spec/src/consensus.rs +++ b/spec/src/consensus.rs @@ -24,8 +24,9 @@ use ckb_types::{ use std::cmp; use std::sync::Arc; -// TODO: add secondary reward for miner +// 1.344 billion per year pub(crate) const DEFAULT_SECONDARY_EPOCH_REWARD: Capacity = Capacity::shannons(613_698_63013698); +// 4.2 billion per year pub(crate) const INITIAL_PRIMARY_EPOCH_REWARD: Capacity = Capacity::shannons(1_917_808_21917808); const MAX_UNCLE_NUM: usize = 2; pub(crate) const TX_PROPOSAL_WINDOW: ProposalWindow = ProposalWindow(2, 10); @@ -34,7 +35,7 @@ pub(crate) const TX_PROPOSAL_WINDOW: ProposalWindow = ProposalWindow(2, 10); // This is to reduce the risk of later txs being reversed if a chain reorganization occurs. pub(crate) const CELLBASE_MATURITY: EpochNumberWithFraction = EpochNumberWithFraction::new_unchecked(4, 0, 1); -// TODO: should adjust this value based on CKB average block time + const MEDIAN_TIME_BLOCK_COUNT: usize = 37; // dampening factor From 675980334a23815b7a34ad69416ba928ad8ef860 Mon Sep 17 00:00:00 2001 From: zhangsoledad <787953403@qq.com> Date: Wed, 9 Oct 2019 16:38:01 +0800 Subject: [PATCH 7/8] chore: speed up maturity test --- test/src/specs/tx_pool/reference_header_maturity.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/src/specs/tx_pool/reference_header_maturity.rs b/test/src/specs/tx_pool/reference_header_maturity.rs index b4f6e5d509d..2da401da6fe 100644 --- a/test/src/specs/tx_pool/reference_header_maturity.rs +++ b/test/src/specs/tx_pool/reference_header_maturity.rs @@ -108,6 +108,8 @@ impl Spec for ReferenceHeaderMaturity { fn modify_chain_spec(&self) -> Box ()> { Box::new(|spec_config| { spec_config.params.cellbase_maturity = CELLBASE_MATURITY_VALUE; + spec_config.params.epoch_duration_target = 30; + spec_config.params.genesis_epoch_length = 5; }) } } From 014fe925489300bfa76be46849e66fb09dc8265d Mon Sep 17 00:00:00 2001 From: zhangsoledad <787953403@qq.com> Date: Wed, 9 Oct 2019 16:01:48 +0800 Subject: [PATCH 8/8] ci: Make sure cargo-audit up-to-date --- .travis.yml | 5 +++++ Makefile | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f15ed451d92..0a7ec8e9088 100644 --- a/.travis.yml +++ b/.travis.yml @@ -80,6 +80,11 @@ matrix: - make check-cargotoml - make check-whitespaces - make check-dirty-rpc-doc + - name: Security Audit + if: 'tag IS NOT present AND (type = pull_request OR branch in (master, staging, trying) OR repo != nervosnetwork/ckb)' + os: linux + rust: nightly + script: make security-audit - name: Test benchmarks on Linux env: CACHE_NAME=bench diff --git a/Makefile b/Makefile index f58ec2f5b82..b199bb380b1 100644 --- a/Makefile +++ b/Makefile @@ -107,8 +107,8 @@ clippy: setup-ckb-test ## Run linter to examine Rust source codes. .PHONY: security-audit security-audit: ## Use cargo-audit to audit Cargo.lock for crates with security vulnerabilities. - @cargo audit --version || cargo install cargo-audit - @cargo audit + @cargo +nightly install cargo-audit -Z install-upgrade + cargo audit # expecting to see "Success No vulnerable packages found" .PHONY: bench-test