From 933bb4ca7544b40a3df993b6d55b42c093ed9184 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 16 Nov 2020 20:12:23 +0300 Subject: [PATCH] core: update committee every [committee length] blocks Was changed in https://github.com/neo-project/neo/pull/1848. Affects storage dumps. --- pkg/consensus/consensus_test.go | 41 +++++++++++++++++---------------- pkg/core/native/native_neo.go | 2 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/pkg/consensus/consensus_test.go b/pkg/consensus/consensus_test.go index ccb28e928..88e85359a 100644 --- a/pkg/consensus/consensus_test.go +++ b/pkg/consensus/consensus_test.go @@ -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() @@ -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() - 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()) - 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)) - }) + srv.dbft.OnTimeout(timer.HV{Height: srv.dbft.BlockIndex}) + checkNextConsensus(t, bc, height+2, hash.Hash160(script)) + }) + */ } func TestService_GetVerified(t *testing.T) { diff --git a/pkg/core/native/native_neo.go b/pkg/core/native/native_neo.go index 05031838d..b94dd543a 100644 --- a/pkg/core/native/native_neo.go +++ b/pkg/core/native/native_neo.go @@ -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 }