Skip to content

Commit

Permalink
consensus: do not even propagate future headers
Browse files Browse the repository at this point in the history
This an aggressively-simple interpretation of the easy part of Ouroboros
Chronos in the presence of The Header-Body Split. (The hard part is the
_synchronization beacons_---which need to be propagated promptly, and will be
implemented much later.)

Other less-aggressive interpretations would propagate future headers/blocks but
set them aside. But this seems much simpler and within an RTT or two, assuming
eg the NTP clients are well-configured.
  • Loading branch information
nfrisby committed Nov 30, 2023
1 parent 53223fd commit 2f90f2c
Show file tree
Hide file tree
Showing 9 changed files with 342 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ mkHandlers
-- ^ Peer Sharing result computation callback
-> Handlers m addrNTN blk
mkHandlers
NodeKernelArgs {keepAliveRng, miniProtocolParameters}
NodeKernelArgs {chainSyncFutureCheck, keepAliveRng, miniProtocolParameters}
NodeKernel {getChainDB, getMempool, getTopLevelConfig, getTracers = tracers}
computePeers =
Handlers {
Expand All @@ -224,6 +224,7 @@ mkHandlers
(chainSyncPipeliningHighMark miniProtocolParameters))
(contramap (TraceLabelPeer peer) (Node.chainSyncClientTracer tracers))
getTopLevelConfig
chainSyncFutureCheck
(defaultChainDbView getChainDB)
, hChainSyncServer = \peer _version ->
chainSyncHeadersServer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import Ouroboros.Consensus.Fragment.InFuture (CheckInFuture,
ClockSkew)
import qualified Ouroboros.Consensus.Fragment.InFuture as InFuture
import Ouroboros.Consensus.Ledger.Extended (ExtLedgerState (..))
import qualified Ouroboros.Consensus.MiniProtocol.ChainSync.Client.InFutureCheck as InFutureCheck
import qualified Ouroboros.Consensus.Network.NodeToClient as NTC
import qualified Ouroboros.Consensus.Network.NodeToNode as NTN
import Ouroboros.Consensus.Node.DbLock
Expand Down Expand Up @@ -392,6 +393,7 @@ runWith RunNodeArgs{..} encAddrNtN decAddrNtN LowLevelRunNodeArgs{..} =
cfg
rnTraceConsensus
btime
(InFutureCheck.realHeaderInFutureCheck llrnMaxClockSkew systemTime)
chainDB
nodeKernel <- initNodeKernel nodeKernelArgs
rnNodeKernelHook registry nodeKernel
Expand Down Expand Up @@ -639,6 +641,7 @@ mkNodeKernelArgs
-> TopLevelConfig blk
-> Tracers m (ConnectionId addrNTN) (ConnectionId addrNTC) blk
-> BlockchainTime m
-> InFutureCheck.HeaderInFutureCheck m blk
-> ChainDB m blk
-> m (NodeKernelArgs m addrNTN (ConnectionId addrNTC) blk)
mkNodeKernelArgs
Expand All @@ -648,6 +651,7 @@ mkNodeKernelArgs
cfg
tracers
btime
chainSyncFutureCheck
chainDB
= do
return NodeKernelArgs
Expand All @@ -657,6 +661,7 @@ mkNodeKernelArgs
, btime
, chainDB
, initChainDB = nodeInitChainDB
, chainSyncFutureCheck
, blockFetchSize = estimateBlockSize
, mempoolCapacityOverride = NoMempoolCapacityBytesOverride
, miniProtocolParameters = defaultMiniProtocolParameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ import Ouroboros.Consensus.Ledger.SupportsPeerSelection
import Ouroboros.Consensus.Ledger.SupportsProtocol
import Ouroboros.Consensus.Mempool
import qualified Ouroboros.Consensus.MiniProtocol.BlockFetch.ClientInterface as BlockFetchClientInterface
import Ouroboros.Consensus.MiniProtocol.ChainSync.Client.InFutureCheck
(HeaderInFutureCheck)
import Ouroboros.Consensus.Node.Run
import Ouroboros.Consensus.Node.Tracers
import Ouroboros.Consensus.Protocol.Abstract
Expand Down Expand Up @@ -132,6 +134,7 @@ data NodeKernelArgs m addrNTN addrNTC blk = NodeKernelArgs {
, btime :: BlockchainTime m
, chainDB :: ChainDB m blk
, initChainDB :: StorageConfig blk -> InitChainDB m blk -> m ()
, chainSyncFutureCheck :: HeaderInFutureCheck m blk
, blockFetchSize :: Header blk -> SizeInBytes
, mempoolCapacityOverride :: MempoolCapacityBytesOverride
, miniProtocolParameters :: MiniProtocolParameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import Ouroboros.Consensus.Ledger.SupportsMempool
import Ouroboros.Consensus.Ledger.SupportsProtocol
import Ouroboros.Consensus.Mempool
import qualified Ouroboros.Consensus.MiniProtocol.ChainSync.Client as CSClient
import qualified Ouroboros.Consensus.MiniProtocol.ChainSync.Client.InFutureCheck as InFutureCheck
import qualified Ouroboros.Consensus.Network.NodeToNode as NTN
import Ouroboros.Consensus.Node.ExitPolicy
import Ouroboros.Consensus.Node.InitStorage
Expand Down Expand Up @@ -974,6 +975,10 @@ runThreadNetwork systemTime ThreadNetworkArgs
, btime
, chainDB
, initChainDB = nodeInitChainDB
, chainSyncFutureCheck =
InFutureCheck.realHeaderInFutureCheck
InFuture.defaultClockSkew
(OracularClock.finiteSystemTime clock)
, blockFetchSize = estimateBlockSize
, mempoolCapacityOverride = NoMempoolCapacityBytesOverride
, keepAliveRng = kaRng
Expand Down
1 change: 1 addition & 0 deletions ouroboros-consensus/ouroboros-consensus.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ library
Ouroboros.Consensus.MiniProtocol.BlockFetch.ClientInterface
Ouroboros.Consensus.MiniProtocol.BlockFetch.Server
Ouroboros.Consensus.MiniProtocol.ChainSync.Client
Ouroboros.Consensus.MiniProtocol.ChainSync.Client.InFutureCheck
Ouroboros.Consensus.MiniProtocol.ChainSync.Server
Ouroboros.Consensus.MiniProtocol.LocalStateQuery.Server
Ouroboros.Consensus.MiniProtocol.LocalTxMonitor.Server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ module Ouroboros.Consensus.Fragment.InFuture (
-- * Clock skew
, clockSkewInSeconds
, defaultClockSkew
-- ** opaque
-- ** not exporting the constructor
, ClockSkew
, unClockSkew
-- * Testing
, dontCheck
, miracle
Expand Down
Loading

0 comments on commit 2f90f2c

Please sign in to comment.