@@ -102,7 +102,15 @@ func (h *gpbftHost) collectChain(base TipSet, head TipSet) ([]TipSet, error) {
102102 // TODO: optimize when head is way beyond base
103103 res := make ([]TipSet , 0 , 2 * gpbft .CHAIN_MAX_LEN )
104104 res = append (res , head )
105+
105106 for ! bytes .Equal (head .Key (), base .Key ()) {
107+ if head .Epoch () < base .Epoch () {
108+ // we reorged away from base
109+ // scream and panic??
110+ // TODO make sure this is correct, re-boostrap/manifest swap code has to be able to
111+ // catch it
112+ panic ("reorg-ed away from base, dunno what to do, reboostrap is the answer" )
113+ }
106114 var err error
107115 head , err = h .client .ec .GetParent (h .runningCtx , head )
108116 if err != nil {
@@ -123,7 +131,7 @@ func (h *gpbftHost) collectChain(base TipSet, head TipSet) ([]TipSet, error) {
123131// ReceiveDecision (or known to be final via some other channel).
124132func (h * gpbftHost ) GetProposalForInstance (instance uint64 ) (* gpbft.SupplementalData , gpbft.ECChain , error ) {
125133 var baseTsk gpbft.TipSetKey
126- if instance == 0 {
134+ if instance == h . manifest . InitialInstance {
127135 ts , err := h .client .ec .GetTipsetByEpoch (h .runningCtx ,
128136 h .manifest .BootstrapEpoch - h .manifest .ECFinality )
129137 if err != nil {
@@ -203,7 +211,7 @@ func (h *gpbftHost) GetCommitteeForInstance(instance uint64) (*gpbft.PowerTable,
203211 var powerEntries gpbft.PowerEntries
204212 var err error
205213
206- if instance < h .manifest .CommiteeLookback {
214+ if instance < h .manifest .InitialInstance + h . manifest . CommiteeLookback {
207215 //boostrap phase
208216 ts , err := h .client .ec .GetTipsetByEpoch (h .runningCtx , h .manifest .BootstrapEpoch - h .manifest .ECFinality )
209217 if err != nil {
@@ -223,8 +231,7 @@ func (h *gpbftHost) GetCommitteeForInstance(instance uint64) (*gpbft.PowerTable,
223231
224232 powerEntries , err = h .client .certStore .GetPowerTable (h .runningCtx , instance )
225233 if err != nil {
226- // this fires every round, is this correct?
227- h .log .Infof ("failed getting power table from certstore: %v, falling back to EC" , err )
234+ h .log .Debugf ("failed getting power table from certstore: %v, falling back to EC" , err )
228235
229236 powerEntries , err = h .client .ec .GetPowerTable (h .runningCtx , powerTsk )
230237 if err != nil {
@@ -318,7 +325,7 @@ func (h *gpbftHost) saveDecision(decision *gpbft.Justification) error {
318325 if err != nil {
319326 return xerrors .Errorf ("forming certificate out of decision: %w" , err )
320327 }
321- _ , _ , _ , err = certs .ValidateFinalityCertificates (h , h .NetworkName (), current .Entries , decision .Vote .Instance , cert . ECChain . Base () )
328+ _ , _ , _ , err = certs .ValidateFinalityCertificates (h , h .NetworkName (), current .Entries , decision .Vote .Instance , nil , * cert )
322329 if err != nil {
323330 return xerrors .Errorf ("certificate is invalid: %w" , err )
324331 }
@@ -327,6 +334,7 @@ func (h *gpbftHost) saveDecision(decision *gpbft.Justification) error {
327334 if err != nil {
328335 return xerrors .Errorf ("saving ceritifcate in a store: %w" , err )
329336 }
337+
330338 return nil
331339}
332340
0 commit comments