Implement extcodehash (#77)

This commit is contained in:
Ermal Kaleci
2024-10-21 10:13:50 +02:00
committed by GitHub
parent 82ae22c163
commit ee83d28a51
10 changed files with 582 additions and 477 deletions
+2 -1
View File
@@ -32,7 +32,7 @@ use polkadot_sdk::{
pallet_revive::{CollectEvents, ContractExecResult, ContractInstantiateResult, DebugInfo},
polkadot_runtime_common::BuildStorage,
polkadot_sdk_frame::testing_prelude::*,
sp_core::H160,
sp_core::{H160, H256},
sp_keystore::{testing::MemoryKeystore, KeystoreExt},
sp_runtime::AccountId32,
};
@@ -185,6 +185,7 @@ pub enum CallResult {
Instantiate {
result: ContractInstantiateResult<Balance, EventRecord>,
wall_time: Duration,
code_hash: H256,
},
}
+10 -2
View File
@@ -4,7 +4,7 @@ use pallet_revive::AddressMapper;
use serde::{Deserialize, Serialize};
use crate::*;
use alloy_primitives::Address;
use alloy_primitives::{keccak256, Address};
#[cfg(feature = "revive-solidity")]
use revive_differential::{Evm, EvmLog};
#[cfg(feature = "revive-solidity")]
@@ -409,6 +409,13 @@ impl Specs {
data,
salt,
} => {
let code: pallet_revive::Code = code.into();
let code_hash = match code.clone() {
pallet_revive::Code::Existing(code_hash) => code_hash,
pallet_revive::Code::Upload(bytes) => {
H256::from_slice(keccak256(&bytes).as_slice())
}
};
let origin = RuntimeOrigin::signed(origin.to_account_id(&results));
let time_start = Instant::now();
let result = Contracts::bare_instantiate(
@@ -416,7 +423,7 @@ impl Specs {
value,
gas_limit.unwrap_or(GAS_LIMIT),
storage_deposit_limit.unwrap_or(DEPOSIT_LIMIT),
code.into(),
code,
data,
salt.0,
DebugInfo::Skip,
@@ -425,6 +432,7 @@ impl Specs {
results.push(CallResult::Instantiate {
result,
wall_time: time_start.elapsed(),
code_hash,
})
}
Upload {