Skip to content

Commit

Permalink
Merge branch 'murisi/disable-encryption' (#1636)
Browse files Browse the repository at this point in the history
* murisi/disable-encryption:
  Added a changelog entry.
  Stop encrypting transactions in tests.
  Disable encrypting transactions when sending.
  • Loading branch information
brentstone committed Jul 5, 2023
2 parents 549c08f + 9028fe2 commit 601d571
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 89 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/1636-disable-encryption.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Disable encryption when sending transactions
([\#1636](https://github.com/anoma/namada/pull/1636))
12 changes: 2 additions & 10 deletions apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,8 @@ mod test_finalize_block {
wrapper.set_code(Code::new(
format!("transaction data: {}", i).as_bytes().to_owned(),
));
wrapper.encrypt(&Default::default());
wrapper.add_section(Section::Signature(Signature::new(
vec![wrapper.header_hash(), wrapper.sections[0].get_hash()],
wrapper.sechashes(),
&keypair,
)));
if i > 1 {
Expand Down Expand Up @@ -1067,7 +1066,6 @@ mod test_finalize_block {
outer_tx.set_data(Data::new(
String::from("transaction data").as_bytes().to_owned(),
));
outer_tx.encrypt(&Default::default());
shell.enqueue_tx(outer_tx.clone());

outer_tx.update_header(TxType::Decrypted(DecryptedTx::Decrypted {
Expand Down Expand Up @@ -1193,7 +1191,6 @@ mod test_finalize_block {
.as_bytes()
.to_owned(),
));
outer_tx.encrypt(&Default::default());
shell.enqueue_tx(outer_tx.clone());
outer_tx.update_header(TxType::Decrypted(DecryptedTx::Decrypted {
#[cfg(not(feature = "mainnet"))]
Expand Down Expand Up @@ -1230,12 +1227,8 @@ mod test_finalize_block {
.as_bytes()
.to_owned(),
));
wrapper_tx.encrypt(&Default::default());
wrapper_tx.add_section(Section::Signature(Signature::new(
vec![
wrapper_tx.header_hash(),
wrapper_tx.sections[0].get_hash(),
],
wrapper_tx.sechashes(),
&keypair,
)));
valid_txs.push(wrapper_tx.clone());
Expand Down Expand Up @@ -1778,7 +1771,6 @@ mod test_finalize_block {
"Encrypted transaction data".as_bytes().to_owned(),
));
let mut decrypted_tx = wrapper_tx.clone();
wrapper_tx.encrypt(&Default::default());

decrypted_tx.update_header(TxType::Decrypted(DecryptedTx::Decrypted {
#[cfg(not(feature = "mainnet"))]
Expand Down
11 changes: 2 additions & 9 deletions apps/src/lib/node/ledger/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,6 @@ mod test_utils {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned()));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.encrypt(&Default::default());

shell.wl_storage.storage.tx_queue.push(TxInQueue {
tx: wrapper,
Expand Down Expand Up @@ -1341,7 +1340,6 @@ mod test_mempool_validate {
unsigned_wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned()));
unsigned_wrapper
.set_data(Data::new("transaction data".as_bytes().to_owned()));
unsigned_wrapper.encrypt(&Default::default());

let mut result = shell.mempool_validate(
unsigned_wrapper.to_bytes().as_ref(),
Expand Down Expand Up @@ -1378,12 +1376,8 @@ mod test_mempool_validate {
invalid_wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned()));
invalid_wrapper
.set_data(Data::new("transaction data".as_bytes().to_owned()));
invalid_wrapper.encrypt(&Default::default());
invalid_wrapper.add_section(Section::Signature(Signature::new(
vec![
invalid_wrapper.header_hash(),
invalid_wrapper.sections[0].get_hash(),
],
invalid_wrapper.sechashes(),
&keypair,
)));

Expand Down Expand Up @@ -1446,9 +1440,8 @@ mod test_mempool_validate {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned()));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.encrypt(&Default::default());
wrapper.add_section(Section::Signature(Signature::new(
vec![wrapper.header_hash(), wrapper.sections[0].get_hash()],
wrapper.sechashes(),
&keypair,
)));

Expand Down
25 changes: 7 additions & 18 deletions apps/src/lib/node/ledger/shell/prepare_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ mod test_prepare_proposal {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned()));
wrapper.set_data(Data::new("transaction_data".as_bytes().to_owned()));
wrapper.encrypt(&Default::default());
let wrapper = wrapper.to_bytes();
#[allow(clippy::redundant_clone)]
let req = RequestPrepareProposal {
Expand Down Expand Up @@ -371,9 +370,8 @@ mod test_prepare_proposal {
tx.set_data(Data::new(
format!("transaction data: {}", i).as_bytes().to_owned(),
));
tx.encrypt(&Default::default());
tx.add_section(Section::Signature(Signature::new(
vec![tx.header_hash(), tx.sections[0].get_hash()],
tx.sechashes(),
&keypair,
)));

Expand Down Expand Up @@ -438,9 +436,8 @@ mod test_prepare_proposal {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned()));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.encrypt(&Default::default());
wrapper.add_section(Section::Signature(Signature::new(
vec![wrapper.header_hash(), wrapper.sections[0].get_hash()],
wrapper.sechashes(),
&keypair,
)));

Expand Down Expand Up @@ -490,9 +487,8 @@ mod test_prepare_proposal {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned()));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.encrypt(&Default::default());
wrapper.add_section(Section::Signature(Signature::new(
vec![wrapper.header_hash(), wrapper.sections[0].get_hash()],
wrapper.sechashes(),
&keypair,
)));

Expand Down Expand Up @@ -531,9 +527,8 @@ mod test_prepare_proposal {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned()));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.encrypt(&Default::default());
wrapper.add_section(Section::Signature(Signature::new(
vec![wrapper.header_hash(), wrapper.sections[0].get_hash()],
wrapper.sechashes(),
&keypair,
)));
let inner_unsigned_hash =
Expand Down Expand Up @@ -586,9 +581,8 @@ mod test_prepare_proposal {
wrapper.set_code(tx_code.clone());
let tx_data = Data::new("transaction data".as_bytes().to_owned());
wrapper.set_data(tx_data.clone());
wrapper.encrypt(&Default::default());
wrapper.add_section(Section::Signature(Signature::new(
vec![wrapper.header_hash(), wrapper.sections[0].get_hash()],
wrapper.sechashes(),
&keypair,
)));

Expand All @@ -608,12 +602,8 @@ mod test_prepare_proposal {
new_wrapper.header.timestamp = wrapper.header.timestamp;
new_wrapper.set_code(tx_code);
new_wrapper.set_data(tx_data);
new_wrapper.encrypt(&Default::default());
new_wrapper.add_section(Section::Signature(Signature::new(
vec![
new_wrapper.header_hash(),
new_wrapper.sections[0].get_hash(),
],
wrapper.sechashes(),
&keypair,
)));

Expand Down Expand Up @@ -654,9 +644,8 @@ mod test_prepare_proposal {
wrapper_tx.set_code(Code::new("wasm_code".as_bytes().to_owned()));
wrapper_tx
.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper_tx.encrypt(&Default::default());
wrapper_tx.add_section(Section::Signature(Signature::new(
vec![wrapper_tx.header_hash(), wrapper_tx.sections[0].get_hash()],
wrapper_tx.sechashes(),
&keypair,
)));

Expand Down
51 changes: 12 additions & 39 deletions apps/src/lib/node/ledger/shell/process_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,6 @@ mod test_process_proposal {
outer_tx.header.chain_id = shell.chain_id.clone();
outer_tx.set_code(Code::new("wasm_code".as_bytes().to_owned()));
outer_tx.set_data(Data::new("transaction data".as_bytes().to_owned()));
outer_tx.encrypt(&Default::default());
let tx = outer_tx.to_bytes();
#[allow(clippy::redundant_clone)]
let request = ProcessProposal {
Expand Down Expand Up @@ -594,9 +593,8 @@ mod test_process_proposal {
outer_tx.header.chain_id = shell.chain_id.clone();
outer_tx.set_code(Code::new("wasm_code".as_bytes().to_owned()));
outer_tx.set_data(Data::new("transaction data".as_bytes().to_owned()));
outer_tx.encrypt(&Default::default());
outer_tx.add_section(Section::Signature(Signature::new(
vec![outer_tx.header_hash(), outer_tx.sections[0].get_hash()],
outer_tx.sechashes(),
&keypair,
)));
let mut new_tx = outer_tx.clone();
Expand Down Expand Up @@ -658,9 +656,8 @@ mod test_process_proposal {
outer_tx.header.chain_id = shell.chain_id.clone();
outer_tx.set_code(Code::new("wasm_code".as_bytes().to_owned()));
outer_tx.set_data(Data::new("transaction data".as_bytes().to_owned()));
outer_tx.encrypt(&Default::default());
outer_tx.add_section(Section::Signature(Signature::new(
vec![outer_tx.header_hash(), outer_tx.sections[0].get_hash()],
outer_tx.sechashes(),
&keypair,
)));

Expand Down Expand Up @@ -725,9 +722,8 @@ mod test_process_proposal {
outer_tx.header.chain_id = shell.chain_id.clone();
outer_tx.set_code(Code::new("wasm_code".as_bytes().to_owned()));
outer_tx.set_data(Data::new("transaction data".as_bytes().to_owned()));
outer_tx.encrypt(&Default::default());
outer_tx.add_section(Section::Signature(Signature::new(
vec![outer_tx.header_hash(), outer_tx.sections[0].get_hash()],
outer_tx.sechashes(),
&keypair,
)));

Expand Down Expand Up @@ -778,7 +774,6 @@ mod test_process_proposal {
outer_tx.set_data(Data::new(
format!("transaction data: {}", i).as_bytes().to_owned(),
));
outer_tx.encrypt(&Default::default());
shell.enqueue_tx(outer_tx.clone());

outer_tx.update_header(TxType::Decrypted(DecryptedTx::Decrypted {
Expand Down Expand Up @@ -835,7 +830,6 @@ mod test_process_proposal {
tx.header.chain_id = shell.chain_id.clone();
tx.set_code(Code::new("wasm_code".as_bytes().to_owned()));
tx.set_data(Data::new("transaction data".as_bytes().to_owned()));
tx.encrypt(&Default::default());
shell.enqueue_tx(tx.clone());

tx.header.tx_type = TxType::Decrypted(DecryptedTx::Undecryptable);
Expand Down Expand Up @@ -885,7 +879,6 @@ mod test_process_proposal {
tx.set_data(Data::new("transaction data".as_bytes().to_owned()));
tx.set_code_sechash(Hash([0u8; 32]));
tx.set_data_sechash(Hash([0u8; 32]));
tx.encrypt(&Default::default());

shell.enqueue_tx(tx.clone());

Expand Down Expand Up @@ -1034,9 +1027,8 @@ mod test_process_proposal {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned()));
wrapper.encrypt(&Default::default());
wrapper.add_section(Section::Signature(Signature::new(
vec![wrapper.header_hash(), wrapper.sections[0].get_hash()],
wrapper.sechashes(),
&keypair,
)));

Expand Down Expand Up @@ -1109,9 +1101,8 @@ mod test_process_proposal {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned()));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.encrypt(&Default::default());
wrapper.add_section(Section::Signature(Signature::new(
vec![wrapper.header_hash(), wrapper.sections[0].get_hash()],
wrapper.sechashes(),
&keypair,
)));

Expand Down Expand Up @@ -1167,9 +1158,8 @@ mod test_process_proposal {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned()));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.encrypt(&Default::default());
wrapper.add_section(Section::Signature(Signature::new(
vec![wrapper.header_hash(), wrapper.sections[0].get_hash()],
wrapper.sechashes(),
&keypair,
)));
let inner_unsigned_hash =
Expand Down Expand Up @@ -1258,9 +1248,8 @@ mod test_process_proposal {
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned()));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
let mut new_wrapper = wrapper.clone();
wrapper.encrypt(&Default::default());
wrapper.add_section(Section::Signature(Signature::new(
vec![wrapper.header_hash(), wrapper.sections[0].get_hash()],
wrapper.sechashes(),
&keypair,
)));
let inner_unsigned_hash =
Expand All @@ -1277,12 +1266,8 @@ mod test_process_proposal {
#[cfg(not(feature = "mainnet"))]
None,
))));
new_wrapper.encrypt(&Default::default());
new_wrapper.add_section(Section::Signature(Signature::new(
vec![
new_wrapper.header_hash(),
new_wrapper.sections[0].get_hash(),
],
new_wrapper.sechashes(),
&keypair,
)));

Expand Down Expand Up @@ -1333,9 +1318,8 @@ mod test_process_proposal {
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned()));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
let mut protocol_tx = wrapper.clone();
wrapper.encrypt(&Default::default());
wrapper.add_section(Section::Signature(Signature::new(
vec![wrapper.header_hash(), wrapper.sections[0].get_hash()],
wrapper.sechashes(),
&keypair,
)));

Expand Down Expand Up @@ -1401,17 +1385,12 @@ mod test_process_proposal {
wrapper
.set_data(Data::new("new transaction data".as_bytes().to_owned()));
let mut decrypted = wrapper.clone();
wrapper.encrypt(&Default::default());

decrypted.update_header(TxType::Decrypted(DecryptedTx::Decrypted {
has_valid_pow: false,
}));
decrypted.add_section(Section::Signature(Signature::new(
vec![
decrypted.header_hash(),
decrypted.sections[0].get_hash(),
decrypted.sections[1].get_hash(),
],
decrypted.sechashes(),
&keypair,
)));
let wrapper_in_queue = TxInQueue {
Expand Down Expand Up @@ -1465,9 +1444,8 @@ mod test_process_proposal {
wrapper.header.expiration = Some(DateTimeUtc::now());
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned()));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.encrypt(&Default::default());
wrapper.add_section(Section::Signature(Signature::new(
vec![wrapper.header_hash(), wrapper.sections[0].get_hash()],
wrapper.sechashes(),
&keypair,
)));

Expand Down Expand Up @@ -1510,17 +1488,12 @@ mod test_process_proposal {
wrapper
.set_data(Data::new("new transaction data".as_bytes().to_owned()));
let mut decrypted = wrapper.clone();
wrapper.encrypt(&Default::default());

decrypted.update_header(TxType::Decrypted(DecryptedTx::Decrypted {
has_valid_pow: false,
}));
decrypted.add_section(Section::Signature(Signature::new(
vec![
decrypted.header_hash(),
decrypted.sections[0].get_hash(),
decrypted.sections[1].get_hash(),
],
decrypted.sechashes(),
&keypair,
)));
let wrapper_in_queue = TxInQueue {
Expand Down
4 changes: 1 addition & 3 deletions core/src/types/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,8 @@ mod test_process_tx {
))));
tx.set_code(Code::new("wasm code".as_bytes().to_owned()));
tx.set_data(Data::new("transaction data".as_bytes().to_owned()));
tx.encrypt(&Default::default());
tx.add_section(Section::Signature(Signature::new(
vec![tx.header_hash(), tx.sections[0].get_hash()],
tx.sechashes(),
&keypair,
)));

Expand Down Expand Up @@ -367,7 +366,6 @@ mod test_process_tx {
))));
tx.set_code(Code::new("wasm code".as_bytes().to_owned()));
tx.set_data(Data::new("transaction data".as_bytes().to_owned()));
tx.encrypt(&Default::default());
let result = tx.validate_tx().expect_err("Test failed");
assert_matches!(result, TxError::SigError(_));
}
Expand Down
Loading

0 comments on commit 601d571

Please sign in to comment.