Skip to content

Commit

Permalink
fix: zero block reward issue (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 authored Jul 10, 2024
1 parent e2846d7 commit e11ee48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/bsc/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ where
let nonce = evm.db_mut().basic(sender).unwrap().unwrap_or_default().nonce;
transaction.set_nonce(nonce);
let hash = transaction.signature_hash();
if hash != system_txs[0].signature_hash() {
if system_txs.is_empty() || hash != system_txs[0].signature_hash() {
debug!("unexpected transaction: {:?}", transaction);
for tx in system_txs.iter() {
debug!("left system tx: {:?}", tx);
Expand Down
5 changes: 5 additions & 0 deletions crates/bsc/evm/src/post_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ where
let (mut block_reward, transition) = system_account.drain_balance();
self.state.apply_transition(vec![(SYSTEM_ADDRESS, transition)]);

// if block reward is zero, no need to distribute
if block_reward == 0 {
return Ok(());
}

let balance_increment = HashMap::from([(validator, block_reward)]);
self.state
.increment_balances(balance_increment)
Expand Down

0 comments on commit e11ee48

Please sign in to comment.