Skip to content

Commit 1b17c6c

Browse files
authored
feat: add ChainProposedLength into the manifest (#788)
* feat: add ChainProposedLength into the manifest Signed-off-by: Jakub Sztandera <[email protected]> * Separate out max length and defualt length Increase max length to 128 to line up with merke tree size Signed-off-by: Jakub Sztandera <[email protected]> * fix manifest test Signed-off-by: Jakub Sztandera <[email protected]> * Change ChainMaxLen to 128 Signed-off-by: Jakub Sztandera <[email protected]> --------- Signed-off-by: Jakub Sztandera <[email protected]>
1 parent b17b794 commit 1b17c6c

File tree

6 files changed

+16
-4
lines changed

6 files changed

+16
-4
lines changed

consensus_inputs.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ func (h *gpbftInputs) GetProposal(ctx context.Context, instance uint64) (_ *gpbf
151151
return nil, nil, fmt.Errorf("computing powertable CID for base: %w", err)
152152
}
153153

154-
suffix := make([]gpbft.TipSet, min(gpbft.ChainMaxLen-1, len(collectedChain))) // -1 because of base
154+
suffixLen := min(gpbft.ChainMaxLen, h.manifest.Gpbft.ChainProposedLength) - 1 // -1 because of base
155+
suffix := make([]gpbft.TipSet, min(suffixLen, len(collectedChain)))
155156
for i := range suffix {
156157
suffix[i].Key = collectedChain[i].Key()
157158
suffix[i].Epoch = collectedChain[i].Epoch()

f3_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func TestF3LateBootstrap(t *testing.T) {
239239
env := newTestEnvironment(t).withNodes(2).start()
240240

241241
// Wait till we're "caught up".
242-
bootstrapInstances := uint64(env.manifest.EC.Finality/(gpbft.ChainMaxLen-1)) + 1
242+
bootstrapInstances := uint64(env.manifest.EC.Finality/(gpbft.ChainDefaultLen-1)) + 1
243243
env.waitForInstanceNumber(bootstrapInstances, 30*time.Second, true)
244244

245245
// Wait until we've finalized a distant epoch. Once we do, our EC will forget the historical

gpbft/chain.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ const (
2121
// CidMaxLen specifies the maximum length of a CID.
2222
CidMaxLen = 38
2323
// ChainMaxLen specifies the maximum length of a chain value.
24-
ChainMaxLen = 100
24+
ChainMaxLen = 128
25+
// ChainDefaultLen specifies the default length of chain value.
26+
ChainDefaultLen = 100
2527
// TipsetKeyMaxLen specifies the maximum length of a tipset. The max size is
2628
// chosen such that it allows ample space for an impossibly-unlikely number of
2729
// blocks in a tipset, while maintaining a practical limit to prevent abuse.

internal/powerstore/powerstore_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func advanceF3(t *testing.T, m *manifest.Manifest, ps *powerstore.Store, cs *cer
201201
basePt, err := cs.GetPowerTable(ctx, instance)
202202
require.NoError(t, err)
203203
for len(gpbftChain) > 1 {
204-
count := min(len(gpbftChain), rand.IntN(epochsPerCert+1)+1, gpbft.ChainMaxLen)
204+
count := min(len(gpbftChain), rand.IntN(epochsPerCert+1)+1, gpbft.ChainDefaultLen)
205205
newChain := gpbftChain[:count]
206206

207207
nextPt := basePt

manifest/manifest.go

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var (
3434
Delta: 6 * time.Second,
3535
DeltaBackOffExponent: 2.0,
3636
MaxLookaheadRounds: 5,
37+
ChainProposedLength: gpbft.ChainDefaultLen,
3738
RebroadcastBackoffBase: 6 * time.Second,
3839
RebroadcastBackoffSpread: 0.1,
3940
RebroadcastBackoffExponent: 1.3,
@@ -93,6 +94,8 @@ type GpbftConfig struct {
9394
DeltaBackOffExponent float64
9495
MaxLookaheadRounds uint64
9596

97+
ChainProposedLength int
98+
9699
RebroadcastBackoffBase time.Duration
97100
RebroadcastBackoffExponent float64
98101
RebroadcastBackoffSpread float64
@@ -107,6 +110,11 @@ func (g *GpbftConfig) Validate() error {
107110
return fmt.Errorf("GPBFT backoff exponent must be at least 1.0, was %f", g.DeltaBackOffExponent)
108111
}
109112

113+
if g.ChainProposedLength < 1 {
114+
return fmt.Errorf("GPBFT proposed chain length cannot be less than 1")
115+
}
116+
// not checking against gpbft.ChainMaxLen, it is handled gracefully
117+
110118
if g.RebroadcastBackoffBase <= 0 {
111119
return fmt.Errorf("GPBFT rebroadcast backoff base must be greater than 0, was %s",
112120
g.RebroadcastBackoffBase)

manifest/manifest_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var base = manifest.Manifest{
3131
Delta: 10,
3232
DeltaBackOffExponent: 1.2,
3333
MaxLookaheadRounds: 5,
34+
ChainProposedLength: gpbft.ChainDefaultLen,
3435
RebroadcastBackoffBase: 10,
3536
RebroadcastBackoffExponent: 1.3,
3637
RebroadcastBackoffMax: 30,

0 commit comments

Comments
 (0)