Skip to content
This repository has been archived by the owner on Feb 6, 2025. It is now read-only.

Commit

Permalink
fix distribute_finality_reward error
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Jun 9, 2024
1 parent 61381b1 commit 4134e55
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
7 changes: 5 additions & 2 deletions crates/bsc/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,10 @@ where
transaction.set_nonce(nonce);
let hash = transaction.signature_hash();
if hash != system_txs[0].signature_hash() {
debug!("unexpected transaction: {:?}", transaction);
for tx in system_txs.iter() {
debug!("left system tx: {:?}", tx);
}
return Err(BscBlockExecutionError::UnexpectedSystemTx.into());
}
system_txs.remove(0);
Expand Down Expand Up @@ -650,8 +654,7 @@ where

// 1. get current validators info
if header.number % self.parlia().epoch() == 0 {
let (validators, vote_addrs) =
self.get_current_validators(parent.number, env.clone());
let (validators, vote_addrs) = self.get_current_validators(parent.number, env.clone());

let vote_addrs_map = if vote_addrs.is_empty() {
HashMap::new()
Expand Down
14 changes: 9 additions & 5 deletions crates/bsc/evm/src/post_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,18 +332,22 @@ where

let validator = header.beneficiary;
let mut accumulated_weights: HashMap<Address, U256> = HashMap::new();
let start = (header.number - self.parlia().epoch()).max(1);

for _ in (start..header.number).rev() {
let parent_header = self.get_header_by_hash(header.parent_hash)?;
let start = (header.number - self.parlia().epoch()).max(1);
let end = header.number;
let mut target_hash = header.parent_hash;
for _ in (start..end).rev() {
let header = &(self.get_header_by_hash(target_hash)?);

if let Some(attestation) =
self.parlia().get_vote_attestation_from_header(&parent_header).map_err(|err| {
self.parlia().get_vote_attestation_from_header(header).map_err(|err| {
BscBlockExecutionError::ParliaConsensusInnerError { error: err.into() }
})?
{
self.process_attestation(&attestation, &parent_header, &mut accumulated_weights)?;
self.process_attestation(&attestation, header, &mut accumulated_weights)?;
}

target_hash = header.parent_hash;
}

let mut validators: Vec<Address> = accumulated_weights.keys().cloned().collect();
Expand Down
2 changes: 1 addition & 1 deletion crates/stages/stages/src/stages/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ where

let mut blocks = Vec::new();
for block_number in start_block..=max_block {
if block_number % 100 == 0 {
if block_number % 1000 == 0 {
info!(target: "sync::stages::execution", "Executing block {:?}", block_number);
}

Expand Down

0 comments on commit 4134e55

Please sign in to comment.