generated from rollkit/template-da-repo
-
Notifications
You must be signed in to change notification settings - Fork 3
feat: use datastore directly for state store #66
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
afa7904
feat: use datastore directly for state store
facundomedica 847ab68
missing commit
facundomedica f6f33b7
added prefix
facundomedica 719b785
lint
facundomedica 5179a57
lint
facundomedica b170ffa
merge
facundomedica 9823886
have a store struct
facundomedica 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
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -41,7 +41,7 @@ func (p *RpcProvider) Block(ctx context.Context, height *int64) (*coretypes.Resu | |
default: | ||
heightValue = p.normalizeHeight(height) | ||
} | ||
header, data, err := p.adapter.Store.GetBlockData(ctx, heightValue) | ||
header, data, err := p.adapter.RollkitStore.GetBlockData(ctx, heightValue) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -65,7 +65,7 @@ func (p *RpcProvider) Block(ctx context.Context, height *int64) (*coretypes.Resu | |
|
||
// BlockByHash implements client.CometRPC. | ||
func (p *RpcProvider) BlockByHash(ctx context.Context, hash []byte) (*coretypes.ResultBlock, error) { | ||
header, data, err := p.adapter.Store.GetBlockByHash(ctx, rlktypes.Hash(hash)) // Used types.Hash from rollkit/types | ||
header, data, err := p.adapter.RollkitStore.GetBlockByHash(ctx, rlktypes.Hash(hash)) // Used types.Hash from rollkit/types | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -120,7 +120,7 @@ func (p *RpcProvider) BlockResults(ctx context.Context, height *int64) (*coretyp | |
// Commit implements client.CometRPC. | ||
func (p *RpcProvider) Commit(ctx context.Context, height *int64) (*coretypes.ResultCommit, error) { | ||
heightValue := p.normalizeHeight(height) | ||
header, data, err := p.adapter.Store.GetBlockData(ctx, heightValue) | ||
header, data, err := p.adapter.RollkitStore.GetBlockData(ctx, heightValue) | ||
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. could you open an issue, this block structure is not the one we want to use. the header is not compatible with ibc here |
||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -156,7 +156,7 @@ func (p *RpcProvider) HeaderByHash(ctx context.Context, hash cmtbytes.HexBytes) | |
// decoding logic in the HTTP service will correctly translate from JSON. | ||
// See https://github.com/cometbft/cometbft/issues/6802 for context. | ||
|
||
header, data, err := p.adapter.Store.GetBlockByHash(ctx, rlktypes.Hash(hash)) // Used types.Hash from rollkit/types | ||
header, data, err := p.adapter.RollkitStore.GetBlockByHash(ctx, rlktypes.Hash(hash)) // Used types.Hash from rollkit/types | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -179,7 +179,7 @@ func (p *RpcProvider) HeaderByHash(ctx context.Context, hash cmtbytes.HexBytes) | |
func (p *RpcProvider) BlockchainInfo(ctx context.Context, minHeight int64, maxHeight int64) (*coretypes.ResultBlockchainInfo, error) { | ||
const limit int64 = 20 // Default limit used in the original code | ||
|
||
height, err := p.adapter.Store.Height(ctx) | ||
height, err := p.adapter.RollkitStore.Height(ctx) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get current height: %w", err) | ||
} | ||
|
@@ -211,7 +211,7 @@ func (p *RpcProvider) BlockchainInfo(ctx context.Context, minHeight int64, maxHe | |
|
||
// Re-fetch height in case new blocks were added during the loop? | ||
// The original code did this. | ||
finalHeight, err := p.adapter.Store.Height(ctx) | ||
finalHeight, err := p.adapter.RollkitStore.Height(ctx) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get final height: %w", err) | ||
} | ||
|
@@ -274,7 +274,7 @@ func (p *RpcProvider) BlockSearch(ctx context.Context, query string, pagePtr *in | |
apiResults := make([]*coretypes.ResultBlock, 0, pageSize) | ||
for i := skipCount; i < skipCount+pageSize; i++ { | ||
height := uint64(results[i]) | ||
header, data, err := p.adapter.Store.GetBlockData(ctx, height) | ||
header, data, err := p.adapter.RollkitStore.GetBlockData(ctx, height) | ||
if err != nil { | ||
// If a block referenced by indexer is missing, should we error out or just skip? | ||
// For now, error out. | ||
|
@@ -307,7 +307,7 @@ func (p *RpcProvider) Validators(ctx context.Context, heightPtr *int64, pagePtr | |
// depending on state pruning. The current implementation implicitly loads latest state. | ||
height := p.normalizeHeight(heightPtr) | ||
|
||
s, err := p.adapter.LoadState(ctx) // Loads the *latest* state | ||
s, err := p.adapter.Store.LoadState(ctx) // Loads the *latest* state | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to load current state: %w", err) | ||
} | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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
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.
Guard against nil
RollkitStore
before callingHeight
Even with the constructor fix, defensive code is advisable:
📝 Committable suggestion