Skip to content

Commit fe778a3

Browse files
committed
TOSQUASH updates to comments, indentation, and a single local variable name
1 parent b67443d commit fe778a3

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Mempool/Update.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ pureTryAddTx cfg wti tx is =
175175
-- greater than what this ledger state allows for a single transaction).
176176
--
177177
-- It might seem simpler to remove the failure case from 'txMeasure' and
178-
-- simply fully validate the tx before determing whether it'd fit in the
179-
-- mempool; that way we could reject invalid txs ASAP. However, for a
178+
-- simply fully validate the tx before determining whether it'd fit in
179+
-- the mempool; that way we could reject invalid txs ASAP. However, for a
180180
-- valid tx, we'd pay that validation cost every time the node's
181181
-- selection changed, even if the tx wouldn't fit. So it'd very much be
182182
-- as if the mempool were effectively over capacity! What's worse, each
@@ -194,7 +194,9 @@ pureTryAddTx cfg wti tx is =
194194
--
195195
-- No measure of a transaction can ever be negative, so the only way
196196
-- adding two measures could result in a smaller measure is if some
197-
-- modular arithmetic overflowed.
197+
-- modular arithmetic overflowed. Also, overflow necessarily yields a
198+
-- lesser result, since adding 'maxBound' is modularly equivalent to
199+
-- subtracting one. Recall that we're checking each individual addition.
198200
--
199201
-- We assume that the 'txMeasure' limit and the mempool capacity
200202
-- 'isCapacity' are much smaller than the modulus, and so this should
@@ -234,8 +236,8 @@ pureTryAddTx cfg wti tx is =
234236
-- Even with the overflow handler, it's important that 'txMeasure'
235237
-- returns a well-bounded result. Otherwise, if an adversarial tx arrived
236238
-- that could't even fit in an empty mempool, then that thread would
237-
-- never release the 'MVar'. In particular, we tacitally assume here that
238-
-- a tx that wouldn't even fit in an empty mempool would be rejected by
239+
-- never release the 'MVar'. In particular, we tacitly assume here that a
240+
-- tx that wouldn't even fit in an empty mempool would be rejected by
239241
-- 'txMeasure'.
240242
| not $ currentSize `Measure.plus` txsz Measure.<= isCapacity is
241243
->

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/MiniProtocol/LocalTxMonitor/Server.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ localTxMonitorServer mempool =
6464
{ capacityInBytes = unByteSize32 capacity
6565
, sizeInBytes = unByteSize32 msNumBytes
6666
, numberOfTxs = msNumTxs
67-
} -- TODO what to do about overflow?
67+
}
6868
pure $ SendMsgReplyGetSizes sizes (serverStAcquired s txs)
6969
, recvMsgAwaitAcquire = do
7070
s' <- atomically $ do

ouroboros-consensus/test/consensus-test/Test/Consensus/Mempool.hs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,13 @@ prop_Mempool_getCapacity mcts =
219219
MempoolCapacityBytesOverride testCapacity = testMempoolCapOverride testSetup
220220
MempoolCapTestSetup (TestSetupWithTxs testSetup _txsToAdd) = mcts
221221

222-
ByteSize32 dom = simpleBlockCapacity
222+
ByteSize32 dnom = simpleBlockCapacity
223223

224224
expectedCapacity =
225225
(\n -> stimes n simpleBlockCapacity)
226226
$ max 1
227-
$ (unByteSize32 testCapacity + dom - 1) `div` dom -- div rounding up
227+
-- adding one less than the denom to the numer achieves rounding up
228+
$ (unByteSize32 testCapacity + dnom - 1) `div` dnom
228229

229230
-- | Test that all valid transactions added to a 'Mempool' via 'addTxs' are
230231
-- appropriately represented in the trace of events.
@@ -299,7 +300,9 @@ prop_Mempool_TraceRemovedTxs setup =
299300
| (tx, Left err) <- fst $ validateTxs ledgerState txsInMempool
300301
]
301302

302-
prjTx :: (Validated (GenTx TestBlock), TicketNo, ByteSize32) -> Validated (GenTx TestBlock)
303+
prjTx ::
304+
(Validated (GenTx TestBlock), TicketNo, ByteSize32)
305+
-> Validated (GenTx TestBlock)
303306
prjTx (a, _b, _c) = a
304307

305308
{-------------------------------------------------------------------------------
@@ -833,9 +836,9 @@ instance Arbitrary MempoolCapTestSetup where
833836
testSetupWithTxs@TestSetupWithTxs { testSetup, txs } <- arbitrary
834837
-- The Mempool should at least be capable of containing the transactions
835838
-- it already contains.
836-
let currentSize = foldMap txSize (testInitialTxs testSetup)
839+
let currentSize = foldMap txSize (testInitialTxs testSetup)
837840
capacityMinBound = currentSize
838-
validTxsToAdd = [tx | (tx, True) <- txs]
841+
validTxsToAdd = [tx | (tx, True) <- txs]
839842
-- Use the current size + the sum of all the valid transactions to add
840843
-- as the upper bound.
841844
capacityMaxBound = currentSize <> foldMap txSize validTxsToAdd

ouroboros-consensus/test/consensus-test/Test/Consensus/Mempool/Fairness/TestBlock.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ instance Ledger.HasTxId (Ledger.GenTx TestBlock) where
7979
txId (TestBlockGenTx tx) = TestBlockTxId tx
8080

8181
mkGenTx :: Int -> Ledger.ByteSize32 -> Ledger.GenTx TestBlock
82-
mkGenTx anId aSize =
83-
TestBlockGenTx $ Tx { txNumber = anId, txSize = aSize }
82+
mkGenTx anId aSize = TestBlockGenTx $ Tx { txNumber = anId, txSize = aSize }
8483

8584
instance Ledger.LedgerSupportsMempool TestBlock where
8685
applyTx _cfg _shouldIntervene _slot gtx st = pure (st, ValidatedGenTx gtx)

0 commit comments

Comments
 (0)