Skip to content

Commit

Permalink
[logging] improve the error log for mempool #9466
Browse files Browse the repository at this point in the history
When submitting same txn to mempool, we got error says "Failed to update gas price to 0"

From Zekun:

> the error message makes no sense , i thought we updated it.

it assume you submit the same txn is to update the gas price to make it higher priority. we should simply return message like txn already in mempool

Closes: #9610
  • Loading branch information
hariria authored and bors-libra committed Nov 3, 2021
1 parent f8857f4 commit 74e312a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/src/tests/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ async fn test_post_transaction_rejected_by_mempool() {
resp,
json!({
"code": 400,
"message": "transaction is rejected: InvalidUpdate - Failed to update gas price to 0"
"message": "transaction is rejected: InvalidUpdate - Transaction already in mempool"
}),
);
}
Expand Down
2 changes: 1 addition & 1 deletion json-rpc/integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ impl PublicUsageTest for MempoolValidationError {
let resp = env.submit(&txn2);
assert_eq!(
resp.error.expect("error").message,
"Server error: Mempool submission error: \"Failed to update gas price to 0\""
"Server error: Mempool submission error: \"Transaction already in mempool\""
.to_string(),
);
});
Expand Down
5 changes: 2 additions & 3 deletions mempool/src/core_mempool/transaction_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ impl TransactionStore {
self.index_remove(&txn);
}
} else {
return MempoolStatus::new(MempoolStatusCode::InvalidUpdate).with_message(
format!("Failed to update gas price to {}", txn.get_gas_price()),
);
return MempoolStatus::new(MempoolStatusCode::InvalidUpdate)
.with_message("Transaction already in mempool".to_string());
}
}
}
Expand Down

0 comments on commit 74e312a

Please sign in to comment.