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

EVM plugin wallet provider and transfer action improvements #1701

Merged
merged 9 commits into from
Jan 2, 2025

Conversation

nicky-ru
Copy link
Contributor

@nicky-ru nicky-ru commented Jan 2, 2025

Relates to:

N/A

Risks

Low.

  • The caching mechanism in the wallet provider is isolated and uses a short TTL (5 seconds), which minimizes the impact on operations.
  • Changes to the transfer action align with existing types and state management, with no breaking changes expected.

Background

What does this PR do?

This PR introduces improvements and fixes to the EVM plugin:

  1. Caching in Wallet Provider: Implements a caching mechanism to store wallet balances for 5 seconds, reducing redundant calls and improving performance.
  2. Align Transfer Action: Removes unnecessary template field from the transfer action, aligning it with its intended type and improving clarity.
  3. State Update on Transfers: Enhances state updates by populating the state with recent messages for better transfer context.
  4. Improved Transfer Template: Refines the transfer template for valid JSON responses and clearer placeholders.

What kind of change is this?

  • Features:
    • Added caching to the WalletProvider to reduce redundant operations.
    • Improved transfer template for better JSON response handling.
  • Performance:
    • Enhanced state updates in the transfer action for improved context handling.
  • Bug Fixes:
    • Aligned transfer action to its intended type, removing unnecessary fields.

Why are we doing this? Any context or related work?

  • To improve the performance and maintainability of the EVM plugin that we use in production.
  • To ensure the transfer action operates in line with its intended functionality, reducing the risk of errors.

Documentation changes needed?

My changes do not require a change to the project documentation.

Testing

Where should a reviewer start?

  1. Review changes in the wallet provider (WalletProvider) for caching logic.
  2. Examine the updated transfer action implementation to verify type alignment and state updates.
  3. Test the improved transfer template to ensure JSON responses are valid and placeholders function correctly.

Detailed testing steps

  1. Run unit tests for the wallet provider to verify caching functionality.
  2. Test the transfer action manually by asking an agent for a transfer and checking:
    • Correct state updates.
    • Valid and cached wallet balance in the state.
    • Successful transaction.
  3. Verify the cache expiry behavior by observing multiple wallet balance fetches within and outside the 5-second TTL.

Deploy Notes

No specific deploy instructions needed; automated tests and regular deployment process suffice.

Discord username

nikita_zhou

Screenshots

Agent interaction

Link to the tx: https://testnet.iotexscan.io/tx/f946fce5bc127761bd780444bf2d3180bf66fa4944b37e803767e99e76dd0d13

Screenshot 2025-01-03 at 12 25 34 AM

Caching

Screenshot 2025-01-03 at 12 26 43 AM

Linting

Screenshot 2025-01-02 at 10 31 25 PM

Testing

Screenshot 2025-01-02 at 10 20 39 PM

@nicky-ru nicky-ru changed the title EVM plugin transfer improvements EVM plugin wallet provider and transfer action improvements Jan 2, 2025
@nicky-ru
Copy link
Contributor Author

nicky-ru commented Jan 2, 2025

I had to remove the Twitter client and update the plugin-story types locally to successfully build and run the project. Specifically, I updated the story configuration object that was causing build failures and removed the Twitter client, which was preventing the project from starting. However, these fixes are unrelated to the changes in this PR and were not committed, they would require separate attention to address properly

monilpat
monilpat previously approved these changes Jan 2, 2025
Copy link
Collaborator

@monilpat monilpat left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for improving this. Yeah the plugin story should have been address yesterday if you are still having issues after rebasing to latest develop then this is new and will be handled separately.

packages/plugin-evm/src/providers/wallet.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@monilpat monilpat left a comment

Choose a reason for hiding this comment

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

LGTM

@monilpat monilpat merged commit a8c279f into elizaOS:develop Jan 2, 2025
3 checks passed
@nicky-ru nicky-ru deleted the evm-transfer-improvement branch January 2, 2025 17:16
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.

2 participants