Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove finalnum inherent, clear babe slotToProof map #1632

Merged
merged 6 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
15 changes: 2 additions & 13 deletions lib/babe/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ 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))
// header.ParentHash = parent.Hash()
// header.Number.Add(parent.Number, big.NewInt(1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?


// create seal and add to digest
seal, err := b.buildBlockSeal(header)
Expand Down Expand Up @@ -275,17 +275,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