Skip to content

Commit 932b806

Browse files
committed
Add finalize API to EC backend
Expand the F3 EC backend API to mark a given tipset as final. This translates to checkpointing the tipset in Lotus beyond which no forks are allowed. Part of #603
1 parent 2c6f7bf commit 932b806

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

ec/ec.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,21 @@ type Backend interface {
1414
GetTipsetByEpoch(ctx context.Context, epoch int64) (TipSet, error)
1515
// GetTipset returns the tipset with the given key.
1616
GetTipset(context.Context, gpbft.TipSetKey) (TipSet, error)
17-
// GetHead returns the current head tipset of the chain
17+
// GetHead returns the current head tipset of the chain, which is guaranteed to
18+
// be a descendant of the latest finalized tipset.
19+
//
20+
// See FinalizeTipset.
1821
GetHead(context.Context) (TipSet, error)
1922
// GetParent returns the parent of the current tipset.
2023
GetParent(context.Context, TipSet) (TipSet, error)
2124
// GetPowerTable returns the power table at the tipset given as an argument.
2225
GetPowerTable(context.Context, gpbft.TipSetKey) (gpbft.PowerEntries, error)
26+
// FinalizeTipset marks the given tipset as finalised beyond which no forks are
27+
// allowed to occur. The finalised tipset overrides the head tipset if it is not
28+
// an ancestor of the current head.
29+
//
30+
// See GetHead.
31+
FinalizeTipset(context.Context, TipSet) error
2332
}
2433

2534
type TipSet interface {

internal/consensus/fake_ec.go

+2
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,5 @@ func (ec *FakeEC) GetTipset(_ context.Context, tsk gpbft.TipSetKey) (ec.TipSet,
183183
epoch := binary.BigEndian.Uint64(tsk[6+32-8 : 6+32])
184184
return ec.genTipset(int64(epoch)), nil
185185
}
186+
187+
func (ec *FakeEC) FinalizeTipset(_ context.Context, ts ec.TipSet) error { return nil }

0 commit comments

Comments
 (0)