Why can non-standard transactions be mined but not relayed? As far as I understand, a non-standard transaction can be mined in to a block (and this block will be accepted by all nodes), but nodes will not relay a non-standard transaction to other nodes.

Why is it that miners have the freedom to construct non-standard transactions, but everyone else is limited to standard transactions?

I've heard that limiting the types of transactions that get relayed is some form of protection (against unusual script types that could cause problems). However, if this is the reason, doesn't this just leave miners with the ability to perform an attack whilst leaving everyone else restricted?

I'm not against standard transactions. I'm just not sure how this situation came to be.
doesn't this just leave miners with the ability to perform an attack whilst leaving everyone else restricted?


Not necessarily. Many of the attacks that the standardness rules protect against require large and many transactions that are expensive to verify. If a node is sent a lot of expensive to verify transactions, it can effectively go down as it spends time verifying those transactions instead of verifying and relaying other "normal" transactions and blocks.

However by virtue of mining, a miner can only create transactions that are limited in size, and they are limited in the number of transactions that can be sent in a block. So non-standard transactions that are large and expensive to verify can be included in blocks (and they have been before), but because there are few of them and they happen, at worst, infrequently, it isn't that big of a problem. The problem is only when there are a lot of such transactions which can only happen via normal transaction broadcast, and then standardness rules will prevent those from being verified (standardness is checked before any expensive verifications happen) and relayed.