Skip to content

Commit 09a18c8

Browse files
tweag-ev-akaxman6
andauthored
Add adr for leashing and update specification with design (#151)
* Add adr for leashing * Update docs/specification.md --------- Co-authored-by: Alex Mason <alex.mason@tweag.io>
1 parent e8a24a1 commit 09a18c8

3 files changed

Lines changed: 55 additions & 13 deletions

File tree

docs/adr/2025-11-25_002-initial-design.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ slug: 2
33
title: |
44
2. Initial design
55
authors: [tweag-ev-ak]
6-
tags: [Proposed]
6+
tags: [Accepted]
77
---
88

99
## Status
1010

11-
Proposed
11+
Accepted
1212

1313
## Context
1414

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
slug: 4
3+
title: |
4+
4. Node Leashing
5+
authors: [tweag-ev-ak]
6+
tags: [Accepted]
7+
---
8+
9+
## Status
10+
11+
Accepted
12+
13+
## Context
14+
15+
The re-executor can be too slow to follow the node's ledger state. It should be able to leash the node in such a way that the node won't proceed until the re-executor has caught up. The specification describes three strategies for leashing implementation.
16+
17+
1. Pausing the `BlockFetch` client.
18+
2. Removal of the connected peers.
19+
3. Use the LoE mechanism.
20+
21+
## Decision
22+
23+
We decided that the first two strategies are too invasive and the third strategy described in the specification seems to be the most viable and correct one, increasing our chances to get it accepted by the cardano-node developers, since we are utilising the already existing and well-tested mechanism.
24+
25+
## Consequences
26+
27+
We get leashing working and have more chances to get it merged to the upstream cardano-node implementation.

docs/specification.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -300,26 +300,33 @@ failure = acquireFailurePointTooOld
300300
/ acquireFailureStateIsBusy
301301
```
302302

303-
2. Either by adding a boolean flag to the existing `msgAcquire` messages:
303+
2. Either by adding a leashing client identifier to the existing messages:
304304

305305
```
306-
= [0, base.point, ? bool]
307-
/ [8, ? bool]
308-
/ [10, ? bool]
306+
msgAcquire = [0, base.point, ? word32]
307+
/ [8, ? words32]
308+
/ [10, ? words32]
309+
310+
...
311+
312+
msgRelease = [5, ? word32]
309313
```
310314

311-
or by adding new "leashed" versions:
315+
or by adding new leashing messages:
312316

313317
```
314318
msgAcquire = [0, base.point]
315319
/ [8]
316320
/ [10]
317-
/ [12, base.point] ; leashed `MsgAcquire` of `SpecificPoint pt`
318-
/ [13] ; leashed `MsgAcquire` of `VolatileTip`
319-
/ [14] ; leashed `MsgAcquire` of `ImmutableTip`
321+
/ [12, base.point, word32] ; leashing `MsgAcquire` of `SpecificPoint pt`
322+
/ [13, word32] ; leashing `MsgAcquire` of `VolatileTip`
323+
/ [14, word32] ; leashing `MsgAcquire` of `ImmutableTip`
324+
325+
msgRelease = [5]
326+
/ [15, word32]
320327
```
321328

322-
`msgReAcquire` will behave depending on which version of `msgAcquire` was sent.
329+
`msgReAcquire` will behave depending on which version of `msgAcquire` was previously sent.
323330

324331
**Cardano node changes**:
325332

@@ -353,9 +360,17 @@ The cardano-node already uses the "Limit on Eagerness" mechanism to limit itself
353360
354361
https://ouroboros-consensus.cardano.intersectmbo.org/docs/references/miscellaneous/genesis_design/#the-limit-on-eagerness-component
355362

356-
We can implement leashing there utilising the existing LoE component.
363+
We consider the leashing implementation utilising the existing LoE mechanism.
364+
365+
1. We introduce a `LeashingState blk = Map LeashID (AnchoredFragment (HeaderWithTime blk))` structure to keep the leashing fragments associated with each leashing client.
366+
2. We update the `LocalStateQuery` server to interact with that state:
367+
- If a new client connects to the server with `leashId`, the server will put the `leashId` together with the client's leashing fragment into the leashing state;
368+
- The leashing fragment is calculated using the current chain of the node and the `Target (Point Block)` provided by user. It's either a `SpecificPoint pt`, `ImmutableTip` or `VolatileTip`.
369+
- If the connected client sends the `MsgRelease` with the `leashId`, the server will remove the leashing fragment from the state;
370+
3. We introduce a `leashingWatcher` similar to existing `gddWatcher`. This watcher is responsible for watching the leashing state variable and the genesis LoE fragment variable. If either one of them is changed, the leashing watcher will recalculate the current LoE fragment, using the `sharedCandidatePrefix` function, and trigger manually the chain selection mechanism to consider the LoE fragment. This way we introduce the local chain candidates and provide the LoE fragment to the chain selection.
371+
4. Such implementation would support both scenarios - the genesis one and the leashing one. The leashing will work even if the genesis is not enabled.
357372

358-
**Sum up**: the first two strategies seem to be too invasive and we are investigating the third strategy to implement the leashing.
373+
**Summary**: the first two strategies seem to be too invasive and [we decided to implement leashing using the third strategy](adr/2026-02-23_004-node-leashing.md).
359374

360375
#### 7. Configuration Map
361376

0 commit comments

Comments
 (0)