Skip to content

Commit

Permalink
fix: fix gentx validation program
Browse files Browse the repository at this point in the history
  • Loading branch information
hacheetos committed Feb 16, 2024
1 parent 7249878 commit fd51d97
Show file tree
Hide file tree
Showing 5 changed files with 1,022 additions and 281 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ COPY . .

RUN go build -o validate-gentx .

CMD ["./validate-gentx"]
# CMD ["./validate-gentx"]
ENTRYPOINT ["tail", "-f", "/dev/null"]
# CMD ["sh", "-c", "./validate-gentx && tail -f /dev/null"]
41 changes: 30 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/json"
"fmt"
"io"
"log"
"math/big"
Expand All @@ -18,23 +19,23 @@ var (
/* Change as needed */
/* =================================================== */
CHAIN_ID = "seda-1-testnet"
WORKING_DIR = "./testnet/" + CHAIN_ID
BINARY_URL = "https://github.com/sedaprotocol/seda-chain/releases/download/v0.0.5/seda-chaind-amd64"
BINARY = "seda-chaind"
WORKING_DIR = "./testnet"
BINARY_URL = "https://github.com/sedaprotocol/seda-chain/releases/download/v0.0.6/sedad-amd64"
BINARY = "sedad"

/* =================================================== */
/* The followings should rarely change */
/* =================================================== */
GENTX_DIR = WORKING_DIR + "/gentx"
BINARY_PATH = "./" + BINARY
SEDA_HOME = os.Getenv("HOME") + "/.seda-chain"
SEDA_HOME = os.Getenv("HOME") + "/.sedad"
PREFIX = "seda"
DENOM = "aseda"

TEST_KEY_NAME = "test-key"
GENESIS_ALLOCATION = "1000000000000000000000000000000000000" + DENOM
DEFAULT_BOND = "300000000000000000000000000000000000" + DENOM
MAXBOND = "600000000000000000000000000000000000"
GENESIS_ALLOCATION = "1000000000000000000000000" + DENOM
DEFAULT_BOND = "1000000000000000000000000" + DENOM
MAXBOND = "600000000000000000000000000000000000" // TO-DO what number to use here?
)

func main() {
Expand Down Expand Up @@ -125,6 +126,15 @@ func validateGentx() {
log.Fatal("Error reading gentx files: ", err)
}

gentxDir := filepath.Join(SEDA_HOME, "config/gentx")
if _, err := os.Stat(gentxDir); os.IsNotExist(err) {
err := os.Mkdir(gentxDir, 0755)
if err != nil {
fmt.Println("Error creating directory:", err)
return
}
}

for i, file := range gentxFiles {
// add keys
keyName := TEST_KEY_NAME + "-" + strconv.Itoa(i)
Expand Down Expand Up @@ -181,12 +191,21 @@ func validateGentx() {
log.Fatalf("Error adding genesis account: %s", err)
}

// create gentx
_, err = exec.Command(BINARY_PATH, "gentx", keyName, DEFAULT_BOND).Output()
// // create gentx
// _, err = exec.Command(BINARY_PATH, "gentx", keyName, DEFAULT_BOND).Output()
// if err != nil {
// log.Fatal("Error creating gentx: ", err)
// }

// copy the gentx file to the node directory
data, err := os.ReadFile(file)
if err != nil {
log.Fatal("Error creating gentx: ", err)
log.Fatalf("Failed to read file: %v", err)
}
err = os.WriteFile(filepath.Join(gentxDir, filepath.Base(file)), data, 0644)
if err != nil {
log.Fatalf("Failed to write file: %v", err)
}

}

log.Println("Validating finished...")
Expand Down
Loading

0 comments on commit fd51d97

Please sign in to comment.