diff --git a/src/core/headers_store.cairo b/src/core/headers_store.cairo index 03b3dce..389a50c 100644 --- a/src/core/headers_store.cairo +++ b/src/core/headers_store.cairo @@ -138,6 +138,9 @@ trait IHeadersStore { // @param mmr_id The id of the MMR to clone // @param last_pos last_pos of the given MMR // @param new_mmr_id The id of the new MMR + // @dev Notice that to prevent overwriting existing MMRs, a check if the MMR with the new id + // already exists is performed. Because of that MMR root = 0 is reserved for non-existing MMRs, + // so 0 cannot be used as a valid mmr root anywhere. fn create_branch_from( ref self: TContractState, mmr_id: MmrId, last_pos: MmrSize, new_mmr_id: MmrId ); diff --git a/src/core/tests/test_headers_store.cairo b/src/core/tests/test_headers_store.cairo index d248c2d..608e583 100644 --- a/src/core/tests/test_headers_store.cairo +++ b/src/core/tests/test_headers_store.cairo @@ -256,8 +256,7 @@ fn test_create_branch_from_message() { // Root equal to 0 is not allowed. assert( - dispatcher.create_branch_from_message(0, 1, 0, mmr_id_2).is_err(), - 'Root = 0 should fail' + dispatcher.create_branch_from_message(0, 1, 0, mmr_id_2).is_err(), 'Root = 0 should fail' ); // Creating MMR with the same ID should fail.