From 5f5d8a58dd853f32340469681f7454b838fc4786 Mon Sep 17 00:00:00 2001 From: Jimmy Hu Date: Wed, 27 Mar 2019 19:53:05 +0800 Subject: core: workaround for GetRoundHeight (#523) * core: workaround for GetRoundHeight * update gopkg.lock * x --- Gopkg.lock | 25 +++++++++++++++++++++++++ core/consensus.go | 6 ++++-- core/test/governance.go | 3 ++- core/utils/round-event.go | 3 ++- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 2293203..faecb2f 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -122,13 +122,38 @@ analyzer-name = "dep" analyzer-version = 1 input-imports = [ + "github.com/btcsuite/btcd/btcec", + "github.com/davecgh/go-spew/spew", "github.com/dexon-foundation/bls/ffi/go/bls", + "github.com/dexon-foundation/dexon/common", + "github.com/dexon-foundation/dexon/common/hexutil", + "github.com/dexon-foundation/dexon/common/math", "github.com/dexon-foundation/dexon/crypto", + "github.com/dexon-foundation/dexon/crypto/secp256k1", + "github.com/dexon-foundation/dexon/crypto/sha3", "github.com/dexon-foundation/dexon/log", "github.com/dexon-foundation/dexon/rlp", + "github.com/go-stack/stack", + "github.com/golang/snappy", + "github.com/naoina/go-stringutil", "github.com/naoina/toml", + "github.com/naoina/toml/ast", + "github.com/pmezard/go-difflib/difflib", + "github.com/stretchr/testify/assert", + "github.com/stretchr/testify/require", "github.com/stretchr/testify/suite", "github.com/syndtr/goleveldb/leveldb", + "github.com/syndtr/goleveldb/leveldb/cache", + "github.com/syndtr/goleveldb/leveldb/comparer", + "github.com/syndtr/goleveldb/leveldb/errors", + "github.com/syndtr/goleveldb/leveldb/filter", + "github.com/syndtr/goleveldb/leveldb/iterator", + "github.com/syndtr/goleveldb/leveldb/journal", + "github.com/syndtr/goleveldb/leveldb/memdb", + "github.com/syndtr/goleveldb/leveldb/opt", + "github.com/syndtr/goleveldb/leveldb/storage", + "github.com/syndtr/goleveldb/leveldb/table", + "github.com/syndtr/goleveldb/leveldb/util", ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/core/consensus.go b/core/consensus.go index 4a95eac..a02f8c1 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -733,7 +733,8 @@ func newConsensusForRound( } baConfig := agreementMgrConfig{} baConfig.from(initRound, initConfig, initCRS) - baConfig.SetRoundBeginHeight(gov.GetRoundHeight(initRound)) + // TODO(jimmy): remove -1 after we match the height with fullnode. + baConfig.SetRoundBeginHeight(gov.GetRoundHeight(initRound) - 1) con.baMgr, err = newAgreementMgr(con, baConfig) if err != nil { panic(err) @@ -809,7 +810,8 @@ func (con *Consensus) prepare(initBlock *types.Block) (err error) { panic(err) } // The init config is provided to baModule when construction. - if evts[len(evts)-1].BeginHeight != con.gov.GetRoundHeight(initRound) { + // TODO(jimmy): remove -1 after we match the height with fullnode. + if evts[len(evts)-1].BeginHeight != con.gov.GetRoundHeight(initRound)-1 { if err := con.baMgr.notifyRoundEvents(evts); err != nil { panic(err) } diff --git a/core/test/governance.go b/core/test/governance.go index 538d064..4970420 100644 --- a/core/test/governance.go +++ b/core/test/governance.go @@ -100,7 +100,8 @@ func (g *Governance) GetRoundHeight(round uint64) uint64 { panic(fmt.Errorf("round begin height is not ready: %d %d", round, len(g.roundBeginHeights))) } - return g.roundBeginHeights[round] + // TODO(jimmy): remove this workaround. + return g.roundBeginHeights[round] + 1 } // CRS returns the CRS for a given round. diff --git a/core/utils/round-event.go b/core/utils/round-event.go index 885c755..c03a2fd 100644 --- a/core/utils/round-event.go +++ b/core/utils/round-event.go @@ -179,7 +179,8 @@ func NewRoundEvent(parentCtx context.Context, gov governanceAccessor, e.ctx, e.ctxCancel = context.WithCancel(parentCtx) e.config = RoundBasedConfig{} e.config.SetupRoundBasedFields(initRound, initConfig) - e.config.SetRoundBeginHeight(gov.GetRoundHeight(initRound)) + // TODO(jimmy): remove -1 after we match the height with fullnode. + e.config.SetRoundBeginHeight(gov.GetRoundHeight(initRound) - 1) // Make sure the DKG reset count in current governance can cover the initial // block height. resetCount := gov.DKGResetCount(initRound + 1) -- cgit