57
57
CompressionEnabled : false ,
58
58
}
59
59
60
+ DefaultChainExchangeConfig = ChainExchangeConfig {
61
+ SubscriptionBufferSize : 32 ,
62
+ MaxChainLength : gpbft .ChainDefaultLen ,
63
+ MaxInstanceLookahead : DefaultCommitteeLookback ,
64
+ MaxDiscoveredChainsPerInstance : 1_000 ,
65
+ MaxWantedChainsPerInstance : 1_000 ,
66
+ }
67
+
60
68
// Default instance alignment when catching up.
61
69
DefaultCatchUpAlignment = DefaultEcConfig .Period / 2
62
70
)
@@ -171,7 +179,7 @@ type EcConfig struct {
171
179
BaseDecisionBackoffTable []float64
172
180
// HeadLookback number of unfinalized tipsets to remove from the head
173
181
HeadLookback int
174
- // Finalize indicates whether or not F3 should finalize tipsets as F3 agrees on them.
182
+ // Finalize indicates whether F3 should finalize tipsets as F3 agrees on them.
175
183
Finalize bool
176
184
}
177
185
@@ -211,6 +219,31 @@ type PubSubConfig struct {
211
219
212
220
func (p * PubSubConfig ) Validate () error { return nil }
213
221
222
+ type ChainExchangeConfig struct {
223
+ SubscriptionBufferSize int
224
+ MaxChainLength int
225
+ MaxInstanceLookahead uint64
226
+ MaxDiscoveredChainsPerInstance int
227
+ MaxWantedChainsPerInstance int
228
+ }
229
+
230
+ func (cx * ChainExchangeConfig ) Validate () error {
231
+ // Note that MaxInstanceLookahead may be zero, which indicates that the chain
232
+ // exchange will only accept discovery of chains from current instance.
233
+ switch {
234
+ case cx .SubscriptionBufferSize < 1 :
235
+ return fmt .Errorf ("chain exchange subscription buffer size must be at least 1, got: %d" , cx .SubscriptionBufferSize )
236
+ case cx .MaxChainLength < 1 :
237
+ return fmt .Errorf ("chain exchange max chain length must be at least 1, got: %d" , cx .MaxChainLength )
238
+ case cx .MaxDiscoveredChainsPerInstance < 1 :
239
+ return fmt .Errorf ("chain exchange max discovered chains per instance must be at least 1, got: %d" , cx .MaxDiscoveredChainsPerInstance )
240
+ case cx .MaxWantedChainsPerInstance < 1 :
241
+ return fmt .Errorf ("chain exchange max wanted chains per instance must be at least 1, got: %d" , cx .MaxWantedChainsPerInstance )
242
+ default :
243
+ return nil
244
+ }
245
+ }
246
+
214
247
// Manifest identifies the specific configuration for the F3 instance currently running.
215
248
type Manifest struct {
216
249
// Pause stops the participation in F3.
@@ -246,6 +279,8 @@ type Manifest struct {
246
279
CertificateExchange CxConfig
247
280
// PubSubConfig specifies the pubsub related configuration.
248
281
PubSub PubSubConfig
282
+ // ChainExchange specifies the chain exchange configuration parameters.
283
+ ChainExchange ChainExchangeConfig
249
284
}
250
285
251
286
func (m * Manifest ) Equal (o * Manifest ) bool {
@@ -311,6 +346,15 @@ func (m *Manifest) Validate() error {
311
346
if err := m .PubSub .Validate (); err != nil {
312
347
return fmt .Errorf ("invalid manifest: invalid pubsub config: %w" , err )
313
348
}
349
+ if err := m .ChainExchange .Validate (); err != nil {
350
+ return fmt .Errorf ("invalid manifest: invalid chain exchange config: %w" , err )
351
+ }
352
+ if m .ChainExchange .MaxChainLength > m .Gpbft .ChainProposedLength {
353
+ return fmt .Errorf ("invalid manifest: chain exchange max chain length %d exceeds gpbft proposed chain length %d" , m .ChainExchange .MaxChainLength , m .Gpbft .ChainProposedLength )
354
+ }
355
+ if m .ChainExchange .MaxInstanceLookahead > m .CommitteeLookback {
356
+ return fmt .Errorf ("invalid manifest: chain exchange max instance lookahead %d exceeds committee lookback %d" , m .ChainExchange .MaxInstanceLookahead , m .CommitteeLookback )
357
+ }
314
358
315
359
return nil
316
360
}
@@ -328,6 +372,7 @@ func LocalDevnetManifest() *Manifest {
328
372
CertificateExchange : DefaultCxConfig ,
329
373
CatchUpAlignment : DefaultCatchUpAlignment ,
330
374
PubSub : DefaultPubSubConfig ,
375
+ ChainExchange : DefaultChainExchangeConfig ,
331
376
}
332
377
return m
333
378
}
@@ -363,6 +408,10 @@ func PubSubTopicFromNetworkName(nn gpbft.NetworkName) string {
363
408
return "/f3/granite/0.0.2/" + string (nn )
364
409
}
365
410
411
+ func ChainExchangeTopicFromNetworkName (nn gpbft.NetworkName ) string {
412
+ return "/f3/chainexchange/0.0.1/" + string (nn )
413
+ }
414
+
366
415
func (m * Manifest ) GpbftOptions () []gpbft.Option {
367
416
return m .Gpbft .ToOptions ()
368
417
}
0 commit comments