Merge pull request #6 from Solovyov1796/mrigration_da

Migration da helper
This commit is contained in:
0xsatoshi 2024-04-26 16:56:28 +08:00 committed by GitHub
commit ac2818e8e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 30 additions and 14 deletions

1
.gitignore vendored
View File

@ -42,3 +42,4 @@ build/linux
go.work go.work
go.work.sum go.work.sum
.build/0gchaind .build/0gchaind
.build/da

View File

@ -6,10 +6,12 @@ import (
"testing" "testing"
"time" "time"
sdkmath "cosmossdk.io/math"
tmdb "github.com/cometbft/cometbft-db" tmdb "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types" abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log" "github.com/cometbft/cometbft/libs/log"
"github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil/sims" "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -627,6 +627,8 @@ func NewApp(
validatorvesting.NewAppModule(app.bankKeeper), validatorvesting.NewAppModule(app.bankKeeper),
evmutil.NewAppModule(app.evmutilKeeper, app.bankKeeper, app.accountKeeper), evmutil.NewAppModule(app.evmutilKeeper, app.bankKeeper, app.accountKeeper),
mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper, nil, mintSubspace), mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper, nil, mintSubspace),
council.NewAppModule(app.CouncilKeeper, app.stakingKeeper),
das.NewAppModule(app.DasKeeper),
) )
// Warning: Some begin blockers must run before others. Ensure the dependencies are understood before modifying this list. // Warning: Some begin blockers must run before others. Ensure the dependencies are understood before modifying this list.

View File

@ -8,6 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/client/config"
"github.com/cosmos/cosmos-sdk/client/debug" "github.com/cosmos/cosmos-sdk/client/debug"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server"
tmcfg "github.com/cometbft/cometbft/config" tmcfg "github.com/cometbft/cometbft/config"
@ -28,8 +29,16 @@ import (
"github.com/0glabs/0g-chain/chaincfg" "github.com/0glabs/0g-chain/chaincfg"
"github.com/0glabs/0g-chain/cmd/opendb" "github.com/0glabs/0g-chain/cmd/opendb"
"github.com/0glabs/0g-chain/cmd/rocksdb" "github.com/0glabs/0g-chain/cmd/rocksdb"
"github.com/0glabs/0g-chain/crypto/vrf"
) )
func customKeyringOptions() keyring.Option {
return func(options *keyring.Options) {
options.SupportedAlgos = append(hd.SupportedAlgorithms, vrf.VrfAlgo)
options.SupportedAlgosLedger = append(hd.SupportedAlgorithmsLedger, vrf.VrfAlgo)
}
}
// NewRootCmd creates a new root command for the 0g-chain blockchain. // NewRootCmd creates a new root command for the 0g-chain blockchain.
func NewRootCmd() *cobra.Command { func NewRootCmd() *cobra.Command {
encodingConfig := app.MakeEncodingConfig() encodingConfig := app.MakeEncodingConfig()
@ -42,7 +51,7 @@ func NewRootCmd() *cobra.Command {
WithAccountRetriever(types.AccountRetriever{}). WithAccountRetriever(types.AccountRetriever{}).
WithBroadcastMode(flags.FlagBroadcastMode). WithBroadcastMode(flags.FlagBroadcastMode).
WithHomeDir(chaincfg.DefaultNodeHome). WithHomeDir(chaincfg.DefaultNodeHome).
WithKeyringOptions(hd.EthSecp256k1Option()). WithKeyringOptions(customKeyringOptions()).
WithViper(chaincfg.EnvPrefix) WithViper(chaincfg.EnvPrefix)
rootCmd := &cobra.Command{ rootCmd := &cobra.Command{
Use: chaincfg.AppName, Use: chaincfg.AppName,

View File

@ -4,7 +4,7 @@ import (
"context" "context"
"time" "time"
"github.com/0glabs/0g-evmos/helper/da/light" "github.com/0glabs/0g-chain/helper/da/light"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View File

@ -1,4 +1,4 @@
module github.com/0glabs/0g-evmos/helper/da module github.com/0glabs/0g-chain/helper/da
go 1.20 go 1.20

View File

@ -11,8 +11,8 @@ import (
"os/signal" "os/signal"
"time" "time"
"github.com/0glabs/0g-evmos/helper/da/service" "github.com/0glabs/0g-chain/helper/da/service"
"github.com/0glabs/0g-evmos/helper/da/types" "github.com/0glabs/0g-chain/helper/da/types"
"github.com/lesismal/nbio/nbhttp" "github.com/lesismal/nbio/nbhttp"
"github.com/lesismal/nbio/nbhttp/websocket" "github.com/lesismal/nbio/nbhttp/websocket"

View File

@ -8,9 +8,9 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/0glabs/0g-evmos/helper/da/client" "github.com/0glabs/0g-chain/helper/da/client"
"github.com/0glabs/0g-evmos/helper/da/types" "github.com/0glabs/0g-chain/helper/da/types"
"github.com/0glabs/0g-evmos/helper/da/utils/sizedw8grp" "github.com/0glabs/0g-chain/helper/da/utils/sizedw8grp"
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
"github.com/lesismal/nbio/nbhttp/websocket" "github.com/lesismal/nbio/nbhttp/websocket"
@ -165,20 +165,20 @@ func runEvmosdCliReportDasResult(ctx context.Context, requestId uint64, result b
strconv.FormatUint(requestId, 10), strconv.FormatUint(requestId, 10),
strconv.FormatBool(result), strconv.FormatBool(result),
"--from", account.(string), "--from", account.(string),
"--gas-prices", "767812500aevmos", // TODO: use args to set gas prices "--gas-prices", "7678500neuron", // TODO: use args to set gas prices
} }
homePath := ctx.Value(types.NODE_HOME_PATH) homePath := ctx.Value(types.NODE_HOME_PATH)
if homePath != nil { if len(homePath.(string)) > 0 {
args = append(args, "--home", homePath.(string)) args = append(args, "--home", homePath.(string))
} }
keyring := ctx.Value(types.NODE_CLI_EXEC_KEYRING) keyring := ctx.Value(types.NODE_CLI_EXEC_KEYRING)
if keyring != nil { if len(keyring.(string)) > 0 {
args = append(args, "--keyring-backend", keyring.(string)) args = append(args, "--keyring-backend", keyring.(string))
} }
cmdStr := relativePath.(string) + "evmosd" cmdStr := relativePath.(string) + "0gchaind"
cmd := exec.Command(cmdStr, append(args, "-y")...) cmd := exec.Command(cmdStr, append(args, "-y")...)
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr

View File

@ -166,13 +166,15 @@ func NewVoteCmd() *cobra.Command {
var tokens sdkmath.Int var tokens sdkmath.Int
for _, val := range rsp.Hist.Valset { for _, val := range rsp.Hist.Valset {
thisValAddr := val.GetOperator() thisValAddr := val.GetOperator()
if thisValAddr.Equals(valAddr) { if thisValAddr.Equals(valAddr) {
tokens = val.GetTokens() tokens = val.GetTokens()
} }
} }
// the denom of token is neuron, need to convert to A0GI
a0gi := tokens.Quo(sdk.NewInt(1_000_000_000_000_000_000))
// 1_000 0AGI token / vote // 1_000 0AGI token / vote
numBallots := tokens.Quo(sdk.NewInt(1_000_000_000_000_000_000)).Quo(sdk.NewInt(1_000)).Uint64() numBallots := a0gi.Quo(sdk.NewInt(1_000)).Uint64()
ballots := make([]*types.Ballot, numBallots) ballots := make([]*types.Ballot, numBallots)
for i := range ballots { for i := range ballots {
ballotID := uint64(i) ballotID := uint64(i)