feat(dursto): make functions using Resolver return Result#770
feat(dursto): make functions using Resolver return Result#770
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #770 +/- ##
==========================================
- Coverage 91.10% 91.09% -0.01%
==========================================
Files 110 110
Lines 20913 20913
Branches 20913 20913
==========================================
- Hits 19052 19050 -2
- Misses 1488 1490 +2
Partials 373 373 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
918ae3c to
8c424c7
Compare
f090b73 to
d8748ee
Compare
0880df7 to
e4f6d71
Compare
d8748ee to
8bd8997
Compare
e4f6d71 to
edf7c47
Compare
8bd8997 to
7b08ced
Compare
edf7c47 to
ba6c4a2
Compare
7b08ced to
046bb04
Compare
ba6c4a2 to
37a8a75
Compare
edfacfe to
ebad67d
Compare
37a8a75 to
8cc254f
Compare
ebad67d to
b9d2fef
Compare
8cc254f to
4ccf7c5
Compare
b9d2fef to
bd05f39
Compare
4ccf7c5 to
b6eb296
Compare
bd05f39 to
d792b08
Compare
b6eb296 to
94cc4b9
Compare
d792b08 to
3b3c0e7
Compare
94cc4b9 to
bc56143
Compare
f0b16d3 to
53297e8
Compare
bc56143 to
3f400f3
Compare
10b51d1 to
4b20377
Compare
54a3a4d to
ce9027b
Compare
@kurtisc I have included such a test in #795 - it requires the type change that @thomasathorne was asking for on the |
e3ce608 to
1286291
Compare
| { | ||
| let right = node_mut.right_mut(); | ||
| let (mut min, _, shrank) = Tree::take_min(right, resolver); | ||
| let (mut min, _, shrank) = Tree::take_min(right, resolver)?; |
There was a problem hiding this comment.
I don't think this method is soundly structured any more. The effect of the mutation that occurs on this line is not undone in case of a failure below. This means, when a failure occurs, the tree is in an inconsistent state. I would imagine this could turn into a foot-gun quite easily. Additionally, avoiding potential exploits to happen by making this correct by construction would probably pay off nicely.
0db6457 to
6302eda
Compare
6302eda to
2415214
Compare
2415214 to
b139a3b
Compare
|
@vapourismo @thomasathorne @kurtisc @emturner @zcabter I have rebased on Ole's error refactor branch that has removed the need for infallible everywhere. |
b139a3b to
4807f6f
Compare
|
|
||
| let data = resolved.to_encode(resolver)?; | ||
| let computed = Hash::hash_encodable(data).expect("The hashing should not fail"); | ||
| let _ = resolved.hash.set(computed); // ignore race: another thread may have set it |
There was a problem hiding this comment.
I think this is a possible solution - as the hash will be set in either case, but I don't know if another thread setting it will mean that the hash set will not be matching the node then, but not sure of how else to do this
2edd59c to
e14864c
Compare
4807f6f to
a178c3b
Compare
a178c3b to
0e20387
Compare
There was a problem hiding this comment.
I'm curious what you intend to signal with the let _ = ... pattern. I've only come across it when a #[must_use] return value needs to be ignored. Though, I am not convinced that's the case here.
| pub(crate) fn to_encode( | ||
| &self, | ||
| resolver: &impl Resolver<Arc<Node>, Node>, | ||
| ) -> Result<impl Encode + '_, OperationalError> { |
There was a problem hiding this comment.
I wish you had introduced the resolver hash method before this, so you wouldn't need to make this encoder fallible.
There was a problem hiding this comment.
I didn't think that making the hash method as part of the resolver would be able to make it infallible?
durable-storage/src/avl/node.rs
Outdated
| node: &mut Arc<Node>, | ||
| resolver: &mut impl Resolver<Arc<Node>, Node>, | ||
| ) -> Result<(), OperationalError> { | ||
| let node_mut = resolver.resolve_mut(node).expect("Node must exist."); |
There was a problem hiding this comment.
| let node_mut = resolver.resolve_mut(node).expect("Node must exist."); | |
| let node_mut = resolver.resolve_mut(node)?; |
0e20387 to
242ba46
Compare
242ba46 to
64719e8
Compare
Part of RV-892.
Part of RV-894.
What
Refactor methods using the resolver to return a
Resultrather than absolute value (though keeping the Error type to Infallible for now, with generic types being introduced in a later PR.Why
Moves us closer to being able to use the resolver for blinding and lazy loading nodes.
The next step will be to make the
Idtype and error types generic. This will be done in #795How
Manually Testing
Tasks for the Author