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

Commit

Permalink
Add evochain light client (#108)
Browse files Browse the repository at this point in the history
* Only client side compile errors

* Upgrade to v1.0.0

* Add grandpa bridge to runtime

* Fix clippy and tests

* Fix lints

* Fix tests and clippy

* Remove comment

* Add ownership chain relayer part

* Fix tests

* Remove 0x from hex

* Add bridge relayer

* Update branch commits

* Working state

* Add laos relay

* Remove unused deps

* Fix lints and prepare for PR

* Fix clippy

* Generate new lock file

* Evochain different branch

* Add documentation

* Remove millau related code

* Improve documentation

* Fix lint

* Remove bridge relayer

* Use workspace deps

* Change crate authors

* Revert gitignore

* Update parity bridges common branch

* Update crate name

* removed wrong comment

* fmt

---------

Co-authored-by: Alessandro Siniscalchi <[email protected]>
  • Loading branch information
dastan and asiniscalchi authored Aug 29, 2023
1 parent f0284e4 commit 7a8bbec
Show file tree
Hide file tree
Showing 9 changed files with 677 additions and 615 deletions.
1,021 changes: 509 additions & 512 deletions Cargo.lock

Large diffs are not rendered by default.

23 changes: 11 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ members = [
"node",
"runtime",
"precompile/*",
"pallets/*"
"pallets/*",
"primitives",
]


[workspace.dependencies]
parity-scale-codec = { version = "3.2.2", default-features = false, features = ["derive"] }
hex-literal = "0.4.1"
Expand All @@ -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 Expand Up @@ -208,16 +209,11 @@ polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "relea
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v1.0.0" }

# Bridge dependencies
bp-header-chain = { git = "https://github.com/freeverseio/parity-bridges-common.git", branch = "polkadot-v1.0.0", default-features = false }
bp-messages = { git = "https://github.com/freeverseio/parity-bridges-common.git", branch = "polkadot-v1.0.0", default-features = false }
bp-evochain = { git = "https://github.com/freeverseio/parity-bridges-common.git", branch = "polkadot-v1.0.0", default-features = false }
bp-relayers = { git = "https://github.com/freeverseio/parity-bridges-common.git", branch = "polkadot-v1.0.0", default-features = false }
bp-runtime = { git = "https://github.com/freeverseio/parity-bridges-common.git", branch = "polkadot-v1.0.0", default-features = false }
bp-ownership-parachain = { git = "https://github.com/freeverseio/parity-bridges-common.git", branch = "polkadot-v1.0.0", default-features = false }
bridge-runtime-common = { git = "https://github.com/freeverseio/parity-bridges-common.git", branch = "polkadot-v1.0.0", default-features = false }
pallet-bridge-grandpa = { git = "https://github.com/freeverseio/parity-bridges-common.git", branch = "polkadot-v1.0.0", default-features = false }
pallet-bridge-messages = { git = "https://github.com/freeverseio/parity-bridges-common.git", branch = "polkadot-v1.0.0", default-features = false }
pallet-bridge-relayers = { git = "https://github.com/freeverseio/parity-bridges-common.git", branch = "polkadot-v1.0.0", default-features = false }
bp-laos-evolution = { git = "https://github.com/freeverseio/parity-bridges-common.git", branch = "laos-crates", default-features = false }
bp-header-chain = { git = "https://github.com/freeverseio/parity-bridges-common.git", branch = "laos-crates", default-features = false }
bp-runtime = { git = "https://github.com/freeverseio/parity-bridges-common.git", branch = "laos-crates", default-features = false }
bridge-runtime-common = { git = "https://github.com/freeverseio/parity-bridges-common.git", branch = "laos-crates", default-features = false }
pallet-bridge-grandpa = { git = "https://github.com/freeverseio/parity-bridges-common.git", branch = "laos-crates", default-features = false }

# LAOS pallets
pallet-living-assets-ownership = { path = "./pallets/living-assets-ownership", default-features = false }
Expand All @@ -228,5 +224,8 @@ pallet-evm-erc721 = { path = "./precompile/erc721", default-features = false }
precompile-utils = { path = "./precompile/utils", default-features = false }
precompile-utils-macro = { path = "./precompile/utils/macro", default-features = false }

# Primitives
ownership-parachain-primitives = { path = "./primitives", default-features = false }

# runtime
laos-runtime = { path = "./runtime" }
7 changes: 2 additions & 5 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ fn testnet_genesis(
.iter()
.map(|&address| {
(
address.into(),
address,
GenesisAccount {
nonce: Default::default(),
balance: Default::default(),
Expand Down Expand Up @@ -337,9 +337,6 @@ fn testnet_genesis(
},
..Default::default()
},
ethereum: Default::default(),
// dynamic_fee: Default::default(),
base_fee: Default::default(),
bridge_evochain_grandpa: Default::default(),
..Default::default()
}
}
2 changes: 1 addition & 1 deletion pallets/living-assets-ownership/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub mod pallet {
// concatenate base_uri with asset_id
let mut token_uri = base_uri.to_vec();
token_uri.push(b'/');
token_uri.extend_from_slice(&asset_id.to_string().as_bytes());
token_uri.extend_from_slice(asset_id.to_string().as_bytes());
Ok(token_uri)
}
}
Expand Down
23 changes: 23 additions & 0 deletions primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "ownership-parachain-primitives"
description = "Primitives of Ownership parachain runtime."
version = "0.1.0"
authors = ["Freeverse"]
edition = "2021"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"

[dependencies]
# Substrate Based Dependencies
frame-support = { workspace = true }
frame-system = { workspace = true }
sp-core = { workspace = true }
sp-runtime = { workspace = true }

[features]
default = ["std"]
std = [
"frame-support/std",
"frame-system/std",
"sp-core/std",
"sp-runtime/std",
]
66 changes: 66 additions & 0 deletions primitives/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//! Primitives of the Ownership parachain.

#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, IdentityFee, Weight};
use frame_system::limits;
use sp_core::Hasher as HasherT;
use sp_runtime::{
traits::{BlakeTwo256, IdentifyAccount, Verify},
MultiSignature, MultiSigner, Perbill,
};

/// Maximal weight of single OwnershipParachain block.
///
/// This represents two seconds of compute assuming a target block time of six seconds.
///
/// Max PoV size is set to `5Mb` as all Cumulus-based parachains do.
pub const MAXIMUM_BLOCK_WEIGHT: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), 5 * 1024 * 1024);

/// Represents the portion of a block that will be used by Normal extrinsics.
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);

/// Block number type used in Ownership chain.
pub type BlockNumber = u32;

/// Hash type used in Ownership chain.
pub type Hash = <BlakeTwo256 as HasherT>::Out;

/// The type of object that can produce hashes on Ownership chain.
pub type Hasher = BlakeTwo256;

/// The header type used by Ownership chain.
pub type Header = sp_runtime::generic::Header<BlockNumber, Hasher>;

/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
pub type Signature = MultiSignature;

/// Some way of identifying an account on the chain. We intentionally make it equivalent
/// to the public key of our transaction signing scheme.
pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;

/// Public key of the chain account that may be used to verify signatures.
pub type AccountSigner = MultiSigner;

/// Balance of an account.
pub type Balance = u128;

/// An instant or duration in time.
pub type Moment = u64;

/// Nonce of a transaction in the parachain.
pub type Nonce = u32;

/// Weight-to-Fee type used by Ownership parachain.
pub type WeightToFee = IdentityFee<Balance>;

frame_support::parameter_types! {
/// Size limit of the Ownership parachain blocks.
pub BlockLength: limits::BlockLength =
limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
/// Weight limit of the Ownership parachain blocks.
pub BlockWeights: limits::BlockWeights =
limits::BlockWeights::with_sensible_defaults(MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO);
}
26 changes: 10 additions & 16 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ hex-literal = { workspace = true, optional = true }
scale-info = { workspace = true, features = ["derive"] }
smallvec = { workspace = true }

# Runtime primitives
ownership-parachain-primitives = { workspace = true }

# Substrate
frame-benchmarking = { workspace = true, optional = true }
frame-executive = { workspace = true }
Expand Down Expand Up @@ -89,15 +92,15 @@ pallet-evm-precompile-simple = { workspace = true }

# Bridge dependencies
bp-header-chain = { workspace = true }
bp-messages = { workspace = true }
bp-evochain = { workspace = true }
bp-relayers = { workspace = true }
bp-laos-evolution = { workspace = true }
bp-runtime = { workspace = true }
bp-ownership-parachain = { workspace = true }
bridge-runtime-common = { workspace = true }
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 = [
Expand Down Expand Up @@ -166,16 +169,11 @@ std = [
"frame-try-runtime",
"pallet-evm-living-assets-ownership/std",
# Bridge deps,
"bp-evochain/std",
"bp-laos-evolution/std",
"bp-header-chain/std",
"bp-messages/std",
"bp-ownership-parachain/std",
"bp-relayers/std",
"bp-runtime/std",
"bridge-runtime-common/std",
"pallet-bridge-grandpa/std",
"pallet-bridge-messages/std",
"pallet-bridge-relayers/std",
]

runtime-benchmarks = [
Expand Down Expand Up @@ -203,8 +201,6 @@ runtime-benchmarks = [
"xcm-executor/runtime-benchmarks",
"bridge-runtime-common/runtime-benchmarks",
"pallet-bridge-grandpa/runtime-benchmarks",
"pallet-bridge-messages/runtime-benchmarks",
"pallet-bridge-relayers/runtime-benchmarks",
]

try-runtime = [
Expand Down Expand Up @@ -236,6 +232,4 @@ try-runtime = [
"polkadot-runtime-common/try-runtime",
"sp-runtime/try-runtime",
"pallet-bridge-grandpa/try-runtime",
"pallet-bridge-messages/try-runtime",
"pallet-bridge-relayers/try-runtime",
]
Loading

0 comments on commit 7a8bbec

Please sign in to comment.