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

[AN-Issue-1409] Handled automation-registry state update on new epoch #144

Merged
merged 9 commits into from
Dec 24, 2024

Conversation

aregng
Copy link

@aregng 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.

Copy link

@nizam-supraoracles nizam-supraoracles left a 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.

@aregng aregng force-pushed the feature/automation-networks branch from 6e99cf6 to bb6fb1b Compare December 20, 2024 10:27
/// 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

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.

Comment on lines +52 to +57
/// 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,
}

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.

Copy link
Author

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.

@@ -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);

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

Copy link
Author

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);

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

Aregnaz Harutyunyan and others added 5 commits December 20, 2024 16:32
- 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
@aregng aregng force-pushed the task/registry-update-on-new-epoch branch from ab774df to bc106d9 Compare December 20, 2024 12:32

// 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(

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

id: u64
}

public fun task_expiry_time(task: &AutomationTaskMetaData): u64 {

Choose a reason for hiding this comment

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

Suggested change
public fun task_expiry_time(task: &AutomationTaskMetaData): u64 {
#[view]
public fun task_expiry_time(task: &AutomationTaskMetaData): u64 {

Copy link
Author

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.

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)

// 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 });

Choose a reason for hiding this comment

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

Suggested change
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

Copy link
Author

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?

let active_task_ids = vector[];
let ids = enumerable_map::get_map_list(&state.tasks);

vector::for_each(ids, |id| {

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.

Choose a reason for hiding this comment

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

@@ -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 {

Choose a reason for hiding this comment

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

CancelledAutomationTask (spelling)

@aregng aregng merged commit a978ff6 into feature/automation-networks Dec 24, 2024
1 check passed
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.

3 participants