@@ -190,6 +190,47 @@ type PublicConfig struct {
190190 MaxDurationShouldAcceptAttestedReport time.Duration // Context deadline passed to ShouldAcceptAttestedReport.
191191 MaxDurationShouldTransmitAcceptedReport time.Duration // Context deadline passed to ShouldTransmitAcceptedReport.
192192
193+ // PrevConfigDigest is the config digest of the previous instance that this
194+ // next instance is a continuation of. The previous instance must overlap in
195+ // at least one oracle with the next instance, though larger overlaps are
196+ // highly encouraged and will improve the initial synchronization
197+ // performance.
198+ //
199+ // WARNING! This is an advanced feature and should only be used if you
200+ // *really* know what you are doing. Failure to set this or any of the other
201+ // Prev fields correctly will result in the instance not making any
202+ // progress or data loss.
203+ PrevConfigDigest * types.ConfigDigest
204+ // PrevSeqNr is the sequence number of the previous instance that this next
205+ // instance will continue from. Sequence numbers in the next instance will
206+ // continue from PrevSeqNr. This must be a snapshot sequence number for the
207+ // previous instance, i.e., PrevSeqNr % PrevInstanceConfig.SnapshotInterval
208+ // == 0. The overlapping oracle must have locally committed the state as of
209+ // PrevSeqNr and the snapshot associated with PrevSeqNr must be in the
210+ // retention window implied by
211+ // PrevInstanceConfig.MaxHistoricalSnapshotsRetained and
212+ // PrevInstanceConfig.SnapshotInterval. (For instances whose previous
213+ // instance already has a PrevSeqNr, this imples PrevSeqNr >
214+ // PrevInstanceConfig.PrevSeqNr.)
215+ //
216+ // Be aware that any state transitions committed after PrevSeqNr in the
217+ // previous instance will not be available in the next instance (and
218+ // typically be lost forever).
219+ //
220+ // WARNING! This is an advanced feature and should only be used if you
221+ // *really* know what you are doing. Failure to set this or any of the other
222+ // Prev fields correctly will result in the instance not making any
223+ // progress or data loss.
224+ PrevSeqNr * uint64
225+ // PrevHistoryDigest is the history digest of the previous instance at
226+ // PrevSeqNr.
227+ //
228+ // WARNING! This is an advanced feature and should only be used if you
229+ // *really* know what you are doing. Failure to set this or any of the other
230+ // Prev fields correctly will result in the instance not making any
231+ // progress or data loss.
232+ PrevHistoryDigest * types.HistoryDigest
233+
193234 // The maximum number of oracles that are assumed to be faulty while the
194235 // protocol can retain liveness and safety. Unless you really know what
195236 // you’re doing, be sure to set this to floor((n-1)/3) where n is the total
@@ -297,6 +338,23 @@ func (c *PublicConfig) GetBlobChunkBytes() int {
297338 return util .NilCoalesce (c .BlobChunkBytes , DefaultBlobChunkBytes )
298339}
299340
341+ type PublicConfigPrevFields struct {
342+ PrevConfigDigest types.ConfigDigest
343+ PrevSeqNr uint64
344+ PrevHistoryDigest types.HistoryDigest
345+ }
346+
347+ func (c * PublicConfig ) GetPrevFields () (PublicConfigPrevFields , bool ) {
348+ if c .PrevConfigDigest == nil || c .PrevSeqNr == nil || c .PrevHistoryDigest == nil {
349+ return PublicConfigPrevFields {}, false
350+ }
351+ return PublicConfigPrevFields {
352+ * c .PrevConfigDigest ,
353+ * c .PrevSeqNr ,
354+ * c .PrevHistoryDigest ,
355+ }, true
356+ }
357+
300358// The minimum interval between round starts.
301359// This is not a guaranteed lower bound. For example, a malicious leader could
302360// violate this bound.
@@ -400,6 +458,10 @@ func publicConfigFromContractConfig(skipInsaneForProductionChecks bool, change t
400458 oc .MaxDurationShouldAcceptAttestedReport ,
401459 oc .MaxDurationShouldTransmitAcceptedReport ,
402460
461+ oc .PrevConfigDigest ,
462+ oc .PrevSeqNr ,
463+ oc .PrevHistoryDigest ,
464+
403465 int (change .F ),
404466 change .OnchainConfig ,
405467 change .ConfigDigest ,
@@ -554,6 +616,13 @@ func checkPublicConfigParameters(cfg PublicConfig) error {
554616 // be made when you change this function!
555617 /////////////////////////////////////////////////////////////////
556618
619+ if ! ((cfg .PrevConfigDigest == nil ) == (cfg .PrevSeqNr == nil ) && (cfg .PrevSeqNr == nil ) == (cfg .PrevHistoryDigest == nil )) {
620+ return fmt .Errorf ("PrevConfigDigest, PrevSeqNr, and PrevHistoryDigest must all be set or all be nil" )
621+ }
622+ if cfg .PrevSeqNr != nil && ! (0 < * cfg .PrevSeqNr ) {
623+ return fmt .Errorf ("PrevSeqNr (%v) must be positive if non-nil" , * cfg .PrevSeqNr )
624+ }
625+
557626 if ! (0 <= cfg .F && cfg .F * 3 < cfg .N ()) {
558627 return fmt .Errorf ("F (%v) must be non-negative and less than N/3 (N = %v)" ,
559628 cfg .F , cfg .N ())
0 commit comments