Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add beacon primitives #9

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
201 changes: 47 additions & 154 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ members = [
"pallets/substrate-channel/rpc",
"pallets/beefy-light-client/runtime-api",
"pallets/beefy-light-client/rpc",
"primitives/*",
]

resolver = "2"
5 changes: 0 additions & 5 deletions pallets/leaf-provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "polkado
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", default-features = false }

sp-mmr-primitives = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", default-features = false }
pallet-mmr = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", default-features = false }
pallet-beefy-mmr = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", default-features = false }
beefy-merkle-tree = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", default-features = false }
beefy-primitives = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", default-features = false }

bridge-types = { path = "../types", default-features = false }
Expand All @@ -51,8 +48,6 @@ std = [
"sp-std/std",
"bridge-types/std",
"sp-mmr-primitives/std",
"pallet-mmr/std",
"pallet-beefy-mmr/std",
]
runtime-benchmarks = [
"bridge-types/runtime-benchmarks",
Expand Down
18 changes: 9 additions & 9 deletions pallets/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ authors = ["Snowfork <[email protected]>"]
edition = "2021"

[dependencies]
enum-iterator = "0.6.0"
codec = { package = "parity-scale-codec", version = "3", default-features = false, features = [
"derive",
] }
Expand All @@ -19,13 +18,11 @@ ethereum-types = { version = "0.14.1", default-features = false, features = [
"rlp",
"serialize",
] }
hex = { package = "rustc-hex", version = "2.1.0", default-features = false }
hex-literal = { version = "0.3.1", default-features = false }
hex = { version = "0.4", default-features = false }
libsecp256k1 = { version = "0.7", default-features = false }
parity-bytes = { version = "0.1.2", default-features = false }
rlp = { version = "0.5", default-features = false }
serde = { version = "1.0.101", optional = true }
getrandom = { version = "0.2.1", features = ["js"] }
serde = { version = "1.0.101", optional = true, features = ["derive"] }
getrandom = { version = "0.2.8", features = ["js"], default-features = false }

frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", default-features = false }
Expand All @@ -36,12 +33,12 @@ sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "po
beefy-primitives = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", default-features = false }

ethabi = { git = "https://github.com/sora-xor/ethabi.git", branch = "sora-v1.6.0", default-features = false }
ethash = { git = "https://github.com/sora-xor/ethash.git", branch = "sora-v1.6.0", default-features = false }
serde_json = { version = "1.0", optional = true }
xcm = { git = "https://github.com/paritytech/polkadot.git", branch = "release-v0.9.31", default-features = false }

ethereum-primitives = { path = "../../primitives/ethereum", default-features = false }

[dev-dependencies]
wasm-bindgen-test = "0.3.19"
rand = "0.7.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand All @@ -59,14 +56,17 @@ std = [
"ethereum-types/std",
"hex/std",
"libsecp256k1/std",
"parity-bytes/std",
"rlp/std",
"frame-support/std",
"frame-system/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"beefy-primitives/std",
"ethereum-primitives/std",
"xcm/std",
"getrandom/std",
]

runtime-benchmarks = [
Expand Down
35 changes: 5 additions & 30 deletions pallets/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,16 @@
#![cfg_attr(not(feature = "std"), no_std)]

pub mod channel_abi;
pub mod difficulty;
pub mod ethashdata;
pub mod ethashproof;
pub mod header;
pub mod log;
mod mpt;
pub mod network_config;
pub mod receipt;
pub mod substrate;
pub mod traits;
pub mod types;

#[cfg(any(feature = "test", test))]
pub mod test_utils;

#[cfg(feature = "std")]
use ::serde::{Deserialize, Serialize};
use codec::{Decode, Encode};
pub use ethereum_types::{Address, H128, H160, H256, H512, H64, U256};
use frame_support::RuntimeDebug;
use sp_std::vec;
use sp_std::vec::Vec;

pub use header::{Header, HeaderId};
pub use log::Log;
pub use receipt::Receipt;
pub use ethereum_primitives::*;

#[derive(Debug)]
pub enum DecodeError {
Expand Down Expand Up @@ -91,7 +77,7 @@ pub type EVMChainId = U256;
scale_info::TypeInfo,
codec::MaxEncodedLen,
)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum SubNetworkId {
Mainnet,
Kusama,
Expand All @@ -111,7 +97,7 @@ pub enum SubNetworkId {
scale_info::TypeInfo,
codec::MaxEncodedLen,
)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum GenericNetworkId {
EVM(EVMChainId),
Sub(SubNetworkId),
Expand Down Expand Up @@ -139,14 +125,3 @@ pub enum GenericAccount<AccountId> {
}

pub const CHANNEL_INDEXING_PREFIX: &[u8] = b"commitment";

pub fn import_digest(network_id: &EVMChainId, header: &Header) -> Vec<u8>
where
EVMChainId: Encode,
Header: Encode,
{
let mut digest = vec![];
network_id.encode_to(&mut digest);
header.encode_to(&mut digest);
digest
}
4 changes: 2 additions & 2 deletions pallets/types/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub struct Message {

/// A message relayed from Parachain.
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, scale_info::TypeInfo)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct ParachainMessage<Balance> {
pub payload: Vec<u8>,
pub nonce: MessageNonce,
Expand Down Expand Up @@ -132,7 +132,7 @@ impl From<Digest> for AuxiliaryDigest {

/// Auxiliary [`DigestItem`] to include in header digest.
#[derive(Encode, Decode, Copy, Clone, PartialEq, Eq, RuntimeDebug, scale_info::TypeInfo)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum AuxiliaryDigestItem {
/// A batch of messages has been committed.
Commitment(GenericNetworkId, H256),
Expand Down
67 changes: 67 additions & 0 deletions primitives/ethereum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[package]
name = "ethereum-primitives"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
codec = { package = "parity-scale-codec", version = "3", default-features = false, features = [
"derive",
] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
ethbloom = { version = "0.13.0", default-features = false, features = [
"rlp",
"codec",
] }
ethereum-types = { version = "0.14.1", default-features = false, features = [
"codec",
"rlp",
"serialize",
] }
hex = { version = "0.4", default-features = false }
hex-literal = { version = "0.3.1", default-features = false }
libsecp256k1 = { version = "0.7", default-features = false }
parity-bytes = { version = "0.1.2", default-features = false }
rlp = { version = "0.5", default-features = false }
serde = { version = "1.0.101", optional = true, features = ["derive"] }
getrandom = { version = "0.2.1", features = ["js"] }

frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", default-features = false }

ethabi = { git = "https://github.com/sora-xor/ethabi.git", branch = "sora-v1.6.0", default-features = false }
ethash = { git = "https://github.com/sora-xor/ethash.git", branch = "sora-v1.6.0", default-features = false }
serde_json = { version = "1.0", optional = true }

[dev-dependencies]
wasm-bindgen-test = "0.3.19"
rand = "0.7.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

[features]
default = ["std"]
expensive_tests = []
test = ["serde_json"]
std = [
"serde",
"codec/std",
"scale-info/std",
"ethabi/std",
"ethbloom/std",
"ethereum-types/std",
"hex/std",
"libsecp256k1/std",
"parity-bytes/std",
"rlp/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
]

runtime-benchmarks = ["frame-support/runtime-benchmarks"]
Loading