-
Notifications
You must be signed in to change notification settings - Fork 2
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
[AN-Issue-1409] Handled automation-registry state update on new epoch #144
[AN-Issue-1409] Handled automation-registry state update on new epoch #144
Conversation
aregng
commented
Dec 18, 2024
- split automation registry external API and internal state to avoid circular dependencies
- enabled automation-registry-state update on new epoch from block module.
aptos-move/framework/supra-framework/sources/automation_registry_state.move
Outdated
Show resolved
Hide resolved
aptos-move/framework/supra-framework/sources/automation_registry_state.move
Show resolved
Hide resolved
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 have just one question regarding the removal of txn_app_hash; everything else looks good to me.
aptos-move/framework/supra-framework/sources/automation_registry.move
Outdated
Show resolved
Hide resolved
6e99cf6
to
bb6fb1b
Compare
/// Remove automation task registry event | ||
struct RemoveAutomationTask has drop, store { | ||
id: u64 | ||
} | ||
|
||
// todo : this function should call during initialzation, but since we already done genesis in that case who can access the function |
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.
This can still be called by governance, after framework upgrade by governance.
/// A collection of automation task entries that are active state. | ||
tasks: EnumerableMap<u64, AutomationTaskMetaData>, | ||
current_index: u64, | ||
gas_committed_for_next_epoch: u64, | ||
automation_gas_limit: u64, | ||
} |
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.
Will all governance configurable parameter also go here? Or are we going to have a separate config/automation_config.move
similar to staking_config
? For example, upper limit on duration, base fee, congestion_threshold
, congestion_multiplier
all should be governance configurable parameters.
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.
at this moment parameters has been split into 2 contexts automation_registry
and automation_registry_state
based on their place of utilization. but I think as long as we are going to have more and more configurable parameters it would be better to have dedicated structure for it. But I would suggest to do it in a separate PR e.g in scope of the PR wehn automation-fee related configurations will be introduced.
aptos-move/framework/supra-framework/sources/automation_registry_state.move
Outdated
Show resolved
Hide resolved
aptos-move/framework/supra-framework/sources/automation_registry_state.move
Show resolved
Hide resolved
aptos-move/framework/supra-framework/sources/automation_registry_state.move
Show resolved
Hide resolved
aptos-move/framework/supra-framework/sources/automation_registry.move
Outdated
Show resolved
Hide resolved
@@ -235,6 +236,7 @@ module supra_framework::block { | |||
randomness::on_new_block(&vm, epoch, round, option::none()); | |||
if (timestamp - reconfiguration::last_reconfiguration_time() >= epoch_interval) { | |||
reconfiguration::reconfigure(); | |||
automation_registry_state::on_new_epoch(epoch_interval); |
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.
This should be called from reconfiguration
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.
reconfiguration does not have access to epoch-interval, either reconfiguration::reconfigure()
should be updated to accept epoch_interval as parameter or we should leave it as it is.
@@ -264,6 +266,7 @@ module supra_framework::block { | |||
|
|||
if (timestamp - reconfiguration::last_reconfiguration_time() >= epoch_interval) { | |||
reconfiguration_with_dkg::try_start(); | |||
automation_registry_state::on_new_epoch(epoch_interval); |
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.
should be called from reconfiguration
- split automation registry external API and internal state to avoid circular dependencies - enabled automation-registry-state update on new epoch from block module.
…s argument - Moved basic parameters checks of registration to automation_registry_state - Added and updated unit tests of autmation_registry_state
ab774df
to
bc106d9
Compare
|
||
// Adjust the gas committed for the next epoch by subtracting the gas amount of the expired task | ||
automation_registry.gas_committed_for_next_epoch = automation_registry.gas_committed_for_next_epoch - expired_task_gas; | ||
} | ||
|
||
/// Withdraw accumulated automation task fees from the resource account - access by admin | ||
entry fun withdraw_automation_task_fees( |
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.
Yes, any governance action can only be taken through a script, so the interface would be public functions that checks that signer is indeed supra_framework
aptos-move/framework/supra-framework/sources/automation_registry.move
Outdated
Show resolved
Hide resolved
id: u64 | ||
} | ||
|
||
public fun task_expiry_time(task: &AutomationTaskMetaData): u64 { |
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.
public fun task_expiry_time(task: &AutomationTaskMetaData): u64 { | |
#[view] | |
public fun task_expiry_time(task: &AutomationTaskMetaData): u64 { |
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.
this is internal function and not a view function exposed to user.
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 believe that a [view]
function can only call other [view]
functions. Therefore, even if we want to call this from other module, this should be declared as [view]
function. If we do not want to expose this to public, perhaps this can be public(friend)
aptos-move/framework/supra-framework/sources/automation_registry_state.move
Outdated
Show resolved
Hide resolved
aptos-move/framework/supra-framework/sources/automation_registry_state.move
Show resolved
Hide resolved
aptos-move/framework/supra-framework/sources/automation_registry_state.move
Outdated
Show resolved
Hide resolved
// Adjust the gas committed for the next epoch by subtracting the gas amount of the cancelled task | ||
state.gas_committed_for_next_epoch = state.gas_committed_for_next_epoch - automation_task_metadata.max_gas_amount; | ||
|
||
event::emit(CanclledAutomationTask { id: automation_task_metadata.id }); |
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.
event::emit(CanclledAutomationTask { id: automation_task_metadata.id }); | |
event::emit(CancelledAutomationTask { id: automation_task_metadata.id }); |
Upon cancellation some event should also emit information about amount refunded
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 assume when coin transfer happens, there will be deposit event, wouldn;t that be enough or we want to have it part of cancellation event as well along with id?
aptos-move/framework/supra-framework/sources/automation_registry_state.move
Show resolved
Hide resolved
let active_task_ids = vector[]; | ||
let ids = enumerable_map::get_map_list(&state.tasks); | ||
|
||
vector::for_each(ids, |id| { |
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.
Since we are only reading the state, perhaps vector::for_each_ref
can be used to avoid creation/copy of elements.
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.
aptos-move/framework/supra-framework/sources/automation_registry_state.move
Show resolved
Hide resolved
@@ -89,7 +92,7 @@ module supra_framework::automation_registry_state { | |||
|
|||
#[event] | |||
/// Remove automation task registry event | |||
struct RemoveAutomationTask has drop, store { | |||
struct CanclledAutomationTask has drop, store { |
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.
CancelledAutomationTask
(spelling)