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 2 commits
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
37 changes: 19 additions & 18 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/simapp/helpers"
"github.com/cosmos/cosmos-sdk/testutil/mock"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -64,26 +66,25 @@ func setup(withGenesis bool, invCheckPeriod uint) (*ChainApp, GenesisState) {
}

// Setup initializes a new ChainApp. A Nop logger is set in ChainApp.
func Setup(isCheckTx bool) *ChainApp {
app, genesisState := setup(!isCheckTx, 5)
if !isCheckTx {
// init chain must be called to stop deliverState from being nil
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
if err != nil {
panic(err)
}
func Setup(t *testing.T, isCheckTx bool) *ChainApp {
t.Helper()

// Initialize the chain
app.InitChain(
abci.RequestInitChain{
Validators: []abci.ValidatorUpdate{},
ConsensusParams: DefaultConsensusParams,
AppStateBytes: stateBytes,
},
)
}
privVal := mock.NewPV()
pubKey, err := privVal.GetPubKey()
require.NoError(t, err)

return app
// create validator set with single validator
validator := tmtypes.NewValidator(pubKey, 1)
valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator})

// generate genesis account
senderPrivKey := secp256k1.GenPrivKey()
acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0)
balance := banktypes.Balance{
Address: acc.GetAddress().String(),
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))),
}
return SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, balance)
}

// SetupWithGenesisValSet initializes a new ChainApp with a validator set and genesis accounts
Expand Down
6 changes: 4 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/cosmos/cosmos-sdk/crypto/hd"
keys "github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/crypto-org-chain/chain-main/v4/app"
Expand All @@ -26,14 +27,15 @@ func TestMnemonic(t *testing.T) {
)
require.NoError(t, err)

publicKey := account.PubKey
publicKey, ok := account.PubKey.GetCachedValue().(*secp256k1.PubKey)
require.True(t, ok)
expectedPublicKey := []byte("0396bb69cbbf27c07e08c0a9d8ac2002ed75a6287a3f2e4cfe11977817ca14fad0")

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

if !bytes.Equal(expectedPublicKeyBytes, publicKey.Value) {
if !bytes.Equal(expectedPublicKeyBytes, publicKey.Key) {
t.Error("HD public key does not match to expected public key")
}
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/crypto-org-chain/chain-main/v4
go 1.18

require (
cosmossdk.io/math v1.0.0-beta.2
github.com/CosmWasm/wasmd v0.28.0
github.com/confluentinc/bincover v0.1.0
github.com/cosmos/cosmos-sdk v0.46.0
Expand Down Expand Up @@ -35,7 +36,6 @@ require (
cloud.google.com/go/iam v0.3.0 // indirect
cloud.google.com/go/storage v1.14.0 // indirect
cosmossdk.io/errors v1.0.0-beta.7 // indirect
cosmossdk.io/math v1.0.0-beta.2 // indirect
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
Expand Down
4 changes: 4 additions & 0 deletions x/nft/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/network"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/crypto-org-chain/chain-main/v4/app"
nftcli "github.com/crypto-org-chain/chain-main/v4/x/nft/client/cli"
nfttestutil "github.com/crypto-org-chain/chain-main/v4/x/nft/client/testutil"
nfttypes "github.com/crypto-org-chain/chain-main/v4/x/nft/types"
Expand All @@ -36,6 +37,9 @@ func (s *IntegrationTestSuite) SetupSuite() {
cfg.AppConstructor = nfttestutil.GetApp
cfg.NumValidators = 2

encCfg := app.MakeEncodingConfig()
cfg.GenesisState = app.NewDefaultGenesisState(encCfg.Marshaler)

s.cfg = cfg
s.network, err = network.New(s.T(), s.T().TempDir(), cfg)
s.Require().NoError(err)
Expand Down
2 changes: 1 addition & 1 deletion x/nft/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type KeeperSuite struct {

func (suite *KeeperSuite) SetupTest() {

app := app.Setup(isCheckTx)
app := app.Setup(suite.T(), isCheckTx)

suite.app = app
suite.legacyAmino = app.LegacyAmino()
Expand Down
22 changes: 11 additions & 11 deletions x/nft/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (
)

var (
ErrInvalidCollection = sdkerrors.Register(ModuleName, 2, "invalid nft collection")
ErrUnknownCollection = sdkerrors.Register(ModuleName, 3, "unknown nft collection")
ErrInvalidNFT = sdkerrors.Register(ModuleName, 4, "invalid nft")
ErrNFTAlreadyExists = sdkerrors.Register(ModuleName, 5, "nft already exists")
ErrUnknownNFT = sdkerrors.Register(ModuleName, 6, "unknown nft")
ErrEmptyTokenData = sdkerrors.Register(ModuleName, 7, "nft data can't be empty")
ErrUnauthorized = sdkerrors.Register(ModuleName, 8, "unauthorized address")
ErrInvalidDenom = sdkerrors.Register(ModuleName, 9, "invalid denom")
ErrInvalidTokenID = sdkerrors.Register(ModuleName, 10, "invalid nft id")
ErrInvalidTokenURI = sdkerrors.Register(ModuleName, 11, "invalid nft uri")
ErrInvalidDenomName = sdkerrors.Register(ModuleName, 12, "invalid denom name")
ErrInvalidCollection = sdkerrors.Register(ModuleNameAlias, 2, "invalid nft collection")
ErrUnknownCollection = sdkerrors.Register(ModuleNameAlias, 3, "unknown nft collection")
ErrInvalidNFT = sdkerrors.Register(ModuleNameAlias, 4, "invalid nft")
ErrNFTAlreadyExists = sdkerrors.Register(ModuleNameAlias, 5, "nft already exists")
ErrUnknownNFT = sdkerrors.Register(ModuleNameAlias, 6, "unknown nft")
ErrEmptyTokenData = sdkerrors.Register(ModuleNameAlias, 7, "nft data can't be empty")
ErrUnauthorized = sdkerrors.Register(ModuleNameAlias, 8, "unauthorized address")
ErrInvalidDenom = sdkerrors.Register(ModuleNameAlias, 9, "invalid denom")
ErrInvalidTokenID = sdkerrors.Register(ModuleNameAlias, 10, "invalid nft id")
ErrInvalidTokenURI = sdkerrors.Register(ModuleNameAlias, 11, "invalid nft uri")
ErrInvalidDenomName = sdkerrors.Register(ModuleNameAlias, 12, "invalid denom name")
)
3 changes: 3 additions & 0 deletions x/nft/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const (
// ModuleName is the name of the module
ModuleName = "nft"

// avoid conflicts with sdk nft module
ModuleNameAlias = "nft2"

// StoreKey is the default store key for NFT
StoreKey = ModuleName
Comment on lines 19 to 20
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't there be a conflict on the store?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

as long as we don't enable the SDK module, it might be fine?

Copy link
Contributor

Choose a reason for hiding this comment

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

but we will want to migrate to it / enable it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm, maybe do that in another PR: #829


Expand Down