Skip to content

Commit

Permalink
Orphan non-accepted blocks before force-committing a slot.
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrm50 committed Nov 21, 2023
1 parent 0e57f8b commit 42ab4fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/protocol/block_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ func (b *BlockDispatcher) processWarpSyncResponse(commitmentID iotago.Commitment

if len(blockIDs) == 0 {
forceCommitmentFunc()

return nil
}

Expand Down
12 changes: 12 additions & 0 deletions pkg/protocol/engine/notarization/slotnotarization/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/iotaledger/iota-core/pkg/protocol/engine/blocks"
"github.com/iotaledger/iota-core/pkg/protocol/engine/ledger"
"github.com/iotaledger/iota-core/pkg/protocol/engine/notarization"
"github.com/iotaledger/iota-core/pkg/protocol/engine/tipselection"
"github.com/iotaledger/iota-core/pkg/protocol/engine/upgrade"
"github.com/iotaledger/iota-core/pkg/protocol/sybilprotection"
"github.com/iotaledger/iota-core/pkg/storage"
Expand All @@ -34,6 +35,7 @@ type Manager struct {
ledger ledger.Ledger
sybilProtection sybilprotection.SybilProtection
upgradeOrchestrator upgrade.Orchestrator
tipSelection tipselection.TipSelection

storage *storage.Storage

Expand All @@ -57,6 +59,7 @@ func NewProvider() module.Provider[*engine.Engine, notarization.Notarization] {

m.ledger = e.Ledger
m.sybilProtection = e.SybilProtection
m.tipSelection = e.TipSelection
m.attestation = e.Attestations
m.upgradeOrchestrator = e.UpgradeOrchestrator

Expand Down Expand Up @@ -111,6 +114,15 @@ func (m *Manager) ForceCommit(slot iotago.SlotIndex) (*model.Commitment, error)
return nil, ierrors.New("notarization manager was stopped")
}

// When force committing set acceptance time in TipSelection to the end of the epoch
// that is LivenessThresholdUpperBound in the future from the committed slot,
// so that all the unaccepted blocks in force committed slot are orphaned.
// The value must be at least LivenessThresholdUpperBound in the future.
// This is to avoid the situation in which future cone of those blocks becomes accepted after force-committing the slot.
// This would cause issues with consistency as it's impossible to add blocks to a committed slot.
artificialAcceptanceTime := m.apiProvider.APIForSlot(slot).TimeProvider().SlotEndTime(slot).Add(m.apiProvider.APIForSlot(slot).ProtocolParameters().LivenessThresholdUpperBound())
m.tipSelection.SetAcceptanceTime(artificialAcceptanceTime)

commitment, err := m.createCommitment(slot)
if err != nil {
return nil, ierrors.Wrapf(err, "failed to create commitment for slot %d", slot)
Expand Down

0 comments on commit 42ab4fd

Please sign in to comment.