From 03ecfc40f2f4ed4189625ac12802717599d17cd6 Mon Sep 17 00:00:00 2001 From: Guantong Date: Fri, 31 Mar 2023 00:26:57 +0800 Subject: [PATCH] Other parachains <> Darwinia <> Ethereum (#1008) * Darwinia 2.0 * Darwinia shell chain (#27) * Skeleton * XCM configs * Bump toolchain * Code cleaning part.1 * Code cleaning part.2 * Update SS58 * Rename * Update token decimals * Format * Extract darwinia core primitives * License * Benchmarks * Extract constants * Docs * CI part.1 * Adjust the runtime pallets structure (#29) * frame-system * pallet-timestamp * pallet-authorship * pallet-balances * pallet-transaction-payment * pallet-parachain-system * pallet-parachain-info * pallet-aura-ext * pallet-xcmp-queue * pallet-dmp-queue * pallet-session * pallet-aura * pallet-collator-selection * format * deal ambiguous name * fix compile * clear imports * update visibility for pallets * add license for pallets * update darwinia comments * CI part.2 Signed-off-by: Xavier Lau * CI part.3 * CI part.4 * Add missing features * Case * Setup build environment * CI part.5 * Enable `kusama-native`, `rococo-native` Signed-off-by: Xavier Lau Co-authored-by: Guantong <04637@163.com> * Docs & formatting (#33) * Add EVM stuff (#30) * Skeleton * XCM configs * Bump toolchain * Code cleaning part.1 * Code cleaning part.2 * Update SS58 * Rename * Update token decimals * Format * Extract darwinia core primitives * Add frontier deps without fork! * License * Add pallets to runtime * Benchmarks * Append command part * Extract constants * Docs * CI part.1 * Adjust the runtime pallets structure (#29) * frame-system * pallet-timestamp * pallet-authorship * pallet-balances * pallet-transaction-payment * pallet-parachain-system * pallet-parachain-info * pallet-aura-ext * pallet-xcmp-queue * pallet-dmp-queue * pallet-session * pallet-aura * pallet-collator-selection * format * deal ambiguous name * fix compile * clear imports * update visibility for pallets * add license for pallets * update darwinia comments * Adapt main * Delete duplicated consts * Hack rpc * Client compile fix * Fix client * Move to ethereum mod * Add more precompile * Fix some issue * Solve conflict * Merge issues * Format * Add basic code for precompiles * Update EthRpcConfig * Use Hashing type * Foramt issue * Adjust service config * Add evm, ethereum feature * Add missing features * Move const * Doc * Format * Format * Format * Format * Format * Safer truncated * Clean importing * Suppress warnings * Remove empty line * Clean importing * Clean importing * Format * Clean importing * Restructure Co-authored-by: Xavier Lau Co-authored-by: Guantong <04637@163.com> * Polish RPC & service (#36) * Use full path * Abstract APIs & types * Format * Extract darwinia-runtime (#32) * Skeleton * XCM configs * Bump toolchain * Code cleaning part.1 * Code cleaning part.2 * Update SS58 * Rename * Update token decimals * Format * Extract darwinia core primitives * License * Benchmarks * Extract constants * Docs * CI part.1 * Adjust the runtime pallets structure (#29) * frame-system * pallet-timestamp * pallet-authorship * pallet-balances * pallet-transaction-payment * pallet-parachain-system * pallet-parachain-info * pallet-aura-ext * pallet-xcmp-queue * pallet-dmp-queue * pallet-session * pallet-aura * pallet-collator-selection * format * deal ambiguous name * fix compile * clear imports * update visibility for pallets * add license for pallets * update darwinia comments * CI part.2 Signed-off-by: Xavier Lau * CI part.3 * CI part.4 * Add missing features * Case * Setup build environment * CI part.5 * init * adjust structure & fix compile * Move`type Barrier` out of `common` because of different runtimes may require different barriers * Add required xcm barriers * format * remove redundant files * format * format * try fix ci * merge main * fix ci * Format * remove unused dependencies * format * format * format * Format Signed-off-by: Xavier Lau Co-authored-by: Xavier Lau * Polish service (#38) * use full path * RuntimeApi Co-authored-by: Xavier Lau * Enable `FrontierDb` subcommand (#37) * Refactor `new_partial` * Try fix compile * Update `new_partial` * Yeah, make compiler happy * Code clean * Something about command * Resolve conflict * Adapt for main style * Self review * Ready for review * Revert full-path in command mod * Code cleaning Co-authored-by: Xavier Lau * Use zero existential deposit (#48) * Update ED * Update `candidacy_bond` * Add messages-substrate deps (#49) * add messages-substrate deps * fix ci * add messages-substrate deps * fix ci * update messages-substrate deps * update cargo.lock * Format Co-authored-by: Xavier Lau * Process system and balances state (#39) * Process state part.1 * More detail * Take storages * Take KV * Merge balances * Extract balance lock * Format * Flatten account * Preprocess storage key * Fix properties * Add shell config * Modularize processor * Calculate total issuance * Recover nonce * Add darwinia's precompiles (#50) * Use `H160` as `AccountId` (#55) * Configure `H160` for runtime * Configure `H160` genesis Signed-off-by: Xavier Lau * Docs * Improve code * Add missing features * Format and enable missing features for #50 * Format * Fix evm config * Revert the rename Signed-off-by: Xavier Lau Co-authored-by: bear * Testnet preparation (#57) * More testing tokens * Update runtime version * Correct name * Adjust genesis accounts (#59) * Adjust genesis accounts * Docs * Typo * Adjust runtime and add pallets (#60) * Adjust runtime and add sudo * Adjust parameter types and add vesting * Fix compile * Add utility * Add collective, elections-phragmen, identity and treasury * Add preimage and scheduler * Add democracy and membership * Add multisig and proxy * License * License * Set balances's index to 5 * Code cleaning * Crab & Pangolin Runtime (#56) * Add assets component (#69) * Add asset pallet * Add asset precompile * Add precompile interface * Impl all asset precompile interfaces * Self review * Code clean * Add mock file * Fix test compile * Add test 1 * Add test 2 * Add test 3 * Add test 4 * Finish test * Add another type * Update asset origin * Fix CI * Move out from Others * Add asset to other runtimes * Bridge related pallets (#70) * Copy from Crab Parachain * Replace Crab Parachain > Darwinia * bridge pallets, many errors need to fix  Conflicts:  Cargo.lock  runtime/common/Cargo.toml  runtime/darwinia/src/pallets/mod.rs * Add fee_market  Conflicts:  runtime/common/Cargo.toml * Update deps * Update deps * Add bridge related pallets to darwinia * Add bridge related pallets to crab * format * Update deps * review * comment Co-authored-by: bear * Fix #72 (#79) * Add `message-transact` back (#74) * Update chain id (#85) * Update parachain IDs (#89) * Change paraId 1000 > 2105 * Darwinia paraId 2046 * Correct block time (#93) * Add parachain staking (#68) * Avoid large enum variant (#98) * Avoid large enum variant * Fix tests Co-authored-by: bear * Add account migration pallet (#86) * Init commit * Add todos * Add `ValidateUnsigned` * Add signature verify * Add event * Add comment * Update message hash * Add mock file * Compile mock * Add basic tests * Add more tests * Code clean * Clean toml * Format * Install it to the runtimes * Rename Co-authored-by: HackFisher Co-authored-by: Xavier Lau * Handle reference count (#102) * Handle reference count * Fix test * Housekeeping (#105) * Housekeeping * Format * Adjust path style (#99) * Bridge related pallets * fee market * format * evm * xcm * format * MaxMessagesToPruneAtOnce * move ByteArray * move AccountToAssetId * move UniqueSaturatedInto * Const * format * Add sudo key (#107) * Update XCM filter (#88) * Improve code (#111) * Update AssetId (#109) * Update asset id * Rename * Release collator staking restriction (#114) * Account migration (#108) * Add `staking` and `deposit` pre-compiles (#81) * Some optimization (#116) * Change sudo to Alith * Format * Doc * Security * Security * Opt * Grammar * Add staking & deposit to Crab & Pangolin (#112) * Some adjustment (#120) * Fast runtime * Valid genesis exposure * Assets genesis * Add `bridge_parachains` pallet (#122) * Update Grandpa Name * Add bridge parachain pallet * Correct bridge message verify * type HeadersToKeep * Fix CI * Fix CI * Account genesis (#123) * Handle EVM accounts and pruge locks Signed-off-by: Xavier Lau * Refactor account genesis * Purge locks * Update scope * Update special accounts list Signed-off-by: Xavier Lau * Vesting genesis (#127) * Handle EVM accounts and pruge locks Signed-off-by: Xavier Lau * Refactor account genesis * Purge locks * Update scope * Update special accounts list * Vesting genesis * Improve state management Signed-off-by: Xavier Lau * Merge balance after update decimal (#128) * Update order * Update README * Update reserve transfer filter (#130) * Frontier pallets storage process (#121) * Build test * Add licenses * Add ethereum schema process * Add evm state process * Self review * Delte useless file * Bump deps * Free license * Refactor * Correct prefixes Signed-off-by: Xavier Lau Signed-off-by: Xavier Lau Co-authored-by: Xavier Lau * Configure instant sealing for dev chains (#119) * Add start_dev_node * Add start_dev_node to command Fix compile * Don't check relay chain for dev node * Correct chain spec Identify * Add instant finalize * Clean * Add tip * Fix CI * opt * format * Revert "Fix CI" This reverts commit 63ae56a8a4ff329a708de8ae7287b3a2133fac19. * Format Signed-off-by: Xavier Lau * Remove redundant clone Signed-off-by: Xavier Lau Co-authored-by: bear Co-authored-by: fisher Co-authored-by: Xavier Lau * Optimize storage (#132) * Update bridge deps (#134) * Update bridge deps * Correct version of cfg-if for `twox-hash` * Fix account insert key (#139) * Fix account insert bug * Code clean * Delete empty line * Correct `RuntimeApi` & `RuntimeExecutor` (#141) * Convert the rest locations to H160 by hashing it (#138) * Convert the rest locations to H160 by hashing it * format * fix review * Process staking (#133) * Process staking * Correct type * Refactor * Introduce `Adjust` trait * Refactor * Format * Update links * Doc * Fix * Doc * Fix vesting processor (#144) * Fix vesting processor Signed-off-by: Xavier Lau * Format Signed-off-by: Xavier Lau * Update KTON owner (#145) * Add genesis (#148) * Add genesis * Fix compile * Clippy (#150) * Fix revert (#149) Co-authored-by: Xavier Lau * Fix hash key (#152) * Process indices & more utility fns (#151) * More tools * Process indices * More error logs Signed-off-by: Xavier Lau Signed-off-by: Xavier Lau * Fix contract account `sufficients` (#146) * Update sufficient * Inc sufficient for contract account * Fix * Use new style * Fix type & code optimization (#154) * Fix type & code optimization * Use `u16` to bypass the https://github.com/polkadot-js/apps/issues/8591 * Fix bonded prefix (#155) * Fix bonded prefix * Restore * Fix * Update type (#156) * Kton state migrate (#137) * Step 1 * Step 2 * Step 3 * Step 4 * Finish processor side * Add runtime side * Add metadata insert * Fix approvals inc * Fresh new details * Use Vec * Adapt new way * Code clean * Remove `sp-core` * Fix todo and review * Fix link and format * Cross compile support (#159) * Improve deposit (#160) * Improve deposit * Test more cases * Fix tests * Some fixes (#162) * Improve config for pallet_bridge_grandpa (#161) * Update max bridged authorities follow https://github.com/paritytech/parity-bridges-common/blob/c28b3ff66c29c6c9d9955583b50c2114de14e98c/primitives/chain-rococo/src/lib.rs#L45-L48 * Update max bridged header size to 65536 * Update weight info follow https://github.com/paritytech/parity-bridges-common/blob/c28b3ff66c29c6c9d9955583b50c2114de14e98c/bin/millau/runtime/src/lib.rs#L431 * Keep WeightInfo to () * Code Clean * Improve kton migration (#163) * Improve kton migration * Typo * Doc * Name * Fix * Fix * Use `DealWithFees` in `transaction_payment` (#164) * Add `claim_with_penalty` interface (#165) * Handle different account types (#168) * Handle different account types * Format * State process test (#153) * First commit * Add balance test * Try fix * test total_issuance * Test the kton part removed * Add evm related test * Assert evm account storages * Update evm storage tests * Add vesting info test * Add indices test * Add staking test * Add staking test 2 * Fix tests * Add deposit items test * Finish staking test * Add tests for assets * Test kton transfer to asset pallet * Test kton total issuance * Fix todo * Add parachain support * Remove ignored case * Add combine solo,para account tests * Code clean * Add filter * Refactor the test * Ignore two cases * Rwrite all tests * Update evm codes test * Code format * Fix indices tests * Remove debug line * Format * Format * Fix review Co-authored-by: Xavier Lau * Happy new year (#170) * Happy new year * Fix * Process proxy and support generic runtime (#172) * Format * Process proxy and support generic runtime * Format * Format * Fixes * Adjust XCM trader (#143) * init LocalAssetTrader * LocalAssetTrader * Update trader for pangolin & crab * format * Update comments * Update logs * format * Format * Simplify code Co-authored-by: fisher Co-authored-by: Xavier Lau * Adjust common functions (#167) * WeightToFee * darwinia_deposit * Move darwinia_deposit to primitives * fix review * remove unused smallvec * Pangolin2 preparation (#174) * New data path * Simplify staking migration * Refactor * Build spec automatically * Download specs automatically * Use `take` * Remove unnecessary doc * Add darwinia dispatch precompile (#173) * Add darwinia dispatch * Fix test Co-authored-by: Xavier Lau Co-authored-by: fisher * Process sudo (#177) * Process sudo * Add testing key * Fixes (#179) * Fix * Bump to fix * Fix genesis * Fix build spec * Test env * Fund Alith (#182) * Fund Alith * Use local chain type * Optional download (#183) * Fix processor tests (#175) * Fix test * Fix test * Delete sudo and metadata * ECDSA authority (#184) * Add message gadget * Fix compile * Fix mock * Fix test * Add ecdsa-authority * License * Add `restake` and fix some bugs (#188) * Add `restake` and fix some bugs * More tests * More tests * Doc * Add restake interface (#189) * Add `Proxy` tests (#190) * Check key prefix * Add tests * Use `any` * Improve existing check (#191) * Improve existing check * Remove unused variable * Modify testnet time (#192) * Improve tips * Clippy * Set testnet time to 5 mins * `account-migration` runtime tests (#169) * Add validate unsigned test * Add validation tests * Account migrate test * Fix redundant encode * Kton asset * prepare accounts * Remove migration * Pass tests * kton tests * Add staking test * Fix test * Staking test * Finish pangolin tests * Add crab and darwinia tests * Revert changes Co-authored-by: Xavier Lau * Human readable sign message (#195) * Human readable sign message * Update spec * Update proxy filter (#197) * Use features check action (#198) Signed-off-by: Xavier Lau Signed-off-by: Xavier Lau * Merge collator payout (#200) * Merge collator payout * Bump runtime version * Improve code * Doc * Refactor runtime tests (#204) * Test only code (#206) * Fix precompiles genesis (#207) * Tweak the genesis config * Add tests * Use check runtime action (#208) * Use check runtime action * Try * Try Signed-off-by: Xavier Lau * Test all runtimes Signed-off-by: Xavier Lau * Done * Remove compress step * Remove unused env var Signed-off-by: Xavier Lau * To `polkadot-v0.9.33` and some other changes (#171) * Anchor polkadot-v0.9.33 * Companion for paritytech/cumulus#1685 * Companion for paritytech/cumulus#1585 * Companion for paritytech/cumulus#1745 * Companion for paritytech/cumulus#1759 * Companion for paritytech/cumulus#1782 * Companion for paritytech/cumulus#1793 * Companion for paritytech/cumulus#1808 * Temp use prepare branch of messages-substrate * Use darwinia fork frontier * Use correct moonbeam substrate commit * Correct bp-darwinia-core std * Use prepare moonbeam v0.9.33 * Update ethereum to 0.14.0 * Companion for paritytech/substrate#11649, paritytech/polkadot#5729 democracy * Companion for paritytech/substrate#11649, paritytech/polkadot#5729 scheduler * Companion for paritytech/substrate#11649, paritytech/polkadot#5729 preimage * Companion for paritytech/substrate#12109 * Type create origin * Format * Fix type CreateOrigin * Format * Companion for paritytech/frontier#935 * Fix compile * Fix service * Format * `Frontier` upgrade (#196) * Delete BaseFee * Fix todo * Update prepare branch * Fix mock * Add pallet-evm-precompile-dispatch/std * Format * Format * Correct version after merge * Fix review * Fix review * Fix CI test * Fix compile after merge Co-authored-by: bear * pallet-identity state process (#124) * Add types folder * Read storage out * Decimal update * Add remove subsOf and superOf * Remove useless file * Add README * Process in runtime side * Format * Add SUDO back * Fix doc link * Identity migrate * Fix runtime * Add tests * Add tests * Code clean * Remove sp-runtime * Code format * Delete useless reserve * Reset the judgements * Self review * Fix * Add identities runtime tests * Fix tests * Just format * Tiny updates * Update doc Co-authored-by: Xavier Lau * Keep identity judgments (#210) * Keep identity judgments * Doc * Bump toolchain to `nightly-2022-11-15` (#212) * Add metadata for front end (#219) * Burn parachain backing RING (#218) * Fix state judgement (#222) * Fix judgement * Use adjust() * Format * Readable address (#224) * Add missing field (#226) * Fix `try-runtime` (#223) * Try fix * Try fix * Adjust toml file * Fix compile * Foramat * Adjust session consumer part.1 (#229) * Clean unused deps (#228) * Clean unused deps * Update messages-substrate deps * Try fix CI * Adapt PolkadotJS (#231) * Release Pangolin2 (#225) * Reorder * Adjust genesis * Typo * State types check (#230) * Check * Use type * Update processor files * Find others * Format * Default pangolin * Fix review * Account migration signer tool (#235) * Doc * Bump version for devnet * Account migration signer tool * Doc * Update docs (#237) Co-authored-by: Xavier Lau * Fix call indexes (#238) * Fix signer cli (#239) * Improve testing (#241) * Improve testing * Fix formula * Opt * State processor CI * Unset * Try Signed-off-by: Xavier Lau * Opt * Opt * Try Signed-off-by: Xavier Lau * Opt * Opt * Final test * Fix * Bump * Fix * Fix --------- Signed-off-by: Xavier Lau * Rebuild accounts' reservation (#242) * Set reservation to zero * Configure genesis collator * Rebuild accounts' reservation and update tests * Update tests * Add EVM tests (#234) * Support Ethereum for dev node * Add first test * Add rpc constants test * Add balance test * Add contract test * Finish balance and contract basic tests * Add bloom filter test * Test `eth_getCode` * Test nonce update * Test opcodes * Add event test * Finally, basic tests are covered. * Use `impl_self_contained_call` (#250) * Rebuild account reference counters (#249) * Rebuild account reference counters part.1 * part.2 * part.3 * TODO * Fix * Fixes Signed-off-by: Xavier Lau * Doc --------- Signed-off-by: Xavier Lau * Add evm checks (#252) * Add evm checks Signed-off-by: Xavier Lau * Fix --------- Signed-off-by: Xavier Lau * Clean empty ledger (#253) Signed-off-by: Xavier Lau * Add bridge extension validation (#251) * Add bridger extension validatioin * Update comments * Revert changes * Fix review * Add `reserve` and `references count` tests (#259) * Fix TODO * Add reserve test * Add another case * Add more samples * Code clean * Fix local test error * Handle special accounts (#265) * Handle special accounts * Refactor * More readable * Doc * Add staging workflow (#258) * Add staging workflow * Test CI * CI * Add deps * CI * CI * CI * Updte trigger --------- Co-authored-by: Xavier Lau * To `polkadot-v0.9.36` (#213) * Anchor polkadot-v0.9.36 * Companion for paritytech/cumulus#1860 * Companion for paritytech/cumulus#1876 * Companion for paritytech/cumulus#1904 * Companion for paritytech/substrate#12310 * Companion for paritytech/substrate#12740 * Bump array-bytes to 6.0.0 * Companion for paritytech/substrate#12868 * Companion for paritytech/cumulus#1930 * Companion for paritytech/cumulus#1905 * Companion for paritytech/cumulus#1880 * Companion for paritytech/cumulus#1997 * Companion for paritytech/cumulus#1559 * Prepare messages-substrate * Companion for paritytech/substrate#12684 * Companion for paritytech/substrate#12740 * Fix compile paritytech/substrate#12740 * Compile done * Format * Add call index * Compile done * Fix CI * Bump moonbeam * Fix CI * Try fix tests * Use into instead of `Compact` * Patch substrate & Fix compile * Fix try-runtime * Remove parity-util-mem * Format * Format * Opt * Format * Use `codec::Compact` * Format --------- Co-authored-by: Xavier Lau * Migrate `pallet-assets` (#260) * Anchor polkadot-v0.9.36 * Companion for paritytech/cumulus#1860 * Companion for paritytech/cumulus#1876 * Companion for paritytech/cumulus#1904 * Companion for paritytech/substrate#12310 * Companion for paritytech/substrate#12740 * Bump array-bytes to 6.0.0 * Companion for paritytech/substrate#12868 * Companion for paritytech/cumulus#1930 * Companion for paritytech/cumulus#1905 * Companion for paritytech/cumulus#1880 * Companion for paritytech/cumulus#1997 * Companion for paritytech/cumulus#1559 * Prepare messages-substrate * Companion for paritytech/substrate#12684 * Companion for paritytech/substrate#12740 * Fix compile paritytech/substrate#12740 * Compile done * Format * Add call index * Compile done * Fix CI * Bump moonbeam * Fix CI * Try fix tests * Use into instead of `Compact` * Patch substrate & Fix compile * Fix try-runtime * Remove parity-util-mem * Companion for https://github.com/paritytech/substrate/pull/12310 * Update state processor * Add type link * Fix review issues * Format --------- Co-authored-by: Guantong * Clean imports (#271) * Clean imports * Fix tests * Migrate multisig (#272) * Migrate multisig * Unit tests * Doc * Fix * More checks * Doc * Reject duplicative submission * Add special accounts migration test (#268) * Part 1 * Part 2 * Rename * Better function names * Update state storage filter (#273) * Let ethereum go * Update pallet name * Fix --------- Co-authored-by: Xavier Lau * Manage runtime through features (#274) * Format * Manage runtime through features * Total issuance assertions (#276) * Process parachain system (#278) * Try workspace's new feature (#277) * Update crate info * Update deps 1 * Update deps 2 * Update deps 3 * Update deps 4 * Format * Fix review * Rename `Staking` to `DarwiniaStaking` (#279) * Rename to `DarwiniaStaking` * Rename * Format (#280) * Add Pangoro2 (#281) * Format * Deduplicate * Add Pangoro2 * Rename * Fix * Fix * Rename * Doc * Set SS58 in runtime and remove from chain spec * To `polkadot-v0.9.37` (#266) * Anchor polkadot-v0.9.37 * Companion for paritytech/substrate#12307 * Companion for paritytech/cumulus#2057 * Use prepare branch for test * Companion for paritytech/frontier#981 * Remove collator selection in bench * Fix BenchmarkHelper * Fix compile * Format * Fix compile * Fix compile feature benchmark * Fix test * Format toml * Format * Pangoro2 0.9.37 * Fix try-runtime * Fix try-runtime cmd * Format * Fix review * Use `Vec` * Typo --------- Co-authored-by: Xavier Lau * Pangolin2 `6005` runtime upgrade (#283) * Update Pangolin CI * Bump runtime version * Set payout fraction to 40% (#284) * Set payout fraction to 40% * Format Signed-off-by: Xavier Lau --------- Signed-off-by: Xavier Lau * Add evm estimate gas tests (#282) * Add estimate gas tests * Fix CI * Fix ethereum block author (#286) * Fix ethereum block author * Move some structs to the common folder * Fix CI test * Clean * Pangolin2 <> Pangoro2 bridge (#285) * Copy darwinia bm => pangoro bm Copy crab bm => pangolin bm * Add pangolin&pangoro bridge-messages * Add bridge related pallets for pangolin&pangoro * Add bridge palles to runtime for pangolin & pangoro * Fix compile * Missing changes * Correct bridge-dispatch * Format * Update genesis * Update nonce test (#288) * Remove assertions in HRMP&DMP (#290) * Patch cumulus * Bump darwinia/cumulus * Preparation of Pangoro2 (#291) * Correct command * Some fixes * Update evm module runtime name (#293) * Fix evm runtime name * Format toml * Add migration * Fix state processor * Use latest polkadot-v0.9.37 commit * Fix tests * Bench upstream pallets (#292) * Fix balances benchmark * Add bridge related bench * Benchmark with steps 50 repeat 20 * Update weights for bridge pallets * Pangolin bench pallets * Bench s2 r1 for all runtimes * Update weights for all runtime * Add benchmarking items and bench darwinia-deposit (#294) * Add benchmarking items and bench darwinia-deposit * Format * Doc * Fix and update CI * Re-cache * Opt * Opt * Correct URI --------- Signed-off-by: Xavier Lau * Auto load large genesis (#295) * Auto load large genesis * Remove unused feature * Format * Opt * Fix broken CI (#296) * Try fix * Fix it! * Remove multisig (#299) * Update Pangoro2 parachain id (#304) * Update cross compile docker image (#303) * Update cross compile docker image * Fix compile * Easy make (#305) * Easy make * Format * Update EthBlockGasLimit (#306) * Update pangolin's max gas limit * Update other runtimes * Move evm tests * Self review * Anchor v0.9.38 * Companion for paritytech/cumulus#2067 * Companion for paritytech/cumulus#697 XCM v3 * Companion for paritytech/cumulus#2096 * Companion for paritytech/cumulus#1863 * Companion for paritytech/cumulus#2073 * Companion for paritytech/cumulus#2126 * Use prepare branch * Companion for paritytech/substrate#13216 * Companion for darwinia-messages-substrate#254 * Companion for paritytech/polkadot#4097 * Part companion for paritytech/cumulus#2067 * Correct companion for cumulus#2073 * Fix xcm compilation * Fix compilation done * Fix compilation with benchmark * Replace prepare branch * Format * Add EthereumXcm and XcmTransactor * Some fix * Fix compile 2 * Compile done * Format * Fix compilation done * Format * Add DarwiniaCall * Patch moonbeam debug branch * Patch polkadot debug branch * Patch frontier debug branch * Add many logs * Patch substrate debug branch * Update frontier&moonbeam debug logs * Add `EthereumXcm` and `XcmTransactor` for pangolin * Optimize bls precompile by arkworks lib (#993) * Optimize bls precompile by arkworks lib * Pin bls-test precompose at `address(2017)` * Fmt * Update deps * Add openssl deps in nix * Remove empty line * Format and fix compile * Fix * Resolve conv * Fix * Use rustup on nixos * Fix * Disable in the crab and darwinia network * Add `shell.nix` to .gitigore * Format * Format --------- Co-authored-by: Xavier Lau Co-authored-by: bear * Opt `deserialize_compressed` -> `deserialize_compressed_unchecked` (#1009) * Remove frontier log * Debug log in ecdsa * XcmTransactor weight v2 * Correct barrier * Remove xcmTransactor from Pangolin * Remove xcmTransactor from Pangoro * Message root record should be updated correctly (#1048) * Adjustable collator count (#1012) * Fix compile * Add missed bls commit * Remove moonbeam-relay-encoder * Refactor * Bench * Unused log * Revert "Update ecdsa-authority spec (#1022)" This reverts commit 3c07f7be6226e901a38d9544a9621032cf9caaa2. * Fix * Fix corner cases and add more unit tests Signed-off-by: Xavier Lau * Add ethereum-xcm to darwinia runtime * Companion for paritytech/frontier#1011, #1014 * Remove debug patch * Fix merging * Revert "Revert "Update ecdsa-authority spec (#1022)"" This reverts commit 2b1a07ba6df574aad43bde40cfa47dfa7d0e86f5. * Fix tests * Fix benchmark compile * Fix try-runtime features * GITHUB_CACHE_VERSION * Format * Move ethereumXcm pallet to EVM stuff * Disable transactThroughProxy * Fix runtime benchmarks * Fix review * Format --------- Signed-off-by: Xavier Lau Co-authored-by: Xavier Lau Co-authored-by: bear Co-authored-by: HackFisher Co-authored-by: fewensa <37804932+fewensa@users.noreply.github.com> Co-authored-by: Guantong Co-authored-by: echo --- .github/workflows/checks.yml | 2 +- Cargo.lock | 125 +++++++++++++------ Cargo.toml | 43 +++---- node/Cargo.toml | 2 +- node/src/frontier_service.rs | 54 +------- node/src/service/mod.rs | 4 +- pallet/message-transact/src/mock.rs | 5 + runtime/crab/Cargo.toml | 3 + runtime/crab/src/pallets/ethereum.rs | 5 + runtime/darwinia/Cargo.toml | 10 +- runtime/darwinia/src/lib.rs | 1 + runtime/darwinia/src/pallets.rs | 2 + runtime/darwinia/src/pallets/ethereum.rs | 5 + runtime/darwinia/src/pallets/ethereum_xcm.rs | 37 ++++++ runtime/darwinia/src/pallets/polkadot_xcm.rs | 40 +++++- runtime/pangolin/Cargo.toml | 10 +- runtime/pangolin/src/lib.rs | 1 + runtime/pangolin/src/pallets.rs | 2 + runtime/pangolin/src/pallets/ethereum.rs | 5 + runtime/pangolin/src/pallets/ethereum_xcm.rs | 37 ++++++ runtime/pangolin/src/pallets/polkadot_xcm.rs | 40 +++++- runtime/pangoro/Cargo.toml | 10 +- runtime/pangoro/src/lib.rs | 1 + runtime/pangoro/src/pallets.rs | 2 + runtime/pangoro/src/pallets/ethereum.rs | 5 + runtime/pangoro/src/pallets/ethereum_xcm.rs | 37 ++++++ runtime/pangoro/src/pallets/polkadot_xcm.rs | 40 +++++- 27 files changed, 394 insertions(+), 134 deletions(-) create mode 100644 runtime/darwinia/src/pallets/ethereum_xcm.rs create mode 100644 runtime/pangolin/src/pallets/ethereum_xcm.rs create mode 100644 runtime/pangoro/src/pallets/ethereum_xcm.rs diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 075eca174..856501782 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -25,7 +25,7 @@ env: CARGO_INCREMENTAL: 1 CARGO_TERM_COLOR: always - GITHUB_CACHE_VERSION: 3 + GITHUB_CACHE_VERSION: 4 RUST_BACKTRACE: full diff --git a/Cargo.lock b/Cargo.lock index 74769c6b9..96ef38cec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,7 +15,7 @@ dependencies = [ [[package]] name = "account" version = "0.1.1" -source = "git+https://github.com/darwinia-network/moonbeam?branch=polkadot-v0.9.38#6b21c49d9c3def2b0cd799f67c1feb136831e749" +source = "git+https://github.com/darwinia-network/moonbeam?branch=update-0.9.38#abca6696c3731dd781d7badfb7cd797e36e39bf5" dependencies = [ "blake2-rfc", "hex", @@ -876,7 +876,7 @@ dependencies = [ [[package]] name = "bp-darwinia-core" version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#b5bf1f59cc9ff8e38f9d1baa65b2dfca68980f0a" +source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#c93f45cda37abe7c6c3144d1895f43bed199584f" dependencies = [ "account", "bp-messages", @@ -893,7 +893,7 @@ dependencies = [ [[package]] name = "bp-header-chain" version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#b5bf1f59cc9ff8e38f9d1baa65b2dfca68980f0a" +source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#c93f45cda37abe7c6c3144d1895f43bed199584f" dependencies = [ "bp-runtime", "finality-grandpa", @@ -910,7 +910,7 @@ dependencies = [ [[package]] name = "bp-message-dispatch" version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#b5bf1f59cc9ff8e38f9d1baa65b2dfca68980f0a" +source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#c93f45cda37abe7c6c3144d1895f43bed199584f" dependencies = [ "bp-runtime", "frame-support", @@ -923,7 +923,7 @@ dependencies = [ [[package]] name = "bp-messages" version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#b5bf1f59cc9ff8e38f9d1baa65b2dfca68980f0a" +source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#c93f45cda37abe7c6c3144d1895f43bed199584f" dependencies = [ "bitvec", "bp-runtime", @@ -940,7 +940,7 @@ dependencies = [ [[package]] name = "bp-parachains" version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#b5bf1f59cc9ff8e38f9d1baa65b2dfca68980f0a" +source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#c93f45cda37abe7c6c3144d1895f43bed199584f" dependencies = [ "bp-polkadot-core", "bp-runtime", @@ -953,7 +953,7 @@ dependencies = [ [[package]] name = "bp-polkadot-core" version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#b5bf1f59cc9ff8e38f9d1baa65b2dfca68980f0a" +source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#c93f45cda37abe7c6c3144d1895f43bed199584f" dependencies = [ "bp-messages", "bp-runtime", @@ -972,7 +972,7 @@ dependencies = [ [[package]] name = "bp-runtime" version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#b5bf1f59cc9ff8e38f9d1baa65b2dfca68980f0a" +source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#c93f45cda37abe7c6c3144d1895f43bed199584f" dependencies = [ "frame-support", "frame-system", @@ -993,7 +993,7 @@ dependencies = [ [[package]] name = "bp-test-utils" version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#b5bf1f59cc9ff8e38f9d1baa65b2dfca68980f0a" +source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#c93f45cda37abe7c6c3144d1895f43bed199584f" dependencies = [ "bp-header-chain", "ed25519-dalek", @@ -1008,7 +1008,7 @@ dependencies = [ [[package]] name = "bridge-runtime-common" version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#b5bf1f59cc9ff8e38f9d1baa65b2dfca68980f0a" +source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#c93f45cda37abe7c6c3144d1895f43bed199584f" dependencies = [ "bp-header-chain", "bp-message-dispatch", @@ -2449,9 +2449,9 @@ dependencies = [ "fc-mapping-sync", "fc-rpc", "fc-rpc-core", + "fc-storage", "fp-evm", "fp-rpc", - "fp-storage", "frame-benchmarking", "frame-benchmarking-cli", "futures", @@ -2795,6 +2795,7 @@ dependencies = [ "pallet-democracy", "pallet-elections-phragmen", "pallet-ethereum", + "pallet-ethereum-xcm", "pallet-evm", "pallet-evm-precompile-blake2", "pallet-evm-precompile-bn128", @@ -3611,7 +3612,7 @@ dependencies = [ [[package]] name = "fc-cli" version = "1.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "clap", "ethereum-types 0.14.1", @@ -3629,7 +3630,7 @@ dependencies = [ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "fp-storage", "kvdb-rocksdb", @@ -3648,9 +3649,10 @@ dependencies = [ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "fc-db", + "fc-storage", "fp-consensus", "fp-rpc", "futures", @@ -3665,13 +3667,14 @@ dependencies = [ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "ethereum", "ethereum-types 0.14.1", "evm", "fc-db", "fc-rpc-core", + "fc-storage", "fp-ethereum", "fp-rpc", "fp-storage", @@ -3699,7 +3702,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-storage", "substrate-prometheus-endpoint", "tokio", ] @@ -3707,7 +3709,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "ethereum", "ethereum-types 0.14.1", @@ -3717,6 +3719,24 @@ dependencies = [ "serde_json", ] +[[package]] +name = "fc-storage" +version = "1.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" +dependencies = [ + "ethereum", + "ethereum-types 0.14.1", + "fp-rpc", + "fp-storage", + "parity-scale-codec", + "sc-client-api", + "sp-api", + "sp-blockchain", + "sp-io", + "sp-runtime", + "sp-storage", +] + [[package]] name = "fdlimit" version = "0.2.1" @@ -3871,7 +3891,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "ethereum", "parity-scale-codec", @@ -3883,7 +3903,7 @@ dependencies = [ [[package]] name = "fp-ethereum" version = "1.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "ethereum", "ethereum-types 0.14.1", @@ -3897,7 +3917,7 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "evm", "frame-support", @@ -3911,7 +3931,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "ethereum", "ethereum-types 0.14.1", @@ -3927,7 +3947,7 @@ dependencies = [ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "frame-support", "parity-scale-codec", @@ -3939,7 +3959,7 @@ dependencies = [ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "parity-scale-codec", "serde", @@ -7163,7 +7183,7 @@ dependencies = [ [[package]] name = "pallet-bridge-dispatch" version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#b5bf1f59cc9ff8e38f9d1baa65b2dfca68980f0a" +source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#c93f45cda37abe7c6c3144d1895f43bed199584f" dependencies = [ "bp-message-dispatch", "bp-runtime", @@ -7179,7 +7199,7 @@ dependencies = [ [[package]] name = "pallet-bridge-grandpa" version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#b5bf1f59cc9ff8e38f9d1baa65b2dfca68980f0a" +source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#c93f45cda37abe7c6c3144d1895f43bed199584f" dependencies = [ "bp-header-chain", "bp-runtime", @@ -7201,7 +7221,7 @@ dependencies = [ [[package]] name = "pallet-bridge-messages" version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#b5bf1f59cc9ff8e38f9d1baa65b2dfca68980f0a" +source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#c93f45cda37abe7c6c3144d1895f43bed199584f" dependencies = [ "bitvec", "bp-message-dispatch", @@ -7222,7 +7242,7 @@ dependencies = [ [[package]] name = "pallet-bridge-parachains" version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#b5bf1f59cc9ff8e38f9d1baa65b2dfca68980f0a" +source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#c93f45cda37abe7c6c3144d1895f43bed199584f" dependencies = [ "bp-parachains", "bp-polkadot-core", @@ -7368,7 +7388,7 @@ dependencies = [ [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "ethereum", "ethereum-types 0.14.1", @@ -7391,10 +7411,36 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-ethereum-xcm" +version = "1.0.0-dev" +source = "git+https://github.com/darwinia-network/moonbeam?branch=update-0.9.38#abca6696c3731dd781d7badfb7cd797e36e39bf5" +dependencies = [ + "ethereum", + "ethereum-types 0.14.1", + "fp-ethereum", + "fp-evm", + "fp-rpc", + "fp-self-contained", + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-evm", + "pallet-timestamp", + "parity-scale-codec", + "rlp", + "scale-info", + "serde", + "sp-io", + "sp-runtime", + "sp-std", + "xcm-primitives", +] + [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "environmental", "evm", @@ -7418,7 +7464,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-blake2" version = "2.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "fp-evm", ] @@ -7426,7 +7472,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-bn128" version = "2.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "fp-evm", "sp-core", @@ -7436,7 +7482,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-dispatch" version = "2.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "fp-evm", "frame-support", @@ -7446,7 +7492,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "fp-evm", "num", @@ -7455,7 +7501,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" -source = "git+https://github.com/darwinia-network/frontier?branch=polkadot-v0.9.38#28c1f8a80152cabdf98afe58dc37fa963682d978" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.38#5644279da588baab7caa9f3a4eb69363e1606461" dependencies = [ "fp-evm", "ripemd", @@ -7483,7 +7529,7 @@ dependencies = [ [[package]] name = "pallet-fee-market" version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#b5bf1f59cc9ff8e38f9d1baa65b2dfca68980f0a" +source = "git+https://github.com/darwinia-network/darwinia-messages-substrate?branch=polkadot-v0.9.38#c93f45cda37abe7c6c3144d1895f43bed199584f" dependencies = [ "bp-messages", "bp-runtime", @@ -8192,6 +8238,7 @@ dependencies = [ "pallet-democracy", "pallet-elections-phragmen", "pallet-ethereum", + "pallet-ethereum-xcm", "pallet-evm", "pallet-evm-precompile-blake2", "pallet-evm-precompile-bn128", @@ -8295,6 +8342,7 @@ dependencies = [ "pallet-democracy", "pallet-elections-phragmen", "pallet-ethereum", + "pallet-ethereum-xcm", "pallet-evm", "pallet-evm-precompile-blake2", "pallet-evm-precompile-bn128", @@ -9850,7 +9898,7 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "precompile-utils" version = "0.1.0" -source = "git+https://github.com/darwinia-network/moonbeam?branch=polkadot-v0.9.38#6b21c49d9c3def2b0cd799f67c1feb136831e749" +source = "git+https://github.com/darwinia-network/moonbeam?branch=update-0.9.38#abca6696c3731dd781d7badfb7cd797e36e39bf5" dependencies = [ "affix", "derive_more", @@ -9881,7 +9929,7 @@ dependencies = [ [[package]] name = "precompile-utils-macro" version = "0.1.0" -source = "git+https://github.com/darwinia-network/moonbeam?branch=polkadot-v0.9.38#6b21c49d9c3def2b0cd799f67c1feb136831e749" +source = "git+https://github.com/darwinia-network/moonbeam?branch=update-0.9.38#abca6696c3731dd781d7badfb7cd797e36e39bf5" dependencies = [ "case", "num_enum", @@ -15503,11 +15551,12 @@ dependencies = [ [[package]] name = "xcm-primitives" version = "0.1.0" -source = "git+https://github.com/darwinia-network/moonbeam?branch=polkadot-v0.9.38#6b21c49d9c3def2b0cd799f67c1feb136831e749" +source = "git+https://github.com/darwinia-network/moonbeam?branch=update-0.9.38#abca6696c3731dd781d7badfb7cd797e36e39bf5" dependencies = [ "cumulus-primitives-core", "ethereum", "ethereum-types 0.14.1", + "frame-benchmarking", "frame-support", "frame-system", "hex", diff --git a/Cargo.toml b/Cargo.toml index e2d29ea11..acbd8a5dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,29 +84,30 @@ pallet-bridge-parachains = { git = "https://github.com/darwinia-network/darwinia pallet-fee-market = { git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.38", default-features = false } # frontier -fc-cli = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" } -fc-consensus = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" } -fc-db = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" } -fc-mapping-sync = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" } -fc-rpc = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" } -fc-rpc-core = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" } -fp-ethereum = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38", default-features = false } -fp-evm = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38", default-features = false } -fp-rpc = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38", default-features = false } -fp-self-contained = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38", default-features = false } -fp-storage = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38", default-features = false } -pallet-ethereum = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38", default-features = false } -pallet-evm = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38", default-features = false } -pallet-evm-precompile-blake2 = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38", default-features = false } -pallet-evm-precompile-bn128 = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38", default-features = false } -pallet-evm-precompile-dispatch = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38", default-features = false } -pallet-evm-precompile-modexp = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38", default-features = false } -pallet-evm-precompile-simple = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38", default-features = false } +fc-cli = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" } +fc-consensus = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" } +fc-db = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" } +fc-mapping-sync = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" } +fc-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" } +fc-rpc-core = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" } +fc-storage = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" } +fp-ethereum = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38", default-features = false } +fp-evm = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38", default-features = false } +fp-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38", default-features = false } +fp-self-contained = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38", default-features = false } +pallet-ethereum = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38", default-features = false } +pallet-evm = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38", default-features = false } +pallet-evm-precompile-blake2 = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38", default-features = false } +pallet-evm-precompile-bn128 = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38", default-features = false } +pallet-evm-precompile-dispatch = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38", default-features = false } +pallet-evm-precompile-modexp = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38", default-features = false } +pallet-evm-precompile-simple = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38", default-features = false } # moonbeam -account = { git = "https://github.com/darwinia-network/moonbeam", branch = "polkadot-v0.9.38", default-features = false } -precompile-utils = { git = "https://github.com/darwinia-network/moonbeam", branch = "polkadot-v0.9.38", default-features = false } -xcm-primitives = { git = "https://github.com/darwinia-network/moonbeam", branch = "polkadot-v0.9.38", default-features = false } +account = { git = "https://github.com/darwinia-network/moonbeam", branch = "update-0.9.38", default-features = false } +pallet-ethereum-xcm = { git = "https://github.com/darwinia-network/moonbeam", branch = "update-0.9.38", default-features = false } +precompile-utils = { git = "https://github.com/darwinia-network/moonbeam", branch = "update-0.9.38", default-features = false } +xcm-primitives = { git = "https://github.com/darwinia-network/moonbeam", branch = "update-0.9.38", default-features = false } # polkadot pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38", default-features = false } diff --git a/node/Cargo.toml b/node/Cargo.toml index 5e4fa50b1..6d7e46770 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -45,9 +45,9 @@ fc-db = { workspace = true } fc-mapping-sync = { workspace = true } fc-rpc = { features = ["rpc-binary-search-estimate"], workspace = true } fc-rpc-core = { workspace = true } +fc-storage = { workspace = true } fp-evm = { workspace = true, features = ["std"] } fp-rpc = { workspace = true, features = ["std"] } -fp-storage = { workspace = true, features = ["std"] } # polkadot polkadot-cli = { workspace = true } diff --git a/node/src/frontier_service.rs b/node/src/frontier_service.rs index 16ab6bc12..912cd7110 100644 --- a/node/src/frontier_service.rs +++ b/node/src/frontier_service.rs @@ -19,27 +19,20 @@ //! Service and service factory implementation. Specialized wrapper over substrate service. // std -use std::{collections::BTreeMap, path::PathBuf, sync::Arc, time::Duration}; +use std::{path::PathBuf, sync::Arc, time::Duration}; // crates.io use futures::{future, StreamExt}; // darwinia use crate::cli::Cli; -use dc_primitives::{Block, BlockNumber, Hash, Hashing}; +use dc_primitives::{BlockNumber, Hash, Hashing}; // frontier use fc_db::Backend as FrontierBackend; use fc_mapping_sync::{MappingSyncWorker, SyncStrategy}; -use fc_rpc::{ - EthTask, OverrideHandle, RuntimeApiStorageOverride, SchemaV1Override, SchemaV2Override, - SchemaV3Override, StorageOverride, -}; +use fc_rpc::{EthTask, OverrideHandle}; use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool}; -use fp_storage::EthereumStorageSchema; // substrate use sc_cli::SubstrateCli; -use sc_client_api::backend::{AuxStore, Backend, StateBackend, StorageProvider}; use sc_service::{BasePath, Configuration, TaskManager}; -use sp_api::ProvideRuntimeApi; -use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; #[allow(clippy::too_many_arguments)] pub fn spawn_frontier_tasks( @@ -73,6 +66,7 @@ pub fn spawn_frontier_tasks( Duration::new(6, 0), client.clone(), backend, + overrides.clone(), frontier_backend, 3, 0, @@ -110,43 +104,3 @@ pub(crate) fn db_config_dir(config: &Configuration) -> PathBuf { .config_dir(config.chain_spec.id()) }) } - -pub(crate) fn overrides_handle(client: Arc) -> Arc> -where - C: 'static - + Send - + Sync - + ProvideRuntimeApi - + StorageProvider - + AuxStore - + HeaderBackend - + HeaderMetadata, - C::Api: sp_api::ApiExt - + fp_rpc::EthereumRuntimeRPCApi - + fp_rpc::ConvertTransactionRuntimeApi, - BE: 'static + Backend, - BE::State: StateBackend, -{ - let mut overrides_map = BTreeMap::new(); - - overrides_map.insert( - EthereumStorageSchema::V1, - Box::new(SchemaV1Override::new(client.clone())) - as Box + Send + Sync>, - ); - overrides_map.insert( - EthereumStorageSchema::V2, - Box::new(SchemaV2Override::new(client.clone())) - as Box + Send + Sync>, - ); - overrides_map.insert( - EthereumStorageSchema::V3, - Box::new(SchemaV3Override::new(client.clone())) - as Box + Send + Sync>, - ); - - Arc::new(OverrideHandle { - schemas: overrides_map, - fallback: Box::new(RuntimeApiStorageOverride::new(client)), - }) -} diff --git a/node/src/service/mod.rs b/node/src/service/mod.rs index 01f926172..7a0c7bd33 100644 --- a/node/src/service/mod.rs +++ b/node/src/service/mod.rs @@ -344,7 +344,7 @@ where ); } - let overrides = frontier_service::overrides_handle(client.clone()); + let overrides = fc_storage::overrides_handle(client.clone()); let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new( task_manager.spawn_handle(), overrides.clone(), @@ -808,7 +808,7 @@ where } let prometheus_registry = config.prometheus_registry().cloned(); - let overrides = frontier_service::overrides_handle(client.clone()); + let overrides = fc_storage::overrides_handle(client.clone()); let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new( task_manager.spawn_handle(), overrides.clone(), diff --git a/pallet/message-transact/src/mock.rs b/pallet/message-transact/src/mock.rs index dd59e762a..0c019d3fc 100644 --- a/pallet/message-transact/src/mock.rs +++ b/pallet/message-transact/src/mock.rs @@ -134,7 +134,12 @@ impl pallet_evm::Config for TestRuntime { type WithdrawOrigin = pallet_evm::EnsureAddressNever; } +frame_support::parameter_types! { + pub const PostBlockAndTxnHashes: pallet_ethereum::PostLogContent = pallet_ethereum::PostLogContent::BlockAndTxnHashes; +} + impl pallet_ethereum::Config for TestRuntime { + type PostLogContent = PostBlockAndTxnHashes; type RuntimeEvent = RuntimeEvent; type StateRoot = IntermediateStateRoot; } diff --git a/runtime/crab/Cargo.toml b/runtime/crab/Cargo.toml index bcc21e487..102d3570b 100644 --- a/runtime/crab/Cargo.toml +++ b/runtime/crab/Cargo.toml @@ -255,6 +255,9 @@ on-chain-release-build = [ ] runtime-benchmarks = [ + # crates.io + "array-bytes", + # cumulus "cumulus-pallet-parachain-system/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", diff --git a/runtime/crab/src/pallets/ethereum.rs b/runtime/crab/src/pallets/ethereum.rs index 8d53d1276..cb4da4755 100644 --- a/runtime/crab/src/pallets/ethereum.rs +++ b/runtime/crab/src/pallets/ethereum.rs @@ -19,7 +19,12 @@ // darwinia use crate::*; +frame_support::parameter_types! { + pub const PostBlockAndTxnHashes: pallet_ethereum::PostLogContent = pallet_ethereum::PostLogContent::BlockAndTxnHashes; +} + impl pallet_ethereum::Config for Runtime { + type PostLogContent = PostBlockAndTxnHashes; type RuntimeEvent = RuntimeEvent; type StateRoot = pallet_ethereum::IntermediateStateRoot; } diff --git a/runtime/darwinia/Cargo.toml b/runtime/darwinia/Cargo.toml index 9a7805ca1..9d66d6bb8 100644 --- a/runtime/darwinia/Cargo.toml +++ b/runtime/darwinia/Cargo.toml @@ -70,8 +70,9 @@ pallet-evm-precompile-modexp = { workspace = true } pallet-evm-precompile-simple = { workspace = true } # moonbeam -precompile-utils = { workspace = true } -xcm-primitives = { workspace = true } +pallet-ethereum-xcm = { workspace = true } +precompile-utils = { workspace = true } +xcm-primitives = { workspace = true } # polkadot pallet-xcm = { workspace = true } @@ -190,6 +191,7 @@ std = [ "pallet-evm-precompile-simple/std", # moonbeam + "pallet-ethereum-xcm/std", "precompile-utils/std", "xcm-primitives/std", @@ -285,6 +287,7 @@ runtime-benchmarks = [ "pallet-evm/runtime-benchmarks", # moonbeam + "pallet-ethereum-xcm/runtime-benchmarks", "xcm-primitives/runtime-benchmarks", # polkadot @@ -342,6 +345,9 @@ try-runtime = [ "pallet-bridge-parachains/try-runtime", "pallet-fee-market/try-runtime", + # moonbeam + "pallet-ethereum-xcm/try-runtime", + # frontier "fp-self-contained/try-runtime", "pallet-ethereum/try-runtime", diff --git a/runtime/darwinia/src/lib.rs b/runtime/darwinia/src/lib.rs index a70555acf..84259f400 100644 --- a/runtime/darwinia/src/lib.rs +++ b/runtime/darwinia/src/lib.rs @@ -152,6 +152,7 @@ frame_support::construct_runtime! { XcmpQueue: cumulus_pallet_xcmp_queue = 32, PolkadotXcm: pallet_xcm = 33, CumulusXcm: cumulus_pallet_xcm = 34, + EthereumXcm: pallet_ethereum_xcm = 44, DmpQueue: cumulus_pallet_dmp_queue = 35, // EVM stuff. diff --git a/runtime/darwinia/src/pallets.rs b/runtime/darwinia/src/pallets.rs index 77bf71176..b8b6382b8 100644 --- a/runtime/darwinia/src/pallets.rs +++ b/runtime/darwinia/src/pallets.rs @@ -99,6 +99,8 @@ mod xcmp_queue; mod polkadot_xcm; pub use polkadot_xcm::*; +mod ethereum_xcm; + mod dmp_queue; // EVM stuff. diff --git a/runtime/darwinia/src/pallets/ethereum.rs b/runtime/darwinia/src/pallets/ethereum.rs index 8d53d1276..cb4da4755 100644 --- a/runtime/darwinia/src/pallets/ethereum.rs +++ b/runtime/darwinia/src/pallets/ethereum.rs @@ -19,7 +19,12 @@ // darwinia use crate::*; +frame_support::parameter_types! { + pub const PostBlockAndTxnHashes: pallet_ethereum::PostLogContent = pallet_ethereum::PostLogContent::BlockAndTxnHashes; +} + impl pallet_ethereum::Config for Runtime { + type PostLogContent = PostBlockAndTxnHashes; type RuntimeEvent = RuntimeEvent; type StateRoot = pallet_ethereum::IntermediateStateRoot; } diff --git a/runtime/darwinia/src/pallets/ethereum_xcm.rs b/runtime/darwinia/src/pallets/ethereum_xcm.rs new file mode 100644 index 000000000..9bf6e4bf7 --- /dev/null +++ b/runtime/darwinia/src/pallets/ethereum_xcm.rs @@ -0,0 +1,37 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Darwinia is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Darwinia. If not, see . + +// darwinia +use crate::*; + +pub struct EthereumXcmEnsureProxy; +impl xcm_primitives::EnsureProxy for EthereumXcmEnsureProxy { + fn ensure_ok(_delegator: AccountId, _delegatee: AccountId) -> Result<(), &'static str> { + Err("Denied") + } +} + +impl pallet_ethereum_xcm::Config for Runtime { + type ControllerOrigin = frame_system::EnsureRoot; + type EnsureProxy = EthereumXcmEnsureProxy; + type InvalidEvmTransactionError = pallet_ethereum::InvalidTransactionWrapper; + type ReservedXcmpWeight = + ::ReservedXcmpWeight; + type ValidatedTransaction = pallet_ethereum::ValidatedTransaction; + type XcmEthereumOrigin = pallet_ethereum_xcm::EnsureXcmEthereumTransaction; +} diff --git a/runtime/darwinia/src/pallets/polkadot_xcm.rs b/runtime/darwinia/src/pallets/polkadot_xcm.rs index b0b688a4b..eecb3de13 100644 --- a/runtime/darwinia/src/pallets/polkadot_xcm.rs +++ b/runtime/darwinia/src/pallets/polkadot_xcm.rs @@ -96,8 +96,6 @@ pub type Barrier = darwinia_common_runtime::xcm_configs::DenyThenTry< >, // Expected responses are OK. xcm_builder::AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - xcm_builder::AllowSubscriptionsFrom, ), >; @@ -128,6 +126,38 @@ impl xcm_builder::TakeRevenue for ToTreasury { } } +pub type XcmWeigher = xcm_builder::FixedWeightBounds; + +pub struct DarwiniaCall; +impl xcm_executor::traits::CallDispatcher for DarwiniaCall { + fn dispatch( + call: RuntimeCall, + origin: RuntimeOrigin, + ) -> Result< + sp_runtime::traits::PostDispatchInfoOf, + sp_runtime::DispatchErrorWithPostInfo>, + > { + if let Ok(raw_origin) = + TryInto::>::try_into(origin.clone().caller) + { + match (call.clone(), raw_origin) { + ( + RuntimeCall::EthereumXcm(pallet_ethereum_xcm::Call::transact { .. }), + frame_system::RawOrigin::Signed(account_id), + ) => { + return RuntimeCall::dispatch( + call, + pallet_ethereum_xcm::Origin::XcmEthereumTransaction(account_id.into()) + .into(), + ); + }, + _ => {}, + } + } + RuntimeCall::dispatch(call, origin) + } +} + pub struct XcmExecutorConfig; impl xcm_executor::Config for XcmExecutorConfig { type AssetClaims = PolkadotXcm; @@ -137,7 +167,7 @@ impl xcm_executor::Config for XcmExecutorConfig { type AssetTransactor = LocalAssetTransactor; type AssetTrap = PolkadotXcm; type Barrier = Barrier; - type CallDispatcher = RuntimeCall; + type CallDispatcher = DarwiniaCall; type FeeManager = (); type IsReserve = xcm_builder::NativeAsset; type IsTeleporter = (); @@ -163,7 +193,7 @@ impl xcm_executor::Config for XcmExecutorConfig { type UniversalAliases = frame_support::traits::Nothing; // Teleporting is disabled. type UniversalLocation = UniversalLocation; - type Weigher = xcm_builder::FixedWeightBounds; + type Weigher = XcmWeigher; type XcmSender = XcmRouter; } @@ -200,7 +230,7 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = LocationToAccountId; type TrustedLockers = (); type UniversalLocation = UniversalLocation; - type Weigher = xcm_builder::FixedWeightBounds; + type Weigher = XcmWeigher; type WeightInfo = pallet_xcm::TestWeightInfo; type XcmExecuteFilter = frame_support::traits::Everything; type XcmExecutor = xcm_executor::XcmExecutor; diff --git a/runtime/pangolin/Cargo.toml b/runtime/pangolin/Cargo.toml index ac1ed7144..c9394bcf7 100644 --- a/runtime/pangolin/Cargo.toml +++ b/runtime/pangolin/Cargo.toml @@ -70,8 +70,9 @@ pallet-evm-precompile-modexp = { workspace = true } pallet-evm-precompile-simple = { workspace = true } # moonbeam -precompile-utils = { workspace = true } -xcm-primitives = { workspace = true } +pallet-ethereum-xcm = { workspace = true } +precompile-utils = { workspace = true } +xcm-primitives = { workspace = true } # polkadot pallet-xcm = { workspace = true } @@ -190,6 +191,7 @@ std = [ "pallet-evm-precompile-simple/std", # moonbeam + "pallet-ethereum-xcm/std", "precompile-utils/std", "xcm-primitives/std", @@ -284,6 +286,7 @@ runtime-benchmarks = [ "pallet-evm/runtime-benchmarks", # moonbeam + "pallet-ethereum-xcm/runtime-benchmarks", "xcm-primitives/runtime-benchmarks", # polkadot @@ -341,6 +344,9 @@ try-runtime = [ "pallet-bridge-parachains/try-runtime", "pallet-fee-market/try-runtime", + # moonbeam + "pallet-ethereum-xcm/try-runtime", + # frontier "fp-self-contained/try-runtime", "pallet-ethereum/try-runtime", diff --git a/runtime/pangolin/src/lib.rs b/runtime/pangolin/src/lib.rs index cea6087a4..3195cc9bd 100644 --- a/runtime/pangolin/src/lib.rs +++ b/runtime/pangolin/src/lib.rs @@ -153,6 +153,7 @@ frame_support::construct_runtime! { XcmpQueue: cumulus_pallet_xcmp_queue = 32, PolkadotXcm: pallet_xcm = 33, CumulusXcm: cumulus_pallet_xcm = 34, + EthereumXcm: pallet_ethereum_xcm = 44, DmpQueue: cumulus_pallet_dmp_queue = 35, // EVM stuff. diff --git a/runtime/pangolin/src/pallets.rs b/runtime/pangolin/src/pallets.rs index 0509cd0d2..48b527a42 100644 --- a/runtime/pangolin/src/pallets.rs +++ b/runtime/pangolin/src/pallets.rs @@ -100,6 +100,8 @@ mod xcmp_queue; mod polkadot_xcm; pub use polkadot_xcm::*; +mod ethereum_xcm; + mod dmp_queue; // EVM stuff. diff --git a/runtime/pangolin/src/pallets/ethereum.rs b/runtime/pangolin/src/pallets/ethereum.rs index 8d53d1276..cb4da4755 100644 --- a/runtime/pangolin/src/pallets/ethereum.rs +++ b/runtime/pangolin/src/pallets/ethereum.rs @@ -19,7 +19,12 @@ // darwinia use crate::*; +frame_support::parameter_types! { + pub const PostBlockAndTxnHashes: pallet_ethereum::PostLogContent = pallet_ethereum::PostLogContent::BlockAndTxnHashes; +} + impl pallet_ethereum::Config for Runtime { + type PostLogContent = PostBlockAndTxnHashes; type RuntimeEvent = RuntimeEvent; type StateRoot = pallet_ethereum::IntermediateStateRoot; } diff --git a/runtime/pangolin/src/pallets/ethereum_xcm.rs b/runtime/pangolin/src/pallets/ethereum_xcm.rs new file mode 100644 index 000000000..9bf6e4bf7 --- /dev/null +++ b/runtime/pangolin/src/pallets/ethereum_xcm.rs @@ -0,0 +1,37 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Darwinia is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Darwinia. If not, see . + +// darwinia +use crate::*; + +pub struct EthereumXcmEnsureProxy; +impl xcm_primitives::EnsureProxy for EthereumXcmEnsureProxy { + fn ensure_ok(_delegator: AccountId, _delegatee: AccountId) -> Result<(), &'static str> { + Err("Denied") + } +} + +impl pallet_ethereum_xcm::Config for Runtime { + type ControllerOrigin = frame_system::EnsureRoot; + type EnsureProxy = EthereumXcmEnsureProxy; + type InvalidEvmTransactionError = pallet_ethereum::InvalidTransactionWrapper; + type ReservedXcmpWeight = + ::ReservedXcmpWeight; + type ValidatedTransaction = pallet_ethereum::ValidatedTransaction; + type XcmEthereumOrigin = pallet_ethereum_xcm::EnsureXcmEthereumTransaction; +} diff --git a/runtime/pangolin/src/pallets/polkadot_xcm.rs b/runtime/pangolin/src/pallets/polkadot_xcm.rs index b95d6c7d9..6e64f27ee 100644 --- a/runtime/pangolin/src/pallets/polkadot_xcm.rs +++ b/runtime/pangolin/src/pallets/polkadot_xcm.rs @@ -96,8 +96,6 @@ pub type Barrier = darwinia_common_runtime::xcm_configs::DenyThenTry< >, // Expected responses are OK. xcm_builder::AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - xcm_builder::AllowSubscriptionsFrom, ), >; @@ -128,6 +126,38 @@ impl xcm_builder::TakeRevenue for ToTreasury { } } +pub type XcmWeigher = xcm_builder::FixedWeightBounds; + +pub struct DarwiniaCall; +impl xcm_executor::traits::CallDispatcher for DarwiniaCall { + fn dispatch( + call: RuntimeCall, + origin: RuntimeOrigin, + ) -> Result< + sp_runtime::traits::PostDispatchInfoOf, + sp_runtime::DispatchErrorWithPostInfo>, + > { + if let Ok(raw_origin) = + TryInto::>::try_into(origin.clone().caller) + { + match (call.clone(), raw_origin) { + ( + RuntimeCall::EthereumXcm(pallet_ethereum_xcm::Call::transact { .. }), + frame_system::RawOrigin::Signed(account_id), + ) => { + return RuntimeCall::dispatch( + call, + pallet_ethereum_xcm::Origin::XcmEthereumTransaction(account_id.into()) + .into(), + ); + }, + _ => {}, + } + } + RuntimeCall::dispatch(call, origin) + } +} + pub struct XcmExecutorConfig; impl xcm_executor::Config for XcmExecutorConfig { type AssetClaims = PolkadotXcm; @@ -137,7 +167,7 @@ impl xcm_executor::Config for XcmExecutorConfig { type AssetTransactor = LocalAssetTransactor; type AssetTrap = PolkadotXcm; type Barrier = Barrier; - type CallDispatcher = RuntimeCall; + type CallDispatcher = DarwiniaCall; type FeeManager = (); type IsReserve = xcm_builder::NativeAsset; type IsTeleporter = (); @@ -163,7 +193,7 @@ impl xcm_executor::Config for XcmExecutorConfig { type UniversalAliases = frame_support::traits::Nothing; // Teleporting is disabled. type UniversalLocation = UniversalLocation; - type Weigher = xcm_builder::FixedWeightBounds; + type Weigher = XcmWeigher; type XcmSender = XcmRouter; } @@ -200,7 +230,7 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = LocationToAccountId; type TrustedLockers = (); type UniversalLocation = UniversalLocation; - type Weigher = xcm_builder::FixedWeightBounds; + type Weigher = XcmWeigher; type WeightInfo = pallet_xcm::TestWeightInfo; type XcmExecuteFilter = frame_support::traits::Everything; type XcmExecutor = xcm_executor::XcmExecutor; diff --git a/runtime/pangoro/Cargo.toml b/runtime/pangoro/Cargo.toml index 017af21f7..794bec340 100644 --- a/runtime/pangoro/Cargo.toml +++ b/runtime/pangoro/Cargo.toml @@ -70,8 +70,9 @@ pallet-evm-precompile-modexp = { workspace = true } pallet-evm-precompile-simple = { workspace = true } # moonbeam -precompile-utils = { workspace = true } -xcm-primitives = { workspace = true } +pallet-ethereum-xcm = { workspace = true } +precompile-utils = { workspace = true } +xcm-primitives = { workspace = true } # polkadot pallet-xcm = { workspace = true } @@ -190,6 +191,7 @@ std = [ "pallet-evm-precompile-simple/std", # moonbeam + "pallet-ethereum-xcm/std", "precompile-utils/std", "xcm-primitives/std", @@ -285,6 +287,7 @@ runtime-benchmarks = [ "pallet-evm/runtime-benchmarks", # moonbeam + "pallet-ethereum-xcm/runtime-benchmarks", "xcm-primitives/runtime-benchmarks", # polkadot @@ -342,6 +345,9 @@ try-runtime = [ "pallet-bridge-parachains/try-runtime", "pallet-fee-market/try-runtime", + # moonbeam + "pallet-ethereum-xcm/try-runtime", + # frontier "fp-self-contained/try-runtime", "pallet-ethereum/try-runtime", diff --git a/runtime/pangoro/src/lib.rs b/runtime/pangoro/src/lib.rs index abccc1b28..e393e8596 100644 --- a/runtime/pangoro/src/lib.rs +++ b/runtime/pangoro/src/lib.rs @@ -153,6 +153,7 @@ frame_support::construct_runtime! { XcmpQueue: cumulus_pallet_xcmp_queue = 32, PolkadotXcm: pallet_xcm = 33, CumulusXcm: cumulus_pallet_xcm = 34, + EthereumXcm: pallet_ethereum_xcm = 44, DmpQueue: cumulus_pallet_dmp_queue = 35, // EVM stuff. diff --git a/runtime/pangoro/src/pallets.rs b/runtime/pangoro/src/pallets.rs index 0509cd0d2..48b527a42 100644 --- a/runtime/pangoro/src/pallets.rs +++ b/runtime/pangoro/src/pallets.rs @@ -100,6 +100,8 @@ mod xcmp_queue; mod polkadot_xcm; pub use polkadot_xcm::*; +mod ethereum_xcm; + mod dmp_queue; // EVM stuff. diff --git a/runtime/pangoro/src/pallets/ethereum.rs b/runtime/pangoro/src/pallets/ethereum.rs index 8d53d1276..cb4da4755 100644 --- a/runtime/pangoro/src/pallets/ethereum.rs +++ b/runtime/pangoro/src/pallets/ethereum.rs @@ -19,7 +19,12 @@ // darwinia use crate::*; +frame_support::parameter_types! { + pub const PostBlockAndTxnHashes: pallet_ethereum::PostLogContent = pallet_ethereum::PostLogContent::BlockAndTxnHashes; +} + impl pallet_ethereum::Config for Runtime { + type PostLogContent = PostBlockAndTxnHashes; type RuntimeEvent = RuntimeEvent; type StateRoot = pallet_ethereum::IntermediateStateRoot; } diff --git a/runtime/pangoro/src/pallets/ethereum_xcm.rs b/runtime/pangoro/src/pallets/ethereum_xcm.rs new file mode 100644 index 000000000..9bf6e4bf7 --- /dev/null +++ b/runtime/pangoro/src/pallets/ethereum_xcm.rs @@ -0,0 +1,37 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Darwinia is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Darwinia. If not, see . + +// darwinia +use crate::*; + +pub struct EthereumXcmEnsureProxy; +impl xcm_primitives::EnsureProxy for EthereumXcmEnsureProxy { + fn ensure_ok(_delegator: AccountId, _delegatee: AccountId) -> Result<(), &'static str> { + Err("Denied") + } +} + +impl pallet_ethereum_xcm::Config for Runtime { + type ControllerOrigin = frame_system::EnsureRoot; + type EnsureProxy = EthereumXcmEnsureProxy; + type InvalidEvmTransactionError = pallet_ethereum::InvalidTransactionWrapper; + type ReservedXcmpWeight = + ::ReservedXcmpWeight; + type ValidatedTransaction = pallet_ethereum::ValidatedTransaction; + type XcmEthereumOrigin = pallet_ethereum_xcm::EnsureXcmEthereumTransaction; +} diff --git a/runtime/pangoro/src/pallets/polkadot_xcm.rs b/runtime/pangoro/src/pallets/polkadot_xcm.rs index 4287ad252..72d89a05e 100644 --- a/runtime/pangoro/src/pallets/polkadot_xcm.rs +++ b/runtime/pangoro/src/pallets/polkadot_xcm.rs @@ -96,8 +96,6 @@ pub type Barrier = darwinia_common_runtime::xcm_configs::DenyThenTry< >, // Expected responses are OK. xcm_builder::AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - xcm_builder::AllowSubscriptionsFrom, ), >; @@ -128,6 +126,38 @@ impl xcm_builder::TakeRevenue for ToTreasury { } } +pub type XcmWeigher = xcm_builder::FixedWeightBounds; + +pub struct DarwiniaCall; +impl xcm_executor::traits::CallDispatcher for DarwiniaCall { + fn dispatch( + call: RuntimeCall, + origin: RuntimeOrigin, + ) -> Result< + sp_runtime::traits::PostDispatchInfoOf, + sp_runtime::DispatchErrorWithPostInfo>, + > { + if let Ok(raw_origin) = + TryInto::>::try_into(origin.clone().caller) + { + match (call.clone(), raw_origin) { + ( + RuntimeCall::EthereumXcm(pallet_ethereum_xcm::Call::transact { .. }), + frame_system::RawOrigin::Signed(account_id), + ) => { + return RuntimeCall::dispatch( + call, + pallet_ethereum_xcm::Origin::XcmEthereumTransaction(account_id.into()) + .into(), + ); + }, + _ => {}, + } + } + RuntimeCall::dispatch(call, origin) + } +} + pub struct XcmExecutorConfig; impl xcm_executor::Config for XcmExecutorConfig { type AssetClaims = PolkadotXcm; @@ -137,7 +167,7 @@ impl xcm_executor::Config for XcmExecutorConfig { type AssetTransactor = LocalAssetTransactor; type AssetTrap = PolkadotXcm; type Barrier = Barrier; - type CallDispatcher = RuntimeCall; + type CallDispatcher = DarwiniaCall; type FeeManager = (); type IsReserve = xcm_builder::NativeAsset; type IsTeleporter = (); @@ -163,7 +193,7 @@ impl xcm_executor::Config for XcmExecutorConfig { type UniversalAliases = frame_support::traits::Nothing; // Teleporting is disabled. type UniversalLocation = UniversalLocation; - type Weigher = xcm_builder::FixedWeightBounds; + type Weigher = XcmWeigher; type XcmSender = XcmRouter; } @@ -200,7 +230,7 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = LocationToAccountId; type TrustedLockers = (); type UniversalLocation = UniversalLocation; - type Weigher = xcm_builder::FixedWeightBounds; + type Weigher = XcmWeigher; type WeightInfo = pallet_xcm::TestWeightInfo; type XcmExecuteFilter = frame_support::traits::Everything; type XcmExecutor = xcm_executor::XcmExecutor;