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

restructure storage, improve task run logic, fixed #441 #446

Merged
merged 5 commits into from
Oct 11, 2023

Conversation

v9n
Copy link
Member

@v9n v9n commented Oct 7, 2023

Improvement over chain storage and underlying data structure, public API of extrinsisc remain unchange.

Changes include:

Refactor Storage

removed AccountTasks
remove ScheduledAssetDeletion

updated Tasks to (account_id, task_id)

add TaskStats and AccountStat to track task count

Task Execution:

Handle task expiration or price moved skipped.

If task has expired by the time it got run, we won't run it,
if price moved by the time the task run, we wo't run it either

Task Scheduling

Introduce MaxTaskPerAccount and MaxTaskOverall limit.

@v9n v9n marked this pull request as draft October 7, 2023 04:22
@v9n v9n force-pushed the restructure-task-storage branch 2 times, most recently from d46b6b2 to b79b5e0 Compare October 9, 2023 23:26
@v9n v9n force-pushed the restructure-task-storage branch from b79b5e0 to 87d11aa Compare October 10, 2023 00:22
@v9n v9n force-pushed the restructure-task-storage branch from 87d11aa to fbd7242 Compare October 10, 2023 00:30
@v9n v9n changed the title restructure storage phase1 restructure storage, improve task run logic Oct 10, 2023
@v9n v9n marked this pull request as ready for review October 10, 2023 16:01
@v9n v9n requested review from chrisli30 and imstar15 October 10, 2023 16:20
pallets/automation-price/src/lib.rs Show resolved Hide resolved
pallets/automation-price/src/lib.rs Outdated Show resolved Hide resolved
@@ -392,10 +403,12 @@ pub mod pallet {
who: AccountOf<T>,
task_id: TaskId,
},
Notify {
message: Vec<u8>,
},
TaskNotFound {
Copy link
Member

Choose a reason for hiding this comment

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

What’re the differences between TaskDoesNotExsit and TaskNotFound?

Copy link
Member

Choose a reason for hiding this comment

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

If the usages are similar I suggest to merge them.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is overlook. They are just same.

Copy link
Member Author

Choose a reason for hiding this comment

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

They are actually a bit different. One is Error, one is an Event.

Error: used when cancel task, if task id not found, we return an error

Event: used when processing task, if a task id not found, we emit an event and continue to normal execution to process other task.

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, yeah if they are at difference places, I don’t think we’ll mix them up with the same name. The change looks good.

pallets/automation-price/src/lib.rs Show resolved Hide resolved
pallets/automation-price/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@imstar15 imstar15 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@v9n v9n changed the title restructure storage, improve task run logic restructure storage, improve task run logic, fixed #441 Oct 11, 2023
@v9n
Copy link
Member Author

v9n commented Oct 11, 2023

@chrisli30 code update and comment is added

Copy link
Member

@chrisli30 chrisli30 left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@@ -392,10 +403,12 @@ pub mod pallet {
who: AccountOf<T>,
task_id: TaskId,
},
Notify {
message: Vec<u8>,
},
TaskNotFound {
Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, yeah if they are at difference places, I don’t think we’ll mix them up with the same name. The change looks good.

@v9n v9n merged commit 7959fde into master Oct 11, 2023
@v9n v9n deleted the restructure-task-storage branch October 11, 2023 17:06
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.

3 participants