mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Make impersonated tx rule more strict
This commit is contained in:
@ -7,7 +7,7 @@ use crate::{
|
||||
use alloc::{fmt, vec::Vec};
|
||||
use alloy_consensus::{
|
||||
transaction::{PooledTransaction, Recovered},
|
||||
SignableTransaction,
|
||||
SignableTransaction, Transaction,
|
||||
};
|
||||
use alloy_eips::eip2718::{Decodable2718, Encodable2718};
|
||||
use alloy_primitives::{keccak256, Address, PrimitiveSignature as Signature, TxHash, B256};
|
||||
@ -18,6 +18,15 @@ use revm_primitives::{address, U256};
|
||||
pub trait FullSignedTx: SignedTransaction + MaybeCompact + MaybeSerdeBincodeCompat {}
|
||||
impl<T> FullSignedTx for T where T: SignedTransaction + MaybeCompact + MaybeSerdeBincodeCompat {}
|
||||
|
||||
/// Check if the transaction is impersonated.
|
||||
/// Signature part is introduced in block_ingest, while the gas_price is trait of hyperliquid system transactions.
|
||||
pub fn is_impersonated_tx(signature: &Signature, gas_price: Option<u128>) -> bool {
|
||||
signature.r() == U256::from(1)
|
||||
&& signature.s() == U256::from(1)
|
||||
&& signature.v() == true
|
||||
&& gas_price == Some(0u128)
|
||||
}
|
||||
|
||||
/// A signed transaction.
|
||||
#[auto_impl::auto_impl(&, Arc)]
|
||||
pub trait SignedTransaction:
|
||||
@ -168,8 +177,7 @@ impl SignedTransaction for PooledTransaction {
|
||||
buf: &mut Vec<u8>,
|
||||
) -> Result<Address, RecoveryError> {
|
||||
let signature = self.signature();
|
||||
if signature.r() == U256::from(1) && signature.s() == U256::from(1) && signature.v() == true
|
||||
{
|
||||
if is_impersonated_tx(signature, self.gas_price()) {
|
||||
return Ok(address!("2222222222222222222222222222222222222222"));
|
||||
}
|
||||
match self {
|
||||
|
||||
Reference in New Issue
Block a user