-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
transaction vout duplication bug fix #1
Conversation
Did you tried testing this against the case described in the original issue? (meaning that with this fix transaction output is not duplicated with transfer command) |
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.
I am afraid this is wrong and does not match the solution from the original issue:
- adding fee to id in https://github.com/LNP-BP/rust-lnpbp/blob/e35da7d534250ac7c52ebfae45c8bd772400a7ab/src/rgb/stash/anchor.rs#L139-L154
- Using 0 instead of fee in https://github.com/LNP-BP/rust-lnpbp/blob/e35da7d534250ac7c52ebfae45c8bd772400a7ab/src/rgb/stash/anchor.rs#L197
The solution was to provide TxContainer with the correct vout. Since TxContainer takes vout as (fee+protocol_factor)%num outputs we must use this instead of either fee or protocol_factor (I propose the later) and set the other one to 0.
I haven't been able to test it cause I couldn't get Sorry I am not seeing how this wrong. We are passing on What am I missing? I also didn't get why
I am not sure why we should trick |
76f4cb0
to
7f48ee0
Compare
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.
I am afraid that this fix is not compatible with other parts of the RGB node code. So I am proposing some adjustments to it.
// TODO: use enum instead of hardcoded value | ||
let protocol_factor = 0; | ||
|
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.
I do not think that setting the protocol_factor
to zero is the best approach here. Besides, this is not compatible with what is done in the verify
associated function of the Anchor
structure.
So I propose that protocol_factor
be initialize the same way that it is done there.
// TODO: use enum instead of hardcoded value | |
let protocol_factor = 0; | |
let protocol_factor = ( | |
Uint256::from_be_bytes(*contract_id.as_slice()) % Uint256::from_u64(num_outs).unwrap() | |
).low_u64() as u32; |
@@ -211,7 +212,7 @@ impl Anchor { | |||
let mut container = TxContainer { | |||
tx: tx.clone(), | |||
fee, | |||
protocol_factor: vout as u32, | |||
protocol_factor: protocol_factor as u32, |
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.
According to my suggested change above, there would be no need to cast protocol_factor
here. So, it should be written only as:
protocol_factor: protocol_factor as u32, | |
protocol_factor: protocol_factor, |
Am I right that this PR was superceded by #2 and can be close dnow? |
Yes, that is correct. |
Ok, closing in favor of merged #2 |
Fixes RGB-WG/rgb-node#127