Skip to content

Commit

Permalink
feat(node): Two phase block proposing for release v1.0.3 (#3558)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekovalev authored Dec 12, 2023
1 parent d02d306 commit 53f7933
Show file tree
Hide file tree
Showing 18 changed files with 1,943 additions and 605 deletions.
11 changes: 6 additions & 5 deletions Cargo.lock

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

11 changes: 11 additions & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,14 @@ impl<AccountId: Default, ProgramId, Balance> PaymentVoucher<AccountId, ProgramId
unimplemented!()
}
}

/// Trait that the RuntimeApi should implement in order to allow deconstruction and reconstruction
/// to and from its components.
#[cfg(any(feature = "std", test))]
pub trait Deconstructable<C> {
type Params: Send;

fn into_parts(self) -> (&'static C, Self::Params);

fn from_parts(call: &C, params: Self::Params) -> Self;
}
4 changes: 4 additions & 0 deletions examples/constructor/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,8 @@ impl Calls {
pub fn infinite_loop(self) -> Self {
self.add_call(Call::Loop)
}

pub fn write_in_loop(self, count: impl Into<Arg<u64>>) -> Self {
self.add_call(Call::WriteN(count.into()))
}
}
15 changes: 15 additions & 0 deletions examples/constructor/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub enum Call {
Wake(Arg<[u8; 32]>),
MessageId,
Loop,
WriteN(Arg<u64>),
}

#[cfg(not(feature = "wasm-wrapper"))]
Expand Down Expand Up @@ -317,6 +318,19 @@ mod wasm {
Some(msg::id().encode())
}

fn write_n(self) -> Option<Vec<u8>> {
let Self::WriteN(count) = self else {
unreachable!()
};

let end = count.value();
for i in 0_u64..end {
unsafe { DATA.insert("last_written_n".into(), i.encode()) };
}

None
}

pub(crate) fn process(self, previous: Option<CallResult>) -> CallResult {
debug!("\t[CONSTRUCTOR] >> Processing {self:?}");
let call = self.clone();
Expand Down Expand Up @@ -347,6 +361,7 @@ mod wasm {
Call::MessageId => self.message_id(),
#[allow(clippy::empty_loop)]
Call::Loop => loop {},
Call::WriteN(..) => self.write_n(),
};

(call, value)
Expand Down
12 changes: 12 additions & 0 deletions gsdk/src/metadata/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3025,6 +3025,16 @@ pub mod runtime_types {
enable_debug_mode {
debug_mode_on: ::core::primitive::bool,
},
#[codec(index = 1)]
#[doc = "A dummy extrinsic with programmatically set weight."]
#[doc = ""]
#[doc = "Used in tests to exhaust block resources."]
#[doc = ""]
#[doc = "Parameters:"]
#[doc = "- `_fraction`: the fraction of the `max_extrinsic` the extrinsic will use."]
exhaust_block_resources {
fraction: runtime_types::sp_arithmetic::per_things::Percent,
},
}
#[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)]
pub struct DebugData {
Expand Down Expand Up @@ -9463,12 +9473,14 @@ pub mod calls {
#[doc = "Calls of pallet `GearDebug`."]
pub enum GearDebugCall {
EnableDebugMode,
ExhaustBlockResources,
}
impl CallInfo for GearDebugCall {
const PALLET: &'static str = "GearDebug";
fn call_name(&self) -> &'static str {
match self {
Self::EnableDebugMode => "enable_debug_mode",
Self::ExhaustBlockResources => "exhaust_block_resources",
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions images/block-proposing-timing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions images/substrate-vs-gear-block.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions images/time-weight-synchronization.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 53f7933

Please sign in to comment.