Skip to content

Commit 5985a11

Browse files
committed
Update adr-019-forced-inclusion-mechanism.md
1 parent 3a29a38 commit 5985a11

File tree

1 file changed

+42
-48
lines changed

1 file changed

+42
-48
lines changed

docs/adr/adr-019-forced-inclusion-mechanism.md

Lines changed: 42 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
- 2025-03-24: Initial draft
66
- 2025-04-23: Renumbered from ADR-018 to ADR-019 to maintain chronological order.
77
- 2025-11-10: Updated to reflect actual implementation
8-
- 2025-12-09: Added documentation for ForcedInclusionGracePeriod parameter
98

109
## Context
1110

@@ -352,8 +351,9 @@ func (s *Syncer) verifyForcedInclusionTxs(currentState State, data *Data) error
352351
// Grace period provides tolerance for temporary DA unavailability
353352
var maliciousTxs, remainingPending []pendingForcedInclusionTx
354353
for _, pending := range stillPending {
355-
// Calculate grace boundary: epoch end + (grace periods × epoch size)
356-
graceBoundary := pending.EpochEnd + (s.genesis.ForcedInclusionGracePeriod * s.genesis.DAEpochForcedInclusion)
354+
// Calculate grace boundary: epoch end + (effective grace periods × epoch size)
355+
effectiveGracePeriod := s.getEffectiveGracePeriod()
356+
graceBoundary := pending.EpochEnd + (effectiveGracePeriod * s.genesis.DAEpochForcedInclusion)
357357

358358
// If current DA height is past the grace boundary, these txs MUST have been included
359359
if currentState.DAHeight > graceBoundary {
@@ -368,7 +368,7 @@ func (s *Syncer) verifyForcedInclusionTxs(currentState State, data *Data) error
368368

369369
// 7. Reject block if sequencer censored forced txs past grace boundary
370370
if len(maliciousTxs) > 0 {
371-
return fmt.Errorf("sequencer is malicious: %d forced inclusion transactions past grace boundary (grace_periods=%d) not included", len(maliciousTxs), s.genesis.ForcedInclusionGracePeriod)
371+
return fmt.Errorf("sequencer is malicious: %d forced inclusion transactions past grace boundary not included", len(maliciousTxs))
372372
}
373373

374374
return nil
@@ -451,40 +451,40 @@ The grace period mechanism provides tolerance for chain congestion while maintai
451451

452452
**Problem**: If the DA layer experiences temporary unavailability or the chain congestion, the sequencer may be unable to fetch forced inclusion transactions from a completed epoch. Without a grace period, full nodes would immediately flag the sequencer as malicious.
453453

454-
**Solution**: The `ForcedInclusionGracePeriod` parameter allows forced inclusion transactions from epoch N to be included during epochs N+1 through N+k (where k is the grace period) before being flagged as malicious.
454+
**Solution**: The grace period mechanism allows forced inclusion transactions from epoch N to be included in subsequent epochs before being flagged as malicious. The grace period is dynamically adjusted based on chain fullness.
455455

456456
**Grace Boundary Calculation**:
457457

458458
```go
459-
graceBoundary := epochEnd + (ForcedInclusionGracePeriod * DAEpochForcedInclusion)
459+
graceBoundary := epochEnd + (effectiveGracePeriod * DAEpochForcedInclusion)
460460

461-
// Example with ForcedInclusionGracePeriod = 1, DAEpochForcedInclusion = 50:
461+
// Example with base grace period = 1 epoch, DAEpochForcedInclusion = 50:
462462
// - Epoch N ends at DA height 100
463-
// - Grace boundary = 100 + (1 * 50) = 150
464-
// - Transaction must be included by DA height 150
465-
// - If not included by height 151+, sequencer is malicious
463+
// - Grace boundary = 100 + (1 * 50) = 150 (adjusted dynamically by chain fullness)
464+
// - Transaction must be included while currentDAHeight <= graceBoundary
465+
// - If currentDAHeight > graceBoundary without inclusion, sequencer is malicious
466466
```
467467

468468
**Configuration Recommendations**:
469469

470-
- **Production (default)**: `ForcedInclusionGracePeriod = 1`
471-
- Tolerates ~1 epoch of DA unavailability (e.g., 50 DA blocks)
470+
- **Production (default)**: Base grace period of 1 epoch
471+
- Automatically adjusted based on chain fullness
472472
- Balances censorship resistance with reliability
473-
- **High Security / Reliable DA**: `ForcedInclusionGracePeriod = 0`
474-
- Strict enforcement, no tolerance
473+
- **High Security / Reliable DA**: Minimum grace period
474+
- Stricter enforcement when block space is available
475475
- Requires 99.9%+ DA uptime
476-
- Immediate detection of censorship
477-
- **Unreliable DA**: `ForcedInclusionGracePeriod = 2+`
478-
- Higher tolerance for DA outages
479-
- Reduced censorship resistance (longer time to detect malicious behavior)
476+
- Faster detection of censorship
477+
- **Unreliable DA**: Network adjusts grace period dynamically
478+
- Higher tolerance (up to 3x base period) when chain is congested
479+
- Reduced censorship resistance temporarily to avoid false positives
480480

481481
**Verification Logic**:
482482

483483
1. Forced inclusion transactions from epoch N are tracked with their epoch boundaries
484484
2. Transactions not immediately included are added to pending queue
485485
3. Each block, full nodes check if pending transactions are past their grace boundary
486-
4. If `currentDAHeight > graceBoundary`, the sequencer is flagged as malicious
487-
5. Transactions within the grace period remain in pending queue without error
486+
4. If `currentDAHeight > graceBoundary`, the sequencer is flagged as malicious (strictly greater than)
487+
5. Transactions within the grace period (where `currentDAHeight <= graceBoundary`) remain in pending queue without error
488488

489489
**Benefits**:
490490

@@ -495,7 +495,7 @@ graceBoundary := epochEnd + (ForcedInclusionGracePeriod * DAEpochForcedInclusion
495495

496496
**Examples and Edge Cases**:
497497

498-
Configuration: `DAEpochForcedInclusion = 50`, `ForcedInclusionGracePeriod = 1`
498+
Configuration: `DAEpochForcedInclusion = 50`, Base grace period of 1 epoch (dynamically adjusted)
499499

500500
_Example 1: Normal Inclusion (Within Same Epoch)_
501501

@@ -528,14 +528,15 @@ _Example 3: Malicious Sequencer (Past Grace Boundary)_
528528
- Result: ❌ Block rejected, sequencer flagged as malicious
529529
```
530530

531-
_Example 4: Strict Mode (Grace Period = 0)_
531+
_Example 4: Low Chain Activity (Minimum Grace Period)_
532532

533533
```
534-
- ForcedInclusionGracePeriod = 0
534+
- Chain is mostly empty (<20% full)
535+
- Grace period is at minimum (0.5x base period)
535536
- Forced tx submitted at height 75 (epoch 51-100)
536-
- Sequencer must include by height 100 (epoch end)
537-
- Block at height 101 without tx is rejected
538-
- Result: Immediate censorship detection, requires high DA reliability
537+
- Grace boundary ≈ 100 + (0.5 × 50) = 125
538+
- Stricter enforcement applied when chain is empty
539+
- Result: Faster censorship detection when block space is available
539540
```
540541

541542
_Example 5: Multiple Pending Transactions_
@@ -549,14 +550,15 @@ _Example 5: Multiple Pending Transactions_
549550
- Result: Block rejected due to Tx A
550551
```
551552

552-
_Example 6: Extended Grace Period (Grace Period = 2)_
553+
_Example 6: High Chain Activity (Extended Grace Period)_
553554

554555
```
555-
- ForcedInclusionGracePeriod = 2
556+
- Chain is highly congested (>80% full)
557+
- Grace period is extended (up to 3x base period)
556558
- Forced tx submitted at height 75 (epoch 51-100)
557-
- Grace boundary = 100 + (2 × 50) = 200
558-
- Sequencer has until DA height 200 to include tx
559-
- Result: More tolerance but delayed censorship detection
559+
- Grace boundary 100 + (3 × 50) = 250
560+
- Higher tolerance during congestion to avoid false positives
561+
- Result: Better operational reliability when block space is scarce
560562
```
561563

562564
#### Size Validation and Max Bytes Handling
@@ -633,12 +635,6 @@ type Genesis struct {
633635
// Higher values reduce DA queries but increase latency
634636
// Lower values increase DA queries but improve responsiveness
635637
DAEpochForcedInclusion uint64
636-
// Number of additional epochs allowed for including forced inclusion transactions
637-
// before marking the sequencer as malicious. Provides tolerance for temporary DA unavailability.
638-
// Value of 0: Strict enforcement (no grace period) - requires 99.9% DA uptime
639-
// Value of 1: Transactions from epoch N can be included through epoch N+1 (recommended)
640-
// Value of 2+: Higher tolerance for unreliable DA environments
641-
ForcedInclusionGracePeriod uint64
642638
}
643639

644640
type DAConfig struct {
@@ -664,8 +660,7 @@ type NodeConfig struct {
664660
# genesis.json
665661
{
666662
"chain_id": "my-rollup",
667-
"forced_inclusion_da_epoch": 10, # Scan 10 DA blocks at a time
668-
"forced_inclusion_grace_period": 1 # Allow 1 epoch grace period (recommended for production)
663+
"da_epoch_forced_inclusion": 10 # Scan 10 DA blocks at a time
669664
}
670665

671666
# config.toml
@@ -683,8 +678,7 @@ based_sequencer = false # Use traditional sequencer
683678
# genesis.json
684679
{
685680
"chain_id": "my-rollup",
686-
"forced_inclusion_da_epoch": 5, # Scan 5 DA blocks at a time
687-
"forced_inclusion_grace_period": 1 # Allow 1 epoch grace period (balances reliability and censorship detection)
681+
"da_epoch_forced_inclusion": 5 # Scan 5 DA blocks at a time
688682
}
689683

690684
# config.toml
@@ -726,19 +720,19 @@ based_sequencer = true # Use based sequencer
726720
b. Build map of transactions in block
727721
c. Check if pending forced txs from previous epochs are included
728722
d. Add any new forced txs not yet included to pending queue
729-
e. Calculate grace boundary for each pending tx:
730-
graceBoundary = epochEnd + (ForcedInclusionGracePeriod × DAEpochForcedInclusion)
723+
e. Calculate grace boundary for each pending tx (dynamically adjusted by chain fullness):
724+
graceBoundary = epochEnd + (effectiveGracePeriod × DAEpochForcedInclusion)
731725
f. Check if any pending txs are past their grace boundary
732726
g. If txs past grace boundary are not included: reject block, flag malicious proposer
733727
h. If txs within grace period: keep in pending queue, allow block
734728
3. Apply block if verification passes
735729

736-
**Grace Period Example** (with `ForcedInclusionGracePeriod = 1`, `DAEpochForcedInclusion = 50`):
730+
**Grace Period Example** (with base grace period = 1 epoch, `DAEpochForcedInclusion = 50`):
737731

738732
- Forced tx appears in epoch ending at DA height 100
739733
- Grace boundary = 100 + (1 × 50) = 150
740734
- Transaction can be included at any DA height from 101 to 150
741-
- At DA height 151+, if not included, sequencer is flagged as malicious
735+
- When currentDAHeight > 150 without inclusion, sequencer is flagged as malicious
742736

743737
### Efficiency Considerations
744738

@@ -811,16 +805,16 @@ Accepted and Implemented
811805
2. **DA Dependency**: Requires DA layer to support multiple namespaces
812806
3. **Higher DA Costs**: Users pay DA posting fees for forced inclusion
813807
4. **Additional Complexity**: New component (DA Retriever) and verification logic with grace period tracking
814-
5. **Epoch Configuration**: Requires setting `DAEpochForcedInclusion` and `ForcedInclusionGracePeriod` in genesis (consensus parameters)
815-
6. **Grace Period Trade-off**: Longer grace periods delay censorship detection but improve operational reliability
808+
5. **Epoch Configuration**: Requires setting `DAEpochForcedInclusion` in genesis (consensus parameter)
809+
6. **Grace Period Adjustment**: Grace period is dynamically adjusted based on block fullness to balance censorship detection with operational reliability
816810

817811
### Neutral
818812

819813
1. **Two Sequencer Types**: Choice between single (hybrid) and based (DA-only)
820814
2. **Privacy Model Unchanged**: Forced inclusion has same privacy as normal path
821815
3. **Monitoring**: Operators should monitor forced inclusion namespace usage and grace period metrics
822816
4. **Documentation**: Users need guidance on when to use forced inclusion and grace period implications
823-
5. **Genesis Parameters**: `DAEpochForcedInclusion` and `ForcedInclusionGracePeriod` are consensus parameters fixed at genesis
817+
5. **Genesis Parameters**: `DAEpochForcedInclusion` is a consensus parameter fixed at genesis; grace period adjustment is dynamic
824818

825819
## References
826820

0 commit comments

Comments
 (0)