Fix Validator Assignment (#609)

* fix

* ready
This commit is contained in:
Raul Jordan 2018-10-02 22:39:19 -05:00 committed by GitHub
parent 763d0d6bdc
commit b8036fcb0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View File

@ -44,7 +44,7 @@ var defaultConfig = &Config{
} }
var demoConfig = &Config{ var demoConfig = &Config{
GenesisTime: time.Now().Add(-8 * time.Second), GenesisTime: time.Now(),
CycleLength: uint64(5), CycleLength: uint64(5),
ShardCount: 3, ShardCount: 3,
DefaultBalance: new(big.Int).Div(big.NewInt(32), big.NewInt(int64(1e18))), DefaultBalance: new(big.Int).Div(big.NewInt(32), big.NewInt(int64(1e18))),

View File

@ -181,8 +181,16 @@ func (sim *Simulator) run(delayChan <-chan time.Time, done <-chan struct{}) {
powChainRef = []byte{byte(sim.slotNum)} powChainRef = []byte{byte(sim.slotNum)}
} }
var blockSlot uint64
if sim.chainService.CurrentBeaconSlot() == 0 {
// cannot process a genesis block, so we start from 1
blockSlot = 1
} else {
blockSlot = sim.chainService.CurrentBeaconSlot()
}
block := types.NewBlock(&pb.BeaconBlock{ block := types.NewBlock(&pb.BeaconBlock{
SlotNumber: sim.chainService.CurrentBeaconSlot(), SlotNumber: blockSlot,
Timestamp: ptypes.TimestampNow(), Timestamp: ptypes.TimestampNow(),
PowChainRef: powChainRef, PowChainRef: powChainRef,
ActiveStateHash: activeStateHash[:], ActiveStateHash: activeStateHash[:],

View File

@ -210,7 +210,10 @@ func (c *CrystallizedState) Validators() []*pb.ValidatorRecord {
// IsCycleTransition checks if a new cycle has been reached. At that point, // IsCycleTransition checks if a new cycle has been reached. At that point,
// a new crystallized state and active state transition will occur. // a new crystallized state and active state transition will occur.
func (c *CrystallizedState) IsCycleTransition(slotNumber uint64) bool { func (c *CrystallizedState) IsCycleTransition(slotNumber uint64) bool {
return slotNumber >= c.LastStateRecalc()+params.GetConfig().CycleLength if c.LastStateRecalc() == 0 && slotNumber == params.GetConfig().CycleLength-1 {
return true
}
return slotNumber >= c.LastStateRecalc()+params.GetConfig().CycleLength-1
} }
// isDynastyTransition checks if a dynasty transition can be processed. At that point, // isDynastyTransition checks if a dynasty transition can be processed. At that point,