forked from dymensionxyz/dymint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created makefile and updated readme (dymensionxyz#129)
* Added a make file and updated the readme accordingly. * Updated markdownlint.yaml to ignore html tags.
- Loading branch information
1 parent
e185578
commit d63ca39
Showing
11 changed files
with
595 additions
and
14 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 |
---|---|---|
|
@@ -4,4 +4,5 @@ MD010: | |
MD013: false | ||
MD024: | ||
allow_different_nesting: true | ||
|
||
MD033: | ||
allowed_elements: ["img"] |
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,100 @@ | ||
PACKAGES=$(shell go list ./...) | ||
BUILDDIR?=$(CURDIR)/build | ||
OUTPUT?=$(BUILDDIR)/dymint | ||
|
||
BUILD_TAGS?=dymint | ||
|
||
COMMIT_HASH := $(shell git rev-parse --short HEAD) | ||
LD_FLAGS = -X github.com/dymensionxyz/dymint/version.DymintGitCommitHash=$(COMMIT_HASH) | ||
BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)" | ||
CGO_ENABLED ?= 0 | ||
|
||
# allow users to pass additional flags via the conventional LDFLAGS variable | ||
LD_FLAGS += $(LDFLAGS) | ||
|
||
# Process Docker environment varible TARGETPLATFORM | ||
# in order to build binary with correspondent ARCH | ||
# by default will always build for linux/amd64 | ||
TARGETPLATFORM ?= | ||
GOOS ?= linux | ||
GOARCH ?= amd64 | ||
GOARM ?= | ||
|
||
ifeq (linux/arm,$(findstring linux/arm,$(TARGETPLATFORM))) | ||
GOOS=linux | ||
GOARCH=arm | ||
GOARM=7 | ||
endif | ||
|
||
ifeq (linux/arm/v6,$(findstring linux/arm/v6,$(TARGETPLATFORM))) | ||
GOOS=linux | ||
GOARCH=arm | ||
GOARM=6 | ||
endif | ||
|
||
ifeq (linux/arm64,$(findstring linux/arm64,$(TARGETPLATFORM))) | ||
GOOS=linux | ||
GOARCH=arm64 | ||
GOARM=7 | ||
endif | ||
|
||
ifeq (linux/386,$(findstring linux/386,$(TARGETPLATFORM))) | ||
GOOS=linux | ||
GOARCH=386 | ||
endif | ||
|
||
ifeq (linux/amd64,$(findstring linux/amd64,$(TARGETPLATFORM))) | ||
GOOS=linux | ||
GOARCH=amd64 | ||
endif | ||
|
||
ifeq (linux/mips,$(findstring linux/mips,$(TARGETPLATFORM))) | ||
GOOS=linux | ||
GOARCH=mips | ||
endif | ||
|
||
ifeq (linux/mipsle,$(findstring linux/mipsle,$(TARGETPLATFORM))) | ||
GOOS=linux | ||
GOARCH=mipsle | ||
endif | ||
|
||
ifeq (linux/mips64,$(findstring linux/mips64,$(TARGETPLATFORM))) | ||
GOOS=linux | ||
GOARCH=mips64 | ||
endif | ||
|
||
ifeq (linux/mips64le,$(findstring linux/mips64le,$(TARGETPLATFORM))) | ||
GOOS=linux | ||
GOARCH=mips64le | ||
endif | ||
|
||
ifeq (linux/riscv64,$(findstring linux/riscv64,$(TARGETPLATFORM))) | ||
GOOS=linux | ||
GOARCH=riscv64 | ||
endif | ||
|
||
all: check build test install | ||
.PHONY: all | ||
|
||
include tests.mk | ||
|
||
############################################################################### | ||
### Build Dymint ### | ||
############################################################################### | ||
|
||
build: | ||
CGO_ENABLED=$(CGO_ENABLED) go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o $(OUTPUT) ./cmd/dymint | ||
.PHONY: build | ||
|
||
install: | ||
CGO_ENABLED=$(CGO_ENABLED) go install $(BUILD_FLAGS) -tags $(BUILD_TAGS) ./cmd/dymint | ||
.PHONY: install | ||
|
||
############################################################################### | ||
### Protobuf ### | ||
############################################################################### | ||
|
||
proto-gen: | ||
@echo "Generating Protobuf files.." | ||
$(shell ./proto/gen.sh) | ||
.PHONY: proto-gen |
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 |
---|---|---|
@@ -1,29 +1,87 @@ | ||
# dymint | ||
# Dymint | ||
|
||
<img src="docs/dymint.png" alt="banner" width="830"/> | ||
|
||
ABCI-client implementation for dYmenion's autonomous RollApp forked from [celestiaorg/optimint](https://github.com/celestiaorg/optimint). | ||
|
||
To learn more about dYmension's autonomous RollApps and dymint read the [docs](https://docs.dymension.xyz/learn/rollapps) | ||
To learn more about dYmension's autonomous RollApps and dymint read the [docs](https://docs.dymension.xyz/learn/rollapps). | ||
|
||
 | ||
 | ||
 | ||
 | ||
 | ||
|
||
## Installation | ||
|
||
### From Binary | ||
|
||
## Building From Source | ||
To download pre-built binaries, see the [releases page](https://github.com/dymensionxyz/dymint/releases). | ||
|
||
Requires Go version >= 1.18. If you need to install Go on your system, head to the [Go download and install page](https://go.dev/doc/install). | ||
## From Source | ||
|
||
You'll need `go` 1.18 [installed](https://golang.org/doc/install) and the required | ||
environment variables set, which can be done with the following commands: | ||
|
||
```sh | ||
echo export GOPATH=\"\$HOME/go\" >> ~/.bash_profile | ||
echo export PATH=\"\$PATH:\$GOPATH/bin\" >> ~/.bash_profile | ||
``` | ||
|
||
To build: | ||
### Get Source Code | ||
|
||
```sh | ||
git clone https://github.com/dymensionxyz/dymint.git | ||
cd dymint | ||
go build -v ./... | ||
``` | ||
|
||
To test: | ||
### Compile | ||
|
||
to put the binary in `$GOPATH/bin`: | ||
|
||
```sh | ||
make install | ||
``` | ||
|
||
or to put the binary in `./build`: | ||
|
||
```sh | ||
make build | ||
``` | ||
|
||
The latest Dymint is now installed. You can verify the installation by | ||
running: | ||
|
||
```sh | ||
dymint | ||
``` | ||
|
||
## Run | ||
|
||
To run a sequencer with a simple in-process (kvstore) application: | ||
|
||
```sh | ||
dymint init | ||
dymint start --proxy_app=kvstore | ||
``` | ||
|
||
## Reinstall | ||
|
||
If you already have Dymint installed, and you make updates, simply | ||
|
||
```sh | ||
make install | ||
``` | ||
|
||
To upgrade, run | ||
|
||
```sh | ||
go test ./... | ||
git pull origin main | ||
make install | ||
``` | ||
|
||
To regenerate protobuf types: | ||
## Regenerate protobuf | ||
|
||
```sh | ||
./proto/gen.sh | ||
make proto-gen | ||
``` |
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,81 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
cfg "github.com/tendermint/tendermint/config" | ||
tmos "github.com/tendermint/tendermint/libs/os" | ||
tmrand "github.com/tendermint/tendermint/libs/rand" | ||
"github.com/tendermint/tendermint/p2p" | ||
"github.com/tendermint/tendermint/privval" | ||
"github.com/tendermint/tendermint/types" | ||
tmtime "github.com/tendermint/tendermint/types/time" | ||
) | ||
|
||
// InitFilesCmd initialises a fresh Dymint Core instance. | ||
var InitFilesCmd = &cobra.Command{ | ||
Use: "init", | ||
Short: "Initialize Dymint", | ||
RunE: initFiles, | ||
} | ||
|
||
func initFiles(cmd *cobra.Command, args []string) error { | ||
return initFilesWithConfig(tmconfig) | ||
} | ||
|
||
func initFilesWithConfig(config *cfg.Config) error { | ||
// private validator | ||
privValKeyFile := config.PrivValidatorKeyFile() | ||
privValStateFile := config.PrivValidatorStateFile() | ||
var pv *privval.FilePV | ||
if tmos.FileExists(privValKeyFile) { | ||
pv = privval.LoadFilePV(privValKeyFile, privValStateFile) | ||
logger.Info("Found private validator", "keyFile", privValKeyFile, | ||
"stateFile", privValStateFile) | ||
} else { | ||
pv = privval.GenFilePV(privValKeyFile, privValStateFile) | ||
pv.Save() | ||
logger.Info("Generated private validator", "keyFile", privValKeyFile, | ||
"stateFile", privValStateFile) | ||
} | ||
|
||
nodeKeyFile := config.NodeKeyFile() | ||
if tmos.FileExists(nodeKeyFile) { | ||
logger.Info("Found node key", "path", nodeKeyFile) | ||
} else { | ||
if _, err := p2p.LoadOrGenNodeKey(nodeKeyFile); err != nil { | ||
return err | ||
} | ||
logger.Info("Generated node key", "path", nodeKeyFile) | ||
} | ||
|
||
// genesis file | ||
genFile := config.GenesisFile() | ||
if tmos.FileExists(genFile) { | ||
logger.Info("Found genesis file", "path", genFile) | ||
} else { | ||
genDoc := types.GenesisDoc{ | ||
ChainID: fmt.Sprintf("test-chain-%v", tmrand.Str(6)), | ||
GenesisTime: tmtime.Now(), | ||
ConsensusParams: types.DefaultConsensusParams(), | ||
} | ||
pubKey, err := pv.GetPubKey() | ||
if err != nil { | ||
return fmt.Errorf("can't get pubkey: %w", err) | ||
} | ||
genDoc.Validators = []types.GenesisValidator{{ | ||
Address: pubKey.Address(), | ||
PubKey: pubKey, | ||
Power: 10, | ||
}} | ||
|
||
if err := genDoc.SaveAs(genFile); err != nil { | ||
return err | ||
} | ||
logger.Info("Generated genesis file", "path", genFile) | ||
} | ||
|
||
return nil | ||
} |
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,97 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
|
||
"github.com/dymensionxyz/dymint/config" | ||
cfg "github.com/tendermint/tendermint/config" | ||
"github.com/tendermint/tendermint/libs/cli" | ||
tmflags "github.com/tendermint/tendermint/libs/cli/flags" | ||
"github.com/tendermint/tendermint/libs/log" | ||
) | ||
|
||
var ( | ||
tmconfig = cfg.DefaultConfig() | ||
dymconfig = config.DefaultNodeConfig | ||
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout)) | ||
) | ||
|
||
func init() { | ||
registerFlagsRootCmd(RootCmd) | ||
} | ||
|
||
func registerFlagsRootCmd(cmd *cobra.Command) { | ||
cmd.PersistentFlags().String("log_level", tmconfig.LogLevel, "log level") | ||
} | ||
|
||
// ParseConfig retrieves the default environment configuration, | ||
// sets up the Dymint root and ensures that the root exists | ||
func ParseConfig(cmd *cobra.Command) (*cfg.Config, error) { | ||
conf := cfg.DefaultConfig() | ||
err := viper.Unmarshal(conf) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var home string | ||
if os.Getenv("DYMINTHOME") != "" { | ||
home = os.Getenv("DYMINTHOME") | ||
} else { | ||
home, err = cmd.Flags().GetString(cli.HomeFlag) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
conf.RootDir = home | ||
|
||
conf.SetRoot(conf.RootDir) | ||
cfg.EnsureRoot(conf.RootDir) | ||
if err := conf.ValidateBasic(); err != nil { | ||
return nil, fmt.Errorf("error in config file: %v", err) | ||
} | ||
|
||
return conf, nil | ||
} | ||
|
||
// RootCmd is the root command for Dymint core. | ||
var RootCmd = &cobra.Command{ | ||
Use: "dymint", | ||
Short: "ABCI-client implementation for dYmenion's autonomous rollapps", | ||
PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) { | ||
v := viper.GetViper() | ||
err = v.BindPFlags(cmd.Flags()) | ||
if err != nil { | ||
return err | ||
} | ||
err = dymconfig.GetViperConfig(v) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
tmconfig, err = ParseConfig(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if tmconfig.LogFormat == cfg.LogFormatJSON { | ||
logger = log.NewTMJSONLogger(log.NewSyncWriter(os.Stdout)) | ||
} | ||
|
||
logger, err = tmflags.ParseLogLevel(tmconfig.LogLevel, logger, cfg.DefaultLogLevel) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if viper.GetBool(cli.TraceFlag) { | ||
logger = log.NewTracingLogger(logger) | ||
} | ||
|
||
logger = logger.With("module", "main") | ||
return nil | ||
}, | ||
} |
Oops, something went wrong.