transaction-pool: drop unpropagable txs if local node cant author blocks (#8048)

* transaction-pool: drop unpropagable txs if local node cant author blocks

* fix test compilation

* transaction-pool: remove unnecessary static bound on CanAuthor

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* rpc-api: add translation for PoolError::Unactionable

* transaction-pool: add test for rejecting unactionable transactions

* basic-authorship: fix doc test

* transaction-pool: fix benchmark compilation

* transaction-pool: rename CanAuthor to IsValidator

* transaction-pool: nit in error message

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
André SilvaandTomasz Drwięga authored and GitHub committed 2021-02-04 20:18:44 +01:00
1 parent 8e36d87ca8
commit 54def5f3d3
19 files changed
+157 -56

No files matched your search

@@ -99,6 +99,9 @@ const POOL_CYCLE_DETECTED: i64 = POOL_INVALID_TX + 5;
const POOL_IMMEDIATELY_DROPPED: i64 = POOL_INVALID_TX + 6;
/// The key type crypto is not known.
const UNSUPPORTED_KEY_TYPE: i64 = POOL_INVALID_TX + 7;
/// The transaction was not included to the pool since it is unactionable,
/// it is not propagable and the local node does not author blocks.
const POOL_UNACTIONABLE: i64 = POOL_INVALID_TX + 8;
impl From<Error> for rpc::Error {
fn from(e: Error) -> Self {
@@ -158,6 +161,14 @@ impl From<Error> for rpc::Error {
message: "Immediately Dropped".into(),
data: Some("The transaction couldn't enter the pool because of the limit".into()),
},
Error::Pool(PoolError::Unactionable) => rpc::Error {
code: rpc::ErrorCode::ServerError(POOL_UNACTIONABLE),
message: "Unactionable".into(),
data: Some(
"The transaction is unactionable since it is not propagable and \
the local node does not author blocks".into(),
),
},
Error::UnsupportedKeyType => rpc::Error {
code: rpc::ErrorCode::ServerError(UNSUPPORTED_KEY_TYPE),
message: "Unknown key type crypto" .into(),