plutus
                                
                                 plutus copied to clipboard
                                
                                    plutus copied to clipboard
                            
                            
                            
                        Use newtype deriving for more parts of `ScriptContext`
Describe the feature you'd like
Some newtypes, e.g. TxId, are serialised to Data using Constr unnecessarily, when they could just use deriving newtype.
https://github.com/input-output-hk/plutus/blob/master/plutus-ledger-api/src/PlutusLedgerApi/V1/Tx.hs#L219
This would reduce evaluation costs a bit.
Describe alternatives you've considered
No response
Same as issue #4705
I fear that too many existing libraries and scripts now depend on TxId being serialized as ConstrData.
So probably best to use data TxId instead of newtype TxId
At the moment we have a consistent policy of having a Constr for every type node. It's not that important, but it is consistent. I can't think of anything that would go wrong if we used newtype deriving, but it also seems like a fairly marginal improvement. And it would need a new language version, and we'd have to support both ways, etc.
PubKeyHash uses newtype deriving. IMO, it makes sense to use newtype deriving for this in all cases where possible.
Given the huge costs
And it would need a new language version, and we'd have to support both ways, etc.
and the modest benefits
I can't think of anything that would go wrong if we used newtype deriving, but it also seems like a fairly marginal improvement.
I'm going to take responsibility and close this issue.