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

Fix #443 Add extra data to reason about task trigger #453

Merged
merged 4 commits into from
Oct 13, 2023

Conversation

v9n
Copy link
Member

@v9n v9n commented Oct 12, 2023

Fix #443 to add a new condition into TaskTrigger. This contains 3 pieices:

  • task trigger func
  • task trigger targe price
  • asset price

@v9n v9n changed the base branch from master to fix-included-bound-on-gt-condition October 12, 2023 16:11
TargetPriceMatched {
// The target price the task set to
target_price: u128,
trigger_function: Vec<u8>,
Copy link
Member

Choose a reason for hiding this comment

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

Okay, I think there might be confusion in this condition paramter, , possibly due to its ambiguity. The goal of the event is not to re-iterate the trigger condition itself, but to provide real-time value of the circumstances that triggered a task in the code. For example, the TaskTriggered event should look like

TaskTriggered {who, taskId, condition: condition_struct }
in which, the condition_struct mirrors the same structure as {destination, exchange, asset1, asset2, amount} with amount being the current value on chain, as a proof of trigger.

Keep in mind the definition of condition_struct is likely to change, so we should use the definition as much as possible, rather than deconstructing it, to faciliate future updates.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, it's actually works that way. it bundles the current value on chains plus the task information because when we debug later the task may have been remove from chain storage and hard to see the original value we have to query data at an old block.

let me cleanup a bit.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, I think we can omit the task details from the event, since it’s trivial compared to the real-time on-chain price. The reason is because task detais do not change after creation, but price varies across blocks. We almost always need to leverage the Insights service to read the task details from the past.

Copy link
Member

Choose a reason for hiding this comment

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

In other words, the task details already have on-chain proof and can be retrieved from Insights, but the triggering price of this moment is not recorded yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, the triggered price is recorded but because I only record price but not (chain, exchange, asset_pair), and it sit at the bottom of the struct so it's hard to see.

I just update a cleaner version. Can you check now, I think should be much more clean.

@v9n v9n force-pushed the fix-included-bound-on-gt-condition branch from b9f8638 to aaa3195 Compare October 12, 2023 22:23
Base automatically changed from fix-included-bound-on-gt-condition to master October 12, 2023 22:41
@v9n v9n force-pushed the add-extra-data-to-reason-about-task-trigger branch from 9145090 to 488359b Compare October 12, 2023 22:45
@v9n v9n force-pushed the add-extra-data-to-reason-about-task-trigger branch from 5dff442 to bf425c0 Compare October 12, 2023 23:32
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.

Okay, the changes look good. I’ll need to give it a try to see how accessible is the new definition of condition in client’s code, for example, maybe it’s as easy as event.condition.toJson().

Comparing its counter-party in automationTime’s code, I think these predefined structs provides a better framework for defining conditions. Let’s try this now, and update the code in automationTime later.
https://github.com/OAK-Foundation/OAK-blockchain/blob/23433654b2c512aed336a9ae6e4174230b74969c/pallets/automation-time/src/lib.rs#L892C2-L892C2

@v9n v9n merged commit 3de8bf4 into master Oct 13, 2023
3 checks passed
@v9n v9n deleted the add-extra-data-to-reason-about-task-trigger branch October 13, 2023 01:57
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.

TaskTriggered event doesn’t containt a condition attribute indicating why a task is triggered
2 participants