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

pallet-mmr: handle forks without collisions in offchain storage #11594

Merged
merged 35 commits into from
Jul 7, 2022
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4ded369
pallet-mmr: fix some typos
acatangiu Jun 1, 2022
eb9eea8
pallet-mmr: make the MMR resilient to chain forks
acatangiu Jun 1, 2022
7c8aac0
pallet-mmr: get hash for block that added node
acatangiu Jun 2, 2022
c82ac27
beefy-mmr: add debug logging
acatangiu Jun 21, 2022
98abe4a
add explanatory comment
acatangiu Jun 22, 2022
db41f81
account for block offset of pallet activation
acatangiu Jun 22, 2022
bfd4142
add support for finding all nodes added by leaf
acatangiu Jun 22, 2022
417de11
minor improvements
acatangiu Jun 23, 2022
25468f9
add helper to return all nodes added to mmr with a leaf append
Lederstrumpf Jun 23, 2022
19b35ee
simplify leaf_node_index_to_leaf_index
Lederstrumpf Jun 23, 2022
f9f202a
dead fish: this also doesn't work
acatangiu Jun 23, 2022
05c5f26
simplify rightmost_leaf_node_index_from_pos
Lederstrumpf Jun 23, 2022
e15810d
minor fix
acatangiu Jun 24, 2022
f803ce9
move leaf canonicalization to offchain worker
acatangiu Jun 24, 2022
94e3b61
move storage related code to storage.rs
acatangiu Jun 24, 2022
ecb77a7
on offchain reads use canonic key for old leaves
acatangiu Jun 24, 2022
a17cb65
fix offchain worker write using canon key
acatangiu Jun 24, 2022
e9ab363
fix pallet-mmr tests
acatangiu Jun 24, 2022
b75b0ae
Merge branch 'master' of github.com:paritytech/substrate into mmr-han…
acatangiu Jun 27, 2022
8856db1
add documentation and fix logging
acatangiu Jun 27, 2022
dfc5b45
add offchain mmr canonicalization test
acatangiu Jun 28, 2022
e9edd28
test canon + generate + verify
acatangiu Jun 28, 2022
f472e9b
fix pallet-beefy-mmr tests
acatangiu Jun 28, 2022
5ed95c7
implement review suggestions
acatangiu Jun 28, 2022
2c8b101
improve test
acatangiu Jun 29, 2022
56f2eaa
pallet-mmr: add offchain pruning of forks
acatangiu Jun 30, 2022
e22a936
Merge branch 'master' of github.com:paritytech/substrate into mmr-han…
acatangiu Jun 30, 2022
2629734
pallet-mmr: improve offchain pruning
acatangiu Jul 1, 2022
58d116f
Merge branch 'master' of github.com:paritytech/substrate into mmr-han…
acatangiu Jul 1, 2022
4e6de82
pallet-mmr: improve MMRStore<OffchainStorage>::get()
acatangiu Jul 1, 2022
e72e344
Merge branch 'master' of github.com:paritytech/substrate into mmr-han…
acatangiu Jul 5, 2022
6335512
pallet-mmr: storage: improve logs
acatangiu Jul 5, 2022
eab718c
fix tests: correctly persist overlay
acatangiu Jul 5, 2022
8a8f3d2
pallet-mmr: fix numeric typo in test
Lederstrumpf Jul 6, 2022
ba9fd71
add comment around LeafData requirements
acatangiu Jul 7, 2022
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
12 changes: 2 additions & 10 deletions frame/merkle-mountain-range/src/mmr/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,8 @@ impl NodesUtils {
// responsible for the addition of node `pos`.
fn rightmost_leaf_node_index_from_pos(mut pos: NodeIndex) -> NodeIndex {
use mmr_lib::helper::pos_height_in_tree;
if pos > 0 {
let mut current_height = pos_height_in_tree(pos);
let mut right_child_height = pos_height_in_tree(pos - 1);
while right_child_height < current_height {
pos = pos - 1;
current_height = right_child_height;
right_child_height = pos_height_in_tree(pos - 1);
}
}
pos
let mut current_height = pos_height_in_tree(pos);
pos - (pos_height_in_tree(pos) as u64)
acatangiu marked this conversation as resolved.
Show resolved Hide resolved
}

// Starting from any leaf position, get the sequence of positions of the nodes added
Expand Down