@@ -55,12 +55,15 @@ func (c *Chain) CreateClients(ctx context.Context, dst *Chain, allowUpdateAfterE
55
55
return "" , "" , err
56
56
}
57
57
58
+ // overriding the unbonding period should only be possible when creating single clients at a time (CreateClient)
59
+ var overrideUnbondingPeriod = time .Duration (0 )
60
+
58
61
var clientSrc , clientDst string
59
62
eg , egCtx := errgroup .WithContext (ctx )
60
63
eg .Go (func () error {
61
64
var err error
62
65
// Create client on src for dst if the client id is unspecified
63
- clientSrc , err = CreateClient (egCtx , c , dst , srcUpdateHeader , dstUpdateHeader , allowUpdateAfterExpiry , allowUpdateAfterMisbehaviour , override , customClientTrustingPeriod , memo )
66
+ clientSrc , err = CreateClient (egCtx , c , dst , srcUpdateHeader , dstUpdateHeader , allowUpdateAfterExpiry , allowUpdateAfterMisbehaviour , override , customClientTrustingPeriod , overrideUnbondingPeriod , memo )
64
67
if err != nil {
65
68
return fmt .Errorf ("failed to create client on src chain{%s}: %w" , c .ChainID (), err )
66
69
}
@@ -70,7 +73,7 @@ func (c *Chain) CreateClients(ctx context.Context, dst *Chain, allowUpdateAfterE
70
73
eg .Go (func () error {
71
74
var err error
72
75
// Create client on dst for src if the client id is unspecified
73
- clientDst , err = CreateClient (egCtx , dst , c , dstUpdateHeader , srcUpdateHeader , allowUpdateAfterExpiry , allowUpdateAfterMisbehaviour , override , customClientTrustingPeriod , memo )
76
+ clientDst , err = CreateClient (egCtx , dst , c , dstUpdateHeader , srcUpdateHeader , allowUpdateAfterExpiry , allowUpdateAfterMisbehaviour , override , customClientTrustingPeriod , overrideUnbondingPeriod , memo )
74
77
if err != nil {
75
78
return fmt .Errorf ("failed to create client on dst chain{%s}: %w" , dst .ChainID (), err )
76
79
}
@@ -102,6 +105,7 @@ func CreateClient(
102
105
allowUpdateAfterMisbehaviour bool ,
103
106
override bool ,
104
107
customClientTrustingPeriod time.Duration ,
108
+ overrideUnbondingPeriod time.Duration ,
105
109
memo string ) (string , error ) {
106
110
// If a client ID was specified in the path and override is not set, ensure the client exists.
107
111
if ! override && src .PathEnd .ClientID != "" {
@@ -122,7 +126,7 @@ func CreateClient(
122
126
if tp == 0 {
123
127
if err := retry .Do (func () error {
124
128
var err error
125
- tp , err = dst .GetTrustingPeriod (ctx )
129
+ tp , err = dst .GetTrustingPeriod (ctx , overrideUnbondingPeriod )
126
130
if err != nil {
127
131
return fmt .Errorf ("failed to get trusting period for chain{%s}: %w" , dst .ChainID (), err )
128
132
}
@@ -143,17 +147,19 @@ func CreateClient(
143
147
zap .Duration ("trust_period" , tp ),
144
148
)
145
149
146
- // Query the unbonding period for dst and retry if the query fails
147
- var ubdPeriod time.Duration
148
- if err := retry .Do (func () error {
149
- var err error
150
- ubdPeriod , err = dst .ChainProvider .QueryUnbondingPeriod (ctx )
151
- if err != nil {
152
- return fmt .Errorf ("failed to query unbonding period for chain{%s}: %w" , dst .ChainID (), err )
150
+ ubdPeriod := overrideUnbondingPeriod
151
+ if ubdPeriod == 0 {
152
+ // Query the unbonding period for dst and retry if the query fails
153
+ if err := retry .Do (func () error {
154
+ var err error
155
+ ubdPeriod , err = dst .ChainProvider .QueryUnbondingPeriod (ctx )
156
+ if err != nil {
157
+ return fmt .Errorf ("failed to query unbonding period for chain{%s}: %w" , dst .ChainID (), err )
158
+ }
159
+ return nil
160
+ }, retry .Context (ctx ), RtyAtt , RtyDel , RtyErr ); err != nil {
161
+ return "" , err
153
162
}
154
- return nil
155
- }, retry .Context (ctx ), RtyAtt , RtyDel , RtyErr ); err != nil {
156
- return "" , err
157
163
}
158
164
159
165
// We want to create a light client on the src chain which tracks the state of the dst chain.
0 commit comments