forked from tari-project/tari-dan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
770 additions
and
128 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
6 changes: 3 additions & 3 deletions
6
...node/src/p2p/services/mempool/and_then.rs → ...2p/services/mempool/validator/and_then.rs
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
22 changes: 22 additions & 0 deletions
22
applications/tari_validator_node/src/p2p/services/mempool/validator/fee.rs
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,22 @@ | ||
// Copyright 2023 The Tari Project | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
use async_trait::async_trait; | ||
use tari_transaction::Transaction; | ||
|
||
use crate::p2p::services::mempool::{MempoolError, Validator}; | ||
|
||
#[derive(Debug)] | ||
pub struct FeeTransactionValidator; | ||
|
||
#[async_trait] | ||
impl Validator<Transaction> for FeeTransactionValidator { | ||
type Error = MempoolError; | ||
|
||
async fn validate(&self, transaction: &Transaction) -> Result<(), MempoolError> { | ||
if transaction.fee_instructions().is_empty() { | ||
return Err(MempoolError::NoFeeInstructions); | ||
} | ||
Ok(()) | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
applications/tari_validator_node/src/p2p/services/mempool/validator/input_refs.rs
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,36 @@ | ||
// Copyright 2023 The Tari Project | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
use tari_dan_common_types::ShardId; | ||
use tari_dan_storage::consensus_models::ExecutedTransaction; | ||
|
||
use crate::p2p::services::mempool::{MempoolError, Validator}; | ||
|
||
/// Refuse to process the transaction if any input_refs are downed | ||
pub struct InputRefsValidator; | ||
|
||
impl InputRefsValidator { | ||
pub fn new() -> Self { | ||
Self | ||
} | ||
} | ||
|
||
impl Validator<ExecutedTransaction> for InputRefsValidator { | ||
type Error = MempoolError; | ||
|
||
async fn validate(&self, executed: &ExecutedTransaction) -> Result<(), Self::Error> { | ||
let Some(diff) = executed.result().finalize.result.accept().cloned() else { | ||
return Ok(()); | ||
}; | ||
|
||
let is_input_refs_downed = diff | ||
.down_iter() | ||
.map(|(s, v)| ShardId::from_address(s, *v)) | ||
.any(|s| executed.transaction().input_refs().contains(&s)); | ||
|
||
if is_input_refs_downed { | ||
return Err(MempoolError::InputRefsDowned); | ||
} | ||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.