-
Notifications
You must be signed in to change notification settings - Fork 219
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
feat!: add recovery byte to output features #3727
feat!: add recovery byte to output features #3727
Conversation
c6951ed
to
355b4a5
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.
Generally looking really good, couple comments but the main one is that the three methods added to the OMS API for adding a rewindable output seem like they don't belong outside of the tests.
Please keep further updates to this PR as their own commits so I can review the new stuff only.
base_layer/core/src/transactions/transaction_protocol/single_receiver.rs
Outdated
Show resolved
Hide resolved
@@ -295,6 +315,24 @@ impl OutputManagerHandle { | |||
} | |||
} | |||
|
|||
pub async fn add_rewindable_output( |
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.
Are add_rewindable_output
, add_rewindable_output_with_tx_id
, add_rewindable_unvalidated_output
only used for testing? I am assuming that they are because how would a normal client of this service be able to construct its own rewindable output externally.
So based on that I would say these three methods don't actually belong in API of this service. Now the question is how do you get these kind of outputs into the output manager for testing. The answer is that in the testing code you have access to the OMS database backend and you can insert them directly.
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 would counter that their counterparts, that is without the rewindable
part, also need to be taken out of the API then. This is expanding on the pattern that is already there.
Your opinion?
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.
The counter parts are used for importing of outputs manually and by the UTXO scanner.
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.
As discussed, I will remove these from the API.
Maybe for a next PR.
50f3f8a
to
3f7b347
Compare
3f7b347
to
9f6e9a2
Compare
9f6e9a2
to
c750fe6
Compare
7f42f21
to
dafe55f
Compare
3442dd9
to
c53dd74
Compare
c53dd74
to
70c34ec
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.
Changes requested:
The json text embedded in the wallet should only be done at wallet startup, not every time output or transaction data is read from the db.
base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs
Outdated
Show resolved
Hide resolved
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.
Well done this was a lot of work. I have a few comments and questions, and my only real concern is that a developer must remember to update the recovery byte when creating OutputFeatures. I would vastly prefer it to be automatically updated whenever the commitment of the output is set or updated.
@@ -779,6 +783,7 @@ mod fetch_utxo_by_unique_id { | |||
lock: 0, | |||
features: features | |||
)]); | |||
features.set_recovery_byte(tx_outputs[0].features.recovery_byte); |
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 happens if someone creates an OutputFeatures
and forgets to call set_recovery_byte
?
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.
A typical flow to create an output is (only discussing the pertinent information):
- Select output features using a default/random recovery byte
- Calculate output weight & determine the fee
- Finalize the commitment information (i.e. select the blinding factor)
- Set the recovery byte with the commitment as input (i.e. finalize the output features)
- Calculate the partial or final metadata signature, also signing the output features
- Finalize the output as an unblinded output, using all previous information as inputs
Recovery byte checks is done in strategic places in the code base and automatically set whenever it needs to be updated within the various protocols. If someone adds functionality and forget to set the recovery byte as required for the protocol, recovery byte validation will not succeed the validation in unblinded_output::as_transaction_output
, unblinded_output::as_rewindable_transaction_output
and transaction_initializer::with_output
.
base_layer/core/src/transactions/transaction_components/output_features.rs
Outdated
Show resolved
Hide resolved
base_layer/core/src/transactions/transaction_components/output_features.rs
Outdated
Show resolved
Hide resolved
Not really possible to do this, please see detailed comment above. |
70c34ec
to
865672c
Compare
865672c
to
17986ba
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 would suggest trying the #[serde(default= 0)]
and not changing any of the existing json in the faucet or sqlite db.
I'll try test this locally as well
base_layer/core/src/transactions/transaction_components/output_features.rs
Outdated
Show resolved
Hide resolved
base_layer/core/src/transactions/transaction_components/output_features.rs
Show resolved
Hide resolved
base_layer/core/src/transactions/transaction_components/output_features.rs
Show resolved
Hide resolved
base_layer/core/src/transactions/transaction_components/output_features.rs
Show resolved
Hide resolved
@@ -848,13 +896,13 @@ where | |||
unique_id, | |||
fee_per_gram, | |||
); | |||
let output_features = OutputFeatures::default(); | |||
let output_features_estimate = OutputFeatures { ..Default::default() }; |
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.
This is the same thing
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.
The wording choice of output_features_estimate
is important here to let the reader know at this stage these features are not the real features and only used to for fee estimation.
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.
Think he means OutputFeatures { ..Default::default() };
is a convoluted way of writing the previous code OutputFeatures::default()
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.
Yip, that was a refactoring remnant.
base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs
Outdated
Show resolved
Hide resolved
base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs
Outdated
Show resolved
Hide resolved
79ee297
to
efb9596
Compare
Added recovery_byte to OutputFeatures. This will not change the genesis block and only become effective with version V1 of the OutputFeatures, resulting in a hard fork. All funds in the wallet will be retained. Co-authored-by: Mike the Tike <mikethetike@tari.com> Co-authored-by: David Main <51991544+StriderDM@users.noreply.github.com>
efb9596
to
165f470
Compare
* development: (118 commits) chore: clean up providing seed words from LibWallet (tari-project#3906) chore: move tari_script into its own crate (tari-project#3909) fix(consensus): check blockchain version within valid range (tari-project#3916) ci: fix missing npm deps and add javascript ci (tari-project#3910) refactor: use clap as a commands parser (tari-project#3867) chore: use git tagged tari_utilities and tari-crypto deps (tari-project#3913) fix: aligned tables left (tari-project#3899) ci: fix vue build v0.29.0 feat!: add recovery byte to output features (tari-project#3727) add ffi ci check (tari-project#3915) fix(block-sync): use avg latency to determine slow sync peer for block sync (tari-project#3912) fix: fix merge mining proxy pool mining (tari-project#3814) revert: remove use of blocking tasks for DHT db (reverts tari-project#3887) (tari-project#3901) chore: add license info missing from some crates (tari-project#3892) fix(core): correctly filter pruned sync peers for block sync (tari-project#3902) ci: revert bors squash merge (tari-project#3900) fix: update metadata size calculation to use FixedSet.iter() docs(rfc): deep links structure convention - deep links is use (tari-project#3897) ci: use squash merge for bors (tari-project#3896) ...
* development: chore: clean up providing seed words from LibWallet (tari-project#3906) chore: move tari_script into its own crate (tari-project#3909) fix(consensus): check blockchain version within valid range (tari-project#3916) ci: fix missing npm deps and add javascript ci (tari-project#3910) refactor: use clap as a commands parser (tari-project#3867) chore: use git tagged tari_utilities and tari-crypto deps (tari-project#3913) fix: aligned tables left (tari-project#3899) ci: fix vue build v0.29.0 feat!: add recovery byte to output features (tari-project#3727) add ffi ci check (tari-project#3915)
Description
Added
recovery_byte
toOutputFeatures
. The recovery byte will uniformly distribute all outputs in the blockchain into 255 "bins" that can be identified by the commitment of the output in combination with a master recovery byte key.This change will come into effect on
dibbler
testnet once theOutputFeatures
version is updated fromV0
toV1
, which will result in a hard fork.All funds will be retained after the hard fork.
Motivation and Context
The reasoning behind this is that it will enable a client to request only a specific subset of full-on outputs in a set of blocks. The commitment only takes up a fraction (less than 5%) of the byte space for a full-on output. A typical use case for this feature would be a wallet recovery client that needs to scan all outputs in the blockchain from the birthdate of the wallet to be recovered. The client would request all commitments in the set of blocks from a base node and identify all those that belong to their own "bin", after which a tailor made request can be submitted to retrieve the full-on output data for the identified commitments. This will result in a better than 20x saving in the amount of data transmitted for wallet recovery.
How Has This Been Tested?