Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] merge several fixes into 118 for next rc release #4616

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
6be1671
Fix the possible cycling attack in RBF
chenyukang Jul 31, 2024
158cfa9
code refactor
chenyukang Jul 31, 2024
db66275
cleanup and add assertion for process_rbf
chenyukang Aug 1, 2024
2c2b1f1
add verify log for monitor
chenyukang Aug 20, 2024
fbe63f4
Integration Test: wait find unverified blocks finish for all specs
eval-exec Aug 22, 2024
47dc5ed
add ignore item in deny.toml.
EthanYuan Aug 22, 2024
83ac99f
Merge pull request #4605 from eval-exec/exec/fix-ci-2
eval-exec Aug 22, 2024
2c057db
Fix SendLargeCyclesTxToRelay on slow machine
chenyukang Aug 22, 2024
0ceb6f8
Merge pull request #4606 from chenyukang/yukang-fix-relay-ci-issue
chenyukang Aug 22, 2024
3bd5fed
Merge pull request #4600 from chenyukang/yukang-add-verify-log
chenyukang Aug 23, 2024
7bfc1e1
add clear verify queue rpc
chenyukang Aug 23, 2024
ce41807
verify worker exit when signal_exit is_cancelled
chenyukang Aug 24, 2024
dc20e94
Make sure the uncle block timestamp is different from the next block …
chenyukang Aug 25, 2024
76ebab4
Merge pull request #4611 from chenyukang/yukang-debug-chain-fork-spec
chenyukang Aug 25, 2024
8744829
Merge pull request #4612 from chenyukang/yukang-fix-verify-queue-exit
chenyukang Aug 25, 2024
6ee85c3
Merge pull request #4609 from chenyukang/yukang-clear-verify-queue
chenyukang Aug 26, 2024
e48f664
Do not start BlockDownload thread if ckb has received exit signal
eval-exec Aug 26, 2024
7304ea7
Merge pull request #4615 from eval-exec/exec/exit-blockdownload-if-Bl…
chenyukang Aug 27, 2024
47f92ff
Early return init_load_unverified thread when no unverified blocks fo…
eval-exec Aug 27, 2024
d28bde6
Integration Test: add more log for SyncChurn
eval-exec Aug 27, 2024
3675433
Merge pull request #4617 from eval-exec/exec/early-return-init-load-u…
driftluo Aug 27, 2024
48c09c2
Integration Test: kill_gracefully on RandomlyKill
eval-exec Aug 28, 2024
50b74a2
Merge pull request #4622 from eval-exec/exec/kill-gracefully-on-integ…
eval-exec Aug 28, 2024
3a40e37
Do not kill gracefully on windows
eval-exec Aug 29, 2024
f9c3c70
Merge pull request #4624 from eval-exec/exec/fix/widnows-ci
eval-exec Aug 29, 2024
258676a
fix: fix atomic ordering in multi-thread
driftluo Aug 28, 2024
114a11f
test
eval-exec Aug 29, 2024
7749bcb
Merge pull request #4625 from eval-exec/exec/ci/windows
eval-exec Aug 30, 2024
2fb17ab
Merge pull request #4623 from driftluo/fix-atomic-ordering
eval-exec Aug 30, 2024
c789b83
Rename ckb_chain::consume_unverified to ckb_chain::verify
eval-exec Aug 30, 2024
b86e176
test: add check relax ordering on ci
driftluo Aug 30, 2024
b30e378
Merge branch 'develop' into yukang-fix-cycling-attack-rbf
chenyukang Aug 30, 2024
3d78da8
chore: remove all relax order
driftluo Aug 30, 2024
a73b7f4
Merge pull request #4561 from chenyukang/yukang-fix-cycling-attack-rbf
quake Sep 2, 2024
6332b10
add retry for git clone in cli_test
chenyukang Sep 2, 2024
9d8e976
CI: windows integration use windows-latest
eval-exec Sep 2, 2024
ea3651f
Merge branch 'develop' into ci-check-relaxed
chenyukang Sep 2, 2024
4919219
Merge pull request #4626 from eval-exec/exec/rename-consume-unverifie…
eval-exec Sep 2, 2024
6fa274e
Merge pull request #4631 from eval-exec/exec/ci/windows-2022
eval-exec Sep 2, 2024
0e99a2a
Merge pull request #4627 from driftluo/ci-check-relaxed
eval-exec Sep 2, 2024
72b735c
Merge pull request #4630 from chenyukang/yukang-add-retry-for-ci
chenyukang Sep 2, 2024
d398e5a
Fix script test error
chenyukang Aug 12, 2024
cf78552
enlarge spec wait time
chenyukang Aug 13, 2024
2e100d8
add logs for script test
chenyukang Aug 13, 2024
0274984
Merge pull request #4581 from chenyukang/yukang-fix-script-test
eval-exec Sep 2, 2024
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
9 changes: 9 additions & 0 deletions chain/src/init_load_unverified.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ impl InitLoadUnverified {
let unverified_hashes: Vec<packed::Byte32> =
self.find_unverified_block_hashes(check_unverified_number);

if check_unverified_number > tip_number && unverified_hashes.is_empty() {
info!(
"no unverified blocks found after tip, current tip: {}-{}",
tip_number,
self.shared.snapshot().tip_hash()
);
return;
}

for unverified_hash in unverified_hashes {
f(&unverified_hash);
}
Expand Down
4 changes: 4 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ feature-depth = 1
# A list of advisory IDs to ignore. Note that ignored advisories will still
# output a note when they are encountered.
ignore = [
# https://rustsec.org/advisories/RUSTSEC-2024-0363
# https://github.com/launchbadge/sqlx/issues/3440
# The queries for the rich indexer receive input parameters via RPC, and the data size is far less than 4GB, so this issue can be temporarily ignored while waiting for sqlx to be fixed.
"RUSTSEC-2024-0363",
# https://rustsec.org/advisories/RUSTSEC-2022-0090
# It was sometimes possible for SQLite versions >= 1.0.12, < 3.39.2 to allow an array-bounds overflow when large string were input into SQLite's `printf` function.
"RUSTSEC-2022-0090",
Expand Down
32 changes: 32 additions & 0 deletions rpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ The crate `ckb-rpc`'s minimum supported rustc version is 1.71.1.
* [Method `remove_transaction`](#pool-remove_transaction)
* [Method `tx_pool_info`](#pool-tx_pool_info)
* [Method `clear_tx_pool`](#pool-clear_tx_pool)
* [Method `clear_tx_verify_queue`](#pool-clear_tx_verify_queue)
* [Method `get_raw_tx_pool`](#pool-get_raw_tx_pool)
* [Method `get_pool_tx_detail_info`](#pool-get_pool_tx_detail_info)
* [Method `tx_pool_ready`](#pool-tx_pool_ready)
Expand Down Expand Up @@ -4748,6 +4749,37 @@ Response
}
```

<a id="pool-clear_tx_verify_queue"></a>
#### Method `clear_tx_verify_queue`
* `clear_tx_verify_queue()`

* result: `null`

Removes all transactions from the verification queue.

###### Examples

Request

```json
{
"id": 42,
"jsonrpc": "2.0",
"method": "clear_tx_verify_queue",
"params": []
}
```

Response

```json
{
"id": 42,
"jsonrpc": "2.0",
"result": null
}
```

<a id="pool-get_raw_tx_pool"></a>
#### Method `get_raw_tx_pool`
* `get_raw_tx_pool(verbose)`
Expand Down
36 changes: 36 additions & 0 deletions rpc/src/module/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,33 @@ pub trait PoolRpc {
#[rpc(name = "clear_tx_pool")]
fn clear_tx_pool(&self) -> Result<()>;

/// Removes all transactions from the verification queue.
///
/// ## Examples
///
/// Request
///
/// ```json
/// {
/// "id": 42,
/// "jsonrpc": "2.0",
/// "method": "clear_tx_verify_queue",
/// "params": []
/// }
/// ```
///
/// Response
///
/// ```json
/// {
/// "id": 42,
/// "jsonrpc": "2.0",
/// "result": null
/// }
/// ```
#[rpc(name = "clear_tx_verify_queue")]
fn clear_tx_verify_queue(&self) -> Result<()>;

/// Returns all transaction ids in tx pool as a json array of string transaction ids.
/// ## Params
///
Expand Down Expand Up @@ -662,6 +689,15 @@ impl PoolRpc for PoolRpcImpl {
Ok(())
}

fn clear_tx_verify_queue(&self) -> Result<()> {
let tx_pool = self.shared.tx_pool_controller();
tx_pool
.clear_verify_queue()
.map_err(|err| RPCError::custom(RPCError::Invalid, err.to_string()))?;

Ok(())
}

fn get_raw_tx_pool(&self, verbose: Option<bool>) -> Result<RawTxPool> {
let tx_pool = self.shared.tx_pool_controller();

Expand Down
5 changes: 5 additions & 0 deletions sync/src/synchronizer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,11 @@ impl Synchronizer {
return;
}

if ckb_stop_handler::has_received_stop_signal() {
info!("received stop signal, stop find_blocks_to_fetch");
return;
}

let unverified_tip = self.shared.active_chain().unverified_tip_number();

let disconnect_list = {
Expand Down
3 changes: 2 additions & 1 deletion test/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ impl Node {
let timestamp = block.timestamp();
let uncle = block
.as_advanced_builder()
.timestamp((timestamp + 1).pack())
.timestamp((timestamp - 1).pack())
.build();
(block, uncle)
}
Expand Down Expand Up @@ -701,6 +701,7 @@ impl Node {
}
};

self.wait_find_unverified_blocks_finished();
self.wait_tx_pool_ready();

self.set_process_guard(ProcessGuard {
Expand Down
5 changes: 5 additions & 0 deletions test/src/specs/sync/sync_churn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ impl Spec for SyncChurn {
if too_many_blocks || restart_stopped_rx.try_recv().is_ok() {
break;
}
info!(
"mining_node {}, tip: {}",
mining_node.node_id(),
mining_node.get_tip_block_number()
);
waiting_for_sync(&mining_nodes);
}
});
Expand Down
1 change: 1 addition & 0 deletions test/src/specs/tx_pool/send_large_cycles_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ impl Spec for SendLargeCyclesTxToRelay {
let node0 = &nodes[0];
let node1 = &nodes[1];

node0.mine_until_out_bootstrap_period();
node1.mine_until_out_bootstrap_period();
node0.connect(node1);
info!("Generate large cycles tx");
Expand Down
6 changes: 5 additions & 1 deletion tx-pool/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ impl TxPoolService {
self.process_orphan_tx(&tx).await;
}
Err(reject) => {
debug!(
info!(
"after_process {} {} remote reject: {} ",
tx_hash, peer, reject
);
Expand Down Expand Up @@ -686,6 +686,10 @@ impl TxPoolService {

if let Some(declared) = declared_cycles {
if declared != verified.cycles {
info!(
"process_tx declared cycles not match verified cycles, declared: {:?} verified: {:?}, tx: {:?}",
declared, verified.cycles, tx
);
return Some((
Err(Reject::DeclaredWrongCycles(declared, verified.cycles)),
snapshot,
Expand Down
12 changes: 12 additions & 0 deletions tx-pool/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pub(crate) enum Message {
GetTransactionWithStatus(Request<Byte32, GetTransactionWithStatusResult>),
NewUncle(Notify<UncleBlockView>),
ClearPool(Request<Arc<Snapshot>, ()>),
ClearVerifyQueue(Request<(), ()>),
GetAllEntryInfo(Request<(), TxPoolEntryInfo>),
GetAllIds(Request<(), TxPoolIds>),
SavePool(Request<(), ()>),
Expand Down Expand Up @@ -322,6 +323,11 @@ impl TxPoolController {
send_message!(self, ClearPool, new_snapshot)
}

/// Clears the tx-verify-queue.
pub fn clear_verify_queue(&self) -> Result<(), AnyError> {
send_message!(self, ClearVerifyQueue, ())
}

/// TODO(doc): @zhangsoledad
pub fn get_all_entry_info(&self) -> Result<TxPoolEntryInfo, AnyError> {
send_message!(self, GetAllEntryInfo, ())
Expand Down Expand Up @@ -914,6 +920,12 @@ async fn process(mut service: TxPoolService, message: Message) {
error!("Responder sending clear_pool failed {:?}", e)
};
}
Message::ClearVerifyQueue(Request { responder, .. }) => {
service.verify_queue.write().await.clear();
if let Err(e) = responder.send(()) {
error!("Responder sending clear_verify_queue failed {:?}", e)
};
}
Message::GetPoolTxDetails(Request {
responder,
arguments: tx_hash,
Expand Down
5 changes: 4 additions & 1 deletion tx-pool/src/verify_mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ impl Worker {

async fn process_inner(&mut self) {
loop {
if self.exit_signal.is_cancelled() {
info!("Verify worker::process_inner exit_signal is cancelled");
return;
}
if self.status != ChunkCommand::Resume {
return;
}
Expand Down Expand Up @@ -170,7 +174,6 @@ impl VerifyMgr {
}

fn send_child_command(&self, command: ChunkCommand) {
//info!("[verify-test] verify-mgr send child command: {:?}", command);
for w in &self.workers {
if let Err(err) = w.0.send(command.clone()) {
info!("send worker command failed, error: {}", err);
Expand Down
Loading