Skip to content

Commit

Permalink
Merge pull request #76 from availproject/ghali/prepare-mainnet
Browse files Browse the repository at this point in the history
Ghali/prepare mainnet
  • Loading branch information
Leouarz authored Feb 26, 2024
2 parents 437bc6f + 517763f commit 1ecd262
Show file tree
Hide file tree
Showing 12 changed files with 307 additions and 665 deletions.
541 changes: 263 additions & 278 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ tiny-keccak = { version = "2.0.2", default-features = false, features = ["keccak


# Substrate
binary-merkle-tree = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-v1.6.0-patch", default-features = false, optional = true }
binary-merkle-tree = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-1.7.1-patch", default-features = false, optional = true }
codec = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
sp-arithmetic = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-v1.6.0-patch", default-features = false }
sp-core = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-v1.6.0-patch", default-features = false }
sp-io = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-v1.6.0-patch", default-features = false }
sp-std = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-v1.6.0-patch", default-features = false }
sp-trie = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-v1.6.0-patch", default-features = false }
sp-arithmetic = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-1.7.1-patch", default-features = false }
sp-core = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-1.7.1-patch", default-features = false }
sp-io = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-1.7.1-patch", default-features = false }
sp-std = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-1.7.1-patch", default-features = false }
sp-trie = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-1.7.1-patch", default-features = false }

# Substrate Runtime
frame-support = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-v1.6.0-patch", default-features = false, optional = true }
sp-runtime = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-v1.6.0-patch", default-features = false, optional = true }
sp-runtime-interface = {git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-v1.6.0-patch", default-features = false, optional = true }
frame-support = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-1.7.1-patch", default-features = false, optional = true }
sp-runtime = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-1.7.1-patch", default-features = false, optional = true }
sp-runtime-interface = {git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-1.7.1-patch", default-features = false, optional = true }

[dev-dependencies]
hex-literal = { version = "0.3.4" }
Expand Down
197 changes: 0 additions & 197 deletions core/src/data_proof.rs

This file was deleted.

31 changes: 10 additions & 21 deletions core/src/header/extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,29 @@ use sp_runtime_interface::pass_by::PassByCodec;

use crate::{DataLookup, HeaderVersion};

pub mod v1;
pub mod v2;
pub mod v3;

/// Header extension data.
#[derive(PartialEq, Eq, Clone, RuntimeDebug, TypeInfo, Encode, Decode)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "runtime", derive(PassByCodec))]
#[repr(u8)]
pub enum HeaderExtension {
V1(v1::HeaderExtension),
V2(v2::HeaderExtension),
V3(v3::HeaderExtension) = 3,

Check warning on line 19 in core/src/header/extension/mod.rs

View workflow job for this annotation

GitHub Actions / build_and_test

casting integer literal to `u8` is unnecessary
}

/// It forwards the call to the inner version of the header. Any invalid version will return the
/// default value or execute an empty block.
macro_rules! forward_to_version {
($self:ident, $function:ident) => {{
match $self {
HeaderExtension::V1(ext) => ext.$function(),
HeaderExtension::V2(ext) => ext.$function(),
HeaderExtension::V3(ext) => ext.$function(),
}
}};

($self:ident, $function:ident, $arg:expr) => {{
match $self {
HeaderExtension::V1(ext) => ext.$function($arg),
HeaderExtension::V2(ext) => ext.$function($arg),
HeaderExtension::V3(ext) => ext.$function($arg),
}
}};
}
Expand All @@ -57,28 +54,20 @@ impl HeaderExtension {

pub fn get_header_version(&self) -> HeaderVersion {
match self {
HeaderExtension::V1(_) => HeaderVersion::V1,
HeaderExtension::V2(_) => HeaderVersion::V2,
HeaderExtension::V3(_) => HeaderVersion::V3,
}
}
}

impl Default for HeaderExtension {
fn default() -> Self {
v1::HeaderExtension::default().into()
v3::HeaderExtension::default().into()
}
}

impl From<v1::HeaderExtension> for HeaderExtension {
impl From<v3::HeaderExtension> for HeaderExtension {
#[inline]
fn from(ext: v1::HeaderExtension) -> Self {
Self::V1(ext)
}
}

impl From<v2::HeaderExtension> for HeaderExtension {
#[inline]
fn from(ext: v2::HeaderExtension) -> Self {
Self::V2(ext)
fn from(ext: v3::HeaderExtension) -> Self {
Self::V3(ext)
}
}
33 changes: 0 additions & 33 deletions core/src/header/extension/v2.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};
use sp_core::{RuntimeDebug, H256};

use crate::{v1::KateCommitment, DataLookup};
use crate::{v3::KateCommitment, DataLookup};

#[derive(PartialEq, Eq, Clone, RuntimeDebug, TypeInfo, Encode, Decode, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
Expand Down
Loading

0 comments on commit 1ecd262

Please sign in to comment.