diff --git a/pkg/consensus/consensus.go b/pkg/consensus/consensus.go index c0a74e666..7fee372c9 100644 --- a/pkg/consensus/consensus.go +++ b/pkg/consensus/consensus.go @@ -464,15 +464,8 @@ func (s *service) getValidators(_ ...block.Transaction) []crypto.PublicKey { return pubs } -func (s *service) getConsensusAddress(validators ...crypto.PublicKey) (h util.Uint160) { - pubs := convertKeys(validators) - - script, err := smartcontract.CreateMultiSigRedeemScript(s.dbft.M(), pubs) - if err != nil { - return - } - - return crypto.Hash160(script) +func (s *service) getConsensusAddress(validators ...crypto.PublicKey) util.Uint160 { + return util.Uint160{} } func convertKeys(validators []crypto.PublicKey) (pubs []*keys.PublicKey) { @@ -493,7 +486,16 @@ func (s *service) newBlockFromContext(ctx *dbft.Context) block.Block { block.Block.Network = s.network block.Block.Timestamp = ctx.Timestamp / 1000000 block.Block.Index = ctx.BlockIndex - block.Block.NextConsensus = ctx.NextConsensus + + validators, err := s.Chain.GetValidators() + if err != nil { + return nil + } + script, err := smartcontract.CreateMultiSigRedeemScript(len(validators)-(len(validators)-1)/3, validators) + if err != nil { + return nil + } + block.Block.NextConsensus = crypto.Hash160(script) block.Block.PrevHash = ctx.PrevHash block.Block.Version = ctx.Version block.Block.ConsensusData.Nonce = ctx.Nonce diff --git a/pkg/consensus/payload_test.go b/pkg/consensus/payload_test.go index 6dc2b0985..1cbe97a3b 100644 --- a/pkg/consensus/payload_test.go +++ b/pkg/consensus/payload_test.go @@ -256,7 +256,6 @@ func randomPrepareRequest(t *testing.T) *prepareRequest { for i := 0; i < txCount; i++ { req.transactionHashes[i] = random.Uint256() } - req.nextConsensus = random.Uint160() return req } diff --git a/pkg/consensus/prepare_request.go b/pkg/consensus/prepare_request.go index fb1d314f9..26be085ad 100644 --- a/pkg/consensus/prepare_request.go +++ b/pkg/consensus/prepare_request.go @@ -11,7 +11,6 @@ type prepareRequest struct { timestamp uint64 nonce uint64 transactionHashes []util.Uint256 - nextConsensus util.Uint160 } var _ payload.PrepareRequest = (*prepareRequest)(nil) @@ -20,7 +19,6 @@ var _ payload.PrepareRequest = (*prepareRequest)(nil) func (p *prepareRequest) EncodeBinary(w *io.BinWriter) { w.WriteU64LE(p.timestamp) w.WriteU64LE(p.nonce) - w.WriteBytes(p.nextConsensus[:]) w.WriteArray(p.transactionHashes) } @@ -28,7 +26,6 @@ func (p *prepareRequest) EncodeBinary(w *io.BinWriter) { func (p *prepareRequest) DecodeBinary(r *io.BinReader) { p.timestamp = r.ReadU64LE() p.nonce = r.ReadU64LE() - r.ReadBytes(p.nextConsensus[:]) r.ReadArray(&p.transactionHashes) } @@ -51,7 +48,7 @@ func (p *prepareRequest) TransactionHashes() []util.Uint256 { return p.transacti func (p *prepareRequest) SetTransactionHashes(hs []util.Uint256) { p.transactionHashes = hs } // NextConsensus implements payload.PrepareRequest interface. -func (p *prepareRequest) NextConsensus() util.Uint160 { return p.nextConsensus } +func (p *prepareRequest) NextConsensus() util.Uint160 { return util.Uint160{} } // SetNextConsensus implements payload.PrepareRequest interface. -func (p *prepareRequest) SetNextConsensus(nc util.Uint160) { p.nextConsensus = nc } +func (p *prepareRequest) SetNextConsensus(_ util.Uint160) {} diff --git a/pkg/consensus/prepare_request_test.go b/pkg/consensus/prepare_request_test.go index 4b91e6cfb..188e32d97 100644 --- a/pkg/consensus/prepare_request_test.go +++ b/pkg/consensus/prepare_request_test.go @@ -20,7 +20,7 @@ func TestPrepareRequest_Setters(t *testing.T) { require.EqualValues(t, 1000000, p.Timestamp()) p.SetNextConsensus(util.Uint160{5, 6, 7}) - require.Equal(t, util.Uint160{5, 6, 7}, p.NextConsensus()) + require.Equal(t, util.Uint160{}, p.NextConsensus()) p.SetNonce(8765) require.EqualValues(t, 8765, p.Nonce()) diff --git a/pkg/consensus/recovery_message_test.go b/pkg/consensus/recovery_message_test.go index 203edf45c..54544edb0 100644 --- a/pkg/consensus/recovery_message_test.go +++ b/pkg/consensus/recovery_message_test.go @@ -31,7 +31,6 @@ func TestRecoveryMessage_Setters(t *testing.T) { timestamp: 87, nonce: 321, transactionHashes: []util.Uint256{{1}}, - nextConsensus: util.Uint160{1, 2}, } p1 := new(Payload) p1.message = &message{}