mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
fix review issues
This commit is contained in:
parent
932664efac
commit
04dfd2a2e9
@ -16,8 +16,6 @@ import (
|
|||||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// d is an alias for sdk.MustNewDecFromStr
|
// d is an alias for sdk.MustNewDecFromStr
|
||||||
|
@ -46,7 +46,6 @@ func (ac appCreator) newApp(
|
|||||||
traceStore io.Writer,
|
traceStore io.Writer,
|
||||||
appOpts servertypes.AppOptions,
|
appOpts servertypes.AppOptions,
|
||||||
) servertypes.Application {
|
) servertypes.Application {
|
||||||
fmt.Println("newApp")
|
|
||||||
var cache sdk.MultiStorePersistentCache
|
var cache sdk.MultiStorePersistentCache
|
||||||
if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
|
if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
|
||||||
cache = store.NewCommitKVStoreCacheManager()
|
cache = store.NewCommitKVStoreCacheManager()
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/server"
|
"github.com/cosmos/cosmos-sdk/server"
|
||||||
@ -16,7 +15,6 @@ func main() {
|
|||||||
if err := svrcmd.Execute(rootCmd, chaincfg.EnvPrefix, chaincfg.DefaultNodeHome); err != nil {
|
if err := svrcmd.Execute(rootCmd, chaincfg.EnvPrefix, chaincfg.DefaultNodeHome); err != nil {
|
||||||
switch e := err.(type) {
|
switch e := err.(type) {
|
||||||
case server.ErrorCode:
|
case server.ErrorCode:
|
||||||
fmt.Println("error")
|
|
||||||
os.Exit(e.Code)
|
os.Exit(e.Code)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -14,9 +14,9 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/0glabs/0g-chain/cmd/opendb"
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/server"
|
"github.com/cosmos/cosmos-sdk/server"
|
||||||
"github.com/kava-labs/kava/cmd/kava/opendb"
|
|
||||||
"github.com/linxGnu/grocksdb"
|
"github.com/linxGnu/grocksdb"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
|
5
go.mod
5
go.mod
@ -24,8 +24,6 @@ require (
|
|||||||
github.com/golang/protobuf v1.5.3
|
github.com/golang/protobuf v1.5.3
|
||||||
github.com/gorilla/mux v1.8.0
|
github.com/gorilla/mux v1.8.0
|
||||||
github.com/grpc-ecosystem/grpc-gateway v1.16.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/linxGnu/grocksdb v1.8.6
|
||||||
github.com/pelletier/go-toml/v2 v2.1.0
|
github.com/pelletier/go-toml/v2 v2.1.0
|
||||||
github.com/prometheus/client_golang v1.14.0
|
github.com/prometheus/client_golang v1.14.0
|
||||||
@ -35,7 +33,6 @@ require (
|
|||||||
github.com/spf13/viper v1.16.0
|
github.com/spf13/viper v1.16.0
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
github.com/subosito/gotenv v1.6.0
|
github.com/subosito/gotenv v1.6.0
|
||||||
github.com/tendermint/tendermint v0.35.9
|
|
||||||
golang.org/x/crypto v0.24.0
|
golang.org/x/crypto v0.24.0
|
||||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
|
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0
|
google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0
|
||||||
@ -235,7 +232,7 @@ replace (
|
|||||||
// Use go-ethereum fork with precompiles
|
// Use go-ethereum fork with precompiles
|
||||||
github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2
|
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
|
// 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
|
// 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
|
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
|
// Downgraded to avoid bugs in following commits which causes "version does not exist" errors
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
|
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
|
||||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
||||||
cdptypes "github.com/kava-labs/kava/x/cdp/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (suite *IntegrationTestSuite) TestUpgradeParams_SDK() {
|
func (suite *IntegrationTestSuite) TestUpgradeParams_SDK() {
|
||||||
|
@ -6,7 +6,8 @@ import (
|
|||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
|
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
|
||||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||||
"github.com/influxdata/influxdb/client"
|
|
||||||
|
"github.com/0glabs/0g-chain/client/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LiveNodeRunnerConfig implements NodeRunner.
|
// LiveNodeRunnerConfig implements NodeRunner.
|
||||||
@ -50,21 +51,21 @@ func (r LiveNodeRunner) StartChains() Chains {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// determine chain id
|
// determine chain id
|
||||||
grpc, err := zgChain.GrpcConn()
|
client, err := grpc.NewClient(zgChain.GrpcUrl)
|
||||||
if err != nil {
|
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{})
|
nodeInfo, err := client.Query.Tm.GetNodeInfo(context.Background(), &tmservice.GetNodeInfoRequest{})
|
||||||
if err != nil {
|
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
|
zgChain.ChainId = nodeInfo.DefaultNodeInfo.Network
|
||||||
|
|
||||||
// determine staking denom
|
// determine staking denom
|
||||||
stakingParams, err := client.Query.Staking.Params(context.Background(), &stakingtypes.QueryParamsRequest{})
|
stakingParams, err := client.Query.Staking.Params(context.Background(), &stakingtypes.QueryParamsRequest{})
|
||||||
if err != nil {
|
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
|
zgChain.StakingDenom = stakingParams.Params.BondDenom
|
||||||
|
|
||||||
|
@ -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)
|
|
||||||
}
|
|
@ -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)
|
|
||||||
}
|
|
@ -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)
|
|
||||||
}
|
|
@ -2,21 +2,11 @@ package keeper_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
sdkmath "cosmossdk.io/math"
|
|
||||||
abci "github.com/cometbft/cometbft/abci/types"
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"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/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/0glabs/0g-chain/app"
|
"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 {
|
type PermissionTestSuite struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user