-
Notifications
You must be signed in to change notification settings - Fork 993
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
hash (features|commitment) in output mmr #615
Conversation
workaround this for wallet refresh and wallet restore
switch commit hash key encodes lock_height cleanup output by commit index (currently broken...)
utxos come from the sumtrees (and only the sumtrees, limited info) outputs come from blocks (and we need to look them up via block height)
this uses sumtree in a consistent way
@ignopeverell this should be in a reasonable place for an early review. |
chain/src/sumtree.rs
Outdated
// edge case here - we may be spending an output with zero-confirmations | ||
// and it just got included in a block. | ||
// The wallet may not know about this new block yet (not yet refreshed). | ||
// Is it safe to assume this the tx was included in the latest block? |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
chain/src/sumtree.rs
Outdated
// If we are spending a coinbase output then go find the block | ||
// and check the coinbase maturity rule is being met. | ||
if input.features.contains(COINBASE_OUTPUT) { | ||
// edge case here - we may be spending an output with zero-confirmations |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -176,6 +183,23 @@ fn test_coinbase_maturity() { | |||
|
|||
let prev = chain.head_header().unwrap(); | |||
|
|||
<<<<<<< HEAD |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Minor comments but looks good to me overall! |
…coinbase outputs)
@ignopeverell this should be good to go now if you want to give it a final review? |
Looking good, ship it! |
Soon as travis sorts out its infra... multiple builds stuck for a couple of hours. Just kicked off a new one. |
Merging - travis is still working through its backlog... |
This PR solves #559 by extending the output pmmr to include the output features in the hash.
The proposed solution is described here in more detail - #597
Replaces #215 (which attempted to encode lock_height in the switch commit)
tl;dr
Specifically we never see (and use) the wrong lock_height (which can and will break consensus).
The combination of these changes should ensure we handle the spending of coinbase outputs correctly even under adverse conditions (chain forks and miners reusing wallet keys, creating duplicate commitments).
SumCommit
takesOutputFeatures
&Commitment
(features|commit)
OutputIdentifier
so we don't need to pass aSumCommit
around everywhereOutputIdentifier
to checkis_unspent
via the MMR (by comparing the hash)Input
lock_height
based on height of block + 1,000lock_height
(also cannot lie about coinbase vs non-coinbase)TODO -