Skip to content

Commit 75d89dd

Browse files
authored
Added properties to automation-registry internal structs to facilitate v1.1 development (#220)
- See ticket Entropy-Foundation/smr-moonshot#1424 - See ticket Entropy-Foundation/smr-moonshot#1823 (comment) - Made creation of the native version of `AutomationTaskMetaData` backward compatible to avoid any updates on smr-side Co-authored-by: Aregnaz Harutyunyan <>
1 parent 8ec5628 commit 75d89dd

File tree

4 files changed

+67
-5
lines changed

4 files changed

+67
-5
lines changed

aptos-move/framework/supra-framework/doc/automation_registry.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ This contract is part of the Supra Framework and is designed to manage automated
120120
<dd>
121121
Will be the same as main_config.registry_max_gas_cap, unless updated during the epoch.
122122
</dd>
123+
<dt>
124+
<code>registration_enabled: bool</code>
125+
</dt>
126+
<dd>
127+
Flag indicating whether the task registration is enabled or paused.
128+
If paused a new task registration will fail.
129+
</dd>
123130
</dl>
124131

125132

@@ -403,6 +410,12 @@ Epoch state
403410
<dd>
404411
Flag indicating whether the task is active, cancelled or pending.
405412
</dd>
413+
<dt>
414+
<code>locked_fee_for_next_epoch: u64</code>
415+
</dt>
416+
<dd>
417+
Fee locked for the task estimated for the next epoch at the start of the current epoch.
418+
</dd>
406419
</dl>
407420

408421

@@ -1821,9 +1834,10 @@ Initialization of Automation Registry with configuration parameters is expected
18211834
congestion_threshold_percentage,
18221835
congestion_base_fee_in_quants_per_sec,
18231836
congestion_exponent,
1824-
task_capacity
1837+
task_capacity,
18251838
},
1826-
next_epoch_registry_max_gas_cap: registry_max_gas_cap
1839+
next_epoch_registry_max_gas_cap: registry_max_gas_cap,
1840+
registration_enabled: <b>true</b>,
18271841
});
18281842

18291843
<b>move_to</b>(supra_framework, <a href="automation_registry.md#0x1_automation_registry_AutomationEpochInfo">AutomationEpochInfo</a> {
@@ -2685,6 +2699,7 @@ Registers a new automation task entry.
26852699
state: <a href="automation_registry.md#0x1_automation_registry_PENDING">PENDING</a>,
26862700
registration_time,
26872701
tx_hash,
2702+
locked_fee_for_next_epoch: 0
26882703
};
26892704

26902705
<a href="../../supra-stdlib/doc/enumerable_map.md#0x1_enumerable_map_add_value">enumerable_map::add_value</a>(&<b>mut</b> <a href="automation_registry.md#0x1_automation_registry">automation_registry</a>.tasks, task_index, automation_task_metadata);

aptos-move/framework/supra-framework/sources/automation_registry.move

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ module supra_framework::automation_registry {
9696
main_config: AutomationRegistryConfig,
9797
/// Will be the same as main_config.registry_max_gas_cap, unless updated during the epoch.
9898
next_epoch_registry_max_gas_cap: u64,
99+
/// Flag indicating whether the task registration is enabled or paused.
100+
/// If paused a new task registration will fail.
101+
registration_enabled: bool,
99102
}
100103

101104
#[resource_group_member(group = supra_framework::object::ObjectGroup)]
@@ -186,7 +189,9 @@ module supra_framework::automation_registry {
186189
/// Registration timestamp in seconds
187190
registration_time: u64,
188191
/// Flag indicating whether the task is active, cancelled or pending.
189-
state: u8
192+
state: u8,
193+
/// Fee locked for the task estimated for the next epoch at the start of the current epoch.
194+
locked_fee_for_next_epoch: u64,
190195
}
191196

192197
#[event]
@@ -506,9 +511,10 @@ module supra_framework::automation_registry {
506511
congestion_threshold_percentage,
507512
congestion_base_fee_in_quants_per_sec,
508513
congestion_exponent,
509-
task_capacity
514+
task_capacity,
510515
},
511-
next_epoch_registry_max_gas_cap: registry_max_gas_cap
516+
next_epoch_registry_max_gas_cap: registry_max_gas_cap,
517+
registration_enabled: true,
512518
});
513519

514520
move_to(supra_framework, AutomationEpochInfo {
@@ -1051,6 +1057,7 @@ module supra_framework::automation_registry {
10511057
state: PENDING,
10521058
registration_time,
10531059
tx_hash,
1060+
locked_fee_for_next_epoch: 0
10541061
};
10551062

10561063
enumerable_map::add_value(&mut automation_registry.tasks, task_index, automation_task_metadata);

types/src/transaction/automation.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ pub struct AutomationTaskMetaData {
202202
pub(crate) registration_time: u64,
203203
/// Flag indicating whether the task is active.
204204
pub(crate) is_active: bool,
205+
/// Fee locked for the task estimated for the next epoch at the start of the current epoch.
206+
pub(crate) locked_fee_for_next_epoch: u64,
205207
}
206208

207209
impl AutomationTaskMetaData {
@@ -218,6 +220,37 @@ impl AutomationTaskMetaData {
218220
aux_data: Vec<Vec<u8>>,
219221
registration_time: u64,
220222
is_active: bool,
223+
) -> Self {
224+
Self::new_with_locked_fee(
225+
id,
226+
owner,
227+
payload_tx,
228+
expiry_time,
229+
tx_hash,
230+
max_gas_amount,
231+
gas_price_cap,
232+
automation_fee_cap_for_epoch,
233+
aux_data,
234+
registration_time,
235+
is_active,
236+
0,
237+
)
238+
}
239+
240+
#[allow(clippy::too_many_arguments)]
241+
pub fn new_with_locked_fee(
242+
id: u64,
243+
owner: AccountAddress,
244+
payload_tx: Vec<u8>,
245+
expiry_time: u64,
246+
tx_hash: Vec<u8>,
247+
max_gas_amount: u64,
248+
gas_price_cap: u64,
249+
automation_fee_cap_for_epoch: u64,
250+
aux_data: Vec<Vec<u8>>,
251+
registration_time: u64,
252+
is_active: bool,
253+
locked_fee_for_next_epoch: u64,
221254
) -> Self {
222255
Self {
223256
id,
@@ -231,6 +264,7 @@ impl AutomationTaskMetaData {
231264
aux_data,
232265
registration_time,
233266
is_active,
267+
locked_fee_for_next_epoch,
234268
}
235269
}
236270

@@ -269,4 +303,8 @@ impl AutomationTaskMetaData {
269303
pub fn id(&self) -> u64 {
270304
self.id
271305
}
306+
307+
pub fn locked_fee_for_next_epoch(&self) -> u64 {
308+
self.locked_fee_for_next_epoch
309+
}
272310
}

types/src/unit_tests/automation.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ fn automated_txn_builder_from_task_meta() {
7979
aux_data: vec![],
8080
registration_time: 1,
8181
is_active: false,
82+
locked_fee_for_next_epoch: 0,
8283
};
8384
assert!(AutomatedTransactionBuilder::try_from(task_meta_invalid_payload.clone()).is_err());
8485

@@ -149,6 +150,7 @@ fn automated_txn_build() {
149150
aux_data: vec![],
150151
registration_time: 1,
151152
is_active: false,
153+
locked_fee_for_next_epoch: 0,
152154
};
153155

154156
let builder = AutomatedTransactionBuilder::try_from(task_meta.clone()).unwrap();

0 commit comments

Comments
 (0)