Skip to content

Commit

Permalink
fix: query params from keeper as prio to get hub 47 params (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt authored Nov 28, 2024
1 parent c6dfbd4 commit 7405c3f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion cmd/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ $ %s tx conn demo-path --timeout 5s`,
}

// ensure that the clients exist
// On Dymension: this is using src = Hub, dst = Rollapp
clientSrc, clientDst, err := c[src].CreateClients(
cmd.Context(),
c[dst],
Expand All @@ -461,7 +462,7 @@ $ %s tx conn demo-path --timeout 5s`,
memo,
)
if err != nil {
return err
return fmt.Errorf("create clients: src: %s: dst: %s: %w", clientSrc, clientDst, err)
}

if clientSrc != "" || clientDst != "" {
Expand Down
20 changes: 11 additions & 9 deletions relayer/chains/cosmos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,10 @@ func (cc *CosmosProvider) QueryCanonicalLightClient(ctx context.Context, rollapp
func (cc *CosmosProvider) QueryUnbondingPeriod(ctx context.Context) (time.Duration, error) {
if cc.PCfg.DymRollapp {
ret, err := cc.queryParamsSubspaceTime(ctx, "sequencers", "UnbondingTime")
if err == nil {
return ret, nil
if err != nil {
return 0, fmt.Errorf("query unbonding period from sequencers module on rollapp: %w", err)
}
return ret, nil
}

// Attempt ICS query
Expand All @@ -393,18 +394,19 @@ func (cc *CosmosProvider) QueryUnbondingPeriod(ctx context.Context) (time.Durati
return consumerUnbondingPeriod, nil
}

// Attempt Staking query.
unbondingPeriod, stakingParamsErr := cc.queryParamsSubspaceTime(ctx, "staking", "UnbondingTime")
if stakingParamsErr == nil {
return unbondingPeriod, nil
}

// Fallback
// Dymension change: query keeper first, then params subspace
req := stakingtypes.QueryParamsRequest{}
queryClient := stakingtypes.NewQueryClient(cc)
res, err := queryClient.Params(ctx, &req)
if err == nil {
return res.Params.UnbondingTime, nil
} else {
cc.log.Error("Query unbonding period from staking keeper.", zap.Error(err), zap.String("chain-id", cc.ChainId()))
}

unbondingPeriod, stakingParamsErr := cc.queryParamsSubspaceTime(ctx, "staking", "UnbondingTime")
if stakingParamsErr == nil {
return unbondingPeriod, nil
}

return 0,
Expand Down
5 changes: 4 additions & 1 deletion relayer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func (c *Chain) CreateClients(ctx context.Context,
eg.Go(func() error {
var err error
// Create client on dst for src if the client id is unspecified
// For Dymension: this is creating the rollapp client on the Hub
clientDst, err = CreateClient(egCtx, dst, c,
dstUpdateHeader, srcUpdateHeader,
allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour,
Expand All @@ -101,7 +102,7 @@ func (c *Chain) CreateClients(ctx context.Context,

if err := eg.Wait(); err != nil {
// If one completed successfully and the other didn't, we can still report modified.
return clientSrc, clientDst, err
return clientSrc, clientDst, fmt.Errorf("create clients: %w", err)
}

c.log.Info(
Expand All @@ -118,6 +119,8 @@ func (c *Chain) CreateClients(ctx context.Context,
// CreateClient creates client tracking dst on src.
func CreateClient(
ctx context.Context,

// Src is the one to create a client ON, Dst is the one to query the info from
src, dst *Chain,
srcUpdateHeader, dstUpdateHeader provider.IBCHeader,
allowUpdateAfterExpiry,
Expand Down

0 comments on commit 7405c3f

Please sign in to comment.