Skip to content

Commit 9ed9ebf

Browse files
committed
Merge branch 'origin/murisi/fix-dry-run-header-and-prover' (#1524)
* origin/murisi/fix-dry-run-header-and-prover: Added a changelog entry for this fix. Fixed the header of transactions in dry_run. Fixed local tx prover dependency regression.
2 parents 8ffec72 + e00ce23 commit 9ed9ebf

4 files changed

Lines changed: 16 additions & 19 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- This change will enable usage of the Namada SDK to create MASP transactions
2+
from non-CLI clients. ([\#1524](https://github.com/anoma/namada/pull/1524))

shared/src/ledger/masp.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,20 +1387,13 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
13871387
}
13881388
}
13891389

1390-
let prover = if let Ok(params_dir) = env::var(ENV_VAR_MASP_PARAMS_DIR) {
1391-
let params_dir = PathBuf::from(params_dir);
1392-
let spend_path = params_dir.join(SPEND_NAME);
1393-
let convert_path = params_dir.join(CONVERT_NAME);
1394-
let output_path = params_dir.join(OUTPUT_NAME);
1395-
LocalTxProver::new(&spend_path, &output_path, &convert_path)
1396-
} else {
1397-
LocalTxProver::with_default_location()
1398-
.expect("unable to load MASP Parameters")
1399-
};
14001390
// Build and return the constructed transaction
14011391
builder
14021392
.clone()
1403-
.build(&prover, &FeeRule::non_standard(tx_fee))
1393+
.build(
1394+
&self.utils.local_tx_prover(),
1395+
&FeeRule::non_standard(tx_fee),
1396+
)
14041397
.map(|(tx, metadata)| {
14051398
Some((builder.map_builder(WalletMap), tx, metadata, epoch))
14061399
})

shared/src/ledger/queries/shell.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,18 @@ where
7878
use crate::ledger::storage::write_log::WriteLog;
7979
use crate::proto::Tx;
8080
use crate::types::storage::TxIndex;
81+
use crate::types::transaction::decrypted::DecryptedTx;
82+
use crate::types::transaction::TxType;
8183

8284
let mut gas_meter = BlockGasMeter::default();
8385
let mut write_log = WriteLog::default();
84-
let tx = Tx::try_from(&request.data[..]).into_storage_result()?;
86+
let mut tx = Tx::try_from(&request.data[..]).into_storage_result()?;
87+
tx.update_header(TxType::Decrypted(DecryptedTx::Decrypted {
88+
#[cfg(not(feature = "mainnet"))]
89+
// To be able to dry-run testnet faucet withdrawal, pretend
90+
// that we got a valid PoW
91+
has_valid_pow: true,
92+
}));
8593
let data = protocol::apply_tx(
8694
tx,
8795
request.data.len(),

shared/src/ledger/tx.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ use crate::types::key::*;
4646
use crate::types::masp::TransferTarget;
4747
use crate::types::storage::{Epoch, RESERVED_ADDRESS_PREFIX};
4848
use crate::types::time::DateTimeUtc;
49-
use crate::types::transaction::decrypted::DecryptedTx;
5049
use crate::types::transaction::{pos, InitAccount, TxType, UpdateVp};
5150
use crate::types::{storage, token};
5251
use crate::vm;
@@ -353,12 +352,7 @@ pub async fn submit_reveal_pk_aux<
353352
.await
354353
.unwrap();
355354

356-
let mut tx = Tx::new(TxType::Decrypted(DecryptedTx::Decrypted {
357-
#[cfg(not(feature = "mainnet"))]
358-
// To be able to dry-run testnet faucet withdrawal, pretend
359-
// that we got a valid PoW
360-
has_valid_pow: true,
361-
}));
355+
let mut tx = Tx::new(TxType::Raw);
362356
tx.header.chain_id = args.chain_id.clone().expect("value should be there");
363357
tx.header.expiration = args.expiration;
364358
tx.set_data(Data::new(tx_data));

0 commit comments

Comments
 (0)