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

Update speculative shielded context only when required #2775

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- `gen_shielded_transfer` now takes an extra `update_ctx`
argument to conditionally update the shielded context.
([\#2775](https://github.com/anoma/namada/pull/2775))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Fixed a bug in the client for which the speculative
shielded context was updated event in a dry run.
([\#2775](https://github.com/anoma/namada/pull/2775))
1 change: 1 addition & 0 deletions crates/apps/src/lib/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,7 @@
&target,
&address::testing::nam(),
denominated_amount,
true,

Check warning on line 1023 in crates/apps/src/lib/bench_utils.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/bench_utils.rs#L1023

Added line #L1023 was not covered by tests
),
)
.unwrap()
Expand Down
17 changes: 10 additions & 7 deletions crates/sdk/src/masp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1944,6 +1944,7 @@
target: &TransferTarget,
token: &Address,
amount: token::DenominatedAmount,
update_ctx: bool,

Check warning on line 1947 in crates/sdk/src/masp.rs

View check run for this annotation

Codecov / codecov/patch

crates/sdk/src/masp.rs#L1947

Added line #L1947 was not covered by tests
) -> Result<Option<ShieldedTransfer>, TransferErr> {
// No shielded components are needed when neither source nor destination
// are shielded
Expand Down Expand Up @@ -2291,13 +2292,15 @@
let (masp_tx, metadata) =
builder.build(&prover, &FeeRule::non_standard(U64Sum::zero()))?;

// Cache the generated transfer
let mut shielded_ctx = context.shielded_mut().await;
shielded_ctx
.pre_cache_transaction(
context, &masp_tx, source, target, token, epoch,
)
.await?;
if update_ctx {

Check warning on line 2295 in crates/sdk/src/masp.rs

View check run for this annotation

Codecov / codecov/patch

crates/sdk/src/masp.rs#L2295

Added line #L2295 was not covered by tests
// Cache the generated transfer
let mut shielded_ctx = context.shielded_mut().await;
shielded_ctx
.pre_cache_transaction(
context, &masp_tx, source, target, token, epoch,
)
.await?;
}

Check warning on line 2303 in crates/sdk/src/masp.rs

View check run for this annotation

Codecov / codecov/patch

crates/sdk/src/masp.rs#L2297-L2303

Added lines #L2297 - L2303 were not covered by tests

Ok(Some(ShieldedTransfer {
builder: builder_clone,
Expand Down
1 change: 1 addition & 0 deletions crates/sdk/src/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
&target,
&args.fee_token,
fee_amount,
!(args.dry_run || args.dry_run_wrapper)

Check warning on line 519 in crates/sdk/src/signing.rs

View check run for this annotation

Codecov / codecov/patch

crates/sdk/src/signing.rs#L519

Added line #L519 was not covered by tests
)
.await
{
Expand Down
6 changes: 5 additions & 1 deletion crates/sdk/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2181,6 +2181,7 @@
&TransferTarget::Address(Address::Internal(InternalAddress::Ibc)),
&args.token,
validated_amount,
!(args.tx.dry_run || args.tx.dry_run_wrapper),

Check warning on line 2184 in crates/sdk/src/tx.rs

View check run for this annotation

Codecov / codecov/patch

crates/sdk/src/tx.rs#L2184

Added line #L2184 was not covered by tests
)
.await?;
let shielded_tx_epoch = shielded_parts.as_ref().map(|trans| trans.0.epoch);
Expand Down Expand Up @@ -2504,6 +2505,7 @@
&args.target,
&args.token,
validated_amount,
!(args.tx.dry_run || args.tx.dry_run_wrapper),

Check warning on line 2508 in crates/sdk/src/tx.rs

View check run for this annotation

Codecov / codecov/patch

crates/sdk/src/tx.rs#L2508

Added line #L2508 was not covered by tests
)
.await?;
let shielded_tx_epoch = shielded_parts.as_ref().map(|trans| trans.0.epoch);
Expand Down Expand Up @@ -2570,6 +2572,7 @@
target: &TransferTarget,
token: &Address,
amount: token::DenominatedAmount,
update_ctx: bool,

Check warning on line 2575 in crates/sdk/src/tx.rs

View check run for this annotation

Codecov / codecov/patch

crates/sdk/src/tx.rs#L2575

Added line #L2575 was not covered by tests
) -> Result<Option<(ShieldedTransfer, HashSet<AssetData>)>> {
// Precompute asset types to increase chances of success in decoding
let token_map = context.wallet().await.get_addresses();
Expand All @@ -2581,7 +2584,7 @@
.await;
let stx_result =
ShieldedContext::<N::ShieldedUtils>::gen_shielded_transfer(
context, source, target, token, amount,
context, source, target, token, amount, update_ctx,

Check warning on line 2587 in crates/sdk/src/tx.rs

View check run for this annotation

Codecov / codecov/patch

crates/sdk/src/tx.rs#L2587

Added line #L2587 was not covered by tests
)
.await;

Expand Down Expand Up @@ -2877,6 +2880,7 @@
&args.target,
&token,
validated_amount,
true,

Check warning on line 2883 in crates/sdk/src/tx.rs

View check run for this annotation

Codecov / codecov/patch

crates/sdk/src/tx.rs#L2883

Added line #L2883 was not covered by tests
)
.await
.map_err(|err| TxSubmitError::MaspError(err.to_string()))?;
Expand Down
Loading