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

Add evm schedule #699

Merged
merged 8 commits into from
Jan 28, 2021
Merged

Add evm schedule #699

merged 8 commits into from
Jan 28, 2021

Conversation

zjb0807
Copy link
Member

@zjb0807 zjb0807 commented Jan 27, 2021

Closes: #631

@zjb0807 zjb0807 requested a review from xlc January 27, 2021 01:01
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);
Copy link

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.

Copy link
Member

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

Copy link
Member Author

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

Copy link
Member

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

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);
Copy link
Member

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

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);
Copy link
Member

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());
Copy link
Member

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))
Copy link
Member

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,
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 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;
}

https://github.com/paritytech/polkadot/pull/2167/files#diff-8a10805ad559865410470a16150cfa44ea0c156becadfc749c10aab87e8c93beR37

@zjb0807 zjb0807 requested a review from xlc January 27, 2021 06:12
@zjb0807 zjb0807 merged commit 5473b9f into master Jan 28, 2021
@zjb0807 zjb0807 deleted the evm-schedule branch January 28, 2021 01:48
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.

EVM: Scheduler API - part 1
3 participants