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

refactor(wasm): fix fee balancing bug for swap claims #1095

Merged
merged 17 commits into from
May 13, 2024
4 changes: 1 addition & 3 deletions apps/minifront/src/state/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ const assembleSwapRequest = async ({ assetIn, amount, assetOut }: SwapSlice) =>
assetId: getAssetIdFromValueView(assetIn.balanceView),
},
claimAddress: await getAddressByIndex(addressIndex.account),
// TODO: Calculate this properly in subsequent PR
// Asset Id should almost certainly be upenumbra,
// may need to indicate native denom in registry
// The prepaid fee will instead be calculated directly in the rust planner logic.
fee: {
amount: {
hi: 0n,
Expand Down
11 changes: 11 additions & 0 deletions packages/query/src/block-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { getAuctionId, getAuctionNftMetadata } from '@penumbra-zone/wasm/auction
import { AuctionId } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/auction/v1alpha1/auction_pb';
import { auctionIdFromBech32 } from '@penumbra-zone/bech32m/pauctid';
import { ScanBlockResult } from '@penumbra-zone/types/state-commitment-tree';
import { GasPrices } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/fee/v1/fee_pb';

declare global {
// `var` required for global declaration (as let/const are block scoped)
Expand Down Expand Up @@ -201,6 +202,16 @@ export class BlockProcessor implements BlockProcessorInterface {
await this.indexedDb.saveGasPrices(compactBlock.gasPrices);
}

// manually (temporarily) set non-zero gas prices in index db for testing purposes.
await this.indexedDb.saveGasPrices(
new GasPrices({
verificationPrice: 1n,
executionPrice: 1n,
blockSpacePrice: 1n,
compactBlockSpacePrice: 1n,
}),
);

TalDerei marked this conversation as resolved.
Show resolved Hide resolved
// wasm view server scan
// - decrypts new notes
// - decrypts new swaps
Expand Down
88 changes: 44 additions & 44 deletions packages/wasm/crate/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 15 additions & 16 deletions packages/wasm/crate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

[package]
name = "penumbra-wasm"
version = "2.0.0"
Expand All @@ -17,20 +16,20 @@ mock-database = []
[dependencies]
# TODO: Use `tag` instead of `rev` once auctions land in a tagged release of
# core.
penumbra-auction = { git = "https://github.com/penumbra-zone/penumbra.git", rev = "519f0f023", package = "penumbra-auction", default-features = false }
penumbra-asset = { git = "https://github.com/penumbra-zone/penumbra.git", rev = "519f0f023", package = "penumbra-asset" }
penumbra-compact-block = { git = "https://github.com/penumbra-zone/penumbra.git", rev = "519f0f023", package = "penumbra-compact-block", default-features = false }
penumbra-dex = { git = "https://github.com/penumbra-zone/penumbra.git", rev = "519f0f023", package = "penumbra-dex", default-features = false }
penumbra-fee = { git = "https://github.com/penumbra-zone/penumbra.git", rev = "519f0f023", package = "penumbra-fee", default-features = false }
penumbra-keys = { git = "https://github.com/penumbra-zone/penumbra.git", rev = "519f0f023", package = "penumbra-keys" }
penumbra-num = { git = "https://github.com/penumbra-zone/penumbra.git", rev = "519f0f023", package = "penumbra-num" }
penumbra-proof-params = { git = "https://github.com/penumbra-zone/penumbra.git", rev = "519f0f023", package = "penumbra-proof-params", default-features = false }
penumbra-proto = { git = "https://github.com/penumbra-zone/penumbra.git", rev = "519f0f023", package = "penumbra-proto", default-features = false }
penumbra-sct = { git = "https://github.com/penumbra-zone/penumbra.git", rev = "519f0f023", package = "penumbra-sct", default-features = false }
penumbra-shielded-pool = { git = "https://github.com/penumbra-zone/penumbra.git", rev = "519f0f023", package = "penumbra-shielded-pool", default-features = false }
penumbra-stake = { git = "https://github.com/penumbra-zone/penumbra.git", rev = "519f0f023", package = "penumbra-stake", default-features = false }
penumbra-tct = { git = "https://github.com/penumbra-zone/penumbra.git", rev = "519f0f023", package = "penumbra-tct" }
penumbra-transaction = { git = "https://github.com/penumbra-zone/penumbra.git", rev = "519f0f023", package = "penumbra-transaction", default-features = false }
penumbra-auction = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.75.0", package = "penumbra-auction", default-features = false }
penumbra-asset = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.75.0", package = "penumbra-asset" }
penumbra-compact-block = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.75.0", package = "penumbra-compact-block", default-features = false }
penumbra-dex = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.75.0", package = "penumbra-dex", default-features = false }
penumbra-fee = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.75.0", package = "penumbra-fee", default-features = false }
penumbra-keys = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.75.0", package = "penumbra-keys" }
penumbra-num = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.75.0", package = "penumbra-num" }
penumbra-proof-params = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.75.0", package = "penumbra-proof-params", default-features = false }
penumbra-proto = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.75.0", package = "penumbra-proto", default-features = false }
penumbra-sct = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.75.0", package = "penumbra-sct", default-features = false }
penumbra-shielded-pool = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.75.0", package = "penumbra-shielded-pool", default-features = false }
penumbra-stake = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.75.0", package = "penumbra-stake", default-features = false }
penumbra-tct = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.75.0", package = "penumbra-tct" }
penumbra-transaction = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.75.0", package = "penumbra-transaction", default-features = false }

anyhow = "1.0.80"
ark-ff = { version = "0.4.2", features = ["std"] }
Expand All @@ -51,4 +50,4 @@ web-sys = { version = "0.3.69", features = ["console"] }

[dev-dependencies]
wasm-bindgen-test = "0.3.42"
serde_json = "1.0.114"
serde_json = "1.0.114"
Loading
Loading