Skip to content

Commit

Permalink
Add fallback for chains using cosmos-sdk 47+
Browse files Browse the repository at this point in the history
  • Loading branch information
vimystic committed Sep 12, 2023
1 parent 5493c83 commit 33e797f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
16 changes: 6 additions & 10 deletions interchaintest/tendermint_v0.37_boundary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import (
"context"
"testing"

relayerinterchaintest "github.com/cosmos/relayer/v2/interchaintest"
interchaintest "github.com/strangelove-ventures/interchaintest/v7"
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v7/conformance"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
"github.com/strangelove-ventures/interchaintest/v7/relayer"
"github.com/strangelove-ventures/interchaintest/v7/relayer/rly"
"github.com/strangelove-ventures/interchaintest/v7/testreporter"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
Expand All @@ -27,15 +25,15 @@ func TestScenarioTendermint37Boundary(t *testing.T) {
{
Name: "gaia",
ChainName: "gaia",
Version: "v12.0.0-rc0",
Version: "v7.0.3",
NumValidators: &nv,
NumFullNodes: &nf,
},
{
// TODO update with mainnet SDK v0.47+ chain version once available
Name: "ibc-go-simd",
ChainName: "ibc-go-simd",
Version: "v7.2.0",
Version: "andrew-47-rc1",
NumValidators: &nv,
NumFullNodes: &nf,
},
Expand All @@ -53,11 +51,9 @@ func TestScenarioTendermint37Boundary(t *testing.T) {
relayerName = "relayer"
)

rf := interchaintest.NewBuiltinRelayerFactory(
ibc.CosmosRly,
zaptest.NewLogger(t),
relayer.CustomDockerImage("ghcr.io/cosmos/relayer", "v2.4.1", rly.RlyDefaultUidGid),
)
rf := relayerinterchaintest.NewRelayerFactory(relayerinterchaintest.RelayerConfig{
InitialBlockHistory: 50,
})

r := rf.Build(t, client, network)

Expand Down
18 changes: 17 additions & 1 deletion relayer/chains/cosmos/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,26 @@ func (cc *CosmosProvider) AccountFromKeyOrAddress(keyOrAddress string) (out sdk.
}

func (cc *CosmosProvider) TrustingPeriod(ctx context.Context) (time.Duration, error) {
var unbondingTime time.Duration

unbondingTime, err := cc.QueryUnbondingPeriod(ctx)
if err == nil {
return unbondingTime, nil
} else {
fmt.Println("%w", err)
}

res, err := cc.QueryStakingParams(ctx)
if err != nil {
return 0, err
// Attempt ICS query
consumerUnbondingPeriod, consumerErr := cc.queryConsumerUnbondingPeriod(ctx)
if consumerErr != nil {
return 0,
fmt.Errorf("failed to query unbonding period as both standard and consumer chain: %s: %w", err.Error(), consumerErr)
}
unbondingTime = consumerUnbondingPeriod
} else {
unbondingTime = res.UnbondingTime
}

// We want the trusting period to be 85% of the unbonding time.
Expand Down

0 comments on commit 33e797f

Please sign in to comment.