From a854e7f5455ed14cfe1c98d3af8a08bac997c944 Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Wed, 3 Feb 2021 17:05:42 +0100 Subject: [PATCH] evidence migration with fixes to generated mocks --- cmd/tendermint/commands/run_node.go | 2 +- config/config.go | 6 +- config/config_test.go | 2 +- consensus/reactor.go | 4 +- consensus/replay.go | 2 +- consensus/replay_stubs.go | 2 +- consensus/state.go | 44 +++---- consensus/types/round_state.go | 2 +- consensus/wal.go | 10 +- consensus/wal_generator.go | 8 +- consensus/wal_test.go | 6 +- evidence/mocks/block_store.go | 8 +- evidence/pool.go | 14 +-- evidence/pool_test.go | 42 +++---- evidence/reactor_test.go | 18 +-- evidence/verify.go | 6 +- evidence/verify_test.go | 4 +- light/client.go | 4 +- light/detector_test.go | 20 ++-- light/proxy/routes.go | 20 ++-- light/rpc/client.go | 1 + light/rpc/mocks/light_client.go | 12 +- proto/tendermint/consensus/types.pb.go | 152 ++++++++++++------------- proto/tendermint/consensus/types.proto | 14 +-- proto/tendermint/types/events.pb.go | 10 +- proto/tendermint/types/events.proto | 2 +- rpc/client/interface.go | 1 + rpc/client/mock/abci.go | 4 +- rpc/client/mock/abci_test.go | 4 +- rpc/client/mock/client.go | 10 +- rpc/client/mocks/client.go | 38 +++---- statesync/stateprovider.go | 14 +-- types/events.go | 6 +- types/vote_set.go | 2 +- 34 files changed, 248 insertions(+), 246 deletions(-) diff --git a/cmd/tendermint/commands/run_node.go b/cmd/tendermint/commands/run_node.go index f33ccdf46..2bec0f393 100644 --- a/cmd/tendermint/commands/run_node.go +++ b/cmd/tendermint/commands/run_node.go @@ -37,7 +37,7 @@ func AddNodeFlags(cmd *cobra.Command) { "genesis-hash", []byte{}, "optional SHA-256 hash of the genesis file") - cmd.Flags().Int64("consensus.double-sign-check-height", config.Consensus.DoubleSignCheckHeight, + cmd.Flags().Uint64("consensus.double-sign-check-height", config.Consensus.DoubleSignCheckHeight, "how many blocks to look back to check existence of the node's "+ "consensus votes before joining consensus") diff --git a/config/config.go b/config/config.go index 130ec3884..ba7caa15d 100644 --- a/config/config.go +++ b/config/config.go @@ -866,7 +866,7 @@ type ConsensusConfig struct { PeerGossipSleepDuration time.Duration `mapstructure:"peer-gossip-sleep-duration"` PeerQueryMaj23SleepDuration time.Duration `mapstructure:"peer-query-maj23-sleep-duration"` - DoubleSignCheckHeight int64 `mapstructure:"double-sign-check-height"` + DoubleSignCheckHeight uint64 `mapstructure:"double-sign-check-height"` } // DefaultConsensusConfig returns a default configuration for the consensus service @@ -885,7 +885,7 @@ func DefaultConsensusConfig() *ConsensusConfig { CreateEmptyBlocksInterval: 0 * time.Second, PeerGossipSleepDuration: 100 * time.Millisecond, PeerQueryMaj23SleepDuration: 2000 * time.Millisecond, - DoubleSignCheckHeight: int64(0), + DoubleSignCheckHeight: uint64(0), } } @@ -902,7 +902,7 @@ func TestConsensusConfig() *ConsensusConfig { cfg.SkipTimeoutCommit = true cfg.PeerGossipSleepDuration = 5 * time.Millisecond cfg.PeerQueryMaj23SleepDuration = 250 * time.Millisecond - cfg.DoubleSignCheckHeight = int64(0) + cfg.DoubleSignCheckHeight = uint64(0) return cfg } diff --git a/config/config_test.go b/config/config_test.go index 78657d848..7ec50290b 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -164,7 +164,7 @@ func TestConsensusConfig_ValidateBasic(t *testing.T) { "PeerGossipSleepDuration negative": {func(c *ConsensusConfig) { c.PeerGossipSleepDuration = -1 }, true}, "PeerQueryMaj23SleepDuration": {func(c *ConsensusConfig) { c.PeerQueryMaj23SleepDuration = time.Second }, false}, "PeerQueryMaj23SleepDuration negative": {func(c *ConsensusConfig) { c.PeerQueryMaj23SleepDuration = -1 }, true}, - "DoubleSignCheckHeight negative": {func(c *ConsensusConfig) { c.DoubleSignCheckHeight = -1 }, true}, + "DoubleSignCheckHeight negative": {func(c *ConsensusConfig) { c.DoubleSignCheckHeight = 0 }, true}, } for desc, tc := range testcases { tc := tc // appease linter diff --git a/consensus/reactor.go b/consensus/reactor.go index b81b5eebb..01b0197f1 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -1584,7 +1584,7 @@ func (m *ProposalPOLMessage) String() string { // BlockPartMessage is sent when gossipping a piece of the proposed block. type BlockPartMessage struct { - Height int64 + Height uint64 Round int32 Part *types.Part } @@ -1693,7 +1693,7 @@ func (m *VoteSetMaj23Message) String() string { // VoteSetBitsMessage is sent to communicate the bit-array of votes seen for the BlockID. type VoteSetBitsMessage struct { - Height int64 + Height uint64 Round int32 Type tmproto.SignedMsgType BlockID types.BlockID diff --git a/consensus/replay.go b/consensus/replay.go index 67ba557e6..154cc27b4 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -91,7 +91,7 @@ func (cs *State) readReplayMessage(msg *TimedWALMessage, newStepSub types.Subscr // Replay only those messages since the last block. `timeoutRoutine` should // run concurrently to read off tickChan. -func (cs *State) catchupReplay(csHeight int64) error { +func (cs *State) catchupReplay(csHeight uint64) error { // Set replayMode to true so we don't log signing errors. cs.replayMode = true diff --git a/consensus/replay_stubs.go b/consensus/replay_stubs.go index 08974a67e..3ed86fb82 100644 --- a/consensus/replay_stubs.go +++ b/consensus/replay_stubs.go @@ -24,7 +24,7 @@ func (emptyMempool) CheckTx(_ types.Tx, _ func(*abci.Response), _ mempl.TxInfo) func (emptyMempool) ReapMaxBytesMaxGas(_, _ int64) types.Txs { return types.Txs{} } func (emptyMempool) ReapMaxTxs(n int) types.Txs { return types.Txs{} } func (emptyMempool) Update( - _ int64, + _ uint64, _ types.Txs, _ []*abci.ResponseDeliverTx, _ mempl.PreCheckFunc, diff --git a/consensus/state.go b/consensus/state.go index 6476693ff..849af62d0 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -57,7 +57,7 @@ type msgInfo struct { // internally generated messages which may update the state type timeoutInfo struct { Duration time.Duration `json:"duration"` - Height int64 `json:"height"` + Height uint64 `json:"height"` Round int32 `json:"round"` Step cstypes.RoundStepType `json:"step"` } @@ -133,8 +133,8 @@ type State struct { nSteps int // some functions can be overwritten for testing - decideProposal func(height int64, round int32) - doPrevote func(height int64, round int32) + decideProposal func(height uint64, round int32) + doPrevote func(height uint64, round int32) setProposal func(proposal *types.Proposal) error // closed when we finish shutting down @@ -263,7 +263,7 @@ func (cs *State) GetRoundStateSimpleJSON() ([]byte, error) { } // GetValidators returns a copy of the current validators. -func (cs *State) GetValidators() (int64, []*types.Validator) { +func (cs *State) GetValidators() (uint64, []*types.Validator) { cs.mtx.RLock() defer cs.mtx.RUnlock() return cs.state.LastBlockHeight, cs.state.Validators.Copy().Validators @@ -290,7 +290,7 @@ func (cs *State) SetTimeoutTicker(timeoutTicker TimeoutTicker) { } // LoadCommit loads the commit for a given height. -func (cs *State) LoadCommit(height int64) *types.Commit { +func (cs *State) LoadCommit(height uint64) *types.Commit { cs.mtx.RLock() defer cs.mtx.RUnlock() if height == cs.blockStore.Height() { @@ -473,7 +473,7 @@ func (cs *State) SetProposal(proposal *types.Proposal, peerID p2p.NodeID) error } // AddProposalBlockPart inputs a part of the proposal block. -func (cs *State) AddProposalBlockPart(height int64, round int32, part *types.Part, peerID p2p.NodeID) error { +func (cs *State) AddProposalBlockPart(height uint64, round int32, part *types.Part, peerID p2p.NodeID) error { if peerID == "" { cs.internalMsgQueue <- msgInfo{&BlockPartMessage{height, round, part}, ""} @@ -525,7 +525,7 @@ func (cs *State) scheduleRound0(rs *cstypes.RoundState) { } // Attempt to schedule a timeout (by sending timeoutInfo on the tickChan) -func (cs *State) scheduleTimeout(duration time.Duration, height int64, round int32, step cstypes.RoundStepType) { +func (cs *State) scheduleTimeout(duration time.Duration, height uint64, round int32, step cstypes.RoundStepType) { cs.timeoutTicker.ScheduleTimeout(timeoutInfo{duration, height, round, step}) } @@ -905,7 +905,7 @@ func (cs *State) handleTxsAvailable() { // Enter: +2/3 precommits for nil at (height,round-1) // Enter: +2/3 prevotes any or +2/3 precommits for block or any from (height, round) // NOTE: cs.StartTime was already set for height. -func (cs *State) enterNewRound(height int64, round int32) { +func (cs *State) enterNewRound(height uint64, round int32) { logger := cs.Logger.With("height", height, "round", round) if cs.Height != height || round < cs.Round || (cs.Round == round && cs.Step != cstypes.RoundStepNewHeight) { @@ -971,7 +971,7 @@ func (cs *State) enterNewRound(height int64, round int32) { // needProofBlock returns true on the first height (so the genesis app hash is signed right away) // and where the last block (height-1) caused the app hash to change -func (cs *State) needProofBlock(height int64) bool { +func (cs *State) needProofBlock(height uint64) bool { if height == cs.state.InitialHeight { return true } @@ -987,7 +987,7 @@ func (cs *State) needProofBlock(height int64) bool { // Enter (CreateEmptyBlocks, CreateEmptyBlocksInterval > 0 ): // after enterNewRound(height,round), after timeout of CreateEmptyBlocksInterval // Enter (!CreateEmptyBlocks) : after enterNewRound(height,round), once txs are in the mempool -func (cs *State) enterPropose(height int64, round int32) { +func (cs *State) enterPropose(height uint64, round int32) { logger := cs.Logger.With("height", height, "round", round) if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPropose <= cs.Step) { @@ -1057,7 +1057,7 @@ func (cs *State) isProposer(address []byte) bool { return bytes.Equal(cs.Validators.GetProposer().Address, address) } -func (cs *State) defaultDecideProposal(height int64, round int32) { +func (cs *State) defaultDecideProposal(height uint64, round int32) { var block *types.Block var blockParts *types.PartSet @@ -1156,7 +1156,7 @@ func (cs *State) createProposalBlock() (block *types.Block, blockParts *types.Pa // Enter: proposal block and POL is ready. // Prevote for LockedBlock if we're locked, or ProposalBlock if valid. // Otherwise vote nil. -func (cs *State) enterPrevote(height int64, round int32) { +func (cs *State) enterPrevote(height uint64, round int32) { if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrevote <= cs.Step) { cs.Logger.Debug(fmt.Sprintf( "enterPrevote(%v/%v): Invalid args. Current step: %v/%v/%v", @@ -1183,7 +1183,7 @@ func (cs *State) enterPrevote(height int64, round int32) { // (so we have more time to try and collect +2/3 prevotes for a single block) } -func (cs *State) defaultDoPrevote(height int64, round int32) { +func (cs *State) defaultDoPrevote(height uint64, round int32) { logger := cs.Logger.With("height", height, "round", round) // If a block is locked, prevote that. @@ -1217,7 +1217,7 @@ func (cs *State) defaultDoPrevote(height int64, round int32) { } // Enter: any +2/3 prevotes at next round. -func (cs *State) enterPrevoteWait(height int64, round int32) { +func (cs *State) enterPrevoteWait(height uint64, round int32) { logger := cs.Logger.With("height", height, "round", round) if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrevoteWait <= cs.Step) { @@ -1252,7 +1252,7 @@ func (cs *State) enterPrevoteWait(height int64, round int32) { // Lock & precommit the ProposalBlock if we have enough prevotes for it (a POL in this round) // else, unlock an existing lock and precommit nil if +2/3 of prevotes were nil, // else, precommit nil otherwise. -func (cs *State) enterPrecommit(height int64, round int32) { +func (cs *State) enterPrecommit(height uint64, round int32) { logger := cs.Logger.With("height", height, "round", round) if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrecommit <= cs.Step) { @@ -1364,7 +1364,7 @@ func (cs *State) enterPrecommit(height int64, round int32) { } // Enter: any +2/3 precommits for next round. -func (cs *State) enterPrecommitWait(height int64, round int32) { +func (cs *State) enterPrecommitWait(height uint64, round int32) { logger := cs.Logger.With("height", height, "round", round) if cs.Height != height || round < cs.Round || (cs.Round == round && cs.TriggeredTimeoutPrecommit) { @@ -1391,7 +1391,7 @@ func (cs *State) enterPrecommitWait(height int64, round int32) { } // Enter: +2/3 precommits for block -func (cs *State) enterCommit(height int64, commitRound int32) { +func (cs *State) enterCommit(height uint64, commitRound int32) { logger := cs.Logger.With("height", height, "commitRound", commitRound) if cs.Height != height || cstypes.RoundStepCommit <= cs.Step { @@ -1457,7 +1457,7 @@ func (cs *State) enterCommit(height int64, commitRound int32) { } // If we have the block AND +2/3 commits for it, finalize. -func (cs *State) tryFinalizeCommit(height int64) { +func (cs *State) tryFinalizeCommit(height uint64) { logger := cs.Logger.With("height", height) if cs.Height != height { @@ -1563,7 +1563,7 @@ func (cs *State) finalizeCommit(height int64) { // Execute and commit the block, update and save the state, and update the mempool. // NOTE The block.AppHash wont reflect these txs until the next block. var err error - var retainHeight int64 + var retainHeight uint64 stateCopy, retainHeight, err = cs.blockExec.ApplyBlock( stateCopy, types.BlockID{Hash: block.Hash(), PartSetHeader: blockParts.Header()}, @@ -1608,7 +1608,7 @@ func (cs *State) finalizeCommit(height int64) { // * cs.StartTime is set to when we will start round0. } -func (cs *State) pruneBlocks(retainHeight int64) (uint64, error) { +func (cs *State) pruneBlocks(retainHeight uint64) (uint64, error) { base := cs.blockStore.Base() if retainHeight <= base { return 0, nil @@ -2163,14 +2163,14 @@ func (cs *State) updatePrivValidatorPubKey() error { } // look back to check existence of the node's consensus votes before joining consensus -func (cs *State) checkDoubleSigningRisk(height int64) error { +func (cs *State) checkDoubleSigningRisk(height uint64) error { if cs.privValidator != nil && cs.privValidatorPubKey != nil && cs.config.DoubleSignCheckHeight > 0 && height > 0 { valAddr := cs.privValidatorPubKey.Address() doubleSignCheckHeight := cs.config.DoubleSignCheckHeight if doubleSignCheckHeight > height { doubleSignCheckHeight = height } - for i := int64(1); i < doubleSignCheckHeight; i++ { + for i := uint64(1); i < doubleSignCheckHeight; i++ { lastCommit := cs.blockStore.LoadSeenCommit(height - i) if lastCommit != nil { for sigIdx, s := range lastCommit.Signatures { diff --git a/consensus/types/round_state.go b/consensus/types/round_state.go index 9e67b76c0..3e1bd00c9 100644 --- a/consensus/types/round_state.go +++ b/consensus/types/round_state.go @@ -65,7 +65,7 @@ func (rs RoundStepType) String() string { // NOTE: Not thread safe. Should only be manipulated by functions downstream // of the cs.receiveRoutine type RoundState struct { - Height int64 `json:"height"` // Height we are working on + Height uint64 `json:"height"` // Height we are working on Round int32 `json:"round"` Step RoundStepType `json:"step"` StartTime time.Time `json:"start_time"` diff --git a/consensus/wal.go b/consensus/wal.go index 80f5e6b07..3c51a4bfb 100644 --- a/consensus/wal.go +++ b/consensus/wal.go @@ -40,7 +40,7 @@ type TimedWALMessage struct { // EndHeightMessage marks the end of the given height inside WAL. // @internal used by scripts/wal2json util. type EndHeightMessage struct { - Height int64 `json:"height"` + Height uint64 `json:"height"` } type WALMessage interface{} @@ -60,7 +60,7 @@ type WAL interface { WriteSync(WALMessage) error FlushAndSync() error - SearchForEndHeight(height int64, options *WALSearchOptions) (rd io.ReadCloser, found bool, err error) + SearchForEndHeight(height uint64, options *WALSearchOptions) (rd io.ReadCloser, found bool, err error) // service methods Start() error @@ -229,13 +229,13 @@ type WALSearchOptions struct { // // CONTRACT: caller must close group reader. func (wal *BaseWAL) SearchForEndHeight( - height int64, + height uint64, options *WALSearchOptions) (rd io.ReadCloser, found bool, err error) { var ( msg *TimedWALMessage gr *auto.GroupReader ) - lastHeightFound := int64(-1) + lastHeightFound := uint64(0) // todo: check this is not breaking, previously -1 // NOTE: starting from the last file in the group because we're usually // searching for the last height. See replay.go @@ -425,7 +425,7 @@ var _ WAL = nilWAL{} func (nilWAL) Write(m WALMessage) error { return nil } func (nilWAL) WriteSync(m WALMessage) error { return nil } func (nilWAL) FlushAndSync() error { return nil } -func (nilWAL) SearchForEndHeight(height int64, options *WALSearchOptions) (rd io.ReadCloser, found bool, err error) { +func (nilWAL) SearchForEndHeight(height uint64, options *WALSearchOptions) (rd io.ReadCloser, found bool, err error) { return nil, false, nil } func (nilWAL) Start() error { return nil } diff --git a/consensus/wal_generator.go b/consensus/wal_generator.go index b3dced8f4..6872816d6 100644 --- a/consensus/wal_generator.go +++ b/consensus/wal_generator.go @@ -96,7 +96,7 @@ func WALGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { // set consensus wal to buffered WAL, which will write all incoming msgs to buffer numBlocksWritten := make(chan struct{}) - wal := newByteBufferWAL(logger, NewWALEncoder(wr), int64(numBlocks), numBlocksWritten) + wal := newByteBufferWAL(logger, NewWALEncoder(wr), uint64(numBlocks), numBlocksWritten) // see wal.go#103 if err := wal.Write(EndHeightMessage{0}); err != nil { t.Error(err) @@ -166,7 +166,7 @@ func getConfig(t *testing.T) *cfg.Config { type byteBufferWAL struct { enc *WALEncoder stopped bool - heightToStop int64 + heightToStop uint64 signalWhenStopsTo chan<- struct{} logger log.Logger @@ -175,7 +175,7 @@ type byteBufferWAL struct { // needed for determinism var fixedTime, _ = time.Parse(time.RFC3339, "2017-01-02T15:04:05Z") -func newByteBufferWAL(logger log.Logger, enc *WALEncoder, nBlocks int64, signalStop chan<- struct{}) *byteBufferWAL { +func newByteBufferWAL(logger log.Logger, enc *WALEncoder, nBlocks uint64, signalStop chan<- struct{}) *byteBufferWAL { return &byteBufferWAL{ enc: enc, heightToStop: nBlocks, @@ -219,7 +219,7 @@ func (w *byteBufferWAL) WriteSync(m WALMessage) error { func (w *byteBufferWAL) FlushAndSync() error { return nil } func (w *byteBufferWAL) SearchForEndHeight( - height int64, + height uint64, options *WALSearchOptions) (rd io.ReadCloser, found bool, err error) { return nil, false, nil } diff --git a/consensus/wal_test.go b/consensus/wal_test.go index a64ecc9a5..3caa9db38 100644 --- a/consensus/wal_test.go +++ b/consensus/wal_test.go @@ -61,7 +61,7 @@ func TestWALTruncate(t *testing.T) { t.Error(err) } - h := int64(50) + h := uint64(50) gr, found, err := wal.SearchForEndHeight(h, &WALSearchOptions{}) assert.NoError(t, err, "expected not to err on height %d", h) assert.True(t, found, "expected to find end height for %d", h) @@ -154,7 +154,7 @@ func TestWALSearchForEndHeight(t *testing.T) { require.NoError(t, err) wal.SetLogger(log.TestingLogger()) - h := int64(3) + h := uint64(3) gr, found, err := wal.SearchForEndHeight(h, &WALSearchOptions{}) assert.NoError(t, err, "expected not to err on height %d", h) assert.True(t, found, "expected to find end height for %d", h) @@ -199,7 +199,7 @@ func TestWALPeriodicSync(t *testing.T) { // The data should have been flushed by the periodic sync assert.Zero(t, wal.Group().Buffered()) - h := int64(4) + h := uint64(4) gr, found, err := wal.SearchForEndHeight(h, &WALSearchOptions{}) assert.NoError(t, err, "expected not to err on height %d", h) assert.True(t, found, "expected to find end height for %d", h) diff --git a/evidence/mocks/block_store.go b/evidence/mocks/block_store.go index cdf316d00..449e356dd 100644 --- a/evidence/mocks/block_store.go +++ b/evidence/mocks/block_store.go @@ -13,11 +13,11 @@ type BlockStore struct { } // LoadBlockCommit provides a mock function with given fields: height -func (_m *BlockStore) LoadBlockCommit(height int64) *types.Commit { +func (_m *BlockStore) LoadBlockCommit(height uint64) *types.Commit { ret := _m.Called(height) var r0 *types.Commit - if rf, ok := ret.Get(0).(func(int64) *types.Commit); ok { + if rf, ok := ret.Get(0).(func(uint64) *types.Commit); ok { r0 = rf(height) } else { if ret.Get(0) != nil { @@ -29,11 +29,11 @@ func (_m *BlockStore) LoadBlockCommit(height int64) *types.Commit { } // LoadBlockMeta provides a mock function with given fields: height -func (_m *BlockStore) LoadBlockMeta(height int64) *types.BlockMeta { +func (_m *BlockStore) LoadBlockMeta(height uint64) *types.BlockMeta { ret := _m.Called(height) var r0 *types.BlockMeta - if rf, ok := ret.Get(0).(func(int64) *types.BlockMeta); ok { + if rf, ok := ret.Get(0).(func(uint64) *types.BlockMeta); ok { r0 = rf(height) } else { if ret.Get(0) != nil { diff --git a/evidence/pool.go b/evidence/pool.go index b0b737632..c67d3fc2f 100644 --- a/evidence/pool.go +++ b/evidence/pool.go @@ -334,13 +334,13 @@ func (evpool *Pool) fastCheck(ev types.Evidence) bool { // IsExpired checks whether evidence or a polc is expired by checking whether a height and time is older // than set by the evidence consensus parameters -func (evpool *Pool) isExpired(height int64, time time.Time) bool { +func (evpool *Pool) isExpired(height uint64, time time.Time) bool { var ( params = evpool.State().ConsensusParams.Evidence ageDuration = evpool.State().LastBlockTime.Sub(time) ageNumBlocks = evpool.State().LastBlockHeight - height ) - return ageNumBlocks > params.MaxAgeNumBlocks && + return ageNumBlocks > uint64(params.MaxAgeNumBlocks) && ageDuration > params.MaxAgeDuration } @@ -410,7 +410,7 @@ func (evpool *Pool) markEvidenceAsCommitted(evidence types.EvidenceList) { // we only need to record the height that it was saved at. key := keyCommitted(ev) - h := gogotypes.Int64Value{Value: ev.Height()} + h := gogotypes.UInt64Value{Value: ev.Height()} evBytes, err := proto.Marshal(&h) if err != nil { evpool.logger.Error("failed to marshal committed evidence", "key(height/hash)", key, "err", err) @@ -480,7 +480,7 @@ func (evpool *Pool) listEvidence(prefixKey int64, maxBytes int64) ([]types.Evide return evidence, totalSize, nil } -func (evpool *Pool) removeExpiredPendingEvidence() (int64, time.Time) { +func (evpool *Pool) removeExpiredPendingEvidence() (uint64, time.Time) { iter, err := dbm.IteratePrefix(evpool.evidenceStore, prefixToBytes(prefixPending)) if err != nil { evpool.logger.Error("failed to iterate over pending evidence", "err", err) @@ -505,7 +505,7 @@ func (evpool *Pool) removeExpiredPendingEvidence() (int64, time.Time) { // Return the height and time with which this evidence will have expired // so we know when to prune next. - return ev.Height() + evpool.State().ConsensusParams.Evidence.MaxAgeNumBlocks + 1, + return ev.Height() + uint64(evpool.State().ConsensusParams.Evidence.MaxAgeNumBlocks+1), ev.Time().Add(evpool.State().ConsensusParams.Evidence.MaxAgeDuration).Add(time.Second) } @@ -643,7 +643,7 @@ func prefixToBytes(prefix int64) []byte { } func keyCommitted(evidence types.Evidence) []byte { - var height int64 = evidence.Height() + var height uint64 = evidence.Height() key, err := orderedcode.Append(nil, prefixCommitted, height, string(evidence.Hash())) if err != nil { panic(err) @@ -652,7 +652,7 @@ func keyCommitted(evidence types.Evidence) []byte { } func keyPending(evidence types.Evidence) []byte { - var height int64 = evidence.Height() + var height uint64 = evidence.Height() key, err := orderedcode.Append(nil, prefixPending, height, string(evidence.Hash())) if err != nil { panic(err) diff --git a/evidence/pool_test.go b/evidence/pool_test.go index 3d17fef13..40f1122bd 100644 --- a/evidence/pool_test.go +++ b/evidence/pool_test.go @@ -30,7 +30,7 @@ var ( func TestEvidencePoolBasic(t *testing.T) { var ( - height = int64(1) + height = uint64(1) stateStore = &smmocks.Store{} evidenceDB = dbm.NewMemDB() blockStore = &mocks.BlockStore{} @@ -88,15 +88,15 @@ func TestEvidencePoolBasic(t *testing.T) { func TestAddExpiredEvidence(t *testing.T) { var ( val = types.NewMockPV() - height = int64(30) + height = uint64(30) stateStore = initializeValidatorState(t, val, height) evidenceDB = dbm.NewMemDB() blockStore = &mocks.BlockStore{} expiredEvidenceTime = time.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC) - expiredHeight = int64(2) + expiredHeight = uint64(2) ) - blockStore.On("LoadBlockMeta", mock.AnythingOfType("int64")).Return(func(h int64) *types.BlockMeta { + blockStore.On("LoadBlockMeta", mock.AnythingOfType("uint64")).Return(func(h uint64) *types.BlockMeta { if h == height || h == expiredHeight { return &types.BlockMeta{Header: types.Header{Time: defaultEvidenceTime}} } @@ -107,7 +107,7 @@ func TestAddExpiredEvidence(t *testing.T) { require.NoError(t, err) testCases := []struct { - evHeight int64 + evHeight uint64 evTime time.Time expErr bool evDescription string @@ -136,7 +136,7 @@ func TestAddExpiredEvidence(t *testing.T) { } func TestReportConflictingVotes(t *testing.T) { - var height int64 = 10 + var height uint64 = 10 pool, pv := defaultTestPool(t, height) val := types.NewValidator(pv.PrivKey.PubKey(), 10) @@ -168,7 +168,7 @@ func TestReportConflictingVotes(t *testing.T) { } func TestEvidencePoolUpdate(t *testing.T) { - height := int64(21) + height := uint64(21) pool, val := defaultTestPool(t, height) state := pool.State() @@ -212,7 +212,7 @@ func TestEvidencePoolUpdate(t *testing.T) { } func TestVerifyPendingEvidencePasses(t *testing.T) { - var height int64 = 1 + var height uint64 = 1 pool, val := defaultTestPool(t, height) ev := types.NewMockDuplicateVoteEvidenceWithValidator( @@ -227,7 +227,7 @@ func TestVerifyPendingEvidencePasses(t *testing.T) { } func TestVerifyDuplicatedEvidenceFails(t *testing.T) { - var height int64 = 1 + var height uint64 = 1 pool, val := defaultTestPool(t, height) ev := types.NewMockDuplicateVoteEvidenceWithValidator( height, @@ -246,9 +246,9 @@ func TestVerifyDuplicatedEvidenceFails(t *testing.T) { // evidence pool func TestCheckEvidenceWithLightClientAttack(t *testing.T) { var ( - nValidators = 5 - validatorPower int64 = 10 - height int64 = 10 + nValidators = 5 + validatorPower int64 = 10 + height uint64 = 10 ) conflictingVals, conflictingPrivVals := types.RandValidatorSet(nValidators, validatorPower) @@ -327,7 +327,7 @@ func TestCheckEvidenceWithLightClientAttack(t *testing.T) { // Tests that restarting the evidence pool after a potential failure will recover the // pending evidence and continue to gossip it func TestRecoverPendingEvidence(t *testing.T) { - height := int64(10) + height := uint64(10) val := types.NewMockPV() valAddress := val.PrivKey.PubKey().Address() evidenceDB := dbm.NewMemDB() @@ -349,7 +349,7 @@ func TestRecoverPendingEvidence(t *testing.T) { evidenceChainID, ) expiredEvidence := types.NewMockDuplicateVoteEvidenceWithValidator( - int64(1), + uint64(1), defaultEvidenceTime.Add(1*time.Minute), val, evidenceChainID, @@ -386,7 +386,7 @@ func TestRecoverPendingEvidence(t *testing.T) { require.Equal(t, goodEvidence, next.Value.(types.Evidence)) } -func initializeStateFromValidatorSet(t *testing.T, valSet *types.ValidatorSet, height int64) sm.Store { +func initializeStateFromValidatorSet(t *testing.T, valSet *types.ValidatorSet, height uint64) sm.Store { stateDB := dbm.NewMemDB() stateStore := sm.NewStore(stateDB) state := sm.State{ @@ -412,7 +412,7 @@ func initializeStateFromValidatorSet(t *testing.T, valSet *types.ValidatorSet, h } // save all states up to height - for i := int64(0); i <= height; i++ { + for i := uint64(0); i <= height; i++ { state.LastBlockHeight = i require.NoError(t, stateStore.Save(state)) } @@ -420,7 +420,7 @@ func initializeStateFromValidatorSet(t *testing.T, valSet *types.ValidatorSet, h return stateStore } -func initializeValidatorState(t *testing.T, privVal types.PrivValidator, height int64) sm.Store { +func initializeValidatorState(t *testing.T, privVal types.PrivValidator, height uint64) sm.Store { pubKey, _ := privVal.GetPubKey() validator := &types.Validator{Address: pubKey.Address(), VotingPower: 10, PubKey: pubKey} @@ -438,7 +438,7 @@ func initializeValidatorState(t *testing.T, privVal types.PrivValidator, height func initializeBlockStore(db dbm.DB, state sm.State, valAddr []byte) *store.BlockStore { blockStore := store.NewBlockStore(db) - for i := int64(1); i <= state.LastBlockHeight; i++ { + for i := uint64(1); i <= state.LastBlockHeight; i++ { lastCommit := makeCommit(i-1, valAddr) block, _ := state.MakeBlock(i, []types.Tx{}, lastCommit, nil, state.Validators.GetProposer().Address) @@ -454,7 +454,7 @@ func initializeBlockStore(db dbm.DB, state sm.State, valAddr []byte) *store.Bloc return blockStore } -func makeCommit(height int64, valAddr []byte) *types.Commit { +func makeCommit(height uint64, valAddr []byte) *types.Commit { commitSigs := []types.CommitSig{{ BlockIDFlag: types.BlockIDFlagCommit, ValidatorAddress: valAddr, @@ -465,7 +465,7 @@ func makeCommit(height int64, valAddr []byte) *types.Commit { return types.NewCommit(height, 0, types.BlockID{}, commitSigs) } -func defaultTestPool(t *testing.T, height int64) (*evidence.Pool, types.MockPV) { +func defaultTestPool(t *testing.T, height uint64) (*evidence.Pool, types.MockPV) { val := types.NewMockPV() valAddress := val.PrivKey.PubKey().Address() evidenceDB := dbm.NewMemDB() @@ -479,7 +479,7 @@ func defaultTestPool(t *testing.T, height int64) (*evidence.Pool, types.MockPV) return pool, val } -func createState(height int64, valSet *types.ValidatorSet) sm.State { +func createState(height uint64, valSet *types.ValidatorSet) sm.State { return sm.State{ ChainID: evidenceChainID, LastBlockHeight: height, diff --git a/evidence/reactor_test.go b/evidence/reactor_test.go index 0958b260f..c20b4e980 100644 --- a/evidence/reactor_test.go +++ b/evidence/reactor_test.go @@ -165,7 +165,7 @@ func createEvidenceList( evList := make([]types.Evidence, numEvidence) for i := 0; i < numEvidence; i++ { ev := types.NewMockDuplicateVoteEvidenceWithValidator( - int64(i+1), + uint64(i+1), time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC), val, evidenceChainID, @@ -211,7 +211,7 @@ func simulateRouter(wg *sync.WaitGroup, primary *reactorTestSuite, suites []*rea func TestReactorMultiDisconnect(t *testing.T) { val := types.NewMockPV() - height := int64(numEvidence) + 10 + height := uint64(numEvidence) + 10 stateDB1 := initializeValidatorState(t, val, height) stateDB2 := initializeValidatorState(t, val, height) @@ -251,7 +251,7 @@ func TestReactorBroadcastEvidence(t *testing.T) { // We need all validators saved for heights at least as high as we have // evidence for. - height := int64(numEvidence) + 10 + height := uint64(numEvidence) + 10 for i := 0; i < numPeers; i++ { stateDBs[i] = initializeValidatorState(t, val, height) } @@ -301,8 +301,8 @@ func TestReactorBroadcastEvidence(t *testing.T) { // ahead receives a list of evidence. func TestReactorBroadcastEvidence_Lagging(t *testing.T) { val := types.NewMockPV() - height1 := int64(numEvidence) + 10 - height2 := int64(numEvidence) / 2 + height1 := uint64(numEvidence) + 10 + height2 := uint64(numEvidence) / 2 // stateDB1 is ahead of stateDB2, where stateDB1 has all heights (1-10) and // stateDB2 only has heights 1-7. @@ -349,7 +349,7 @@ func TestReactorBroadcastEvidence_Lagging(t *testing.T) { func TestReactorBroadcastEvidence_Pending(t *testing.T) { val := types.NewMockPV() - height := int64(10) + height := uint64(10) stateDB1 := initializeValidatorState(t, val, height) stateDB2 := initializeValidatorState(t, val, height) @@ -399,7 +399,7 @@ func TestReactorBroadcastEvidence_Pending(t *testing.T) { func TestReactorBroadcastEvidence_Committed(t *testing.T) { val := types.NewMockPV() - height := int64(10) + height := uint64(10) stateDB1 := initializeValidatorState(t, val, height) stateDB2 := initializeValidatorState(t, val, height) @@ -465,7 +465,7 @@ func TestReactorBroadcastEvidence_FullyConnected(t *testing.T) { // We need all validators saved for heights at least as high as we have // evidence for. - height := int64(numEvidence) + 10 + height := uint64(numEvidence) + 10 for i := 0; i < numPeers; i++ { stateDBs[i] = initializeValidatorState(t, val, height) } @@ -510,7 +510,7 @@ func TestReactorBroadcastEvidence_FullyConnected(t *testing.T) { func TestReactorBroadcastEvidence_RemovePeer(t *testing.T) { val := types.NewMockPV() - height := int64(10) + height := uint64(10) stateDB1 := initializeValidatorState(t, val, height) stateDB2 := initializeValidatorState(t, val, height) diff --git a/evidence/verify.go b/evidence/verify.go index dabd248c8..ffa308d55 100644 --- a/evidence/verify.go +++ b/evidence/verify.go @@ -56,14 +56,14 @@ func (evpool *Pool) verify(evidence types.Evidence) error { ageDuration := state.LastBlockTime.Sub(evTime) // check that the evidence hasn't expired - if ageDuration > evidenceParams.MaxAgeDuration && ageNumBlocks > evidenceParams.MaxAgeNumBlocks { + if ageDuration > evidenceParams.MaxAgeDuration && int64(ageNumBlocks) > evidenceParams.MaxAgeNumBlocks { return types.NewErrInvalidEvidence( evidence, fmt.Errorf( "evidence from height %d (created at: %v) is too old; min height is %d and evidence can not be older than %v", evidence.Height(), evTime, - height-evidenceParams.MaxAgeNumBlocks, + height-uint64(evidenceParams.MaxAgeNumBlocks), state.LastBlockTime.Add(evidenceParams.MaxAgeDuration), ), ) @@ -281,7 +281,7 @@ func VerifyDuplicateVote(e *types.DuplicateVoteEvidence, chainID string, valSet return nil } -func getSignedHeader(blockStore BlockStore, height int64) (*types.SignedHeader, error) { +func getSignedHeader(blockStore BlockStore, height uint64) (*types.SignedHeader, error) { blockMeta := blockStore.LoadBlockMeta(height) if blockMeta == nil { return nil, fmt.Errorf("don't have header at height #%d", height) diff --git a/evidence/verify_test.go b/evidence/verify_test.go index e97dc402a..7f09f7e4b 100644 --- a/evidence/verify_test.go +++ b/evidence/verify_test.go @@ -384,7 +384,7 @@ func TestVerifyDuplicateVoteEvidence(t *testing.T) { } func makeVote( - t *testing.T, val types.PrivValidator, chainID string, valIndex int32, height int64, + t *testing.T, val types.PrivValidator, chainID string, valIndex int32, height uint64, round int32, step int, blockID types.BlockID, time time.Time) *types.Vote { pubKey, err := val.GetPubKey() require.NoError(t, err) @@ -407,7 +407,7 @@ func makeVote( return v } -func makeHeaderRandom(height int64) *types.Header { +func makeHeaderRandom(height uint64) *types.Header { return &types.Header{ Version: version.Consensus{Block: version.BlockProtocol, App: 1}, ChainID: evidenceChainID, diff --git a/light/client.go b/light/client.go index 1fe10a364..82a7c8f8f 100644 --- a/light/client.go +++ b/light/client.go @@ -385,7 +385,7 @@ func (c *Client) compareWithLatestHeight(height uint64) (uint64, error) { if err != nil { return 0, fmt.Errorf("can't get last trusted height: %w", err) } - if latestHeight == -1 { // todo standardize errors + if latestHeight == 0 { // todo: should we standardize errors to avoid 0 checks return 0, errors.New("no headers exist") } @@ -410,7 +410,7 @@ func (c *Client) Update(ctx context.Context, now time.Time) (*types.LightBlock, return nil, fmt.Errorf("can't get last trusted height: %w", err) } - if lastTrustedHeight == -1 { + if lastTrustedHeight == 0 { // no light blocks yet => wait return nil, nil } diff --git a/light/detector_test.go b/light/detector_test.go index 9b172ae2a..ca05609e1 100644 --- a/light/detector_test.go +++ b/light/detector_test.go @@ -27,20 +27,20 @@ func TestLightClientAttackEvidence_Lunatic(t *testing.T) { primaryValidators = make(map[int64]*types.ValidatorSet, latestHeight) ) - witnessHeaders, witnessValidators, chainKeys := genMockNodeWithKeys(chainID, latestHeight, valSize, 2, bTime) + witnessHeaders, witnessValidators, chainKeys := genMockNodeWithKeys(chainID, int64(latestHeight), valSize, 2, bTime) witness := mockp.New(chainID, witnessHeaders, witnessValidators) - forgedKeys := chainKeys[divergenceHeight-1].ChangeKeys(3) // we change 3 out of the 5 validators (still 2/5 remain) + forgedKeys := chainKeys[int64(divergenceHeight)-1].ChangeKeys(3) // we change 3 out of the 5 validators (still 2/5 remain) forgedVals := forgedKeys.ToValidators(2, 0) - for height := int64(1); height <= latestHeight; height++ { + for height := uint64(1); height <= latestHeight; height++ { if height < divergenceHeight { - primaryHeaders[height] = witnessHeaders[height] - primaryValidators[height] = witnessValidators[height] + primaryHeaders[int64(height)] = witnessHeaders[int64(height)] + primaryValidators[int64(height)] = witnessValidators[int64(height)] continue } - primaryHeaders[height] = forgedKeys.GenSignedHeader(chainID, height, bTime.Add(time.Duration(height)*time.Minute), + primaryHeaders[int64(height)] = forgedKeys.GenSignedHeader(chainID, height, bTime.Add(time.Duration(height)*time.Minute), nil, forgedVals, forgedVals, hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(forgedKeys)) - primaryValidators[height] = forgedVals + primaryValidators[int64(height)] = forgedVals } primary := mockp.New(chainID, primaryHeaders, primaryValidators) @@ -118,7 +118,7 @@ func TestLightClientAttackEvidence_Equivocation(t *testing.T) { } // we don't have a network partition so we will make 4/5 (greater than 2/3) malicious and vote again for // a different block (which we do by adding txs) - primaryHeaders[height] = chainKeys[height].GenSignedHeader(chainID, height, + primaryHeaders[height] = chainKeys[height].GenSignedHeader(chainID, uint64(height), bTime.Add(time.Duration(height)*time.Minute), []types.Tx{[]byte("abcd")}, witnessValidators[height], witnessValidators[height+1], hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(chainKeys[height])-1) @@ -157,7 +157,7 @@ func TestLightClientAttackEvidence_Equivocation(t *testing.T) { SignedHeader: primaryHeaders[divergenceHeight], ValidatorSet: primaryValidators[divergenceHeight], }, - CommonHeight: divergenceHeight, + CommonHeight: uint64(divergenceHeight), } assert.True(t, witness.HasEvidence(evAgainstPrimary)) @@ -166,7 +166,7 @@ func TestLightClientAttackEvidence_Equivocation(t *testing.T) { SignedHeader: witnessHeaders[divergenceHeight], ValidatorSet: witnessValidators[divergenceHeight], }, - CommonHeight: divergenceHeight, + CommonHeight: uint64(divergenceHeight), } assert.True(t, primary.HasEvidence(evAgainstWitness)) } diff --git a/light/proxy/routes.go b/light/proxy/routes.go index db8df9783..d086d414c 100644 --- a/light/proxy/routes.go +++ b/light/proxy/routes.go @@ -75,10 +75,10 @@ func makeNetInfoFunc(c *lrpc.Client) rpcNetInfoFunc { } } -type rpcBlockchainInfoFunc func(ctx *rpctypes.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) +type rpcBlockchainInfoFunc func(ctx *rpctypes.Context, minHeight, maxHeight uint64) (*ctypes.ResultBlockchainInfo, error) func makeBlockchainInfoFunc(c *lrpc.Client) rpcBlockchainInfoFunc { - return func(ctx *rpctypes.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) { + return func(ctx *rpctypes.Context, minHeight, maxHeight uint64) (*ctypes.ResultBlockchainInfo, error) { return c.BlockchainInfo(ctx.Context(), minHeight, maxHeight) } } @@ -91,10 +91,10 @@ func makeGenesisFunc(c *lrpc.Client) rpcGenesisFunc { } } -type rpcBlockFunc func(ctx *rpctypes.Context, height *int64) (*ctypes.ResultBlock, error) +type rpcBlockFunc func(ctx *rpctypes.Context, height *uint64) (*ctypes.ResultBlock, error) func makeBlockFunc(c *lrpc.Client) rpcBlockFunc { - return func(ctx *rpctypes.Context, height *int64) (*ctypes.ResultBlock, error) { + return func(ctx *rpctypes.Context, height *uint64) (*ctypes.ResultBlock, error) { return c.Block(ctx.Context(), height) } } @@ -107,18 +107,18 @@ func makeBlockByHashFunc(c *lrpc.Client) rpcBlockByHashFunc { } } -type rpcBlockResultsFunc func(ctx *rpctypes.Context, height *int64) (*ctypes.ResultBlockResults, error) +type rpcBlockResultsFunc func(ctx *rpctypes.Context, height *uint64) (*ctypes.ResultBlockResults, error) func makeBlockResultsFunc(c *lrpc.Client) rpcBlockResultsFunc { - return func(ctx *rpctypes.Context, height *int64) (*ctypes.ResultBlockResults, error) { + return func(ctx *rpctypes.Context, height *uint64) (*ctypes.ResultBlockResults, error) { return c.BlockResults(ctx.Context(), height) } } -type rpcCommitFunc func(ctx *rpctypes.Context, height *int64) (*ctypes.ResultCommit, error) +type rpcCommitFunc func(ctx *rpctypes.Context, height *uint64) (*ctypes.ResultCommit, error) func makeCommitFunc(c *lrpc.Client) rpcCommitFunc { - return func(ctx *rpctypes.Context, height *int64) (*ctypes.ResultCommit, error) { + return func(ctx *rpctypes.Context, height *uint64) (*ctypes.ResultCommit, error) { return c.Commit(ctx.Context(), height) } } @@ -141,11 +141,11 @@ func makeTxSearchFunc(c *lrpc.Client) rpcTxSearchFunc { } } -type rpcValidatorsFunc func(ctx *rpctypes.Context, height *int64, +type rpcValidatorsFunc func(ctx *rpctypes.Context, height *uint64, page, perPage *int) (*ctypes.ResultValidators, error) func makeValidatorsFunc(c *lrpc.Client) rpcValidatorsFunc { - return func(ctx *rpctypes.Context, height *int64, page, perPage *int) (*ctypes.ResultValidators, error) { + return func(ctx *rpctypes.Context, height *uint64, page, perPage *int) (*ctypes.ResultValidators, error) { return c.Validators(ctx.Context(), height, page, perPage) } } diff --git a/light/rpc/client.go b/light/rpc/client.go index 27b2b41b7..2debbb2bd 100644 --- a/light/rpc/client.go +++ b/light/rpc/client.go @@ -26,6 +26,7 @@ var errNegOrZeroHeight = errors.New("negative or zero height") type KeyPathFunc func(path string, key []byte) (merkle.KeyPath, error) // LightClient is an interface that contains functionality needed by Client from the light client. +//go:generate mockery --case underscore --name LightClient type LightClient interface { ChainID() string VerifyLightBlockAtHeight(ctx context.Context, height uint64, now time.Time) (*types.LightBlock, error) diff --git a/light/rpc/mocks/light_client.go b/light/rpc/mocks/light_client.go index 3613472a9..8ec167fd4 100644 --- a/light/rpc/mocks/light_client.go +++ b/light/rpc/mocks/light_client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.3.0. DO NOT EDIT. +// Code generated by mockery v2.5.1. DO NOT EDIT. package mocks @@ -36,7 +36,7 @@ func (_m *LightClient) TrustedLightBlock(height uint64) (*types.LightBlock, erro ret := _m.Called(height) var r0 *types.LightBlock - if rf, ok := ret.Get(0).(func(int64) *types.LightBlock); ok { + if rf, ok := ret.Get(0).(func(uint64) *types.LightBlock); ok { r0 = rf(height) } else { if ret.Get(0) != nil { @@ -45,7 +45,7 @@ func (_m *LightClient) TrustedLightBlock(height uint64) (*types.LightBlock, erro } var r1 error - if rf, ok := ret.Get(1).(func(int64) error); ok { + if rf, ok := ret.Get(1).(func(uint64) error); ok { r1 = rf(height) } else { r1 = ret.Error(1) @@ -55,11 +55,11 @@ func (_m *LightClient) TrustedLightBlock(height uint64) (*types.LightBlock, erro } // VerifyLightBlockAtHeight provides a mock function with given fields: ctx, height, now -func (_m *LightClient) VerifyLightBlockAtHeight(ctx context.Context, height int64, now time.Time) (*types.LightBlock, error) { +func (_m *LightClient) VerifyLightBlockAtHeight(ctx context.Context, height uint64, now time.Time) (*types.LightBlock, error) { ret := _m.Called(ctx, height, now) var r0 *types.LightBlock - if rf, ok := ret.Get(0).(func(context.Context, int64, time.Time) *types.LightBlock); ok { + if rf, ok := ret.Get(0).(func(context.Context, uint64, time.Time) *types.LightBlock); ok { r0 = rf(ctx, height, now) } else { if ret.Get(0) != nil { @@ -68,7 +68,7 @@ func (_m *LightClient) VerifyLightBlockAtHeight(ctx context.Context, height int6 } var r1 error - if rf, ok := ret.Get(1).(func(context.Context, int64, time.Time) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, uint64, time.Time) error); ok { r1 = rf(ctx, height, now) } else { r1 = ret.Error(1) diff --git a/proto/tendermint/consensus/types.pb.go b/proto/tendermint/consensus/types.pb.go index 6372a88d4..d5c5fe0f6 100644 --- a/proto/tendermint/consensus/types.pb.go +++ b/proto/tendermint/consensus/types.pb.go @@ -28,7 +28,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // NewRoundStep is sent for every step taken in the ConsensusState. // For every height/round/step transition type NewRoundStep struct { - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` Step uint32 `protobuf:"varint,3,opt,name=step,proto3" json:"step,omitempty"` SecondsSinceStartTime int64 `protobuf:"varint,4,opt,name=seconds_since_start_time,json=secondsSinceStartTime,proto3" json:"seconds_since_start_time,omitempty"` @@ -68,7 +68,7 @@ func (m *NewRoundStep) XXX_DiscardUnknown() { var xxx_messageInfo_NewRoundStep proto.InternalMessageInfo -func (m *NewRoundStep) GetHeight() int64 { +func (m *NewRoundStep) GetHeight() uint64 { if m != nil { return m.Height } @@ -107,7 +107,7 @@ func (m *NewRoundStep) GetLastCommitRound() int32 { //i.e., there is a Proposal for block B and 2/3+ prevotes for the block B in the round r. // In case the block is also committed, then IsCommit flag is set to true. type NewValidBlock struct { - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` BlockPartSetHeader types.PartSetHeader `protobuf:"bytes,3,opt,name=block_part_set_header,json=blockPartSetHeader,proto3" json:"block_part_set_header"` BlockParts *bits.BitArray `protobuf:"bytes,4,opt,name=block_parts,json=blockParts,proto3" json:"block_parts,omitempty"` @@ -147,7 +147,7 @@ func (m *NewValidBlock) XXX_DiscardUnknown() { var xxx_messageInfo_NewValidBlock proto.InternalMessageInfo -func (m *NewValidBlock) GetHeight() int64 { +func (m *NewValidBlock) GetHeight() uint64 { if m != nil { return m.Height } @@ -229,7 +229,7 @@ func (m *Proposal) GetProposal() types.Proposal { // ProposalPOL is sent when a previous proposal is re-proposed. type ProposalPOL struct { - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` ProposalPolRound int32 `protobuf:"varint,2,opt,name=proposal_pol_round,json=proposalPolRound,proto3" json:"proposal_pol_round,omitempty"` ProposalPol bits.BitArray `protobuf:"bytes,3,opt,name=proposal_pol,json=proposalPol,proto3" json:"proposal_pol"` } @@ -267,7 +267,7 @@ func (m *ProposalPOL) XXX_DiscardUnknown() { var xxx_messageInfo_ProposalPOL proto.InternalMessageInfo -func (m *ProposalPOL) GetHeight() int64 { +func (m *ProposalPOL) GetHeight() uint64 { if m != nil { return m.Height } @@ -290,7 +290,7 @@ func (m *ProposalPOL) GetProposalPol() bits.BitArray { // BlockPart is sent when gossipping a piece of the proposed block. type BlockPart struct { - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` Part types.Part `protobuf:"bytes,3,opt,name=part,proto3" json:"part"` } @@ -328,7 +328,7 @@ func (m *BlockPart) XXX_DiscardUnknown() { var xxx_messageInfo_BlockPart proto.InternalMessageInfo -func (m *BlockPart) GetHeight() int64 { +func (m *BlockPart) GetHeight() uint64 { if m != nil { return m.Height } @@ -396,7 +396,7 @@ func (m *Vote) GetVote() *types.Vote { // HasVote is sent to indicate that a particular vote has been received. type HasVote struct { - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` Type types.SignedMsgType `protobuf:"varint,3,opt,name=type,proto3,enum=tendermint.types.SignedMsgType" json:"type,omitempty"` Index int32 `protobuf:"varint,4,opt,name=index,proto3" json:"index,omitempty"` @@ -435,7 +435,7 @@ func (m *HasVote) XXX_DiscardUnknown() { var xxx_messageInfo_HasVote proto.InternalMessageInfo -func (m *HasVote) GetHeight() int64 { +func (m *HasVote) GetHeight() uint64 { if m != nil { return m.Height } @@ -465,7 +465,7 @@ func (m *HasVote) GetIndex() int32 { // VoteSetMaj23 is sent to indicate that a given BlockID has seen +2/3 votes. type VoteSetMaj23 struct { - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` Type types.SignedMsgType `protobuf:"varint,3,opt,name=type,proto3,enum=tendermint.types.SignedMsgType" json:"type,omitempty"` BlockID types.BlockID `protobuf:"bytes,4,opt,name=block_id,json=blockId,proto3" json:"block_id"` @@ -504,7 +504,7 @@ func (m *VoteSetMaj23) XXX_DiscardUnknown() { var xxx_messageInfo_VoteSetMaj23 proto.InternalMessageInfo -func (m *VoteSetMaj23) GetHeight() int64 { +func (m *VoteSetMaj23) GetHeight() uint64 { if m != nil { return m.Height } @@ -534,7 +534,7 @@ func (m *VoteSetMaj23) GetBlockID() types.BlockID { // VoteSetBits is sent to communicate the bit-array of votes seen for the BlockID. type VoteSetBits struct { - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` Type types.SignedMsgType `protobuf:"varint,3,opt,name=type,proto3,enum=tendermint.types.SignedMsgType" json:"type,omitempty"` BlockID types.BlockID `protobuf:"bytes,4,opt,name=block_id,json=blockId,proto3" json:"block_id"` @@ -574,7 +574,7 @@ func (m *VoteSetBits) XXX_DiscardUnknown() { var xxx_messageInfo_VoteSetBits proto.InternalMessageInfo -func (m *VoteSetBits) GetHeight() int64 { +func (m *VoteSetBits) GetHeight() uint64 { if m != nil { return m.Height } @@ -801,61 +801,61 @@ func init() { func init() { proto.RegisterFile("tendermint/consensus/types.proto", fileDescriptor_81a22d2efc008981) } var fileDescriptor_81a22d2efc008981 = []byte{ - // 853 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x4f, 0x8f, 0xdb, 0x44, - 0x14, 0xb7, 0x59, 0x67, 0x93, 0x7d, 0xde, 0xec, 0xc2, 0x68, 0x5b, 0x85, 0x00, 0x49, 0x30, 0x97, - 0x15, 0x42, 0x0e, 0xca, 0x1e, 0x90, 0x0a, 0x12, 0x60, 0xfe, 0xd4, 0xad, 0x9a, 0x36, 0x72, 0x4a, - 0x85, 0xb8, 0x58, 0x4e, 0x3c, 0x4a, 0x86, 0xc6, 0x1e, 0xcb, 0x33, 0xc9, 0xb2, 0x57, 0x3e, 0x01, - 0x1f, 0x80, 0xaf, 0x81, 0xc4, 0x47, 0xe8, 0xb1, 0x47, 0x4e, 0x15, 0xca, 0x7e, 0x04, 0x04, 0x67, - 0x34, 0xe3, 0x49, 0x3c, 0xa1, 0xde, 0x85, 0xbd, 0x20, 0xf5, 0x36, 0xe3, 0xf7, 0xde, 0x6f, 0xde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x75, 0xf6, 0xed, 0xea, 0x52, 0xaa, - 0x33, 0xa5, 0xa7, 0x33, 0x00, 0xeb, 0x09, 0xe5, 0xa2, 0x03, 0xad, 0x15, 0xe5, 0x58, 0xb1, 0x59, - 0x11, 0x29, 0xbc, 0x02, 0xe9, 0xe3, 0xfc, 0x68, 0x42, 0xdd, 0x8f, 0x98, 0x8c, 0xbb, 0x59, 0x7e, - 0x67, 0x60, 0x09, 0x34, 0x99, 0xdf, 0x51, 0x55, 0xab, 0x8d, 0xc9, 0x2c, 0xc5, 0xf1, 0x90, 0xcd, - 0x1e, 0x5f, 0x64, 0x38, 0x90, 0xce, 0x02, 0x8a, 0xa4, 0x31, 0xfe, 0x41, 0x36, 0x54, 0x2d, 0x28, - 0x36, 0xce, 0xaf, 0x26, 0x1c, 0x8a, 0x0c, 0xc6, 0x98, 0x0f, 0xa3, 0xef, 0x07, 0x67, 0xff, 0x47, - 0x26, 0x5f, 0x41, 0xa3, 0x68, 0x70, 0x12, 0xab, 0xee, 0x7e, 0xf3, 0xe5, 0x40, 0x59, 0xbb, 0x7b, - 0x5f, 0x7a, 0xc7, 0x82, 0xe5, 0xf5, 0x8b, 0x6e, 0x5d, 0x7d, 0x08, 0xea, 0x32, 0xf6, 0x5e, 0xec, - 0xfc, 0x61, 0x82, 0xad, 0x52, 0xf7, 0x08, 0x67, 0xaf, 0x4e, 0xe6, 0xe8, 0x0e, 0xd4, 0x44, 0x07, - 0x30, 0x39, 0x9c, 0xff, 0xb5, 0xb9, 0x8b, 0x10, 0xe7, 0x2f, 0x0b, 0xea, 0x43, 0xcc, 0x58, 0x34, - 0xc3, 0xe8, 0x3e, 0x1c, 0xa5, 0xf8, 0xbc, 0x18, 0xa8, 0x50, 0xca, 0x68, 0xd1, 0x77, 0x8e, 0x5b, - 0xf5, 0x03, 0x70, 0x75, 0x99, 0xf6, 0x8d, 0xe0, 0x30, 0xd5, 0x65, 0x7b, 0x08, 0xc7, 0x02, 0x6b, - 0x25, 0xf4, 0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4, 0xaf, 0xbf, 0x26, 0xca, 0x65, 0xf1, 0xea, 0xa8, - 0x7a, 0xb7, 0x4c, 0xf6, 0xa5, 0xed, 0xec, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc7, 0x5c, 0x91, - 0x04, 0xd6, 0x08, 0x00, 0x00, + // 855 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcd, 0x8e, 0xe3, 0x44, + 0x10, 0xb6, 0x19, 0x67, 0x92, 0x29, 0xcf, 0x0f, 0xb4, 0x66, 0x57, 0x61, 0x80, 0x4c, 0x30, 0x97, + 0x11, 0x42, 0x0e, 0xca, 0x1c, 0x90, 0x16, 0x24, 0xc0, 0xfc, 0xac, 0x77, 0xb5, 0xb3, 0x1b, 0x75, + 0x96, 0x15, 0xe2, 0x62, 0x39, 0x71, 0x2b, 0x69, 0x36, 0x76, 0x5b, 0xee, 0x4e, 0x86, 0xb9, 0xf2, + 0x04, 0x3c, 0x00, 0xaf, 0x81, 0xc4, 0x23, 0xec, 0x71, 0x8f, 0x9c, 0x56, 0x28, 0xf3, 0x08, 0x08, + 0xce, 0xa8, 0xdb, 0x9d, 0xb8, 0xc3, 0x7a, 0x06, 0xe6, 0x82, 0xb4, 0xb7, 0x6e, 0x57, 0xd5, 0xd7, + 0xd5, 0x5f, 0x55, 0x7d, 0x6e, 0xe8, 0x0a, 0x92, 0x25, 0xa4, 0x48, 0x69, 0x26, 0x7a, 0x63, 0x96, + 0x71, 0x92, 0xf1, 0x39, 0xef, 0x89, 0x8b, 0x9c, 0x70, 0x3f, 0x2f, 0x98, 0x60, 0xe8, 0xb0, 0xf2, + 0xf0, 0xd7, 0x1e, 0x47, 0x87, 0x13, 0x36, 0x61, 0xca, 0xa1, 0x27, 0x57, 0xa5, 0xef, 0xd1, 0xdb, + 0x06, 0x9a, 0xc2, 0x30, 0x91, 0x8e, 0xcc, 0xb3,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0xf5, 0x28, 0x6b, 0xad, + 0x08, 0x2d, 0xbc, 0xb3, 0x16, 0x53, 0x29, 0x05, 0x6a, 0xa0, 0xb7, 0x5f, 0x96, 0xc7, 0x2a, 0x56, + 0x76, 0x61, 0x68, 0x95, 0x63, 0x8d, 0xee, 0x40, 0x6b, 0x1a, 0xf3, 0x48, 0x45, 0x35, 0x55, 0xd4, + 0x3b, 0xf5, 0x51, 0x7a, 0xf6, 0x43, 0x0b, 0x37, 0xa7, 0x5a, 0x06, 0xee, 0xc3, 0xbe, 0x8c, 0x53, + 0xbf, 0x93, 0x54, 0x8e, 0x63, 0xbb, 0x75, 0x5d, 0x41, 0xcd, 0xc1, 0x95, 0x05, 0x5d, 0x98, 0x83, + 0x7c, 0x17, 0xf6, 0xd6, 0x58, 0xb2, 0x9f, 0xda, 0x3b, 0xd7, 0x91, 0x68, 0x0c, 0x92, 0x24, 0x71, + 0x51, 0x6d, 0x83, 0x06, 0x6c, 0xf1, 0x79, 0x1a, 0x7c, 0xf3, 0x6c, 0xd9, 0xb1, 0x9f, 0x2f, 0x3b, + 0xf6, 0xef, 0xcb, 0x8e, 0xfd, 0xd3, 0x65, 0xc7, 0x7a, 0x7e, 0xd9, 0xb1, 0x7e, 0xbb, 0xec, 0x58, + 0xdf, 0x7d, 0x3c, 0xa1, 0x62, 0x3a, 0x1f, 0xf9, 0x63, 0x96, 0xf6, 0xcc, 0xd7, 0x44, 0xb5, 0x2c, + 0x5f, 0x1d, 0x75, 0xef, 0x96, 0xd1, 0xb6, 0xb2, 0x9d, 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xd2, + 0xa7, 0x97, 0x11, 0xd6, 0x08, 0x00, 0x00, } func (m *NewRoundStep) Marshal() (dAtA []byte, err error) { @@ -1845,7 +1845,7 @@ func (m *NewRoundStep) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= int64(b&0x7F) << shift + m.Height |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1990,7 +1990,7 @@ func (m *NewValidBlock) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= int64(b&0x7F) << shift + m.Height |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2250,7 +2250,7 @@ func (m *ProposalPOL) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= int64(b&0x7F) << shift + m.Height |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2371,7 +2371,7 @@ func (m *BlockPart) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= int64(b&0x7F) << shift + m.Height |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2578,7 +2578,7 @@ func (m *HasVote) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= int64(b&0x7F) << shift + m.Height |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2704,7 +2704,7 @@ func (m *VoteSetMaj23) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= int64(b&0x7F) << shift + m.Height |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2844,7 +2844,7 @@ func (m *VoteSetBits) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= int64(b&0x7F) << shift + m.Height |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/proto/tendermint/consensus/types.proto b/proto/tendermint/consensus/types.proto index 6e1f41371..f7f94d91d 100644 --- a/proto/tendermint/consensus/types.proto +++ b/proto/tendermint/consensus/types.proto @@ -10,7 +10,7 @@ import "tendermint/libs/bits/types.proto"; // NewRoundStep is sent for every step taken in the ConsensusState. // For every height/round/step transition message NewRoundStep { - int64 height = 1; + uint64 height = 1; int32 round = 2; uint32 step = 3; int64 seconds_since_start_time = 4; @@ -21,7 +21,7 @@ message NewRoundStep { //i.e., there is a Proposal for block B and 2/3+ prevotes for the block B in the round r. // In case the block is also committed, then IsCommit flag is set to true. message NewValidBlock { - int64 height = 1; + uint64 height = 1; int32 round = 2; tendermint.types.PartSetHeader block_part_set_header = 3 [(gogoproto.nullable) = false]; tendermint.libs.bits.BitArray block_parts = 4; @@ -35,14 +35,14 @@ message Proposal { // ProposalPOL is sent when a previous proposal is re-proposed. message ProposalPOL { - int64 height = 1; + uint64 height = 1; int32 proposal_pol_round = 2; tendermint.libs.bits.BitArray proposal_pol = 3 [(gogoproto.nullable) = false]; } // BlockPart is sent when gossipping a piece of the proposed block. message BlockPart { - int64 height = 1; + uint64 height = 1; int32 round = 2; tendermint.types.Part part = 3 [(gogoproto.nullable) = false]; } @@ -54,7 +54,7 @@ message Vote { // HasVote is sent to indicate that a particular vote has been received. message HasVote { - int64 height = 1; + uint64 height = 1; int32 round = 2; tendermint.types.SignedMsgType type = 3; int32 index = 4; @@ -62,7 +62,7 @@ message HasVote { // VoteSetMaj23 is sent to indicate that a given BlockID has seen +2/3 votes. message VoteSetMaj23 { - int64 height = 1; + uint64 height = 1; int32 round = 2; tendermint.types.SignedMsgType type = 3; tendermint.types.BlockID block_id = 4 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; @@ -70,7 +70,7 @@ message VoteSetMaj23 { // VoteSetBits is sent to communicate the bit-array of votes seen for the BlockID. message VoteSetBits { - int64 height = 1; + uint64 height = 1; int32 round = 2; tendermint.types.SignedMsgType type = 3; tendermint.types.BlockID block_id = 4 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; diff --git a/proto/tendermint/types/events.pb.go b/proto/tendermint/types/events.pb.go index a9aa26a79..ec97f7a9d 100644 --- a/proto/tendermint/types/events.pb.go +++ b/proto/tendermint/types/events.pb.go @@ -23,7 +23,7 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type EventDataRoundState struct { - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` Step string `protobuf:"bytes,3,opt,name=step,proto3" json:"step,omitempty"` } @@ -61,7 +61,7 @@ func (m *EventDataRoundState) XXX_DiscardUnknown() { var xxx_messageInfo_EventDataRoundState proto.InternalMessageInfo -func (m *EventDataRoundState) GetHeight() int64 { +func (m *EventDataRoundState) GetHeight() uint64 { if m != nil { return m.Height } @@ -95,13 +95,13 @@ var fileDescriptor_72cfafd446dedf7c = []byte{ 0xcd, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x40, 0x48, 0xeb, 0x81, 0xa5, 0x95, 0xc2, 0xb9, 0x84, 0x5d, 0x41, 0x2a, 0x5c, 0x12, 0x4b, 0x12, 0x83, 0xf2, 0x4b, 0xf3, 0x52, 0x82, 0x4b, 0x12, 0x4b, 0x52, 0x85, 0xc4, 0xb8, 0xd8, 0x32, 0x52, 0x33, 0xd3, 0x33, 0x4a, 0x24, - 0x18, 0x15, 0x18, 0x35, 0x98, 0x83, 0xa0, 0x3c, 0x21, 0x11, 0x2e, 0xd6, 0x22, 0x90, 0x2a, 0x09, + 0x18, 0x15, 0x18, 0x35, 0x58, 0x82, 0xa0, 0x3c, 0x21, 0x11, 0x2e, 0xd6, 0x22, 0x90, 0x2a, 0x09, 0x26, 0x05, 0x46, 0x0d, 0xd6, 0x20, 0x08, 0x47, 0x48, 0x88, 0x8b, 0xa5, 0xb8, 0x24, 0xb5, 0x40, 0x82, 0x59, 0x81, 0x51, 0x83, 0x33, 0x08, 0xcc, 0x76, 0x0a, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xf3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x64, 0xe7, 0x22, 0x98, 0x60, 0xc7, 0xea, 0xa3, 0x7b, 0x25, 0x89, 0x0d, 0x2c, 0x6e, 0x0c, - 0x08, 0x00, 0x00, 0xff, 0xff, 0xc3, 0xe9, 0x14, 0x02, 0xe5, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0xff, 0xff, 0x67, 0xc9, 0x82, 0x7f, 0xe5, 0x00, 0x00, 0x00, } func (m *EventDataRoundState) Marshal() (dAtA []byte, err error) { @@ -223,7 +223,7 @@ func (m *EventDataRoundState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= int64(b&0x7F) << shift + m.Height |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/proto/tendermint/types/events.proto b/proto/tendermint/types/events.proto index a1e5cc498..d25b35503 100644 --- a/proto/tendermint/types/events.proto +++ b/proto/tendermint/types/events.proto @@ -4,7 +4,7 @@ package tendermint.types; option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; message EventDataRoundState { - int64 height = 1; + uint64 height = 1; int32 round = 2; string step = 3; } diff --git a/rpc/client/interface.go b/rpc/client/interface.go index a778bb415..4169418e6 100644 --- a/rpc/client/interface.go +++ b/rpc/client/interface.go @@ -31,6 +31,7 @@ import ( // Client wraps most important rpc calls a client would make if you want to // listen for events, test if it also implements events.EventSwitch. +//go:generate mockery --case underscore --name Client type Client interface { service.Service ABCIClient diff --git a/rpc/client/mock/abci.go b/rpc/client/mock/abci.go index 0737deec0..a6a4c68be 100644 --- a/rpc/client/mock/abci.go +++ b/rpc/client/mock/abci.go @@ -56,7 +56,7 @@ func (a ABCIApp) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.Re return &res, nil } res.DeliverTx = a.App.DeliverTx(abci.RequestDeliverTx{Tx: tx}) - res.Height = -1 // TODO + res.Height = 0 // TODO: see if 0 affects logic return &res, nil } @@ -166,7 +166,7 @@ func NewABCIRecorder(client client.ABCIClient) *ABCIRecorder { type QueryArgs struct { Path string Data bytes.HexBytes - Height int64 + Height uint64 Prove bool } diff --git a/rpc/client/mock/abci_test.go b/rpc/client/mock/abci_test.go index d164b275a..a4a74637b 100644 --- a/rpc/client/mock/abci_test.go +++ b/rpc/client/mock/abci_test.go @@ -22,7 +22,7 @@ func TestABCIMock(t *testing.T) { assert, require := assert.New(t), require.New(t) key, value := []byte("foo"), []byte("bar") - height := int64(10) + height := uint64(10) goodTx := types.Tx{0x01, 0xff} badTx := types.Tx{0x12, 0x21} @@ -180,7 +180,7 @@ func TestABCIApp(t *testing.T) { // commit // TODO: This may not be necessary in the future - if res.Height == -1 { + if res.Height == 0 { m.App.Commit() } diff --git a/rpc/client/mock/client.go b/rpc/client/mock/client.go index ed911ec20..e77f8676c 100644 --- a/rpc/client/mock/client.go +++ b/rpc/client/mock/client.go @@ -128,7 +128,7 @@ func (c Client) DumpConsensusState(ctx context.Context) (*ctypes.ResultDumpConse return core.DumpConsensusState(&rpctypes.Context{}) } -func (c Client) ConsensusParams(ctx context.Context, height *int64) (*ctypes.ResultConsensusParams, error) { +func (c Client) ConsensusParams(ctx context.Context, height *uint64) (*ctypes.ResultConsensusParams, error) { return core.ConsensusParams(&rpctypes.Context{}, height) } @@ -150,7 +150,7 @@ func (c Client) DialPeers( return core.UnsafeDialPeers(&rpctypes.Context{}, peers, persistent, unconditional, private) } -func (c Client) BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) { +func (c Client) BlockchainInfo(ctx context.Context, minHeight, maxHeight uint64) (*ctypes.ResultBlockchainInfo, error) { return core.BlockchainInfo(&rpctypes.Context{}, minHeight, maxHeight) } @@ -158,7 +158,7 @@ func (c Client) Genesis(ctx context.Context) (*ctypes.ResultGenesis, error) { return core.Genesis(&rpctypes.Context{}) } -func (c Client) Block(ctx context.Context, height *int64) (*ctypes.ResultBlock, error) { +func (c Client) Block(ctx context.Context, height *uint64) (*ctypes.ResultBlock, error) { return core.Block(&rpctypes.Context{}, height) } @@ -166,11 +166,11 @@ func (c Client) BlockByHash(ctx context.Context, hash []byte) (*ctypes.ResultBlo return core.BlockByHash(&rpctypes.Context{}, hash) } -func (c Client) Commit(ctx context.Context, height *int64) (*ctypes.ResultCommit, error) { +func (c Client) Commit(ctx context.Context, height *uint64) (*ctypes.ResultCommit, error) { return core.Commit(&rpctypes.Context{}, height) } -func (c Client) Validators(ctx context.Context, height *int64, page, perPage *int) (*ctypes.ResultValidators, error) { +func (c Client) Validators(ctx context.Context, height *uint64, page, perPage *int) (*ctypes.ResultValidators, error) { return core.Validators(&rpctypes.Context{}, height, page, perPage) } diff --git a/rpc/client/mocks/client.go b/rpc/client/mocks/client.go index 6a9008717..2bb0219fb 100644 --- a/rpc/client/mocks/client.go +++ b/rpc/client/mocks/client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.3.0. DO NOT EDIT. +// Code generated by mockery v2.5.1. DO NOT EDIT. package mocks @@ -92,11 +92,11 @@ func (_m *Client) ABCIQueryWithOptions(ctx context.Context, path string, data by } // Block provides a mock function with given fields: ctx, height -func (_m *Client) Block(ctx context.Context, height *int64) (*coretypes.ResultBlock, error) { +func (_m *Client) Block(ctx context.Context, height *uint64) (*coretypes.ResultBlock, error) { ret := _m.Called(ctx, height) var r0 *coretypes.ResultBlock - if rf, ok := ret.Get(0).(func(context.Context, *int64) *coretypes.ResultBlock); ok { + if rf, ok := ret.Get(0).(func(context.Context, *uint64) *coretypes.ResultBlock); ok { r0 = rf(ctx, height) } else { if ret.Get(0) != nil { @@ -105,7 +105,7 @@ func (_m *Client) Block(ctx context.Context, height *int64) (*coretypes.ResultBl } var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *int64) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *uint64) error); ok { r1 = rf(ctx, height) } else { r1 = ret.Error(1) @@ -138,11 +138,11 @@ func (_m *Client) BlockByHash(ctx context.Context, hash []byte) (*coretypes.Resu } // BlockResults provides a mock function with given fields: ctx, height -func (_m *Client) BlockResults(ctx context.Context, height *int64) (*coretypes.ResultBlockResults, error) { +func (_m *Client) BlockResults(ctx context.Context, height *uint64) (*coretypes.ResultBlockResults, error) { ret := _m.Called(ctx, height) var r0 *coretypes.ResultBlockResults - if rf, ok := ret.Get(0).(func(context.Context, *int64) *coretypes.ResultBlockResults); ok { + if rf, ok := ret.Get(0).(func(context.Context, *uint64) *coretypes.ResultBlockResults); ok { r0 = rf(ctx, height) } else { if ret.Get(0) != nil { @@ -151,7 +151,7 @@ func (_m *Client) BlockResults(ctx context.Context, height *int64) (*coretypes.R } var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *int64) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *uint64) error); ok { r1 = rf(ctx, height) } else { r1 = ret.Error(1) @@ -161,11 +161,11 @@ func (_m *Client) BlockResults(ctx context.Context, height *int64) (*coretypes.R } // BlockchainInfo provides a mock function with given fields: ctx, minHeight, maxHeight -func (_m *Client) BlockchainInfo(ctx context.Context, minHeight int64, maxHeight int64) (*coretypes.ResultBlockchainInfo, error) { +func (_m *Client) BlockchainInfo(ctx context.Context, minHeight uint64, maxHeight uint64) (*coretypes.ResultBlockchainInfo, error) { ret := _m.Called(ctx, minHeight, maxHeight) var r0 *coretypes.ResultBlockchainInfo - if rf, ok := ret.Get(0).(func(context.Context, int64, int64) *coretypes.ResultBlockchainInfo); ok { + if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64) *coretypes.ResultBlockchainInfo); ok { r0 = rf(ctx, minHeight, maxHeight) } else { if ret.Get(0) != nil { @@ -174,7 +174,7 @@ func (_m *Client) BlockchainInfo(ctx context.Context, minHeight int64, maxHeight } var r1 error - if rf, ok := ret.Get(1).(func(context.Context, int64, int64) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, uint64, uint64) error); ok { r1 = rf(ctx, minHeight, maxHeight) } else { r1 = ret.Error(1) @@ -299,11 +299,11 @@ func (_m *Client) CheckTx(_a0 context.Context, _a1 types.Tx) (*coretypes.ResultC } // Commit provides a mock function with given fields: ctx, height -func (_m *Client) Commit(ctx context.Context, height *int64) (*coretypes.ResultCommit, error) { +func (_m *Client) Commit(ctx context.Context, height *uint64) (*coretypes.ResultCommit, error) { ret := _m.Called(ctx, height) var r0 *coretypes.ResultCommit - if rf, ok := ret.Get(0).(func(context.Context, *int64) *coretypes.ResultCommit); ok { + if rf, ok := ret.Get(0).(func(context.Context, *uint64) *coretypes.ResultCommit); ok { r0 = rf(ctx, height) } else { if ret.Get(0) != nil { @@ -312,7 +312,7 @@ func (_m *Client) Commit(ctx context.Context, height *int64) (*coretypes.ResultC } var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *int64) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *uint64) error); ok { r1 = rf(ctx, height) } else { r1 = ret.Error(1) @@ -322,11 +322,11 @@ func (_m *Client) Commit(ctx context.Context, height *int64) (*coretypes.ResultC } // ConsensusParams provides a mock function with given fields: ctx, height -func (_m *Client) ConsensusParams(ctx context.Context, height *int64) (*coretypes.ResultConsensusParams, error) { +func (_m *Client) ConsensusParams(ctx context.Context, height *uint64) (*coretypes.ResultConsensusParams, error) { ret := _m.Called(ctx, height) var r0 *coretypes.ResultConsensusParams - if rf, ok := ret.Get(0).(func(context.Context, *int64) *coretypes.ResultConsensusParams); ok { + if rf, ok := ret.Get(0).(func(context.Context, *uint64) *coretypes.ResultConsensusParams); ok { r0 = rf(ctx, height) } else { if ret.Get(0) != nil { @@ -335,7 +335,7 @@ func (_m *Client) ConsensusParams(ctx context.Context, height *int64) (*coretype } var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *int64) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *uint64) error); ok { r1 = rf(ctx, height) } else { r1 = ret.Error(1) @@ -757,11 +757,11 @@ func (_m *Client) UnsubscribeAll(ctx context.Context, subscriber string) error { } // Validators provides a mock function with given fields: ctx, height, page, perPage -func (_m *Client) Validators(ctx context.Context, height *int64, page *int, perPage *int) (*coretypes.ResultValidators, error) { +func (_m *Client) Validators(ctx context.Context, height *uint64, page *int, perPage *int) (*coretypes.ResultValidators, error) { ret := _m.Called(ctx, height, page, perPage) var r0 *coretypes.ResultValidators - if rf, ok := ret.Get(0).(func(context.Context, *int64, *int, *int) *coretypes.ResultValidators); ok { + if rf, ok := ret.Get(0).(func(context.Context, *uint64, *int, *int) *coretypes.ResultValidators); ok { r0 = rf(ctx, height, page, perPage) } else { if ret.Get(0) != nil { @@ -770,7 +770,7 @@ func (_m *Client) Validators(ctx context.Context, height *int64, page *int, perP } var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *int64, *int, *int) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *uint64, *int, *int) error); ok { r1 = rf(ctx, height, page, perPage) } else { r1 = ret.Error(1) diff --git a/statesync/stateprovider.go b/statesync/stateprovider.go index eb680902e..26c5d63fa 100644 --- a/statesync/stateprovider.go +++ b/statesync/stateprovider.go @@ -89,7 +89,7 @@ func (s *lightClientStateProvider) AppHash(ctx context.Context, height uint64) ( defer s.Unlock() // We have to fetch the next height, which contains the app hash for the previous height. - header, err := s.lc.VerifyLightBlockAtHeight(ctx, int64(height+1), time.Now()) + header, err := s.lc.VerifyLightBlockAtHeight(ctx, height+1, time.Now()) if err != nil { return nil, err } @@ -101,11 +101,11 @@ func (s *lightClientStateProvider) AppHash(ctx context.Context, height uint64) ( // breaking it. We should instead have a Has(ctx, height) method which checks // that the state provider has access to the necessary data for the height. // We piggyback on AppHash() since it's called when adding snapshots to the pool. - _, err = s.lc.VerifyLightBlockAtHeight(ctx, int64(height+2), time.Now()) + _, err = s.lc.VerifyLightBlockAtHeight(ctx, height+2, time.Now()) if err != nil { return nil, err } - _, err = s.lc.VerifyLightBlockAtHeight(ctx, int64(height), time.Now()) + _, err = s.lc.VerifyLightBlockAtHeight(ctx, height, time.Now()) if err != nil { return nil, err } @@ -116,7 +116,7 @@ func (s *lightClientStateProvider) AppHash(ctx context.Context, height uint64) ( func (s *lightClientStateProvider) Commit(ctx context.Context, height uint64) (*types.Commit, error) { s.Lock() defer s.Unlock() - header, err := s.lc.VerifyLightBlockAtHeight(ctx, int64(height), time.Now()) + header, err := s.lc.VerifyLightBlockAtHeight(ctx, height, time.Now()) if err != nil { return nil, err } @@ -145,15 +145,15 @@ func (s *lightClientStateProvider) State(ctx context.Context, height uint64) (sm // // We need to fetch the NextValidators from height+2 because if the application changed // the validator set at the snapshot height then this only takes effect at height+2. - lastLightBlock, err := s.lc.VerifyLightBlockAtHeight(ctx, int64(height), time.Now()) + lastLightBlock, err := s.lc.VerifyLightBlockAtHeight(ctx, height, time.Now()) if err != nil { return sm.State{}, err } - currentLightBlock, err := s.lc.VerifyLightBlockAtHeight(ctx, int64(height+1), time.Now()) + currentLightBlock, err := s.lc.VerifyLightBlockAtHeight(ctx, height+1, time.Now()) if err != nil { return sm.State{}, err } - nextLightBlock, err := s.lc.VerifyLightBlockAtHeight(ctx, int64(height+2), time.Now()) + nextLightBlock, err := s.lc.VerifyLightBlockAtHeight(ctx, height+2, time.Now()) if err != nil { return sm.State{}, err } diff --git a/types/events.go b/types/events.go index 37a559451..43b83a9b1 100644 --- a/types/events.go +++ b/types/events.go @@ -89,7 +89,7 @@ type EventDataTx struct { // NOTE: This goes into the replay WAL type EventDataRoundState struct { - Height int64 `json:"height"` + Height uint64 `json:"height"` Round int32 `json:"round"` Step string `json:"step"` } @@ -100,7 +100,7 @@ type ValidatorInfo struct { } type EventDataNewRound struct { - Height int64 `json:"height"` + Height uint64 `json:"height"` Round int32 `json:"round"` Step string `json:"step"` @@ -108,7 +108,7 @@ type EventDataNewRound struct { } type EventDataCompleteProposal struct { - Height int64 `json:"height"` + Height uint64 `json:"height"` Round int32 `json:"round"` Step string `json:"step"` diff --git a/types/vote_set.go b/types/vote_set.go index b27b6f9b4..4ed89dff6 100644 --- a/types/vote_set.go +++ b/types/vote_set.go @@ -645,7 +645,7 @@ func (vs *blockVotes) getByIndex(index int32) *Vote { // Common interface between *consensus.VoteSet and types.Commit type VoteSetReader interface { - GetHeight() int64 + GetHeight() uint64 GetRound() int32 Type() byte Size() int