-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support multiple chain ids in FinalizedChainsInfo #365
Merged
Merged
Changes from 26 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
9ad14f8
finalized chains info
gusin13 3ae0569
update proto
gusin13 8a8cb01
comments
gusin13 b2723d9
update tests
gusin13 d8caeaa
update comments
gusin13 823d3a5
update query
gusin13 5e729dc
fix e2e tests
gusin13 841411a
fix query params in e2e test
gusin13 a67ad65
add e2e test
gusin13 86b0302
add log
gusin13 a7feb68
clean up proto
gusin13 34f5a95
fix swag
gusin13 c2e1fda
update comment
gusin13 69a3775
fix e2e tests
gusin13 e956f83
wrap up input checker fn
gusin13 6d8ee0c
update docstring
gusin13 3c7002b
use empty url vals instead of nil
gusin13 160ed0a
remove err log
gusin13 bcaa672
optimize
gusin13 1f0868e
helper func
gusin13 6184aaa
add docstring
gusin13 4c76dc4
desc error message by caller
gusin13 b0936b6
wrap error
gusin13 ac08c02
optimize as per suggestions
gusin13 d161505
reduce loc
gusin13 5141fea
extra line
gusin13 ba3e00b
simplify exists
gusin13 425c3e7
simplify exists
gusin13 dcbb49d
simplify logic
gusin13 4b14662
fix comments
gusin13 abccd46
more comments
gusin13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package keeper | ||
|
||
import ( | ||
bbn "github.com/babylonchain/babylon/types" | ||
"github.com/babylonchain/babylon/x/zoneconcierge/types" | ||
"github.com/cosmos/cosmos-sdk/store/prefix" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
bbn "github.com/babylonchain/babylon/types" | ||
"github.com/babylonchain/babylon/x/zoneconcierge/types" | ||
) | ||
|
||
// GetEpochChainInfo gets the latest chain info of a given epoch for a given chain ID | ||
|
@@ -20,15 +21,16 @@ func (k Keeper) GetEpochChainInfo(ctx sdk.Context, chainID string, epochNumber u | |
return &chainInfo, nil | ||
} | ||
|
||
// EpochChainInfoExists checks if the latest chain info exists of a given epoch for a given chain ID | ||
func (k Keeper) EpochChainInfoExists(ctx sdk.Context, chainID string, epochNumber uint64) bool { | ||
store := k.epochChainInfoStore(ctx, chainID) | ||
epochNumberBytes := sdk.Uint64ToBigEndian(epochNumber) | ||
return store.Has(epochNumberBytes) | ||
} | ||
|
||
// GetLastFinalizedChainInfo gets the last finalised chain info recorded for a given chain ID | ||
// and the earliest epoch that snapshots this chain info | ||
func (k Keeper) GetLastFinalizedChainInfo(ctx sdk.Context, chainID string) (uint64, *types.ChainInfo, error) { | ||
// find the last finalised epoch | ||
finalizedEpoch, err := k.GetFinalizedEpoch(ctx) | ||
if err != nil { | ||
return 0, nil, err | ||
} | ||
|
||
func (k Keeper) GetLastFinalizedChainInfo(ctx sdk.Context, chainID string, finalizedEpoch uint64) (uint64, *types.ChainInfo, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Few things:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, fixed in my last commits. |
||
// find the chain info of this epoch | ||
chainInfo, err := k.GetEpochChainInfo(ctx, chainID, finalizedEpoch) | ||
if err != nil { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method can also be used on the first lines of the
GetEpochChainInfo
function above in order to not have duplicated logic.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure fixed