-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: L2 network cannot filter transactions (#47)
Co-authored-by: Thomas Nguy <[email protected]>
- Loading branch information
1 parent
9cdee2c
commit 120be37
Showing
14 changed files
with
182 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use std::collections::HashSet; | ||
|
||
use zksync_dal::transactions_dal::L2TxSubmissionResult; | ||
use zksync_types::{fee::TransactionExecutionMetrics, l2::L2Tx, Address}; | ||
|
||
use super::{tx_sink::TxSink, SubmitTxError}; | ||
use crate::tx_sender::MasterPoolSink; | ||
|
||
/// Wrapper for the master DB pool that allows to submit transactions to the mempool. | ||
#[derive(Debug)] | ||
pub struct DenyListPoolSink { | ||
deny_list: HashSet<Address>, | ||
master_pool_sync: MasterPoolSink, | ||
} | ||
|
||
impl DenyListPoolSink { | ||
pub fn new(master_pool_sync: MasterPoolSink, deny_list: HashSet<Address>) -> Self { | ||
Self { | ||
master_pool_sync, | ||
deny_list, | ||
} | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl TxSink for DenyListPoolSink { | ||
async fn submit_tx( | ||
&self, | ||
tx: &L2Tx, | ||
execution_metrics: TransactionExecutionMetrics, | ||
) -> Result<L2TxSubmissionResult, SubmitTxError> { | ||
let address_and_nonce = (tx.initiator_account(), tx.nonce()); | ||
if self.deny_list.contains(&address_and_nonce.0) { | ||
return Err(SubmitTxError::SenderInDenyList(tx.initiator_account())); | ||
} | ||
|
||
self.master_pool_sync.submit_tx(tx, execution_metrics).await | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.