-
Notifications
You must be signed in to change notification settings - Fork 990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
store both mmr index and block height into database for output #2903
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is nice.
I'd like to do some local testing with this over the next couple of days before we merge but 👍.
@@ -396,7 +396,7 @@ where | |||
{ | |||
fn deser_if_prefix_match(&self, key: &[u8], value: &[u8]) -> Option<(Vec<u8>, T)> { | |||
let plen = self.prefix.len(); | |||
if plen == 0 || key[0..plen] == self.prefix[..] { | |||
if plen == 0 || (key.len() >= plen && key[0..plen] == self.prefix[..]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was this change needed for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I get it now after rereading it. We just check the length for safety so it doesn't panic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Actually I saw a panic here on a test, don't know exact reason, but not bad to give a safe protection here.
@garyyu Is this good to go? I can merge if so. |
@antiochp ok if you don't need that new type for the (u64, u64). I have run a lot of tests on several nodes for this PR, no problem found. |
Testing this locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In rebuild_index
we do the following -
for pos in self.output_pmmr.leaf_pos_iter() {
if let Some(out) = self.output_pmmr.get_data(pos) {
self.batch.save_output_pos(&out.commit, pos)?;
count += 1;
}
}
i.e. We are still calling save_output_pos()
and I think we should be calling the new save_output_pos_height()
instead?
No, I keep it to avoid a big refactoring. Instead, after each time calling this There're 2 locations for this
(BTW, I want another PR to give a complete refactoring on the current |
PR for #2889.
5~10 times speed improvement for
/v1/chain/outputs
and/v1/txhashset/outputs
APIs, which will make the walletrestore
,check
andrefresh outputs
super fast comparing to current version.For the database migration speed, I tested on current Floonet and spent
5
seconds for this migration on my laptop (Intel(R) Core(TM) i5-8210Y CPU @ 1.60GHz
).The test examples of these APIs: