-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: download gaiad * chore: push the wip code * wip * feat: running a 2 validators network in cosmos-hub * wip * feat: multi chain command * feat: start all the nodes with just one command * feat: evmos multi node support * wip * fix: hermes working with 2 evmos * feat: hermes working with evmos and cosmos * chore: support evmos and gaia in start node * fix: start command using the node config * chore: remove commented code * chore: remove print * docs: update sidebar * chore: fix linter issues
- Loading branch information
Showing
53 changed files
with
2,322 additions
and
905 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
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,50 @@ | ||
package playground | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/hanchon/hanchond/playground/filesmanager" | ||
"github.com/hanchon/hanchond/playground/gaia" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// buildGaiadCmd represents the buildGaiad command | ||
var buildGaiadCmd = &cobra.Command{ | ||
Use: "build-gaiad", | ||
Short: "Get the Gaiad binary from the github releases", | ||
Long: `It downloads the already built gaiad binary from github, it accepts a version flag to specify any tag. It defaults to: v1.9.0.`, | ||
Run: func(cmd *cobra.Command, _ []string) { | ||
_ = filesmanager.SetHomeFolderFromCobraFlags(cmd) | ||
version, err := cmd.Flags().GetString("version") | ||
if err != nil { | ||
fmt.Println("could not read the version:", err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
isDarwin, err := cmd.Flags().GetBool("is-darwin") | ||
if err != nil { | ||
fmt.Println("could not read the isDarwin:", err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
// Create build folder if needed | ||
if err := filesmanager.CreateBuildsDir(); err != nil { | ||
fmt.Println("could not create build folder:" + err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
fmt.Println("Downloading gaiad from github:", version) | ||
if err = gaia.GetGaiadBinary(isDarwin, version); err != nil { | ||
fmt.Println("could not get gaiad from github:" + err.Error()) | ||
os.Exit(1) | ||
} | ||
fmt.Println("Gaiad is now available") | ||
}, | ||
} | ||
|
||
func init() { | ||
PlaygroundCmd.AddCommand(buildGaiadCmd) | ||
buildGaiadCmd.PersistentFlags().StringP("version", "v", "v18.1.0", "Gaiad version to download") | ||
buildGaiadCmd.PersistentFlags().Bool("is-darwin", true, "Is the system MacOS arm?") | ||
} |
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,150 @@ | ||
package playground | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"strconv" | ||
|
||
"github.com/hanchon/hanchond/playground/database" | ||
"github.com/hanchon/hanchond/playground/filesmanager" | ||
"github.com/hanchon/hanchond/playground/gaia" | ||
"github.com/hanchon/hanchond/playground/sql" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// initGaiaCmd represents the initGaia command | ||
var initGaiaCmd = &cobra.Command{ | ||
Use: "init-gaia id", | ||
Args: cobra.ExactArgs(1), | ||
Short: "Init the genesis file for a new chain", | ||
Long: `Set up the data and config folder for the new chain`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
queries := sql.InitDBFromCmd(cmd) | ||
_ = queries | ||
|
||
chainid, err := strconv.ParseInt(args[0], 10, 64) | ||
if err != nil { | ||
fmt.Println("invalid chain id, it must be integer", err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
if filesmanager.IsNodeHomeFolderInitialized(chainid, 0) { | ||
fmt.Println("the home folder for this node was already created") | ||
os.Exit(1) | ||
} | ||
|
||
chainID := "cosmoshub-99" | ||
|
||
nodes := make([]*gaia.Gaia, 2) | ||
|
||
var chainDB database.Chain | ||
|
||
for k := range nodes { | ||
path := filesmanager.GetNodeHomeFolder(chainid, int64(k)) | ||
g := gaia.NewGaia(fmt.Sprintf("moniker-%d-%d", chainid, k), path, chainID, "validator-key", "icsstake") | ||
// Init the config files | ||
if err := g.InitNode(); err != nil { | ||
panic(err) | ||
} | ||
// Update general parameters in the genesis file | ||
if err := g.UpdateGenesisFile(); err != nil { | ||
panic(err) | ||
} | ||
if err := g.UpdateConfigFile(false); err != nil { | ||
panic(err) | ||
} | ||
if err := g.UpdateAppFile(); err != nil { | ||
panic(err) | ||
} | ||
if err := g.CreateGenTx(); err != nil { | ||
panic(err) | ||
} | ||
// Assign random and unique ports | ||
if err := g.AssignPorts(queries); err != nil { | ||
panic(err) | ||
} | ||
// Update the Config Files | ||
if err := g.UpdateConfigPorts(); err != nil { | ||
panic(err) | ||
} | ||
|
||
nodes[k] = g | ||
if k == 0 { | ||
chainDB, err = g.SaveChainToDB(queries) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
_, err := g.SaveNodeToDB(chainDB, queries) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
// Join genesis transactions | ||
for k, v := range nodes { | ||
if k == 0 { | ||
continue | ||
} | ||
files, err := filepath.Glob(v.HomeDir + "/config/gentx/*.json") | ||
if err != nil { | ||
panic("no files: " + err.Error()) | ||
} | ||
if len(files) == 0 { | ||
panic("no files 2: " + err.Error()) | ||
} | ||
|
||
if err := filesmanager.CopyFile( | ||
files[0], | ||
nodes[0].HomeDir+"/config/gentx", | ||
); err != nil { | ||
panic(err) | ||
} | ||
addr, err := v.GetValidatorAddress() | ||
if err != nil { | ||
panic(err) | ||
} | ||
if err := nodes[0].AddGenesisAccount(addr); err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
if err := nodes[0].CollectGenTxs(); err != nil { | ||
panic(err) | ||
} | ||
if err := nodes[0].ValidateGenesis(); err != nil { | ||
panic(err) | ||
} | ||
|
||
peers := []string{} | ||
for k := range nodes { | ||
peerInfo, err := nodes[k].GetPeerInfo() | ||
if err != nil { | ||
panic(err) | ||
} | ||
peers = append(peers, peerInfo) | ||
|
||
if k == 0 { | ||
continue | ||
} | ||
if err := filesmanager.CopyFile( | ||
nodes[0].HomeDir+"/config/genesis.json", | ||
nodes[k].HomeDir+"/config/genesis.json", | ||
); err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
for k := range nodes { | ||
if err := nodes[k].AddPersistenPeers(peers); err != nil { | ||
panic(err) | ||
} | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
PlaygroundCmd.AddCommand(initGaiaCmd) | ||
initGaiaCmd.Flags().StringP("version", "v", "local", "Version of the Evmos node that you want to use, defaults to local. Tag names are supported.") | ||
} |
Oops, something went wrong.