mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-31 13:16:59 +00:00
e2e & maverick
This commit is contained in:
@@ -249,9 +249,9 @@ func (pool *BlockPool) AddBlock(peerID p2p.NodeID, block *types.Block, blockSize
|
||||
pool.Logger.Error("peer sent us a block we didn't expect",
|
||||
"peer", peerID, "curHeight", pool.height, "blockHeight", block.Height)
|
||||
diff := pool.height - block.Height
|
||||
if diff < 0 {
|
||||
// diff *= -1 //todo: what?
|
||||
}
|
||||
// if diff < 0 {
|
||||
// diff *= -1 //todo: what?
|
||||
// }
|
||||
if diff > maxDiffBetweenCurrentAndReceivedBlockHeight {
|
||||
pool.sendError(errors.New("peer sent us a block we didn't expect with a height too far ahead/behind"), peerID)
|
||||
}
|
||||
|
||||
@@ -78,7 +78,11 @@ func (mpc *mockPContext) applyBlock(blockID types.BlockID, block *types.Block) e
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mpc *mockPContext) verifyCommit(chainID string, blockID types.BlockID, height uint64, commit *types.Commit) error {
|
||||
func (mpc *mockPContext) verifyCommit(
|
||||
chainID string,
|
||||
blockID types.BlockID,
|
||||
height uint64,
|
||||
commit *types.Commit) error {
|
||||
for _, h := range mpc.verificationBL {
|
||||
if uint64(h) == height {
|
||||
return fmt.Errorf("generic verification error")
|
||||
|
||||
@@ -984,9 +984,6 @@ func (cfg *ConsensusConfig) ValidateBasic() error {
|
||||
if cfg.PeerQueryMaj23SleepDuration < 0 {
|
||||
return errors.New("peer-query-maj23-sleep-duration can't be negative")
|
||||
}
|
||||
if cfg.DoubleSignCheckHeight < 0 {
|
||||
return errors.New("double-sign-check-height can't be negative")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -480,7 +480,12 @@ func ensureNoNewTimeout(stepCh <-chan tmpubsub.Message, timeout int64) {
|
||||
"We should be stuck waiting, not receiving NewTimeout event")
|
||||
}
|
||||
|
||||
func ensureNewEvent(ch <-chan tmpubsub.Message, height uint64, round int32, timeout time.Duration, errorMessage string) {
|
||||
func ensureNewEvent(
|
||||
ch <-chan tmpubsub.Message,
|
||||
height uint64,
|
||||
round int32,
|
||||
timeout time.Duration,
|
||||
errorMessage string) {
|
||||
select {
|
||||
case <-time.After(timeout):
|
||||
panic(errorMessage)
|
||||
|
||||
@@ -1443,9 +1443,6 @@ type NewRoundStepMessage struct {
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
func (m *NewRoundStepMessage) ValidateBasic() error {
|
||||
if m.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if m.Round < 0 {
|
||||
return errors.New("negative Round")
|
||||
}
|
||||
@@ -1503,9 +1500,6 @@ type NewValidBlockMessage struct {
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
func (m *NewValidBlockMessage) ValidateBasic() error {
|
||||
if m.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if m.Round < 0 {
|
||||
return errors.New("negative Round")
|
||||
}
|
||||
@@ -1560,9 +1554,6 @@ type ProposalPOLMessage struct {
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
func (m *ProposalPOLMessage) ValidateBasic() error {
|
||||
if m.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if m.ProposalPOLRound < 0 {
|
||||
return errors.New("negative ProposalPOLRound")
|
||||
}
|
||||
@@ -1591,9 +1582,6 @@ type BlockPartMessage struct {
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
func (m *BlockPartMessage) ValidateBasic() error {
|
||||
if m.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if m.Round < 0 {
|
||||
return errors.New("negative Round")
|
||||
}
|
||||
@@ -1637,9 +1625,6 @@ type HasVoteMessage struct {
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
func (m *HasVoteMessage) ValidateBasic() error {
|
||||
if m.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if m.Round < 0 {
|
||||
return errors.New("negative Round")
|
||||
}
|
||||
@@ -1669,9 +1654,6 @@ type VoteSetMaj23Message struct {
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
func (m *VoteSetMaj23Message) ValidateBasic() error {
|
||||
if m.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if m.Round < 0 {
|
||||
return errors.New("negative Round")
|
||||
}
|
||||
@@ -1702,9 +1684,6 @@ type VoteSetBitsMessage struct {
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
func (m *VoteSetBitsMessage) ValidateBasic() error {
|
||||
if m.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if !types.IsVoteTypeValid(m.Type) {
|
||||
return errors.New("invalid Type")
|
||||
}
|
||||
|
||||
+1
-3
@@ -248,9 +248,7 @@ func (h *Handshaker) Handshake(proxyApp proxy.AppConns) error {
|
||||
}
|
||||
|
||||
blockHeight := res.LastBlockHeight
|
||||
if blockHeight < 0 {
|
||||
return fmt.Errorf("got a negative last block height (%d) from the app", blockHeight)
|
||||
}
|
||||
|
||||
appHash := res.LastBlockAppHash
|
||||
|
||||
h.logger.Info("ABCI Handshake App Info",
|
||||
|
||||
+4
-3
@@ -394,8 +394,6 @@ func (c *Client) compareWithLatestHeight(height uint64) (uint64, error) {
|
||||
return 0, fmt.Errorf("unverified header/valset requested (latest: %d)", latestHeight)
|
||||
case height == 0:
|
||||
return latestHeight, nil
|
||||
case height < 0:
|
||||
return 0, errors.New("negative height")
|
||||
}
|
||||
|
||||
return height, nil
|
||||
@@ -442,7 +440,10 @@ func (c *Client) Update(ctx context.Context, now time.Time) (*types.LightBlock,
|
||||
// primary.
|
||||
//
|
||||
// It will replace the primary provider if an error from a request to the provider occurs
|
||||
func (c *Client) VerifyLightBlockAtHeight(ctx context.Context, height uint64, now time.Time) (*types.LightBlock, error) {
|
||||
func (c *Client) VerifyLightBlockAtHeight(
|
||||
ctx context.Context,
|
||||
height uint64,
|
||||
now time.Time) (*types.LightBlock, error) {
|
||||
if height <= 0 {
|
||||
return nil, errors.New("negative or zero height")
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ func TestLightClientAttackEvidence_Lunatic(t *testing.T) {
|
||||
|
||||
witnessHeaders, witnessValidators, chainKeys := genMockNodeWithKeys(chainID, int64(latestHeight), valSize, 2, bTime)
|
||||
witness := mockp.New(chainID, witnessHeaders, witnessValidators)
|
||||
forgedKeys := chainKeys[int64(divergenceHeight)-1].ChangeKeys(3) // we change 3 out of the 5 validators (still 2/5 remain)
|
||||
// we change 3 out of the 5 validators (still 2/5 remain)
|
||||
forgedKeys := chainKeys[int64(divergenceHeight)-1].ChangeKeys(3)
|
||||
forgedVals := forgedKeys.ToValidators(2, 0)
|
||||
|
||||
for height := uint64(1); height <= latestHeight; height++ {
|
||||
@@ -38,7 +39,9 @@ func TestLightClientAttackEvidence_Lunatic(t *testing.T) {
|
||||
primaryValidators[int64(height)] = witnessValidators[int64(height)]
|
||||
continue
|
||||
}
|
||||
primaryHeaders[int64(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[int64(height)] = forgedVals
|
||||
}
|
||||
|
||||
@@ -170,9 +170,6 @@ func (p *http) signedHeader(ctx context.Context, height *uint64) (*types.SignedH
|
||||
}
|
||||
|
||||
func validateHeight(height uint64) (*uint64, error) {
|
||||
if height < 0 {
|
||||
return nil, fmt.Errorf("expected height >= 0, got height %d", height)
|
||||
}
|
||||
|
||||
h := &height
|
||||
if height == 0 {
|
||||
|
||||
@@ -75,7 +75,10 @@ func makeNetInfoFunc(c *lrpc.Client) rpcNetInfoFunc {
|
||||
}
|
||||
}
|
||||
|
||||
type rpcBlockchainInfoFunc func(ctx *rpctypes.Context, minHeight, maxHeight uint64) (*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 uint64) (*ctypes.ResultBlockchainInfo, error) {
|
||||
|
||||
+4
-1
@@ -236,7 +236,10 @@ func (c *Client) Health(ctx context.Context) (*ctypes.ResultHealth, error) {
|
||||
|
||||
// BlockchainInfo calls rpcclient#BlockchainInfo and then verifies every header
|
||||
// returned.
|
||||
func (c *Client) BlockchainInfo(ctx context.Context, minHeight, maxHeight uint64) (*ctypes.ResultBlockchainInfo, error) {
|
||||
func (c *Client) BlockchainInfo(
|
||||
ctx context.Context,
|
||||
minHeight,
|
||||
maxHeight uint64) (*ctypes.ResultBlockchainInfo, error) {
|
||||
res, err := c.next.BlockchainInfo(ctx, minHeight, maxHeight)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -69,26 +69,12 @@ func (m *Message) Validate() error {
|
||||
|
||||
switch msg := m.Sum.(type) {
|
||||
case *Message_BlockRequest:
|
||||
if m.GetBlockRequest().Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
|
||||
case *Message_BlockResponse:
|
||||
// validate basic is called later when converting from proto
|
||||
return nil
|
||||
|
||||
case *Message_NoBlockResponse:
|
||||
if m.GetNoBlockResponse().Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
|
||||
case *Message_StatusResponse:
|
||||
if m.GetStatusResponse().Base < 0 {
|
||||
return errors.New("negative Base")
|
||||
}
|
||||
if m.GetStatusResponse().Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if m.GetStatusResponse().Base > m.GetStatusResponse().Height {
|
||||
return fmt.Errorf(
|
||||
"base %v cannot be greater than height %v",
|
||||
|
||||
@@ -51,10 +51,6 @@ func BlockchainInfo(ctx *rpctypes.Context, minHeight, maxHeight uint64) (*ctypes
|
||||
// if 0, use blockstore base for min, latest block height for max
|
||||
// enforce limit.
|
||||
func filterMinMax(base, height, min, max, limit uint64) (uint64, uint64, error) {
|
||||
// filter negatives
|
||||
if min < 0 || max < 0 {
|
||||
return min, max, fmt.Errorf("heights must be non-negative")
|
||||
}
|
||||
|
||||
// adjust for default values
|
||||
if min == 0 {
|
||||
|
||||
+1
-1
@@ -458,7 +458,7 @@ func (s *syncer) verifyApp(snapshot *snapshot) (uint64, error) {
|
||||
return 0, errVerifyFailed
|
||||
}
|
||||
|
||||
if uint64(resp.LastBlockHeight) != snapshot.Height {
|
||||
if resp.LastBlockHeight != snapshot.Height {
|
||||
s.logger.Error(
|
||||
"ABCI app reported unexpected last block height",
|
||||
"expected", snapshot.Height,
|
||||
|
||||
+6
-6
@@ -50,7 +50,7 @@ func (app *Application) Info(req abci.RequestInfo) abci.ResponseInfo {
|
||||
return abci.ResponseInfo{
|
||||
Version: version.ABCIVersion,
|
||||
AppVersion: 1,
|
||||
LastBlockHeight: int64(app.state.Height),
|
||||
LastBlockHeight: app.state.Height,
|
||||
LastBlockAppHash: app.state.Hash,
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (app *Application) Info(req abci.RequestInfo) abci.ResponseInfo {
|
||||
// Info implements ABCI.
|
||||
func (app *Application) InitChain(req abci.RequestInitChain) abci.ResponseInitChain {
|
||||
var err error
|
||||
app.state.initialHeight = uint64(req.InitialHeight)
|
||||
app.state.initialHeight = req.InitialHeight
|
||||
if len(req.AppStateBytes) > 0 {
|
||||
err = app.state.Import(0, req.AppStateBytes)
|
||||
if err != nil {
|
||||
@@ -100,7 +100,7 @@ func (app *Application) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDelive
|
||||
func (app *Application) EndBlock(req abci.RequestEndBlock) abci.ResponseEndBlock {
|
||||
var err error
|
||||
resp := abci.ResponseEndBlock{}
|
||||
if resp.ValidatorUpdates, err = app.validatorUpdates(uint64(req.Height)); err != nil {
|
||||
if resp.ValidatorUpdates, err = app.validatorUpdates(req.Height); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return resp
|
||||
@@ -119,9 +119,9 @@ func (app *Application) Commit() abci.ResponseCommit {
|
||||
}
|
||||
logger.Info("Created state sync snapshot", "height", snapshot.Height)
|
||||
}
|
||||
retainHeight := int64(0)
|
||||
retainHeight := uint64(0)
|
||||
if app.cfg.RetainBlocks > 0 {
|
||||
retainHeight = int64(height - app.cfg.RetainBlocks + 1)
|
||||
retainHeight = height - app.cfg.RetainBlocks + 1
|
||||
}
|
||||
return abci.ResponseCommit{
|
||||
Data: hash,
|
||||
@@ -132,7 +132,7 @@ func (app *Application) Commit() abci.ResponseCommit {
|
||||
// Query implements ABCI.
|
||||
func (app *Application) Query(req abci.RequestQuery) abci.ResponseQuery {
|
||||
return abci.ResponseQuery{
|
||||
Height: int64(app.state.Height),
|
||||
Height: app.state.Height,
|
||||
Key: req.Data,
|
||||
Value: []byte(app.state.Get(string(req.Data))),
|
||||
}
|
||||
|
||||
@@ -152,9 +152,9 @@ func startMaverick(cfg *Config) error {
|
||||
return fmt.Errorf("failed to setup config: %w", err)
|
||||
}
|
||||
|
||||
misbehaviors := make(map[int64]mcs.Misbehavior, len(cfg.Misbehaviors))
|
||||
misbehaviors := make(map[uint64]mcs.Misbehavior, len(cfg.Misbehaviors))
|
||||
for heightString, misbehaviorString := range cfg.Misbehaviors {
|
||||
height, _ := strconv.ParseInt(heightString, 10, 64)
|
||||
height, _ := strconv.ParseUint(heightString, 10, 64)
|
||||
misbehaviors[height] = mcs.MisbehaviorList[misbehaviorString]
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ func Generate(r *rand.Rand) ([]e2e.Manifest, error) {
|
||||
func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, error) {
|
||||
manifest := e2e.Manifest{
|
||||
IPv6: opt["ipv6"].(bool),
|
||||
InitialHeight: int64(opt["initialHeight"].(int)),
|
||||
InitialHeight: uint64(opt["initialHeight"].(int)),
|
||||
InitialState: opt["initialState"].(map[string]string),
|
||||
Validators: &map[string]int64{},
|
||||
ValidatorUpdates: map[string]map[string]int64{},
|
||||
@@ -104,7 +104,7 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er
|
||||
nextStartAt := manifest.InitialHeight + 5
|
||||
quorum := numValidators*2/3 + 1
|
||||
for i := 1; i <= numValidators; i++ {
|
||||
startAt := int64(0)
|
||||
startAt := uint64(0)
|
||||
if i > quorum {
|
||||
startAt = nextStartAt
|
||||
nextStartAt += 5
|
||||
@@ -134,7 +134,7 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er
|
||||
|
||||
// Finally, we generate random full nodes.
|
||||
for i := 1; i <= numFulls; i++ {
|
||||
startAt := int64(0)
|
||||
startAt := uint64(0)
|
||||
if r.Float64() >= 0.5 {
|
||||
startAt = nextStartAt
|
||||
nextStartAt += 5
|
||||
@@ -190,7 +190,7 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er
|
||||
// here, since we need to know the overall network topology and startup
|
||||
// sequencing.
|
||||
func generateNode(
|
||||
r *rand.Rand, mode e2e.Mode, startAt int64, initialHeight int64, forceArchive bool,
|
||||
r *rand.Rand, mode e2e.Mode, startAt, initialHeight uint64, forceArchive bool,
|
||||
) *e2e.ManifestNode {
|
||||
node := e2e.ManifestNode{
|
||||
Mode: string(mode),
|
||||
@@ -214,7 +214,7 @@ func generateNode(
|
||||
}
|
||||
|
||||
if node.Mode == "validator" {
|
||||
misbehaveAt := startAt + 5 + int64(r.Intn(10))
|
||||
misbehaveAt := startAt + 5 + uint64(r.Intn(10))
|
||||
if startAt == 0 {
|
||||
misbehaveAt += initialHeight - 1
|
||||
}
|
||||
@@ -256,7 +256,7 @@ type misbehaviorOption struct {
|
||||
misbehavior string
|
||||
}
|
||||
|
||||
func (m misbehaviorOption) atHeight(height int64) map[string]string {
|
||||
func (m misbehaviorOption) atHeight(height uint64) map[string]string {
|
||||
misbehaviorMap := make(map[string]string)
|
||||
if m.misbehavior == "" {
|
||||
return misbehaviorMap
|
||||
|
||||
@@ -13,7 +13,7 @@ type Manifest struct {
|
||||
IPv6 bool `toml:"ipv6"`
|
||||
|
||||
// InitialHeight specifies the initial block height, set in genesis. Defaults to 1.
|
||||
InitialHeight int64 `toml:"initial_height"`
|
||||
InitialHeight uint64 `toml:"initial_height"`
|
||||
|
||||
// InitialState is an initial set of key/value pairs for the application,
|
||||
// set in genesis. Defaults to nothing.
|
||||
@@ -90,7 +90,7 @@ type ManifestNode struct {
|
||||
|
||||
// StartAt specifies the block height at which the node will be started. The
|
||||
// runner will wait for the network to reach at least this block height.
|
||||
StartAt int64 `toml:"start_at"`
|
||||
StartAt uint64 `toml:"start_at"`
|
||||
|
||||
// FastSync specifies the fast sync mode: "" (disable), "v0" or "v2".
|
||||
// Defaults to disabled.
|
||||
|
||||
+10
-10
@@ -54,10 +54,10 @@ type Testnet struct {
|
||||
File string
|
||||
Dir string
|
||||
IP *net.IPNet
|
||||
InitialHeight int64
|
||||
InitialHeight uint64
|
||||
InitialState map[string]string
|
||||
Validators map[*Node]int64
|
||||
ValidatorUpdates map[int64]map[*Node]int64
|
||||
ValidatorUpdates map[uint64]map[*Node]int64
|
||||
Nodes []*Node
|
||||
KeyType string
|
||||
LogLevel string
|
||||
@@ -72,7 +72,7 @@ type Node struct {
|
||||
NodeKey crypto.PrivKey
|
||||
IP net.IP
|
||||
ProxyPort uint32
|
||||
StartAt int64
|
||||
StartAt uint64
|
||||
FastSync string
|
||||
StateSync bool
|
||||
Database string
|
||||
@@ -84,7 +84,7 @@ type Node struct {
|
||||
Seeds []*Node
|
||||
PersistentPeers []*Node
|
||||
Perturbations []Perturbation
|
||||
Misbehaviors map[int64]string
|
||||
Misbehaviors map[uint64]string
|
||||
LogLevel string
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ func LoadTestnet(file string) (*Testnet, error) {
|
||||
InitialHeight: 1,
|
||||
InitialState: manifest.InitialState,
|
||||
Validators: map[*Node]int64{},
|
||||
ValidatorUpdates: map[int64]map[*Node]int64{},
|
||||
ValidatorUpdates: map[uint64]map[*Node]int64{},
|
||||
Nodes: []*Node{},
|
||||
KeyType: "ed25519",
|
||||
LogLevel: manifest.LogLevel,
|
||||
@@ -161,7 +161,7 @@ func LoadTestnet(file string) (*Testnet, error) {
|
||||
SnapshotInterval: nodeManifest.SnapshotInterval,
|
||||
RetainBlocks: nodeManifest.RetainBlocks,
|
||||
Perturbations: []Perturbation{},
|
||||
Misbehaviors: make(map[int64]string),
|
||||
Misbehaviors: make(map[uint64]string),
|
||||
LogLevel: manifest.LogLevel,
|
||||
}
|
||||
if node.StartAt == testnet.InitialHeight {
|
||||
@@ -186,7 +186,7 @@ func LoadTestnet(file string) (*Testnet, error) {
|
||||
node.Perturbations = append(node.Perturbations, Perturbation(p))
|
||||
}
|
||||
for heightString, misbehavior := range nodeManifest.Misbehaviors {
|
||||
height, err := strconv.ParseInt(heightString, 10, 64)
|
||||
height, err := strconv.ParseUint(heightString, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to parse height %s to int64: %w", heightString, err)
|
||||
}
|
||||
@@ -262,7 +262,7 @@ func LoadTestnet(file string) (*Testnet, error) {
|
||||
}
|
||||
valUpdate[node] = power
|
||||
}
|
||||
testnet.ValidatorUpdates[int64(height)] = valUpdate
|
||||
testnet.ValidatorUpdates[uint64(height)] = valUpdate
|
||||
}
|
||||
|
||||
return testnet, testnet.Validate()
|
||||
@@ -435,8 +435,8 @@ func (t Testnet) HasPerturbations() bool {
|
||||
}
|
||||
|
||||
// LastMisbehaviorHeight returns the height of the last misbehavior.
|
||||
func (t Testnet) LastMisbehaviorHeight() int64 {
|
||||
lastHeight := int64(0)
|
||||
func (t Testnet) LastMisbehaviorHeight() uint64 {
|
||||
lastHeight := uint64(0)
|
||||
for _, node := range t.Nodes {
|
||||
for height := range node.Misbehaviors {
|
||||
if height > lastHeight {
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
// waitForHeight waits for the network to reach a certain height (or above),
|
||||
// returning the highest height seen. Errors if the network is not making
|
||||
// progress at all.
|
||||
func waitForHeight(testnet *e2e.Testnet, height int64) (*types.Block, *types.BlockID, error) {
|
||||
func waitForHeight(testnet *e2e.Testnet, height uint64) (*types.Block, *types.BlockID, error) {
|
||||
var (
|
||||
err error
|
||||
maxResult *rpctypes.ResultBlock
|
||||
@@ -66,7 +66,7 @@ func waitForHeight(testnet *e2e.Testnet, height int64) (*types.Block, *types.Blo
|
||||
}
|
||||
|
||||
// waitForNode waits for a node to become available and catch up to the given block height.
|
||||
func waitForNode(node *e2e.Node, height int64, timeout time.Duration) (*rpctypes.ResultStatus, error) {
|
||||
func waitForNode(node *e2e.Node, height uint64, timeout time.Duration) (*rpctypes.ResultStatus, error) {
|
||||
client, err := node.Client()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -89,8 +89,8 @@ func waitForNode(node *e2e.Node, height int64, timeout time.Duration) (*rpctypes
|
||||
}
|
||||
|
||||
// waitForAllNodes waits for all nodes to become available and catch up to the given block height.
|
||||
func waitForAllNodes(testnet *e2e.Testnet, height int64, timeout time.Duration) (int64, error) {
|
||||
lastHeight := int64(0)
|
||||
func waitForAllNodes(testnet *e2e.Testnet, height uint64, timeout time.Duration) (uint64, error) {
|
||||
lastHeight := uint64(0)
|
||||
for _, node := range testnet.Nodes {
|
||||
if node.Mode == e2e.ModeSeed {
|
||||
continue
|
||||
|
||||
@@ -404,7 +404,7 @@ func MakeAppConfig(node *e2e.Node) ([]byte, error) {
|
||||
}
|
||||
|
||||
// UpdateConfigStateSync updates the state sync config for a node.
|
||||
func UpdateConfigStateSync(node *e2e.Node, height int64, hash []byte) error {
|
||||
func UpdateConfigStateSync(node *e2e.Node, height uint64, hash []byte) error {
|
||||
cfgPath := filepath.Join(node.Testnet.Dir, node.Name, "config", "config.toml")
|
||||
|
||||
// FIXME Apparently there's no function to simply load a config file without
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Wait waits for a number of blocks to be produced, and for all nodes to catch
|
||||
// up with it.
|
||||
func Wait(testnet *e2e.Testnet, blocks int64) error {
|
||||
func Wait(testnet *e2e.Testnet, blocks uint64) error {
|
||||
block, _, err := waitForHeight(testnet, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -18,7 +18,7 @@ func Wait(testnet *e2e.Testnet, blocks int64) error {
|
||||
}
|
||||
|
||||
// WaitUntil waits until a given height has been reached.
|
||||
func WaitUntil(testnet *e2e.Testnet, height int64) error {
|
||||
func WaitUntil(testnet *e2e.Testnet, height uint64) error {
|
||||
logger.Info(fmt.Sprintf("Waiting for all nodes to reach height %v...", height))
|
||||
_, err := waitForAllNodes(testnet, height, 20*time.Second)
|
||||
if err != nil {
|
||||
|
||||
@@ -63,7 +63,7 @@ func TestBlock_Range(t *testing.T) {
|
||||
assert.Greater(t, first, node.Testnet.InitialHeight,
|
||||
"state synced nodes should not contain network's initial height")
|
||||
|
||||
case node.RetainBlocks > 0 && int64(node.RetainBlocks) < (last-node.Testnet.InitialHeight+1):
|
||||
case node.RetainBlocks > 0 && node.RetainBlocks < (last-node.Testnet.InitialHeight+1):
|
||||
// Delta handles race conditions in reading first/last heights.
|
||||
assert.InDelta(t, node.RetainBlocks, last-first+1, 1,
|
||||
"node not pruning expected blocks")
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestEvidence_Misbehavior(t *testing.T) {
|
||||
blocks := fetchBlockChain(t)
|
||||
testNode(t, func(t *testing.T, node e2e.Node) {
|
||||
seenEvidence := make(map[int64]struct{})
|
||||
seenEvidence := make(map[uint64]struct{})
|
||||
for _, block := range blocks {
|
||||
// Find any evidence blaming this node in this block
|
||||
var nodeEvidence types.Evidence
|
||||
|
||||
@@ -127,8 +127,8 @@ func TestValidator_Sign(t *testing.T) {
|
||||
// validator set updates.
|
||||
type validatorSchedule struct {
|
||||
Set *types.ValidatorSet
|
||||
height int64
|
||||
updates map[int64]map[*e2e.Node]int64
|
||||
height uint64
|
||||
updates map[uint64]map[*e2e.Node]int64
|
||||
}
|
||||
|
||||
func newValidatorSchedule(testnet e2e.Testnet) *validatorSchedule {
|
||||
@@ -143,8 +143,8 @@ func newValidatorSchedule(testnet e2e.Testnet) *validatorSchedule {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *validatorSchedule) Increment(heights int64) {
|
||||
for i := int64(0); i < heights; i++ {
|
||||
func (s *validatorSchedule) Increment(heights uint64) {
|
||||
for i := uint64(0); i < heights; i++ {
|
||||
s.height++
|
||||
if s.height > 2 {
|
||||
// validator set updates are offset by 2, since they only take effect
|
||||
|
||||
@@ -16,11 +16,11 @@ var MisbehaviorList = map[string]Misbehavior{
|
||||
type Misbehavior struct {
|
||||
Name string
|
||||
|
||||
EnterPropose func(cs *State, height int64, round int32)
|
||||
EnterPropose func(cs *State, height uint64, round int32)
|
||||
|
||||
EnterPrevote func(cs *State, height int64, round int32)
|
||||
EnterPrevote func(cs *State, height uint64, round int32)
|
||||
|
||||
EnterPrecommit func(cs *State, height int64, round int32)
|
||||
EnterPrecommit func(cs *State, height uint64, round int32)
|
||||
|
||||
ReceivePrevote func(cs *State, prevote *types.Vote)
|
||||
|
||||
@@ -48,7 +48,7 @@ func DefaultMisbehavior() Misbehavior {
|
||||
func DoublePrevoteMisbehavior() Misbehavior {
|
||||
b := DefaultMisbehavior()
|
||||
b.Name = "double-prevote"
|
||||
b.EnterPrevote = func(cs *State, height int64, round int32) {
|
||||
b.EnterPrevote = func(cs *State, height uint64, round int32) {
|
||||
|
||||
// If a block is locked, prevote that.
|
||||
if cs.LockedBlock != nil {
|
||||
@@ -107,7 +107,7 @@ func DoublePrevoteMisbehavior() Misbehavior {
|
||||
|
||||
// DEFAULTS
|
||||
|
||||
func defaultEnterPropose(cs *State, height int64, round int32) {
|
||||
func defaultEnterPropose(cs *State, height uint64, round int32) {
|
||||
logger := cs.Logger.With("height", height, "round", round)
|
||||
// If we don't get the proposal and all block parts quick enough, enterPrevote
|
||||
cs.scheduleTimeout(cs.config.Propose(round), height, round, cstypes.RoundStepPropose)
|
||||
@@ -148,7 +148,7 @@ func defaultEnterPropose(cs *State, height int64, round int32) {
|
||||
}
|
||||
}
|
||||
|
||||
func defaultEnterPrevote(cs *State, height int64, round int32) {
|
||||
func defaultEnterPrevote(cs *State, height uint64, round int32) {
|
||||
logger := cs.Logger.With("height", height, "round", round)
|
||||
|
||||
// If a block is locked, prevote that.
|
||||
@@ -181,7 +181,7 @@ func defaultEnterPrevote(cs *State, height int64, round int32) {
|
||||
cs.signAddVote(tmproto.PrevoteType, cs.ProposalBlock.Hash(), cs.ProposalBlockParts.Header())
|
||||
}
|
||||
|
||||
func defaultEnterPrecommit(cs *State, height int64, round int32) {
|
||||
func defaultEnterPrecommit(cs *State, height uint64, round int32) {
|
||||
logger := cs.Logger.With("height", height, "round", round)
|
||||
|
||||
// check for a polka
|
||||
|
||||
@@ -292,7 +292,11 @@ func (conR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {
|
||||
panic("Bad VoteSetBitsMessage field Type. Forgot to add a check in ValidateBasic?")
|
||||
}
|
||||
src.TrySend(VoteSetBitsChannel, MustEncode(&VoteSetBitsMessage{
|
||||
x
|
||||
Height: msg.Height,
|
||||
Round: msg.Round,
|
||||
Type: msg.Type,
|
||||
BlockID: msg.BlockID,
|
||||
Votes: ourVotes,
|
||||
}))
|
||||
default:
|
||||
conR.Logger.Error(fmt.Sprintf("Unknown message type %v", reflect.TypeOf(msg)))
|
||||
@@ -1027,7 +1031,7 @@ func (ps *PeerState) InitProposalBlockParts(partSetHeader types.PartSetHeader) {
|
||||
}
|
||||
|
||||
// SetHasProposalBlockPart sets the given block part index as known for the peer.
|
||||
func (ps *PeerState) SetHasProposalBlockPart(height int64, round int32, index int) {
|
||||
func (ps *PeerState) SetHasProposalBlockPart(height uint64, round int32, index int) {
|
||||
ps.mtx.Lock()
|
||||
defer ps.mtx.Unlock()
|
||||
|
||||
@@ -1083,7 +1087,7 @@ func (ps *PeerState) PickVoteToSend(votes types.VoteSetReader) (vote *types.Vote
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (ps *PeerState) getVoteBitArray(height int64, round int32, votesType tmproto.SignedMsgType) *bits.BitArray {
|
||||
func (ps *PeerState) getVoteBitArray(height uint64, round int32, votesType tmproto.SignedMsgType) *bits.BitArray {
|
||||
if !types.IsVoteTypeValid(votesType) {
|
||||
return nil
|
||||
}
|
||||
@@ -1130,7 +1134,7 @@ func (ps *PeerState) getVoteBitArray(height int64, round int32, votesType tmprot
|
||||
}
|
||||
|
||||
// 'round': A round for which we have a +2/3 commit.
|
||||
func (ps *PeerState) ensureCatchupCommitRound(height int64, round int32, numValidators int) {
|
||||
func (ps *PeerState) ensureCatchupCommitRound(height uint64, round int32, numValidators int) {
|
||||
if ps.PRS.Height != height {
|
||||
return
|
||||
}
|
||||
@@ -1162,13 +1166,13 @@ func (ps *PeerState) ensureCatchupCommitRound(height int64, round int32, numVali
|
||||
// what votes this peer has received.
|
||||
// NOTE: It's important to make sure that numValidators actually matches
|
||||
// what the node sees as the number of validators for height.
|
||||
func (ps *PeerState) EnsureVoteBitArrays(height int64, numValidators int) {
|
||||
func (ps *PeerState) EnsureVoteBitArrays(height uint64, numValidators int) {
|
||||
ps.mtx.Lock()
|
||||
defer ps.mtx.Unlock()
|
||||
ps.ensureVoteBitArrays(height, numValidators)
|
||||
}
|
||||
|
||||
func (ps *PeerState) ensureVoteBitArrays(height int64, numValidators int) {
|
||||
func (ps *PeerState) ensureVoteBitArrays(height uint64, numValidators int) {
|
||||
if ps.PRS.Height == height {
|
||||
if ps.PRS.Prevotes == nil {
|
||||
ps.PRS.Prevotes = bits.NewBitArray(numValidators)
|
||||
@@ -1235,7 +1239,7 @@ func (ps *PeerState) SetHasVote(vote *types.Vote) {
|
||||
ps.setHasVote(vote.Height, vote.Round, vote.Type, vote.ValidatorIndex)
|
||||
}
|
||||
|
||||
func (ps *PeerState) setHasVote(height int64, round int32, voteType tmproto.SignedMsgType, index int32) {
|
||||
func (ps *PeerState) setHasVote(height uint64, round int32, voteType tmproto.SignedMsgType, index int32) {
|
||||
logger := ps.logger.With(
|
||||
"peerH/R",
|
||||
fmt.Sprintf("%d/%d", ps.PRS.Height, ps.PRS.Round),
|
||||
@@ -1424,7 +1428,7 @@ func decodeMsg(bz []byte) (msg Message, err error) {
|
||||
// NewRoundStepMessage is sent for every step taken in the ConsensusState.
|
||||
// For every height/round/step transition
|
||||
type NewRoundStepMessage struct {
|
||||
Height int64
|
||||
Height uint64
|
||||
Round int32
|
||||
Step cstypes.RoundStepType
|
||||
SecondsSinceStartTime int64
|
||||
@@ -1433,9 +1437,6 @@ type NewRoundStepMessage struct {
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
func (m *NewRoundStepMessage) ValidateBasic() error {
|
||||
if m.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if m.Round < 0 {
|
||||
return errors.New("negative Round")
|
||||
}
|
||||
@@ -1456,7 +1457,7 @@ func (m *NewRoundStepMessage) ValidateBasic() error {
|
||||
}
|
||||
|
||||
// ValidateHeight validates the height given the chain's initial height.
|
||||
func (m *NewRoundStepMessage) ValidateHeight(initialHeight int64) error {
|
||||
func (m *NewRoundStepMessage) ValidateHeight(initialHeight uint64) error {
|
||||
if m.Height < initialHeight {
|
||||
return fmt.Errorf("invalid Height %v (lower than initial height %v)",
|
||||
m.Height, initialHeight)
|
||||
@@ -1484,7 +1485,7 @@ func (m *NewRoundStepMessage) String() string {
|
||||
// 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 NewValidBlockMessage struct {
|
||||
Height int64
|
||||
Height uint64
|
||||
Round int32
|
||||
BlockPartSetHeader types.PartSetHeader
|
||||
BlockParts *bits.BitArray
|
||||
@@ -1493,9 +1494,6 @@ type NewValidBlockMessage struct {
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
func (m *NewValidBlockMessage) ValidateBasic() error {
|
||||
if m.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if m.Round < 0 {
|
||||
return errors.New("negative Round")
|
||||
}
|
||||
@@ -1543,16 +1541,13 @@ func (m *ProposalMessage) String() string {
|
||||
|
||||
// ProposalPOLMessage is sent when a previous proposal is re-proposed.
|
||||
type ProposalPOLMessage struct {
|
||||
Height int64
|
||||
Height uint64
|
||||
ProposalPOLRound int32
|
||||
ProposalPOL *bits.BitArray
|
||||
}
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
func (m *ProposalPOLMessage) ValidateBasic() error {
|
||||
if m.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if m.ProposalPOLRound < 0 {
|
||||
return errors.New("negative ProposalPOLRound")
|
||||
}
|
||||
@@ -1574,16 +1569,13 @@ 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
|
||||
}
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
func (m *BlockPartMessage) ValidateBasic() error {
|
||||
if m.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if m.Round < 0 {
|
||||
return errors.New("negative Round")
|
||||
}
|
||||
@@ -1619,7 +1611,7 @@ func (m *VoteMessage) String() string {
|
||||
|
||||
// HasVoteMessage is sent to indicate that a particular vote has been received.
|
||||
type HasVoteMessage struct {
|
||||
Height int64
|
||||
Height uint64
|
||||
Round int32
|
||||
Type tmproto.SignedMsgType
|
||||
Index int32
|
||||
@@ -1627,9 +1619,6 @@ type HasVoteMessage struct {
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
func (m *HasVoteMessage) ValidateBasic() error {
|
||||
if m.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if m.Round < 0 {
|
||||
return errors.New("negative Round")
|
||||
}
|
||||
@@ -1651,7 +1640,7 @@ func (m *HasVoteMessage) String() string {
|
||||
|
||||
// VoteSetMaj23Message is sent to indicate that a given BlockID has seen +2/3 votes.
|
||||
type VoteSetMaj23Message struct {
|
||||
Height int64
|
||||
Height uint64
|
||||
Round int32
|
||||
Type tmproto.SignedMsgType
|
||||
BlockID types.BlockID
|
||||
@@ -1659,9 +1648,6 @@ type VoteSetMaj23Message struct {
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
func (m *VoteSetMaj23Message) ValidateBasic() error {
|
||||
if m.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if m.Round < 0 {
|
||||
return errors.New("negative Round")
|
||||
}
|
||||
@@ -1683,7 +1669,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
|
||||
@@ -1692,9 +1678,6 @@ type VoteSetBitsMessage struct {
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
func (m *VoteSetBitsMessage) ValidateBasic() error {
|
||||
if m.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if !types.IsVoteTypeValid(m.Type) {
|
||||
return errors.New("invalid Type")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -171,7 +171,7 @@ LOOP:
|
||||
// Parses marker lines of the form:
|
||||
// #ENDHEIGHT: 12345
|
||||
/*
|
||||
func makeHeightSearchFunc(height int64) auto.SearchFunc {
|
||||
func makeHeightSearchFunc(height uint64) auto.SearchFunc {
|
||||
return func(line string) (int, error) {
|
||||
line = strings.TrimRight(line, "\n")
|
||||
parts := strings.Split(line, " ")
|
||||
@@ -248,9 +248,6 @@ func (h *Handshaker) Handshake(proxyApp proxy.AppConns) error {
|
||||
}
|
||||
|
||||
blockHeight := res.LastBlockHeight
|
||||
if blockHeight < 0 {
|
||||
return fmt.Errorf("got a negative last block height (%d) from the app", blockHeight)
|
||||
}
|
||||
appHash := res.LastBlockAppHash
|
||||
|
||||
h.logger.Info("ABCI Handshake App Info",
|
||||
@@ -285,7 +282,7 @@ func (h *Handshaker) Handshake(proxyApp proxy.AppConns) error {
|
||||
func (h *Handshaker) ReplayBlocks(
|
||||
state sm.State,
|
||||
appHash []byte,
|
||||
appBlockHeight int64,
|
||||
appBlockHeight uint64,
|
||||
proxyApp proxy.AppConns,
|
||||
) ([]byte, error) {
|
||||
storeBlockBase := h.store.Base()
|
||||
@@ -439,7 +436,7 @@ func (h *Handshaker) replayBlocks(
|
||||
state sm.State,
|
||||
proxyApp proxy.AppConns,
|
||||
appBlockHeight,
|
||||
storeBlockHeight int64,
|
||||
storeBlockHeight uint64,
|
||||
mutateState bool) ([]byte, error) {
|
||||
// App is further behind than it should be, so we need to replay blocks.
|
||||
// We replay all blocks from appBlockHeight+1.
|
||||
@@ -491,7 +488,7 @@ func (h *Handshaker) replayBlocks(
|
||||
}
|
||||
|
||||
// ApplyBlock on the proxyApp with the last block.
|
||||
func (h *Handshaker) replayBlock(state sm.State, height int64, proxyApp proxy.AppConnConsensus) (sm.State, error) {
|
||||
func (h *Handshaker) replayBlock(state sm.State, height uint64, proxyApp proxy.AppConnConsensus) (sm.State, error) {
|
||||
block := h.store.LoadBlock(height)
|
||||
meta := h.store.LoadBlockMeta(height)
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ func (pb *playback) replayReset(count int, newStepSub types.Subscription) error
|
||||
pb.cs.Wait()
|
||||
|
||||
newCS := NewState(pb.cs.config, pb.genesisState.Copy(), pb.cs.blockExec,
|
||||
pb.cs.blockStore, pb.cs.txNotifier, pb.cs.evpool, map[int64]Misbehavior{})
|
||||
pb.cs.blockStore, pb.cs.txNotifier, pb.cs.evpool, map[uint64]Misbehavior{})
|
||||
newCS.SetEventBus(pb.cs.eventBus)
|
||||
newCS.startForReplay()
|
||||
|
||||
@@ -331,7 +331,7 @@ func newConsensusStateForReplay(config cfg.BaseConfig, csConfig *cfg.ConsensusCo
|
||||
blockExec := sm.NewBlockExecutor(stateStore, log.TestingLogger(), proxyApp.Consensus(), mempool, evpool)
|
||||
|
||||
consensusState := NewState(csConfig, state.Copy(), blockExec,
|
||||
blockStore, mempool, evpool, map[int64]Misbehavior{})
|
||||
blockStore, mempool, evpool, map[uint64]Misbehavior{})
|
||||
|
||||
consensusState.SetEventBus(eventBus)
|
||||
return consensusState
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -86,7 +86,7 @@ type State struct {
|
||||
nSteps int
|
||||
|
||||
// some functions can be overwritten for testing
|
||||
decideProposal func(height int64, round int32)
|
||||
decideProposal func(height uint64, round int32)
|
||||
|
||||
// closed when we finish shutting down
|
||||
done chan struct{}
|
||||
@@ -99,7 +99,7 @@ type State struct {
|
||||
metrics *Metrics
|
||||
|
||||
// misbehaviors mapped for each height (can't have more than one misbehavior per height)
|
||||
misbehaviors map[int64]Misbehavior
|
||||
misbehaviors map[uint64]Misbehavior
|
||||
|
||||
// the switch is passed to the state so that maveick misbehaviors can directly control which
|
||||
// information they send to which nodes
|
||||
@@ -117,7 +117,7 @@ func NewState(
|
||||
blockStore sm.BlockStore,
|
||||
txNotifier txNotifier,
|
||||
evpool evidencePool,
|
||||
misbehaviors map[int64]Misbehavior,
|
||||
misbehaviors map[uint64]Misbehavior,
|
||||
options ...StateOption,
|
||||
) *State {
|
||||
cs := &State{
|
||||
@@ -237,7 +237,7 @@ func (cs *State) handleMsg(mi msgInfo) {
|
||||
// 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) {
|
||||
@@ -276,7 +276,7 @@ func (cs *State) enterPropose(height int64, round int32) {
|
||||
// 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",
|
||||
@@ -313,7 +313,7 @@ func (cs *State) enterPrevote(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) {
|
||||
@@ -449,7 +449,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"`
|
||||
}
|
||||
@@ -533,7 +533,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
|
||||
@@ -560,7 +560,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() {
|
||||
@@ -732,7 +732,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}, ""}
|
||||
@@ -766,7 +766,7 @@ func (cs *State) SetProposalAndBlock(
|
||||
//------------------------------------------------------------
|
||||
// internal functions for managing the state
|
||||
|
||||
func (cs *State) updateHeight(height int64) {
|
||||
func (cs *State) updateHeight(height uint64) {
|
||||
cs.metrics.Height.Set(float64(height))
|
||||
cs.Height = height
|
||||
}
|
||||
@@ -784,7 +784,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})
|
||||
}
|
||||
|
||||
@@ -1098,7 +1098,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) {
|
||||
@@ -1164,7 +1164,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
|
||||
}
|
||||
@@ -1180,7 +1180,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
|
||||
|
||||
@@ -1276,7 +1276,7 @@ func (cs *State) createProposalBlock() (block *types.Block, blockParts *types.Pa
|
||||
}
|
||||
|
||||
// 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) {
|
||||
@@ -1306,7 +1306,7 @@ func (cs *State) enterPrevoteWait(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) {
|
||||
@@ -1333,7 +1333,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 {
|
||||
@@ -1399,7 +1399,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 {
|
||||
@@ -1427,7 +1427,7 @@ func (cs *State) tryFinalizeCommit(height int64) {
|
||||
}
|
||||
|
||||
// Increment height and goto cstypes.RoundStepNewHeight
|
||||
func (cs *State) finalizeCommit(height int64) {
|
||||
func (cs *State) finalizeCommit(height uint64) {
|
||||
if cs.Height != height || cs.Step != cstypes.RoundStepCommit {
|
||||
cs.Logger.Debug(fmt.Sprintf(
|
||||
"finalizeCommit(%v): Invalid args. Current step: %v/%v/%v",
|
||||
@@ -1505,7 +1505,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()},
|
||||
@@ -1550,7 +1550,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
|
||||
@@ -1567,7 +1567,7 @@ func (cs *State) pruneBlocks(retainHeight int64) (uint64, error) {
|
||||
return pruned, nil
|
||||
}
|
||||
|
||||
func (cs *State) recordMetrics(height int64, block *types.Block) {
|
||||
func (cs *State) recordMetrics(height uint64, block *types.Block) {
|
||||
cs.metrics.Validators.Set(float64(cs.Validators.Size()))
|
||||
cs.metrics.ValidatorsPower.Set(float64(cs.Validators.TotalVotingPower()))
|
||||
|
||||
@@ -1887,14 +1887,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 {
|
||||
@@ -1911,7 +1911,7 @@ func (cs *State) checkDoubleSigningRisk(height int64) error {
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
||||
func CompareHRS(h1 int64, r1 int32, s1 cstypes.RoundStepType, h2 int64, r2 int32, s2 cstypes.RoundStepType) int {
|
||||
func CompareHRS(h1 uint64, r1 int32, s1 cstypes.RoundStepType, h2 uint64, r2 int32, s2 cstypes.RoundStepType) int {
|
||||
if h1 < h2 {
|
||||
return -1
|
||||
} else if h1 > h2 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
// NOTE: starting from the last file in the group because we're usually
|
||||
// searching for the last height. See replay.go
|
||||
@@ -429,7 +429,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 }
|
||||
|
||||
@@ -88,7 +88,7 @@ func WALGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) {
|
||||
evpool := sm.EmptyEvidencePool{}
|
||||
blockExec := sm.NewBlockExecutor(stateStore, log.TestingLogger(), proxyApp.Consensus(), mempool, evpool)
|
||||
consensusState := NewState(config.Consensus, state.Copy(),
|
||||
blockExec, blockStore, mempool, evpool, map[int64]Misbehavior{})
|
||||
blockExec, blockStore, mempool, evpool, map[uint64]Misbehavior{})
|
||||
consensusState.SetLogger(logger)
|
||||
consensusState.SetEventBus(eventBus)
|
||||
if privValidator != nil {
|
||||
@@ -99,7 +99,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)
|
||||
@@ -169,7 +169,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
|
||||
@@ -178,7 +178,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,
|
||||
@@ -222,7 +222,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
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ import (
|
||||
|
||||
// ParseMisbehaviors is a util function that converts a comma separated string into
|
||||
// a map of misbehaviors to be executed by the maverick node
|
||||
func ParseMisbehaviors(str string) (map[int64]cs.Misbehavior, error) {
|
||||
func ParseMisbehaviors(str string) (map[uint64]cs.Misbehavior, error) {
|
||||
// check if string is empty in which case we run a normal node
|
||||
var misbehaviors = make(map[int64]cs.Misbehavior)
|
||||
var misbehaviors = make(map[uint64]cs.Misbehavior)
|
||||
if str == "" {
|
||||
return misbehaviors, nil
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func ParseMisbehaviors(str string) (map[int64]cs.Misbehavior, error) {
|
||||
}
|
||||
OUTER_LOOP:
|
||||
for i := 0; i < len(strs); i += 2 {
|
||||
height, err := strconv.ParseInt(strs[i+1], 10, 64)
|
||||
height, err := strconv.ParseUint(strs[i+1], 10, 64)
|
||||
if err != nil {
|
||||
return misbehaviors, fmt.Errorf("failed to parse misbehavior height: %w", err)
|
||||
}
|
||||
@@ -117,7 +117,7 @@ type Provider func(*cfg.Config, log.Logger) (*Node, error)
|
||||
// DefaultNewNode returns a Tendermint node with default settings for the
|
||||
// PrivValidator, ClientCreator, GenesisDoc, and DBProvider.
|
||||
// It implements NodeProvider.
|
||||
func DefaultNewNode(config *cfg.Config, logger log.Logger, misbehaviors map[int64]cs.Misbehavior) (*Node, error) {
|
||||
func DefaultNewNode(config *cfg.Config, logger log.Logger, misbehaviors map[uint64]cs.Misbehavior) (*Node, error) {
|
||||
nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load or gen node key %s, err: %w", config.NodeKeyFile(), err)
|
||||
@@ -476,7 +476,7 @@ func createConsensusReactor(config *cfg.Config,
|
||||
waitSync bool,
|
||||
eventBus *types.EventBus,
|
||||
consensusLogger log.Logger,
|
||||
misbehaviors map[int64]cs.Misbehavior) (*cs.Reactor, *cs.State) {
|
||||
misbehaviors map[uint64]cs.Misbehavior) (*cs.Reactor, *cs.State) {
|
||||
|
||||
consensusState := cs.NewState(
|
||||
config.Consensus,
|
||||
@@ -710,7 +710,7 @@ func NewNode(config *cfg.Config,
|
||||
dbProvider DBProvider,
|
||||
metricsProvider MetricsProvider,
|
||||
logger log.Logger,
|
||||
misbehaviors map[int64]cs.Misbehavior,
|
||||
misbehaviors map[uint64]cs.Misbehavior,
|
||||
options ...Option) (*Node, error) {
|
||||
|
||||
blockStore, stateDB, err := initDBs(config, dbProvider)
|
||||
|
||||
@@ -73,7 +73,7 @@ func (pvKey FilePVKey) Save() {
|
||||
|
||||
// FilePVLastSignState stores the mutable part of PrivValidator.
|
||||
type FilePVLastSignState struct {
|
||||
Height int64 `json:"height"`
|
||||
Height uint64 `json:"height"`
|
||||
Round int32 `json:"round"`
|
||||
Step int8 `json:"step"`
|
||||
Signature []byte `json:"signature,omitempty"`
|
||||
@@ -89,7 +89,7 @@ type FilePVLastSignState struct {
|
||||
// it returns true if the HRS matches the arguments and the SignBytes are not empty (indicating
|
||||
// we have already signed for this HRS, and can reuse the existing signature).
|
||||
// It panics if the HRS matches the arguments, there's a SignBytes, but no Signature.
|
||||
func (lss *FilePVLastSignState) CheckHRS(height int64, round int32, step int8) (bool, error) {
|
||||
func (lss *FilePVLastSignState) CheckHRS(height uint64, round int32, step int8) (bool, error) {
|
||||
|
||||
if lss.Height > height {
|
||||
return false, fmt.Errorf("height regression. Got %v, last height %v", height, lss.Height)
|
||||
@@ -346,7 +346,7 @@ func (pv *FilePV) signProposal(chainID string, proposal *tmproto.Proposal) error
|
||||
}
|
||||
|
||||
// Persist height/round/step and signature
|
||||
func (pv *FilePV) saveSigned(height int64, round int32, step int8,
|
||||
func (pv *FilePV) saveSigned(height uint64, round int32, step int8,
|
||||
signBytes []byte, sig []byte) {
|
||||
|
||||
pv.LastSignState.Height = height
|
||||
|
||||
+1
-6
@@ -390,9 +390,7 @@ func (h Header) ValidateBasic() error {
|
||||
return fmt.Errorf("chainID is too long; got: %d, max: %d", len(h.ChainID), MaxChainIDLen)
|
||||
}
|
||||
|
||||
if h.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
} else if h.Height == 0 {
|
||||
if h.Height == 0 {
|
||||
return errors.New("zero Height")
|
||||
}
|
||||
|
||||
@@ -874,9 +872,6 @@ func (commit *Commit) IsCommit() bool {
|
||||
// ValidateBasic performs basic validation that doesn't involve state data.
|
||||
// Does not actually check the cryptographic signatures.
|
||||
func (commit *Commit) ValidateBasic() error {
|
||||
if commit.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if commit.Round < 0 {
|
||||
return errors.New("negative Round")
|
||||
}
|
||||
|
||||
@@ -73,9 +73,6 @@ func (genDoc *GenesisDoc) ValidateAndComplete() error {
|
||||
if len(genDoc.ChainID) > MaxChainIDLen {
|
||||
return fmt.Errorf("chain_id in genesis doc is too long (max: %d)", MaxChainIDLen)
|
||||
}
|
||||
if genDoc.InitialHeight < 0 {
|
||||
return fmt.Errorf("initial_height cannot be negative (got %v)", genDoc.InitialHeight)
|
||||
}
|
||||
if genDoc.InitialHeight == 0 {
|
||||
genDoc.InitialHeight = 1
|
||||
}
|
||||
|
||||
@@ -50,9 +50,6 @@ func (p *Proposal) ValidateBasic() error {
|
||||
if p.Type != tmproto.ProposalType {
|
||||
return errors.New("invalid Type")
|
||||
}
|
||||
if p.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if p.Round < 0 {
|
||||
return errors.New("negative Round")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user