Skip to content

Commit

Permalink
feat: handle sequencer reward address (#866)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs authored Aug 28, 2024
1 parent 378dc5c commit 87f3765
Show file tree
Hide file tree
Showing 23 changed files with 449 additions and 138 deletions.
20 changes: 4 additions & 16 deletions cmd/config/init/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type PathValue struct {

// TODO(#130): fix to support epochs
func getDefaultGenesisParams(
sequencerAddr, genesisOperatorAddress string, raCfg *config.RollappConfig,
sequencerAddr string, raCfg *config.RollappConfig,
) []PathValue {
return []PathValue{
// these should be injected from the genesis creator
Expand All @@ -37,12 +37,6 @@ func getDefaultGenesisParams(
{"app_state.distribution.params.community_tax", "0.00002"},
{"app_state.gov.voting_params.voting_period", "300s"},
{"app_state.bank.denom_metadata", getBankDenomMetadata(raCfg.BaseDenom, raCfg.Decimals)},

{"app_state.sequencers.genesis_operator_address", genesisOperatorAddress},
// {
// "app_state.hubgenesis.params.genesis_triggerer_allowlist.0",
// map[string]string{"address": sequencerAddr},
// },
{"app_state.denommetadata.params.allowed_addresses.0", sequencerAddr},
}
}
Expand All @@ -69,16 +63,11 @@ func UpdateJSONParams(jsonFilePath string, params []PathValue) error {
}

func UpdateGenesisParams(home string, raCfg *config.RollappConfig) error {
oa, err := getGenesisOperatorAddress(home)
if err != nil {
return err
}

sa, err := GetRollappSequencerAddress(home)
if err != nil {
return err
}
params := getDefaultGenesisParams(sa, oa, raCfg)
params := getDefaultGenesisParams(sa, raCfg)
addGenAccountCmd := GetAddGenesisAccountCmd(
consts.KeysIds.RollappSequencer,
consts.DefaultTokenSupply,
Expand Down Expand Up @@ -137,14 +126,13 @@ func getGenesisOperatorAddress(home string) (string, error) {
}

func GetRollappSequencerAddress(home string) (string, error) {
rollappConfigDirPath := filepath.Join(home, consts.ConfigDirName.Rollapp)
seqKeyConfig := utils.KeyConfig{
Dir: rollappConfigDirPath,
Dir: consts.ConfigDirName.Rollapp,
ID: consts.KeysIds.RollappSequencer,
ChainBinary: consts.Executables.RollappEVM,
Type: consts.EVM_ROLLAPP,
}
addr, err := utils.GetAddressBinary(seqKeyConfig, consts.Executables.RollappEVM)
addr, err := utils.GetAddressBinary(seqKeyConfig, home)
if err != nil {
return "", err
}
Expand Down
58 changes: 32 additions & 26 deletions cmd/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,25 @@ var Executables = struct {
}

var KeysIds = struct {
HubSequencer string
HubGenesis string
RollappSequencer string
RollappRelayer string
HubRelayer string
Celestia string
Eibc string
HubSequencer string
HubGenesis string
RollappSequencer string
RollappSequencerReward string
RollappSequencerPrivValidator string
RollappRelayer string
HubRelayer string
Celestia string
Eibc string
}{
HubSequencer: "hub_sequencer",
HubGenesis: "hub_genesis",
RollappSequencer: "rollapp_genesis_account",
RollappRelayer: "relayer-rollapp-key",
HubRelayer: "relayer-hub-key",
Celestia: "my_celes_key",
Eibc: "whale",
HubSequencer: "hub_sequencer",
HubGenesis: "hub_genesis",
RollappSequencer: "rollapp_genesis_account",
RollappSequencerReward: "rollapp_sequencer_rewards",
RollappSequencerPrivValidator: "rollapp_sequencer_priv_validator",
RollappRelayer: "relayer-rollapp-key",
HubRelayer: "relayer-hub-key",
Celestia: "my_celes_key",
Eibc: "whale",
}

var AddressPrefixes = struct {
Expand All @@ -59,19 +63,21 @@ var AddressPrefixes = struct {
}

var ConfigDirName = struct {
Rollapp string
Relayer string
DALightNode string
HubKeys string
LocalHub string
Eibc string
Rollapp string
Relayer string
DALightNode string
HubKeys string
RollappSequencerKeys string
LocalHub string
Eibc string
}{
Rollapp: "rollapp",
Relayer: "relayer",
DALightNode: "da-light-node",
HubKeys: "hub-keys",
LocalHub: "local-hub",
Eibc: ".eibc-client",
Rollapp: "rollapp",
Relayer: "relayer",
DALightNode: "da-light-node",
HubKeys: "hub-keys",
RollappSequencerKeys: "rollapp-sequencer-keys",
LocalHub: "local-hub",
Eibc: ".eibc-client",
}

var Denoms = struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/consts/da.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
type DAType string

const (
Local DAType = "local"
Local DAType = "mock"
Celestia DAType = "celestia"
Avail DAType = "avail"
)
Expand Down
3 changes: 2 additions & 1 deletion cmd/da-light-client/da_light_client.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package da_light_client

import (
da_start "github.com/dymensionxyz/roller/cmd/da-light-client/start"
"github.com/spf13/cobra"

da_start "github.com/dymensionxyz/roller/cmd/da-light-client/start"
)

func DALightClientCmd() *cobra.Command {
Expand Down
4 changes: 2 additions & 2 deletions cmd/rollapp/init/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"strconv"
"strings"

"github.com/dymensionxyz/roller/utils/config"
"github.com/pelletier/go-toml/v2"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
Expand All @@ -24,6 +23,7 @@ import (
datalayer "github.com/dymensionxyz/roller/data_layer"
globalutils "github.com/dymensionxyz/roller/utils"
"github.com/dymensionxyz/roller/utils/bash"
"github.com/dymensionxyz/roller/utils/config"
"github.com/dymensionxyz/roller/utils/config/tomlconfig"
"github.com/dymensionxyz/roller/utils/errorhandling"
"github.com/dymensionxyz/roller/utils/sequencer"
Expand Down Expand Up @@ -180,7 +180,7 @@ func runInit(cmd *cobra.Command, env string, raID string) error {
return err
}

sequencers, err := sequencer.GetRegisteredSequencers(raID, hd)
sequencers, err := sequencer.RegisteredRollappSequencersOnHub(raID, hd)
if err != nil {
return err
}
Expand Down
18 changes: 16 additions & 2 deletions cmd/rollapp/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ func Cmd() *cobra.Command {
rollappConfig.RollappID,
)

seq, err := sequencerutils.GetRegisteredSequencers(rollappConfig.RollappID, hd)
seq, err := sequencerutils.RegisteredRollappSequencersOnHub(
rollappConfig.RollappID,
hd,
)
if err != nil {
pterm.Error.Println("failed to retrieve registered sequencers: ", err)
}
Expand Down Expand Up @@ -663,12 +666,23 @@ func Cmd() *cobra.Command {
)

pterm.Info.Println("initialization complete")

pterm.Info.Println("next steps:")
pterm.Info.Printf(
"run %s load the necessary systemd services\n",
"%s:run %s load the necessary systemd services\n",
pterm.DefaultBasicText.WithStyle(pterm.FgYellow.ToStyle()).
Sprintf("on Linux"),
pterm.DefaultBasicText.WithStyle(pterm.FgYellow.ToStyle()).
Sprintf("roller rollapp services load"),
)

pterm.Info.Printf(
"%s:run %s to start the rollapp processes interactively\n",
pterm.DefaultBasicText.WithStyle(pterm.FgYellow.ToStyle()).
Sprintf("on Other OSs"),
pterm.DefaultBasicText.WithStyle(pterm.FgYellow.ToStyle()).
Sprintf("roller rollapp start"),
)
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/rollapp/sequencer/metadata/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func Cmd() *cobra.Command {
}
seqAddrInfo.Address = strings.TrimSpace(seqAddrInfo.Address)

seq, err := sequencerutils.GetRegisteredSequencers(rollappConfig.RollappID, hd)
seq, err := sequencerutils.RegisteredRollappSequencersOnHub(rollappConfig.RollappID, hd)
if err != nil {
pterm.Error.Println("failed to retrieve registered sequencers: ", err)
}
Expand Down
7 changes: 6 additions & 1 deletion cmd/rollapp/sequencer/metadata/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,17 @@ func Cmd() *cobra.Command {
"--node", rollerData.HubData.RPC_URL, "--chain-id", rollerData.HubData.ID,
)

txHash, err := bash.ExecCommandWithInput(updateSeqCmd)
txOutput, err := bash.ExecCommandWithInput(updateSeqCmd, "signatures")
if err != nil {
pterm.Error.Println("failed to update sequencer metadata", err)
return
}

txHash, err := bash.ExtractTxHash(txOutput)
if err != nil {
return
}

err = tx.MonitorTransaction(rollerData.HubData.RPC_URL, txHash)
if err != nil {
pterm.Error.Println("transaction failed", err)
Expand Down
Loading

0 comments on commit 87f3765

Please sign in to comment.