Skip to content

parlia: opt consensus perf and FF stability;#267

Open
galaio wants to merge 3 commits intobnb-chain:developfrom
galaio:opt-parlia
Open

parlia: opt consensus perf and FF stability;#267
galaio wants to merge 3 commits intobnb-chain:developfrom
galaio:opt-parlia

Conversation

@galaio
Copy link
Contributor

@galaio galaio commented Feb 10, 2026

Description

This PR primarily optimizes consensus performance and FF stability, enabling reth-bsc to produce blocks and complete finalization in lower latency scenarios.

Specific optimizations:

  1. Added Fast Attestation feature, see: BEP648: Enhanced Fast Finality via InMemory Voting Pool bsc#3520;
  2. Supported delayed sealing, optimized tokio scheduling, and improved FF stability;
  3. Used system_contracts cache to avoid duplicate generation;
  4. Optimized FF logic to prevent initial Attestation from failing to generate.
  5. Fixed some other corner cases, and optimized logs and metrics;

Changes

Notable changes:

  • parlia: opt consensus perf and FF stability;
  • ...


}

async fn check_fast_atteatation(vote: VoteEnvelope) -> Result<(), eyre::Error> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async fn check_fast_atteatation(vote: VoteEnvelope) -> Result<(), eyre::Error> {
async fn check_fast_attestation(vote: VoteEnvelope) -> Result<(), eyre::Error> {

Comment on lines +578 to +586
// TODO: remove it now, miner can produce block until timeout.
// let mut time_for_mining_ms = period_ms / 2;
// let last_block_in_turn = snap.last_block_in_one_turn(header.number);
// if !last_block_in_turn {
// time_for_mining_ms = period_ms;
// }
// if delay_ms > time_for_mining_ms {
// delay_ms = time_for_mining_ms;
// }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we keep it?

// once one attestation generated, attestation of snap would not be nil forever basically
// ref: https://github.com/bnb-chain/bsc/blob/583cfec3ea811fb124e6812aabd190555d5aeabc/consensus/parlia/parlia.go#L2161
if justified_hash == B256::ZERO {
match get_cannonical_header_from_cache(0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
match get_cannonical_header_from_cache(0) {
match get_canonical_header_from_cache(0) {

reth-chainspec = { git = "https://github.com/bnb-chain/reth.git", tag = "v0.0.7" }
reth-cli-util = { git = "https://github.com/bnb-chain/reth.git", tag = "v0.0.7" }
reth-discv4 = { git = "https://github.com/bnb-chain/reth.git", tag = "v0.0.7", features = [
reth = { git = "https://github.com/galaio/bnb-reth.git", rev = "f3d3416a47059c8815891eee9997cb15b32b473a" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please be sure our are using https://github.com/bnb-chain/reth/tree/rebase-v1.10.2-bnb as we rebased the old reth and the history will not be the same

guard
.cur_votes
.get(&target_hash)
.map(|vm| vm.vote_messages.len())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quorum is calculated from raw pool count (vote_messages.len()), not validator-filtered/verified votes

if guard.notified_quorum_blocks.contains(&target_hash) {
return Ok(());
}
guard.notified_quorum_blocks.insert(target_hash);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happens before confirming event channel availability/send success. If send fails (or channel is not initialized), this block is permanently marked and future valid notifications are suppressed

}

// record finality duration in header
let finalized_header = get_header_by_hash_from_cache(&justified_hash)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metric collection is now in the attestation assembly critical path. If header lookup misses, we return error and skip attestation assembly.

total_job_duration_ms = total_job_duration.as_millis(),
"No best payload available, building empty payload as in-turn fallback"
);
warn!(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fallback empty payload is now built unconditionally when no best payload exists. Previously this was gated to in-turn behavior. Was this intentional? This may increase off-turn empty block attempts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants