-
Notifications
You must be signed in to change notification settings - Fork 602
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
Add evm schedule #699
Add evm schedule #699
Conversation
modules/evm/src/lib.rs
Outdated
let from_account = T::AddressMapping::get_account_id(&from); | ||
// unreserve the deposit for gas_limit and storage_limit | ||
let total_fee = T::StorageDepositPerByte::get().saturating_mul(storage_limit.into()).saturating_add(gas_limit.into()); | ||
T::Currency::unreserve(&from_account, total_fee); |
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.
Consider unreserve after the Runner call
because it is fallible. Would not want to unreserve if the Runner::call fails and returns Error::<T>::NoPermission
for example. Then, someone could call this without permission on purpose to unreserve that total fee amount.
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 ensure_root
so people can't call this directly
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.
@xlc
Maybe should remove unreserve and reserve.
Just judge whether the free_balance >= total_fee
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.
The fee is not handle correctly here, but can fix it in later PR #700
modules/evm/src/lib.rs
Outdated
let from_account = T::AddressMapping::get_account_id(&from); | ||
// unreserve the deposit for gas_limit and storage_limit | ||
let total_fee = T::StorageDepositPerByte::get().saturating_mul(storage_limit.into()).saturating_add(gas_limit.into()); | ||
T::Currency::unreserve(&from_account, total_fee); |
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 ensure_root
so people can't call this directly
modules/evm/src/lib.rs
Outdated
let from_account = T::AddressMapping::get_account_id(&from); | ||
// unreserve the deposit for gas_limit and storage_limit | ||
let total_fee = T::StorageDepositPerByte::get().saturating_mul(storage_limit.into()).saturating_add(gas_limit.into()); | ||
T::Currency::unreserve(&from_account, total_fee); |
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.
The fee is not handle correctly here, but can fix it in later PR #700
// reserve the deposit for gas_limit and storage_limit | ||
let total_fee = Runtime::StorageDepositPerByte::get() | ||
.saturating_mul(storage_limit.into()) | ||
.saturating_add(gas_limit.into()); |
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 isn't right, but can happen with #700
) | ||
.map_err(|_| ExitError::Other("Scheduler failed".into()))?; | ||
|
||
Ok((ExitSucceed::Returned, vec![], 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.
make the return the schedule task ID so it can be later used by #701
Encode::encode(&( | ||
&"ScheduleCall", | ||
from, | ||
input_data, |
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 is just too much data in the name. Maybe we can just have a "ScheduleCall" + sequential ID
?
The ID can be storage with
parameter_types! {
pub storage EvmSchedullerNextID: u32 = 0u32;
}
Closes: #631