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

feat: Add checks against eviction cases #231

Merged
merged 13 commits into from
Jul 17, 2024
Merged

Conversation

mohandast52
Copy link
Collaborator

@mohandast52 mohandast52 commented Jul 15, 2024

Warning

The code was tested by mocking the services within the app.

Case 1: Evicted and minimum staking duration achieved

  • To test the eviction scenarios, I have mocked the serviceID: 529 in the UI. Here is a representation of the service information on eth95.dev.
eviceted-but-passed-min-staking-duration
  • As we can see, service 529 is evicted (serviceStakingState is 2) and was started on July 13th, surpassing the minimum staking duration of 3 days. Therefore, the user can start the agent without any issues.
can-start

Case 2: Evicted and minimum staking duration NOT achieved

  • There was no service evicted recently in less than 3 days (not meeting the minimum staking duration). However, service ID 486 was started 1 day ago, and its state was mocked to mark serviceStakingState as 2.
service-486-info
  • As we can see, the service is evicted and the minimum staging duration is not met either. Therefore, the user cannot start the agent and will see the following message.
service-cannot-start

EVICTION MESSAGE

eviction-message

The commit updates the property names in the `StakingContractInfo` type to improve clarity and consistency. The `minStakingDuration` property is renamed to `minimumStakingDuration`, and the `serviceStakingTime` property is renamed to `serviceStakingStartTime`. This change aligns with the recent user commits and follows the established commit message conventions in the repository.
@mohandast52 mohandast52 self-assigned this Jul 16, 2024
@mohandast52 mohandast52 added the enhancement New feature or request label Jul 16, 2024
@mohandast52 mohandast52 marked this pull request as ready for review July 16, 2024 21:20
Copy link
Collaborator

@Tanya-atatakai Tanya-atatakai left a comment

Choose a reason for hiding this comment

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

@mohandast52 a general question, if the user, after their agent's eviction, waits enough time, but is still blocked due to not having enough slots, how will they know?

serviceId: number,
): Promise<StakingContractInfo | undefined> => {
if (!serviceId) return;

const contractCalls = [
serviceStakingTokenMechUsageContract.availableRewards(),
serviceStakingTokenMechUsageContract.maxNumServices(),
serviceStakingTokenMechUsageContract.getServiceIds(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these ServiceIds and the ones first of which we pass to the getStakingContractInfo with this new change (I mean the services from services?.[0]?.chain_data?.token) kind of the same? Just wonder, if they are, maybe we can not do unnecessary call?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think so. The services in ServicesProvider are fetched from an API (as you can see here) and not from a contract.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yep I saw that too, was just wondering if the values are the same

@mohandast52
Copy link
Collaborator Author

a general question, if the user, after their agent's eviction, waits enough time, but is still blocked due to not having enough slots, how will they know?

The user will still see that the slots are empty. Do you have a different perspective on this?

@mohandast52 mohandast52 merged commit 45baebf into main Jul 17, 2024
4 checks passed
@mohandast52 mohandast52 deleted the mohan/eviction-case branch July 17, 2024 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants