Skip to content
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

Make the consensus enclave aware of the master minters #1684

Merged
merged 29 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9975348
Add master minters configuration to TokensConfig (#1504)
eranrund Feb 22, 2022
bca47f0
Minting data types and initial LedgerDb support (#1537)
eranrund Mar 2, 2022
70d6efb
MintTx/Config protobuf conversions (#1558)
eranrund Mar 2, 2022
46056c3
Store mint-related transations in LedgerDb (#1587)
eranrund Mar 10, 2022
9a1aba3
Expose LedgerDb API for looking up txs by nonce (#1602)
eranrund Mar 11, 2022
4a8639e
Minting transaction validation (#1593)
eranrund Mar 11, 2022
20f43d8
SetMintConfigTx -> MintConfigTx (#1607)
eranrund Mar 11, 2022
6492656
Small fixes following the confidential-token-id merging (#1609)
eranrund Mar 11, 2022
4198b9a
Eran/merge master 2022 03 14 (#1629)
eranrund Mar 15, 2022
b7f1da3
Support reaching consensus on MintConfigTxs (#1630)
eranrund Mar 16, 2022
639d69c
Support for reaching consensus on MintTx, mint client improvements (#…
eranrund Mar 17, 2022
63e779e
Merge branch 'master' into feature/minting
eranrund Mar 17, 2022
c2486d5
Update ledger/db/src/mint_tx_store.rs
eranrund Mar 17, 2022
b2238de
pr comments
eranrund Mar 17, 2022
5ec6dad
improve comment
eranrund Mar 17, 2022
2d8030a
use const
eranrund Mar 17, 2022
b51bc1e
Update ledger/db/src/mint_tx_store.rs
eranrund Mar 17, 2022
169f6d1
Merge branch 'master' into feature/minting
eranrund Mar 21, 2022
17cbe3a
lint
eranrund Mar 21, 2022
794f737
add MasterMintersMap
eranrund Mar 18, 2022
ba0b757
pass MasterMintersMap around
eranrund Mar 18, 2022
59abda3
enclave validates MintConfigTxs
eranrund Mar 18, 2022
56d784c
fix typo
eranrund Mar 22, 2022
c4fcbf2
lint
eranrund Mar 22, 2022
0477dea
more lint
eranrund Mar 22, 2022
7796872
fix block index
eranrund Mar 22, 2022
0e4209f
try less concurrency
eranrund Mar 22, 2022
2918407
Merge branch 'master' into eran/enclave-master-minters
eranrund Mar 22, 2022
44d960d
Revert "try less concurrency"
eranrund Mar 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ commands:
./target/release/sample-keys --num 4 --output-dir fog_keys --fog-report-url 'insecure-fog://localhost:6200' --fog-authority-root $FOG_AUTHORITY_ROOT

./target/release/fog-distribution \
--block-version 3 \
--sample-data-dir . \
--max-threads 1 \
--peer insecure-mc://localhost:3200/ \
Expand Down
31 changes: 31 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ members = [
"consensus/enclave/impl",
"consensus/enclave/measurement",
"consensus/enclave/mock",
"consensus/mint-client",
"consensus/scp",
"consensus/scp/play",
"consensus/service",
Expand Down
3 changes: 3 additions & 0 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ links = "mc-api"
mc-account-keys = { path = "../account-keys" }
mc-attest-core = { path = "../attest/core" }
mc-crypto-keys = { path = "../crypto/keys" }
mc-crypto-multisig = { path = "../crypto/multisig" }
mc-transaction-core = { path = "../transaction/core" }
mc-util-repr-bytes = { path = "../util/repr-bytes" }
mc-util-serial = { path = "../util/serial" }
Expand Down Expand Up @@ -46,3 +47,5 @@ generic-array = "0.14"
pem = "1.0"
prost = { version = "0.9", default-features = false }
rand = "0.8"
rand_core = "0.6"
rand_hc = "0.3"
6 changes: 6 additions & 0 deletions api/proto/blockchain.proto
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ message BlockContents {

// Outputs created in this block.
repeated external.TxOut outputs = 2;

/// mint-config transactions in this block.
repeated external.MintConfigTx mint_config_txs = 3;

/// Mint transactions in this block.
repeated external.MintTx mint_txs = 4;
}

message BlockSignature {
Expand Down
78 changes: 78 additions & 0 deletions api/proto/external.proto
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ message Ed25519Signature {
bytes data = 1;
}

///////////////////////////////////////////////////////////////////////////////
// `mc-crypto-multisig` crate
///////////////////////////////////////////////////////////////////////////////

message Ed25519MultiSig {
repeated Ed25519Signature signatures = 1;
}

message Ed25519SignerSet {
repeated Ed25519Public signers = 1;
uint32 threshold = 2;
}


///////////////////////////////////////////////////////////////////////////////
// `account-keys` crate
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -297,3 +311,67 @@ message VerificationReport {
/// The raw report body JSON, as a byte sequence
string http_body = 3;
}

/// The contents of a mint-tx, which is a transaction to mint new tokens.
message MintTxPrefix {
/// Token ID we are minting.
uint32 token_id = 1;

/// Amount we are minting.
uint64 amount = 2;

/// The destination's public subaddress view key 'C'.
CompressedRistretto view_public_key = 3;

/// The destination's public subaddress spend key `D`.
CompressedRistretto spend_public_key = 4;

/// Nonce, to prevent replay attacks.
bytes nonce = 5;

/// The block index at which this transaction is no longer valid.
uint64 tombstone_block = 6;
}

/// A mint transaction coupled with a signature over it.
message MintTx {
MintTxPrefix prefix = 1;
Ed25519MultiSig signature = 2;
}

/// A minting configuration for a single token ID.
/// The minting configuration specifies who is allowed to submit mint
/// transactions, for which token and at what total limit.
message MintConfig {
/// Token ID this configuration applies to.
uint32 token_id = 1;

/// The set of keys that can sign a minting transaction.
Ed25519SignerSet signer_set = 2;

/// The maximal amount this configuration can mint from the moment it has
/// been applied.
uint64 mint_limit = 3;
}

/// The contents of a mint-config transaction. This transaction alters the
/// minting configuration for a single token ID.
message MintConfigTxPrefix {
/// Token ID we are replacing the configuration set for.
uint32 token_id = 1;

/// The new configuration.
repeated MintConfig configs = 2;

/// Nonce, to prevent replay attacks.
bytes nonce = 3;

/// The block index at which this transaction is no longer valid.
uint64 tombstone_block = 4;
}

/// A mint-config transaction coupled with a signature over it.
message MintConfigTx {
MintConfigTxPrefix prefix = 1;
Ed25519MultiSig signature = 2;
}
6 changes: 5 additions & 1 deletion api/src/convert/archive_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ mod tests {
.map(|block| block.id.clone())
.unwrap_or_else(|| BlockID::try_from(&[1u8; 32][..]).unwrap());

let block_contents = BlockContents::new(vec![key_image.clone()], vec![tx_out.clone()]);
let block_contents = BlockContents {
key_images: vec![key_image.clone()],
outputs: vec![tx_out.clone()],
..Default::default()
};
let block = Block::new(
BlockVersion::ONE,
&parent_block_id,
Expand Down
69 changes: 52 additions & 17 deletions api/src/convert/block_contents.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
//! Convert to/from blockchain::BlockContents

use crate::{blockchain, convert::ConversionError, external};
use mc_transaction_core::{ring_signature::KeyImage, tx, BlockContents};
use protobuf::RepeatedField;
use mc_transaction_core::{
mint::{MintConfigTx, MintTx},
ring_signature::KeyImage,
tx::TxOut,
BlockContents,
};
use std::convert::TryFrom;

impl From<&mc_transaction_core::BlockContents> for blockchain::BlockContents {
fn from(source: &mc_transaction_core::BlockContents) -> Self {
let mut block_contents = blockchain::BlockContents::new();

let key_images: Vec<external::KeyImage> = source
let key_images = source
.key_images
.iter()
.map(external::KeyImage::from)
.collect();

let outputs: Vec<external::TxOut> =
source.outputs.iter().map(external::TxOut::from).collect();
let outputs = source.outputs.iter().map(external::TxOut::from).collect();

block_contents.set_key_images(RepeatedField::from_vec(key_images));
block_contents.set_outputs(RepeatedField::from_vec(outputs));
let mint_config_txs = source
.mint_config_txs
.iter()
.map(external::MintConfigTx::from)
.collect();

let mint_txs = source.mint_txs.iter().map(external::MintTx::from).collect();

block_contents.set_key_images(key_images);
block_contents.set_outputs(outputs);
block_contents.set_mint_config_txs(mint_config_txs);
block_contents.set_mint_txs(mint_txs);
block_contents
}
}
Expand All @@ -28,15 +41,37 @@ impl TryFrom<&blockchain::BlockContents> for mc_transaction_core::BlockContents
type Error = ConversionError;

fn try_from(source: &blockchain::BlockContents) -> Result<Self, Self::Error> {
let mut key_images: Vec<KeyImage> = Vec::new();
for key_image in source.get_key_images() {
key_images.push(KeyImage::try_from(key_image)?);
}

let mut outputs: Vec<tx::TxOut> = Vec::new();
for output in source.get_outputs() {
outputs.push(tx::TxOut::try_from(output)?);
}
Ok(BlockContents::new(key_images, outputs))
let key_images = source
.get_key_images()
.iter()
.map(KeyImage::try_from)
.collect::<Result<_, _>>()?;

let outputs = source
.get_outputs()
.iter()
.map(TxOut::try_from)
.collect::<Result<_, _>>()?;

let mint_config_txs = source
.get_mint_config_txs()
.iter()
.map(MintConfigTx::try_from)
.collect::<Result<_, _>>()?;

let mint_txs = source
.get_mint_txs()
.iter()
.map(MintTx::try_from)
.collect::<Result<_, _>>()?;

// We purposefully do not ..Default::default() here so that new fields are not
// missed.
Ok(BlockContents {
key_images,
outputs,
mint_config_txs,
mint_txs,
})
}
}
Loading