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

add use selec_head to update startinfo and add some testing case #3972

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
66 changes: 45 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ api-limiter = { path = "commons/api-limiter" }
arc-swap = "1.5.1"
arrayref = "0.3"
ascii = "1.0.0"
async-std = "1.12"
async-std = { version = "1.12", features = ["attributes", "tokio1"] }
async-trait = "0.1.53"
asynchronous-codec = "0.5"
atomic-counter = "1.0.1"
Expand All @@ -257,6 +257,9 @@ bcs-ext = { path = "commons/bcs_ext" }
bech32 = "0.9"
bencher = "0.1.5"
bitflags = "1.3.2"
faster-hex = "0.6"
indexmap = "1.9.1"
bincode = { version = "1", default-features = false }
bs58 = "0.3.1"
byteorder = "1.3.4"
bytes = "1"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl ChainBencher {
let block = ConsensusStrategy::Dummy
.create_block(block_template, self.net.time_service().as_ref())
.unwrap();
self.chain.write().apply(block).unwrap();
self.chain.write().apply(block, None, &mut None).unwrap();
}
}

Expand Down
22 changes: 16 additions & 6 deletions block-relayer/src/block_relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,18 @@ impl BlockRelayer {
&self,
network: NetworkServiceRef,
executed_block: Arc<ExecutedBlock>,
tips_header: Option<Vec<HashValue>>,
) {
if !self.is_nearly_synced() {
debug!("[block-relay] Ignore NewHeadBlock event because the node has not been synchronized yet.");
return;
}
let compact_block = executed_block.block().clone().into();
let compact_block_msg =
CompactBlockMessage::new(compact_block, executed_block.block_info.clone());
let compact_block_msg = CompactBlockMessage::new(
compact_block,
executed_block.block_info.clone(),
tips_header,
);
network.broadcast(NotificationMessage::CompactBlock(Box::new(
compact_block_msg,
)));
Expand Down Expand Up @@ -203,7 +207,9 @@ impl BlockRelayer {
ctx: &mut ServiceContext<BlockRelayer>,
) -> Result<()> {
let network = ctx.get_shared::<NetworkServiceRef>()?;
let block_connector_service = ctx.service_ref::<BlockConnectorService>()?.clone();
let block_connector_service = ctx
.service_ref::<BlockConnectorService<TxPoolService>>()?
.clone();
let txpool = self.txpool.clone();
let metrics = self.metrics.clone();
let fut = async move {
Expand Down Expand Up @@ -238,7 +244,11 @@ impl BlockRelayer {
)
.await?;

block_connector_service.notify(PeerNewBlock::new(peer_id, block))?;
block_connector_service.notify(PeerNewBlock::new(
peer_id,
block,
compact_block_msg.message.tips_header,
))?;
}
Ok(())
};
Expand Down Expand Up @@ -286,7 +296,7 @@ impl EventHandler<Self, NewHeadBlock> for BlockRelayer {
return;
}
};
self.broadcast_compact_block(network, event.0);
self.broadcast_compact_block(network, event.0, event.1);
}
}

Expand All @@ -303,7 +313,7 @@ impl EventHandler<Self, NewBranch> for BlockRelayer {
return;
}
};
self.broadcast_compact_block(network, event.0);
self.broadcast_compact_block(network, event.0, event.1);
}
}

Expand Down
Loading
Loading