Merge pull request #1095 from nspcc-dev/update-dbft-neox-2.x

consensus: update dbft library (neox-2.x)
This commit is contained in:
Roman Khimov 2020-06-24 14:32:06 +03:00 committed by GitHub
commit 03977083c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 8 deletions

2
go.mod
View file

@ -9,7 +9,7 @@ require (
github.com/go-yaml/yaml v2.1.0+incompatible github.com/go-yaml/yaml v2.1.0+incompatible
github.com/gorilla/websocket v1.4.2 github.com/gorilla/websocket v1.4.2
github.com/mr-tron/base58 v1.1.2 github.com/mr-tron/base58 v1.1.2
github.com/nspcc-dev/dbft v0.0.0-20200610194044-e2dbc098ab46 github.com/nspcc-dev/dbft v0.0.0-20200623100921-5a182c20965e
github.com/nspcc-dev/rfc6979 v0.2.0 github.com/nspcc-dev/rfc6979 v0.2.0
github.com/pkg/errors v0.8.1 github.com/pkg/errors v0.8.1
github.com/prometheus/client_golang v1.2.1 github.com/prometheus/client_golang v1.2.1

4
go.sum
View file

@ -156,8 +156,8 @@ github.com/nspcc-dev/dbft v0.0.0-20200117124306-478e5cfbf03a h1:ajvxgEe9qY4vvoSm
github.com/nspcc-dev/dbft v0.0.0-20200117124306-478e5cfbf03a/go.mod h1:/YFK+XOxxg0Bfm6P92lY5eDSLYfp06XOdL8KAVgXjVk= github.com/nspcc-dev/dbft v0.0.0-20200117124306-478e5cfbf03a/go.mod h1:/YFK+XOxxg0Bfm6P92lY5eDSLYfp06XOdL8KAVgXjVk=
github.com/nspcc-dev/dbft v0.0.0-20200219114139-199d286ed6c1 h1:yEx9WznS+rjE0jl0dLujCxuZSIb+UTjF+005TJu/nNI= github.com/nspcc-dev/dbft v0.0.0-20200219114139-199d286ed6c1 h1:yEx9WznS+rjE0jl0dLujCxuZSIb+UTjF+005TJu/nNI=
github.com/nspcc-dev/dbft v0.0.0-20200219114139-199d286ed6c1/go.mod h1:O0qtn62prQSqizzoagHmuuKoz8QMkU3SzBoKdEvm3aQ= github.com/nspcc-dev/dbft v0.0.0-20200219114139-199d286ed6c1/go.mod h1:O0qtn62prQSqizzoagHmuuKoz8QMkU3SzBoKdEvm3aQ=
github.com/nspcc-dev/dbft v0.0.0-20200610194044-e2dbc098ab46 h1:3MTsGNIWSi0FZm3hmj9//iaDRNHqBZzgfBbPEagh2eY= github.com/nspcc-dev/dbft v0.0.0-20200623100921-5a182c20965e h1:QOT9slflIkEKb5wY0ZUC0dCmCgoqGlhOAh9+xWMIxfg=
github.com/nspcc-dev/dbft v0.0.0-20200610194044-e2dbc098ab46/go.mod h1:1FYQXSbb6/9HQIkoF8XO7W/S8N7AZRkBsgwbcXRvk0E= github.com/nspcc-dev/dbft v0.0.0-20200623100921-5a182c20965e/go.mod h1:1FYQXSbb6/9HQIkoF8XO7W/S8N7AZRkBsgwbcXRvk0E=
github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg= github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg=
github.com/nspcc-dev/neofs-crypto v0.2.0 h1:ftN+59WqxSWz/RCgXYOfhmltOOqU+udsNQSvN6wkFck= github.com/nspcc-dev/neofs-crypto v0.2.0 h1:ftN+59WqxSWz/RCgXYOfhmltOOqU+udsNQSvN6wkFck=
github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA= github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA=

View file

@ -123,7 +123,6 @@ func NewService(cfg Config) (Service, error) {
dbft.WithLogger(srv.log), dbft.WithLogger(srv.log),
dbft.WithSecondsPerBlock(cfg.TimePerBlock), dbft.WithSecondsPerBlock(cfg.TimePerBlock),
dbft.WithGetKeyPair(srv.getKeyPair), dbft.WithGetKeyPair(srv.getKeyPair),
dbft.WithTxPerBlock(10000),
dbft.WithRequestTx(cfg.RequestTx), dbft.WithRequestTx(cfg.RequestTx),
dbft.WithGetTx(srv.getTx), dbft.WithGetTx(srv.getTx),
dbft.WithGetVerified(srv.getVerifiedTx), dbft.WithGetVerified(srv.getVerifiedTx),
@ -483,7 +482,7 @@ func (s *service) getBlock(h util.Uint256) block.Block {
return &neoBlock{Block: *b} return &neoBlock{Block: *b}
} }
func (s *service) getVerifiedTx(count int) []block.Transaction { func (s *service) getVerifiedTx() []block.Transaction {
pool := s.Config.Chain.GetMemPool() pool := s.Config.Chain.GetMemPool()
var txx []mempool.TxWithFee var txx []mempool.TxWithFee

View file

@ -26,7 +26,7 @@ func TestNewService(t *testing.T) {
require.NoError(t, srv.Chain.PoolTx(tx)) require.NoError(t, srv.Chain.PoolTx(tx))
var txx []block.Transaction var txx []block.Transaction
require.NotPanics(t, func() { txx = srv.getVerifiedTx(1) }) require.NotPanics(t, func() { txx = srv.getVerifiedTx() })
require.Len(t, txx, 2) require.Len(t, txx, 2)
require.Equal(t, tx, txx[1]) require.Equal(t, tx, txx[1])
srv.Chain.Close() srv.Chain.Close()
@ -59,7 +59,7 @@ func TestService_GetVerified(t *testing.T) {
srv.dbft.ViewNumber = 1 srv.dbft.ViewNumber = 1
t.Run("new transactions will be proposed in case of failure", func(t *testing.T) { t.Run("new transactions will be proposed in case of failure", func(t *testing.T) {
txx := srv.getVerifiedTx(10) txx := srv.getVerifiedTx()
require.Equal(t, 2, len(txx), "there is only 1 tx in mempool") require.Equal(t, 2, len(txx), "there is only 1 tx in mempool")
require.Equal(t, txs[3], txx[1]) require.Equal(t, txs[3], txx[1])
}) })
@ -69,7 +69,7 @@ func TestService_GetVerified(t *testing.T) {
require.NoError(t, srv.Chain.PoolTx(tx)) require.NoError(t, srv.Chain.PoolTx(tx))
} }
txx := srv.getVerifiedTx(10) txx := srv.getVerifiedTx()
require.Contains(t, txx, txs[0]) require.Contains(t, txx, txs[0])
require.Contains(t, txx, txs[1]) require.Contains(t, txx, txs[1])
require.NotContains(t, txx, txs[2]) require.NotContains(t, txx, txs[2])