What happens to non-standard transactions in the case of a blockchain reorg? Blockchain

[m1]-&gt; [m2] -&gt; [m3] -&gt; [m4]

         |  -&gt; [f1] -&gt; [f2] -&gt; [new]



m - mainchain blocks
f - fork blocks
new - tip of the fork that is at greater height than the previous mainchain


In this case we must switch from the mainchain to the fork, due to the height of forkchain being greater than the mainchain.

My question is about transactions in blocks [m3], [m4]. In the case a transaction was in [m3] but not included in either the blocks [f1],[f2]. Since that transaction is not confirmed in the new mainchain (the forkchain) after the switch, would this tx be available for miners again to include for next block? Would this transactions be returned to the rawmempool?

And what if this transaction was added without isStandard check (in case adding in block), should we process isStandard check for this transaction?
Each of the blockchain forks assumes itself to be the only valid blockchain. They do not change their behavior due to a competing chain. They will require checks and confirm transactions completely independently from each other. It is likely that the same transactions are confirmed in both competing chains, just in different order and perhaps also at different heights. If a chain reorganization happens, and some transactions were not confirmed in the new best chain yet, they are still in the pool of unconfirmed transactions for that chain.

So, if you actually switch from [m4] to [new], and a transaction was not confirmed in the [new] chain that had been confirmed in the chain containing [m4], yes of course it would be in pool of unconfirmed transactions for that chain.

isStandard() is performed by every node when it learns about a transaction. Each miner decides whether to confirm transactions that don't pass isStandard() by themselves. It is irrelevant whether a competitor would include it or not for this process. If the forkchain is extended by a miner that doesn't confirm non-standard transactions, it will only be confirmed later when someone else chooses to do so.