-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from White-Whale-Defi-Platform/fix-statesync
add statesync to root.go
- Loading branch information
Showing
10 changed files
with
193 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
run: | ||
tests: true | ||
# timeout for analysis, e.g. 30s, 5m, default is 1m | ||
timeout: 5m | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- depguard | ||
- dogsled | ||
- errcheck | ||
- exportloopref | ||
- goconst | ||
- gocritic | ||
- gofumpt | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- misspell | ||
- nakedret | ||
- nolintlint | ||
- revive | ||
- staticcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
|
||
# TODO: fix the sdkerrors.Wrap deprecation warning and re-enable staticcheck | ||
|
||
issues: | ||
exclude-rules: | ||
- text: "Error return value of `flagSet.Set` is not checked" | ||
linters: | ||
- errcheck | ||
- text: "SA1019: sdkerrors.Wrapf is deprecated: functionality of this package has been moved to it's own module" | ||
linters: | ||
- staticcheck | ||
- text: "sdkerrors.Error is deprecated: the type has been moved to cosmossdk.io/errors module" | ||
linters: | ||
- staticcheck | ||
- text: "sdkerrors.Wrap is deprecated: functionality of this package has been moved to it's own module" | ||
linters: | ||
- staticcheck | ||
- text: "Use of weak random number generator" | ||
linters: | ||
- gosec | ||
- text: "comment on exported var" | ||
linters: | ||
- golint | ||
- text: "don't use an underscore in package name" | ||
linters: | ||
- golint | ||
- text: "ST1003:" | ||
linters: | ||
- stylecheck | ||
# FIXME: Disabled until golangci-lint updates stylecheck with this fix: | ||
# https://github.com/dominikh/go-tools/issues/389 | ||
- text: "ST1016:" | ||
linters: | ||
- stylecheck | ||
- path: "migrations" | ||
text: "SA1019:" | ||
linters: | ||
- staticcheck | ||
|
||
max-issues-per-linter: 10000 | ||
max-same-issues: 10000 | ||
|
||
linters-settings: | ||
dogsled: | ||
max-blank-identifiers: 3 | ||
maligned: | ||
# print struct with more effective memory layout or not, false by default | ||
suggest-new: true | ||
nolintlint: | ||
allow-unused: false | ||
allow-leading-space: true | ||
require-explanation: false | ||
require-specific: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,17 @@ import ( | |
"errors" | ||
"io" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/spf13/cast" | ||
|
||
"github.com/cosmos/cosmos-sdk/baseapp" | ||
"github.com/cosmos/cosmos-sdk/snapshots" | ||
"github.com/cosmos/cosmos-sdk/version" | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
|
||
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" | ||
"github.com/spf13/cobra" | ||
tmcfg "github.com/tendermint/tendermint/config" | ||
tmcli "github.com/tendermint/tendermint/libs/cli" | ||
|
@@ -20,6 +25,9 @@ import ( | |
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" | ||
"github.com/White-Whale-Defi-Platform/migaloo-chain/app" | ||
"github.com/White-Whale-Defi-Platform/migaloo-chain/app/params" | ||
"github.com/cosmos/cosmos-sdk/store" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/config" | ||
"github.com/cosmos/cosmos-sdk/client/debug" | ||
|
@@ -92,6 +100,8 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { | |
func initTendermintConfig() *tmcfg.Config { | ||
cfg := tmcfg.DefaultConfig() | ||
|
||
cfg.P2P.Seeds = "[email protected]:12856,[email protected]:27656,ebc272824924ea1a27ea3183dd0b9ba713494f83@whitewhale-mainnet-seed.autostake.net:27096,[email protected]:20756" | ||
|
||
// these values put a higher strain on node memory | ||
cfg.P2P.MaxNumInboundPeers = 320 | ||
cfg.P2P.MaxNumOutboundPeers = 40 | ||
|
@@ -247,11 +257,36 @@ type appCreator struct { | |
|
||
// newApp is an appCreator | ||
func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application { | ||
var cache sdk.MultiStorePersistentCache | ||
|
||
if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) { | ||
cache = store.NewCommitKVStoreCacheManager() | ||
} | ||
|
||
pruningOpts, err := server.GetPruningOptionsFromFlags(appOpts) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
snapshotDir := filepath.Join(cast.ToString(appOpts.Get(flags.FlagHome)), "data", "snapshots") | ||
snapshotDB, err := sdk.NewLevelDB("metadata", snapshotDir) //nolint:staticcheck | ||
if err != nil { | ||
panic(err) | ||
} | ||
snapshotStore, err := snapshots.NewStore(snapshotDB, snapshotDir) | ||
if err != nil { | ||
panic(err) | ||
} | ||
var wasmOpts []wasm.Option | ||
if cast.ToBool(appOpts.Get("telemetry.enabled")) { | ||
wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer)) | ||
} | ||
|
||
snapshotOptions := snapshottypes.NewSnapshotOptions( | ||
cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval)), | ||
cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent)), | ||
) | ||
|
||
skipUpgradeHeights := make(map[int64]bool) | ||
for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) { | ||
skipUpgradeHeights[int64(h)] = true | ||
|
@@ -269,6 +304,16 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a | |
app.GetEnabledProposals(), | ||
appOpts, | ||
wasmOpts, | ||
baseapp.SetPruning(pruningOpts), | ||
baseapp.SetInterBlockCache(cache), | ||
baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))), | ||
baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))), | ||
baseapp.SetHaltTime(cast.ToUint64(appOpts.Get(server.FlagHaltTime))), | ||
baseapp.SetMinRetainBlocks(cast.ToUint64(appOpts.Get(server.FlagMinRetainBlocks))), | ||
baseapp.SetInterBlockCache(cache), | ||
baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))), | ||
baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))), | ||
baseapp.SetSnapshot(snapshotStore, snapshotOptions), | ||
) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
# microtick and bitcanna contributed significantly here. | ||
# invoke this script in your migaloo-chain folder like this: | ||
# bash scripts/statesync.bash | ||
set -uxe | ||
|
||
# Set Golang environment variables. | ||
export GOPATH=~/go | ||
export PATH=$PATH:~/go/bin | ||
|
||
# Install Migaloo. | ||
go install ./... | ||
|
||
# NOTE: ABOVE YOU CAN USE ALTERNATIVE DATABASES, HERE ARE THE EXACT COMMANDS | ||
# go install -ldflags '-w -s -X github.com/cosmos/cosmos-sdk/types.DBBackend=rocksdb' -tags rocksdb ./... | ||
# go install -ldflags '-w -s -X github.com/cosmos/cosmos-sdk/types.DBBackend=badgerdb' -tags badgerdb ./... | ||
# go install -ldflags '-w -s -X github.com/cosmos/cosmos-sdk/types.DBBackend=boltdb' -tags boltdb ./... | ||
|
||
# Initialize chain. | ||
migalood init test | ||
|
||
# get genesis | ||
wget -O ~/.migalood/config/genesis.json https://github.com/White-Whale-Defi-Platform/migaloo-chain/raw/release/v2.0.x/networks/mainnet/genesis.json | ||
|
||
|
||
# Set minimum gas price. | ||
sed -i '' 's/minimum-gas-prices = ""/minimum-gas-prices = "0.0025uwhale"/' "$HOME/.migalood/config/app.toml" | ||
|
||
# Get "trust_hash" and "trust_height". | ||
INTERVAL=1000 | ||
LATEST_HEIGHT=$(curl -s https://rpc-whitewhale-h93nh9ykmqnzbrez-ie.internalendpoints.notional.ventures/block | jq -r .result.block.header.height) | ||
BLOCK_HEIGHT=$((LATEST_HEIGHT-INTERVAL)) | ||
TRUST_HASH=$(curl -s "https://rpc-whitewhale-h93nh9ykmqnzbrez-ie.internalendpoints.notional.ventures/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash) | ||
|
||
# Print out block and transaction hash from which to sync state. | ||
echo "trust_height: $BLOCK_HEIGHT" | ||
echo "trust_hash: $TRUST_HASH" | ||
|
||
# Export state sync variables. | ||
export MIGALOOD_STATESYNC_ENABLE=true | ||
export MIGALOOD_P2P_MAX_NUM_OUTBOUND_PEERS=200 | ||
# replace the url below with a working one | ||
export MIGALOOD_STATESYNC_RPC_SERVERS="https://rpc-whitewhale-h93nh9ykmqnzbrez-ie.internalendpoints.notional.ventures:443,http://65.108.5.173:2481" | ||
export MIGALOOD_STATESYNC_TRUST_HEIGHT=$BLOCK_HEIGHT | ||
export MIGALOOD_STATESYNC_TRUST_HASH=$TRUST_HASH | ||
|
||
# Fetch and set list of seeds from chain registry. | ||
MIGALOOD_P2P_SEEDS=$(curl -s https://raw.githubusercontent.com/cosmos/chain-registry/master/migaloo/chain.json | jq -r '[foreach .peers.seeds[] as $item (""; "\($item.id)@\($item.address)")] | join(",")') | ||
export MIGALOOD_P2P_SEEDS | ||
|
||
|
||
# Start chain. | ||
migalood start --x-crisis-skip-assert-invariants --minimum-gas-prices 0.00001uwhale |
Empty file.