This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Log2 Ancestors Module #2053
Copy link
Copy link
Open
Labels
I9-optimisationAn enhancement to provide better overall performance in terms of time-to-completion for a task.An enhancement to provide better overall performance in terms of time-to-completion for a task.Z1-easyCan be fixed primarily by duplicating and adapting code by an intermediate coderCan be fixed primarily by duplicating and adapting code by an intermediate coderZ6-mentorAn easy task where a mentor is available. Please indicate in the issue who the mentor could be.An easy task where a mentor is available. Please indicate in the issue who the mentor could be.
Milestone
Description
The idea behind log2 ancestors is to keep a record of some block hashes in the history of the chain.
decl_storage! {
Ancestors: map BlockNumber => (BlockNumber, Hash);
}
fn initialise() {
let number = current_number() - 1;
let parent_hash = parent_hash();
let mut index = 0;
let mut working_number = number;
while index < 32 {
Ancestors::put(index, (number, parent_hash)); // storage
if working_number % 2 != 0 { break }
working_number /= 2;
index += 1;
}
// post-condition: Ancestors(index) stores the hash and
// number of the last block whose number was divisible by 2^index.
}We can use this module to safely skip backwards in the finalized chain, so long ancestry proofs become shorter.
burdges
Metadata
Metadata
Assignees
Labels
I9-optimisationAn enhancement to provide better overall performance in terms of time-to-completion for a task.An enhancement to provide better overall performance in terms of time-to-completion for a task.Z1-easyCan be fixed primarily by duplicating and adapting code by an intermediate coderCan be fixed primarily by duplicating and adapting code by an intermediate coderZ6-mentorAn easy task where a mentor is available. Please indicate in the issue who the mentor could be.An easy task where a mentor is available. Please indicate in the issue who the mentor could be.