Skip to content

Commit

Permalink
chore: remove finalnum inherent, clear babe slotToProof map (ChainS…
Browse files Browse the repository at this point in the history
  • Loading branch information
noot authored and timwu20 committed Dec 6, 2021
1 parent b02525b commit 571a0be
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 25 deletions.
3 changes: 0 additions & 3 deletions dot/sync/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ func BuildBlock(t *testing.T, instance runtime.Instance, parent *types.Header, e
err = idata.SetInt64Inherent(types.Babeslot, 1)
require.NoError(t, err)

err = idata.SetBigIntInherent(types.Finalnum, big.NewInt(0))
require.NoError(t, err)

ienc, err := idata.Encode()
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion dot/types/babe.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type BabeConfiguration struct {
C1 uint64 // (1-(c1/c2)) is the probability of a slot being empty
C2 uint64
GenesisAuthorities []*AuthorityRaw
Randomness [32]byte
Randomness [RandomnessLength]byte
SecondarySlots byte
}

Expand Down
1 change: 0 additions & 1 deletion dot/types/inherents.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
var (
Timstap0 = []byte("timstap0")
Babeslot = []byte("babeslot")
Finalnum = []byte("finalnum")
Uncles00 = []byte("uncles00")
)

Expand Down
14 changes: 0 additions & 14 deletions lib/babe/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ func (b *BlockBuilder) buildBlock(parent *types.Header, slot Slot) (*types.Block

logger.Trace("finalised block")

header.ParentHash = parent.Hash()
header.Number.Add(parent.Number, big.NewInt(1))

// create seal and add to digest
seal, err := b.buildBlockSeal(header)
if err != nil {
Expand Down Expand Up @@ -275,17 +272,6 @@ func (b *BlockBuilder) buildBlockInherents(slot Slot) ([][]byte, error) {
return nil, err
}

// add finalnum
fin, err := b.blockState.GetFinalizedHeader(0, 0)
if err != nil {
return nil, err
}

err = idata.SetBigIntInherent(types.Finalnum, fin.Number)
if err != nil {
return nil, err
}

ienc, err := idata.Encode()
if err != nil {
return nil, err
Expand Down
4 changes: 4 additions & 0 deletions lib/babe/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ func (b *Service) initiateEpoch(epoch uint64) error {
logger.Debug("initiating epoch", "epoch", epoch, "start slot", startSlot)

for i := startSlot; i < startSlot+b.epochLength; i++ {
if epoch > 0 {
delete(b.slotToProof, i-b.epochLength) // clear data from previous epoch
}

b.slotToProof[i], err = b.runLottery(i, epoch)
if err != nil {
return fmt.Errorf("error running slot lottery at slot %d: error %s", i, err)
Expand Down
3 changes: 0 additions & 3 deletions lib/runtime/life/exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ func buildBlock(t *testing.T, instance runtime.Instance) *types.Block {
err = idata.SetInt64Inherent(types.Babeslot, 1)
require.NoError(t, err)

err = idata.SetBigIntInherent(types.Finalnum, big.NewInt(0))
require.NoError(t, err)

ienc, err := idata.Encode()
require.NoError(t, err)

Expand Down
3 changes: 0 additions & 3 deletions lib/runtime/wasmer/exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,6 @@ func buildBlock(t *testing.T, instance runtime.Instance) *types.Block {
err = idata.SetInt64Inherent(types.Babeslot, 1)
require.NoError(t, err)

err = idata.SetBigIntInherent(types.Finalnum, big.NewInt(0))
require.NoError(t, err)

ienc, err := idata.Encode()
require.NoError(t, err)

Expand Down

0 comments on commit 571a0be

Please sign in to comment.