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 #387 - Generalize the Event and Error of tasks by separating execution from triggering and rescheduling #383

Merged
merged 42 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
62730ce
If the balance is insufficient, skip the bond
imstar15 Jul 13, 2023
3900804
fixup: auto format Rust code
Jul 13, 2023
a9e94cb
Fix tests for auto compound task
imstar15 Jul 14, 2023
b0e16ec
Add test cases of 4 scenarios for auto compound task
imstar15 Jul 17, 2023
380328f
Fix DelegationNotFound typo
imstar15 Jul 18, 2023
32fd90d
Change the branch of pallet-parachain-staking library to oak-staging
imstar15 Jul 18, 2023
f8d061a
In the AutoCompoundDelegatorStakeFailed event, the error_message will…
imstar15 Jul 19, 2023
9268558
Merge branch 'master' into fix-auto-compound-task
imstar15 Jul 24, 2023
e74fc9f
Add non_interrupt_errors to Task attributes
imstar15 Jul 24, 2023
414dd65
fixup: auto format Rust code
Jul 24, 2023
8033e82
Add encoded_call attribute to TaskTriggered event
imstar15 Jul 25, 2023
8a65340
fixup: auto format Rust code
Jul 25, 2023
f60ec35
Remove XcmpTaskSucceeded, AutoCompoundDelegatorStakeSucceeded, AutoCo…
imstar15 Jul 25, 2023
2b5ae4d
fixup: auto format Rust code
Jul 25, 2023
49c19a9
Fix tests
imstar15 Jul 26, 2023
07fc23b
Fix tests. Add comments.
imstar15 Jul 27, 2023
8dad836
Merge branch 'master' into fix-auto-compound-task
imstar15 Jul 28, 2023
707c7cb
fixup: auto format Rust code
Jul 28, 2023
2c84a6f
Rename cancel_upon_errors to abort_errors
imstar15 Jul 28, 2023
1b02d36
fixup: auto format Rust code
Jul 28, 2023
8d3462c
Fix tests
imstar15 Jul 28, 2023
938ec97
fixup: auto format Rust code
Jul 28, 2023
a8167bf
Add TaskExecuted event
imstar15 Jul 31, 2023
8e12676
fixup: auto format Rust code
Jul 31, 2023
19e9eec
Fix tests
imstar15 Jul 31, 2023
eb25f28
fixup: auto format Rust code
Jul 31, 2023
5afe04b
Remove DynamicDispatchResult in benchmarking
imstar15 Jul 31, 2023
0a33b0d
Rename TaskFailedToReschedule to TaskRescheduleFailed
imstar15 Jul 31, 2023
0a9f202
Add comments
imstar15 Jul 31, 2023
f8f67bd
Add more checks in tests
imstar15 Aug 1, 2023
269dacf
fixup: auto format Rust code
Aug 1, 2023
917cb56
Merge branch 'master' into fix-auto-compound-task
chrisli30 Aug 1, 2023
0584ce2
Check dynamic dispatch error in bechmarking
imstar15 Aug 2, 2023
588c0ee
Remove abort_errors in TaskTriggered event
imstar15 Aug 2, 2023
599cdb2
Merge branch 'master' into fix-auto-compound-task
imstar15 Aug 2, 2023
70acade
Deposit DelegationIncreased event in MockDelegatorActions
imstar15 Aug 2, 2023
1c3f998
Merge branch 'master' into fix-auto-compound-task
imstar15 Aug 2, 2023
ac9d600
Rename cancel_errors to abort_errors in mock.rs
imstar15 Aug 3, 2023
03137e2
Revert assert_last_event and add allow(dead_code) annotation on it
imstar15 Aug 3, 2023
0843dda
Update parachain-staking library
imstar15 Aug 3, 2023
4049d66
Change the type of encoded_call in TaskTriggered event
imstar15 Aug 3, 2023
aa620dd
Change the type of abort_errors to Vec<Vec<u8>>
imstar15 Aug 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "r
xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38" }

# Moonbeam Dependencies
pallet-parachain-staking = { git = "https://github.com/OAK-Foundation/moonbeam", branch = "oak-polkadot-v0.9.38" }
pallet-parachain-staking = { git = "https://github.com/OAK-Foundation/moonbeam", branch = "oak-staging" }

# ORML Dependencies
orml-asset-registry = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.38" }
Expand Down
7 changes: 5 additions & 2 deletions pallets/automation-time/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ scale-info = { version = "2.1", default-features = false, features = [
"derive",
] }
log = { version = "0.4.17", default-features = false }
hex = { version = "0.4.3", default-features = false, features = [
"alloc",
] }

# Polkadot
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.38" }
Expand All @@ -33,6 +36,7 @@ cumulus-primitives-core = { git = 'https://github.com/paritytech/cumulus', defau
## Substrate Primitive Dependencies
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }

## Substrate FRAME Dependencies
frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.38" }
Expand All @@ -46,7 +50,7 @@ pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-fe
xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.38" }

## Moonbeam Dependencies
pallet-parachain-staking = { git = "https://github.com/OAK-Foundation/moonbeam", default-features = false, branch = "oak-polkadot-v0.9.38" }
pallet-parachain-staking = { git = "https://github.com/OAK-Foundation/moonbeam", default-features = false, branch = "oak-staging" }

## ORML
orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.38" }
Expand All @@ -62,7 +66,6 @@ primitives = { path = "../../primitives", default-features = false }
rand = { version = "0.7.3" }
serde = { version = "1.0.144" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }

pallet-xcm = { git = 'https://github.com/paritytech/polkadot', default-features = false, branch = "release-v0.9.38" }
Expand Down
14 changes: 7 additions & 7 deletions pallets/automation-time/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ fn schedule_notify_tasks<T: Config>(owner: T::AccountId, times: Vec<u64>, count:
task_id.clone(),
times.clone(),
vec![4, 5, 6],
vec![],
)
.unwrap();
let task_id = AutomationTime::<T>::schedule_task(&task).unwrap();
Expand Down Expand Up @@ -92,6 +93,7 @@ fn schedule_xcmp_tasks<T: Config>(owner: T::AccountId, times: Vec<u64>, count: u
Weight::from_ref_time(5_000),
Weight::from_ref_time(10_000),
InstructionSequence::PayThroughSovereignAccount,
vec![],
)
.unwrap();
let task_id = AutomationTime::<T>::schedule_task(&task).unwrap();
Expand Down Expand Up @@ -123,6 +125,7 @@ fn schedule_auto_compound_delegated_stake_tasks<T: Config>(
frequency,
collator,
account_minimum,
vec![],
)
.unwrap();
AutomationTime::<T>::schedule_task(&task).unwrap();
Expand Down Expand Up @@ -324,9 +327,6 @@ benchmarks! {
let call: <T as Config>::Call = frame_system::Call::remark { remark: vec![] }.into();
let encoded_call = call.encode();
}: { AutomationTime::<T>::run_dynamic_dispatch_action(caller.clone(), encoded_call, task_id.clone()) }
verify {
Copy link
Member

Choose a reason for hiding this comment

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

I think we should still keep this verify block. i had a similar code in here we can use to get the right task id

https://github.com/OAK-Foundation/OAK-blockchain/blob/917cb56330ece0ac6fc8c5b79a804ac04ec39e8a/pallets/automation-time/src/benchmarking.rs#L221-L227

Copy link
Member Author

Choose a reason for hiding this comment

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

Because run_dynamic_dispatch_action does not throw events, it only returns error. Therefore, I checked the error it returns. Since error variable cannot be used in the verify block, I did not include these checks in the verify block

Refers to:
https://github.com/paritytech/substrate/blob/fbddfbd76c60c6fda0024e8a44e82ad776033e4b/frame/state-trie-migration/src/lib.rs#L964

.

Copy link
Member

Choose a reason for hiding this comment

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

ic, that makes sense.

assert_last_event::<T>(Event::DynamicDispatchResult{ who: caller, task_id: task_id.clone(), result: Ok(()) }.into())
}

run_dynamic_dispatch_action_fail_decode {
let caller: T::AccountId = account("caller", 0, SEED);
Expand Down Expand Up @@ -355,7 +355,7 @@ benchmarks! {

for i in 0..v {
let task_id: Vec<u8> = vec![i.saturated_into::<u8>()];
let task = TaskOf::<T>::create_event_task::<T>(caller.clone(), task_id.clone(), vec![time.into()], vec![4, 5, 6]).unwrap();
let task = TaskOf::<T>::create_event_task::<T>(caller.clone(), task_id.clone(), vec![time.into()], vec![4, 5, 6], vec![]).unwrap();
AutomationTime::<T>::schedule_task(&task).unwrap();
let missed_task = MissedTaskV2Of::<T>::new(caller.clone(), task_id.clone(), time.into());
<AccountTasks<T>>::insert(caller.clone(), task_id.clone(), task);
Expand Down Expand Up @@ -395,7 +395,7 @@ benchmarks! {

for i in 0..v {
let task_id: Vec<u8> = vec![i.saturated_into::<u8>()];
let task = TaskOf::<T>::create_event_task::<T>(caller.clone(), task_id.clone(), vec![execution_time], vec![65, 65.saturating_add(i as u8)]).unwrap();
let task = TaskOf::<T>::create_event_task::<T>(caller.clone(), task_id.clone(), vec![execution_time], vec![65, 65.saturating_add(i as u8)], vec![]).unwrap();
let task_id = AutomationTime::<T>::schedule_task(&task).unwrap();
<AccountTasks<T>>::insert(caller.clone(), task_id.clone(), task);
task_ids.push((caller.clone(), task_id.clone()))
Expand Down Expand Up @@ -442,7 +442,7 @@ benchmarks! {
for j in 0..1 {
let time = time.saturating_add(3600);
let task_id: Vec<u8> = vec![i.saturated_into::<u8>(), j.saturated_into::<u8>()];
let task = TaskOf::<T>::create_event_task::<T>(caller.clone(), task_id.clone(), vec![time.into()], vec![4, 5, 6]).unwrap();
let task = TaskOf::<T>::create_event_task::<T>(caller.clone(), task_id.clone(), vec![time.into()], vec![4, 5, 6], vec![]).unwrap();
AutomationTime::<T>::schedule_task(&task).unwrap();
<AccountTasks<T>>::insert(caller.clone(), task_id, task);
}
Expand All @@ -458,7 +458,7 @@ benchmarks! {

for i in 0..T::MaxTasksPerSlot::get() {
task_id = increment_task_id(task_id);
let task = TaskOf::<T>::create_event_task::<T>(caller.clone(), task_id.clone(), vec![current_time.into()], vec![4, 5, 6]).unwrap();
let task = TaskOf::<T>::create_event_task::<T>(caller.clone(), task_id.clone(), vec![current_time.into()], vec![4, 5, 6], vec![]).unwrap();
AutomationTime::<T>::schedule_task(&task).unwrap();
<AccountTasks<T>>::insert(caller.clone(), task_id.clone(), task);
}
Expand Down
Loading