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 batch-precompile to shiden and astar #1006

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions runtime/astar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pallet-contracts = { workspace = true }
pallet-contracts-primitives = { workspace = true }
pallet-ethereum = { workspace = true }
pallet-evm = { workspace = true }
pallet-evm-precompile-batch = { workspace = true }
pallet-evm-precompile-blake2 = { workspace = true }
pallet-evm-precompile-bn128 = { workspace = true }
pallet-evm-precompile-dispatch = { workspace = true }
Expand Down Expand Up @@ -152,6 +153,7 @@ std = [
"pallet-custom-signatures/std",
"pallet-dapps-staking/std",
"pallet-evm-precompile-dapps-staking/std",
"pallet-evm-precompile-batch/std",
"pallet-evm-precompile-sr25519/std",
"pallet-evm-precompile-assets-erc20/std",
"pallet-evm-precompile-substrate-ecdsa/std",
Expand Down
12 changes: 9 additions & 3 deletions runtime/astar/src/precompiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use pallet_evm::{
PrecompileResult, PrecompileSet,
};
use pallet_evm_precompile_assets_erc20::{AddressToAssetId, Erc20AssetsPrecompileSet};
use pallet_evm_precompile_batch::BatchPrecompile;
use pallet_evm_precompile_blake2::Blake2F;
use pallet_evm_precompile_bn128::{Bn128Add, Bn128Mul, Bn128Pairing};
use pallet_evm_precompile_dapps_staking::DappsStakingWrapper;
Expand Down Expand Up @@ -56,9 +57,11 @@ impl<R, C> AstarNetworkPrecompiles<R, C> {
/// Return all addresses that contain precompiles. This can be used to populate dummy code
/// under the precompile.
pub fn used_addresses() -> impl Iterator<Item = H160> {
sp_std::vec![1, 2, 3, 4, 5, 6, 7, 8, 1024, 1025, 1026, 1027, 20481, 20482, 20483, 20484]
.into_iter()
.map(hash)
sp_std::vec![
1, 2, 3, 4, 5, 6, 7, 8, 1024, 1025, 1026, 1027, 20481, 20482, 20483, 20484, 20486
]
.into_iter()
.map(hash)
}
}

Expand All @@ -69,6 +72,7 @@ impl<R, C> PrecompileSet for AstarNetworkPrecompiles<R, C>
where
Erc20AssetsPrecompileSet<R>: PrecompileSet,
DappsStakingWrapper<R>: Precompile,
BatchPrecompile<R>: Precompile,
XcmPrecompile<R, C>: Precompile,
Dispatch<R>: Precompile,
R: pallet_evm::Config
Expand Down Expand Up @@ -114,6 +118,8 @@ where
a if a == hash(20483) => Some(SubstrateEcdsaPrecompile::<R>::execute(handle)),
// Xcm 0x5004
a if a == hash(20484) => Some(XcmPrecompile::<R, C>::execute(handle)),
// Batch 0x5006
a if a == hash(20486) => Some(BatchPrecompile::<R>::execute(handle)),
// If the address matches asset prefix, the we route through the asset precompile set
a if &a.to_fixed_bytes()[0..4] == ASSET_PRECOMPILE_ADDRESS_PREFIX => {
Erc20AssetsPrecompileSet::<R>::new().execute(handle)
Expand Down
2 changes: 2 additions & 0 deletions runtime/shiden/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pallet-contracts = { workspace = true }
pallet-contracts-primitives = { workspace = true }
pallet-ethereum = { workspace = true }
pallet-evm = { workspace = true }
pallet-evm-precompile-batch = { workspace = true }
pallet-evm-precompile-blake2 = { workspace = true }
pallet-evm-precompile-bn128 = { workspace = true }
pallet-evm-precompile-dispatch = { workspace = true }
Expand Down Expand Up @@ -163,6 +164,7 @@ std = [
"pallet-evm-precompile-modexp/std",
"pallet-evm-precompile-sha3fips/std",
"pallet-dapps-staking/std",
"pallet-evm-precompile-batch/std",
"pallet-evm-precompile-dapps-staking/std",
"pallet-evm-precompile-sr25519/std",
"pallet-evm-precompile-assets-erc20/std",
Expand Down
12 changes: 9 additions & 3 deletions runtime/shiden/src/precompiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use pallet_evm::{
PrecompileResult, PrecompileSet,
};
use pallet_evm_precompile_assets_erc20::{AddressToAssetId, Erc20AssetsPrecompileSet};
use pallet_evm_precompile_batch::BatchPrecompile;
use pallet_evm_precompile_blake2::Blake2F;
use pallet_evm_precompile_bn128::{Bn128Add, Bn128Mul, Bn128Pairing};
use pallet_evm_precompile_dapps_staking::DappsStakingWrapper;
Expand Down Expand Up @@ -56,9 +57,11 @@ impl<R, C> ShidenNetworkPrecompiles<R, C> {
/// Return all addresses that contain precompiles. This can be used to populate dummy code
/// under the precompile.
pub fn used_addresses() -> impl Iterator<Item = H160> {
sp_std::vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 1024, 1025, 1026, 1027, 20481, 20482, 20483, 20484]
.into_iter()
.map(hash)
sp_std::vec![
1, 2, 3, 4, 5, 6, 7, 8, 9, 1024, 1025, 1026, 1027, 20481, 20482, 20483, 20484, 20486
]
.into_iter()
.map(hash)
}
}

Expand All @@ -69,6 +72,7 @@ impl<R, C> PrecompileSet for ShidenNetworkPrecompiles<R, C>
where
Erc20AssetsPrecompileSet<R>: PrecompileSet,
DappsStakingWrapper<R>: Precompile,
BatchPrecompile<R>: Precompile,
XcmPrecompile<R, C>: Precompile,
Dispatch<R>: Precompile,
R: pallet_evm::Config
Expand Down Expand Up @@ -114,6 +118,8 @@ where
a if a == hash(20483) => Some(SubstrateEcdsaPrecompile::<R>::execute(handle)),
// Xcm 0x5004
a if a == hash(20484) => Some(XcmPrecompile::<R, C>::execute(handle)),
// Batch 0x5006
a if a == hash(20486) => Some(BatchPrecompile::<R>::execute(handle)),
// If the address matches asset prefix, the we route through the asset precompile set
a if &a.to_fixed_bytes()[0..4] == ASSET_PRECOMPILE_ADDRESS_PREFIX => {
Erc20AssetsPrecompileSet::<R>::new().execute(handle)
Expand Down
Loading