Skip to content

Commit 589e273

Browse files
authored
Merge branch 'main' into formal-spec
2 parents eab2c7d + f8acfcc commit 589e273

File tree

4 files changed

+109
-21
lines changed

4 files changed

+109
-21
lines changed

Logbook.md

+68
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,71 @@
1+
# Leios logbook
2+
3+
## 2024-09-20
4+
5+
### Team meeting
6+
7+
- Introductions and roles
8+
- Excellent balance of Agda, Haskell, and Rust skills
9+
- Reviewed administrative informoration
10+
- PI7 Jira tickets, mirrored at [#16](https://github.com/input-output-hk/ouroboros-leios/issues/16), [#17](https://github.com/input-output-hk/ouroboros-leios/issues/17), [#18](https://github.com/input-output-hk/ouroboros-leios/issues/18)
11+
- Nominal objectives, tasks, and deliverables for next 12 months
12+
- Work agreement
13+
- Write down “everything” in a “research journal”
14+
- what we do
15+
- why we do it
16+
- what are the expected results vs. actual results.
17+
- Regular (at least weekly) technical review of all work done by everyone
18+
- Show & tell sessions
19+
- Communicate with the stakeholders (including community) on a regular basis
20+
- Experimenting, pivoting, and dead-ends provide valuable learnings and should be documented in logbook
21+
- Processes and workflows can emerge from our needs, and do not have to match typical production enviroments
22+
- However, QA and checking each others' work is important
23+
- Ensure all results are “easily” reproducible by the community
24+
- Arnaud will pair with engineering staff each week in October
25+
- Technical report each quarter -- the next will be in December
26+
- CIP at conclusion of innovation workstream
27+
- Project resources listed at [discussion #15](https://github.com/input-output-hk/ouroboros-leios/discussions/15)
28+
- Open discussion
29+
- Leios flavors
30+
- Blob, short, simplified, and full
31+
- All flavors have the same security guarantees
32+
- Blob Leios does not deal with Cardano transactions
33+
- Full Leios adds robust throughput even in the face of performance issues in base protocol
34+
- Details of interaction with ledger
35+
- Fairness for fees
36+
- Wastage (i.e., duplicate or conflicting transactions)
37+
- Time-dependent smart contracts
38+
- Demo of initial DeltaQ rust implementation by Roland
39+
- Brian will coordinate with David about contracts and with Hans about tweeting
40+
- Communication and collaboration
41+
- Use slack channel for admistrative and scheduling
42+
- Use github [discussions](https://github.com/input-output-hk/ouroboros-leios/discussions) or [pull requests](https://github.com/input-output-hk/ouroboros-leios/pulls)
43+
- When relevant, summarize discussion results or PR comments in [this logbook](./Logbook.md)
44+
- Put experimental code and work in progress on the main branch of [this repository](./)
45+
- Avoid long-lived branches
46+
- If warranted, code can later be separated into a new repository via `git subtree`
47+
- Mostly keep main branch passing the CI, but short-lived exceptions are okay
48+
- Describe new work and findings in [this logbook](./Logbook.md)
49+
- Approximately three working meetings per week
50+
- Each meeting (or slack) will settle the topic for the next meeting
51+
- Next steps
52+
- Meetings next week approximately at 1400 UTC
53+
- Duncan will present on existing ouroboros network
54+
- Two meetings to discuss, brainstorm, and plan network simulations
55+
- Future meetings
56+
- Duncan will present on ouroboros consensus protocol
57+
- Duncan will present on praos lessons learned
58+
- Arnaud, Yves, or Brian will present on peras lessons learned
59+
- Andre will present on formalization lessons learned
60+
- Additional protocol and formalization meetings
61+
- At some point we'll meet with PNSol about DeltaQ collaboration
62+
- Possible in-person meeting mid December or January?
63+
- Work focus
64+
- Roland and Yves will collaborate on DeltaQ
65+
- Everyone should familiarize themselves with the [simulation/](simulation/) and [leios-sim/](leios-sim/) code
66+
- Live version of `leios-sim` at https://leios-simulation.cardano-scaling.org/index.html
67+
- Run `simulation` locally via [instructions below](#running-ouroborous-net-viz-in-the-browser)
68+
169
## 2024-08-30
270

371
### Nix and CI support for Leios specification

leios-sim/index.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ document.addEventListener('DOMContentLoaded', () => {
7373
// queue.
7474
var queuedIBs = [];
7575

76+
// We keep track of recently endorsed IBs to avoid double counting
77+
var recently_endorsed_IB_UUIDs = [];
78+
7679
// accumulate the size of all endorsed IBs.
7780
var total_endorsed_data = 0;
7881
var total_dropped_data = 0;
@@ -133,12 +136,15 @@ document.addEventListener('DOMContentLoaded', () => {
133136
break;
134137
}
135138
case 'ReceivedEB': {
136-
137-
if (logData.receivedEB.eb_linked_IBs.length != 0) {
138-
queuedIBs = _.differenceWith(queuedIBs, logData.receivedEB.eb_linked_IBs, _.isEqual);
139-
total_endorsed_data += logData.receivedEB.eb_linked_IBs.map(ib => ib.ib_size).reduce((a, b) => a + b, 0);
140-
total_endorsed_IBs += logData.receivedEB.eb_linked_IBs.length;
141-
total_endorsed_latency += logData.receivedEB.eb_linked_IBs.map(ib => logData.receivedEB.eb_slot - ib.ib_slot).reduce((a, b) => a + b, 0);
139+
var new_endorsed_IBs = logData.receivedEB.eb_linked_IBs.filter(ib => !recently_endorsed_IB_UUIDs.includes(ib.ib_UUID));
140+
141+
if (new_endorsed_IBs.length != 0) {
142+
queuedIBs = _.differenceWith(queuedIBs, new_endorsed_IBs, _.isEqual);
143+
total_endorsed_data += new_endorsed_IBs.map(ib => ib.ib_size).reduce((a, b) => a + b, 0);
144+
total_endorsed_IBs += new_endorsed_IBs.length;
145+
total_endorsed_latency += new_endorsed_IBs.map(ib => logData.receivedEB.eb_slot - ib.ib_slot).reduce((a, b) => a + b, 0);
146+
// TODO find a reasonable lenght to truncate to
147+
recently_endorsed_IB_UUIDs = recently_endorsed_IB_UUIDs.concat(new_endorsed_IBs.map(ib => ib.ib_UUID)).slice(-500);
142148
}
143149

144150
// We know that future EBs will link IBs whose slots are

leios-sim/leios-sim.cabal

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ library
4343
, http-types
4444
, text
4545
, time
46+
, uuid
4647
, wai
4748
, wai-extra
4849
, wai-middleware-static

leios-sim/src/Leios/Model.hs

+28-15
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ module Leios.Model where
3838

3939
import Prelude hiding (init)
4040

41+
import Data.UUID (UUID)
4142
import Control.Applicative (asum)
4243
import Control.Concurrent.Class.MonadSTM.TChan (TChan, newTChanIO, readTChan, writeTChan)
4344
import Control.Concurrent.Class.MonadSTM.TQueue (TQueue, newTQueueIO, readTQueue)
4445
import Control.Concurrent.Class.MonadSTM.TVar (TVar, check, modifyTVar', newTVarIO, readTVar, readTVarIO, writeTVar)
45-
import Control.Monad (forever, replicateM, replicateM_)
46+
import Control.Monad (foldM, forever, replicateM, replicateM_)
4647
import Control.Monad.Class.MonadAsync (Async, Concurrently (Concurrently, runConcurrently), MonadAsync, async, race_)
4748
import Control.Monad.Class.MonadSTM (MonadSTM, STM, atomically, retry)
4849
import Control.Monad.Class.MonadTimer (MonadDelay, MonadTimer, threadDelay)
@@ -60,7 +61,7 @@ import qualified Data.PQueue.Max as PQueue
6061
import Data.Word (Word64)
6162
import GHC.Generics (Generic)
6263
import Leios.Trace (mkTracer)
63-
import System.Random (RandomGen, mkStdGen, randomR, split)
64+
import System.Random (RandomGen, mkStdGen, random, randomR, split)
6465
import Text.Pretty.Simple (pPrint)
6566

6667
--------------------------------------------------------------------------------
@@ -71,16 +72,16 @@ import Text.Pretty.Simple (pPrint)
7172
--
7273
-- TODO: we might want to split this between constants and parameters that can be tweaked at runtime.
7374
data Parameters = Parameters
74-
{ _L :: NumberOfSlots
75+
{ _L :: NumberOfSlots
7576
-- ^ Slice length.
76-
, λ :: NumberOfSlices
77+
, λ :: NumberOfSlices
7778
-- ^ Number of slices (of size '_L') the diffusion period takes.
7879
, nodeBandwidth :: BitsPerSecond
79-
, ibSize :: NumberOfBits
80+
, ibSize :: NumberOfBits
8081
-- ^ Size of the diffusion block.
81-
, f_I :: IBFrequency
82-
, f_E :: EBFrequency
83-
, initialSeed :: Int
82+
, f_I :: IBFrequency
83+
, f_E :: EBFrequency
84+
, initialSeed :: Int
8485
}
8586
deriving (Show, Generic)
8687
deriving anyclass (Aeson.ToJSON, Aeson.FromJSON)
@@ -139,6 +140,7 @@ data IB = IB
139140
{ ib_slot :: Slot
140141
, ib_producer :: NodeId
141142
, ib_size :: NumberOfBits
143+
, ib_UUID :: UUID
142144
}
143145
deriving (Show, Eq, Generic)
144146
deriving anyclass (Aeson.ToJSON, Aeson.FromJSON)
@@ -268,13 +270,16 @@ node nodeId nodeStakePercent initialGenerator tracer world continueTVar = do
268270
-- Generate IB blocks
269271
let (numberOfIBsInThisSlot, generator1) =
270272
slotsLed generator (getIBFrequency f_I)
271-
replicateM_ numberOfIBsInThisSlot $ produceIB slot
273+
generator2 <- foldM
274+
produceIB
275+
generator1
276+
$ replicate numberOfIBsInThisSlot slot
272277
-- Generate EB blocks
273-
let (numberOfEBsInThisSlot, generator2) =
274-
slotsLed generator1 (getEBFrequency f_E)
278+
let (numberOfEBsInThisSlot, generator3) =
279+
slotsLed generator2 (getEBFrequency f_E)
275280
replicateM_ numberOfEBsInThisSlot $ produceEB slot
276281
-- Continue
277-
loop generator2
282+
loop generator3
278283
loop initialGenerator
279284

280285
consumer = forever $ do
@@ -293,14 +298,22 @@ node nodeId nodeStakePercent initialGenerator tracer world continueTVar = do
293298
q = ceiling f
294299
(nodeLeads, nextGenerator) =
295300
leadsMultiple generator q nodeStakePercent f
296-
in
301+
in
297302
(length $ filter id nodeLeads, nextGenerator)
298303

299-
produceIB slot = do
304+
produceIB generator slot = do
300305
Parameters{ibSize} <- getParams world
301-
let newIB = IB{ib_slot = slot, ib_producer = nodeId, ib_size = ibSize}
306+
let
307+
(uuid,nextGenerator) = random generator
308+
newIB = IB {
309+
ib_slot = slot
310+
, ib_producer = nodeId
311+
, ib_size = ibSize
312+
, ib_UUID = uuid
313+
}
302314
traceWith tracer (ProducedIB newIB)
303315
MsgIB newIB `sendTo` world
316+
pure nextGenerator
304317

305318
produceEB slot = do
306319
Parameters{_L, λ} <- getParams world

0 commit comments

Comments
 (0)