-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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: simapp/v2 #20412
base: main
Are you sure you want to change the base?
feat: simapp/v2 #20412
Conversation
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe updates span multiple files, focusing on enhancing the Go program's debugging configurations, refining module imports and initializations, improving state handling and encoding logic, and introducing new methods for state changes and consensus handling. These changes collectively aim to streamline the debugging process, enhance modularity, and ensure more robust state management and error handling. Changes
Sequence Diagram(s) (Beta)No significant control flow changes requiring sequence diagrams were identified. Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
if fd.IsExtension() { | ||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.CometInfo")) | ||
} | ||
panic(fmt.Errorf("message cosmos.consensus.v1.CometInfo does not contain field %s", fd.FullName())) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods Warning
store/v2/commitment/store.go
Outdated
@@ -113,6 +112,18 @@ func (c *CommitStore) GetLatestVersion() (uint64, error) { | |||
return version, nil | |||
} | |||
|
|||
func (c *CommitStore) IsEmpty() (bool, error) { |
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.
godoc
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.
Actionable comments posted: 4
Outside diff range and nitpick comments (2)
x/tx/decode/decode.go (2)
23-24
: Ensure the new fieldsDynamicMessages
andMessages
are properly documented.Adding comments to explain the purpose of these fields would enhance code readability and maintainability.
Line range hint
122-172
: Review the logic for handling dynamic and gogoproto messages.The logic for handling different types of messages can be complex. Consider simplifying this logic or breaking it down into smaller, more manageable functions.
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (2)
- simapp/v2/export.go (1 hunks)
- x/tx/decode/decode.go (6 hunks)
Files skipped from review as they are similar to previous changes (1)
- simapp/v2/export.go
Additional context used
Path-based instructions (1)
x/tx/decode/decode.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (2)
x/tx/decode/decode.go (2)
64-64
: Ensurecodec
is used correctly in theDecoder
struct.Verification successful
The
codec
field in theDecoder
struct is used correctly. TheNewDecoder
method ensures thatoptions.ProtoCodec
is not nil before assigning it to thecodec
field. TheDecode
method then uses thiscodec
field to unmarshal messages, which is consistent with its intended purpose.
NewDecoder
method checks foroptions.ProtoCodec
and assigns it tocodec
.Decode
method usesd.codec.Unmarshal
to unmarshal messages.No issues found with the usage of
codec
in theDecoder
struct.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that `codec` is used correctly throughout the `Decoder` struct. # Test: Search for the usage of `codec`. Expect: Correct and consistent usage. rg --type go 'codec' x/tx/decode/decode.goLength of output: 237
Script:
#!/bin/bash # Description: Extract the full implementation of the `Decoder` struct and its methods for comprehensive review. # Search for the `Decoder` struct definition and its methods. ast-grep --lang go --pattern $'type Decoder struct { $$$ }' x/tx/decode/decode.go # Search for methods associated with the `Decoder` struct. ast-grep --lang go --pattern $'func ($_ Decoder) $_($_) $_ { $$$ }' x/tx/decode/decode.goLength of output: 357
Script:
#!/bin/bash # Description: Search for the instantiation and usage of the `Decoder` struct in the codebase. # Search for the instantiation of the `Decoder` struct. rg --type go 'Decoder{' . # Search for the usage of the `Decoder` struct. rg --type go 'Decoder' .Length of output: 20998
Script:
#!/bin/bash # Description: Extract the implementation of `NewDecoder` and `Decode` methods for comprehensive review. # Extract the implementation of `NewDecoder` method. ast-grep --lang go --pattern $'func NewDecoder(options Options) (*Decoder, error) { $$$ }' x/tx/decode/decode.go # Extract the implementation of `Decode` method. ast-grep --lang go --pattern $'func (d *Decoder) Decode(txBytes []byte) (*DecodedTx, error) { $$$ }' x/tx/decode/decode.goLength of output: 6916
45-45
: Ensurecodec
is properly initialized and used.Verification successful
To ensure that
codec
is properly initialized and used, we need to verify the initialization ofoptions.ProtoCodec
and check its usage throughout the codebase.
The search results indicate that
options.ProtoCodec
is indeed initialized and used in various parts of the codebase. Specifically, it is assigned tocodec
and used in theUnmarshal
method, among other places.
x/tx/decode/decode.go: codec: options.ProtoCodec
x/tx/decode/decode.go: err = d.codec.Unmarshal(anyMsg.Value, msg)
Additionally,
ProtoCodec
is initialized in multiple files, ensuring that it is properly set up.
codec/proto_codec.go: func NewProtoCodec(interfaceRegistry types.InterfaceRegistry) *ProtoCodec {
Given this information, it is clear that
codec
is properly initialized and used.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that `codec` is properly initialized and used in all relevant parts of the code. # Test: Search for the usage of `codec`. Expect: Proper initialization and usage. rg --type go 'codec' x/tx/decode/decode.goLength of output: 237
Script:
#!/bin/bash # Description: Verify the initialization and usage of `options.ProtoCodec`. # Search for the initialization of `options.ProtoCodec`. rg --type go 'ProtoCodec' # Search for the usage of `options.ProtoCodec`. rg --type go 'options.ProtoCodec'Length of output: 21727
} | ||
|
||
return msgs, nil | ||
return dtx.Messages, nil |
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.
Tip
Codebase Verification
Ensure that dtx.Messages
is properly populated before calling GetMessages
. Currently, there are no assignments to dtx.Messages
in the codebase, which will result in GetMessages
returning nil or an error.
Analysis chain
Ensure that GetMessages
method returns correct data.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that `GetMessages` method returns the correct data.
# Test: Check the return values of `GetMessages`. Expect: Correct data based on input conditions.
rg --type go 'GetMessages' x/tx/decode/decode.go
Length of output: 113
Script:
#!/bin/bash
# Description: Extract the full implementation of the `GetMessages` method and analyze how `dtx.Messages` is populated.
# Extract the full implementation of the `GetMessages` method.
ast-grep --lang go --pattern $'func (dtx *DecodedTx) GetMessages() ([]transaction.Msg, error) {
$$$
}' x/tx/decode/decode.go
# Search for where `dtx.Messages` is populated within the codebase.
rg --type go 'dtx.Messages'
Length of output: 646
Script:
#!/bin/bash
# Description: Search for assignments to `dtx.Messages` within the codebase to verify how it is populated.
# Search for assignments to `dtx.Messages`.
rg --type go 'dtx.Messages\s*='
Length of output: 95
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.
Actionable comments posted: 2
Outside diff range and nitpick comments (6)
store/v2/commitment/store.go (4)
Line range hint
375-375
: Address the undefined error forErrorExportDone
.- if errors.Is(err, ErrorExportDone) { + if errors.Is(err, io.EOF) {
Line range hint
407-407
: Address the undefined error forImporter
.- var importer Importer + var importer snapshots.Importer
Line range hint
409-409
: Remove the unused variablestoreKey
.- storeKey declared and not used (typecheck)
Line range hint
8-8
: Remove the unused import "math".- "math"
server/v2/stf/stf.go (2)
Line range hint
38-40
: Define missing types forbranchFn
,makeGasMeterFn
, andmakeGasMeteredStateFn
.The types
branchFn
,makeGasMeterFn
, andmakeGasMeteredStateFn
are used in theSTF
struct but are not defined anywhere in the provided code. This will cause a compilation error. You should define these types or import them if they are defined in another package.
Line range hint
558-560
: Define or import the undefined types used innewExecutionContext
.The function
newExecutionContext
uses several types (branchFn
,makeGasMeterFn
,makeGasMeteredStateFn
) that are not defined in the provided code snippet. Ensure these types are properly defined or imported to avoid compilation errors.Also applies to: 606-608
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (4)
- server/v2/stf/stf.go (6 hunks)
- simapp/v2/simdv2/cmd/root_di.go (1 hunks)
- store/v2/commitment/store.go (1 hunks)
- store/v2/root/store.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- simapp/v2/simdv2/cmd/root_di.go
Additional context used
Path-based instructions (3)
store/v2/commitment/store.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.store/v2/root/store.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.server/v2/stf/stf.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
golangci-lint
store/v2/commitment/store.go
42-42: undefined: Tree (typecheck)
29-29: undefined: store (typecheck)
31-31: undefined: store (typecheck)
46-46: undefined: Tree (typecheck)
375-375: undefined: ErrorExportDone (typecheck)
407-407: undefined: Importer (typecheck)
409-409: storeKey declared and not used (typecheck)
8-8: "math" imported and not used (typecheck)
store/v2/root/store.go
33-33: undefined: store (typecheck)
36-36: undefined: store (typecheck)
22-22: undefined: store (typecheck)
67-67: undefined: store (typecheck)
68-68: undefined: store (typecheck)
72-72: undefined: store (typecheck)
130-130: undefined: store (typecheck)
134-134: undefined: store (typecheck)
166-166: undefined: store (typecheck)
115-115: undefined: NewReaderMap (typecheck)
127-127: undefined: NewReaderMap (typecheck)
177-177: undefined: store (typecheck)
182-182: undefined: store (typecheck)
191-191: undefined: store (typecheck)
197-197: undefined: store (typecheck)
206-206: undefined: store (typecheck)
395-395: no new variables on left side of := (typecheck)
server/v2/stf/stf.go
38-38: undefined: branchFn (typecheck)
39-39: undefined: makeGasMeterFn (typecheck)
40-40: undefined: makeGasMeteredStateFn (typecheck)
558-558: undefined: branchFn (typecheck)
559-559: undefined: makeGasMeterFn (typecheck)
560-560: undefined: makeGasMeteredStateFn (typecheck)
606-606: undefined: makeGasMeterFn (typecheck)
607-607: undefined: makeGasMeteredStateFn (typecheck)
608-608: undefined: branchFn (typecheck)
server/v2/stf/stf.go
Outdated
|
||
// setHeaderInfo sets the header info in the state to be used by queries in the future. | ||
func (s STF[T]) setHeaderInfo(state store.WriterMap, headerInfo header.Info) error { | ||
runtimeStore, err := state.GetWriter(appmanager.RuntimeIdentity) | ||
// TODO storing header info is too low level here, stf should be stateless. |
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.
Consider abstracting header info storage.
The comment suggests that storing header info at this level might be too low. It could be beneficial to abstract this functionality into a separate keeper or service to maintain the statelessness of the STF. This would align with the separation of concerns principle and potentially simplify the STF structure.
store/v2/root/store.go
Outdated
isEmpty, err := s.stateCommitment.IsEmpty() | ||
if err != nil { | ||
return fmt.Errorf("failed to check if SC store is empty: %w", err) | ||
} | ||
|
||
isEmpty, err := s.stateCommitment.IsEmpty() |
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.
Correct the variable redeclaration issue.
- isEmpty, err := s.stateCommitment.IsEmpty()
+ isEmpty, err = s.stateCommitment.IsEmpty()
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
isEmpty, err := s.stateCommitment.IsEmpty() | |
isEmpty, err = s.stateCommitment.IsEmpty() |
Tools
golangci-lint
395-395: no new variables on left side of := (typecheck)
@@ -101,6 +101,7 @@ func init() { | |||
ProvideModuleManager, | |||
ProvideGenesisTxHandler, | |||
ProvideCometService, | |||
ProvideAppVersionModifier, |
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 seems to be present in main 🤔
Description
Introduce simapp/v2 which runs on server/v2 infrastructure.
Depends on:
#20387Includes: #20483, #20485
Closes: #20492
Testing
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
Summary by CodeRabbit
New Features
Bug Fixes
Hash
andAppHash
fields in theInfo
struct.AppHash
length to ensure proper encoding.Refactor
ReaderMap
andWriterMap
interfaces for consistency.Chores