Skip to content
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

Allow force transfers from marker and market accounts. #1855

Merged
merged 6 commits into from Feb 23, 2024

Conversation

SpicyLemon
Copy link
Contributor

@SpicyLemon SpicyLemon commented Feb 23, 2024

Description

Allow force transfers from marker and market accounts.


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

Summary by CodeRabbit

  • New Features
    • Introduced an improvement to enable force transfers from marker and market accounts, enhancing flexibility and control for users.

@SpicyLemon SpicyLemon requested a review from a team as a code owner February 23, 2024 00:22
Copy link
Contributor

coderabbitai bot commented Feb 23, 2024

Warning

Rate Limit Exceeded

@SpicyLemon has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 11 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 8bd61dc and 66a75d1.

Walkthrough

These updates introduce an improvement to support force transfers from marker and market accounts, enhancing the system's flexibility. The changes involve adding necessary functions and modifications in the test setup to accommodate the new feature, alongside ensuring the correct account types can perform force transfers. This enhancement streamlines interactions with marker and market accounts, reflecting a thoughtful addition to the system's capabilities.

Changes

File Summary
x/marker/keeper/keeper_test.go
x/marker/keeper/marker.go
- Added exchange imports.
- Modified setAcc to return sdk.AccAddress.
- Added functions to create marker and market accounts.
- Updated address initialization in tests.
- Added marker/types imports in marker.go.
- Modified canForceTransferFrom to allow force transfers from MarkerAccountI and MarketAccount.
- Adjusted comments for clarity.
CHANGELOG.md - Documented the addition of force transfer improvements for marker and market accounts.

🐇✨

In the realm of code, where logic intertwines,
A rabbit hopped in, leaving changes behind.
Marker and market, now bend to the will,
Of forceful transfers, a skill to instill.
With each line of code, the rabbit did weave,
A tapestry of progress, on this tech-eve.
🌟🐾

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?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Taztingo
Taztingo previously approved these changes Feb 23, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 887ed40 and 3696aea.
Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • x/marker/keeper/keeper_test.go (4 hunks)
  • x/marker/keeper/marker.go (2 hunks)
Files not reviewed due to errors (1)
  • (no review received)
Additional comments: 2
x/marker/keeper/marker.go (2)
  • 14-14: The addition of the exchange and marker/types imports is necessary for the new functionality introduced in this PR. Ensure that these packages are used effectively within the file and that there are no unused imports to maintain code cleanliness.
  • 711-743: The modifications to the canForceTransferFrom function introduce logic to allow force transfers from specific account types, including group addresses, marker accounts, and market accounts. This change is crucial for enabling the new force transfer functionality for marker and market accounts. However, it's important to ensure that this does not inadvertently allow unauthorized transfers or affect the security of the system.
  1. The logic to allow force transfers from group addresses and accounts with a non-zero sequence is reasonable, as it aligns with the intention to enable force transfers while maintaining security constraints.
  2. The explicit checks for marker accounts (types.MarkerAccountI) and market accounts (exchange.MarketAccount) are essential for the new feature. It's important that these checks are accurate and that the types used (types.MarkerAccountI and exchange.MarketAccount) correctly represent the intended account types.
  3. The comment on line 724-727 provides a good explanation of the rationale behind allowing force transfers only from accounts that have signed at least one transaction. This approach helps mitigate potential security risks associated with force transfers from accounts that have never been used.

Overall, the changes to this function seem to align with the objectives of the PR. However, it's crucial to ensure that these changes have been thoroughly tested, especially considering the potential security implications of force transfers.

x/marker/keeper/keeper_test.go Outdated Show resolved Hide resolved
x/marker/keeper/keeper_test.go Outdated Show resolved Hide resolved
x/marker/keeper/keeper_test.go Show resolved Hide resolved
x/marker/keeper/keeper_test.go Outdated Show resolved Hide resolved
… Namely, have the account creators take in a string to use for the addr instead of the full address that it's going to just turn around and return.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3696aea and 8bd61dc.
Files selected for processing (1)
  • x/marker/keeper/keeper_test.go (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/marker/keeper/keeper_test.go

iramiller
iramiller previously approved these changes Feb 23, 2024
Taztingo
Taztingo previously approved these changes Feb 23, 2024
@SpicyLemon SpicyLemon dismissed stale reviews from Taztingo and iramiller via 66a75d1 February 23, 2024 00:40
@SpicyLemon SpicyLemon enabled auto-merge (squash) February 23, 2024 00:42
Copy link
Contributor

@nullpointer0x00 nullpointer0x00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good to me. However, we have a lot of comments explaining why things are being done the way they are. Should we also add/move these to the spec?

@iramiller
Copy link
Member

Should we also add/move these to the spec?

It is about time to rebuild the spec for the marker module in a far more detailed and expressive way ... things like state machine/flow diagrams, theory of operation, and example uses...

@SpicyLemon
Copy link
Contributor Author

Everything looks good to me. However, we have a lot of comments explaining why things are being done the way they are. Should we also add/move these to the spec?

I feel like those should just stay in the code. The spec docs already have info on how it all behaves. Those comments (for the most part) only apply to a few lines of code and are really dependent on how we've organized all those checks. They're really just there to help us the next time we need to go in and make changes or review the code.

@SpicyLemon
Copy link
Contributor Author

It is about time to rebuild the spec for the marker module in a far more detailed and expressive way ... things like state machine/flow diagrams, theory of operation, and example uses...

I've been keeping the transfer/send-restriction stuff up-to-date at least. But yeah, it'd be good to review/update/refactor the spec docs at some point.

@SpicyLemon SpicyLemon merged commit 1391c70 into main Feb 23, 2024
35 checks passed
@SpicyLemon SpicyLemon deleted the dwedul/force-xfers-from-markers branch February 23, 2024 22:31
SpicyLemon added a commit that referenced this pull request Mar 18, 2024
* Allow force transfers out of marker and market accounts.

* Add some test cases for marker and market accounts with canForceTransferFrom.

* Add changelog entry.

* Tweak TestCanForceTransferFrom a little based on coderabbit feedback. Namely, have the account creators take in a string to use for the addr instead of the full address that it's going to just turn around and return.

* Lint fix (needed extra empty line in keeper/marker.go).
SpicyLemon added a commit that referenced this pull request Mar 18, 2024
…fer authz validation). (#1876)

* Allow force transfers from marker and market accounts. (#1855)

* Allow force transfers out of marker and market accounts.

* Add some test cases for marker and market accounts with canForceTransferFrom.

* Add changelog entry.

* Tweak TestCanForceTransferFrom a little based on coderabbit feedback. Namely, have the account creators take in a string to use for the addr instead of the full address that it's going to just turn around and return.

* Lint fix (needed extra empty line in keeper/marker.go).

* Fix MarkerTransferAuthorization validation. (#1856)

* Fix MarkerTransferAuthorization validation to make sure the limit is valid Coins and the addresses in the allow list are valid.

* Add changelog entry.

* Fix one of the changelog lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants