From ccd609d5624d5c552824f18183ed0ab34e6114a5 Mon Sep 17 00:00:00 2001 From: Robert Pirtle Date: Tue, 12 Dec 2023 13:58:43 -0800 Subject: [PATCH] feat(cli): patch cometbft to support rollbacks of >1 block (#535) * feat(cli): patch cometbft to support rollbacks of >1 block * update to tagged cometbft --- go.mod | 2 +- go.sum | 4 ++-- server/rollback.go | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index e01181a2c45a..debaf6b1d3b4 100644 --- a/go.mod +++ b/go.mod @@ -174,7 +174,7 @@ replace ( github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/jhump/protoreflect => github.com/jhump/protoreflect v1.9.0 // use cometbft - github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.27 + github.com/tendermint/tendermint => github.com/kava-labs/cometbft v0.34.27-kava.1 ) retract ( diff --git a/go.sum b/go.sum index 416e6a88637b..cbd186eb37b7 100644 --- a/go.sum +++ b/go.sum @@ -198,8 +198,6 @@ github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE github.com/coinbase/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI= github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA= github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M= -github.com/cometbft/cometbft v0.34.27 h1:ri6BvmwjWR0gurYjywcBqRe4bbwc3QVs9KRcCzgh/J0= -github.com/cometbft/cometbft v0.34.27/go.mod h1:BcCbhKv7ieM0KEddnYXvQZR+pZykTKReJJYf7YC7qhw= github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo= github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= @@ -600,6 +598,8 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8 github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0= github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= +github.com/kava-labs/cometbft v0.34.27-kava.1 h1:JkTspNCrz9matgrr7nsWgEkgNzDz5YwZhR5jZyxVt/0= +github.com/kava-labs/cometbft v0.34.27-kava.1/go.mod h1:BcCbhKv7ieM0KEddnYXvQZR+pZykTKReJJYf7YC7qhw= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= diff --git a/server/rollback.go b/server/rollback.go index c5245589aacb..3e1cfad5c873 100644 --- a/server/rollback.go +++ b/server/rollback.go @@ -11,6 +11,8 @@ import ( // NewRollbackCmd creates a command to rollback tendermint and multistore state by one height. func NewRollbackCmd(appCreator types.AppCreator, defaultNodeHome string) *cobra.Command { + var removeBlock bool + cmd := &cobra.Command{ Use: "rollback", Short: "rollback cosmos-sdk and tendermint state by one height", @@ -32,7 +34,7 @@ application. } app := appCreator(ctx.Logger, db, nil, ctx.Viper) // rollback tendermint state - height, hash, err := tmcmd.RollbackState(ctx.Config) + height, hash, err := tmcmd.RollbackState(ctx.Config, removeBlock) if err != nil { return fmt.Errorf("failed to rollback tendermint state: %w", err) } @@ -48,5 +50,6 @@ application. } cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory") + cmd.Flags().BoolVar(&removeBlock, "hard", false, "remove last block as well as state") return cmd }