Skip to content

Commit 37ff779

Browse files
authored
Updated EVM Bridge channel (#80)
* Update types for EVM bridge * Updated bridge channel * Fix warnings * Fix warnings * Fix warnings * Fix clippy * Remove Native asset kind * Refactoring
1 parent 87eadea commit 37ff779

File tree

11 files changed

+2367
-0
lines changed

11 files changed

+2367
-0
lines changed

Cargo.lock

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pallets/channel/Cargo.toml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[package]
2+
name = "bridge-channel"
3+
description = "Bridge Channel"
4+
version = "0.1.1"
5+
edition = "2021"
6+
authors = ['Polka Biome Ltd. <[email protected]>']
7+
repository = "https://github.com/sora-xor/sora2-common"
8+
9+
[package.metadata.docs.rs]
10+
targets = ["x86_64-unknown-linux-gnu"]
11+
12+
[dependencies]
13+
serde = { version = "1.0.101", optional = true }
14+
codec = { version = "3", package = "parity-scale-codec", default-features = false, features = [
15+
"derive",
16+
] }
17+
scale-info = { version = "2", default-features = false, features = ["derive"] }
18+
hex-literal = { version = "0.4.1", optional = true }
19+
rlp = { version = "0.5", default-features = false, optional = true }
20+
21+
frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38", default-features = false, optional = true }
22+
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38", default-features = false }
23+
frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38", default-features = false }
24+
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38", default-features = false }
25+
sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38", default-features = false }
26+
sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38", default-features = false }
27+
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38", default-features = false }
28+
pallet-timestamp = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38", default-features = false }
29+
30+
bridge-types = { path = "../types", default-features = false }
31+
ethabi = { git = "https://github.com/sora-xor/ethabi.git", branch = "sora-v1.6.0", default-features = false }
32+
once_cell = { version = "1.5.2", default-features = false, features = [
33+
'alloc',
34+
'unstable',
35+
] }
36+
37+
[dev-dependencies]
38+
pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38" }
39+
tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.38", package = "orml-tokens" }
40+
traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.38", package = "orml-traits" }
41+
currencies = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.38", package = "orml-currencies" }
42+
sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38" }
43+
rlp = { version = "0.5" }
44+
45+
[features]
46+
default = ["std"]
47+
std = [
48+
"serde",
49+
"codec/std",
50+
"scale-info/std",
51+
"frame-support/std",
52+
"frame-system/std",
53+
"sp-core/std",
54+
"sp-runtime/std",
55+
"sp-std/std",
56+
"sp-io/std",
57+
"bridge-types/std",
58+
"ethabi/std",
59+
]
60+
runtime-benchmarks = [
61+
"bridge-types/runtime-benchmarks",
62+
"frame-benchmarking",
63+
"frame-support/runtime-benchmarks",
64+
"frame-system/runtime-benchmarks",
65+
"hex-literal",
66+
"rlp",
67+
]
68+
69+
try-runtime = ["frame-support/try-runtime"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// This file is part of the SORA network and Polkaswap app.
2+
3+
// Copyright (c) 2020, 2021, Polka Biome Ltd. All rights reserved.
4+
// SPDX-License-Identifier: BSD-4-Clause
5+
6+
// Redistribution and use in source and binary forms, with or without modification,
7+
// are permitted provided that the following conditions are met:
8+
9+
// Redistributions of source code must retain the above copyright notice, this list
10+
// of conditions and the following disclaimer.
11+
// Redistributions in binary form must reproduce the above copyright notice, this
12+
// list of conditions and the following disclaimer in the documentation and/or other
13+
// materials provided with the distribution.
14+
//
15+
// All advertising materials mentioning features or use of this software must display
16+
// the following acknowledgement: This product includes software developed by Polka Biome
17+
// Ltd., SORA, and Polkaswap.
18+
//
19+
// Neither the name of the Polka Biome Ltd. nor the names of its contributors may be used
20+
// to endorse or promote products derived from this software without specific prior written permission.
21+
22+
// THIS SOFTWARE IS PROVIDED BY Polka Biome Ltd. AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES,
23+
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Polka Biome Ltd. BE LIABLE FOR ANY
25+
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26+
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27+
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28+
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
29+
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
//! BridgeInboundChannel pallet benchmarking
32+
33+
use super::*;
34+
use bridge_types::GenericNetworkId;
35+
use frame_benchmarking::{benchmarks, impl_benchmark_test_suite};
36+
use frame_system::{self, RawOrigin};
37+
use sp_std::prelude::*;
38+
39+
const BASE_NETWORK_ID: GenericNetworkId = GenericNetworkId::Sub(SubNetworkId::Mainnet);
40+
41+
#[allow(unused_imports)]
42+
use crate::inbound::Pallet as BridgeInboundChannel;
43+
44+
// This collection of benchmarks should include a benchmark for each
45+
// call dispatched by the channel, i.e. each "app" pallet function
46+
// that can be invoked by MessageDispatch. The most expensive call
47+
// should be used in the `submit` benchmark.
48+
//
49+
// We rely on configuration via chain spec of the app pallets because
50+
// we don't have access to their storage here.
51+
benchmarks! {
52+
// Benchmark `submit` extrinsic under worst case conditions:
53+
// * `submit` dispatches the DotApp::unlock call
54+
// * `unlock` call successfully unlocks DOT
55+
submit {
56+
let messages = vec![];
57+
let commitment = bridge_types::GenericCommitment::Sub(
58+
bridge_types::substrate::Commitment {
59+
messages: messages.try_into().unwrap(),
60+
nonce: 1u64,
61+
}
62+
);
63+
let proof = T::Verifier::valid_proof().unwrap();
64+
}: _(RawOrigin::None, BASE_NETWORK_ID, commitment, proof)
65+
verify {
66+
assert_eq!(1, <ChannelNonces<T>>::get(BASE_NETWORK_ID));
67+
}
68+
}
69+
70+
impl_benchmark_test_suite!(
71+
BridgeInboundChannel,
72+
crate::inbound::test::new_tester(),
73+
crate::inbound::test::Test,
74+
);

0 commit comments

Comments
 (0)