diff --git a/Cargo.lock b/Cargo.lock index 8c81bccf3..d4214b41f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,6 +12,27 @@ dependencies = [ "regex", ] +[[package]] +name = "account" +version = "0.1.1" +source = "git+https://github.com/darwinia-network/moonbeam?branch=polkadot-v0.9.30#9d31c6120bb0f317053da9cac7fe7cd2a44f844c" +dependencies = [ + "blake2-rfc", + "hex", + "impl-serde", + "libsecp256k1 0.6.0", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sha3 0.9.1", + "sp-core", + "sp-io", + "sp-runtime", + "sp-runtime-interface", + "sp-std", +] + [[package]] name = "addr2line" version = "0.17.0" @@ -163,6 +184,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" + [[package]] name = "base64" version = "0.13.0" @@ -202,13 +229,23 @@ dependencies = [ "digest 0.10.5", ] +[[package]] +name = "blake2-rfc" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" +dependencies = [ + "arrayvec 0.4.12", + "constant_time_eq", +] + [[package]] name = "block-buffer" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ - "block-padding", + "block-padding 0.1.5", "byte-tools", "byteorder", "generic-array 0.12.4", @@ -220,6 +257,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ + "block-padding 0.2.1", "generic-array 0.14.6", ] @@ -241,10 +279,17 @@ dependencies = [ "byte-tools", ] +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + [[package]] name = "bp-darwinia-core" version = "0.1.0" dependencies = [ + "account", "bp-messages", "bp-runtime", "frame-support", @@ -472,6 +517,12 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + [[package]] name = "core-foundation-sys" version = "0.8.3" @@ -1272,6 +1323,25 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "292a948cd991e376cf75541fe5b97a1081d713c618b4f1b9500f8844e49eb565" +[[package]] +name = "libsecp256k1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9d220bc1feda2ac231cb78c3d26f27676b8cf82c96971f7aeef3d0cf2797c73" +dependencies = [ + "arrayref", + "base64 0.12.3", + "digest 0.9.0", + "hmac-drbg", + "libsecp256k1-core 0.2.2", + "libsecp256k1-gen-ecmult 0.2.1", + "libsecp256k1-gen-genmult 0.2.1", + "rand 0.7.3", + "serde", + "sha2 0.9.9", + "typenum", +] + [[package]] name = "libsecp256k1" version = "0.7.1" @@ -1279,18 +1349,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" dependencies = [ "arrayref", - "base64", + "base64 0.13.0", "digest 0.9.0", "hmac-drbg", - "libsecp256k1-core", - "libsecp256k1-gen-ecmult", - "libsecp256k1-gen-genmult", + "libsecp256k1-core 0.3.0", + "libsecp256k1-gen-ecmult 0.3.0", + "libsecp256k1-gen-genmult 0.3.0", "rand 0.8.5", "serde", "sha2 0.9.9", "typenum", ] +[[package]] +name = "libsecp256k1-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0f6ab710cec28cef759c5f18671a27dae2a5f952cdaaee1d8e2908cb2478a80" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + [[package]] name = "libsecp256k1-core" version = "0.3.0" @@ -1302,13 +1383,31 @@ dependencies = [ "subtle", ] +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccab96b584d38fac86a83f07e659f0deafd0253dc096dab5a36d53efe653c5c3" +dependencies = [ + "libsecp256k1-core 0.2.2", +] + [[package]] name = "libsecp256k1-gen-ecmult" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" dependencies = [ - "libsecp256k1-core", + "libsecp256k1-core 0.3.0", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67abfe149395e3aa1c48a2beb32b068e2334402df8181f818d3aee2b304c4f5d" +dependencies = [ + "libsecp256k1-core 0.2.2", ] [[package]] @@ -1317,7 +1416,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" dependencies = [ - "libsecp256k1-core", + "libsecp256k1-core 0.3.0", ] [[package]] @@ -2256,6 +2355,18 @@ dependencies = [ "digest 0.10.5", ] +[[package]] +name = "sha3" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" +dependencies = [ + "block-buffer 0.9.0", + "digest 0.9.0", + "keccak", + "opaque-debug 0.3.0", +] + [[package]] name = "sha3" version = "0.10.5" @@ -2387,7 +2498,7 @@ dependencies = [ "hash256-std-hasher", "impl-serde", "lazy_static", - "libsecp256k1", + "libsecp256k1 0.7.1", "log", "merlin", "num-traits", @@ -2425,7 +2536,7 @@ dependencies = [ "byteorder", "digest 0.10.5", "sha2 0.10.6", - "sha3", + "sha3 0.10.5", "sp-std", "twox-hash", ] @@ -2502,7 +2613,7 @@ dependencies = [ "bytes", "futures", "hash-db", - "libsecp256k1", + "libsecp256k1 0.7.1", "log", "parity-scale-codec", "parking_lot", diff --git a/modules/dispatch/src/lib.rs b/modules/dispatch/src/lib.rs index 1621f3590..aed33e801 100644 --- a/modules/dispatch/src/lib.rs +++ b/modules/dispatch/src/lib.rs @@ -933,6 +933,7 @@ mod tests { prepare_root_message(RuntimeCall::System(frame_system::Call::remark { remark: vec![1, 2, 3], })); + let weight = message.weight; message.dispatch_fee_payment = DispatchFeePayment::AtTargetChain; diff --git a/primitives/darwinia-core/Cargo.toml b/primitives/darwinia-core/Cargo.toml index 3085b94ec..3e30370a6 100644 --- a/primitives/darwinia-core/Cargo.toml +++ b/primitives/darwinia-core/Cargo.toml @@ -10,6 +10,8 @@ version = "0.1.0" # crates.io parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] } scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } +# moonbeam +account = { default-features = false, git = "https://github.com/darwinia-network/moonbeam", branch = "polkadot-v0.9.30" } # paritytech bp-messages = { default-features = false, path = "../messages" } bp-runtime = { default-features = false, path = "../runtime" } @@ -25,6 +27,8 @@ std = [ # crates.io "parity-scale-codec/std", "scale-info/std", + # moonbeam + "account/std", # paritytech "bp-messages/std", "bp-runtime/std", diff --git a/primitives/darwinia-core/src/lib.rs b/primitives/darwinia-core/src/lib.rs index 1c2fcd34e..7f27998de 100644 --- a/primitives/darwinia-core/src/lib.rs +++ b/primitives/darwinia-core/src/lib.rs @@ -19,6 +19,8 @@ #![cfg_attr(not(feature = "std"), no_std)] mod copy_paste_from_darwinia { + // moonbeam + use account::EthereumSignature; // paritytech use frame_support::{ dispatch::DispatchClass, @@ -32,16 +34,16 @@ mod copy_paste_from_darwinia { use sp_runtime::{ generic, traits::{BlakeTwo256, IdentifyAccount, Verify}, - MultiAddress, MultiSignature, OpaqueExtrinsic, Perbill, + OpaqueExtrinsic, Perbill, }; pub type BlockNumber = u32; pub type Hashing = BlakeTwo256; pub type Hash = H256; - pub type Signature = MultiSignature; + pub type Signature = EthereumSignature; pub type AccountPublic = ::Signer; pub type AccountId = ::AccountId; - pub type Address = MultiAddress; + pub type Address = AccountId; pub type Nonce = u32; pub type Balance = u128; pub type Header = generic::Header; @@ -105,7 +107,7 @@ use frame_support::{ unsigned::{TransactionValidityError, UnknownTransaction}, weights::Weight, }; -use sp_core::H256; +use sp_core::{H160, H256}; use sp_runtime::{ generic, generic::Era, @@ -263,6 +265,7 @@ impl Chain for DarwiniaLike { pub struct AccountIdConverter; impl Convert for AccountIdConverter { fn convert(hash: H256) -> AccountId { - hash.to_fixed_bytes().into() + let evm_address: H160 = hash.into(); + evm_address.into() } } diff --git a/primitives/runtime/src/lib.rs b/primitives/runtime/src/lib.rs index 11ed5d8c8..f49ddd373 100644 --- a/primitives/runtime/src/lib.rs +++ b/primitives/runtime/src/lib.rs @@ -48,7 +48,7 @@ use frame_support::{ log, pallet_prelude::DispatchResult, PalletError, RuntimeDebug, StorageHasher, StorageValue, }; use frame_system::RawOrigin; -use sp_core::{hash::H256, storage::StorageKey}; +use sp_core::{storage::StorageKey, H256}; use sp_io::hashing::blake2_256; use sp_runtime::{ traits::{BadOrigin, Header as HeaderT},