@@ -52,15 +52,15 @@ func (pr *Prover) SetupForRelay(ctx context.Context) error {
5252// These states will be submitted to the counterparty chain as MsgCreateClient.
5353// If `height` is nil, the latest finalized height is selected automatically.
5454func (pr * Prover ) CreateInitialLightClientState (ctx context.Context , height exported.Height ) (exported.ClientState , exported.ConsensusState , error ) {
55- latestHeight , err := pr .chain .LatestHeight (context . TODO () )
55+ latestHeight , err := pr .chain .LatestHeight (ctx )
5656 if err != nil {
5757 return nil , nil , err
5858 }
5959 var finalizedHeader []* ETHHeader
6060 if height == nil {
61- _ , finalizedHeader , err = queryLatestFinalizedHeader (context . TODO () , pr .chain .Header , latestHeight .GetRevisionHeight ())
61+ _ , finalizedHeader , err = queryLatestFinalizedHeader (ctx , pr .chain .Header , latestHeight .GetRevisionHeight ())
6262 } else {
63- finalizedHeader , err = queryFinalizedHeader (context . TODO () , pr .chain .Header , height .GetRevisionHeight (), latestHeight .GetRevisionHeight ())
63+ finalizedHeader , err = queryFinalizedHeader (ctx , pr .chain .Header , height .GetRevisionHeight (), latestHeight .GetRevisionHeight ())
6464 }
6565 if err != nil {
6666 return nil , nil , err
@@ -69,18 +69,18 @@ func (pr *Prover) CreateInitialLightClientState(ctx context.Context, height expo
6969 return nil , nil , fmt .Errorf ("no finalized headers were found up to %d" , latestHeight .GetRevisionHeight ())
7070 }
7171 //Header should be Finalized, not necessarily Verifiable.
72- return pr .buildInitialState (& Header {
72+ return pr .buildInitialState (ctx , & Header {
7373 Headers : finalizedHeader ,
7474 })
7575}
7676
7777// GetLatestFinalizedHeader returns the latest finalized header from the chain
7878func (pr * Prover ) GetLatestFinalizedHeader (ctx context.Context ) (out core.Header , err error ) {
79- latestHeight , err := pr .chain .LatestHeight (context . TODO () )
79+ latestHeight , err := pr .chain .LatestHeight (ctx )
8080 if err != nil {
8181 return nil , err
8282 }
83- header , err := pr .GetLatestFinalizedHeaderByLatestHeight (context . TODO () , latestHeight .GetRevisionHeight ())
83+ header , err := pr .GetLatestFinalizedHeaderByLatestHeight (ctx , latestHeight .GetRevisionHeight ())
8484 if err != nil {
8585 return nil , err
8686 }
@@ -90,31 +90,31 @@ func (pr *Prover) GetLatestFinalizedHeader(ctx context.Context) (out core.Header
9090
9191// GetLatestFinalizedHeaderByLatestHeight returns the latest finalized verifiable header from the chain
9292func (pr * Prover ) GetLatestFinalizedHeaderByLatestHeight (ctx context.Context , latestBlockNumber uint64 ) (core.Header , error ) {
93- height , finalizedHeader , err := queryLatestFinalizedHeader (context . TODO () , pr .chain .Header , latestBlockNumber )
93+ height , finalizedHeader , err := queryLatestFinalizedHeader (ctx , pr .chain .Header , latestBlockNumber )
9494 if err != nil {
9595 return nil , err
9696 }
9797 // Make headers verifiable
98- return pr .withValidators (height , finalizedHeader )
98+ return pr .withValidators (ctx , height , finalizedHeader )
9999}
100100
101101// SetupHeadersForUpdate creates a new header based on a given header
102102func (pr * Prover ) SetupHeadersForUpdate (ctx context.Context , counterparty core.FinalityAwareChain , latestFinalizedHeader core.Header ) ([]core.Header , error ) {
103103 header := latestFinalizedHeader .(* Header )
104104 // LCP doesn't need height / EVM needs latest height
105- latestHeightOnDstChain , err := counterparty .LatestHeight (context . TODO () )
105+ latestHeightOnDstChain , err := counterparty .LatestHeight (ctx )
106106 if err != nil {
107107 return nil , err
108108 }
109- csRes , err := counterparty .QueryClientState (core .NewQueryContext (context . TODO () , latestHeightOnDstChain ))
109+ csRes , err := counterparty .QueryClientState (core .NewQueryContext (ctx , latestHeightOnDstChain ))
110110 if err != nil {
111111 return nil , fmt .Errorf ("no client state found : SetupHeadersForUpdate: height = %d, %+v" , latestHeightOnDstChain .GetRevisionHeight (), err )
112112 }
113113 var cs exported.ClientState
114114 if err = pr .chain .Codec ().UnpackAny (csRes .ClientState , & cs ); err != nil {
115115 return nil , err
116116 }
117- return pr .SetupHeadersForUpdateByLatestHeight (context . TODO () , cs .GetLatestHeight (), header )
117+ return pr .SetupHeadersForUpdateByLatestHeight (ctx , cs .GetLatestHeight (), header )
118118}
119119
120120func (pr * Prover ) SetupHeadersForUpdateByLatestHeight (ctx context.Context , clientStateLatestHeight exported.Height , latestFinalizedHeader * Header ) ([]core.Header , error ) {
@@ -127,14 +127,14 @@ func (pr *Prover) SetupHeadersForUpdateByLatestHeight(ctx context.Context, clien
127127 if ethHeaders == nil {
128128 return nil , nil
129129 }
130- return pr .withValidators (height , ethHeaders )
130+ return pr .withValidators (ctx , height , ethHeaders )
131131 }
132- latestHeight , err := pr .chain .LatestHeight (context . TODO () )
132+ latestHeight , err := pr .chain .LatestHeight (ctx )
133133 if err != nil {
134134 return nil , err
135135 }
136136 return setupHeadersForUpdate (
137- context . TODO () ,
137+ ctx ,
138138 queryVerifiableNeighboringEpochHeader ,
139139 pr .chain .Header ,
140140 clientStateLatestHeight ,
@@ -144,7 +144,7 @@ func (pr *Prover) SetupHeadersForUpdateByLatestHeight(ctx context.Context, clien
144144
145145func (pr * Prover ) ProveState (ctx core.QueryContext , path string , value []byte ) ([]byte , clienttypes.Height , error ) {
146146 proofHeight := toHeight (ctx .Height ())
147- accountProof , commitmentProof , err := pr .getStateCommitmentProof (context . TODO (), []byte (path ), proofHeight )
147+ accountProof , commitmentProof , err := pr .getStateCommitmentProof (ctx . Context (), []byte (path ), proofHeight )
148148 if err != nil {
149149 return nil , proofHeight , err
150150 }
@@ -161,11 +161,11 @@ func (pr *Prover) ProveState(ctx core.QueryContext, path string, value []byte) (
161161}
162162
163163func (pr * Prover ) CheckRefreshRequired (ctx context.Context , counterparty core.ChainInfoICS02Querier ) (bool , error ) {
164- cpQueryHeight , err := counterparty .LatestHeight (context . TODO () )
164+ cpQueryHeight , err := counterparty .LatestHeight (ctx )
165165 if err != nil {
166166 return false , fmt .Errorf ("failed to get the latest height of the counterparty chain: %+v" , err )
167167 }
168- cpQueryCtx := core .NewQueryContext (context . TODO () , cpQueryHeight )
168+ cpQueryCtx := core .NewQueryContext (ctx , cpQueryHeight )
169169
170170 resCs , err := counterparty .QueryClientState (cpQueryCtx )
171171 if err != nil {
@@ -188,12 +188,12 @@ func (pr *Prover) CheckRefreshRequired(ctx context.Context, counterparty core.Ch
188188 }
189189 lcLastTimestamp := time .Unix (0 , int64 (cons .GetTimestamp ()))
190190
191- selfQueryHeight , err := pr .chain .LatestHeight (context . TODO () )
191+ selfQueryHeight , err := pr .chain .LatestHeight (ctx )
192192 if err != nil {
193193 return false , fmt .Errorf ("failed to get the latest height of the self chain: %+v" , err )
194194 }
195195
196- selfTimestamp , err := pr .chain .Timestamp (context . TODO () , selfQueryHeight )
196+ selfTimestamp , err := pr .chain .Timestamp (ctx , selfQueryHeight )
197197 if err != nil {
198198 return false , fmt .Errorf ("failed to get timestamp of the self chain: %+v" , err )
199199 }
@@ -227,19 +227,19 @@ func (pr *Prover) CheckRefreshRequired(ctx context.Context, counterparty core.Ch
227227
228228}
229229
230- func (pr * Prover ) withValidators (height uint64 , ethHeaders []* ETHHeader ) (core.Header , error ) {
231- return withValidators (context . TODO () , pr .chain .Header , height , ethHeaders )
230+ func (pr * Prover ) withValidators (ctx context. Context , height uint64 , ethHeaders []* ETHHeader ) (core.Header , error ) {
231+ return withValidators (ctx , pr .chain .Header , height , ethHeaders )
232232}
233233
234- func (pr * Prover ) buildInitialState (dstHeader core.Header ) (exported.ClientState , exported.ConsensusState , error ) {
234+ func (pr * Prover ) buildInitialState (ctx context. Context , dstHeader core.Header ) (exported.ClientState , exported.ConsensusState , error ) {
235235 currentEpoch := getCurrentEpoch (dstHeader .GetHeight ().GetRevisionHeight ())
236- currentValidators , currentTurnLength , err := queryValidatorSetAndTurnLength (context . TODO () , pr .chain .Header , currentEpoch )
236+ currentValidators , currentTurnLength , err := queryValidatorSetAndTurnLength (ctx , pr .chain .Header , currentEpoch )
237237 if err != nil {
238238 return nil , nil , err
239239 }
240240
241241 previousEpoch := getPreviousEpoch (dstHeader .GetHeight ().GetRevisionHeight ())
242- previousValidators , previousTurnLength , err := queryValidatorSetAndTurnLength (context . TODO () , pr .chain .Header , previousEpoch )
242+ previousValidators , previousTurnLength , err := queryValidatorSetAndTurnLength (ctx , pr .chain .Header , previousEpoch )
243243 if err != nil {
244244 return nil , nil , err
245245 }
@@ -248,7 +248,7 @@ func (pr *Prover) buildInitialState(dstHeader core.Header) (exported.ClientState
248248 return nil , nil , err
249249 }
250250
251- chainID , err := pr .chain .CanonicalChainID (context . TODO () )
251+ chainID , err := pr .chain .CanonicalChainID (ctx )
252252 if err != nil {
253253 return nil , nil , err
254254 }
0 commit comments