Skip to content

Commit

Permalink
[breaking][libra framework] delete testnet mint script
Browse files Browse the repository at this point in the history
Now that designated dealers are not subject to dual attestation, his script can now be replaced with ordinary peer-to-peer payments. This PR deletes the script and removes all of its uses.

Closes: diem#5455
  • Loading branch information
sblackshear authored and bors-libra committed Aug 5, 2020
1 parent ea78416 commit 8439536
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 169 deletions.
9 changes: 7 additions & 2 deletions execution/executor-benchmark/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ use storage_interface::{DbReader, DbReaderWriter};
use storage_service::start_storage_service_with_db;
use transaction_builder::{
encode_create_testing_account_script, encode_peer_to_peer_with_metadata_script,
encode_testnet_mint_script,
};

struct AccountData {
Expand Down Expand Up @@ -151,7 +150,13 @@ impl TransactionGenerator {
(i * block_size + j) as u64,
&self.genesis_key,
self.genesis_key.public_key(),
encode_testnet_mint_script(coin1_tag(), account.address, init_account_balance),
encode_peer_to_peer_with_metadata_script(
coin1_tag(),
account.address,
init_account_balance,
vec![],
vec![],
),
);
transactions.push(txn);
}
Expand Down
25 changes: 21 additions & 4 deletions execution/executor-test-helpers/src/integration_test_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use std::{convert::TryFrom, sync::Arc};
use storage_interface::{DbReaderWriter, Order};
use transaction_builder::{
encode_create_testing_account_script, encode_peer_to_peer_with_metadata_script,
encode_testnet_mint_script,
};

pub fn test_execution_with_storage_impl() -> Arc<LibraDB> {
Expand Down Expand Up @@ -112,7 +111,13 @@ pub fn test_execution_with_storage_impl() -> Arc<LibraDB> {
/* sequence_number = */ 0,
genesis_key.clone(),
genesis_key.public_key(),
Some(encode_testnet_mint_script(coin1_tag(), account1, 2_000_000)),
Some(encode_peer_to_peer_with_metadata_script(
coin1_tag(),
account1,
2_000_000,
vec![],
vec![],
)),
);

// Create account2 with 1.2M coins.
Expand All @@ -121,7 +126,13 @@ pub fn test_execution_with_storage_impl() -> Arc<LibraDB> {
/* sequence_number = */ 1,
genesis_key.clone(),
genesis_key.public_key(),
Some(encode_testnet_mint_script(coin1_tag(), account2, 1_200_000)),
Some(encode_peer_to_peer_with_metadata_script(
coin1_tag(),
account2,
1_200_000,
vec![],
vec![],
)),
);

// Create account3 with 1M coins.
Expand All @@ -130,7 +141,13 @@ pub fn test_execution_with_storage_impl() -> Arc<LibraDB> {
/* sequence_number = */ 2,
genesis_key.clone(),
genesis_key.public_key(),
Some(encode_testnet_mint_script(coin1_tag(), account3, 1_000_000)),
Some(encode_peer_to_peer_with_metadata_script(
coin1_tag(),
account3,
1_000_000,
vec![],
vec![],
)),
);

// Transfer 20k coins from account1 to account2.
Expand Down
9 changes: 7 additions & 2 deletions execution/executor/tests/db_bootstrapper_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ use std::{convert::TryFrom, sync::Arc};
use storage_interface::{DbReader, DbReaderWriter};
use transaction_builder::{
encode_create_testing_account_script, encode_peer_to_peer_with_metadata_script,
encode_testnet_mint_script,
};

#[test]
Expand Down Expand Up @@ -137,7 +136,13 @@ fn get_mint_transaction(
/* sequence_number = */ libra_root_seq_num,
libra_root_key.clone(),
libra_root_key.public_key(),
Some(encode_testnet_mint_script(coin1_tag(), *account, amount)),
Some(encode_peer_to_peer_with_metadata_script(
coin1_tag(),
*account,
amount,
vec![],
vec![],
)),
)
}

Expand Down
39 changes: 25 additions & 14 deletions language/e2e-tests/src/tests/transaction_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,12 @@ fn create_child_vasp_all_currencies() {
// mint to the parent VASP
executor.execute_and_apply(
dd.transaction()
.script(encode_testnet_mint_script(
.script(encode_peer_to_peer_with_metadata_script(
account_config::coin1_tag(),
*parent.address(),
amount,
vec![],
vec![],
))
.sequence_number(0)
.sign(),
Expand Down Expand Up @@ -276,10 +278,12 @@ fn create_child_vasp_with_balance() {
// mint to the parent VASP
executor.execute_and_apply(
dd.transaction()
.script(encode_testnet_mint_script(
.script(encode_peer_to_peer_with_metadata_script(
account_config::coin1_tag(),
*parent.address(),
amount,
vec![],
vec![],
))
.sequence_number(0)
.sign(),
Expand Down Expand Up @@ -572,7 +576,6 @@ fn dual_attestation_payment() {
.sequence_number(3)
.sign(),
);
println!("{:?}", output);
assert_aborted_with(output, MISMATCHED_METADATA_SIGNATURE_ERROR_CODE)
}
}
Expand All @@ -585,11 +588,7 @@ fn create_dual_attestation_payment(
ref_id: Vec<u8>,
receiver_compliance_private_key: &Ed25519PrivateKey,
) -> Script {
// UTF8-encoded string "@@$$LIBRA_ATTEST$$@@" without length prefix
let mut domain_separator = vec![
0x40, 0x40, 0x24, 0x24, 0x4C, 0x49, 0x42, 0x52, 0x41, 0x5F, 0x41, 0x54, 0x54, 0x45, 0x53,
0x54, 0x24, 0x24, 0x40, 0x40,
];
let mut domain_separator = b"@@$$LIBRA_ATTEST$$@@".to_vec();
let message = {
let mut msg = ref_id.clone();
msg.append(&mut lcs::to_bytes(&sender_address).unwrap());
Expand Down Expand Up @@ -1110,21 +1109,25 @@ fn account_limits() {
// mint money to both vasp A & B
executor.execute_and_apply(
dd.transaction()
.script(encode_testnet_mint_script(
.script(encode_peer_to_peer_with_metadata_script(
account_config::coin1_tag(),
*vasp_a.address(),
2 * mint_amount,
vec![],
vec![],
))
.sequence_number(0)
.ttl(ttl)
.sign(),
);
executor.execute_and_apply(
dd.transaction()
.script(encode_testnet_mint_script(
.script(encode_peer_to_peer_with_metadata_script(
account_config::coin1_tag(),
*vasp_b.address(),
2 * mint_amount,
vec![],
vec![],
))
.sequence_number(1)
.ttl(ttl)
Expand Down Expand Up @@ -1266,10 +1269,12 @@ fn account_limits() {
// DD deposit fails since vasp A is at inflow limit
let output = executor.execute_transaction(
dd.transaction()
.script(encode_testnet_mint_script(
.script(encode_peer_to_peer_with_metadata_script(
account_config::coin1_tag(),
*vasp_a_child.address(),
1,
vec![],
vec![],
))
.sequence_number(2)
.ttl(ttl)
Expand All @@ -1285,10 +1290,12 @@ fn account_limits() {
// DD deposit now succeeds since window is reset
let output = executor.execute_transaction(
dd.transaction()
.script(encode_testnet_mint_script(
.script(encode_peer_to_peer_with_metadata_script(
account_config::coin1_tag(),
*vasp_a_child.address(),
1,
vec![],
vec![],
))
.sequence_number(2)
.ttl(ttl)
Expand Down Expand Up @@ -1564,10 +1571,12 @@ fn account_limits() {
// DD deposit fails since vasp A is at holding limit
let output = executor.execute_transaction(
dd.transaction()
.script(encode_testnet_mint_script(
.script(encode_peer_to_peer_with_metadata_script(
account_config::coin1_tag(),
*vasp_a_child.address(),
1,
vec![],
vec![],
))
.sequence_number(2)
.ttl(ttl)
Expand All @@ -1584,10 +1593,12 @@ fn account_limits() {
// and because holdings are not reset from one window to the next.
let output = executor.execute_transaction(
dd.transaction()
.script(encode_testnet_mint_script(
.script(encode_peer_to_peer_with_metadata_script(
account_config::coin1_tag(),
*vasp_a_child.address(),
1,
vec![],
vec![],
))
.sequence_number(2)
.ttl(ttl)
Expand Down
8 changes: 4 additions & 4 deletions language/e2e-tests/src/tests/transaction_fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ use move_core_types::{
language_storage::{StructTag, TypeTag},
};
use std::convert::TryFrom;
use transaction_builder::{
encode_burn_txn_fees_script, encode_create_testing_account_script, encode_testnet_mint_script,
};
use transaction_builder::*;

#[test]
fn burn_txn_fees() {
Expand All @@ -41,10 +39,12 @@ fn burn_txn_fees() {

executor.execute_and_apply(
dd.transaction()
.script(encode_testnet_mint_script(
.script(encode_peer_to_peer_with_metadata_script(
account_config::coin1_tag(),
*sender.address(),
10_000_000,
vec![],
vec![],
))
.sequence_number(0)
.sign(),
Expand Down
3 changes: 0 additions & 3 deletions language/stdlib/compiled/src/transaction_scripts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ pub enum StdlibScript {
UpdateAccountLimitWindowInfo,
SetValidatorConfigAndReconfigure,
SetValidatorOperator,
TestnetMint,
TieredMint,
UnfreezeAccount,
UnmintLbr,
Expand Down Expand Up @@ -99,7 +98,6 @@ impl StdlibScript {
UpdateAccountLimitWindowInfo,
SetValidatorConfigAndReconfigure,
SetValidatorOperator,
TestnetMint,
TieredMint,
UnfreezeAccount,
UnmintLbr,
Expand Down Expand Up @@ -211,7 +209,6 @@ impl fmt::Display for StdlibScript {
CreateValidatorAccount => "create_validator_account",
CreateValidatorOperatorAccount => "create_validator_operator_account",
FreezeAccount => "freeze_account",
TestnetMint => "testnet_mint",
MintLbr => "mint_lbr",
ModifyPublishingOption => "modify_publishing_option",
PeerToPeerWithMetadata => "peer_to_peer_with_metadata",
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ The
<code>amount</code> >=
<code><a href="../../modules/doc/DualAttestation.md#0x1_DualAttestation_get_cur_microlibra_limit">DualAttestation::get_cur_microlibra_limit</a></code> LBR and
<code>payer</code> and
<code>payee</code> are distinct entities
(e.g., different VASPs, or a VASP and a DesignatedDealer).
<code>payee</code> are distinct VASPs.
However, a transaction sender can opt in to dual attestation even when it is not required (e.g., a DesignatedDealer -> VASP payment) by providing a non-empty
<code>metadata_signature</code>.
Standardized
<code>metadata</code> LCS format can be found in
<code>libra_types::transaction::metadata::Metadata</code>.
Expand Down
49 changes: 0 additions & 49 deletions language/stdlib/transaction_scripts/doc/testnet_mint.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use 0x1::VASP;
/// `metadata` and an (optional) `metadata_signature` on the message
/// `metadata` | `Signer::address_of(payer)` | `amount` | `DualAttestation::DOMAIN_SEPARATOR`.
/// The `metadata` and `metadata_signature` parameters are only required if `amount` >=
/// `DualAttestation::get_cur_microlibra_limit` LBR and `payer` and `payee` are distinct entities
/// (e.g., different VASPs, or a VASP and a DesignatedDealer).
/// `DualAttestation::get_cur_microlibra_limit` LBR and `payer` and `payee` are distinct VASPs.
/// However, a transaction sender can opt in to dual attestation even when it is not required (e.g., a DesignatedDealer -> VASP payment) by providing a non-empty `metadata_signature`.
/// Standardized `metadata` LCS format can be found in `libra_types::transaction::metadata::Metadata`.
///
/// ## Events
Expand Down
22 changes: 0 additions & 22 deletions language/stdlib/transaction_scripts/testnet_mint.move

This file was deleted.

Loading

0 comments on commit 8439536

Please sign in to comment.