Skip to content

Commit 78de4f9

Browse files
authored
Merge pull request #32 from datachainlab/add-context
Add context.Context to Prover methods
2 parents 9693de9 + e0ce5b2 commit 78de4f9

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ require (
77
github.com/cosmos/cosmos-sdk v0.50.5
88
github.com/cosmos/gogoproto v1.4.11
99
github.com/cosmos/ibc-go/v8 v8.2.1
10-
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.13
10+
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.16
1111
github.com/ethereum/go-ethereum v1.14.12
12-
github.com/hyperledger-labs/yui-relayer v0.5.10
12+
github.com/hyperledger-labs/yui-relayer v0.5.11
1313
github.com/prysmaticlabs/fastssz v0.0.0-20241008181541-518c4ce73516
1414
github.com/prysmaticlabs/prysm/v5 v5.2.0
1515
github.com/spf13/cobra v1.8.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ github.com/d4l3k/messagediff v1.2.1 h1:ZcAIMYsUg0EAp9X+tt8/enBE/Q8Yd5kzPynLyKptt
402402
github.com/d4l3k/messagediff v1.2.1/go.mod h1:Oozbb1TVXFac9FtSIxHBMnBCq2qeH/2KkEQxENCrlLo=
403403
github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0=
404404
github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
405-
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.13 h1:RbYtraeZwN55qfbzfoDIJPK8CWWx5dWfO8CfnvS+dhk=
406-
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.13/go.mod h1:dxL5umpjncKRw7iBFE2W+dGpmmWOiggth0aQsJrtLKM=
405+
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.16 h1:C4xwZ1Pq5O+ITjP5UphpwThtTHnWiTe0V4pckEvqfwI=
406+
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.16/go.mod h1:sf+ti1uM1joxhukxIyj8oDQ5yf7d+e+nl+3vtn9f5CM=
407407
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
408408
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
409409
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
@@ -759,8 +759,8 @@ github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXM
759759
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
760760
github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
761761
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
762-
github.com/hyperledger-labs/yui-relayer v0.5.10 h1:j35SRowNfVDU3gvq4Th3Wy8ufRD5K4wbXDLQAGOgT8w=
763-
github.com/hyperledger-labs/yui-relayer v0.5.10/go.mod h1:kJvSmuagdDsSlvbnHtEHbhmkUlAS43/ArLDwukOKSlo=
762+
github.com/hyperledger-labs/yui-relayer v0.5.11 h1:tBDWJa96jQhxL9zLDbB94VvSgw0f8Xk9tqPuKMT3ARw=
763+
github.com/hyperledger-labs/yui-relayer v0.5.11/go.mod h1:kJvSmuagdDsSlvbnHtEHbhmkUlAS43/ArLDwukOKSlo=
764764
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
765765
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
766766
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=

relay/beacon.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package relay
22

33
import (
4+
"context"
45
"fmt"
56

67
"github.com/datachainlab/ethereum-ibc-relay-prover/beacon"
@@ -84,7 +85,7 @@ func (pr *Prover) getSlotAtTimestamp(timestamp uint64) (uint64, error) {
8485

8586
// returns a period corresponding to a given execution block number
8687
func (pr *Prover) getPeriodWithBlockNumber(blockNumber uint64) (uint64, error) {
87-
timestamp, err := pr.chain.Timestamp(pr.newHeight(int64(blockNumber)))
88+
timestamp, err := pr.chain.Timestamp(context.TODO(), pr.newHeight(int64(blockNumber)))
8889
if err != nil {
8990
return 0, err
9091
}

relay/prover.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ type InitialState struct {
7474
// CreateInitialLightClientState returns a pair of ClientState and ConsensusState based on the state of the self chain at `height`.
7575
// These states will be submitted to the counterparty chain as MsgCreateClient.
7676
// If `height` is nil, the latest finalized height is selected automatically.
77-
func (pr *Prover) CreateInitialLightClientState(height ibcexported.Height) (ibcexported.ClientState, ibcexported.ConsensusState, error) {
77+
func (pr *Prover) CreateInitialLightClientState(ctx context.Context, height ibcexported.Height) (ibcexported.ClientState, ibcexported.ConsensusState, error) {
7878
if height == nil {
7979
height = pr.newHeight(0)
8080
}
@@ -111,7 +111,7 @@ func (pr *Prover) CreateInitialLightClientState(height ibcexported.Height) (ibce
111111
// SetupHeadersForUpdate returns the finalized header and any intermediate headers needed to apply it to the client on the counterpaty chain
112112
// The order of the returned header slice should be as: [<intermediate headers>..., <update header>]
113113
// if the header slice's length == 0 and err == nil, the relayer should skips the update-client
114-
func (pr *Prover) SetupHeadersForUpdate(counterparty core.FinalityAwareChain, latestFinalizedHeader core.Header) ([]core.Header, error) {
114+
func (pr *Prover) SetupHeadersForUpdate(ctx context.Context, counterparty core.FinalityAwareChain, latestFinalizedHeader core.Header) ([]core.Header, error) {
115115
lfh, ok := latestFinalizedHeader.(*lctypes.Header)
116116
if !ok {
117117
return nil, fmt.Errorf("unexpected header type: %T", latestFinalizedHeader)
@@ -120,7 +120,7 @@ func (pr *Prover) SetupHeadersForUpdate(counterparty core.FinalityAwareChain, la
120120
return nil, err
121121
}
122122

123-
latestHeight, err := counterparty.LatestHeight()
123+
latestHeight, err := counterparty.LatestHeight(context.TODO())
124124
if err != nil {
125125
return nil, err
126126
}
@@ -230,7 +230,7 @@ func (pr *Prover) buildInitialState(blockNumber uint64) (*InitialState, error) {
230230
return nil, fmt.Errorf("the height is not finalized yet: blockNumber=%v finalized_block_number=%v", blockNumber, eh.BlockNumber)
231231
}
232232

233-
timestamp, err := pr.chain.Timestamp(pr.newHeight(int64(blockNumber)))
233+
timestamp, err := pr.chain.Timestamp(context.TODO(), pr.newHeight(int64(blockNumber)))
234234
if err != nil {
235235
return nil, fmt.Errorf("failed to get timestamp: %v", err)
236236
}
@@ -278,7 +278,7 @@ func (pr *Prover) buildInitialState(blockNumber uint64) (*InitialState, error) {
278278

279279
// buildLatestFinalizedHeader returns the latest finalized header on this chain
280280
// The returned header is expected to be the latest one of headers that can be verified by the light client
281-
func (pr *Prover) GetLatestFinalizedHeader() (headers core.Header, err error) {
281+
func (pr *Prover) GetLatestFinalizedHeader(ctx context.Context) (headers core.Header, err error) {
282282
res, err := pr.beaconClient.GetLightClientFinalityUpdate()
283283
if err != nil {
284284
return nil, err
@@ -310,8 +310,8 @@ func (pr *Prover) GetLatestFinalizedHeader() (headers core.Header, err error) {
310310
}, nil
311311
}
312312

313-
func (pr *Prover) CheckRefreshRequired(counterparty core.ChainInfoICS02Querier) (bool, error) {
314-
cpQueryHeight, err := counterparty.LatestHeight()
313+
func (pr *Prover) CheckRefreshRequired(ctx context.Context, counterparty core.ChainInfoICS02Querier) (bool, error) {
314+
cpQueryHeight, err := counterparty.LatestHeight(context.TODO())
315315
if err != nil {
316316
return false, fmt.Errorf("failed to get the latest height of the counterparty chain: %v", err)
317317
}
@@ -338,12 +338,12 @@ func (pr *Prover) CheckRefreshRequired(counterparty core.ChainInfoICS02Querier)
338338
}
339339
lcLastTimestamp := time.Unix(0, int64(cons.GetTimestamp()))
340340

341-
selfQueryHeight, err := pr.chain.LatestHeight()
341+
selfQueryHeight, err := pr.chain.LatestHeight(context.TODO())
342342
if err != nil {
343343
return false, fmt.Errorf("failed to get the latest height of the self chain: %v", err)
344344
}
345345

346-
selfTimestamp, err := pr.chain.Timestamp(selfQueryHeight)
346+
selfTimestamp, err := pr.chain.Timestamp(context.TODO(), selfQueryHeight)
347347
if err != nil {
348348
return false, fmt.Errorf("failed to get timestamp of the self chain: %v", err)
349349
}

0 commit comments

Comments
 (0)