Skip to content

Commit

Permalink
fix: substitute min sequencer bond with global value
Browse files Browse the repository at this point in the history
fix: substitute min sequencer bond with global value
  • Loading branch information
artemijspavlovs committed Dec 3, 2024
1 parent e3a1a16 commit d4a6c55
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 17 deletions.
8 changes: 7 additions & 1 deletion cmd/rollapp/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,18 @@ RollApp's IRO time: %v`,
)

if !isSequencerRegistered {
minBond, _ := sequencer.GetMinSequencerBondInBaseDenom(
minBond, err := sequencer.GetMinSequencerBondInBaseDenom(
rollappConfig.RollappID,
rollappConfig.HubData,
)
if err != nil {
pterm.Error.Println("failed to get min bond: ", err)
return
}

var bondAmount cosmossdktypes.Coin
bondAmount.Denom = consts.Denoms.Hub

floatDenomRepresentation := displayRegularDenom(*minBond, 18)
displayDenom := fmt.Sprintf(
"%s%s",
Expand Down
37 changes: 37 additions & 0 deletions utils/rollapp/rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path/filepath"
"strings"

cosmossdktypes "github.com/cosmos/cosmos-sdk/types"
dymensiontypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types"
"github.com/pterm/pterm"

Expand Down Expand Up @@ -275,3 +276,39 @@ func Show(raID string, hd consts.HubData) (*ShowRollappResponse, error) {

return &raResponse, nil
}

type RaParams struct {
Params MinSequencerBond `json:"params"`
}

type MinSequencerBond struct {
MinSequencerBondGlobal cosmossdktypes.Coin `json:"min_sequencer_bond_global"`
}

func GetRollappParams(hd consts.HubData) (*RaParams, error) {
var resp RaParams
cmd := exec.Command(
consts.Executables.Dymension,
"q",
"rollapp",
"params",
"--node",
hd.RpcUrl,
"--chain-id",
hd.ID,
"-o",
"json",
)

out, err := bash.ExecCommandWithStdout(cmd)
if err != nil {
return nil, err
}

err = json.Unmarshal(out.Bytes(), &resp)
if err != nil {
return nil, err
}

return &resp, nil
}
31 changes: 16 additions & 15 deletions utils/rollapp/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package rollapp
import (
"time"

cosmossdktypes "github.com/cosmos/cosmos-sdk/types"
tmtypes "github.com/tendermint/tendermint/types"
)

Expand All @@ -21,21 +22,21 @@ type Summary struct {
}

type Rollapp struct {
RollappId string `json:"rollapp_id,omitempty"`
Owner string `json:"owner,omitempty"`
PreLaunchTime string `json:"pre_launch_time,omitempty"`
GenesisState RollappGenesisState `json:"genesis_state"`
ChannelId string `json:"channel_id,omitempty"`
Frozen bool `json:"frozen,omitempty"`
RegisteredDenoms []string `json:"registeredDenoms,omitempty"`
Metadata *RollappMetadata `json:"metadata,omitempty"`
GenesisInfo GenesisInfo `json:"genesis_info"`
InitialSequencer string `json:"initial_sequencer,omitempty"`
VmType string `json:"vm_type,omitempty"`
Launched bool `json:"launched,omitempty"`
LivenessEventHeight string `json:"liveness_event_height,omitempty"`
LastStateUpdateHeight string `json:"last_state_update_height,omitempty"`
MinSequencerBond string `json:"min_sequencer_bond,omitempty"`
RollappId string `json:"rollapp_id,omitempty"`
Owner string `json:"owner,omitempty"`
PreLaunchTime string `json:"pre_launch_time,omitempty"`
GenesisState RollappGenesisState `json:"genesis_state"`
ChannelId string `json:"channel_id,omitempty"`
Frozen bool `json:"frozen,omitempty"`
RegisteredDenoms []string `json:"registeredDenoms,omitempty"`
Metadata *RollappMetadata `json:"metadata,omitempty"`
GenesisInfo GenesisInfo `json:"genesis_info"`
InitialSequencer string `json:"initial_sequencer,omitempty"`
VmType string `json:"vm_type,omitempty"`
Launched bool `json:"launched,omitempty"`
LivenessEventHeight string `json:"liveness_event_height,omitempty"`
LastStateUpdateHeight string `json:"last_state_update_height,omitempty"`
MinSequencerBond []cosmossdktypes.Coin `json:"min_sequencer_bond,omitempty"`
}

type GenesisInfo struct {
Expand Down
12 changes: 11 additions & 1 deletion utils/sequencer/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,17 @@ func GetMinSequencerBondInBaseDenom(raID string, hd consts.HubData) (*cosmossdkt

_ = json.Unmarshal(out.Bytes(), &qra)

c := qra.MinSequencerBond[0]
var c cosmossdktypes.Coin
if qra.MinSequencerBond != nil {
c = qra.MinSequencerBond[0]
} else {
params, err := rollapp.GetRollappParams(hd)
if err != nil {
return nil, err
}
c = params.Params.MinSequencerBondGlobal
}

return &c, nil
}

Expand Down

0 comments on commit d4a6c55

Please sign in to comment.