Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 67ef6c7

Browse files
committed
add AuraUnincludedSegmentApi
1 parent 7489c94 commit 67ef6c7

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed

Cargo.lock

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ members = [
3030
"pallets/xcmp-queue",
3131
"parachain-template/node",
3232
"parachain-template/runtime",
33+
"primitives/aura",
3334
"primitives/core",
3435
"primitives/parachain-inherent",
3536
"primitives/timestamp",

primitives/aura/Cargo.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[package]
2+
name = "cumulus-primitives-aura"
3+
version = "0.1.0"
4+
authors = ["Parity Technologies <[email protected]>"]
5+
edition = "2021"
6+
7+
[dependencies]
8+
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ "derive" ] }
9+
10+
# Substrate
11+
sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
12+
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
13+
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
14+
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
15+
16+
# Polkadot
17+
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
18+
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
19+
20+
[features]
21+
default = [ "std" ]
22+
std = [
23+
"codec/std",
24+
"sp-api/std",
25+
"sp-consensus-aura/std",
26+
"sp-runtime/std",
27+
"sp-std/std",
28+
"polkadot-core-primitives/std",
29+
"polkadot-primitives/std",
30+
]

primitives/aura/src/lib.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2023 Parity Technologies (UK) Ltd.
2+
// This file is part of Cumulus.
3+
4+
// Substrate is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// Substrate is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License
15+
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
16+
17+
//! Core primitives for Aura in Cumulus.
18+
//!
19+
//! In particular, this exposes the [`AuraUnincludedSegmentApi`] which is used to regulate
20+
//! the behavior of Aura within a parachain context.
21+
22+
#![cfg_attr(not(feature = "std"), no_std)]
23+
24+
pub use sp_consensus_aura::Slot;
25+
26+
sp_api::decl_runtime_apis! {
27+
/// This runtime API is used to inform potential block authors whether they will
28+
/// have the right to author at a slot, assuming they have claimed the slot.
29+
///
30+
/// In particular, this API allows Aura-based parachains to regulate their "unincluded segment",
31+
/// which is the section of the head of the chain which has not yet been made available in the
32+
/// relay chain.
33+
///
34+
/// When the unincluded segment is short, Aura chains will allow authors to create multiple
35+
/// blocks per slot in order to build a backlog. When it is saturated, this API will limit
36+
/// the amount of blocks that can be created.
37+
pub trait AuraUnincludedSegmentApi {
38+
/// Whether it is legal to extend the chain, assuming the given block is the most
39+
/// recently included one as-of the relay parent that will be built against, and
40+
/// the given slot.
41+
///
42+
/// This should be consistent with the logic the runtime uses when validating blocks to
43+
/// avoid issues.
44+
fn can_build_upon(included_hash: Block::Hash, slot: Slot) -> bool;
45+
}
46+
}

0 commit comments

Comments
 (0)