Skip to content

Commit dd787d9

Browse files
authored
Merge branch 'develop' into rc/v0.203.x
2 parents fe23a53 + 154e9e3 commit dd787d9

File tree

9 files changed

+47
-62
lines changed

9 files changed

+47
-62
lines changed

Cargo.lock

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ url = "2.2.2"
308308
walkdir = "2.1.4"
309309
yansi = "0.5"
310310
seq-macro = "0.3"
311-
strum = { version = "0.27", features = ["derive"] }
311+
strum = { version = "0.27", default-features = false, features = ["derive"] }
312312
phf = { version = "0.12", features = ["macros"] }
313313

314314
[profile.release]

ckb-bin/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ ckb-stop-handler.workspace = true
4949
tokio = { workspace = true, features = ["sync"] }
5050

5151
[target.'cfg(not(target_os="windows"))'.dependencies]
52-
daemonize = { version = "0.5.0" }
52+
daemonize-me = { version = "2" }
5353
nix = { version = "0.29.0", default-features = false, features = ["signal"] }
5454
colored = "2.0"
5555

ckb-bin/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use setup_guard::SetupGuard;
2222
#[cfg(not(target_os = "windows"))]
2323
use colored::Colorize;
2424
#[cfg(not(target_os = "windows"))]
25-
use daemonize::Daemonize;
25+
use daemonize_me::Daemon;
2626
#[cfg(not(target_os = "windows"))]
2727
use subcommand::check_process;
2828
#[cfg(feature = "with_sentry")]
@@ -105,10 +105,7 @@ fn run_app_in_daemon(
105105
eprintln!("no ckb process, starting ...");
106106

107107
let pwd = std::env::current_dir()?;
108-
let daemon = Daemonize::new()
109-
.pid_file(pid_file)
110-
.chown_pid_file(true)
111-
.working_directory(pwd);
108+
let daemon = Daemon::new().pid_file(pid_file, Some(false)).work_dir(pwd);
112109

113110
match daemon.start() {
114111
Ok(_) => {

devtools/release/publish-crates.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ retry_cargo_publish() {
1414
-e '/^\[dev-dependencies\]/, /^\[/ { /^[^\[]/d }' \
1515
-e '/# dev-feature$/d' \
1616
-e '/^ckb-test\.workspace/d' \
17-
-e '/^ckb-test\.workspace/d' \
1817
-e '/^ckb-test = .*version/d' \
1918
Cargo.toml
2019

network/src/protocols/discovery/mod.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use self::{
2020
protocol::{decode, encode},
2121
state::RemoteAddress,
2222
};
23-
use crate::{Flags, NetworkState, ProtocolId, SupportProtocols};
23+
use crate::{Flags, NetworkState, ProtocolId};
2424

2525
mod addr;
2626
pub(crate) mod protocol;
@@ -79,17 +79,6 @@ impl<M: AddressManager + Send + Sync> ServiceProtocol for DiscoveryProtocol<M> {
7979
{
8080
self.sessions
8181
.insert(session.id, SessionState::new(context, &self.addr_mgr).await);
82-
} else if let Err(e) = context
83-
.close_protocol(
84-
context.session.id,
85-
SupportProtocols::Discovery.protocol_id(),
86-
)
87-
.await
88-
{
89-
error!(
90-
"Block-Relay-Only Session close DiscoveryProtocol failed, session: {:?} {}",
91-
context.session, e
92-
);
9382
}
9483
}
9584

network/src/protocols/identify/mod.rs

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,12 @@ impl<T: Callback> ServiceProtocol for IdentifyProtocol<T> {
206206
async fn connected(&mut self, context: ProtocolContextMutRef<'_>, version: &str) {
207207
let session = context.session;
208208
debug!("IdentifyProtocol connected, session: {:?}", session);
209-
if self.callback.register(&context, version) {
210-
let remote_info =
211-
RemoteInfo::new(session.clone(), Duration::from_secs(DEFAULT_TIMEOUT));
212-
self.remote_infos.insert(session.id, remote_info);
213-
214-
let listen_addrs: Vec<Multiaddr> = self
215-
.callback
209+
let remote_info = RemoteInfo::new(session.clone(), Duration::from_secs(DEFAULT_TIMEOUT));
210+
self.remote_infos.insert(session.id, remote_info);
211+
let listen_addrs = if self.callback.register(&context, version) {
212+
Vec::new()
213+
} else {
214+
self.callback
216215
.local_listen_addrs()
217216
.iter()
218217
.filter(|addr| {
@@ -222,24 +221,15 @@ impl<T: Callback> ServiceProtocol for IdentifyProtocol<T> {
222221
})
223222
.take(MAX_ADDRS)
224223
.cloned()
225-
.collect();
226-
227-
let identify = self.callback.identify();
228-
let data =
229-
IdentifyMessage::new(listen_addrs, session.address.clone(), identify).encode();
230-
let _ = context
231-
.quick_send_message(data)
232-
.await
233-
.map_err(|err| error!("IdentifyProtocol quick_send_message, error: {:?}", err));
234-
} else if let Err(e) = context
235-
.close_protocol(context.session.id, SupportProtocols::Identify.protocol_id())
224+
.collect()
225+
};
226+
227+
let identify = self.callback.identify();
228+
let data = IdentifyMessage::new(listen_addrs, session.address.clone(), identify).encode();
229+
let _ = context
230+
.quick_send_message(data)
236231
.await
237-
{
238-
error!(
239-
"Block-Relay-Only Session close IdentifyProtocol failed, session: {:?} {}",
240-
context.session, e
241-
);
242-
}
232+
.map_err(|err| error!("IdentifyProtocol quick_send_message, error: {:?}", err));
243233
}
244234

245235
async fn disconnected(&mut self, context: ProtocolContextMutRef<'_>) {
@@ -363,17 +353,12 @@ impl IdentifyCallback {
363353
impl Callback for IdentifyCallback {
364354
fn register(&self, context: &ProtocolContextMutRef, version: &str) -> bool {
365355
let session_id = context.session.id;
366-
let is_anchor = self
367-
.network_state
368-
.with_peer_registry(|reg| reg.is_anchor(session_id));
369-
if !is_anchor {
370-
self.network_state.with_peer_registry_mut(|reg| {
371-
reg.get_peer_mut(session_id).map(|peer| {
372-
peer.protocols.insert(context.proto_id, version.to_owned());
373-
})
374-
});
375-
}
376-
!is_anchor
356+
self.network_state.with_peer_registry_mut(|reg| {
357+
if let Some(peer) = reg.get_peer_mut(session_id) {
358+
peer.protocols.insert(context.proto_id, version.to_owned());
359+
}
360+
reg.is_anchor(session_id)
361+
})
377362
}
378363

379364
fn unregister(&self, context: &ProtocolContextMutRef) {

sync/src/filter/get_block_filters_process.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,22 @@ impl<'a> GetBlockFiltersProcess<'a> {
3838
if latest >= start_number {
3939
let mut block_hashes = Vec::new();
4040
let mut filters = Vec::new();
41+
let mut current_content_size = 0;
42+
current_content_size += 8; // Size of start_number
43+
4144
for block_number in start_number..start_number + BATCH_SIZE {
4245
if let Some(block_hash) = active_chain.get_block_hash(block_number) {
4346
if let Some(block_filter) = active_chain.get_block_filter(&block_hash) {
47+
if current_content_size
48+
+ block_hash.as_slice().len()
49+
+ block_filter.as_slice().len()
50+
>= 2 * 1024 * 1024
51+
{
52+
// Break if the encoded size of `block_hash` + `block_filter` + `start_number` reaches 2MB, to avoid frame size too large
53+
break;
54+
}
55+
current_content_size +=
56+
block_hash.as_slice().len() + block_filter.as_slice().len();
4457
block_hashes.push(block_hash);
4558
filters.push(block_filter);
4659
} else {

util/indexer-sync/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ impl IndexerSyncService {
138138
where
139139
I: IndexerSync + Clone + Send + 'static,
140140
{
141-
if let Err(e) = self.secondary_db.try_catch_up_with_primary() {
142-
error!("secondary_db try_catch_up_with_primary error {}", e);
143-
}
144141
loop {
142+
if let Err(e) = self.secondary_db.try_catch_up_with_primary() {
143+
error!("secondary_db try_catch_up_with_primary error {}", e);
144+
}
145145
if has_received_stop_signal() {
146146
info!("try_loop_sync received exit signal, exit now");
147147
break;

0 commit comments

Comments
 (0)