how do i check a transaction before it gets added to the transaction pool, kind of like BlockImport but for transactions that are coming from outside(from other validators or clients)?
1 Answer
Every transaction is passed to the validate_transaction
function in your runtime, before it enters the pool. This ensures that the transaction is valid and also gives back information about how longevity and priority of the transaction.
-
is to possible to have an off-chain worker inside that function (because i want to call a grpc server from there, fetch something offchain) Nov 15, 2022 at 13:56
-
1Theoretically yes, but that would make this check very expensive. But this check should be as cheap as possible, as otherwise nodes can start spamming you with transactions and making your node do expensive operations for free.– bkchrNov 15, 2022 at 14:14