mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-27 00:35:18 +00:00
Compare commits
No commits in common. "3709a236326f9e360fb70ee838dcd7af72529e54" and "932664eface10edd8f51bc4c9fdfa8f1374ba023" have entirely different histories.
3709a23632
...
932664efac
@ -16,6 +16,8 @@ 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,6 +46,7 @@ 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()
|
||||||
|
@ -52,13 +52,6 @@ The pass backend requires GnuPG: https://gnupg.org/
|
|||||||
addCmd := keys.AddKeyCommand()
|
addCmd := keys.AddKeyCommand()
|
||||||
addCmd.Flags().Bool(ethFlag, false, "use default evm coin-type (60) and key signing algorithm (\"eth_secp256k1\")")
|
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
|
addCmd.RunE = runAddCmd
|
||||||
|
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/server"
|
"github.com/cosmos/cosmos-sdk/server"
|
||||||
@ -15,6 +16,7 @@ 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,6 +24,8 @@ 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
|
||||||
@ -33,6 +35,7 @@ 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
|
||||||
@ -232,7 +235,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/0glabs/ethermint v0.21.0-0g.v3.0.2
|
github.com/evmos/ethermint => github.com/0g-wh/ethermint v0.21.0-0glabs-v26.3.1
|
||||||
// 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,6 +8,7 @@ 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,8 +6,7 @@ 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.
|
||||||
@ -51,21 +50,21 @@ func (r LiveNodeRunner) StartChains() Chains {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// determine chain id
|
// determine chain id
|
||||||
client, err := grpc.NewClient(zgChain.GrpcUrl)
|
grpc, err := zgChain.GrpcConn()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("failed to create 0g-chain grpc client: %s", err))
|
panic(fmt.Sprintf("failed to establish grpc conn to %s: %s", r.config.ZgChainGrpcUrl, 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 0g-chain node info: %s", err))
|
panic(fmt.Sprintf("failed to fetch 0-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 0g-chain staking params: %s", err))
|
panic(fmt.Sprintf("failed to fetch 0gchain staking params: %s", err))
|
||||||
}
|
}
|
||||||
zgChain.StakingDenom = stakingParams.Params.BondDenom
|
zgChain.StakingDenom = stakingParams.Params.BondDenom
|
||||||
|
|
||||||
|
23
x/cdp/keeper/migrations.go
Normal file
23
x/cdp/keeper/migrations.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
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)
|
||||||
|
}
|
21
x/cdp/migrations/v2/store.go
Normal file
21
x/cdp/migrations/v2/store.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
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)
|
||||||
|
}
|
62
x/cdp/migrations/v2/store_test.go
Normal file
62
x/cdp/migrations/v2/store_test.go
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
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,11 +2,21 @@ 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