-
Notifications
You must be signed in to change notification settings - Fork 151
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
Support for reaching consensus on MintTx, mint client improvements #1641
Conversation
// Perform minting. | ||
for mint_tx in &mint_txs { | ||
// One last chance to prevent minting MOB. | ||
if mint_tx.prefix.token_id == Mob::ID { | ||
return Err(Error::FormBlock("Attempted to mint MOB".into())); | ||
} | ||
|
||
let recipient = PublicAddress::new( | ||
&mint_tx.prefix.spend_public_key, | ||
&mint_tx.prefix.view_public_key, | ||
); | ||
let output = mint_output( | ||
&recipient, | ||
MINTED_OUTPUT_PRIVATE_KEY_DOMAIN_TAG.as_bytes(), | ||
parent_block, | ||
&mint_txs, | ||
mint_tx.prefix.amount, | ||
TokenId::from(mint_tx.prefix.token_id), | ||
)?; | ||
|
||
outputs.push(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.
This is an important change.
self.validate_mint_txs(&inputs.mint_txs)?; | ||
let mint_txs = inputs.mint_txs; |
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.
Optional/Equivalent: Borrow
self.validate_mint_txs(&inputs.mint_txs)?; | |
let mint_txs = inputs.mint_txs; | |
let mint_txs = &inputs.mint_txs; | |
self.validate_mint_txs(mint_txs)?; |
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.
That wont work, since I am later moving it into BlockContents
.
consensus/mint-client/Cargo.toml
Outdated
pem = "1.0" | ||
rand = "0.8" | ||
rand = "0.8" |
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.
Nit: Add trailing newline
Co-authored-by: Remoun Metyas <remoun@mobilecoin.com>
* Add master minters configuration to TokensConfig (#1504) * minting configuration wip * fmt * fix indent * fix test * add test, be more aggressive about validation * use serde(with=...) * one line * Minting data types and initial LedgerDb support (#1537) * initial mint data structures * basic mint config in ledger * basic get/set test * another test * update total minted api+tests * add migration code * enforce limit * lock and lint * fmt * update comment and remove pub * update lock files * misc pr review fixes * add a test for setting an active configuration with no configs * small fixes * use PEM encoding for signers * fix tag * ensure total minted amount cannot decrease * use inconsistent_digit_grouping to make version numbers more readable * fmt * MintTx/Config protobuf conversions (#1558) * add external.proto minting messages and api conversion traits * tests * mint tx conversions * lint * fix module name * Store mint-related transations in LedgerDb (#1587) * wip * remove BlockContents::new to make adding new fields less tedious * fix typos/lints * add todo * fix typos * more defaults * tests * iterate * more tests * remove unneeded public api * more tests * more tests * stricter validation * reorganize code * lint * add mint migration code * mint_tx_store test no. 1 * dont allow overwriting existing blocks, iterate on test * pr fixes * lint * more tests * add test * remove unneeded type declaration * Update ledger/db/src/mint_config_store.rs Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * rename test to better explain what its testing * be more strict about having outputs when MintTxs are present Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * Expose LedgerDb API for looking up txs by nonce (#1602) * wip * remove BlockContents::new to make adding new fields less tedious * fix typos/lints * add todo * fix typos * more defaults * tests * iterate * more tests * remove unneeded public api * more tests * more tests * stricter validation * reorganize code * lint * add mint migration code * mint_tx_store test no. 1 * dont allow overwriting existing blocks, iterate on test * pr fixes * lint * more tests * add test * remove unneeded type declaration * add public ledger api for looking up mint txs by nonce, change to return block index since that is more useful * missing mock changes * fix fmt * Update ledger/db/src/mint_config_store.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * fix typo * Update ledger/db/src/mint_config_store.rs Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * rename test to better explain what its testing * be more strict about having outputs when MintTxs are present * add public ledger api for looking up mint txs by nonce, change to return block index since that is more useful Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * Minting transaction validation (#1593) * wip * remove BlockContents::new to make adding new fields less tedious * fix typos/lints * add todo * fix typos * more defaults * tests * iterate * more tests * remove unneeded public api * more tests * more tests * stricter validation * reorganize code * lint * add mint migration code * mint_tx_store test no. 1 * dont allow overwriting existing blocks, iterate on test * pr fixes * lint * more tests * add test * remove unneeded type declaration * add public ledger api for looking up mint txs by nonce, change to return block index since that is more useful * missing mock changes * fix fmt * Update ledger/db/src/mint_config_store.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * fix typo * Update ledger/db/src/mint_config_store.rs Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * rename test to better explain what its testing * be more strict about having outputs when MintTxs are present * add public ledger api for looking up mint txs by nonce, change to return block index since that is more useful * initial work on validation * SetMintConfigTx validation + tests * reorganize * MintTx validation and tests * lint * add comments * update comments * Update transaction/core/src/mint/validation/common.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * Update transaction/core/src/mint/validation/config.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * address pr review comment * make nonce constant length Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * SetMintConfigTx -> MintConfigTx (#1607) * SetMintConfigTx -> MintConfigTx * more renames * Small fixes following the confidential-token-id merging (#1609) * post rebase fixes * fix tests * Eran/merge master 2022 03 14 (#1629) * Update grpcio to 0.10 (#1592) * Bump pretty_assertions from 1.1.0 to 1.2.0 (#1610) Bumps [pretty_assertions](https://github.com/colin-kiegel/rust-pretty-assertions) from 1.1.0 to 1.2.0. - [Release notes](https://github.com/colin-kiegel/rust-pretty-assertions/releases) - [Changelog](https://github.com/colin-kiegel/rust-pretty-assertions/blob/main/CHANGELOG.md) - [Commits](https://github.com/colin-kiegel/rust-pretty-assertions/commits) --- updated-dependencies: - dependency-name: pretty_assertions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * delete slam, fixes #1574 (#1611) slam is no longer needed because fog-distro, which began life as a fork of it, has superceded it and slam is no longer used in CD * introduce FormBlockInputs and break out some code from form_block into its own method (#1625) * introduce FormBlockInputs and break out some code from form_block into its own method * add some missing code * add missing import * remove the Copy trait from ConsensusValue (#1628) * remove the Copy and Display traits from ConsensusValue since they make it hard to add transaction types that cant implement them * add back display * fmt Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Chris Beck <beck.ct@gmail.com> * Support reaching consensus on MintConfigTxs (#1630) * initial work on stubbing out SetMintConfigTx * MintTxManager replaces stubs * grpc api * fmt * mint client and misc improvements * interate towards tx working * actual validation taking place * iterate * append block from client works * wip * rename and lint * fix nonce length * comine, cleanups, validate that nonce is not already in ledger * cleanups * lint * make test code reusable * add tests * structopt -> clap * rebase fixes * fix test * Update consensus/mint-client/src/config.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * address review comments * Update transaction/core/test-utils/src/mint.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * use dedup_by+truncate * renames * undo incorrect change * typo Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * Support for reaching consensus on MintTx, mint client improvements (#1641) * stub out ProposeMintTx * expose get_active_mint_config_for_mint_tx, more plumbing * undo wrong change * MintTxManager impls for MintTx * mint client support subcommands * basic MintTx flow works, getting NoOutputs * mobilecoind api filtering for token_id * minting is working :) * client improvements, local network script defaults to having two mintable tokens * tests * more tests yay * testsssssssss * test fixes and linting * try without block version * back to block v3 * Update consensus/service/src/api/client_api_service.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * new line Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * Update ledger/db/src/mint_tx_store.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * pr comments * improve comment * use const * Update ledger/db/src/mint_tx_store.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * lint Co-authored-by: sugargoat <sugargoat@mobilecoin.com> Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Chris Beck <beck.ct@gmail.com>
* Add master minters configuration to TokensConfig (#1504) * minting configuration wip * fmt * fix indent * fix test * add test, be more aggressive about validation * use serde(with=...) * one line * Minting data types and initial LedgerDb support (#1537) * initial mint data structures * basic mint config in ledger * basic get/set test * another test * update total minted api+tests * add migration code * enforce limit * lock and lint * fmt * update comment and remove pub * update lock files * misc pr review fixes * add a test for setting an active configuration with no configs * small fixes * use PEM encoding for signers * fix tag * ensure total minted amount cannot decrease * use inconsistent_digit_grouping to make version numbers more readable * fmt * MintTx/Config protobuf conversions (#1558) * add external.proto minting messages and api conversion traits * tests * mint tx conversions * lint * fix module name * Store mint-related transations in LedgerDb (#1587) * wip * remove BlockContents::new to make adding new fields less tedious * fix typos/lints * add todo * fix typos * more defaults * tests * iterate * more tests * remove unneeded public api * more tests * more tests * stricter validation * reorganize code * lint * add mint migration code * mint_tx_store test no. 1 * dont allow overwriting existing blocks, iterate on test * pr fixes * lint * more tests * add test * remove unneeded type declaration * Update ledger/db/src/mint_config_store.rs Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * rename test to better explain what its testing * be more strict about having outputs when MintTxs are present Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * Expose LedgerDb API for looking up txs by nonce (#1602) * wip * remove BlockContents::new to make adding new fields less tedious * fix typos/lints * add todo * fix typos * more defaults * tests * iterate * more tests * remove unneeded public api * more tests * more tests * stricter validation * reorganize code * lint * add mint migration code * mint_tx_store test no. 1 * dont allow overwriting existing blocks, iterate on test * pr fixes * lint * more tests * add test * remove unneeded type declaration * add public ledger api for looking up mint txs by nonce, change to return block index since that is more useful * missing mock changes * fix fmt * Update ledger/db/src/mint_config_store.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * fix typo * Update ledger/db/src/mint_config_store.rs Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * rename test to better explain what its testing * be more strict about having outputs when MintTxs are present * add public ledger api for looking up mint txs by nonce, change to return block index since that is more useful Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * Minting transaction validation (#1593) * wip * remove BlockContents::new to make adding new fields less tedious * fix typos/lints * add todo * fix typos * more defaults * tests * iterate * more tests * remove unneeded public api * more tests * more tests * stricter validation * reorganize code * lint * add mint migration code * mint_tx_store test no. 1 * dont allow overwriting existing blocks, iterate on test * pr fixes * lint * more tests * add test * remove unneeded type declaration * add public ledger api for looking up mint txs by nonce, change to return block index since that is more useful * missing mock changes * fix fmt * Update ledger/db/src/mint_config_store.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * fix typo * Update ledger/db/src/mint_config_store.rs Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * rename test to better explain what its testing * be more strict about having outputs when MintTxs are present * add public ledger api for looking up mint txs by nonce, change to return block index since that is more useful * initial work on validation * SetMintConfigTx validation + tests * reorganize * MintTx validation and tests * lint * add comments * update comments * Update transaction/core/src/mint/validation/common.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * Update transaction/core/src/mint/validation/config.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * address pr review comment * make nonce constant length Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * SetMintConfigTx -> MintConfigTx (#1607) * SetMintConfigTx -> MintConfigTx * more renames * Small fixes following the confidential-token-id merging (#1609) * post rebase fixes * fix tests * Eran/merge master 2022 03 14 (#1629) * Update grpcio to 0.10 (#1592) * Bump pretty_assertions from 1.1.0 to 1.2.0 (#1610) Bumps [pretty_assertions](https://github.com/colin-kiegel/rust-pretty-assertions) from 1.1.0 to 1.2.0. - [Release notes](https://github.com/colin-kiegel/rust-pretty-assertions/releases) - [Changelog](https://github.com/colin-kiegel/rust-pretty-assertions/blob/main/CHANGELOG.md) - [Commits](https://github.com/colin-kiegel/rust-pretty-assertions/commits) --- updated-dependencies: - dependency-name: pretty_assertions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * delete slam, fixes #1574 (#1611) slam is no longer needed because fog-distro, which began life as a fork of it, has superceded it and slam is no longer used in CD * introduce FormBlockInputs and break out some code from form_block into its own method (#1625) * introduce FormBlockInputs and break out some code from form_block into its own method * add some missing code * add missing import * remove the Copy trait from ConsensusValue (#1628) * remove the Copy and Display traits from ConsensusValue since they make it hard to add transaction types that cant implement them * add back display * fmt Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Chris Beck <beck.ct@gmail.com> * Support reaching consensus on MintConfigTxs (#1630) * initial work on stubbing out SetMintConfigTx * MintTxManager replaces stubs * grpc api * fmt * mint client and misc improvements * interate towards tx working * actual validation taking place * iterate * append block from client works * wip * rename and lint * fix nonce length * comine, cleanups, validate that nonce is not already in ledger * cleanups * lint * make test code reusable * add tests * structopt -> clap * rebase fixes * fix test * Update consensus/mint-client/src/config.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * address review comments * Update transaction/core/test-utils/src/mint.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * use dedup_by+truncate * renames * undo incorrect change * typo Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * Support for reaching consensus on MintTx, mint client improvements (#1641) * stub out ProposeMintTx * expose get_active_mint_config_for_mint_tx, more plumbing * undo wrong change * MintTxManager impls for MintTx * mint client support subcommands * basic MintTx flow works, getting NoOutputs * mobilecoind api filtering for token_id * minting is working :) * client improvements, local network script defaults to having two mintable tokens * tests * more tests yay * testsssssssss * test fixes and linting * try without block version * back to block v3 * Update consensus/service/src/api/client_api_service.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * new line Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * Update ledger/db/src/mint_tx_store.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * pr comments * improve comment * use const * Update ledger/db/src/mint_tx_store.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * lint * add MasterMintersMap * pass MasterMintersMap around * enclave validates MintConfigTxs * fix typo * lint * more lint * fix block index * try less concurrency * Revert "try less concurrency" This reverts commit 0e4209f. Co-authored-by: sugargoat <sugargoat@mobilecoin.com> Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Chris Beck <beck.ct@gmail.com>
* Add master minters configuration to TokensConfig (#1504) * minting configuration wip * fmt * fix indent * fix test * add test, be more aggressive about validation * use serde(with=...) * one line * Minting data types and initial LedgerDb support (#1537) * initial mint data structures * basic mint config in ledger * basic get/set test * another test * update total minted api+tests * add migration code * enforce limit * lock and lint * fmt * update comment and remove pub * update lock files * misc pr review fixes * add a test for setting an active configuration with no configs * small fixes * use PEM encoding for signers * fix tag * ensure total minted amount cannot decrease * use inconsistent_digit_grouping to make version numbers more readable * fmt * MintTx/Config protobuf conversions (#1558) * add external.proto minting messages and api conversion traits * tests * mint tx conversions * lint * fix module name * Store mint-related transations in LedgerDb (#1587) * wip * remove BlockContents::new to make adding new fields less tedious * fix typos/lints * add todo * fix typos * more defaults * tests * iterate * more tests * remove unneeded public api * more tests * more tests * stricter validation * reorganize code * lint * add mint migration code * mint_tx_store test no. 1 * dont allow overwriting existing blocks, iterate on test * pr fixes * lint * more tests * add test * remove unneeded type declaration * Update ledger/db/src/mint_config_store.rs Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * rename test to better explain what its testing * be more strict about having outputs when MintTxs are present Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * Expose LedgerDb API for looking up txs by nonce (#1602) * wip * remove BlockContents::new to make adding new fields less tedious * fix typos/lints * add todo * fix typos * more defaults * tests * iterate * more tests * remove unneeded public api * more tests * more tests * stricter validation * reorganize code * lint * add mint migration code * mint_tx_store test no. 1 * dont allow overwriting existing blocks, iterate on test * pr fixes * lint * more tests * add test * remove unneeded type declaration * add public ledger api for looking up mint txs by nonce, change to return block index since that is more useful * missing mock changes * fix fmt * Update ledger/db/src/mint_config_store.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * fix typo * Update ledger/db/src/mint_config_store.rs Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * rename test to better explain what its testing * be more strict about having outputs when MintTxs are present * add public ledger api for looking up mint txs by nonce, change to return block index since that is more useful Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * Minting transaction validation (#1593) * wip * remove BlockContents::new to make adding new fields less tedious * fix typos/lints * add todo * fix typos * more defaults * tests * iterate * more tests * remove unneeded public api * more tests * more tests * stricter validation * reorganize code * lint * add mint migration code * mint_tx_store test no. 1 * dont allow overwriting existing blocks, iterate on test * pr fixes * lint * more tests * add test * remove unneeded type declaration * add public ledger api for looking up mint txs by nonce, change to return block index since that is more useful * missing mock changes * fix fmt * Update ledger/db/src/mint_config_store.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * fix typo * Update ledger/db/src/mint_config_store.rs Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * rename test to better explain what its testing * be more strict about having outputs when MintTxs are present * add public ledger api for looking up mint txs by nonce, change to return block index since that is more useful * initial work on validation * SetMintConfigTx validation + tests * reorganize * MintTx validation and tests * lint * add comments * update comments * Update transaction/core/src/mint/validation/common.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * Update transaction/core/src/mint/validation/config.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * address pr review comment * make nonce constant length Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> Co-authored-by: sugargoat <sugargoat@mobilecoin.com> * SetMintConfigTx -> MintConfigTx (#1607) * SetMintConfigTx -> MintConfigTx * more renames * Small fixes following the confidential-token-id merging (#1609) * post rebase fixes * fix tests * Eran/merge master 2022 03 14 (#1629) * Update grpcio to 0.10 (#1592) * Bump pretty_assertions from 1.1.0 to 1.2.0 (#1610) Bumps [pretty_assertions](https://github.com/colin-kiegel/rust-pretty-assertions) from 1.1.0 to 1.2.0. - [Release notes](https://github.com/colin-kiegel/rust-pretty-assertions/releases) - [Changelog](https://github.com/colin-kiegel/rust-pretty-assertions/blob/main/CHANGELOG.md) - [Commits](https://github.com/colin-kiegel/rust-pretty-assertions/commits) --- updated-dependencies: - dependency-name: pretty_assertions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * delete slam, fixes #1574 (#1611) slam is no longer needed because fog-distro, which began life as a fork of it, has superceded it and slam is no longer used in CD * introduce FormBlockInputs and break out some code from form_block into its own method (#1625) * introduce FormBlockInputs and break out some code from form_block into its own method * add some missing code * add missing import * remove the Copy trait from ConsensusValue (#1628) * remove the Copy and Display traits from ConsensusValue since they make it hard to add transaction types that cant implement them * add back display * fmt Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Chris Beck <beck.ct@gmail.com> * Support reaching consensus on MintConfigTxs (#1630) * initial work on stubbing out SetMintConfigTx * MintTxManager replaces stubs * grpc api * fmt * mint client and misc improvements * interate towards tx working * actual validation taking place * iterate * append block from client works * wip * rename and lint * fix nonce length * comine, cleanups, validate that nonce is not already in ledger * cleanups * lint * make test code reusable * add tests * structopt -> clap * rebase fixes * fix test * Update consensus/mint-client/src/config.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * address review comments * Update transaction/core/test-utils/src/mint.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * use dedup_by+truncate * renames * undo incorrect change * typo Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * Support for reaching consensus on MintTx, mint client improvements (#1641) * stub out ProposeMintTx * expose get_active_mint_config_for_mint_tx, more plumbing * undo wrong change * MintTxManager impls for MintTx * mint client support subcommands * basic MintTx flow works, getting NoOutputs * mobilecoind api filtering for token_id * minting is working :) * client improvements, local network script defaults to having two mintable tokens * tests * more tests yay * testsssssssss * test fixes and linting * try without block version * back to block v3 * Update consensus/service/src/api/client_api_service.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * new line Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * Update ledger/db/src/mint_tx_store.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * pr comments * improve comment * use const * support multiple configs and multiple signers * reusable config objects * support multiple signers * offline flow pt 1 * offline flow pt 2 * remove unneeded dep * Update consensus/mint-client/src/bin/main.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * Update consensus/mint-client/src/config.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * Update consensus/mint-client/src/config.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * Update consensus/mint-client/src/config.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * Update consensus/mint-client/src/config.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * Update consensus/mint-client/src/config.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * fix incorrect suggestion, DRY nonce generation * improve usage doc * DRY file loading * Trigger CI * Update consensus/mint-client/src/bin/main.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * Update consensus/mint-client/src/config.rs Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> * pr fixes Co-authored-by: sugargoat <sugargoat@mobilecoin.com> Co-authored-by: Remoun Metyas <remoun@mobilecoin.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Chris Beck <beck.ct@gmail.com>
Motivation
Similarly to #1630, we need to support submitting a
MintTx
to a consensus node, have it go through SCP, and end in the ledger together with TxOuts that are created as a result of the minting.This PR provides that functionality.
In this PR
ProposeMintTx
.TxOut
s.mc-consensus-mint-client
utility.Future Work
MintConfig
s when generatingMintConfigTx
sRunning locally
You will need to run the local network, see https://github.com/mobilecoinfoundation/mobilecoin/blob/master/tools/local-network/README.md for details on how to do that.
The local network script has been changed such that it has two mintable tokens, and the master minter keys are stored in
/tmp/mc-local-network/minting-keys/master-minter1
(for token id 1) and/tmp/mc-local-network/minting-keys/master-minter2
(for token id 2).Once the network is running, you need to propose a
MintConfigTx
in order to configure a minting configuration. For example, to do it for the 1st token:./target/release/mc-consensus-mint-client generate-and-submit-mint-config-tx --node insecure-mc://localhost:3200/ --signing-key /tmp/mc-local-network/minting-keys/master-minter1 --token-id 1
The version of the minting client in this PR generates a single minting configuration, with a hardcoded amount (1000) and hardcoded signer key that is the same signing key that is used to sign the transaction. In real world, these keys would be different. That improvement would come in a future PR.
Once you successfully submitted a
MintConfigTx
, you should be able to mint to a b58 address of your choice:./target/release/mc-consensus-mint-client generate-and-submit-mint-tx --node insecure-mc://localhost:3200/ --signing-key /tmp/mc-local-network/minting-keys/master-minter1 --recipient 8RwFxr8HXWDBozY7nqNcpuPFgj4o2XskkvnmT8gqSiN1jDUhLT5LpRK1M4aJ4huDvvkbby82rUeuRfCicVEKzYoqsbHkwcDHvE7AgxQ5aNM --token-id 1 --amount 1
To test that the minting worked, I used mobilecoind. The local network starts mobilecoind (on token id 0) and I ran another instance:
./target/release/mobilecoind --ledger-db /tmp/mc-local-network/mobilecoind-ledger-db1 --poll-interval 1 --mobilecoind-db /tmp/mc-local-network/mobilecoind-db1 --listen-uri insecure-mobilecoind://0.0.0.0:4445/ --watcher-db /tmp/mc-local-network/watcher-db1 --peer insecure-mc://localhost:3200/ --peer insecure-mc://localhost:3201/ --peer insecure-mc://localhost:3202/ --tx-source-url file:///tmp/mc-local-network/node-ledger-distribution-0 --tx-source-url file:///tmp/mc-local-network/node-ledger-distribution-1 --tx-source-url file:///tmp/mc-local-network/node-ledger-distribution-2 --token-id 1
I then used the mobilecoind python stuff to test this. I created a virtualenv (
python3 -mvenv env
), activated it (. ./env/bin/activate
), installed the mobilecoin python lib (cd mobilecoind/clients/python/lib; python setup.py install
) and then ran this script: