Skip to content

Commit

Permalink
Merge branch 'master' into feat/tests
Browse files Browse the repository at this point in the history
  • Loading branch information
boogeroccam authored Nov 18, 2024
2 parents 2e56998 + 6398d49 commit 78443a2
Show file tree
Hide file tree
Showing 91 changed files with 17,459 additions and 159 deletions.
24 changes: 23 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
upgradekeeper "cosmossdk.io/x/upgrade/keeper"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/ethereum/go-ethereum/common"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand Down Expand Up @@ -136,6 +137,9 @@ import (

capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
memiavlstore "github.com/crypto-org-chain/cronos/store"
"github.com/cosmos/cosmos-sdk/client/flags"
evmante "github.com/evmos/ethermint/app/ante"
)

const (
Expand Down Expand Up @@ -234,6 +238,8 @@ type App struct {
txConfig client.TxConfig
interfaceRegistry codectypes.InterfaceRegistry

pendingTxListeners []evmante.PendingTxListener

// non depinject support modules store keys
keys map[string]*storetypes.KVStoreKey
okeys map[string]*storetypes.ObjectStoreKey
Expand Down Expand Up @@ -397,6 +403,9 @@ func New(
// }
// baseAppOptions = append(baseAppOptions, prepareOpt)

homePath := cast.ToString(appOpts.Get(flags.FlagHome))
baseAppOptions = memiavlstore.SetupMemIAVL(logger, homePath, appOpts, false, false, 0, baseAppOptions)

app.App = appBuilder.Build(db, traceStore, baseAppOptions...)

encConfig := MakeEncodingConfig()
Expand Down Expand Up @@ -703,6 +712,7 @@ func (app *App) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64) {
sdk.MsgTypeURL(&evmtypes.MsgEthereumTx{}),
sdk.MsgTypeURL(&vestingtypes.MsgCreateVestingAccount{}),
},
PendingTxListener: app.onPendingTx,
})
if err != nil {
panic(err)
Expand All @@ -724,8 +734,9 @@ func initParamsKeeper(

func (app *App) applyUpgrades() {
app.applyUpgrade_v0_1_2()
app.applyUpgrade_v0_2_2()
app.applyUpgrade_v0_2_4()
// app.applyUpgrade_v0_2_3()
app.applyUpgrade_v0_2_7()
}

// AutoCliOpts returns the autocli options for the app.
Expand All @@ -747,3 +758,14 @@ func (app *App) AutoCliOpts() autocli.AppOptions {
ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()),
}
}

// RegisterPendingTxListener is used by json-rpc server to listen to pending transactions callback.
func (app *App) RegisterPendingTxListener(listener evmante.PendingTxListener) {
app.pendingTxListeners = append(app.pendingTxListeners, listener)
}

func (app *App) onPendingTx(hash common.Hash) {
for _, listener := range app.pendingTxListeners {
listener(hash)
}
}
43 changes: 43 additions & 0 deletions app/upgrade_v0_2_4.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,46 @@ func (app *App) upgradeHandler_v0_2_4() func(ctx context.Context, _ upgradetypes
return vm, err
}
}

// for andromeda
const (
planName_0_2_2 = "0.2.2"
)

func (app *App) applyUpgrade_v0_2_2() {
app.UpgradeKeeper.SetUpgradeHandler(planName_0_2_2, app.upgradeHandler_v0_2_2())
}

func (app *App) upgradeHandler_v0_2_2() func(ctx context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
logger := sdk.UnwrapSDKContext(ctx).Logger()

logger.Info("Starting module migrations...")

vm, err := app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
if err != nil {
return vm, err
}

logger.Info("Upgrade " + plan.Name + " complete")

return vm, err
}
}


// solve 0.1.2 update problem on andromeda
const (
planName_0_2_7 = "0.2.7"
)

func (app *App) applyUpgrade_v0_2_7() {
app.UpgradeKeeper.SetUpgradeHandler(planName_0_2_7, app.upgradeHandler_v0_2_7())
}

func (app *App) upgradeHandler_v0_2_7() func(ctx context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
sdk.UnwrapSDKContext(ctx).Logger().Info("Upgrade " + plan.Name + " complete")
return fromVM, nil
}
}
17 changes: 17 additions & 0 deletions cmd/galacticad/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,20 @@ func VerifyAddressFormat(bz []byte) error {

return nil
}

type VersionDBConfig struct {
// Enable defines if the versiondb should be enabled.
Enable bool `mapstructure:"enable"`
}

func DefaultVersionDBConfig() VersionDBConfig {
return VersionDBConfig{
Enable: false,
}
}

var DefaultVersionDBTemplate = `
[versiondb]
# Enable defines if the versiondb should be enabled.
enable = {{ .VersionDB.Enable }}
`
21 changes: 15 additions & 6 deletions cmd/galacticad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,21 @@ import (

// ethertypes "github.com/evmos/ethermint/types"

"github.com/Galactica-corp/galactica/app"
authtxconfig "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
txsign "github.com/cosmos/cosmos-sdk/types/tx/signing"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
"slices"

confixcmd "cosmossdk.io/tools/confix/cmd"
"github.com/Galactica-corp/galactica/app"
appparams "github.com/Galactica-corp/galactica/app/params"
"github.com/Galactica-corp/galactica/cmd/galacticad/cmd/ethkeys"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/client/pruning"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
txsign "github.com/cosmos/cosmos-sdk/types/tx/signing"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtxconfig "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
memiavlcfg "github.com/crypto-org-chain/cronos/store/config"
evmenc "github.com/evmos/ethermint/encoding"
confixcmd "cosmossdk.io/tools/confix/cmd"
)

// NewRootCmd creates a new root command for a Cosmos SDK application
Expand Down Expand Up @@ -229,6 +232,7 @@ func initRootCmd(

rootCmd.AddCommand(
snapshot.Cmd(a.newApp),
pruning.Cmd(a.newApp, app.DefaultNodeHome),
)

rootCmd, err := srvflags.AddGlobalFlags(rootCmd)
Expand Down Expand Up @@ -431,6 +435,9 @@ func initAppConfig() (string, interface{}) {

type CustomAppConfig struct {
ethermintconfig.Config

MemIAVL memiavlcfg.MemIAVLConfig `mapstructure:"memiavl"`
VersionDB VersionDBConfig `mapstructure:"versiondb"`
}

// Optionally allow the chain developer to overwrite the SDK's default
Expand All @@ -452,7 +459,9 @@ func initAppConfig() (string, interface{}) {
srvCfg.JSONRPC.API = ethermintconfig.GetAPINamespaces()

customAppConfig := CustomAppConfig{
Config: *srvCfg,
Config: *srvCfg,
MemIAVL: memiavlcfg.DefaultMemIAVLConfig(),
VersionDB: DefaultVersionDBConfig(),
}
customAppTemplate := serverconfig.DefaultConfigTemplate + ethermintconfig.DefaultConfigTemplate

Expand Down
55 changes: 40 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ require (
cosmossdk.io/x/tx v0.13.3
cosmossdk.io/x/upgrade v0.1.1
github.com/bufbuild/buf v1.23.1
github.com/cometbft/cometbft v0.38.10
github.com/cometbft/cometbft v0.38.11
github.com/cosmos/cosmos-db v1.0.2
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.6
github.com/cosmos/gogoproto v1.4.12
github.com/cosmos/ibc-go/modules/capability v1.0.0
github.com/cosmos/ibc-go/v8 v8.2.1
github.com/cosmos/rosetta v0.50.3-1
github.com/crypto-org-chain/cronos/store v0.0.0-00010101000000-000000000000
github.com/ethereum/go-ethereum v1.10.26
github.com/evmos/ethermint v0.0.0-00010101000000-000000000000
github.com/golang/protobuf v1.5.4
Expand All @@ -38,7 +39,7 @@ require (
github.com/stretchr/testify v1.9.0
google.golang.org/genproto/googleapis/api v0.0.0-20240521202816-d264139d666e
google.golang.org/grpc v1.64.0
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0
google.golang.org/protobuf v1.34.1
)

Expand All @@ -59,6 +60,7 @@ require (
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
github.com/alitto/pond v1.8.3 // indirect
github.com/aws/aws-sdk-go v1.53.10 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
Expand Down Expand Up @@ -86,14 +88,15 @@ require (
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.0.1 // indirect
github.com/cosmos/iavl v1.1.2 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/creachadair/atomicfile v0.3.1 // indirect
github.com/creachadair/tomledit v0.0.24 // indirect
github.com/crypto-org-chain/go-block-stm v0.0.0-20240408011717-9f11af197bde // indirect
github.com/crypto-org-chain/cronos/memiavl v0.0.4 // indirect
github.com/crypto-org-chain/go-block-stm v0.0.0-20240912024944-1cd89976aa5e // indirect
github.com/danieljoos/wincred v1.2.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
Expand Down Expand Up @@ -180,6 +183,7 @@ require (
github.com/klauspost/pgzip v1.2.6 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/linxGnu/grocksdb v1.9.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand All @@ -205,9 +209,9 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/profile v1.7.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.47.0 // indirect
github.com/prometheus/common v0.52.2 // indirect
github.com/prometheus/procfs v0.15.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
Expand All @@ -233,11 +237,14 @@ require (
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tidwall/sjson v1.2.5 // indirect
github.com/tidwall/tinylru v1.1.0 // indirect
github.com/tidwall/wal v1.1.7 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/ulikunitz/xz v0.5.12 // indirect
github.com/vbatts/tar-split v0.11.3 // indirect
github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d // indirect
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
Expand Down Expand Up @@ -274,20 +281,38 @@ require (
sigs.k8s.io/yaml v1.4.0 // indirect
)

// release/v0.50.x
replace (
cosmossdk.io/store => github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20240415105151-0108877a3201
cosmossdk.io/x/tx => github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20240415105151-0108877a3201
// use cosmos fork of keyring
//github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
cosmossdk.io/client/v2 => github.com/crypto-org-chain/cosmos-sdk/client/v2 v2.0.0-20240911084450-6870ba130be2
cosmossdk.io/store => github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20240911084450-6870ba130be2
cosmossdk.io/x/tx => github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20240911084450-6870ba130be2
github.com/cosmos/cosmos-sdk => github.com/crypto-org-chain/cosmos-sdk v0.50.6-0.20240911084450-6870ba130be2
)

replace (
github.com/crypto-org-chain/cronos/memiavl => ./memiavl
github.com/crypto-org-chain/cronos/store => ./store
github.com/crypto-org-chain/cronos/versiondb => ./versiondb
)

replace (
// Use cosmos keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0

// for go-ethereum
github.com/cockroachdb/pebble => github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811
// use cometbft
github.com/cometbft/cometbft-db => github.com/crypto-org-chain/cometbft-db v0.0.0-20231011055109-57922ac52a63
github.com/cosmos/cosmos-sdk => github.com/crypto-org-chain/cosmos-sdk v0.0.0-20240415105151-0108877a3201
// dgrijalva/jwt-go is deprecated and doesn't receive security updates.
// TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240425065928-ebb09502e7a7
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20240502052908-179e436703b3
// replace broken goleveldb
// develop
github.com/evmos/ethermint => github.com/valli0x/ethermint v0.1.1-gala

// Fix upstream GHSA-h395-qcrw-5vmq and GHSA-3vp4-m3rf-835h vulnerabilities.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0
github.com/jhump/protoreflect => github.com/jhump/protoreflect v1.9.0
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/tidwall/btree => github.com/crypto-org-chain/btree v0.0.0-20240406140148-2687063b042c

)
Loading

0 comments on commit 78443a2

Please sign in to comment.