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] #3262: Don't prematurely execute time-triggers before their start
timestamp
#4333
base: main
Are you sure you want to change the base?
[fix] #3262: Don't prematurely execute time-triggers before their start
timestamp
#4333
Conversation
…e their `start` timestamp Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
start
timestamp`start
timestamp
ff6b8ac
to
160c838
Compare
Pull Request Test Coverage Report for Build 8070574387Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we say we confirmed the following points:
- the trigger was successfully registered
- interval (time-event) and schedule (time-event acceptor points) matched
- but the trigger did not execute because it was premature
- now that it is past the
schedule.start
time and other conditions met, the trigger has successfully executed
I think at least one more query will be required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot read the role of PERIOD
here from its name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to remove it
let schedule = Schedule::starting_at(Duration::from_secs(TIMESTAMP)) | ||
.with_period(Duration::from_secs(10)); | ||
let since = Duration::from_secs(TIMESTAMP + 35); | ||
let length = Duration::from_secs(4); | ||
let schedule = Schedule::starting_at(Duration::from_secs(TIMESTAMP - 5)) | ||
.with_period(Duration::from_secs(20)); | ||
let since = Duration::from_secs(TIMESTAMP); | ||
let length = Duration::from_secs(5); | ||
let interval = TimeInterval { since, length }; | ||
assert_eq!(count_matches_in_interval(&schedule, &interval), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this change guarantee anything new?
In each case before and after, the intersection of schedule and interval seems to be empty, regardless of where schedule.start
is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this tests isn't testing anything new.
In each case two interval is located between two schedule points.
I'm going to revert it.
@@ -115,7 +117,7 @@ fn change_asset_metadata_after_1_sec() -> Result<()> { | |||
&mut test_client, | |||
&account_id, | |||
Duration::from_secs(1), | |||
usize::try_from(PERIOD.as_millis() / DEFAULT_CONSENSUS_ESTIMATION.as_millis() + 1)?, | |||
2, // One block for trigger registration and one for execution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we introduce something like scopes to show why it's equal to 2? And have a variable that we increment?
I see that it's a test but that value might cause confusions even with the commentary
Description
While original issues doesn't state it clearly I think that the problem was premature execution of time triggers.
So that trigger could be executed even before
start
. I fixed this.start
point beforelatest_block_timestamp + consensus_estimation
time, whereconsensus_estimation = 4 secs
and is a hardcoded constant. Everithing before this timestamp is considered already analyzed by Iroha. In other words -- time-triggers in the past are forbidden.start
point is in futurechange_asset_metadata_after_1_sec
testForbidding time-triggers in the past was the simpliest solution and I actually think it was making sence to implement that in the initial solution.
Linked issue
Benefits
Checklist
CONTRIBUTING.md