mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-28 19:31:34 +00:00
dbft: rev up, fix context timestamp initialization
See nspcc-dev/dbft#64, fixes #2753.
This commit is contained in:
parent
0f625f04f0
commit
493b979b95
4 changed files with 10 additions and 8 deletions
2
go.mod
2
go.mod
|
@ -11,7 +11,7 @@ require (
|
||||||
github.com/holiman/uint256 v1.2.0
|
github.com/holiman/uint256 v1.2.0
|
||||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
|
||||||
github.com/mr-tron/base58 v1.2.0
|
github.com/mr-tron/base58 v1.2.0
|
||||||
github.com/nspcc-dev/dbft v0.0.0-20221018080254-c7e1bf49ccd7
|
github.com/nspcc-dev/dbft v0.0.0-20221020093431-31c1bbdc74f2
|
||||||
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22
|
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22
|
||||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220927123257-24c107e3a262
|
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220927123257-24c107e3a262
|
||||||
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659
|
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -251,8 +251,8 @@ github.com/nspcc-dev/dbft v0.0.0-20191209120240-0d6b7568d9ae/go.mod h1:3FjXOoHmA
|
||||||
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/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-20210721160347-1b03241391ac/go.mod h1:U8MSnEShH+o5hexfWJdze6uMFJteP0ko7J2frO7Yu1Y=
|
github.com/nspcc-dev/dbft v0.0.0-20210721160347-1b03241391ac/go.mod h1:U8MSnEShH+o5hexfWJdze6uMFJteP0ko7J2frO7Yu1Y=
|
||||||
github.com/nspcc-dev/dbft v0.0.0-20221018080254-c7e1bf49ccd7 h1:RxVI9RFiHmpUvbuYIM5siLMiOvVt8P651BdmTstGi3Q=
|
github.com/nspcc-dev/dbft v0.0.0-20221020093431-31c1bbdc74f2 h1:2soBy8en5W4/1Gvbog8RyVpEbarGWZwPxppZjffWzZE=
|
||||||
github.com/nspcc-dev/dbft v0.0.0-20221018080254-c7e1bf49ccd7/go.mod h1:g9xisXmX9NP9MjioaTe862n9SlZTrP+6PVUWLBYOr98=
|
github.com/nspcc-dev/dbft v0.0.0-20221020093431-31c1bbdc74f2/go.mod h1:g9xisXmX9NP9MjioaTe862n9SlZTrP+6PVUWLBYOr98=
|
||||||
github.com/nspcc-dev/go-ordered-json v0.0.0-20210915112629-e1b6cce73d02/go.mod h1:79bEUDEviBHJMFV6Iq6in57FEOCMcRhfQnfaf0ETA5U=
|
github.com/nspcc-dev/go-ordered-json v0.0.0-20210915112629-e1b6cce73d02/go.mod h1:79bEUDEviBHJMFV6Iq6in57FEOCMcRhfQnfaf0ETA5U=
|
||||||
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22 h1:n4ZaFCKt1pQJd7PXoMJabZWK9ejjbLOVrkl/lOUmshg=
|
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22 h1:n4ZaFCKt1pQJd7PXoMJabZWK9ejjbLOVrkl/lOUmshg=
|
||||||
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22/go.mod h1:79bEUDEviBHJMFV6Iq6in57FEOCMcRhfQnfaf0ETA5U=
|
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22/go.mod h1:79bEUDEviBHJMFV6Iq6in57FEOCMcRhfQnfaf0ETA5U=
|
||||||
|
|
|
@ -268,7 +268,9 @@ func (s *service) Name() string {
|
||||||
func (s *service) Start() {
|
func (s *service) Start() {
|
||||||
if s.started.CAS(false, true) {
|
if s.started.CAS(false, true) {
|
||||||
s.log.Info("starting consensus service")
|
s.log.Info("starting consensus service")
|
||||||
s.dbft.Start()
|
b, _ := s.Chain.GetBlock(s.Chain.CurrentBlockHash()) // Can't fail, we have some current block!
|
||||||
|
s.lastTimestamp = b.Timestamp
|
||||||
|
s.dbft.Start(s.lastTimestamp * nsInMs)
|
||||||
s.Chain.SubscribeForBlocks(s.blockEvents)
|
s.Chain.SubscribeForBlocks(s.blockEvents)
|
||||||
go s.eventLoop()
|
go s.eventLoop()
|
||||||
}
|
}
|
||||||
|
@ -359,7 +361,7 @@ func (s *service) handleChainBlock(b *coreb.Block) {
|
||||||
zap.Uint32("dbft index", s.dbft.BlockIndex),
|
zap.Uint32("dbft index", s.dbft.BlockIndex),
|
||||||
zap.Uint32("chain index", s.Chain.BlockHeight()))
|
zap.Uint32("chain index", s.Chain.BlockHeight()))
|
||||||
s.postBlock(b)
|
s.postBlock(b)
|
||||||
s.dbft.InitializeConsensus(0)
|
s.dbft.InitializeConsensus(0, b.Timestamp*nsInMs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ func initServiceNextConsensus(t *testing.T, newAcc *wallet.Account, offset uint3
|
||||||
require.NoError(t, bc.PoolTx(tx))
|
require.NoError(t, bc.PoolTx(tx))
|
||||||
|
|
||||||
srv := newTestServiceWithChain(t, bc)
|
srv := newTestServiceWithChain(t, bc)
|
||||||
srv.dbft.Start()
|
srv.dbft.Start(0)
|
||||||
|
|
||||||
// Register new candidate.
|
// Register new candidate.
|
||||||
b.Reset()
|
b.Reset()
|
||||||
|
@ -164,7 +164,7 @@ func TestService_NextConsensus(t *testing.T) {
|
||||||
|
|
||||||
func TestService_GetVerified(t *testing.T) {
|
func TestService_GetVerified(t *testing.T) {
|
||||||
srv := newTestService(t)
|
srv := newTestService(t)
|
||||||
srv.dbft.Start()
|
srv.dbft.Start(0)
|
||||||
var txs []*transaction.Transaction
|
var txs []*transaction.Transaction
|
||||||
for i := 0; i < 4; i++ {
|
for i := 0; i < 4; i++ {
|
||||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 100000)
|
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 100000)
|
||||||
|
@ -294,7 +294,7 @@ func TestService_getTx(t *testing.T) {
|
||||||
|
|
||||||
func TestService_PrepareRequest(t *testing.T) {
|
func TestService_PrepareRequest(t *testing.T) {
|
||||||
srv := newTestServiceWithState(t, true)
|
srv := newTestServiceWithState(t, true)
|
||||||
srv.dbft.Start()
|
srv.dbft.Start(0)
|
||||||
t.Cleanup(srv.dbft.Timer.Stop)
|
t.Cleanup(srv.dbft.Timer.Stop)
|
||||||
|
|
||||||
priv, _ := getTestValidator(1)
|
priv, _ := getTestValidator(1)
|
||||||
|
|
Loading…
Reference in a new issue