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!: Add support for standard ibc #614

Merged
merged 18 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f7e5ce3
Removed set-settlement command of relayer.
omritoptix Dec 4, 2023
0bb850e
Changed relayer start command to use the actual rly start and not run…
omritoptix Dec 4, 2023
e455c96
Fixed bug with missing 'go' command before and logFile option.
omritoptix Dec 4, 2023
7ffd9ec
Added migration file to migrate to version v1.0.0
omritoptix Dec 5, 2023
9ffc8d8
Changed create-rollapp command to match new hub version.
omritoptix Dec 5, 2023
c3728b8
Change channel creation logic to match new relayer version.
omritoptix Dec 5, 2023
d81a17a
Updated binary versions in compile script.
omritoptix Dec 6, 2023
6bda8c5
Fixed test goldens to match new relayer configuration.
omritoptix Dec 6, 2023
76ff33c
Removed redundant code to fix linter error.
omritoptix Dec 6, 2023
cc3dc74
Updated local gas price to match the new local hub gas price.
omritoptix Dec 9, 2023
bb27038
Updated relayer migration script to add extra-codec necessary for rea…
omritoptix Dec 9, 2023
85b9e2b
Added context to start commands to get killed once context is done.
omritoptix Dec 9, 2023
f648ff6
Updated hub tag to be latest.
omritoptix Dec 9, 2023
6384a25
Fixed tests to match new relayer config.
omritoptix Dec 9, 2023
a73a324
feat: add denom registration on rollapp creation (#628)
mtsitrin Dec 10, 2023
1c94289
Fixed bug where override wasn't passed to create link cmd.
omritoptix Dec 10, 2023
2835a9e
Updated compile locally to use v2.0.0-alpha.3
omritoptix Dec 10, 2023
ea5f007
Fixed bug with relayer key migration.
omritoptix Dec 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/config/init/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ var Hubs = map[string]config.HubData{
ID: LocalHubID,
RPC_URL: "http://localhost:36657",
ARCHIVE_RPC_URL: "http://localhost:36657",
GAS_PRICE: "0",
GAS_PRICE: "100000000",
},
}
74 changes: 74 additions & 0 deletions cmd/config/init/denom_metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package initconfig

import (
"encoding/json"
"fmt"
"os"
"strings"
)

type BankDenomMetadata struct {
Base string `json:"base"`
DenomUnits []BankDenomUnitMetadata `json:"denom_units"`
Description string `json:"description"`
Display string `json:"display"`
Name string `json:"name"`
Symbol string `json:"symbol"`
}

type BankDenomUnitMetadata struct {
Aliases []string `json:"aliases"`
Denom string `json:"denom"`
Exponent uint `json:"exponent"`
}

func getBankDenomMetadata(denom string, decimals uint) string {
displayDenom := denom[1:]

metadata := []BankDenomMetadata{
{
Base: denom,
DenomUnits: []BankDenomUnitMetadata{
{
Aliases: []string{},
Denom: denom,
Exponent: 0,
},
{
Aliases: []string{},
Denom: displayDenom,
Exponent: decimals,
},
},
Description: fmt.Sprintf("Denom metadata for %s (%s)", displayDenom, denom),
Display: displayDenom,
Name: displayDenom,
Symbol: strings.ToUpper(displayDenom),
},
}

json, err := json.Marshal(metadata)
if err != nil {
return ""
}

return string(json)
}

func createTokenMetadaJSON(metadataPath string, denom string, decimals uint) error {
metadata := getBankDenomMetadata(denom, decimals)
if metadata == "" {
return fmt.Errorf("failed to generate token metadata")
}

file, err := os.Create(metadataPath)
if err != nil {
return err
}
_, err = file.WriteString(metadata)
if err != nil {
return err
}

return nil
}
48 changes: 8 additions & 40 deletions cmd/config/init/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"math/big"
"os"
"strconv"
"strings"

"github.com/dymensionxyz/roller/cmd/consts"
"github.com/dymensionxyz/roller/cmd/utils"
Expand Down Expand Up @@ -57,6 +56,12 @@ func initializeRollappGenesis(initConfig config.RollappConfig) error {
if err != nil {
return err
}

err = createTokenMetadaJSON(filepath.Join(RollappConfigDir(initConfig.Home), "tokenmetadata.json"), initConfig.Denom, initConfig.Decimals)
if err != nil {
return err
}

return nil
}

Expand All @@ -70,25 +75,8 @@ type PathValue struct {
Value interface{}
}

type BankDenomMetadata struct {
Base string `json:"base"`
DenomUnits []BankDenomUnitMetadata `json:"denom_units"`
Description string `json:"description"`
Display string `json:"display"`
Name string `json:"name"`
Symbol string `json:"symbol"`
}

type BankDenomUnitMetadata struct {
Aliases []string `json:"aliases"`
Denom string `json:"denom"`
Exponent uint `json:"exponent"`
}

// TODO(#130): fix to support epochs
func getDefaultGenesisParams(denom string, decimals uint) []PathValue {
displayDenom := denom[1:]

return []PathValue{
{"app_state.mint.params.mint_denom", denom},
{"app_state.staking.params.bond_denom", denom},
Expand All @@ -101,27 +89,7 @@ func getDefaultGenesisParams(denom string, decimals uint) []PathValue {
{"app_state.distribution.params.community_tax", "0.00002"},
{"app_state.gov.voting_params.voting_period", "300s"},
{"app_state.staking.params.unbonding_time", "3628800s"},
{"app_state.bank.denom_metadata", []BankDenomMetadata{
{
Base: denom,
DenomUnits: []BankDenomUnitMetadata{
{
Aliases: []string{},
Denom: denom,
Exponent: 0,
},
{
Aliases: []string{},
Denom: displayDenom,
Exponent: decimals,
},
},
Description: fmt.Sprintf("Denom metadata for %s (%s)", displayDenom, denom),
Display: displayDenom,
Name: displayDenom,
Symbol: strings.ToUpper(displayDenom),
},
}},
{"app_state.bank.denom_metadata", getBankDenomMetadata(denom, decimals)},
}
}

Expand Down Expand Up @@ -171,7 +139,7 @@ func generateGenesisTx(initConfig config.RollappConfig) error {
func registerSequencerAsGoverner(initConfig config.RollappConfig) error {
totalSupply, err := strconv.Atoi(initConfig.TokenSupply)
if err != nil {
return fmt.Errorf("Error converting string to integer: %w", err)
return fmt.Errorf("error converting string to integer: %w", err)
}
// Convert to token supply with decimals
stakedSupply := big.NewInt(int64(totalSupply / totalSupplyToStakingRatio))
Expand Down
32 changes: 15 additions & 17 deletions cmd/config/init/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package initconfig

import (
"encoding/json"
"github.com/dymensionxyz/roller/relayer"
"os"
"os/exec"
"path/filepath"

"github.com/dymensionxyz/roller/relayer"

"github.com/dymensionxyz/roller/config"

"github.com/dymensionxyz/roller/cmd/consts"
Expand All @@ -17,24 +18,23 @@ type RelayerFileChainConfig struct {
Value RelayerFileChainConfigValue `json:"value"`
}
type RelayerFileChainConfigValue struct {
Key string `json:"key"`
ChainID string `json:"chain-id"`
RpcAddr string `json:"rpc-addr"`
AccountPrefix string `json:"account-prefix"`
KeyringBackend string `json:"keyring-backend"`
GasAdjustment float64 `json:"gas-adjustment"`
GasPrices string `json:"gas-prices"`
Debug bool `json:"debug"`
Timeout string `json:"timeout"`
OutputFormat string `json:"output-format"`
SignMode string `json:"sign-mode"`
ClientType string `json:"client-type"`
Key string `json:"key"`
ChainID string `json:"chain-id"`
RpcAddr string `json:"rpc-addr"`
AccountPrefix string `json:"account-prefix"`
KeyringBackend string `json:"keyring-backend"`
GasAdjustment float64 `json:"gas-adjustment"`
GasPrices string `json:"gas-prices"`
Debug bool `json:"debug"`
Timeout string `json:"timeout"`
OutputFormat string `json:"output-format"`
SignMode string `json:"sign-mode"`
ExtraCodecs []string `json:"extra-codecs"`
}

type RelayerChainConfig struct {
ChainConfig relayer.ChainConfig
GasPrices string
ClientType string
KeyName string
}

Expand Down Expand Up @@ -65,7 +65,7 @@ func getRelayerFileChainConfig(relayerChainConfig RelayerChainConfig) RelayerFil
Timeout: "10s",
OutputFormat: "json",
SignMode: "direct",
ClientType: relayerChainConfig.ClientType,
ExtraCodecs: []string{"ethermint"},
},
}
}
Expand All @@ -91,14 +91,12 @@ func addChainsConfig(rollappConfig relayer.ChainConfig, hubConfig relayer.ChainC
relayerRollappConfig := getRelayerFileChainConfig(RelayerChainConfig{
ChainConfig: rollappConfig,
GasPrices: rollappConfig.GasPrices + rollappConfig.Denom,
ClientType: "01-dymint",
KeyName: consts.KeysIds.RollappRelayer,
})

relayerHubConfig := getRelayerFileChainConfig(RelayerChainConfig{
ChainConfig: hubConfig,
GasPrices: hubConfig.GasPrices + hubConfig.Denom,
ClientType: "07-tendermint",
KeyName: consts.KeysIds.HubRelayer,
})

Expand Down
2 changes: 1 addition & 1 deletion cmd/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ var Hubs = map[string]config.HubData{
ID: LocalHubID,
RPC_URL: "http://localhost:36657",
ARCHIVE_RPC_URL: "http://localhost:36657",
GAS_PRICE: "0",
GAS_PRICE: "100000000",
},
// TODO: Add mainnet hub data
MainnetHubName: FroopylandHubData,
Expand Down
6 changes: 5 additions & 1 deletion cmd/da-light-client/start/start.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package start

import (
"context"
"errors"
"fmt"

Expand Down Expand Up @@ -52,7 +53,10 @@ func Cmd() *cobra.Command {

logFilePath := utils.GetDALogFilePath(rollappConfig.Home)
LCEndpoint = damanager.GetLightNodeEndpoint()
utils.RunBashCmdAsync(startDALCCmd, printOutput, parseError, utils.WithLogging(logFilePath))
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go utils.RunBashCmdAsync(ctx, startDALCCmd, printOutput, parseError, utils.WithLogging(logFilePath))
select {}
},
}

Expand Down
1 change: 1 addition & 0 deletions cmd/migrate/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var migrationsRegistry = []VersionMigrator{
&VersionMigratorV0112{},
&VersionMigratorV0113{},
&VersionMigratorV0118{},
&VersionMigratorV1000{},
}

func Cmd() *cobra.Command {
Expand Down
40 changes: 40 additions & 0 deletions cmd/migrate/v1_0_00.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package migrate

import (
"fmt"
"os/exec"

"github.com/dymensionxyz/roller/cmd/consts"
"github.com/dymensionxyz/roller/cmd/utils"
"github.com/dymensionxyz/roller/config"
"github.com/dymensionxyz/roller/relayer"
)

type VersionMigratorV1000 struct{}

func (v *VersionMigratorV1000) ShouldMigrate(prevVersion VersionData) bool {
return prevVersion.Major < 1
}

func (v *VersionMigratorV1000) PerformMigration(rlpCfg config.RollappConfig) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes required on the rollapp itself? how it's state will change to use the tendermint IBC?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change to the rollapp itself is in the rollapp binary.

fmt.Println("💈 Migrating Rollapp key...")
migrateRollappKeyCmd := exec.Command(consts.Executables.RollappEVM, "keys", "migrate", "--home", rlpCfg.Home+"/relayer/keys/"+rlpCfg.RollappID, "--keyring-backend", "test")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't rly have this migrate functionally? by rly keys list maybe?
just to avoid the dependency on the rollapp/hub binary

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't have it.

out, err := utils.ExecBashCommandWithStdout(migrateRollappKeyCmd)
if err != nil {
return err
}
fmt.Println(out.String())
fmt.Println("💈 Migrating Hub key...")
migrateHubKeyCmd := exec.Command(consts.Executables.Dymension, "keys", "migrate", "--home", rlpCfg.Home+"/relayer/keys/"+rlpCfg.HubData.ID, "--keyring-backend", "test")
out, err = utils.ExecBashCommandWithStdout(migrateHubKeyCmd)
if err != nil {
return err
}
fmt.Println(out.String())
fmt.Println("💈 Updating relayer configuration to match new relayer key...")
if err := relayer.UpdateRlyConfigValue(rlpCfg, []string{"chains", rlpCfg.RollappID, "value", "extra-codecs"}, []string{"ethermint"}); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ethermint codec won't break something with non-evm rollapp?

return err
}
return nil

}
9 changes: 1 addition & 8 deletions cmd/relayer/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,9 @@ func Start() *cobra.Command {
_, err := rly.CreateIBCChannel(override, logFileOption, seq)
utils.PrettifyErrorIfExists(err)
}

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

updateClientsCmd := rly.GetUpdateClientsCmd()
utils.RunCommandEvery(ctx, updateClientsCmd.Path, updateClientsCmd.Args[1:], 3600, logFileOption)
relayPacketsCmd := rly.GetRelayPacketsCmd()
utils.RunCommandEvery(ctx, relayPacketsCmd.Path, relayPacketsCmd.Args[1:], 5, logFileOption)
relayAcksCmd := rly.GetRelayAcksCmd()
utils.RunCommandEvery(ctx, relayAcksCmd.Path, relayAcksCmd.Args[1:], 5, logFileOption)
go utils.RunBashCmdAsync(ctx, rly.GetStartCmd(), func() {}, func(errMessage string) string { return errMessage }, logFileOption)
fmt.Printf("💈 The relayer is running successfully on you local machine! Channels: src, %s <-> %s, dst",
rly.SrcChannel, rly.DstChannel)

Expand Down
9 changes: 7 additions & 2 deletions cmd/sequencer/start/start.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package sequnecer_start

import (
"context"
"fmt"
"github.com/dymensionxyz/roller/sequencer"
"math/big"
"path/filepath"

"github.com/dymensionxyz/roller/sequencer"

"strings"

"github.com/dymensionxyz/roller/cmd/consts"
Expand Down Expand Up @@ -38,10 +40,13 @@ func StartCmd() *cobra.Command {
utils.PrintInsufficientBalancesIfAny(sequencerInsufficientAddrs, rollappConfig)
seq := sequencer.GetInstance(rollappConfig)
startRollappCmd := seq.GetStartCmd()
utils.RunBashCmdAsync(startRollappCmd, func() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go utils.RunBashCmdAsync(ctx, startRollappCmd, func() {
printOutput(rollappConfig)
}, parseError,
utils.WithLogging(utils.GetSequencerLogPath(rollappConfig)))
select {}
},
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/tx/register/bash_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import (
)

func getRegisterRollappCmd(rollappConfig config.RollappConfig) *exec.Cmd {
tokenMetadataPath := filepath.Join(rollappConfig.Home, consts.ConfigDirName.Rollapp, "config", "tokenmetadata.json")
cmdArgs := []string{
"tx", "rollapp", "create-rollapp", rollappConfig.RollappID, "stamp1", "genesis-path/1", "3", "3", `{"Addresses":[]}`,
"tx", "rollapp", "create-rollapp", rollappConfig.RollappID, "3", `{"Addresses":[]}`, tokenMetadataPath,
}
cmdArgs = append(cmdArgs, getCommonDymdTxFlags(rollappConfig)...)
return exec.Command(
Expand Down
Loading
Loading