Pass transaction source to validate_transaction (#5366)

* WiP

* Support source in the runtime API.

* Finish implementation in txpool.

* Fix warning.

* Fix tests.

* Apply suggestions from code review

Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-Authored-By: Nikolay Volf <nikvolf@gmail.com>

* Extra changes.

* Fix test and benches.

* fix test

* Fix test & benches again.

* Fix tests.

* Update bumpalo

* Fix doc test.

* Fix doctest.

* Fix doctest.

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
This commit is contained in:
Tomasz Drwięga
2020-03-25 14:09:23 +01:00
committed by GitHub
parent 601ac11e52
commit 04ccb179e9
37 changed files with 414 additions and 163 deletions
@@ -51,7 +51,9 @@ use sp_core::crypto::KeyTypeId;
use sp_runtime::{
offchain::{http, Duration, storage::StorageValueRef},
traits::Zero,
transaction_validity::{InvalidTransaction, ValidTransaction, TransactionValidity},
transaction_validity::{
InvalidTransaction, ValidTransaction, TransactionValidity, TransactionSource,
},
};
use sp_std::{vec, vec::Vec};
use lite_json::json::JsonValue;
@@ -509,7 +511,10 @@ impl<T: Trait> frame_support::unsigned::ValidateUnsigned for Module<T> {
/// By default unsigned transactions are disallowed, but implementing the validator
/// here we make sure that some particular calls (the ones produced by offchain worker)
/// are being whitelisted and marked as valid.
fn validate_unsigned(call: &Self::Call) -> TransactionValidity {
fn validate_unsigned(
_source: TransactionSource,
call: &Self::Call,
) -> TransactionValidity {
// Firstly let's check that we call the right function.
if let Call::submit_price_unsigned(block_number, new_price) = call {
// Now let's check if the transaction has any chance to succeed.