Skip to content

Commit

Permalink
Stop creating redundant transaction descriptors.
Browse files Browse the repository at this point in the history
  • Loading branch information
murisi committed Jan 11, 2024
1 parent 238d52a commit 25cb341
Show file tree
Hide file tree
Showing 55 changed files with 45 additions and 36 deletions.
45 changes: 27 additions & 18 deletions sdk/src/masp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1552,13 +1552,17 @@ impl<U: ShieldedUtils + MaybeSend + MaybeSync> ShieldedContext<U> {
let script = TransparentAddress(hash.into());
for (denom, asset_type) in MaspDenom::iter().zip(asset_types.iter())
{
builder
.add_transparent_input(TxOut {
asset_type: *asset_type,
value: denom.denominate(&amount.amount()),
address: script,
})
.map_err(builder::Error::TransparentBuild)?;
let amount_part = denom.denominate(&amount.amount());
// Skip adding an input if its value is 0
if amount_part != 0 {
builder
.add_transparent_input(TxOut {
asset_type: *asset_type,
value: amount_part,
address: script,
})
.map_err(builder::Error::TransparentBuild)?;
}
}
}

Expand All @@ -1568,15 +1572,19 @@ impl<U: ShieldedUtils + MaybeSend + MaybeSync> ShieldedContext<U> {
let ovk_opt = spending_key.map(|x| x.expsk.ovk);
for (denom, asset_type) in MaspDenom::iter().zip(asset_types.iter())
{
builder
.add_sapling_output(
ovk_opt,
pa.into(),
*asset_type,
denom.denominate(&amount.amount()),
memo.clone(),
)
.map_err(builder::Error::SaplingBuild)?;
let amount_part = denom.denominate(&amount.amount());
// Skip adding a shielded output if its value is 0
if amount_part != 0 {
builder
.add_sapling_output(
ovk_opt,
pa.into(),
*asset_type,
amount_part,
memo.clone(),
)
.map_err(builder::Error::SaplingBuild)?;
}
}
} else {
// Embed the transparent target address into the shielded
Expand All @@ -1595,6 +1603,7 @@ impl<U: ShieldedUtils + MaybeSend + MaybeSync> ShieldedContext<U> {
for (denom, asset_type) in MaspDenom::iter().zip(asset_types.iter())
{
let vout = denom.denominate(&amount.amount());
// Skip adding a transparent output if its value is 0
if vout != 0 {
builder
.add_transparent_output(
Expand All @@ -1621,7 +1630,7 @@ impl<U: ShieldedUtils + MaybeSend + MaybeSync> ShieldedContext<U> {
})?
.components()
{
if *amt >= 0 {
if *amt > 0 {
// Send the change in this asset type back to the sender
builder
.add_sapling_output(
Expand All @@ -1632,7 +1641,7 @@ impl<U: ShieldedUtils + MaybeSend + MaybeSync> ShieldedContext<U> {
memo.clone(),
)
.map_err(builder::Error::SaplingBuild)?;
} else {
} else if *amt < 0 {
// Record how much of the current asset type we are short by
additional += I128Sum::from_nonnegative(*asset_type, -*amt)
.map_err(|()| {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
36 changes: 18 additions & 18 deletions wasm/checksums.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"tx_become_validator.wasm": "tx_become_validator.bd7ff3b0a23ed75808a86228882aab146e8049990dcdf6b626fe2d7f21edb036.wasm",
"tx_bond.wasm": "tx_bond.fc2a23de87031579eb9478994bd6c921c4e510cdc6fe129b447eeb0502252413.wasm",
"tx_bridge_pool.wasm": "tx_bridge_pool.3dd5d65709cb1fe54374ed82932eeb3ab88e5398563ef92156efcffa6d7a8f9c.wasm",
"tx_change_consensus_key.wasm": "tx_change_consensus_key.4ef03df9400428f4d3d19b233c98a1993081cc174253958d54ab2b3cad9b95ec.wasm",
"tx_change_validator_commission.wasm": "tx_change_validator_commission.fd0c0344b22f02fd244e15cfd2b14e93150cd2e3f36596dfd38789cd3703fa8e.wasm",
"tx_change_validator_metadata.wasm": "tx_change_validator_metadata.a494c345ae3a3cfcd96871d8e735d559a493b56d8dae4552a3369808752f8ba4.wasm",
"tx_claim_rewards.wasm": "tx_claim_rewards.1eabd6d53204790e5be0b97f68200ff1d3773ffb9bfef433e95efd215bf8be60.wasm",
"tx_deactivate_validator.wasm": "tx_deactivate_validator.a983fe31390f2c1a67bc6b93037ffd260d5b25e10fd91f4fa0105c07325ba593.wasm",
"tx_become_validator.wasm": "tx_become_validator.72e6a268b0543da2e55032d0d2afd36b2a9e29a54b8bc4a1dfb256c99f65c283.wasm",
"tx_bond.wasm": "tx_bond.88652ac2893742ff5e535e2adeb98ec27e89c5fa8a8afb3e0bf44eb3edf3d30a.wasm",
"tx_bridge_pool.wasm": "tx_bridge_pool.9292675ce9475af7e20ba77b082e17385debe4cbc56f56b2f5cc8d0d44c95ad9.wasm",
"tx_change_consensus_key.wasm": "tx_change_consensus_key.7ad8bcf0ed888b0bc609b2eaabfa5661581a8b427471e8a3d003859742b738e5.wasm",
"tx_change_validator_commission.wasm": "tx_change_validator_commission.5c1dfe78881e896aa2eefdbafec4ad3395040ef43fc39519f1f44aee7c97e486.wasm",
"tx_change_validator_metadata.wasm": "tx_change_validator_metadata.c587a9775e30958e7d1454a334466d6e1d87484f57819f81713aab240a34927b.wasm",
"tx_claim_rewards.wasm": "tx_claim_rewards.468139fd1c365f196a3a335040e065b20c20ecded18c774124816634f9074e12.wasm",
"tx_deactivate_validator.wasm": "tx_deactivate_validator.e78ca502de5b7e261b007d8048c0f72799ea1772fd479d24460dd9ca90b6572c.wasm",
"tx_ibc.wasm": "tx_ibc.ee0085336f8f39150f38862ce04ea81bab4409894d24f80a20ddb9769a07c6eb.wasm",
"tx_init_account.wasm": "tx_init_account.29f157c5de9cec1fe05668ab7f93bee8783a09dbb6ae5a63b0d35d98a0c7a791.wasm",
"tx_init_proposal.wasm": "tx_init_proposal.202b0c0051f322875094de08515b0913c27099b93cb92d26d34fbf24e8f4bad1.wasm",
"tx_reactivate_validator.wasm": "tx_reactivate_validator.68e32b4f1f91dbeb0b65c370efe55c2a62f56ee5ee87ba06e1d47394352d76b5.wasm",
"tx_redelegate.wasm": "tx_redelegate.1877a0ce5e9cefee1f093d67c93aba14dcb013a9cb3175932cbd37cfb2a18a3b.wasm",
"tx_init_proposal.wasm": "tx_init_proposal.db7efc4e2244226f5a29e4ade99d1e06599c2ea24dfe7246719a754e68ddbe61.wasm",
"tx_reactivate_validator.wasm": "tx_reactivate_validator.86969b34ac734b6c55a26b45cfdff47bcd2f1d41e50e567712fe7211f48ef96e.wasm",
"tx_redelegate.wasm": "tx_redelegate.b2d97c065b8877679fc419c6ad258e36fc53afeb6ba4e995995b0a18e9e92180.wasm",
"tx_resign_steward.wasm": "tx_resign_steward.f16dc643858adc7ded92cc888a8258df0ef0cace0a87e769ef74d831e3d192aa.wasm",
"tx_reveal_pk.wasm": "tx_reveal_pk.c6449a27bdb3272c55e9913c27a4724f5116554cb04c8cc79ece943b71ae08da.wasm",
"tx_transfer.wasm": "tx_transfer.c1a06cf5050be5c5cdf331d9a595a1d6ccbe597ec9bcd41fb1a7912f09b8db9e.wasm",
"tx_unbond.wasm": "tx_unbond.f3a6b926c9f0e7f1a133b618aac590c8647af2f14ba3d681b380e057fdf8e5e5.wasm",
"tx_unjail_validator.wasm": "tx_unjail_validator.ec7bd383d7ecbe56e4d9ad66e90ee8149cfff13883fd2fd67c82f653cad13efd.wasm",
"tx_update_account.wasm": "tx_update_account.24135a3a06cb76d2ad6397742633cf18f826fb953fdfd2fad8f216eb9559cd0c.wasm",
"tx_transfer.wasm": "tx_transfer.2bb8e3d38a6a4c9938d284d7498e49f0d098b091b43c9dbf0ebd1cec594c3190.wasm",
"tx_unbond.wasm": "tx_unbond.f0dc715e5269516ad4154b99b80e27e773f25f35c9e4bc204d2660d1dfd0007a.wasm",
"tx_unjail_validator.wasm": "tx_unjail_validator.ef175881d69c3243f5e67390ca18c27f325e4ce00e6317049e4c50db71cf81d6.wasm",
"tx_update_account.wasm": "tx_update_account.58c2ad37ce137323db55a3827427765b96b98f10b6f6f6bc0ae3004dae10e3f3.wasm",
"tx_update_steward_commission.wasm": "tx_update_steward_commission.503a7baa36e7a86af7f00bc061a281528c64d32216d5593844b5836c9303b5c3.wasm",
"tx_vote_proposal.wasm": "tx_vote_proposal.47b698e895f4e8109d1f40da3dc8c867104c2a4dc2fe92a728b1aff54c1c754c.wasm",
"tx_withdraw.wasm": "tx_withdraw.358fef13e33b71f80740e030f2e5f3e0b3cabcc1bb0520cfa663ce38632675e6.wasm",
"vp_implicit.wasm": "vp_implicit.81542e9a471ddb8d389d26a469b1da51fa93e053c24f67bc6e397256dfbabbb3.wasm",
"vp_user.wasm": "vp_user.7e9414d2d39f82bfa895c1c8385d607d19c5ef49d204124e9191cbe4f525689b.wasm"
"tx_withdraw.wasm": "tx_withdraw.566eeaf74b7e53f9f484c1bccd68f7a7b509ee49042c4c11db4e071d8163c0ca.wasm",
"vp_implicit.wasm": "vp_implicit.cf53a4e6be9f606610c4d4ae0466bb6c60f29c383cd0e39dea4608e7430168a2.wasm",
"vp_user.wasm": "vp_user.e3cf7ead08a51721e52b477ac88353249ab253bd2c12ccaa74139a34f7df85fa.wasm"
}
Binary file modified wasm_for_tests/tx_fail.wasm
Binary file not shown.
Binary file modified wasm_for_tests/tx_memory_limit.wasm
Binary file not shown.
Binary file modified wasm_for_tests/tx_no_op.wasm
Binary file not shown.
Binary file modified wasm_for_tests/tx_proposal_code.wasm
Binary file not shown.
Binary file modified wasm_for_tests/tx_read_storage_key.wasm
Binary file not shown.
Binary file modified wasm_for_tests/tx_write.wasm
Binary file not shown.
Binary file modified wasm_for_tests/vp_always_false.wasm
Binary file not shown.
Binary file modified wasm_for_tests/vp_always_true.wasm
Binary file not shown.
Binary file modified wasm_for_tests/vp_eval.wasm
Binary file not shown.
Binary file modified wasm_for_tests/vp_memory_limit.wasm
Binary file not shown.
Binary file modified wasm_for_tests/vp_read_storage_key.wasm
Binary file not shown.

0 comments on commit 25cb341

Please sign in to comment.