Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 3 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
8 changes: 6 additions & 2 deletions frame/system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ decl_storage! {
ExtrinsicData get(fn extrinsic_data): map hasher(twox_64_concat) u32 => Vec<u8>;

/// The current block number being processed. Set by `execute_block`.
Number get(fn block_number) build(|_| 1.into()): T::BlockNumber;
Number get(fn block_number) build(|_| T::BlockNumber::zero()): T::BlockNumber;
Comment thread
shawntabrizi marked this conversation as resolved.
Outdated

/// Hash of the previous block.
ParentHash get(fn parent_hash) build(|_| hash69()): T::Hash;
Expand Down Expand Up @@ -749,6 +749,10 @@ impl<T: Trait> Module<T> {
/// This will update storage entries that correspond to the specified topics.
/// It is expected that light-clients could subscribe to this topics.
pub fn deposit_event_indexed(topics: &[T::Hash], event: T::Event) {
let block_no = Self::block_number();
// Don't populate events on genesis.
if block_no == T::BlockNumber::zero() { return }
Comment thread
shawntabrizi marked this conversation as resolved.
Outdated

let phase = ExecutionPhase::get().unwrap_or_default();
let event = EventRecord {
phase,
Expand Down Expand Up @@ -781,7 +785,6 @@ impl<T: Trait> Module<T> {
return;
}

let block_no = Self::block_number();
for topic in topics {
// The same applies here.
if <EventTopics<T>>::append(topic, &[(block_no, event_idx)]).is_err() {
Expand Down Expand Up @@ -2041,6 +2044,7 @@ mod tests {
let mut ext = new_test_ext();
ext.register_extension(sp_core::traits::CallInWasmExt::new(executor));
ext.execute_with(|| {
System::set_block_number(1);
System::set_code(
RawOrigin::Root.into(),
substrate_test_runtime_client::runtime::WASM_BINARY.to_vec(),
Expand Down