Skip to content

Commit

Permalink
removed unneeded state-index query
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin committed Apr 13, 2024
1 parent 3cd56c5 commit db3324d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ require (
github.com/libp2p/go-libp2p-kad-dht v0.21.1
github.com/libp2p/go-libp2p-pubsub v0.9.3
github.com/multiformats/go-multiaddr v0.11.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.16.0
github.com/rollkit/celestia-openrpc v0.0.0-00010101000000-000000000000
github.com/rs/cors v1.9.0
Expand Down Expand Up @@ -270,6 +269,7 @@ require (
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/linxGnu/grocksdb v1.8.12 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/regen-network/cosmos-proto v0.3.1 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,6 @@ github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQx
github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
github.com/dymensionxyz/cosmosclient v0.4.2-beta h1:sokBefcN1tIOlUKmB8Q2E9XMJ93LueqtFThiM/kA4DI=
github.com/dymensionxyz/cosmosclient v0.4.2-beta/go.mod h1:GQQu3ITEjWfi5ULR2B6X2i2YZNennY1yzcT5qdL4MGI=
github.com/dymensionxyz/dymension/v3 v3.1.0-rc01.0.20240402213116-e5302877e497 h1:hxo94dtPQc4A3CB8RuIFGcdMS2vIL483HR/dBUhP8po=
github.com/dymensionxyz/dymension/v3 v3.1.0-rc01.0.20240402213116-e5302877e497/go.mod h1:3Pfrr8j/BR9ztNKztGfC5PqDiO6CcrzMLCJtFtPEVW4=
github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56 h1:cmpJYdRviuUfmlJdHrcAND8Jd6JIY4rp63bWAQzPr54=
github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56/go.mod h1:3Pfrr8j/BR9ztNKztGfC5PqDiO6CcrzMLCJtFtPEVW4=
github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3 h1:vmAdUGUc4rTIiO3Phezr7vGq+0uPDVKSA4WAe8+yl6w=
Expand Down
16 changes: 5 additions & 11 deletions settlement/dymension/dymension.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,11 @@ func (d *HubClient) PostBatch(batch *types.Batch, daClient da.Client, daResult *

// GetLatestBatch returns the latest batch from the Dymension Hub.
func (d *HubClient) GetLatestBatch(rollappID string) (*settlement.ResultRetrieveBatch, error) {
var latestStateInfoIndexResp *rollapptypes.QueryGetLatestStateIndexResponse

var stateInfoResp *rollapptypes.QueryGetStateInfoResponse
err := d.RunWithRetry(func() error {
var err error
latestStateInfoIndexResp, err = d.rollappQueryClient.LatestStateIndex(d.ctx,
&rollapptypes.QueryGetLatestStateIndexRequest{RollappId: d.config.RollappID})
stateInfoResp, err = d.rollappQueryClient.StateInfo(d.ctx,
&rollapptypes.QueryGetStateInfoRequest{RollappId: d.config.RollappID})

if status.Code(err) == codes.NotFound {
return retry.Unrecoverable(settlement.ErrBatchNotFound)
Expand All @@ -302,17 +301,12 @@ func (d *HubClient) GetLatestBatch(rollappID string) (*settlement.ResultRetrieve
if err != nil {
return nil, err
}

// not supposed to happen, but just in case
if latestStateInfoIndexResp == nil {
if stateInfoResp == nil {
return nil, settlement.ErrEmptyResponse
}

latestBatch, err := d.GetBatchAtIndex(rollappID, latestStateInfoIndexResp.StateIndex.Index)
if err != nil {
return nil, err
}
return latestBatch, nil
return d.convertStateInfoToResultRetrieveBatch(&stateInfoResp.StateInfo)
}

// GetBatchAtIndex returns the batch at the given index from the Dymension Hub.
Expand Down

0 comments on commit db3324d

Please sign in to comment.