Skip to content

Commit

Permalink
Merge branch 'murisi/fix-dry-run-header' into draft
Browse files Browse the repository at this point in the history
  • Loading branch information
Murisi Tarusenga committed May 25, 2023
2 parents c73eb2c + 16b9734 commit d5331b5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
16 changes: 4 additions & 12 deletions shared/src/ledger/masp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1386,21 +1386,13 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
return Err(builder::Error::InsufficientFunds(additional));
}
}

let prover = if let Ok(params_dir) = env::var(ENV_VAR_MASP_PARAMS_DIR) {
let params_dir = PathBuf::from(params_dir);
let spend_path = params_dir.join(SPEND_NAME);
let convert_path = params_dir.join(CONVERT_NAME);
let output_path = params_dir.join(OUTPUT_NAME);
LocalTxProver::new(&spend_path, &output_path, &convert_path)
} else {
LocalTxProver::with_default_location()
.expect("unable to load MASP Parameters")
};
// Build and return the constructed transaction
builder
.clone()
.build(&prover, &FeeRule::non_standard(tx_fee))
.build(
&self.utils.local_tx_prover(),
&FeeRule::non_standard(tx_fee),
)
.map(|(tx, metadata)| {
Some((builder.map_builder(WalletMap), tx, metadata, epoch))
})
Expand Down
10 changes: 9 additions & 1 deletion shared/src/ledger/queries/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,18 @@ where
use crate::ledger::storage::write_log::WriteLog;
use crate::proto::Tx;
use crate::types::storage::TxIndex;
use crate::types::transaction::decrypted::DecryptedTx;
use crate::types::transaction::TxType;

let mut gas_meter = BlockGasMeter::default();
let mut write_log = WriteLog::default();
let tx = Tx::try_from(&request.data[..]).into_storage_result()?;
let mut tx = Tx::try_from(&request.data[..]).into_storage_result()?;
tx.update_header(TxType::Decrypted(DecryptedTx::Decrypted {
#[cfg(not(feature = "mainnet"))]
// To be able to dry-run testnet faucet withdrawal, pretend
// that we got a valid PoW
has_valid_pow: true,
}));
let data = protocol::apply_tx(
tx,
request.data.len(),
Expand Down
8 changes: 1 addition & 7 deletions shared/src/ledger/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ use crate::types::key::*;
use crate::types::masp::TransferTarget;
use crate::types::storage::{Epoch, RESERVED_ADDRESS_PREFIX};
use crate::types::time::DateTimeUtc;
use crate::types::transaction::decrypted::DecryptedTx;
use crate::types::transaction::{pos, InitAccount, TxType, UpdateVp};
use crate::types::{storage, token};
use crate::vm;
Expand Down Expand Up @@ -346,12 +345,7 @@ pub async fn submit_reveal_pk_aux<
println!("Submitting a tx to reveal the public key for address {addr}...");
let tx_data = public_key.try_to_vec().map_err(Error::EncodeKeyFailure)?;
let tx_code = args.tx_reveal_code_path.clone();
let mut tx = Tx::new(TxType::Decrypted(DecryptedTx::Decrypted {
#[cfg(not(feature = "mainnet"))]
// To be able to dry-run testnet faucet withdrawal, pretend
// that we got a valid PoW
has_valid_pow: true,
}));
let mut tx = Tx::new(TxType::Raw);
tx.header.chain_id = args.chain_id.clone().expect("value should be there");
tx.header.expiration = args.expiration;
tx.set_data(Data::new(tx_data));
Expand Down
Binary file modified wasm_for_tests/tx_write_storage_key.wasm
Binary file not shown.

0 comments on commit d5331b5

Please sign in to comment.