Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Add evochain light client #108

Merged
37 commits merged into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
78752e5
Only client side compile errors
dastanbeksamatov Aug 3, 2023
1a5189c
Upgrade to v1.0.0
dastanbeksamatov Aug 4, 2023
d16b040
Add grandpa bridge to runtime
dastanbeksamatov Aug 4, 2023
e43fdac
Fix clippy and tests
dastanbeksamatov Aug 4, 2023
3414679
Merge branch 'dev' of github-freeverse:freeverseio/laos-ownership-nod…
dastanbeksamatov Aug 4, 2023
ef4e8ae
Merge branch 'dev' into feat/grandpa-bridge
Aug 4, 2023
00262c9
Fix lints
dastanbeksamatov Aug 4, 2023
ade7089
Merge branch 'feat/grandpa-bridge' of github-freeverse:freeverseio/la…
dastanbeksamatov Aug 4, 2023
e02fff8
Fix tests and clippy
dastanbeksamatov Aug 4, 2023
b0bb716
Remove comment
dastanbeksamatov Aug 4, 2023
cc97592
Add ownership chain relayer part
dastanbeksamatov Aug 4, 2023
72b663d
Merge branch 'dev' of github-freeverse:freeverseio/laos-ownership-nod…
dastanbeksamatov Aug 4, 2023
c73309b
Fix tests
dastanbeksamatov Aug 4, 2023
c154b1e
Remove 0x from hex
dastanbeksamatov Aug 4, 2023
1852460
Add bridge relayer
dastanbeksamatov Aug 15, 2023
436593c
Update branch commits
dastanbeksamatov Aug 17, 2023
b69e233
Working state
dastanbeksamatov Aug 22, 2023
8201b0a
Add laos relay
dastanbeksamatov Aug 22, 2023
147051e
Remove unused deps
dastanbeksamatov Aug 22, 2023
9b9b661
Fix lints and prepare for PR
dastanbeksamatov Aug 22, 2023
9926e23
Fix clippy
dastanbeksamatov Aug 22, 2023
1da04d9
Merge branch 'dev' of github-freeverse:freeverseio/laos-ownership-nod…
dastanbeksamatov Aug 22, 2023
68dd5a1
Generate new lock file
dastanbeksamatov Aug 22, 2023
184d0f4
Evochain different branch
dastanbeksamatov Aug 24, 2023
dead57c
Add documentation
dastanbeksamatov Aug 24, 2023
0775b4b
Remove millau related code
dastanbeksamatov Aug 24, 2023
c28b64a
Improve documentation
dastanbeksamatov Aug 24, 2023
a88adf6
Fix lint
dastanbeksamatov Aug 24, 2023
7bad16d
Remove bridge relayer
dastanbeksamatov Aug 25, 2023
e911754
Merge branch 'dev' of github-freeverse:freeverseio/laos-ownership-nod…
dastanbeksamatov Aug 25, 2023
f22143b
Use workspace deps
dastanbeksamatov Aug 25, 2023
0522701
Change crate authors
dastanbeksamatov Aug 25, 2023
4bb12b3
Revert gitignore
dastanbeksamatov Aug 28, 2023
5f60293
Update parity bridges common branch
dastanbeksamatov Aug 29, 2023
3b11c46
Update crate name
dastanbeksamatov Aug 29, 2023
56a4bd8
removed wrong comment
asiniscalchi Aug 29, 2023
147485e
fmt
asiniscalchi Aug 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ similar-asserts = { version = "1.1.0" }
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "1.0" }
static_assertions = "1.1"

# Wasm builder
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
Expand Down
5 changes: 1 addition & 4 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,6 @@ fn testnet_genesis(
},
..Default::default()
},
ethereum: Default::default(),
// dynamic_fee: Default::default(),
base_fee: Default::default(),
bridge_evochain_grandpa: Default::default(),
..Default::default()
}
}
5 changes: 5 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ pallet-bridge-grandpa = { workspace = true }
pallet-bridge-messages = { workspace = true }
pallet-bridge-relayers = { workspace = true }

[dev-dependencies]
bridge-runtime-common = { workspace = true, features = ["integrity-test"] }
static_assertions = { workspace = true }
hex-literal = { workspace = true }

[features]
default = [
"std",
Expand Down
124 changes: 124 additions & 0 deletions runtime/src/evochain_messages.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.

// Parity Bridges Common 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.

// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

//! Everything required to serve Evochain <-> OwnershipParachain messages.

// TODO: this is almost exact copy of `evochain_messages.rs` from Rococo runtime.
// Should be extracted to a separate crate and reused here.

use crate::{Runtime, WithEvochainMessagesInstance};

use bp_messages::LaneId;
use bridge_runtime_common::messages_xcm_extension::{
LaneIdFromChainId, XcmBlobHauler, XcmBlobHaulerAdapter,
};
use frame_support::{parameter_types, weights::Weight};
use sp_core::Get;
use xcm_builder::HaulBlobExporter;

parameter_types! {
/// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge
/// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual
/// tests, confirming that we don't break encoding somewhere between.
///
/// Weight credit for our test messages.
///
/// 2 XCM instructions is for simple `Trap(42)` program, coming through bridge
/// (it is prepended with `UniversalOrigin` instruction).
pub WeightCredit: Weight = crate::UnitWeightCost::get().saturating_mul(2);
}

/// Call-dispatch based message dispatch for Evochain -> OwnershipParachain messages.
pub type FromEvochainMessageDispatch =
bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatch<
crate::OnOwnershipParachainBlobDispatcher,
(),
>;

/// Export XCM messages to be relayed to Evochain.
pub type ToEvochainBlobExporter =
HaulBlobExporter<XcmBlobHaulerAdapter<ToEvochainXcmBlobHauler>, crate::EvochainNetwork, ()>;

/// To-Evochain XCM hauler.
pub struct ToEvochainXcmBlobHauler;

impl XcmBlobHauler for ToEvochainXcmBlobHauler {
type MessageSender = pallet_bridge_messages::Pallet<Runtime, WithEvochainMessagesInstance>;

fn xcm_lane() -> LaneId {
LaneIdFromChainId::<Runtime, WithEvochainMessagesInstance>::get()
}
}

#[cfg(test)]
mod tests {
use super::*;
use crate::{EvochainGrandpaInstance, Runtime, WithEvochainMessagesInstance};
use bridge_runtime_common::{
assert_complete_bridge_types,
integrity::{
assert_complete_with_relay_chain_bridge_constants, check_message_lane_weights,
AssertChainConstants, AssertCompleteBridgeConstants,
},
};

#[test]
fn ensure_evochain_message_lane_weights_are_correct() {
check_message_lane_weights::<
bp_ownership_parachain::OwnershipParachain,
Runtime,
WithEvochainMessagesInstance,
>(
bp_evochain::EXTRA_STORAGE_PROOF_SIZE,
bp_ownership_parachain::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
bp_ownership_parachain::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
false,
);
}

#[test]
fn ensure_bridge_integrity() {
assert_complete_bridge_types!(
runtime: Runtime,
with_bridged_chain_grandpa_instance: EvochainGrandpaInstance,
with_bridged_chain_messages_instance: WithEvochainMessagesInstance,
this_chain: bp_ownership_parachain::OwnershipParachain,
bridged_chain: bp_evochain::Evochain,
);

assert_complete_with_relay_chain_bridge_constants::<
Runtime,
EvochainGrandpaInstance,
WithEvochainMessagesInstance,
>(AssertCompleteBridgeConstants {
this_chain_constants: AssertChainConstants {
block_length: bp_ownership_parachain::BlockLength::get(),
block_weights: bp_ownership_parachain::BlockWeights::get(),
},
});
}

#[test]
fn ownership_parachain_evochain_bridge_identifier_did_not_changed() {
// there's nothing criminal if it is changed, but then thou need to fix it across
// all deployments scripts, alerts and so on
assert_eq!(
*ToEvochainXcmBlobHauler::xcm_lane().as_ref(),
hex_literal::hex!("8c3ce4218626cc27fdf49e1791a20e8a0970b89f1465a38e8f8787552ddc3a50")
.into(),
);
}
}
Loading