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

Problem: cosmos-sdk 0.46 is not used #828

Merged
merged 34 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7834930
ugprade dependencies and tidy
yihuang Aug 8, 2022
d213eb2
fix build
yihuang Aug 8, 2022
2e3ddda
fix go lint
yihuang Aug 9, 2022
c9c7578
go test ./x/nft/...
yihuang Aug 9, 2022
6e199b8
make test
yihuang Aug 9, 2022
4ed8dc8
update gomod2nix.toml
yihuang Aug 9, 2022
2b52324
remove build time db_backend
yihuang Aug 9, 2022
e1e921a
fixup! fix go lint
yihuang Aug 9, 2022
567cfa3
fixup! remove build time db_backend
yihuang Aug 9, 2022
aa6e445
fix instrumented binary
yihuang Aug 9, 2022
126228a
fix nix build
yihuang Aug 9, 2022
ae5613e
fix integration tests
yihuang Aug 9, 2022
055edb5
fix gov test, deposit not get burn
yihuang Aug 9, 2022
7729321
fix upgrade integration test
yihuang Aug 9, 2022
93d4346
posthandler scaffolding
yihuang Aug 9, 2022
720c5cd
fix upgrade integration test
yihuang Aug 9, 2022
cf37877
fix cmd in integration test
yihuang Aug 10, 2022
9d3ec19
init cmd of ClusterCLI
yihuang Aug 10, 2022
a7d1c44
fix empty upgrade_info
yihuang Aug 10, 2022
62d73b0
Merge branch 'master' into sdk-46
yihuang Aug 10, 2022
bf99a30
go mod tidy and gomod2nix
yihuang Aug 10, 2022
5c96dab
fix build
yihuang Aug 10, 2022
9e26bbc
fixup! fix empty upgrade_info
yihuang Aug 10, 2022
1651de4
Merge remote-tracking branch 'origin/master' into sdk-46
yihuang Aug 10, 2022
b48e949
fix upgrade integration test
yihuang Aug 10, 2022
f884d9f
Merge branch 'master' into sdk-46
yihuang Aug 11, 2022
d1cf1c5
remove wasmvm build tag
yihuang Aug 11, 2022
4adfb00
fix upgrade failure
yihuang Aug 11, 2022
93dee51
update cosmos-sdk for upgrade fix
yihuang Aug 12, 2022
dd02033
Merge remote-tracking branch 'origin/master' into sdk-46
yihuang Aug 15, 2022
8cf0f04
increase sim build timeout
yihuang Aug 15, 2022
a026553
fix sim test
yihuang Aug 15, 2022
30cbacc
cleanup modules
yihuang Aug 15, 2022
4f0cf37
Merge branch 'master' into sdk-46
yihuang Aug 15, 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
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ linters:
- stylecheck
- unconvert

issues:
exclude-rules:
- text: "Use of weak random number generator"
linters:
- gosec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may no need to exclude globally, but just on the relevant places?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


linters-settings:
exclude: ./pystarport/pystarport/*
govet:
Expand Down
12 changes: 9 additions & 3 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ func (app *ChainApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs
feePool.CommunityPool = feePool.CommunityPool.Add(scraps...)
app.DistrKeeper.SetFeePool(ctx, feePool)

app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator())
if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()); err != nil {
panic(err)
}
return false
})

Expand All @@ -133,8 +135,12 @@ func (app *ChainApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs
if errd != nil {
panic(errd)
}
app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr)
app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr)
if err := app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr); err != nil {
panic(err)
}
if err := app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr); err != nil {
panic(err)
}
}

// reset context height
Expand Down
5 changes: 3 additions & 2 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/cosmos/cosmos-sdk/simapp/helpers"
"github.com/cosmos/cosmos-sdk/store"
"github.com/cosmos/cosmos-sdk/store/prefix"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -46,8 +47,8 @@ func init() {
}

type StoreKeysPrefixes struct {
A sdk.StoreKey
B sdk.StoreKey
A storetypes.StoreKey
B storetypes.StoreKey
Prefixes [][]byte
}

Expand Down
9 changes: 5 additions & 4 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"testing"
"time"

sdkmath "cosmossdk.io/math"
"github.com/CosmWasm/wasmd/x/wasm"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
Expand Down Expand Up @@ -240,7 +241,7 @@ func createIncrementalAccounts(accNum int) []sdk.AccAddress {
}

// AddTestAddrsFromPubKeys adds the addresses into the ChainApp providing only the public keys.
func AddTestAddrsFromPubKeys(app *ChainApp, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt sdk.Int) {
func AddTestAddrsFromPubKeys(app *ChainApp, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt sdkmath.Int) {
initCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), accAmt))

for _, pk := range pubKeys {
Expand All @@ -250,17 +251,17 @@ func AddTestAddrsFromPubKeys(app *ChainApp, ctx sdk.Context, pubKeys []cryptotyp

// AddTestAddrs constructs and returns accNum amount of accounts with an
// initial balance of accAmt in random order
func AddTestAddrs(app *ChainApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress {
func AddTestAddrs(app *ChainApp, ctx sdk.Context, accNum int, accAmt sdkmath.Int) []sdk.AccAddress {
return addTestAddrs(app, ctx, accNum, accAmt, createRandomAccounts)
}

// AddTestAddrs constructs and returns accNum amount of accounts with an
// initial balance of accAmt in random order
func AddTestAddrsIncremental(app *ChainApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress {
func AddTestAddrsIncremental(app *ChainApp, ctx sdk.Context, accNum int, accAmt sdkmath.Int) []sdk.AccAddress {
return addTestAddrs(app, ctx, accNum, accAmt, createIncrementalAccounts)
}

func addTestAddrs(app *ChainApp, ctx sdk.Context, accNum int, accAmt sdk.Int, strategy GenerateAccountStrategy) []sdk.AccAddress {
func addTestAddrs(app *ChainApp, ctx sdk.Context, accNum int, accAmt sdkmath.Int, strategy GenerateAccountStrategy) []sdk.AccAddress {
testAddrs := strategy(accNum)

initCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), accAmt))
Expand Down
2 changes: 1 addition & 1 deletion cmd/chain-maind/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty
panic(err)
}

snapshotDB, err := sdk.NewLevelDB("metadata", snapshotDir)
snapshotDB, err := dbm.NewDB("metadata", server.GetAppDBBackend(appOpts), snapshotDir)
if err != nil {
panic(err)
}
Expand Down
7 changes: 4 additions & 3 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import (
keys "github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/crypto-org-chain/chain-main/v4/app"
"github.com/crypto-org-chain/chain-main/v4/config"
)

func TestMnemonic(t *testing.T) {
kb := keys.NewInMemory()
kb := keys.NewInMemory(app.MakeEncodingConfig().Marshaler)
account, err := kb.NewAccount(
"croTest",
"point shiver hurt flight fun online hub antenna engine pave chef fantasy front interest poem accident catch load frequent praise elite pet remove used",
Expand All @@ -25,14 +26,14 @@ func TestMnemonic(t *testing.T) {
)
require.NoError(t, err)

publicKey := account.GetPubKey()
publicKey := account.PubKey
expectedPublicKey := []byte("0396bb69cbbf27c07e08c0a9d8ac2002ed75a6287a3f2e4cfe11977817ca14fad0")

expectedPublicKeyBytes := make([]byte, hex.DecodedLen(len(expectedPublicKey)))
_, err = hex.Decode(expectedPublicKeyBytes, expectedPublicKey)
require.NoError(t, err)

if !bytes.Equal(expectedPublicKeyBytes, publicKey.Bytes()) {
if !bytes.Equal(expectedPublicKeyBytes, publicKey.Value) {
t.Error("HD public key does not match to expected public key")
}
}
Expand Down
5 changes: 3 additions & 2 deletions test/coins.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
fmt "fmt"
"strings"

sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand Down Expand Up @@ -40,12 +41,12 @@ func (parser *FakeCoinParser) GetBaseUnit() string {
}

// FIXME: NOT IMPLEMENTED
func (parser *FakeCoinParser) MustSprintBaseCoin(baseCoin sdk.Int, denom string) string {
func (parser *FakeCoinParser) MustSprintBaseCoin(baseCoin sdkmath.Int, denom string) string {
return ""
}

// FIXME: NOT IMPLEMENTED
func (parser *FakeCoinParser) SprintBaseCoin(baseCoin sdk.Int, denom string) (string, error) {
func (parser *FakeCoinParser) SprintBaseCoin(baseCoin sdkmath.Int, denom string) (string, error) {
return "", nil
}

Expand Down
10 changes: 6 additions & 4 deletions x/chainmain/client/cli/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"path/filepath"
"time"

sdkmath "cosmossdk.io/math"
crypto "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/spf13/cobra"
tmconfig "github.com/tendermint/tendermint/config"
Expand Down Expand Up @@ -267,7 +268,8 @@ func InitTestnet(
_ = os.RemoveAll(outputDir)
return saveErr
}
addr, err := keyInfo.GetAddress()
var addr sdk.AccAddress
addr, err = keyInfo.GetAddress()
if err != nil {
_ = os.RemoveAll(outputDir)
return err
Expand Down Expand Up @@ -562,10 +564,10 @@ func parseStakingCoin(coins sdk.Coins, stakingAmount string) (sdk.Coin, error) {
}

// return half amount of coins
func halfCoins(coins sdk.Coins) sdk.Int {
amount := sdk.ZeroInt()
func halfCoins(coins sdk.Coins) sdkmath.Int {
amount := sdkmath.ZeroInt()
for _, coin := range coins {
amount = amount.Add(coin.Amount.Quo(sdk.NewInt(2)))
amount = amount.Add(coin.Amount.Quo(sdkmath.NewInt(2)))
}
return amount
}
Expand Down
6 changes: 4 additions & 2 deletions x/nft/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ type IntegrationTestSuite struct {
}

func (s *IntegrationTestSuite) SetupSuite() {
var err error
s.T().Log("setting up integration test suite")

cfg := network.DefaultConfig()
cfg.AppConstructor = nfttestutil.GetApp
cfg.NumValidators = 2

s.cfg = cfg
s.network = network.New(s.T(), cfg)
s.network, err = network.New(s.T(), s.T().TempDir(), cfg)
s.Require().NoError(err)

_, err := s.network.WaitForHeight(1)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
}

Expand Down
4 changes: 2 additions & 2 deletions x/nft/client/testutil/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"github.com/crypto-org-chain/chain-main/v4/app"
nftcli "github.com/crypto-org-chain/chain-main/v4/x/nft/client/cli"

pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
dbm "github.com/tendermint/tm-db"
)

Expand All @@ -31,7 +31,7 @@ func GetApp(val network.Validator) servertypes.Application {
wasm.EnableAllProposals,
simapp.EmptyAppOptions{},
nil,
baseapp.SetPruning(storetypes.NewPruningOptionsFromString(val.AppConfig.Pruning)),
baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)),
baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices),
)
}
Expand Down
6 changes: 3 additions & 3 deletions x/nft/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ func CreateTestAddrs(numAddrs int) []sdk.AccAddress {
numString := strconv.Itoa(i)
buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") // base address string

buffer.WriteString(numString) // adding on final two digits to make addresses unique
res, _ := sdk.AccAddressFromHex(buffer.String()) // nolint: errcheck
buffer.WriteString(numString) // adding on final two digits to make addresses unique
res, _ := sdk.AccAddressFromHexUnsafe(buffer.String()) // nolint: errcheck
bech := res.String()
addresses = append(addresses, testAddr(buffer.String(), bech))
buffer.Reset()
Expand All @@ -223,7 +223,7 @@ func CreateTestAddrs(numAddrs int) []sdk.AccAddress {

// for incode address generation
func testAddr(addr string, bech string) sdk.AccAddress {
res, err := sdk.AccAddressFromHex(addr)
res, err := sdk.AccAddressFromHexUnsafe(addr)
if err != nil {
panic(err)
}
Expand Down
6 changes: 3 additions & 3 deletions x/nft/types/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func CreateTestAddrs(numAddrs int) []sdk.AccAddress {
numString := strconv.Itoa(i)
buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") // base address string

buffer.WriteString(numString) // adding on final two digits to make addresses unique
res, _ := sdk.AccAddressFromHex(buffer.String()) // nolint: errcheck
buffer.WriteString(numString) // adding on final two digits to make addresses unique
res, _ := sdk.AccAddressFromHexUnsafe(buffer.String()) // nolint: errcheck
bech := res.String()
addresses = append(addresses, testAddr(buffer.String(), bech))
buffer.Reset()
Expand All @@ -43,7 +43,7 @@ func CreateTestAddrs(numAddrs int) []sdk.AccAddress {

// for incode address generation
func testAddr(addr string, bech string) sdk.AccAddress {
res, err := sdk.AccAddressFromHex(addr)
res, err := sdk.AccAddressFromHexUnsafe(addr)
if err != nil {
panic(err)
}
Expand Down