Compare commits

...

2 Commits

Author SHA1 Message Date
0g-wh
3709a23632 fix cmd/keys
Some checks are pending
Continuous Integration (Commit) / lint (push) Waiting to run
2024-08-04 14:13:11 +08:00
0g-wh
04dfd2a2e9 fix review issues 2024-08-04 13:56:43 +08:00
13 changed files with 18 additions and 767 deletions

View File

@ -16,8 +16,6 @@ import (
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/suite"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)
// d is an alias for sdk.MustNewDecFromStr

View File

@ -46,7 +46,6 @@ func (ac appCreator) newApp(
traceStore io.Writer,
appOpts servertypes.AppOptions,
) servertypes.Application {
fmt.Println("newApp")
var cache sdk.MultiStorePersistentCache
if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
cache = store.NewCommitKVStoreCacheManager()

View File

@ -52,6 +52,13 @@ The pass backend requires GnuPG: https://gnupg.org/
addCmd := keys.AddKeyCommand()
addCmd.Flags().Bool(ethFlag, false, "use default evm coin-type (60) and key signing algorithm (\"eth_secp256k1\")")
algoFlag := addCmd.Flag(flags.FlagKeyType)
algoFlag.DefValue = string(hd.EthSecp256k1Type)
err := algoFlag.Value.Set(string(hd.EthSecp256k1Type))
if err != nil {
panic(err)
}
addCmd.RunE = runAddCmd
cmd.AddCommand(

View File

@ -1,7 +1,6 @@
package main
import (
"fmt"
"os"
"github.com/cosmos/cosmos-sdk/server"
@ -16,7 +15,6 @@ func main() {
if err := svrcmd.Execute(rootCmd, chaincfg.EnvPrefix, chaincfg.DefaultNodeHome); err != nil {
switch e := err.(type) {
case server.ErrorCode:
fmt.Println("error")
os.Exit(e.Code)
default:

View File

@ -14,9 +14,9 @@ import (
"syscall"
"time"
"github.com/0glabs/0g-chain/cmd/opendb"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
"github.com/kava-labs/kava/cmd/kava/opendb"
"github.com/linxGnu/grocksdb"
"github.com/spf13/cobra"
"golang.org/x/exp/slices"

5
go.mod
View File

@ -24,8 +24,6 @@ require (
github.com/golang/protobuf v1.5.3
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/influxdata/influxdb v1.8.3
github.com/kava-labs/kava v0.26.1
github.com/linxGnu/grocksdb v1.8.6
github.com/pelletier/go-toml/v2 v2.1.0
github.com/prometheus/client_golang v1.14.0
@ -35,7 +33,6 @@ require (
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.8.4
github.com/subosito/gotenv v1.6.0
github.com/tendermint/tendermint v0.35.9
golang.org/x/crypto v0.24.0
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0
@ -235,7 +232,7 @@ replace (
// Use go-ethereum fork with precompiles
github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2
// Use ethermint fork that respects min-gas-price with NoBaseFee true and london enabled, and includes eip712 support
github.com/evmos/ethermint => github.com/0g-wh/ethermint v0.21.0-0glabs-v26.3.1
github.com/evmos/ethermint => github.com/0glabs/ethermint v0.21.0-0g.v3.0.2
// See https://github.com/cosmos/cosmos-sdk/pull/10401, https://github.com/cosmos/cosmos-sdk/commit/0592ba6158cd0bf49d894be1cef4faeec59e8320
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0
// Downgraded to avoid bugs in following commits which causes "version does not exist" errors

638
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
cdptypes "github.com/kava-labs/kava/x/cdp/types"
)
func (suite *IntegrationTestSuite) TestUpgradeParams_SDK() {

View File

@ -6,7 +6,8 @@ import (
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/influxdata/influxdb/client"
"github.com/0glabs/0g-chain/client/grpc"
)
// LiveNodeRunnerConfig implements NodeRunner.
@ -50,21 +51,21 @@ func (r LiveNodeRunner) StartChains() Chains {
}
// determine chain id
grpc, err := zgChain.GrpcConn()
client, err := grpc.NewClient(zgChain.GrpcUrl)
if err != nil {
panic(fmt.Sprintf("failed to establish grpc conn to %s: %s", r.config.ZgChainGrpcUrl, err))
panic(fmt.Sprintf("failed to create 0g-chain grpc client: %s", err))
}
nodeInfo, err := client.Query.Tm.GetNodeInfo(context.Background(), &tmservice.GetNodeInfoRequest{})
if err != nil {
panic(fmt.Sprintf("failed to fetch 0-chain node info: %s", err))
panic(fmt.Sprintf("failed to fetch 0g-chain node info: %s", err))
}
zgChain.ChainId = nodeInfo.DefaultNodeInfo.Network
// determine staking denom
stakingParams, err := client.Query.Staking.Params(context.Background(), &stakingtypes.QueryParamsRequest{})
if err != nil {
panic(fmt.Sprintf("failed to fetch 0gchain staking params: %s", err))
panic(fmt.Sprintf("failed to fetch 0g-chain staking params: %s", err))
}
zgChain.StakingDenom = stakingParams.Params.BondDenom

View File

@ -1,23 +0,0 @@
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
v2 "github.com/kava-labs/kava/x/cdp/migrations/v2"
)
// Migrator is a struct for handling in-place store migrations.
type Migrator struct {
keeper Keeper
}
// NewMigrator returns a new Migrator.
func NewMigrator(keeper Keeper) Migrator {
return Migrator{
keeper: keeper,
}
}
// Migrate1to2 migrates from version 1 to 2.
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v2.MigrateStore(ctx, m.keeper.paramSubspace)
}

View File

@ -1,21 +0,0 @@
package v2
import (
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
// MigrateStore performs in-place store migrations for consensus version 2
// V2 adds the begin_blocker_execution_block_interval param to parameters.
func MigrateStore(ctx sdk.Context, paramstore paramtypes.Subspace) error {
migrateParamsStore(ctx, paramstore)
return nil
}
// migrateParamsStore ensures the param key table exists and has the begin_blocker_execution_block_interval property
func migrateParamsStore(ctx sdk.Context, paramstore paramtypes.Subspace) {
if !paramstore.HasKeyTable() {
paramstore.WithKeyTable(types.ParamKeyTable())
}
paramstore.Set(ctx, types.KeyBeginBlockerExecutionBlockInterval, types.DefaultBeginBlockerExecutionBlockInterval)
}

View File

@ -1,62 +0,0 @@
package v2_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
v2cdp "github.com/kava-labs/kava/x/cdp/migrations/v2"
)
func TestStoreMigrationAddsKeyTableIncludingNewParam(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig()
cdpKey := sdk.NewKVStoreKey(types.ModuleName)
tcdpKey := sdk.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(cdpKey, tcdpKey)
paramstore := paramtypes.NewSubspace(encCfg.Codec, encCfg.Amino, cdpKey, tcdpKey, types.ModuleName)
// Check param doesn't exist before
require.False(t, paramstore.Has(ctx, types.KeyBeginBlockerExecutionBlockInterval))
// Run migrations.
err := v2cdp.MigrateStore(ctx, paramstore)
require.NoError(t, err)
// Make sure the new params are set.
require.True(t, paramstore.Has(ctx, types.KeyBeginBlockerExecutionBlockInterval))
// Assert the value is what we expect
result := types.DefaultBeginBlockerExecutionBlockInterval
paramstore.Get(ctx, types.KeyBeginBlockerExecutionBlockInterval, &result)
require.Equal(t, result, types.DefaultBeginBlockerExecutionBlockInterval)
}
func TestStoreMigrationSetsNewParamOnExistingKeyTable(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig()
cdpKey := sdk.NewKVStoreKey(types.ModuleName)
tcdpKey := sdk.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(cdpKey, tcdpKey)
paramstore := paramtypes.NewSubspace(encCfg.Codec, encCfg.Amino, cdpKey, tcdpKey, types.ModuleName)
paramstore.WithKeyTable(types.ParamKeyTable())
// expect it to have key table
require.True(t, paramstore.HasKeyTable())
// expect it to not have new param
require.False(t, paramstore.Has(ctx, types.KeyBeginBlockerExecutionBlockInterval))
// Run migrations.
err := v2cdp.MigrateStore(ctx, paramstore)
require.NoError(t, err)
// Make sure the new params are set.
require.True(t, paramstore.Has(ctx, types.KeyBeginBlockerExecutionBlockInterval))
// Assert the value is what we expect
result := types.DefaultBeginBlockerExecutionBlockInterval
paramstore.Get(ctx, types.KeyBeginBlockerExecutionBlockInterval, &result)
require.Equal(t, result, types.DefaultBeginBlockerExecutionBlockInterval)
}

View File

@ -2,21 +2,11 @@ package keeper_test
import (
"testing"
"time"
sdkmath "cosmossdk.io/math"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/stretchr/testify/suite"
"github.com/0glabs/0g-chain/app"
bep3types "github.com/0glabs/0g-chain/x/bep3/types"
cdptypes "github.com/0glabs/0g-chain/x/cdp/types"
"github.com/0glabs/0g-chain/x/committee/types"
pricefeedtypes "github.com/0glabs/0g-chain/x/pricefeed/types"
)
type PermissionTestSuite struct {