[] https://github.com/AstarNetwork/Astar.git
./target/release/astar-collator --dev -d ./data -l info
astar frontier evm use HashedAddressMapping in evm pallet
alice public key is d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
H160 is 0cf49bc5aca76015898fbdfc914af870bf057aeff1d347225b6c01595ad0699b = BlakeTwo256( b"evm:"[0..4] + 15fdd31c61141abd04a99fd6822c8558854ccde3 )
evm miner address is 5CMh6W6x5ZJaj2QGndYHa4Pc4ppvSFc9J66mBrxwteUkRe8p = ss58(0cf49bc5aca76015898fbdfc914af870bf057aeff1d347225b6c01595ad0699b)
impl pallet_evm::Config for Runtime {
type AddressMapping = HashedAddressMapping<BlakeTwo256>;
}
pub struct FindAuthorTruncated<F>(PhantomData<F>);
impl<F: FindAuthor<u32>> FindAuthor<H160> for FindAuthorTruncated<F> {
fn find_author<'a, I>(digests: I) -> Option<H160>
where
I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,
{
if let Some(author_index) = F::find_author(digests) {
let authority_id = Aura::authorities()[author_index as usize].clone();
return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));
}
None
}
}
impl<H: Hasher<Out = H256>> AddressMapping<AccountId32> for HashedAddressMapping<H> {
fn into_account_id(address: H160) -> AccountId32 {
let mut data = [0u8; 24];
data[0..4].copy_from_slice(b"evm:");
data[4..24].copy_from_slice(&address[..]);
let hash = H::hash(&data);
AccountId32::from(Into::<[u8; 32]>::into(hash))
}
}
fn pay_priority_fee(tip: Self::LiquidityInfo) {
// Default Ethereum behaviour: issue the tip to the block author.
if let Some(tip) = tip {
let account_id = T::AddressMapping::into_account_id(<Pallet<T>>::find_author());
let _ = C::deposit_into_existing(&account_id, tip_after_commission.peek());
}
}