@@ -349,6 +349,21 @@ func (cia *chainInfoAPI) VerifyEntry(parent, child *types.BeaconEntry, height ab
349349// the entry has not yet been produced, the call will block until the entry
350350// becomes available
351351func (cia * chainInfoAPI ) StateGetBeaconEntry (ctx context.Context , epoch abi.ChainEpoch ) (* types.BeaconEntry , error ) {
352+ ts := cia .chain .ChainReader .GetHead ()
353+ if epoch <= ts .Height () {
354+ if epoch < 0 {
355+ epoch = 0
356+ }
357+ // get the beacon entry off the chain
358+ ts , err := cia .chain .ChainReader .GetTipSet (ctx , types .EmptyTSK )
359+ if err != nil {
360+ return nil , err
361+ }
362+ r := chain .NewChainRandomnessSource (cia .chain .ChainReader , ts .Key (), cia .chain .Drand , cia .chain .Fork .GetNetworkVersion )
363+ return r .GetBeaconEntry (ctx , epoch )
364+ }
365+
366+ // else we're asking for the future, get it from drand and block until it arrives
352367 b := cia .chain .Drand .BeaconForEpoch (epoch )
353368 nv := cia .chain .Fork .GetNetworkVersion (ctx , epoch )
354369 rr := b .MaxBeaconRoundForEpoch (nv , epoch )
@@ -745,6 +760,7 @@ func (cia *chainInfoAPI) StateGetNetworkParams(ctx context.Context) (*types.Netw
745760 UpgradeDragonHeight : cfg .NetworkParams .ForkUpgradeParam .UpgradeDragonHeight ,
746761 UpgradePhoenixHeight : cfg .NetworkParams .ForkUpgradeParam .UpgradePhoenixHeight ,
747762 UpgradeWaffleHeight : cfg .NetworkParams .ForkUpgradeParam .UpgradeWaffleHeight ,
763+ UpgradeTuktukHeight : cfg .NetworkParams .ForkUpgradeParam .UpgradeTuktukHeight ,
748764 },
749765 Eip155ChainID : cfg .NetworkParams .Eip155ChainID ,
750766 }
0 commit comments