Skip to content

Commit 391dda3

Browse files
authored
Merge pull request Plutonomicon#1653 from Plutonomicon/dshuiski/tx-witness-set
Fix transaction witness set 'attach' functions
2 parents b13dac4 + 16c6b88 commit 391dda3

File tree

2 files changed

+41
-44
lines changed

2 files changed

+41
-44
lines changed

CHANGELOG.md

+25-17
Original file line numberDiff line numberDiff line change
@@ -7,82 +7,90 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
77
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
88
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
99

10-
- [[v9.3.1]](#v931)
10+
- [[Unreleased]](#unreleased)
1111
- [Fixed](#fixed)
12-
- [[v9.3.0]](#v930)
12+
- [[v9.3.1]](#v931)
1313
- [Fixed](#fixed-1)
14+
- [[v9.3.0]](#v930)
15+
- [Fixed](#fixed-2)
1416
- [Changed](#changed)
1517
- [[v9.2.0]](#v920)
1618
- [Added](#added)
1719
- [Changed](#changed-1)
1820
- [Removed](#removed)
19-
- [Fixed](#fixed-2)
21+
- [Fixed](#fixed-3)
2022
- [[v9.1.0]](#v910)
2123
- [Added](#added-1)
22-
- [Changed](#changed-2
24+
- [Changed](#changed-2)
2325
- [Removed](#removed-1)
24-
- [Fixed](#fixed-3)
26+
- [Fixed](#fixed-4)
2527
- [[v9.0.0]](#v900)
2628
- [Deprecated](#deprecated)
2729
- [Added](#added-2)
2830
- [Removed](#removed-2)
2931
- [Changed](#changed-3)
30-
- [Fixed](#fixed-4)
32+
- [Fixed](#fixed-5)
3133
- [[v8.0.0]](#v800)
3234
- [Added](#added-3)
3335
- [Changed](#changed-4)
34-
- [Fixed](#fixed-5)
36+
- [Fixed](#fixed-6)
3537
- [Removed](#removed-3)
3638
- [[v7.0.0]](#v700)
3739
- [Added](#added-4)
3840
- [Changed](#changed-5)
39-
- [Fixed](#fixed-6)
41+
- [Fixed](#fixed-7)
4042
- [Removed](#removed-4)
4143
- [[v6.0.0]](#v600)
4244
- [Added](#added-5)
4345
- [Changed](#changed-6)
44-
- [Fixed](#fixed-7)
46+
- [Fixed](#fixed-8)
4547
- [Removed](#removed-5)
4648
- [[v5.0.0]](#v500)
4749
- [Added](#added-6)
4850
- [Changed](#changed-7)
4951
- [Removed](#removed-6)
50-
- [Fixed](#fixed-8)
52+
- [Fixed](#fixed-9)
5153
- [Runtime Dependencies](#runtime-dependencies)
5254
- [[v4.0.2] - 2023-01-17](#v402---2023-01-17)
53-
- [Fixed](#fixed-9)
55+
- [Fixed](#fixed-10)
5456
- [[v4.0.1] - 2022-12-20](#v401---2022-12-20)
5557
- [Added](#added-7)
5658
- [[v4.0.0] - 2022-12-15](#v400---2022-12-15)
5759
- [Added](#added-8)
5860
- [Changed](#changed-8)
5961
- [Removed](#removed-7)
60-
- [Fixed](#fixed-10)
62+
- [Fixed](#fixed-11)
6163
- [Runtime Dependencies](#runtime-dependencies-1)
6264
- [[3.0.0] - 2022-11-21](#300---2022-11-21)
6365
- [Added](#added-9)
6466
- [Changed](#changed-9)
6567
- [Removed](#removed-8)
66-
- [Fixed](#fixed-11)
68+
- [Fixed](#fixed-12)
6769
- [Runtime Dependencies](#runtime-dependencies-2)
6870
- [[2.0.0] - 2022-09-12](#200---2022-09-12)
6971
- [Added](#added-10)
7072
- [Changed](#changed-10)
7173
- [Removed](#removed-9)
72-
- [Fixed](#fixed-12)
74+
- [Fixed](#fixed-13)
7375
- [[2.0.0-alpha] - 2022-07-05](#200-alpha---2022-07-05)
7476
- [Added](#added-11)
7577
- [Removed](#removed-10)
7678
- [Changed](#changed-11)
77-
- [Fixed](#fixed-13)
78-
- [[1.1.0] - 2022-06-30](#110---2022-06-30)
7979
- [Fixed](#fixed-14)
80-
- [[1.0.1] - 2022-06-17](#101---2022-06-17)
80+
- [[1.1.0] - 2022-06-30](#110---2022-06-30)
8181
- [Fixed](#fixed-15)
82+
- [[1.0.1] - 2022-06-17](#101---2022-06-17)
83+
- [Fixed](#fixed-16)
8284
- [[1.0.0] - 2022-06-10](#100---2022-06-10)
8385

8486
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
8587

88+
## [Unreleased]
89+
90+
### Fixed
91+
92+
- Fixed transaction witness set 'attach' functions. Previously, the updated witness set was incorrectly appended to the existing set, causing performance degradation when processing constraints for complex transactions. ([#1653](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1653))
93+
8694
## [v9.3.1]
8795

8896
### Fixed

src/Internal/Transaction.purs

+16-27
Original file line numberDiff line numberDiff line change
@@ -90,43 +90,32 @@ setScriptDataHash costModels rs ds tx@(Transaction { body, witnessSet })
9090
attachDatum :: PlutusData -> Transaction -> Transaction
9191
attachDatum d = attachDatums [ d ]
9292

93-
attachDatums
94-
:: Array PlutusData -> Transaction -> Transaction
93+
attachDatums :: Array PlutusData -> Transaction -> Transaction
9594
attachDatums [] tx = tx
9695
attachDatums datums tx@(Transaction { witnessSet: TransactionWitnessSet ws }) =
97-
do
98-
updateTxWithWitnesses tx $ TransactionWitnessSet $ ws
99-
{ plutusData = nub $ ws.plutusData <> datums }
96+
updateTxWithWitnesses tx $ TransactionWitnessSet $ ws
97+
{ plutusData = nub $ ws.plutusData <> datums
98+
}
10099

101100
-- | Attach a `PlutusScript` to a transaction by modifying its existing witness
102101
-- | set
103-
attachPlutusScript
104-
:: PlutusScript -> Transaction -> Transaction
102+
attachPlutusScript :: PlutusScript -> Transaction -> Transaction
105103
attachPlutusScript ps = attachPlutusScripts [ ps ]
106104

107-
attachPlutusScripts
108-
:: Array PlutusScript
109-
-> Transaction
110-
-> Transaction
105+
attachPlutusScripts :: Array PlutusScript -> Transaction -> Transaction
111106
attachPlutusScripts ps tx@(Transaction { witnessSet: TransactionWitnessSet ws }) =
112-
do
113-
updateTxWithWitnesses tx
114-
$ TransactionWitnessSet
115-
$ ws { plutusScripts = nub $ ws.plutusScripts <> ps }
107+
updateTxWithWitnesses tx $ TransactionWitnessSet $ ws
108+
{ plutusScripts = nub $ ws.plutusScripts <> ps
109+
}
116110

117111
-- | Attach a `NativeScript` to a transaction by modifying its existing witness
118112
-- | set
119-
attachNativeScript
120-
:: NativeScript -> Transaction -> Transaction
113+
attachNativeScript :: NativeScript -> Transaction -> Transaction
121114
attachNativeScript ns tx@(Transaction { witnessSet: TransactionWitnessSet ws }) =
122-
do
123-
updateTxWithWitnesses tx
124-
$ TransactionWitnessSet
125-
$ ws { nativeScripts = nub $ ws.nativeScripts <> [ ns ] }
115+
updateTxWithWitnesses tx $ TransactionWitnessSet $ ws
116+
{ nativeScripts = nub $ ws.nativeScripts <> [ ns ]
117+
}
126118

127-
updateTxWithWitnesses
128-
:: Transaction
129-
-> TransactionWitnessSet
130-
-> Transaction
131-
updateTxWithWitnesses tx@(Transaction t) ws =
132-
over Transaction _ { witnessSet = t.witnessSet <> ws } tx
119+
updateTxWithWitnesses :: Transaction -> TransactionWitnessSet -> Transaction
120+
updateTxWithWitnesses tx ws =
121+
over Transaction _ { witnessSet = ws } tx

0 commit comments

Comments
 (0)