Skip to content

Commit

Permalink
core: update committee every [committee length] blocks
Browse files Browse the repository at this point in the history
Was changed in neo-project/neo#1848. Affects
storage dumps.
  • Loading branch information
AnnaShaleva committed Dec 3, 2020
1 parent 586dede commit 1b3f598
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
45 changes: 23 additions & 22 deletions pkg/consensus/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestService_NextConsensus(t *testing.T) {
require.Equal(t, h, hdr.NextConsensus)
}

t.Run("vote 1 block before update", func(t *testing.T) {
t.Run("vote 1 block before update", func(t *testing.T) { // voting occurs every block in SingleTestChain
srv, acc := initServiceNextConsensus(t, newAcc, 1)
bc := srv.Chain.(*core.Blockchain)
defer bc.Close()
Expand All @@ -135,27 +135,28 @@ func TestService_NextConsensus(t *testing.T) {
srv.dbft.OnTimeout(timer.HV{Height: srv.dbft.BlockIndex})
checkNextConsensus(t, bc, height+1, hash.Hash160(script))
})

t.Run("vote 2 blocks before update", func(t *testing.T) {
srv, acc := initServiceNextConsensus(t, newAcc, 2)
bc := srv.Chain.(*core.Blockchain)
defer bc.Close()

height := bc.BlockHeight()
checkNextConsensus(t, bc, height, acc.Contract.ScriptHash())
// Reset <- we are here
// OnPersist <- nothing to do
// Block <-
//
// Reset <- update next consensus
// OnPersist <- update committee
// Block <-
srv.dbft.OnTimeout(timer.HV{Height: srv.dbft.BlockIndex})
checkNextConsensus(t, bc, height+1, acc.Contract.ScriptHash())

srv.dbft.OnTimeout(timer.HV{Height: srv.dbft.BlockIndex})
checkNextConsensus(t, bc, height+2, hash.Hash160(script))
})
/*
t.Run("vote 2 blocks before update", func(t *testing.T) {
srv, acc := initServiceNextConsensus(t, newAcc, 2)
bc := srv.Chain.(*core.Blockchain)
defer bc.Close()
height := bc.BlockHeight()
checkNextConsensus(t, bc, height, acc.Contract.ScriptHash())
// Reset <- we are here
// OnPersist <- nothing to do
// Block <-
//
// Reset <- update next consensus
// OnPersist <- update committee
// Block <-
srv.dbft.OnTimeout(timer.HV{Height: srv.dbft.BlockIndex})
checkNextConsensus(t, bc, height+1, acc.Contract.ScriptHash())
srv.dbft.OnTimeout(timer.HV{Height: srv.dbft.BlockIndex})
checkNextConsensus(t, bc, height+2, hash.Hash160(script))
})
*/
}

func TestService_GetVerified(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/native/native_neo.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (n *NEO) updateCommittee(ic *interop.Context) error {
// ShouldUpdateCommittee returns true if committee is updated at block h.
func ShouldUpdateCommittee(h uint32, bc blockchainer.Blockchainer) bool {
cfg := bc.GetConfig()
r := cfg.ValidatorsCount + len(cfg.StandbyCommittee)
r := len(cfg.StandbyCommittee)
return h%uint32(r) == 0
}

Expand Down

0 comments on commit 1b3f598

Please sign in to comment.