Skip to content

Commit

Permalink
chore: release v1.7.0-alpha-rc01
Browse files Browse the repository at this point in the history
Release-As: v1.7.0-alpha-pre-rc

chore: ci
  • Loading branch information
github-actions[bot] authored and artemijspavlovs committed Sep 19, 2024
1 parent 4890bc7 commit a2397a5
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 98 deletions.
7 changes: 5 additions & 2 deletions cmd/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ const RollerConfigFileName = "roller.toml"
type VMType string

const (
SDK_ROLLAPP VMType = "sdk"
EVM_ROLLAPP VMType = "evm"
SDK_ROLLAPP VMType = "sdk"
EVM_ROLLAPP VMType = "evm"
WASM_ROLLAPP VMType = "wasm"
)

func ToVMType(s string) (VMType, error) {
Expand All @@ -136,6 +137,8 @@ func ToVMType(s string) (VMType, error) {
return SDK_ROLLAPP, nil
case string(EVM_ROLLAPP):
return EVM_ROLLAPP, nil
case string(WASM_ROLLAPP):
return WASM_ROLLAPP, nil
default:
return "", fmt.Errorf("invalid VMType: %s", s)
}
Expand Down
1 change: 1 addition & 0 deletions cmd/relayer/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func Cmd() *cobra.Command {
home,
rollappConfig.RollappID,
&hd,
string(rollappConfig.VMType),
)
errorhandling.PrettifyErrorIfExists(err)

Expand Down
7 changes: 3 additions & 4 deletions cmd/rollapp/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func Cmd() *cobra.Command {
).Show()
}

pterm.Info.Println("validating RollApp ID: ", raID)
_, err = rollapp.ValidateChainID(raID)
if err != nil {
pterm.Error.Println("failed to validate chain id: ", err)
Expand All @@ -93,15 +92,15 @@ func Cmd() *cobra.Command {
if env == "mock" {
vmtypes := []string{"evm", "wasm"}
vmtype, _ := pterm.DefaultInteractiveSelect.
WithDefaultText("select the environment you want to initialize for").
WithDefaultText("select the rollapp VM type you want to initialize for").
WithOptions(vmtypes).
Show()
err = dependencies.InstallBinaries(env, true, vmtype)
if err != nil {
pterm.Error.Println("failed to install binaries: ", err)
return
}
err := runInit(cmd, env, raID)
err := runInit(cmd, env, raID, vmtype)
if err != nil {
fmt.Println("failed to run init: ", err)
return
Expand Down Expand Up @@ -172,7 +171,7 @@ func Cmd() *cobra.Command {
return
}

err = runInit(cmd, env, raID)
err = runInit(cmd, env, raID, strings.ToLower(raResponse.Rollapp.VmType))
if err != nil {
pterm.Error.Printf("failed to initialize the RollApp: %v\n", err)
return
Expand Down
4 changes: 3 additions & 1 deletion cmd/rollapp/init/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ import (
"github.com/dymensionxyz/roller/utils/sequencer"
)

func runInit(cmd *cobra.Command, env string, raID string) error {
// nolint: gocyclo
func runInit(cmd *cobra.Command, env, raID, vmType string) error {
home, err := filesystem.ExpandHomePath(cmd.Flag(cmdutils.FlagNames.Home).Value.String())
if err != nil {
pterm.Error.Println("failed to expand home directory")
Expand Down Expand Up @@ -134,6 +135,7 @@ func runInit(cmd *cobra.Command, env string, raID string) error {
home,
raID,
&hd,
vmType,
)
if err != nil {
errorhandling.PrettifyErrorIfExists(err)
Expand Down
1 change: 1 addition & 0 deletions cmd/rollapp/sequencer/metadata/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func Cmd() *cobra.Command {
home,
rollerData.RollappID,
&hd,
string(rollerData.VMType),
)
errorhandling.PrettifyErrorIfExists(err)

Expand Down
79 changes: 9 additions & 70 deletions cmd/rollapp/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func Cmd() *cobra.Command {
home,
rollerData.RollappID,
&hd,
string(rollerData.VMType),
)
errorhandling.PrettifyErrorIfExists(err)

Expand Down Expand Up @@ -129,6 +130,13 @@ func Cmd() *cobra.Command {
WithOptions(options).
Show()

rollerConfigFilePath := filepath.Join(home, consts.RollerConfigFileName)
err = globalutils.UpdateFieldInToml(rollerConfigFilePath, "node_type", nodeType)
if err != nil {
pterm.Error.Println("failed to update node type in roller config file: ", err)
return
}

switch nodeType {
case "sequencer":
pterm.Info.Println("getting the existing sequencer address ")
Expand Down Expand Up @@ -502,7 +510,6 @@ func Cmd() *cobra.Command {
}

// DA
oh := initconfig.NewOutputHandler(false)
damanager := datalayer.NewDAManager(rollappConfig.DA.Backend, rollappConfig.Home)
daHome := filepath.Join(
damanager.GetRootDirectory(),
Expand All @@ -516,27 +523,7 @@ func Cmd() *cobra.Command {

var shouldOverwrite bool
if isDaInitialized {
pterm.Info.Println("DA client is already initialized")
oh.StopSpinner()
shouldOverwrite, err = oh.PromptOverwriteConfig(daHome)
if err != nil {
return
}
}

if shouldOverwrite {
pterm.Info.Println("overriding the existing da configuration")
err := os.RemoveAll(daHome)
if err != nil {
pterm.Error.Printf("failed to remove %s: %v\n", daHome, err)
return
}

err = os.MkdirAll(daHome, 0o755)
if err != nil {
pterm.Error.Printf("failed to create %s: %v\n", daHome, err)
return
}
pterm.Warning.Println("DA client is already initialized")
}

if !isDaInitialized || shouldOverwrite {
Expand Down Expand Up @@ -758,54 +745,6 @@ func Cmd() *cobra.Command {
return cmd
}

func printOutput(rlpCfg config.RollappConfig, cmd *exec.Cmd) {
seq := sequencer.GetInstance(rlpCfg)
pterm.DefaultSection.WithIndentCharacter("💈 ").
Println("The Rollapp sequencer is running on your local machine!")
fmt.Println("💈 Endpoints:")

fmt.Printf("EVM RPC: http://127.0.0.1:%v\n", seq.JsonRPCPort)
fmt.Printf("Node RPC: http://127.0.0.1:%v\n", seq.RPCPort)
fmt.Printf("Rest API: http://127.0.0.1:%v\n", seq.APIPort)

fmt.Println("💈 Log file path: ", LogPath)
fmt.Println("💈 Rollapp root dir: ", RollappDirPath)
fmt.Printf(
"💈 PID: %d (saved in %s)\n",
cmd.Process.Pid,
filepath.Join(rlpCfg.Home, "rollapputils.pid"),
)
}

func createPidFile(path string, cmd *exec.Cmd) error {
pidPath := filepath.Join(path, "rollapputils.pid")
file, err := os.Create(pidPath)
if err != nil {
fmt.Println("Error creating file:", err)
return err
}
// nolint errcheck
defer file.Close()

pid := cmd.Process.Pid
_, err = file.WriteString(fmt.Sprintf("%d", pid))
if err != nil {
fmt.Println("Error writing to file:", err)
return err
}

return nil
}

func parseError(errMsg string) string {
lines := strings.Split(errMsg, "\n")
if len(lines) > 0 &&
lines[0] == "Error: failed to initialize database: resource temporarily unavailable" {
return "The Rollapp sequencer is already running on your local machine. Only one sequencer can run at any given time."
}
return errMsg
}

func populateSequencerMetadata(raCfg config.RollappConfig) error {
cd := dymensionseqtypes.ContactDetails{
Website: "",
Expand Down
14 changes: 9 additions & 5 deletions cmd/rollapp/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ Consider using 'services' if you want to run a 'systemd' service instead.
LogPath = filepath.Join(rollappConfig.Home, consts.ConfigDirName.Rollapp, "rollapp.log")
RollappDirPath = filepath.Join(rollappConfig.Home, consts.ConfigDirName.Rollapp)

fmt.Println(startRollappCmd.String())
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go bash.RunCmdAsync(
Expand Down Expand Up @@ -117,12 +116,15 @@ func PrintOutput(
msg = pterm.DefaultBasicText.WithStyle(
pterm.
FgGreen.ToStyle(),
).Sprintf("💈 The Rollapp sequencer is running on your local machine!")
).Sprintf("💈 The Rollapp %s is running on your local machine!", rlpCfg.NodeType)
} else {
msg = pterm.DefaultBasicText.WithStyle(
pterm.
FgRed.ToStyle(),
).Sprintf("❗ The Rollapp sequencer is in unhealthy state. Please check the logs for more information.")
).Sprintf(
"❗ The Rollapp %s is in unhealthy state. Please check the logs for more information.",
rlpCfg.NodeType,
)
}

fmt.Println(msg)
Expand All @@ -135,7 +137,9 @@ func PrintOutput(
if withEndpoints {
pterm.DefaultSection.WithIndentCharacter("💈").
Println("Endpoints:")
fmt.Printf("EVM RPC: http://0.0.0.0:%v\n", seq.JsonRPCPort)
if rlpCfg.VMType == "evm" {
fmt.Printf("EVM RPC: http://0.0.0.0:%v\n", seq.JsonRPCPort)
}
fmt.Printf("Node RPC: http://0.0.0.0:%v\n", seq.RPCPort)
fmt.Printf("Rest API: http://0.0.0.0:%v\n", seq.APIPort)
}
Expand All @@ -159,7 +163,7 @@ func PrintOutput(
pterm.DefaultSection.WithIndentCharacter("💈").
Println("Wallet Info:")
fmt.Println("Sequencer Address:", seqAddrData[0].Address)
if withBalance {
if withBalance && rlpCfg.NodeType == "sequencer" {
fmt.Println("Sequencer Balance:", seqAddrData[0].Balance.String())
go func() {
for {
Expand Down
4 changes: 3 additions & 1 deletion utils/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"strings"
"unicode"

"github.com/pterm/pterm"

"github.com/dymensionxyz/roller/cmd/consts"
globalutils "github.com/dymensionxyz/roller/utils"
"github.com/pterm/pterm"
)

var SupportedDas = []consts.DAType{consts.Celestia, consts.Avail, consts.Local}
Expand All @@ -20,6 +21,7 @@ type RollappConfig struct {
RollappID string `toml:"rollapp_id"`
RollappBinary string `toml:"rollapp_binary"`
VMType consts.VMType `toml:"execution"`
NodeType string `toml:"node_type"`
Denom string `toml:"denom"`
// TokenSupply string
Decimals uint
Expand Down
8 changes: 6 additions & 2 deletions utils/config/tomlconfig/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,21 @@ func Load(path string) ([]byte, error) {

func LoadRollappMetadataFromChain(
home, raID string,
hd *consts.HubData,
hd *consts.HubData, vmType string,
) (*config.RollappConfig, error) {
var cfg config.RollappConfig
vmt, err := consts.ToVMType(vmType)
if err != nil {
return nil, err
}
if hd.ID == "mock" {
cfg = config.RollappConfig{
Home: home,
RollappID: raID,
GenesisHash: "",
GenesisUrl: "",
RollappBinary: consts.Executables.RollappEVM,
VMType: consts.EVM_ROLLAPP,
VMType: vmt,
Denom: "mock",
Decimals: 18,
HubData: *hd,
Expand Down
8 changes: 4 additions & 4 deletions utils/dependencies/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ func InstallBinaries(bech32 string, withMockDA bool, vmType string) error {
}
} else if vmType == "wasm" {
goreleaserDeps["rollapp"] = types.Dependency{
Name: "rollapp-evm",
Name: "rollapp-wasm",
Repository: "https://github.com/artemijspavlovs/rollapp-wasm",
Release: "v1.0.0-rc04-roller-02",
Release: "v1.0.0-rc04-roller-03",
Binaries: []types.BinaryPathPair{
{
Binary: "rollappd",
Expand Down Expand Up @@ -228,7 +228,7 @@ func InstallBinaries(bech32 string, withMockDA bool, vmType string) error {

func InstallBinaryFromRepo(dep types.Dependency, td string) error {
spinner, _ := pterm.DefaultSpinner.Start(
fmt.Sprintf("Installing %s\n", dep.Name),
fmt.Sprintf("Installing %s", dep.Name),
)
targetDir, err := os.MkdirTemp(os.TempDir(), td)
if err != nil {
Expand Down Expand Up @@ -294,7 +294,7 @@ func InstallBinaryFromRepo(dep types.Dependency, td string) error {

func InstallBinaryFromRelease(dep types.Dependency) error {
spinner, _ := pterm.DefaultSpinner.Start(
fmt.Sprintf("Installing %s\n", dep.Name),
fmt.Sprintf("Installing %s", dep.Name),
)
goOs := strings.Title(runtime.GOOS)
goArch := strings.ToLower(runtime.GOARCH)
Expand Down
2 changes: 1 addition & 1 deletion utils/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func ExpandHomePath(path string) (string, error) {
// TODO: download the file in chunks if possible
func DownloadFile(url, fp string) error {
spinner, _ := pterm.DefaultSpinner.
Start("Downloading file file from ", url)
Start(fmt.Sprintf("Downloading file from %s", url))

// nolint:gosec
resp, err := http.Get(url)
Expand Down
28 changes: 22 additions & 6 deletions utils/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import (
"strings"

"github.com/cometbft/cometbft/types"
"github.com/pterm/pterm"

"github.com/dymensionxyz/roller/cmd/consts"
"github.com/dymensionxyz/roller/utils/bash"
"github.com/dymensionxyz/roller/utils/config"
"github.com/dymensionxyz/roller/utils/config/jsonconfig"
"github.com/dymensionxyz/roller/utils/filesystem"
"github.com/dymensionxyz/roller/utils/rollapp"
"github.com/dymensionxyz/roller/utils/sequencer"
"github.com/pterm/pterm"
)

type AppState struct {
Expand Down Expand Up @@ -244,14 +245,13 @@ func UpdateGenesisParams(home string, raCfg *config.RollappConfig) error {
func getDefaultGenesisParams(
raCfg *config.RollappConfig,
) []config.PathValue {
return []config.PathValue{
var params []config.PathValue

commonParams := []config.PathValue{
{Path: "app_state.mint.params.mint_denom", Value: raCfg.BaseDenom},
{Path: "app_state.staking.params.bond_denom", Value: raCfg.BaseDenom},
{Path: "app_state.evm.params.evm_denom", Value: raCfg.BaseDenom},
{Path: "app_state.gov.deposit_params.min_deposit.0.denom", Value: raCfg.BaseDenom},
{Path: "consensus_params.block.max_gas", Value: "40000000"},
{Path: "app_state.feemarket.params.no_base_fee", Value: true},
{Path: "app_state.feemarket.params.min_gas_price", Value: "0.0"},
{Path: "app_state.distribution.params.base_proposer_reward", Value: "0.8"},
{Path: "app_state.distribution.params.community_tax", Value: "0.00002"},
{Path: "app_state.gov.voting_params.voting_period", Value: "300s"},
Expand All @@ -260,9 +260,25 @@ func getDefaultGenesisParams(
Path: "app_state.bank.denom_metadata",
Value: getBankDenomMetadata(raCfg.BaseDenom, raCfg.Decimals),
},
{Path: "app_state.evm.params.extra_eips", Value: []string{"3855"}},
{Path: "app_state.claims.params.claims_denom", Value: raCfg.BaseDenom},
}

if raCfg.VMType == consts.WASM_ROLLAPP {
wasmParams := []config.PathValue{}
params = append(commonParams, wasmParams...)
}

if raCfg.VMType == consts.EVM_ROLLAPP {
evmParams := []config.PathValue{
{Path: "app_state.evm.params.evm_denom", Value: raCfg.BaseDenom},
{Path: "app_state.feemarket.params.no_base_fee", Value: true},
{Path: "app_state.evm.params.extra_eips", Value: []string{"3855"}},
{Path: "app_state.feemarket.params.min_gas_price", Value: "0.0"},
}
params = append(commonParams, evmParams...)
}

return params
}

func getBankDenomMetadata(denom string, decimals uint) []BankDenomMetadata {
Expand Down
Loading

0 comments on commit a2397a5

Please sign in to comment.