From 40192d95ce0127b5106d3a7bedd2170e9bde3015 Mon Sep 17 00:00:00 2001 From: Roshan Date: Mon, 15 Jul 2024 14:48:31 +0800 Subject: [PATCH] fix: add exception for slash system transaction --- crates/bsc/evm/src/execute.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/bsc/evm/src/execute.rs b/crates/bsc/evm/src/execute.rs index cb4362f05..18cebc5dd 100644 --- a/crates/bsc/evm/src/execute.rs +++ b/crates/bsc/evm/src/execute.rs @@ -18,7 +18,7 @@ use reth_evm::{ }; use reth_primitives::{ parlia::{ParliaConfig, Snapshot, VoteAddress, CHECKPOINT_INTERVAL}, - system_contracts::get_upgrade_system_contracts, + system_contracts::{get_upgrade_system_contracts, SLASH_CONTRACT}, Address, BlockNumber, BlockWithSenders, Bytes, Header, Receipt, Transaction, TransactionSigned, B256, BSC_MAINNET, U256, }; @@ -34,7 +34,7 @@ use revm_primitives::{ BlockEnv, CfgEnvWithHandlerCfg, EVMError, EnvWithHandlerCfg, ResultAndState, TransactTo, }; use std::{collections::HashMap, num::NonZeroUsize, sync::Arc, time::Instant}; -use tracing::debug; +use tracing::{debug, warn}; const SNAP_CACHE_NUM: usize = 2048; @@ -605,6 +605,14 @@ where transaction.set_nonce(nonce); let hash = transaction.signature_hash(); if system_txs.is_empty() || hash != system_txs[0].signature_hash() { + // slash tx could fail and not in the block + if let Some(to) = transaction.to() { + if to == SLASH_CONTRACT.parse().unwrap() { + warn!("slash validator failed"); + return Ok(()); + } + } + debug!("unexpected transaction: {:?}", transaction); for tx in system_txs.iter() { debug!("left system tx: {:?}", tx);