Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ run immDBDir sockAddr cfg getSlotDelay leiosDbFile leiosSchedule = withRegistry
-- | A JSON-encoded list of @(slotDbl, (ebSlot, ebHashHex, mbEbBytesSize))@
-- entries; the immdb-server delivers each entry at its scheduled slot via the
-- LeiosNotify mini-protocol.
--
-- TODO the third component could be a Bool saying which offer to send, with
-- the EB offer's size looked up just-in-time.
data LeiosSchedule = MkLeiosSchedule [(Double, (Word64, T.Text, Maybe Word32))]
deriving Generic

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ immDBServer codecCfg encAddr decAddr immDB networkMagic getSlotDelay mkLeiosNoti
leiosNotifyServerPeer
( MVar.takeMVar (leiosMailbox leiosContext) <&> \case
(p, Just sz) -> MsgLeiosBlockOffer p sz
(p, Nothing) -> MsgLeiosBlockTxsOffer p
-- [0, maxBound) offers the whole closure without knowing its size
(p, Nothing) -> MsgLeiosBlockTxsOffer p 0 maxBound
)
leiosFetchProt =
MiniProtocolCb $ \ctx channel ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ mkHandlers
, hKeepAliveServer = \_version _peer -> keepAliveServer
, hPeerSharingClient = \_version controlMessageSTM _peer -> peerSharingClient controlMessageSTM
, hPeerSharingServer = \_version _peer -> peerSharingServer getPeerSharingAPI
, hLeiosNotifyClient = \_version controlMessageSTM peer peerVars -> toLeiosNotifyClientPeerPipelined $ Effect $ do
, hLeiosNotifyClient = \version controlMessageSTM peer peerVars -> toLeiosNotifyClientPeerPipelined $ Effect $ do
let tracer = leiosPeerTracer peer
kernelTracer = Node.leiosKernelTracer tracers
LeiosVoteState{addVote} = leiosVoteState
Expand Down Expand Up @@ -644,10 +644,19 @@ mkHandlers
traceWith tracer $ MkTraceLeiosPeer $ "MsgLeiosBlockOffer " <> Leios.prettyLeiosPoint point
checkOffer $ Leios.checkLeiosBlockOffer point ebBytesSize
Leios.recordEbBodyOffer getLeiosReady peerVars (point, ebBytesSize)
MsgLeiosBlockTxsOffer point -> do
traceWith tracer $ MkTraceLeiosPeer $ "MsgLeiosBlockTxsOffer " <> Leios.prettyLeiosPoint point
checkOffer $ Leios.checkLeiosClosureOffer point
Leios.recordEbClosureOffer getLeiosReady peerVars point
MsgLeiosBlockTxsOffer point start end -> do
traceWith tracer $
MkTraceLeiosPeer $
"MsgLeiosBlockTxsOffer " <> Leios.prettyLeiosPoint point <> " " <> show (start, end)
checkOffer $
-- TODO thread the real 'LeiosFetchStaticEnv' rather than the demo one
Leios.checkLeiosClosureOffer
Leios.demoLeiosFetchStaticEnv
(Leios.leiosClosureOfferMinLength version)
point
start
end
Leios.recordEbClosureOffer getLeiosReady peerVars point start end
MsgLeiosVotes vs -> do
-- TODO no LeiosNotify message may simply be ignored, or
-- the peer can send it without bound. Votes still can be:
Expand Down Expand Up @@ -788,7 +797,8 @@ mkHandlers
AcquiredEb point ebSize ->
offer point Leios.OfferedBody $ MsgLeiosBlockOffer point ebSize
AcquiredEbTxs point ->
offer point Leios.OfferedClosure $ MsgLeiosBlockTxsOffer point
-- [0, maxBound) offers the whole closure without knowing its size
offer point Leios.OfferedClosure $ MsgLeiosBlockTxsOffer point 0 maxBound
)
<|> (getNextVote <&> \vote -> Just $ MsgLeiosVotes [vote])

Expand Down Expand Up @@ -840,7 +850,7 @@ mkHandlers
Map LeiosPoint (Set.Set Leios.OfferedBodyOrClosure)
recordOffer = \case
MsgLeiosBlockOffer point _ -> Map.adjust (Set.insert Leios.OfferedBody) point
MsgLeiosBlockTxsOffer point -> Map.adjust (Set.insert Leios.OfferedClosure) point
MsgLeiosBlockTxsOffer point _ _ -> Map.adjust (Set.insert Leios.OfferedClosure) point
_ -> id

pump =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ heardUnannouncedOffers PeerEnv{peHeard} =
go (maybe id ((:) . fst) (lthAnnouncement hdr) announced) rest
Notify.MsgLeiosBlockOffer point _size
| point `notElem` announced -> point : go announced rest
Notify.MsgLeiosBlockTxsOffer point
Notify.MsgLeiosBlockTxsOffer point _start _end
| point `notElem` announced -> point : go announced rest
_ -> go announced rest

Expand Down Expand Up @@ -261,15 +261,15 @@ offerEb PeerEnv{peNotifications} point size =
atomically $
PlainSTM.modifyTVar peNotifications (<> [Notify.MsgLeiosBlockOffer point size])

-- | Have this peer offer this endorser block's closure over LeiosNotify.
-- | Have this peer offer this endorser block's whole closure over LeiosNotify.
--
-- Independent of 'offerEb': either may be sent first, or alone. Like it, this
-- is not an announcement, so an honest peer says it only after its own
-- 'Notify.MsgLeiosBlockAnnouncement' for that endorser block.
offerEbTxs :: PeerEnv (IOSim s) -> LeiosPoint -> IOSim s ()
offerEbTxs PeerEnv{peNotifications} point =
atomically $
PlainSTM.modifyTVar peNotifications (<> [Notify.MsgLeiosBlockTxsOffer point])
PlainSTM.modifyTVar peNotifications (<> [Notify.MsgLeiosBlockTxsOffer point 0 maxBound])

-- | The endorser blocks the node has offered this peer, in order.
heardOffers :: PeerEnv (IOSim s) -> IOSim s [LeiosPoint]
Expand All @@ -280,7 +280,7 @@ heardOffers PeerEnv{peHeard} =
offered :: LeiosNotification -> [LeiosPoint]
offered = \case
Notify.MsgLeiosBlockOffer point _size -> [point]
Notify.MsgLeiosBlockTxsOffer point -> [point]
Notify.MsgLeiosBlockTxsOffer point _start _end -> [point]
_ -> []

-- | The endorser blocks whose /body/ the node has told this peer it holds.
Expand All @@ -307,7 +307,7 @@ heardClosureOffers PeerEnv{peHeard} =
where
offered :: LeiosNotification -> [LeiosPoint]
offered = \case
Notify.MsgLeiosBlockTxsOffer point -> [point]
Notify.MsgLeiosBlockTxsOffer point _start _end -> [point]
_ -> []

-- | Have this peer ask the node for this endorser block's body.
Expand Down
Loading
Loading