Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
1664: chore: update get_block_template rpc doc r=quake,u2,keroro520,yangby-cryptape a=shaojunda

replace difficulty with compact_target

1669: chore(test): Allow CI debug logs r=u2,zhangsoledad a=keroro520

The number of logs is acceptable after #1474. 

1671: test: disconnect check by all part r=u2,keroro520,quake a=driftluo

Disconnect check by all part

1673: docs: Update PoW mining algorithm description r=u2,quake a=ashchan

Now that this has been decided the doc should reflect that before the next round of mining test.

1680: fix: get_block_transactions_process r=u2,quake a=zhangsoledad



1689: chore: issuance comment r=u2,quake a=zhangsoledad

comments were lost on rebase

1690: ci: Make sure cargo-audit up-to-date r=quake,u2 a=zhangsoledad

rustsec/rustsec#143
https://internals.rust-lang.org/t/idea-cargo-install-update/11072
rust-lang/cargo#6797



1691: chore: speed up maturity test r=u2,quake a=zhangsoledad



Co-authored-by: shaojunda <shaojunda@gmail.com>
Co-authored-by: keroro520 <keroroxx520@gmail.com>
Co-authored-by: driftluo <driftluo@foxmail.com>
Co-authored-by: James Chen <james@ashchan.com>
Co-authored-by: zhangsoledad <787953403@qq.com>
  • Loading branch information
6 people committed Oct 10, 2019
9 parents c9d667b + c60d730 + d6aa09a + 1498d48 + 1946d89 + 799b57f + e346371 + 014fe92 + 6759803 commit 0ff4548
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion rpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1533,10 +1533,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",
Expand Down
2 changes: 1 addition & 1 deletion rpc/json/rpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@
"current_time": "0x16d6269e84f",
"cycles_limit": "0x2540be400",
"dao": "0x004fb9e277860700b2f80165348723003d1862ec960000000028eb3d7e7a0100",
"difficulty": "0x100",
"compact_target": "0x100",
"epoch": "0x3e80001000000",
"number": "0x1",
"parent_hash": "0xd5c495b7dd4d9d066a6a4d4356bc31955ad3199e0d856f34cfbe159c46ee335b",
Expand Down
5 changes: 3 additions & 2 deletions spec/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
5 changes: 0 additions & 5 deletions test/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,6 @@ impl Node {
message: Default::default(),
});

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,
Expand Down
77 changes: 77 additions & 0 deletions test/src/specs/relay/get_block_transactions_process.rs
Original file line number Diff line number Diff line change
@@ -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<UncleBlockView> = block_transactions
.uncles()
.into_iter()
.map(|uncle| uncle.into_view())
.collect();
assert_eq!(received_uncles[0], block2.as_uncle());
}
}
}
2 changes: 2 additions & 0 deletions test/src/specs/relay/mod.rs
Original file line number Diff line number Diff line change
@@ -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::*;
14 changes: 13 additions & 1 deletion test/src/specs/sync/ibd_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions test/src/specs/tx_pool/reference_header_maturity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ impl Spec for ReferenceHeaderMaturity {
fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec) -> ()> {
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;
})
}
}

0 comments on commit 0ff4548

Please sign in to comment.