-
Notifications
You must be signed in to change notification settings - Fork 836
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(precompile): add FundCommunityPool
precompile tx for distribution module
#2572
feat(precompile): add FundCommunityPool
precompile tx for distribution module
#2572
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2572 +/- ##
===========================================
- Coverage 70.45% 59.06% -11.40%
===========================================
Files 293 342 +49
Lines 22559 21754 -805
===========================================
- Hits 15893 12848 -3045
- Misses 5800 7823 +2023
- Partials 866 1083 +217
|
FundCommunityPool
precompile tx for distribution module
I don't know how to fix "Lint / Run golangci-lint (pull_request) " |
Thanks for the contribution @luchenqun!! |
Can you please add some integration tests?
|
It would be better if you could provide a previously implemented for the second test case. |
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.
Thanks @luchenqun!
Signed-off-by: stepit <[email protected]>
@luchenqun can you please address the conficts? |
Hey @luchenqun tests are now failing because |
Warning Walkthrough skippedFile diffs could not be summarized. 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 (
|
It's possible that when I merged with the main branch, I used the content from the main branch in these two files. But now I have updated them back, hahaha. @0xstepit There is still a E2E Test / test-nix (test_filters.py) (pull_request) that has not passed. I don't know what the problem is, I need you to take a look. |
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: 7
Outside diff range and nitpick comments (7)
precompiles/distribution/types.go (1)
48-52
: Add documentation forEventFundCommunityPool
.It's a good practice to include comments explaining the purpose and usage of newly introduced types. This helps maintain readability and usability of the codebase.
tests/nix_tests/utils.py (4)
Line range hint
103-104
: Convert to f-string for better readability and performance.- "Waited too long for the port {} on host {} to start accepting connections.".format(port, host) + f"Waited too long for the port {port} on host {host} to start accepting connections."
Line range hint
172-172
: Rename unused loop variable for clarity.- for i in range(int(timeout / interval)): + for _i in range(int(timeout / interval)):
Line range hint
374-374
: Useisinstance()
for type checking instead of direct type comparison.- if type(attr["key"]) is str: + if isinstance(attr["key"], str):
Line range hint
488-488
: Avoid using mutable default arguments to prevent bugs.- def build_deploy_contract_tx(w3, info, args=(), key=KEYS["validator"]): + def build_deploy_contract_tx(w3, info, args=None, key=KEYS["validator"]): + if args is None: + args = ()CHANGELOG.md (2)
Line range hint
932-932
: Indentation issue detected in unordered list items.- - (deps) [#1985](https://github.com/evmos/evmos/pull/1985) Add CI action to check for a Changelog entry on PRs to `main`. + - (deps) [#1985](https://github.com/evmos/evmos/pull/1985) Add CI action to check for a Changelog entry on PRs to `main`.Tools
Markdownlint
55-55: Expected: 120; Actual: 134 (MD013, line-length)
Line length
57-57: Expected: 120; Actual: 128 (MD013, line-length)
Line length
Line range hint
48-48
: Line exceeds the recommended character limit.Consider breaking this line into two to improve readability and adhere to Markdown best practices.
Tools
Markdownlint
55-55: Expected: 120; Actual: 134 (MD013, line-length)
Line length
57-57: Expected: 120; Actual: 128 (MD013, line-length)
Line length
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (17)
- .github/workflows/e2e-test.yml (1 hunks)
- CHANGELOG.md (1 hunks)
- precompiles/common/errors.go (1 hunks)
- precompiles/distribution/DistributionI.sol (6 hunks)
- precompiles/distribution/abi.json (2 hunks)
- precompiles/distribution/distribution.go (2 hunks)
- precompiles/distribution/distribution_test.go (2 hunks)
- precompiles/distribution/events.go (2 hunks)
- precompiles/distribution/events_test.go (2 hunks)
- precompiles/distribution/integration_test.go (5 hunks)
- precompiles/distribution/tx.go (7 hunks)
- precompiles/distribution/tx_test.go (1 hunks)
- precompiles/distribution/types.go (3 hunks)
- precompiles/testutil/contracts/DistributionCaller.sol (10 hunks)
- tests/nix_tests/cosmoscli.py (1 hunks)
- tests/nix_tests/test_distr_precompile.py (1 hunks)
- tests/nix_tests/utils.py (1 hunks)
Files not summarized due to errors (2)
- precompiles/distribution/distribution_test.go: Error: Server error. Please try again later.
- tests/nix_tests/cosmoscli.py: Error: Server error. Please try again later.
Files not reviewed due to errors (7)
- precompiles/common/errors.go (Error: Server error. Please try again later.)
- tests/nix_tests/test_distr_precompile.py (Error: Server error. Please try again later.)
- precompiles/distribution/distribution.go (Error: Server error. Please try again later.)
- precompiles/distribution/events.go (Error: Server error. Please try again later.)
- precompiles/distribution/tx.go (Error: Server error. Please try again later.)
- precompiles/distribution/tx_test.go (Error: Server error. Please try again later.)
- precompiles/distribution/abi.json (Error: Server error. Please try again later.)
Files skipped from review due to trivial changes (1)
- .github/workflows/e2e-test.yml
Additional context used
GitHub Check: codecov/patch
precompiles/distribution/events.go
[warning] 175-175: precompiles/distribution/events.go#L175
Added line #L175 was not covered by testsprecompiles/distribution/tx.go
[warning] 243-243: precompiles/distribution/tx.go#L243
Added line #L243 was not covered by tests
[warning] 249-249: precompiles/distribution/tx.go#L249
Added line #L249 was not covered by tests
[warning] 259-259: precompiles/distribution/tx.go#L259
Added line #L259 was not covered by testsprecompiles/distribution/types.go
[warning] 169-169: precompiles/distribution/types.go#L169
Added line #L169 was not covered by tests
[warning] 178-178: precompiles/distribution/types.go#L178
Added line #L178 was not covered by tests
Ruff
tests/nix_tests/utils.py
103-104: Use f-string instead of
format
call (UP032)Convert to f-string
172-172: Loop control variable
i
not used within loop body (B007)Rename unused
i
to_i
374-374: Do not compare types, use
isinstance()
(E721)
488-488: Do not use mutable data structures for argument defaults (B006)
Replace with
None
; initialize within function
Markdownlint
CHANGELOG.md
932-932: Expected: 4; Actual: 2 (MD007, ul-indent)
Unordered list indentation
933-933: Expected: 4; Actual: 2 (MD007, ul-indent)
Unordered list indentation
934-934: Expected: 4; Actual: 2 (MD007, ul-indent)
Unordered list indentation
48-48: Expected: 120; Actual: 127 (MD013, line-length)
Line length
55-55: Expected: 120; Actual: 134 (MD013, line-length)
Line length
57-57: Expected: 120; Actual: 128 (MD013, line-length)
Line length
71-71: Expected: 120; Actual: 162 (MD013, line-length)
Line length
74-74: Expected: 120; Actual: 167 (MD013, line-length)
Line length
80-80: Expected: 120; Actual: 132 (MD013, line-length)
Line length
83-83: Expected: 120; Actual: 152 (MD013, line-length)
Line length
90-90: Expected: 120; Actual: 137 (MD013, line-length)
Line length
105-105: Expected: 120; Actual: 129 (MD013, line-length)
Line length
120-120: Expected: 120; Actual: 142 (MD013, line-length)
Line length
121-121: Expected: 120; Actual: 133 (MD013, line-length)
Line length
176-176: Expected: 120; Actual: 151 (MD013, line-length)
Line length
180-180: Expected: 120; Actual: 147 (MD013, line-length)
Line length
182-182: Expected: 120; Actual: 149 (MD013, line-length)
Line length
183-183: Expected: 120; Actual: 154 (MD013, line-length)
Line length
187-187: Expected: 120; Actual: 148 (MD013, line-length)
Line length
188-188: Expected: 120; Actual: 128 (MD013, line-length)
Line length
191-191: Expected: 120; Actual: 131 (MD013, line-length)
Line length
202-202: Expected: 120; Actual: 150 (MD013, line-length)
Line length
214-214: Expected: 120; Actual: 189 (MD013, line-length)
Line length
224-224: Expected: 120; Actual: 134 (MD013, line-length)
Line length
230-230: Expected: 120; Actual: 130 (MD013, line-length)
Line length
234-234: Expected: 120; Actual: 138 (MD013, line-length)
Line length
238-238: Expected: 120; Actual: 137 (MD013, line-length)
Line length
244-244: Expected: 120; Actual: 136 (MD013, line-length)
Line length
246-246: Expected: 120; Actual: 137 (MD013, line-length)
Line length
248-248: Expected: 120; Actual: 132 (MD013, line-length)
Line length
249-249: Expected: 120; Actual: 144 (MD013, line-length)
Line length
251-251: Expected: 120; Actual: 164 (MD013, line-length)
Line length
252-252: Expected: 120; Actual: 139 (MD013, line-length)
Line length
255-255: Expected: 120; Actual: 139 (MD013, line-length)
Line length
265-265: Expected: 120; Actual: 129 (MD013, line-length)
Line length
266-266: Expected: 120; Actual: 142 (MD013, line-length)
Line length
272-272: Expected: 120; Actual: 186 (MD013, line-length)
Line length
273-273: Expected: 120; Actual: 153 (MD013, line-length)
Line length
277-277: Expected: 120; Actual: 139 (MD013, line-length)
Line length
279-279: Expected: 120; Actual: 152 (MD013, line-length)
Line length
285-285: Expected: 120; Actual: 149 (MD013, line-length)
Line length
286-286: Expected: 120; Actual: 159 (MD013, line-length)
Line length
288-288: Expected: 120; Actual: 132 (MD013, line-length)
Line length
290-290: Expected: 120; Actual: 172 (MD013, line-length)
Line length
307-307: Expected: 120; Actual: 149 (MD013, line-length)
Line length
309-309: Expected: 120; Actual: 145 (MD013, line-length)
Line length
319-319: Expected: 120; Actual: 231 (MD013, line-length)
Line length
322-322: Expected: 120; Actual: 142 (MD013, line-length)
Line length
328-328: Expected: 120; Actual: 145 (MD013, line-length)
Line length
331-331: Expected: 120; Actual: 155 (MD013, line-length)
Line length
332-332: Expected: 120; Actual: 138 (MD013, line-length)
Line length
333-333: Expected: 120; Actual: 151 (MD013, line-length)
Line length
334-334: Expected: 120; Actual: 132 (MD013, line-length)
Line length
335-335: Expected: 120; Actual: 160 (MD013, line-length)
Line length
357-357: Expected: 120; Actual: 172 (MD013, line-length)
Line length
361-361: Expected: 120; Actual: 142 (MD013, line-length)
Line length
362-362: Expected: 120; Actual: 138 (MD013, line-length)
Line length
377-377: Expected: 120; Actual: 141 (MD013, line-length)
Line length
380-380: Expected: 120; Actual: 127 (MD013, line-length)
Line length
381-381: Expected: 120; Actual: 141 (MD013, line-length)
Line length
393-393: Expected: 120; Actual: 169 (MD013, line-length)
Line length
399-399: Expected: 120; Actual: 147 (MD013, line-length)
Line length
412-412: Expected: 120; Actual: 158 (MD013, line-length)
Line length
414-414: Expected: 120; Actual: 306 (MD013, line-length)
Line length
432-432: Expected: 120; Actual: 147 (MD013, line-length)
Line length
438-438: Expected: 120; Actual: 180 (MD013, line-length)
Line length
449-449: Expected: 120; Actual: 168 (MD013, line-length)
Line length
489-489: Expected: 120; Actual: 138 (MD013, line-length)
Line length
490-490: Expected: 120; Actual: 131 (MD013, line-length)
Line length
500-500: Expected: 120; Actual: 129 (MD013, line-length)
Line length
508-508: Expected: 120; Actual: 262 (MD013, line-length)
Line length
516-516: Expected: 120; Actual: 143 (MD013, line-length)
Line length
521-521: Expected: 120; Actual: 133 (MD013, line-length)
Line length
522-522: Expected: 120; Actual: 143 (MD013, line-length)
Line length
527-527: Expected: 120; Actual: 140 (MD013, line-length)
Line length
537-537: Expected: 120; Actual: 142 (MD013, line-length)
Line length
544-544: Expected: 120; Actual: 262 (MD013, line-length)
Line length
566-566: Expected: 120; Actual: 136 (MD013, line-length)
Line length
579-579: Expected: 120; Actual: 130 (MD013, line-length)
Line length
586-586: Expected: 120; Actual: 135 (MD013, line-length)
Line length
601-601: Expected: 120; Actual: 230 (MD013, line-length)
Line length
602-602: Expected: 120; Actual: 131 (MD013, line-length)
Line length
603-603: Expected: 120; Actual: 177 (MD013, line-length)
Line length
604-604: Expected: 120; Actual: 203 (MD013, line-length)
Line length
605-605: Expected: 120; Actual: 156 (MD013, line-length)
Line length
609-609: Expected: 120; Actual: 148 (MD013, line-length)
Line length
617-617: Expected: 120; Actual: 163 (MD013, line-length)
Line length
672-672: Expected: 120; Actual: 160 (MD013, line-length)
Line length
696-696: Expected: 120; Actual: 226 (MD013, line-length)
Line length
701-701: Expected: 120; Actual: 145 (MD013, line-length)
Line length
757-757: Expected: 120; Actual: 140 (MD013, line-length)
Line length
765-765: Expected: 120; Actual: 166 (MD013, line-length)
Line length
769-769: Expected: 120; Actual: 147 (MD013, line-length)
Line length
793-793: Expected: 120; Actual: 169 (MD013, line-length)
Line length
798-798: Expected: 120; Actual: 141 (MD013, line-length)
Line length
799-799: Expected: 120; Actual: 167 (MD013, line-length)
Line length
835-835: Expected: 120; Actual: 144 (MD013, line-length)
Line length
845-845: Expected: 120; Actual: 146 (MD013, line-length)
Line length
846-846: Expected: 120; Actual: 233 (MD013, line-length)
Line length
848-848: Expected: 120; Actual: 159 (MD013, line-length)
Line length
856-856: Expected: 120; Actual: 160 (MD013, line-length)
Line length
857-857: Expected: 120; Actual: 133 (MD013, line-length)
Line length
909-909: Expected: 120; Actual: 131 (MD013, line-length)
Line length
926-926: Expected: 120; Actual: 131 (MD013, line-length)
Line length
932-932: Expected: 120; Actual: 163 (MD013, line-length)
Line length
954-954: Expected: 120; Actual: 184 (MD013, line-length)
Line length
967-967: Expected: 120; Actual: 168 (MD013, line-length)
Line length
987-987: Expected: 120; Actual: 154 (MD013, line-length)
Line length
Additional comments not posted (8)
precompiles/testutil/contracts/DistributionCaller.sol (2)
72-87
: The functiontestFundCommunityPool
successfully implements the new feature.This function correctly increments and decrements the
counter
around the call tofundCommunityPool
, which is a good use of state management to track function calls.
15-17
: Ensure consistent use of address types.Also applies to: 25-27, 36-38, 47-49, 57-58, 66-70, 78-87, 95-96, 104-105, 120-133, 142-144, 150-155, 172-173, 191-193, 203-208, 219-224, 234-238
Verification successful
The script output indicates that
address
type parameters are used consistently across the Solidity files. There are no apparent inconsistencies in the usage ofaddress
parameters within the provided lines and the overall file.
- File:
precompiles/testutil/contracts/DistributionCaller.sol
- Lines: 15-17, 25-27, 36-38, 47-49, 57-58, 66-70, 78-87, 95-96, 104-105, 120-133, 142-144, 150-155, 172-173, 191-193, 203-208, 219-224, 234-238
The usage of
address
parameters appears consistent across the specified lines.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all address parameters across functions are consistently used. # Test: Search for the usage of address type parameters. Expect: Consistent usage. rg --type solidity $'address'Length of output: 61
Script:
#!/bin/bash # Description: Find all Solidity files and search for address type parameters. # Step 1: Find all Solidity files. sol_files=$(fd . --extension sol) # Step 2: Search for address type parameters within these files. for file in $sol_files; do echo "File: $file" rg 'address' "$file" doneLength of output: 38077
precompiles/distribution/distribution_test.go (2)
39-43
: The test case forFundCommunityPoolMethod
is correctly added.The addition of this test case ensures that the new functionality is covered by the suite, which is crucial for maintaining the robustness of the feature.
158-172
: Integration test forFundCommunityPoolMethod
is implemented correctly.The test setup and execution for the new
FundCommunityPoolMethod
are well-implemented, ensuring the functionality works as expected under simulated conditions.precompiles/distribution/DistributionI.sol (1)
71-76
: TheFundCommunityPool
event and method are correctly defined.The addition of these definitions is crucial for the new functionality, allowing interaction with the community pool through a precompiled contract.
Also applies to: 114-123
precompiles/distribution/events_test.go (1)
254-289
: The test for theFundCommunityPool
event is implemented correctly.This test ensures that the event is emitted correctly when the
FundCommunityPool
function is called, which is essential for verifying the integration of the new feature.precompiles/distribution/types.go (1)
159-169
: Verify the use of custom error messages and their documentation.Also applies to: 178-178
Verification successful
The custom error messages
ErrInvalidNumberOfArgs
,ErrInvalidHexAddress
, andErrInvalidAmount
are well-documented inprecompiles/common/errors.go
and are used consistently across the codebase.
Definitions and documentation:
precompiles/common/errors.go
Consistent usage:
precompiles/staking/types.go
precompiles/ics20/types.go
precompiles/vesting/types.go
precompiles/distribution/types.go
precompiles/bank/types.go
precompiles/authorization/types.go
precompiles/bech32/methods.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the consistency and documentation of custom error messages used in `NewMsgFundCommunityPool`. # Test: Search for the error message definitions in the codebase. Expect: Clear documentation and consistent usage. rg --type go $'ErrInvalidNumberOfArgs|ErrInvalidHexAddress|ErrInvalidAmount' --glob '*.go'Length of output: 10644
Tools
GitHub Check: codecov/patch
[warning] 169-169: precompiles/distribution/types.go#L169
Added line #L169 was not covered by teststests/nix_tests/cosmoscli.py (1)
398-403
: Good error handling by checking for the presence of keys and non-empty arrays.
Description
I don't have evmos native token to deposit into the community pool, but I can facilitate a FundCommunityPool precompiled contract transaction for users who have ideas to contribute funds to the community pool. 😄😄😄
js test script