ouroboros-network icon indicating copy to clipboard operation
ouroboros-network copied to clipboard

ThreadNet: Use getLedgerBackingStoreValueHandle inside forkTxProducer

Open dnadales opened this issue 3 years ago • 0 comments

Function forkTxProducer uses a ledger backing store value handle, which is obtained before forking the producer:

      -- Create a 'DiskLedgerView' to be used in 'forkTxProducer'. This function
      -- needs the 'DiskLedgerView' to elaborate a complete UTxO set to generate
      -- transactions.
      let
        extractBsValueHandle ::
             StaticEither
               'False
               ( LedgerBackingStoreValueHandle m (ExtLedgerState blk)
               , LedgerDB' blk
               , m ()
               )
               (Either
                 (Point blk)
                 ( LedgerBackingStoreValueHandle m (ExtLedgerState blk)
                 , LedgerDB' blk
                 , m ())
               )
          -> ( LedgerBackingStoreValueHandle m (ExtLedgerState blk)
             , LedgerDB (ExtLedgerState blk)
             , m ()
             )
        extractBsValueHandle = \case
            StaticLeft bsValueHandle -> bsValueHandle
      seBsValueHandle <-
          fmap extractBsValueHandle
        $ ChainDB.getLedgerBackingStoreValueHandle chainDB registry (StaticLeft ())
      forkTxProducer
        coreNodeId
        registry
        clock
        pInfoConfig
        -- Combine with the CoreNodeId, otherwise each node would generate the
        -- same transactions.
        (seed `combineWith` unCoreNodeId coreNodeId)
        -- Uses the same varRNG as the block producer, but we split the RNG
        -- each time, so this is fine.
        (mkDiskLedgerView seBsValueHandle)
        mempool

the problem is that the value handle corresponds to an initial ledger state. Instead, we want the value handle of the node's current ledger state.

So we should get the value handle inside forkTxProducer.

dnadales avatar Aug 11 '22 12:08 dnadales