-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
fix: reimplement sig verification for app v2 #21386
Conversation
WalkthroughWalkthroughThe changes involve a series of updates across multiple files aimed at enhancing command execution outputs, refining testing expectations, and restructuring the gas management system within the Cosmos SDK. Key modifications include transitioning from Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLIWrapper
participant Command as Command Execution
CLI->>Command: runWithInput()
Command-->>CLI: CombinedOutput()
Note over CLI: Captures stdout and stderr together
sequenceDiagram
participant Validator as TxValidator
participant Decorator as SigVerificationDecorator
participant Module as AppModule
Module->>Validator: ValidateTx(tx)
Validator->>Decorator: AnteHandle(tx)
Decorator-->>Validator: Error or success
Validator-->>Module: Validation Result
Possibly related 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 Documentation and Community
|
@facundomedica your pull request is missing a changelog! |
@@ -19,5 +19,5 @@ jq '.app_state.gov.params.expedited_voting_period = "300s"' $SIMD_HOME/config/ge | |||
jq '.app_state.mint.minter.inflation = "0.300000000000000000"' $SIMD_HOME/config/genesis.json > temp.json && mv temp.json $SIMD_HOME/config/genesis.json # to change the inflation | |||
$SIMD_BIN genesis add-genesis-account alice 5000000000stake --keyring-backend test | |||
$SIMD_BIN genesis add-genesis-account bob 5000000000stake --keyring-backend test | |||
$SIMD_BIN genesis gentx alice 1000000stake --chain-id demo | |||
$SIMD_BIN genesis gentx alice 1000000stake --chain-id simapp-v2-chain |
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 was failing now that we check sigs 😅
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: 0
Outside diff range, codebase verification and nitpick comments (2)
tests/systemtests/staking_test.go (1)
38-39
: Clarify the TODO comment and expected balance assertion.The TODO comment indicates that the balance assertion is temporary until the fee decorator is implemented. Ensure that this is tracked and updated once the decorator is complete.
Consider adding a reference to the issue or task tracking the fee decorator implementation for better traceability.
x/auth/ante/ante.go (1)
5-5
: Refactor remaining references tostoretypes.GasMeter
.The codebase still contains several references to
storetypes.GasMeter
, which suggests that the refactoring togas.Meter
is incomplete. Please review and update the following occurrences to ensure consistency:
types/context.go
: Multiple references.x/auth/ante/sigverify_test.go
: Line withstoretypes.GasMeter
.x/auth/ante/ante_test.go
: Line withSigGasConsumer
.server/mock/store.go
: Function usingstoretypes.GasMeter
.runtime/gas.go
: Reference tostoretypes.GasMeter
.baseapp/baseapp.go
: Function returningstoretypes.GasMeter
.Analysis chain
Review the change in
SigGasConsumer
function signature.The change from
storetypes.GasMeter
togas.Meter
suggests a refactoring of the gas management system. Ensure that all dependent code is updated to accommodate this change.Check for any other references to
storetypes.GasMeter
in the codebase to ensure consistency. Use the following script to verify:Also applies to: 24-24
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify references to `storetypes.GasMeter` in the codebase. # Test: Search for references. Expect: No occurrences of `storetypes.GasMeter`. rg --type go 'storetypes.GasMeter'Length of output: 1123
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (7)
- tests/systemtests/cli.go (1 hunks)
- tests/systemtests/staking_test.go (1 hunks)
- tests/systemtests/unordered_tx_test.go (1 hunks)
- x/auth/ante/ante.go (2 hunks)
- x/auth/ante/sigverify.go (12 hunks)
- x/auth/tx/config/depinject.go (5 hunks)
- x/auth/types/account_retriever.go (2 hunks)
Files skipped from review due to trivial changes (1)
- tests/systemtests/unordered_tx_test.go
Additional context used
Path-based instructions (6)
tests/systemtests/staking_test.go (3)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
tests/**/*
: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"x/auth/ante/ante.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/auth/types/account_retriever.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/auth/tx/config/depinject.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.tests/systemtests/cli.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
tests/**/*
: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"x/auth/ante/sigverify.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (15)
x/auth/types/account_retriever.go (1)
79-80
: Enhance error handling inGetAccountNumberSequence
.The additional condition for checking wrapped errors from CometBFT improves the robustness of error handling. This ensures that the method can gracefully handle cases where an account might not exist.
Ensure that similar error handling improvements are applied consistently across other methods if applicable.
x/auth/tx/config/depinject.go (5)
18-19
: Imports look good.The new imports
appmodulev2
andtransaction
are appropriate for the added functionalities.
58-58
: Addition ofAccountAbstractionKeeper
is appropriate.The new field enhances the module's capability to handle account abstractions.
69-69
: Addition ofModule
field is appropriate.The new field encapsulates transaction validation functionality, aligning with architectural goals.
147-155
: Integration ofAppModule
with signature verification is appropriate.The changes enhance transaction validation capabilities by integrating signature verification into the module's output.
241-254
:AppModule
struct and methods are well-implemented.The struct and its methods align with the architectural goal of enhancing transaction validation.
tests/systemtests/cli.go (1)
226-226
: Use ofCombinedOutput()
is a good change.Capturing both stdout and stderr enhances debugging capabilities.
x/auth/ante/sigverify.go (8)
51-51
: Transition togas.Meter
is appropriate.The change aligns with updated standards for gas management.
502-515
: Use ofgas.Meter
inDefaultSigVerificationGasConsumer
is appropriate.The change aligns with the updated gas management approach.
594-594
: Use ofcontext.Context
inGetSignerAcc
is appropriate.The change aligns with broader Go conventions, improving consistency.
230-230
: Use ofcontext.Context
inauthenticate
is appropriate.The change aligns with broader Go conventions, improving consistency.
Line range hint
287-302
: Use ofcontext.Context
inconsumeSignatureGas
is appropriate.The change aligns with broader Go conventions, improving consistency.
306-306
: Use ofcontext.Context
inverifySig
is appropriate.The change aligns with broader Go conventions, improving consistency.
379-379
: Use ofcontext.Context
insetPubKey
is appropriate.The change aligns with broader Go conventions, improving consistency.
427-427
: Use ofcontext.Context
inauthenticateAbstractedAccount
is appropriate.The change aligns with broader Go conventions, improving consistency.
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: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (4)
- contrib/images/simd-env/Dockerfile (2 hunks)
- contrib/images/simd-env/wrapper.sh (2 hunks)
- scripts/init-simapp-v2.sh (1 hunks)
- simapp/simd/cmd/testnet_test.go (1 hunks)
Additional context used
Path-based instructions (1)
simapp/simd/cmd/testnet_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
Additional comments not posted (6)
contrib/images/simd-env/wrapper.sh (2)
5-5
: Update binary path tosimdv2
.The binary path has been updated to use
simdv2
, which aligns with the new versioning. Ensure that thesimdv2
binary is available in the specified location.
14-14
: Update SIMD home directory tosimdv2
.The home directory path has been updated to
simdv2
, which is consistent with the new binary version. Verify that the directory structure supports this change.scripts/init-simapp-v2.sh (1)
22-22
: Update chain ID tosimapp-v2-chain
.The chain ID has been updated to
simapp-v2-chain
, which reflects the new version of the simulation application. Ensure that all configurations and dependencies are aligned with this new chain ID.contrib/images/simd-env/Dockerfile (2)
36-36
: SetCOSMOS_BUILD_OPTIONS
tov2
.The build options have been updated to
v2
, indicating a version update in the build configuration. Ensure that the build process and dependencies are compatible with this change.
49-49
: Update output binary name tosimdv2
.The output binary name has been changed to
simdv2
, reflecting a version update. Verify that all references to the binary are updated accordingly.simapp/simd/cmd/testnet_test.go (1)
48-48
: Verify the module registration.The change in the expected length of
moduleManager.Modules
from 8 to 9 suggests an additional module registration. Ensure that this aligns with the application's requirements and that all necessary modules are correctly registered and tested.
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: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (4)
- contrib/images/simd-env/Dockerfile (2 hunks)
- contrib/images/simd-env/wrapper.sh (2 hunks)
- scripts/init-simapp-v2.sh (1 hunks)
- simapp/simd/cmd/testnet_test.go (1 hunks)
Additional context used
Path-based instructions (1)
simapp/simd/cmd/testnet_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
Additional comments not posted (6)
contrib/images/simd-env/wrapper.sh (2)
5-5
: Update binary version reference.The
BINARY
variable has been updated to default tosimdv2
, reflecting a version change. Ensure that this change is consistent with the rest of the system and that all references to the binary are updated accordingly.
14-14
: Update SIMDHOME path for new version.The
SIMDHOME
variable now points to a directory withsimdv2
, indicating a version update. Verify that all configurations and dependencies are aligned with this new path.scripts/init-simapp-v2.sh (1)
22-22
: Update chain ID for genesis transaction.The chain ID has been updated to
simapp-v2-chain
, which matches the versioning of the application. Ensure that this change is reflected in all relevant configurations and documentation.contrib/images/simd-env/Dockerfile (2)
36-36
: Introduce COSMOS_BUILD_OPTIONS for build process.The build command now includes
COSMOS_BUILD_OPTIONS=v2
, indicating a new build configuration. Verify that this option is correctly supported and documented in the build process.
49-49
: Update output binary name to simdv2.The output binary is now named
simdv2
, reflecting a version update. Ensure that all scripts and configurations that reference the binary are updated to use this new name.simapp/simd/cmd/testnet_test.go (1)
48-48
: LGTM! Verify module registration.The update in the expected length of
moduleManager.Modules
from 8 to 9 reflects the addition of a new module. Ensure that the module registration is correctly handled elsewhere in the codebase.
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: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (4)
- contrib/images/simd-env/Dockerfile (2 hunks)
- contrib/images/simd-env/wrapper.sh (2 hunks)
- scripts/init-simapp-v2.sh (1 hunks)
- simapp/simd/cmd/testnet_test.go (1 hunks)
Additional context used
Path-based instructions (1)
simapp/simd/cmd/testnet_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
Additional comments not posted (6)
contrib/images/simd-env/wrapper.sh (2)
5-5
: Verify the availability of the new binary.The
BINARY
variable now defaults tosimdv2
. Ensure that this binary is available in the expected location and is compatible with the rest of the system.
14-14
: Verify the directory structure forSIMDHOME
.The
SIMDHOME
path now reflects the new binary version. Ensure that the directory structure supports this change and that all related configurations are updated accordingly.scripts/init-simapp-v2.sh (1)
22-22
: Verify the consistency of the chain ID update.The chain ID has been updated to
simapp-v2-chain
. Ensure that all related configurations, scripts, and dependencies are updated to reflect this change.contrib/images/simd-env/Dockerfile (2)
36-36
: Verify the integration of the new build option.The build command now includes
COSMOS_BUILD_OPTIONS=v2
. Ensure that this option is correctly integrated and compatible with the build process.
49-49
: Verify the consistency of the artifact name update.The output artifact has been renamed to
simdv2
. Ensure that all references to this artifact in the system are updated to reflect this change.simapp/simd/cmd/testnet_test.go (1)
48-48
: Update the assertion to reflect the correct number of modules.The assertion now expects 9 modules instead of 8, which aligns with the updated test setup. The comment provides clarity on the inclusion of the runtime module.
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: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files ignored due to path filters (1)
core/testing/go.sum
is excluded by!**/*.sum
Files selected for processing (6)
- core/testing/gas/service_mocks.go (1 hunks)
- core/testing/go.mod (1 hunks)
- scripts/mockgen.sh (1 hunks)
- x/auth/ante/ante_test.go (2 hunks)
- x/auth/ante/sigverify.go (14 hunks)
- x/auth/ante/sigverify_test.go (5 hunks)
Files skipped from review due to trivial changes (1)
- core/testing/gas/service_mocks.go
Files skipped from review as they are similar to previous changes (1)
- x/auth/ante/sigverify.go
Additional context used
Path-based instructions (2)
x/auth/ante/sigverify_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"x/auth/ante/ante_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
Additional comments not posted (7)
core/testing/go.mod (1)
9-9
: Addition ofgithub.com/golang/mock
dependency is appropriate.The inclusion of
github.com/golang/mock v1.6.0
enhances the testing framework by enabling mock object usage, which is beneficial for isolating components during testing.scripts/mockgen.sh (1)
29-29
: Addition of mock generation forcore/gas/service.go
is appropriate.The new command enhances the script's functionality by allowing for the mocking of the gas service, which is crucial for testing purposes.
x/auth/ante/sigverify_test.go (4)
11-12
: New imports for gas management are appropriate.The additions of
cosmossdk.io/core/gas
andgastestutil
are necessary for the updated gas management structure and mock gas meter utility.
61-131
: Enhancements toTestConsumeSignatureVerificationGas
improve test precision.The introduction of a mock gas meter and the
malleate
function allows for more precise and clear testing of gas consumption during signature verification.
196-196
: Update tonoOpGasConsume
aligns with new gas management.The change to use
gas.Meter
ensures consistency with the updated gas management structure.
Line range hint
318-318
: Comprehensive test coverage inTestAnteHandlerChecks
.The test cases cover various scenarios for signature verification with different key types, ensuring thorough testing of the logic.
x/auth/ante/ante_test.go (1)
1269-1272
: Verify the change in gas meter type and method.The
meter
parameter type has been updated fromstoretypes.GasMeter
togas.Meter
, andConsumeGas
is replaced withConsume
. Ensure that this change is consistent with the rest of the codebase and that the new method behaves as expected.Run the following script to verify the usage of
gas.Meter
andConsume
in the codebase:Verification successful
Change Verified: Consistent Usage of
gas.Meter
andConsume
The update from
storetypes.GasMeter
togas.Meter
and fromConsumeGas
toConsume
is consistent across the codebase. TheConsume
method is used in various contexts, confirming that the change aligns with the expected behavior. No issues were found with this refactoring.
- The
gas.Meter
type andConsume
method are used consistently in both tests and implementations.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `gas.Meter` and `Consume` in the codebase. # Test: Search for the usage of `gas.Meter` and `Consume`. Expect: Consistent usage across the codebase. rg --type go -A 5 'gas.Meter' rg --type go -A 5 'Consume'Length of output: 85191
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: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (5)
- x/auth/ante/ante_test.go (4 hunks)
- x/auth/ante/sigverify.go (14 hunks)
- x/auth/ante/sigverify_test.go (8 hunks)
- x/auth/ante/testutil_test.go (2 hunks)
- x/auth/client/cli/tx_multisign.go (1 hunks)
Files skipped from review due to trivial changes (1)
- x/auth/client/cli/tx_multisign.go
Files skipped from review as they are similar to previous changes (1)
- x/auth/ante/ante_test.go
Additional context used
Path-based instructions (3)
x/auth/ante/testutil_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"x/auth/ante/sigverify_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"x/auth/ante/sigverify.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (9)
x/auth/ante/testutil_test.go (1)
81-81
: LGTM: Addition of header information to context.The inclusion of
WithHeaderInfo
enhances the context setup by providing block height and chain ID, which is useful for tests requiring blockchain state awareness.x/auth/ante/sigverify_test.go (2)
11-11
: LGTM: Import ofgas
package.The import of the
gas
package is necessary for the updated gas management system.
197-197
: LGTM: Update tonoOpGasConsume
function.The update to use
gas.Meter
instead ofstoretypes.GasMeter
aligns with the new gas management structure.x/auth/ante/sigverify.go (6)
13-14
: LGTM: Import ofevent
andgas
packages.The import of these packages is necessary for the updated event management and gas consumption logic.
51-51
: LGTM: Update toSignatureVerificationGasConsumer
type.The change to use
gas.Meter
reflects the updated gas management system.
154-158
: LGTM: Update toAnteHandle
method.The inclusion of
ValidateTx
enhances error handling by directly returning errors.
203-226
: LGTM: Use of event manager for event emission.The structured event emission using an event manager improves the organization and handling of emitted events.
512-526
: LGTM: Update toDefaultSigVerificationGasConsumer
.The transition to
gas.Meter
and the updated logic for consuming gas based on public key type align with the new gas management structure.
604-604
: Verify the impact of context changes on the codebase.The change from
sdk.Context
tocontext.Context
in function signatures may affect other parts of the codebase.Run the following script to verify the usage of updated function signatures:
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.
ACK
@@ -12,6 +12,7 @@ import ( | |||
) | |||
|
|||
func TestUnorderedTXDuplicate(t *testing.T) { | |||
t.Skip() |
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.
can you add a short todo as to why its skipped?
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.
will do this and merge
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.
LGTM
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: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (2)
- tests/systemtests/staking_test.go (1 hunks)
- tests/systemtests/unordered_tx_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- tests/systemtests/staking_test.go
- tests/systemtests/unordered_tx_test.go
@Mergifyio backport release/v0.52.x |
✅ Backports have been created
|
(cherry picked from commit 7c85b98) # Conflicts: # core/testing/go.mod # core/testing/go.sum
Co-authored-by: Facundo Medica <[email protected]> Co-authored-by: Julien Robert <[email protected]>
Description
I also removed the usages ofhandling it optionally now, only if context is an sdk.Context, otherwise we'll always verify the signature!ctx.IsSigverifyTx()
, I'm unsure of the impact of thisAuthor 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.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit
Bug Fixes
Tests
New Features