*: use MaxTransactionsPerBlock from Policy native contract
part of #904 1. We now have MaxTransactionsPerBlock set in native Policy contract, so this value should be used in (dbft).GetVerified method instead of passing it as an argument. 2. Removed (dbft).WithTxPerBlock. 2. DBFT API has changed, so update it's version. 3. Removed MaxTransactionsPerBlock from node configuration, as we have it set in native Policy contract.
This commit is contained in:
parent
c2735a4569
commit
8de0332107
8 changed files with 9 additions and 17 deletions
|
@ -18,7 +18,6 @@ ProtocolConfiguration:
|
|||
- seed5.neo.org:10333
|
||||
VerifyBlocks: true
|
||||
VerifyTransactions: false
|
||||
MaxTransactionsPerBlock: 500
|
||||
|
||||
ApplicationConfiguration:
|
||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||
|
|
|
@ -18,7 +18,6 @@ ProtocolConfiguration:
|
|||
- seed5t.neo.org:20333
|
||||
VerifyBlocks: true
|
||||
VerifyTransactions: false
|
||||
MaxTransactionsPerBlock: 500
|
||||
|
||||
ApplicationConfiguration:
|
||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||
|
|
2
go.mod
2
go.mod
|
@ -9,7 +9,7 @@ require (
|
|||
github.com/go-yaml/yaml v2.1.0+incompatible
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/mr-tron/base58 v1.1.2
|
||||
github.com/nspcc-dev/dbft v0.0.0-20200531081613-7a39e7b757ac
|
||||
github.com/nspcc-dev/dbft v0.0.0-20200623100921-5a182c20965e
|
||||
github.com/nspcc-dev/rfc6979 v0.2.0
|
||||
github.com/pierrec/lz4 v2.5.2+incompatible
|
||||
github.com/pkg/errors v0.8.1
|
||||
|
|
4
go.sum
4
go.sum
|
@ -137,8 +137,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-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-20200531081613-7a39e7b757ac h1:cXPgsp4avJ7cR1nPRdpFRHmWoMSRZ41FSvlNjpsyTiA=
|
||||
github.com/nspcc-dev/dbft v0.0.0-20200531081613-7a39e7b757ac/go.mod h1:1FYQXSbb6/9HQIkoF8XO7W/S8N7AZRkBsgwbcXRvk0E=
|
||||
github.com/nspcc-dev/dbft v0.0.0-20200623100921-5a182c20965e h1:QOT9slflIkEKb5wY0ZUC0dCmCgoqGlhOAh9+xWMIxfg=
|
||||
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/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=
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
type (
|
||||
ProtocolConfiguration struct {
|
||||
Magic netmode.Magic `yaml:"Magic"`
|
||||
MaxTransactionsPerBlock int `yaml:"MaxTransactionsPerBlock"`
|
||||
MemPoolSize int `yaml:"MemPoolSize"`
|
||||
// SaveStorageBatch enables storage batch saving before every persist.
|
||||
SaveStorageBatch bool `yaml:"SaveStorageBatch"`
|
||||
|
|
|
@ -121,7 +121,6 @@ func NewService(cfg Config) (Service, error) {
|
|||
dbft.WithLogger(srv.log),
|
||||
dbft.WithSecondsPerBlock(cfg.TimePerBlock),
|
||||
dbft.WithGetKeyPair(srv.getKeyPair),
|
||||
dbft.WithTxPerBlock(10000),
|
||||
dbft.WithRequestTx(cfg.RequestTx),
|
||||
dbft.WithGetTx(srv.getTx),
|
||||
dbft.WithGetVerified(srv.getVerifiedTx),
|
||||
|
@ -392,7 +391,7 @@ func (s *service) getBlock(h util.Uint256) block.Block {
|
|||
return &neoBlock{Block: *b}
|
||||
}
|
||||
|
||||
func (s *service) getVerifiedTx(count int) []block.Transaction {
|
||||
func (s *service) getVerifiedTx() []block.Transaction {
|
||||
pool := s.Config.Chain.GetMemPool()
|
||||
|
||||
var txx []*transaction.Transaction
|
||||
|
|
|
@ -31,7 +31,7 @@ func TestNewService(t *testing.T) {
|
|||
require.NoError(t, srv.Chain.PoolTx(tx))
|
||||
|
||||
var txx []block.Transaction
|
||||
require.NotPanics(t, func() { txx = srv.getVerifiedTx(1) })
|
||||
require.NotPanics(t, func() { txx = srv.getVerifiedTx() })
|
||||
require.Len(t, txx, 1)
|
||||
require.Equal(t, tx, txx[0])
|
||||
srv.Chain.Close()
|
||||
|
@ -69,7 +69,7 @@ func TestService_GetVerified(t *testing.T) {
|
|||
srv.dbft.ViewNumber = 1
|
||||
|
||||
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, 1, len(txx), "there is only 1 tx in mempool")
|
||||
require.Equal(t, txs[3], txx[0])
|
||||
})
|
||||
|
@ -79,7 +79,7 @@ func TestService_GetVerified(t *testing.T) {
|
|||
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[1])
|
||||
require.NotContains(t, txx, txs[2])
|
||||
|
|
|
@ -152,10 +152,6 @@ func NewBlockchain(s storage.Store, cfg config.ProtocolConfiguration, log *zap.L
|
|||
cfg.MemPoolSize = defaultMemPoolSize
|
||||
log.Info("mempool size is not set or wrong, setting default value", zap.Int("MemPoolSize", cfg.MemPoolSize))
|
||||
}
|
||||
if cfg.MaxTransactionsPerBlock <= 0 {
|
||||
cfg.MaxTransactionsPerBlock = 0
|
||||
log.Info("MaxTransactionsPerBlock is not set or wrong, setting default value (unlimited)", zap.Int("MaxTransactionsPerBlock", cfg.MaxTransactionsPerBlock))
|
||||
}
|
||||
bc := &Blockchain{
|
||||
config: cfg,
|
||||
dao: dao.NewSimple(s, cfg.Magic),
|
||||
|
|
Loading…
Reference in a new issue