Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to tendermint v0.35.4 and cosmos-sdk v0.46.0 #399

Merged
merged 32 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
15f2bad
update app to be v0.46.0 compat
evan-forbes May 8, 2022
84be0f0
remove store and mem keys as we shouldn't use these
evan-forbes May 8, 2022
b829223
comment out the IBC modules for now as it is not ready
evan-forbes May 9, 2022
d5cfe57
use patch version of core and the sdk
evan-forbes May 10, 2022
4ae16ca
more small changes to get to compile
evan-forbes May 10, 2022
8a1c16c
replace cosmoscmd with local cmd infra
evan-forbes May 10, 2022
bb3e874
add missing modules to set begin,init,end methods
evan-forbes May 11, 2022
0213dc3
linter
evan-forbes May 11, 2022
e16642f
fix validate basic test
evan-forbes May 11, 2022
de6f135
comment out extra test case for now
evan-forbes May 11, 2022
5ceff93
add a validator set to the genesis state of the testapp
evan-forbes May 11, 2022
5792df6
use default tx handler for middleware
evan-forbes May 12, 2022
dee857b
uncomment out test
evan-forbes May 12, 2022
fa0be53
rename encoding config var to not overwrite encoding package
evan-forbes May 12, 2022
89d51e0
use patched version of core that removes malleated txs from the v1 me…
evan-forbes May 12, 2022
3c83764
linter
evan-forbes May 12, 2022
c12c290
docs
evan-forbes May 12, 2022
5cc5e93
remove commented code
evan-forbes May 12, 2022
a114cf8
fix makefile
evan-forbes May 12, 2022
956cac7
add a command to change the mode to validator in script
evan-forbes May 12, 2022
83286f5
use a release instead of a commit
evan-forbes May 13, 2022
3aa50b4
Merge branch 'master' into evan/upgrade-core-35.4
evan-forbes May 13, 2022
3a58c64
add commets to ibc uninstall to point to issue #412
evan-forbes May 16, 2022
f201a83
get rid of all starport scaffolding comments
evan-forbes May 16, 2022
7854b41
add comment describing panic
evan-forbes May 16, 2022
740ad00
use a constant for env prefix
evan-forbes May 16, 2022
b3eb112
include comment for picking default snapshot interval
evan-forbes May 16, 2022
c99d791
Merge branch 'master' into evan/upgrade-core-35.4
evan-forbes May 16, 2022
df6d36e
patch merge
evan-forbes May 16, 2022
a644be9
fix integration test
evan-forbes May 16, 2022
bce2ed7
remove print statement
evan-forbes May 17, 2022
17379f7
use release and not a specific commit
evan-forbes May 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ BUILD_FLAGS := -ldflags '$(ldflags)'
all: install

mod:
@go mod tidy
@go mod tidy -compat=1.17

pre-build:
@echo "Fetching latest tags"
Expand All @@ -34,7 +34,7 @@ build: mod
@mkdir -p build/
@go build -o build/ ./cmd/celestia-appd
@packr2 clean
@go mod tidy
@go mod tidy -compat=1.17

install: go.sum
@echo "--> Installing celestia-appd"
Expand Down
294 changes: 171 additions & 123 deletions app/app.go

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions app/encoding/encoding.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package encoding

import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
)

type InterfaceRegister func(codectypes.InterfaceRegistry)

// EncodingConfig specifies the concrete encoding types to use for a given app.
// This is provided for compatibility between protobuf and amino implementations.
type EncodingConfig struct {
InterfaceRegistry codectypes.InterfaceRegistry
Codec codec.Codec
TxConfig client.TxConfig
Amino *codec.LegacyAmino
}

// MakeEncodingConfig creates an encoding config for the app.
func MakeEncodingConfig(regs ...InterfaceRegister) EncodingConfig {
liamsi marked this conversation as resolved.
Show resolved Hide resolved
amino := codec.NewLegacyAmino()
interfaceRegistry := codectypes.NewInterfaceRegistry()
std.RegisterInterfaces(interfaceRegistry)
for _, reg := range regs {
reg(interfaceRegistry)
}
marshaler := codec.NewProtoCodec(interfaceRegistry)
txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes)

return EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Codec: marshaler,
TxConfig: txCfg,
Amino: amino,
}
}
28 changes: 22 additions & 6 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ func (app *App) ExportAppStateAndValidators(
height := app.LastBlockHeight() + 1
if forZeroHeight {
height = 0
app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
err := app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
if err != nil {
return servertypes.ExportedApp{}, err
}
}

genState := app.mm.ExportGenesis(ctx, app.appCodec)
Expand All @@ -51,7 +54,7 @@ func (app *App) ExportAppStateAndValidators(
// prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated
// in favour of export at a block height
func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) error {
applyAllowedAddrs := false

// check if there is a allowed address list
Expand Down Expand Up @@ -110,14 +113,25 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
feePool.CommunityPool = feePool.CommunityPool.Add(scraps...)
app.DistrKeeper.SetFeePool(ctx, feePool)

app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator())
err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator())
if err != nil {
// we can panic here as we do not know how to handle invalid validator state
panic(err)
liamsi marked this conversation as resolved.
Show resolved Hide resolved
}
return false
})

// reinitialize all delegations
for _, del := range dels {
app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr())
app.DistrKeeper.Hooks().AfterDelegationModified(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr())
err := app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr())
// note: these errors aren't handled by the cosmos-sdk,
if err != nil {
return err
}
err = app.DistrKeeper.Hooks().AfterDelegationModified(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr())
if err != nil {
return err
}
}

// reset context height
Expand Down Expand Up @@ -168,7 +182,7 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
iter.Close()

if _, err := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx); err != nil {
panic(err)
return err
}

/* Handle slashing state. */
Expand All @@ -182,4 +196,6 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
return false
},
)

return nil
}
7 changes: 3 additions & 4 deletions app/test/prepare_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@ import (
"testing"

"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/app/encoding"
"github.com/celestiaorg/celestia-app/testutil"
"github.com/celestiaorg/celestia-app/x/payment/types"
"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/spm/cosmoscmd"
abci "github.com/tendermint/tendermint/abci/types"
core "github.com/tendermint/tendermint/proto/tendermint/types"
)

func TestPrepareProposal(t *testing.T) {
signer := testutil.GenerateKeyringSigner(t, testAccName)
info := signer.GetSignerInfo()

encCfg := cosmoscmd.MakeEncodingConfig(app.ModuleBasics)
encCfg := encoding.MakeEncodingConfig(app.ModuleBasics.RegisterInterfaces)

testApp := testutil.SetupTestApp(t, info.GetAddress())
testApp := testutil.SetupTestAppWithGenesisValSet(t)

type test struct {
input abci.RequestPrepareProposal
Expand Down
15 changes: 10 additions & 5 deletions app/test/process_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package app_test

import (
"crypto/rand"
"math/big"
"testing"

"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/app/encoding"
"github.com/celestiaorg/celestia-app/testutil"
"github.com/celestiaorg/celestia-app/x/payment/types"
"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/spm/cosmoscmd"
abci "github.com/tendermint/tendermint/abci/types"
tmrand "github.com/tendermint/tendermint/libs/rand"
"github.com/tendermint/tendermint/pkg/consts"
Expand All @@ -22,11 +23,10 @@ import (

func TestMessageInclusionCheck(t *testing.T) {
signer := testutil.GenerateKeyringSigner(t, testAccName)
info := signer.GetSignerInfo()

testApp := testutil.SetupTestApp(t, info.GetAddress())
testApp := testutil.SetupTestAppWithGenesisValSet(t)

encConf := cosmoscmd.MakeEncodingConfig(app.ModuleBasics)
encConf := encoding.MakeEncodingConfig(app.ModuleBasics.RegisterInterfaces)

firstValidPFD, msg1 := genRandMsgPayForData(t, signer, 8)
secondValidPFD, msg2 := genRandMsgPayForData(t, signer, 8)
Expand Down Expand Up @@ -170,7 +170,7 @@ func genRandMsgPayForData(t *testing.T, signer *types.KeyringSigner, squareSize
_, err := rand.Read(ns)
require.NoError(t, err)

message := make([]byte, 20)
message := make([]byte, randomInt(20))
_, err = rand.Read(message)
require.NoError(t, err)

Expand All @@ -194,3 +194,8 @@ func buildTx(t *testing.T, signer *types.KeyringSigner, txCfg client.TxConfig, m

return rawTx
}

func randomInt(max int64) int64 {
i, _ := rand.Int(rand.Reader, big.NewInt(max))
return i.Int64()
}
8 changes: 2 additions & 6 deletions app/test/split_shares_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ package app_test

import (
"bytes"
"fmt"
"testing"

"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/app/encoding"
"github.com/celestiaorg/celestia-app/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/spm/cosmoscmd"
"github.com/tendermint/tendermint/pkg/consts"
"github.com/tendermint/tendermint/pkg/da"
core "github.com/tendermint/tendermint/proto/tendermint/types"
coretypes "github.com/tendermint/tendermint/types"
)

func TestSplitShares(t *testing.T) {
encCfg := cosmoscmd.MakeEncodingConfig(app.ModuleBasics)
encCfg := encoding.MakeEncodingConfig(app.ModuleBasics.RegisterInterfaces)

type test struct {
squareSize uint64
Expand Down Expand Up @@ -99,9 +98,6 @@ func TestSplitShares(t *testing.T) {
parsedShares, _, err := parsedData.ComputeShares(tt.squareSize)
require.NoError(t, err)

rawParsedShares := parsedShares.RawShares()
fmt.Println(len(square), len(rawParsedShares))

require.Equal(t, square, parsedShares.RawShares())
}
}
49 changes: 4 additions & 45 deletions cmd/celestia-appd/main.go
Original file line number Diff line number Diff line change
@@ -1,58 +1,17 @@
package main

import (
"io"
"os"

"github.com/celestiaorg/celestia-app/app"
"github.com/cosmos/cosmos-sdk/baseapp"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/tendermint/spm/cosmoscmd"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"
)

const envPrefix = "CELESTIA"

func main() {
rootCmd, _ := cosmoscmd.NewRootCmd(
app.Name,
app.AccountAddressPrefix,
app.DefaultNodeHome,
app.Name,
app.ModuleBasics,
appBuilder,
// this line is used by starport scaffolding # root/arguments
)
if err := svrcmd.Execute(rootCmd, app.DefaultNodeHome); err != nil {
rootCmd := NewRootCmd()
if err := svrcmd.Execute(rootCmd, envPrefix, app.DefaultNodeHome); err != nil {
os.Exit(1)
}
}

// appBuilder wraps the app.New func to return a cosmoscmd.App interface instead
// of the raw app.App. The New func has to return a raw app.App, because we need
// to call PrepareProposal
func appBuilder(
logger log.Logger,
db dbm.DB,
traceStore io.Writer,
loadLatest bool,
skipUpgradeHeights map[int64]bool,
homePath string,
invCheckPeriod uint,
encodingConfig cosmoscmd.EncodingConfig,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) cosmoscmd.App {
return app.New(
logger,
db,
traceStore,
loadLatest,
skipUpgradeHeights,
homePath,
invCheckPeriod,
encodingConfig,
appOpts,
baseAppOptions...,
)
}
Loading