Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support sequencer reward and relayer addr upon sequencer creation #1094

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
48 changes: 44 additions & 4 deletions utils/sequencer/sequencer.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package sequencer

// TODO: most of the functions here should be a part of sequencer_manager

import (
"encoding/json"
"fmt"
Expand All @@ -25,10 +27,13 @@
"github.com/dymensionxyz/roller/utils/tx"
)

func Register(raCfg roller.RollappConfig, desiredBond cosmossdktypes.Coin) error {
func getCreateSequencerCmd(
raCfg roller.RollappConfig,
desiredBond cosmossdktypes.Coin,
) (*exec.Cmd, error) {
seqPubKey, err := keys.GetSequencerPubKey(raCfg)
if err != nil {
return err
return nil, err
}

seqMetadataPath := filepath.Join(
Expand All @@ -37,14 +42,30 @@
"init",
"sequencer-metadata.json",
)

_, err = isValidSequencerMetadata(seqMetadataPath)
if err != nil {
return err
return nil, err
}

home := roller.GetRootDir()
customRewardAddress, _ := pterm.DefaultInteractiveTextInput.WithDefaultText(
"would you like to use a custom reward address (leave empty to use the sequencer address)",
).Show()
customRewardAddress = strings.TrimSpace(customRewardAddress)

// TODO: improve ux
relayerAddresses, _ := pterm.DefaultInteractiveTextInput.WithDefaultText(
"provide a comma separated list of addresses that you want to enable relay IBC packets (example: addr1,addr2)",
).Show()
relayerAddresses = strings.TrimSpace(relayerAddresses)

cmd := exec.Command(
consts.Executables.Dymension,

home := raCfg.Home

Check failure on line 65 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected := in argument list; possibly missing comma or )

Check failure on line 65 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected := in argument list; possibly missing comma or )

Check failure on line 65 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected := in argument list; possibly missing comma or )

Check failure on line 65 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / build

syntax error: unexpected := in argument list; possibly missing comma or )

args := []string{

Check failure on line 67 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected ] at end of statement

Check failure on line 67 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected ] at end of statement

Check failure on line 67 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected ] at end of statement

Check failure on line 67 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / build

syntax error: unexpected ] at end of statement

"tx",
"sequencer",
"create-sequencer",
Expand All @@ -61,6 +82,25 @@
"--node", raCfg.HubData.RpcUrl, "--chain-id", raCfg.HubData.ID,
}

if customRewardAddress != "" {

Check failure on line 85 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: non-declaration statement outside function body) (typecheck)

Check failure on line 85 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: non-declaration statement outside function body) (typecheck)

Check failure on line 85 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / build

syntax error: non-declaration statement outside function body
args := []string{"--reward-address", customRewardAddress}
cmd.Args = append(cmd.Args, args...)
}

if relayerAddresses != "" {
args := []string{"--whitelisted-relayers", relayerAddresses}
cmd.Args = append(cmd.Args, args...)
}

return cmd, err
}

func Register(raCfg roller.RollappConfig, desiredBond cosmossdktypes.Coin) error {
cmd, err := getCreateSequencerCmd(raCfg, desiredBond)
if err != nil {
return err
}

displayBond, err := BaseDenomToDenom(desiredBond, 18)
if err != nil {
return err
Expand Down
Loading