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 account_call and account_create in EVM Runtime RPC #2698

Merged
merged 4 commits into from
Jan 30, 2024

Conversation

zjb0807
Copy link
Member

@zjb0807 zjb0807 commented Jan 29, 2024

Closes: #2650

@zjb0807 zjb0807 requested a review from xlc January 29, 2024 03:19
Copy link

codecov bot commented Jan 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (97bfc23) 67.06% compared to head (94a04ac) 67.09%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2698      +/-   ##
==========================================
+ Coverage   67.06%   67.09%   +0.02%     
==========================================
  Files          67       68       +1     
  Lines        8608     8983     +375     
==========================================
+ Hits         5773     6027     +254     
- Misses       2835     2956     +121     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

xlc
xlc previously approved these changes Jan 29, 2024
@zjb0807 zjb0807 merged commit 06e988b into master Jan 30, 2024
6 checks passed
@zjb0807 zjb0807 deleted the add-account-call branch January 30, 2024 03:34
@shunjizhan
Copy link
Contributor

shunjizhan commented Jan 30, 2024

currently when adding new runtime code, we need to copy and paste the same code for each of { mandala, karura, acala } runtime definition. I am curious if there is any way to keep the code more DRY? Maybe like a shared runtime definition, and each of the network can extend it with overrides

@xlc
Copy link
Member

xlc commented Jan 30, 2024

with this polkadot-js/api#5725, there will be no need to supply runtime API defs anymore

@shunjizhan
Copy link
Contributor

I mean in this PR, we need to write the following runtime codes 3 times. In substrate there is no shortcut to write "shared runtime implementation"?

		// required by xtokens precompile
		#[transactional]
		fn account_call(
			from: AccountId,
			to: H160,
			data: Vec<u8>,
			value: Balance,
			gas_limit: u64,
			storage_limit: u32,
			access_list: Option<Vec<AccessListItem>>,
			estimate: bool,
		) -> Result<CallInfo, sp_runtime::DispatchError> {
			let from = EvmAddressMapping::<Runtime>::get_or_create_evm_address(&from);

			Self::call(from, to, data, value, gas_limit, storage_limit, access_list, estimate)
		}

		fn account_create(
			from: AccountId,
			data: Vec<u8>,
			value: Balance,
			gas_limit: u64,
			storage_limit: u32,
			access_list: Option<Vec<AccessListItem>>,
			estimate: bool,
		) -> Result<CreateInfo, sp_runtime::DispatchError> {
			let from = EvmAddressMapping::<Runtime>::get_or_create_evm_address(&from);

			Self::create(from, data, value, gas_limit, storage_limit, access_list, estimate)
		}
	}

@xlc
Copy link
Member

xlc commented Jan 30, 2024

oh. right. no. but we could write some macro to help it but macro in macro is going to make things complicated and it is mostly the method signature are duplicated and implementation are shared

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.

Update EVM RPC runtime APi to allow estimate gas from Substrate account
3 participants