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.sum
.build/0gchaind
.build/da

View File

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

View File

@ -627,6 +627,8 @@ func NewApp(
validatorvesting.NewAppModule(app.bankKeeper),
evmutil.NewAppModule(app.evmutilKeeper, app.bankKeeper, app.accountKeeper),
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.

View File

@ -8,6 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/config"
"github.com/cosmos/cosmos-sdk/client/debug"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/server"
tmcfg "github.com/cometbft/cometbft/config"
@ -28,8 +29,16 @@ import (
"github.com/0glabs/0g-chain/chaincfg"
"github.com/0glabs/0g-chain/cmd/opendb"
"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.
func NewRootCmd() *cobra.Command {
encodingConfig := app.MakeEncodingConfig()
@ -42,7 +51,7 @@ func NewRootCmd() *cobra.Command {
WithAccountRetriever(types.AccountRetriever{}).
WithBroadcastMode(flags.FlagBroadcastMode).
WithHomeDir(chaincfg.DefaultNodeHome).
WithKeyringOptions(hd.EthSecp256k1Option()).
WithKeyringOptions(customKeyringOptions()).
WithViper(chaincfg.EnvPrefix)
rootCmd := &cobra.Command{
Use: chaincfg.AppName,

View File

@ -4,7 +4,7 @@ import (
"context"
"time"
"github.com/0glabs/0g-evmos/helper/da/light"
"github.com/0glabs/0g-chain/helper/da/light"
"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

View File

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

View File

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

View File

@ -166,13 +166,15 @@ func NewVoteCmd() *cobra.Command {
var tokens sdkmath.Int
for _, val := range rsp.Hist.Valset {
thisValAddr := val.GetOperator()
if thisValAddr.Equals(valAddr) {
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
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)
for i := range ballots {
ballotID := uint64(i)