Skip to content

Commit

Permalink
feat: make sure duplication check happens first in mempool (#4627)
Browse files Browse the repository at this point in the history
Description
---
Changes the order of validation in mempool to check the excess signature before checking the inputs. 

Motivation and Context
---
When receiving old transactions, if we check the inputs first, the tx will fail on input validation, and we flag this as a transaction that double spends some input. 
This is incorrect as it's a rebroadcast of an old already mined transaction. So we check the kernel_excess signature first, and if this is already contained in the blockchain, we just print out a debug message saying we received an old already mined kernel.
  • Loading branch information
SWvheerden authored Sep 7, 2022
1 parent 058f492 commit 23e4894
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion applications/tari_base_node/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ async fn build_node_context(
app_config.base_node.bypass_range_proof_verification,
blockchain_db.clone(),
)),
Box::new(TxInputAndMaturityValidator::new(blockchain_db.clone())),
Box::new(TxConsensusValidator::new(blockchain_db.clone())),
Box::new(TxInputAndMaturityValidator::new(blockchain_db.clone())),
]);
let mempool = Mempool::new(
app_config.base_node.mempool.clone(),
Expand Down
5 changes: 4 additions & 1 deletion base_layer/core/src/mempool/mempool_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ impl MempoolStorage {
Ok(TxStorageResponse::NotStoredConsensus)
},
Err(ValidationError::DuplicateKernelError(msg)) => {
warn!(target: LOG_TARGET, "Validation failed due to duplicate kernel: {}", msg);
debug!(
target: LOG_TARGET,
"Validation failed due to already mined kernel: {}", msg
);
Ok(TxStorageResponse::NotStoredConsensus)
},
Err(e) => {
Expand Down
6 changes: 1 addition & 5 deletions base_layer/wallet_ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ fn main() {
]),
..Default::default()
},
autogen_warning: Some(
"// This file was generated by cargo-bindgen. Please do not edit
manually."
.to_string(),
),
autogen_warning: Some("// This file was generated by cargo-bindgen. Please do not edit manually.".to_string()),
style: Style::Tag,
cpp_compat: true,
export: ExportConfig {
Expand Down

0 comments on commit 23e4894

Please sign in to comment.