-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add upload evm code function #10129
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 upload evm code function #10129
Changes from 8 commits
b6027ad
f87d6b1
794d5af
e8e1f83
a4822a5
6c5abfa
9bdcf4d
5d79e49
3c9bf9c
96f206b
b1c19df
d908848
d84f7b2
bbdf08a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| title: Add upload evm code function | ||
| doc: | ||
| - audience: Node Dev | ||
| description: |- | ||
| EVM Runtime Code Upload for Foundry Integration | ||
| This feature enables direct upload of EVM runtime bytecode (deployed contract code without constructor) to the pallet-revive, supporting Foundry's code migration functionality between REVM and pallet-revive execution environments. | ||
| crates: | ||
| - name: pallet-revive | ||
| bump: minor | ||
| - name: pallet-revive-fixtures | ||
| bump: major |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2095,6 +2095,21 @@ impl<T: Config> Pallet<T> { | |
| .map_err(ContractAccessError::StorageWriteFailed) | ||
| } | ||
|
|
||
| /// Uploads evm runtime code and returns the Vm binary contract blob and deposit amount | ||
| /// collected. | ||
| pub fn try_upload_evm_runtime_code( | ||
| origin: H160, | ||
| code: Vec<u8>, | ||
| storage_deposit_limit: BalanceOf<T>, | ||
| exec_config: &ExecConfig, | ||
| ) -> Result<(ContractBlob<T>, BalanceOf<T>), DispatchError> { | ||
| let origin = T::AddressMapper::to_account_id(&origin); | ||
| let mut module = ContractBlob::from_evm_runtime_code(code, origin)?; | ||
| let deposit = module.store_code(exec_config, None)?; | ||
| ensure!(storage_deposit_limit >= deposit, <Error<T>>::StorageDepositLimitExhausted); | ||
| Ok((module, deposit)) | ||
| } | ||
|
||
|
|
||
| /// Pallet account, used to hold funds for contracts upload deposit. | ||
| pub fn account_id() -> T::AccountId { | ||
| use frame_support::PalletId; | ||
|
|
||
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.
maybe EvmByteCodeType ?