Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
turbocrime committed Jun 18, 2024
1 parent 364af60 commit 8c43178
Show file tree
Hide file tree
Showing 22 changed files with 80 additions and 92 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
'@penumbra-zone/transport-chrome': major
'@penumbra-zone/eslint-config': major
'@repo/tailwind-config': major
'@repo/eslint-config': major
'@penumbra-zone/transport-dom': major
'@penumbra-zone/perspective': major
'@penumbra-zone/protobuf': major
'@penumbra-zone/services': major
'tsconfig': major
'@repo/tsconfig': major
'node-status': major
'@penumbra-zone/bech32m': major
'@penumbra-zone/getters': major
Expand All @@ -17,7 +18,7 @@
'@penumbra-zone/query': major
'@penumbra-zone/types': major
'@penumbra-zone/wasm': major
'@penumbra-zone/ui': major
'@repo/ui': major
---

reconfigure all package builds
2 changes: 1 addition & 1 deletion apps/minifront/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from '@repo/tailwind-config';
export { default } from '@repo/tailwind-config';
2 changes: 1 addition & 1 deletion apps/node-status/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from '@repo/tailwind-config';
export { default } from '@repo/tailwind-config';
28 changes: 14 additions & 14 deletions pack-public.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

# pnpm doesn't like to recurse for the pack command, and turbo doesn't
# understand it as a script. this script should pack every non-private package.
pnpm turbo compile
pnpm pack -C packages/bech32m
pnpm pack -C packages/client
pnpm pack -C packages/crypto
pnpm pack -C packages/getters
pnpm pack -C packages/keys
pnpm pack -C packages/perspective
pnpm pack -C packages/protobuf
pnpm pack -C packages/query
pnpm pack -C packages/services
pnpm pack -C packages/storage
pnpm pack -C packages/transport-chrome
pnpm pack -C packages/transport-dom
pnpm pack -C packages/types
pnpm turbo build --filter="./packages/*"
pnpm pack -C packages/bech32m && \
pnpm pack -C packages/client && \
pnpm pack -C packages/crypto && \
pnpm pack -C packages/getters && \
pnpm pack -C packages/keys && \
pnpm pack -C packages/perspective && \
pnpm pack -C packages/protobuf && \
pnpm pack -C packages/query && \
pnpm pack -C packages/services && \
pnpm pack -C packages/storage && \
pnpm pack -C packages/transport-chrome && \
pnpm pack -C packages/transport-dom && \
pnpm pack -C packages/types && \
pnpm pack -C packages/wasm
3 changes: 1 addition & 2 deletions packages/bech32m/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"scripts": {
"build": "tsc --build",
"clean": "rm -rfv dist package penumbra-zone-*.tgz",
"lint": "eslint src",
"prepack": "$npm_execpath run build",
"lint": "tsc --noEmit && eslint src",
"test": "vitest run"
},
"files": [
Expand Down
3 changes: 1 addition & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"scripts": {
"build": "tsc --build",
"clean": "rm -rfv dist package penumbra-zone-*.tgz",
"lint": "eslint src",
"prepack": "$npm_execpath run build"
"lint": "eslint src"
},
"files": [
"dist"
Expand Down
1 change: 0 additions & 1 deletion packages/crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"build": "tsc --build",
"clean": "rm -rfv dist package penumbra-zone-*.tgz",
"lint": "eslint src",
"prepack": "$npm_execpath run build",
"test": "vitest run"
},
"files": [
Expand Down
1 change: 0 additions & 1 deletion packages/getters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"build": "tsc --build",
"clean": "rm -rfv dist package penumbra-zone-*.tgz",
"lint": "eslint src",
"prepack": "$npm_execpath run build",
"test": "vitest run"
},
"files": [
Expand Down
1 change: 0 additions & 1 deletion packages/perspective/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"build": "tsc --build",
"clean": "rm -rfv dist package penumbra-zone-*.tgz",
"lint": "eslint src",
"prepack": "$npm_execpath run build",
"test": "vitest run"
},
"files": [
Expand Down
3 changes: 1 addition & 2 deletions packages/protobuf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"scripts": {
"build": "tsc --build",
"clean": "rm -rfv dist package penumbra-zone-*.tgz",
"lint": "eslint src",
"prepack": "$npm_execpath run build"
"lint": "eslint src"
},
"files": [
"dist"
Expand Down
1 change: 0 additions & 1 deletion packages/query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"build": "tsc --build",
"clean": "rm -rfv dist package penumbra-zone-*.tgz",
"lint": "eslint src",
"prepack": "$npm_execpath run build",
"test": "vitest run"
},
"files": [
Expand Down
83 changes: 43 additions & 40 deletions packages/query/src/block-processor.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { RootQuerier } from './root-querier';
import { sha256Hash } from '@penumbra-zone/crypto-web/sha256';
import { computePositionId, getLpNftMetadata } from '@penumbra-zone/wasm/dex';

import {
getExchangeRateFromValidatorInfoResponse,
getIdentityKeyFromValidatorInfoResponse,
} from '@penumbra-zone/getters/validator-info-response';
AssetId,
Metadata,
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb';
import { AuctionId } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/auction/v1/auction_pb';
import {
PositionState,
PositionState_PositionStateEnum,
Expand All @@ -14,6 +11,7 @@ import {
CommitmentSource,
Nullifier,
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/sct/v1/sct_pb';
import { ValidatorInfoResponse } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/stake/v1/stake_pb';
import {
Action,
Transaction,
Expand All @@ -24,28 +22,29 @@ import {
SpendableNoteRecord,
SwapRecord,
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1/view_pb';
import { backOff } from 'exponential-backoff';
import type { BlockProcessorInterface } from '@penumbra-zone/types/block-processor';
import type { IndexedDbInterface } from '@penumbra-zone/types/indexed-db';
import type { ViewServerInterface } from '@penumbra-zone/types/servers';
import { customizeSymbol } from '@penumbra-zone/wasm/metadata';
import { updatePricesFromSwaps } from './helpers/price-indexer';
import {
AssetId,
Metadata,
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb';
import { auctionIdFromBech32 } from '@penumbra-zone/bech32m/pauctid';
import { bech32mIdentityKey } from '@penumbra-zone/bech32m/penumbravalid';
import { sha256Hash } from '@penumbra-zone/crypto-web/sha256';
import { getAssetId } from '@penumbra-zone/getters/metadata';
import { PRICE_RELEVANCE_THRESHOLDS, assetPatterns } from '@penumbra-zone/types/assets';
import {
getExchangeRateFromValidatorInfoResponse,
getIdentityKeyFromValidatorInfoResponse,
} from '@penumbra-zone/getters/validator-info-response';
import { toDecimalExchangeRate } from '@penumbra-zone/types/amount';
import { ValidatorInfoResponse } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/stake/v1/stake_pb';
import { PRICE_RELEVANCE_THRESHOLDS, assetPatterns } from '@penumbra-zone/types/assets';
import type { BlockProcessorInterface } from '@penumbra-zone/types/block-processor';
import { uint8ArrayToHex } from '@penumbra-zone/types/hex';
import { AuctionId } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/auction/v1/auction_pb';
import { auctionIdFromBech32 } from '@penumbra-zone/bech32m/pauctid';
import type { IndexedDbInterface } from '@penumbra-zone/types/indexed-db';
import type { ViewServerInterface } from '@penumbra-zone/types/servers';
import { ScanBlockResult } from '@penumbra-zone/types/state-commitment-tree';
import { computePositionId, getLpNftMetadata } from '@penumbra-zone/wasm/dex';
import { customizeSymbol } from '@penumbra-zone/wasm/metadata';
import { backOff } from 'exponential-backoff';
import { updatePricesFromSwaps } from './helpers/price-indexer';
import { processActionDutchAuctionEnd } from './helpers/process-action-dutch-auction-end';
import { processActionDutchAuctionSchedule } from './helpers/process-action-dutch-auction-schedule';
import { processActionDutchAuctionWithdraw } from './helpers/process-action-dutch-auction-withdraw';
import { RootQuerier } from './root-querier';

declare global {
// eslint-disable-next-line no-var
Expand Down Expand Up @@ -309,29 +308,33 @@ export class BlockProcessor implements BlockProcessorInterface {
}

if (globalThis.__ASSERT_ROOT__) {
/*
* Compares the locally stored, filtered TCT root with the actual one on chain. They should match.
* This is expensive to do every block, so should only be done in development for debugging purposes.
*/
const remoteRoot = await this.querier.cnidarium.fetchRemoteRoot(compactBlock.height);
const inMemoryRoot = this.viewServer.getSctRoot();

if (remoteRoot.equals(inMemoryRoot)) {
console.log(
`Block height: ${compactBlock.height} root matches remote ✅ \n`,
`Hash: ${uint8ArrayToHex(inMemoryRoot.inner)}`,
);
} else {
console.log(
`Block height: ${compactBlock.height} root does not match remote ❌ \n`,
`Local hash: ${uint8ArrayToHex(inMemoryRoot.inner)} \n`,
`Remote hash: ${uint8ArrayToHex(remoteRoot.inner)}`,
);
}
await this.assertRootValid(compactBlock.height);
}
}
}

/*
* Compares the locally stored, filtered TCT root with the actual one on chain. They should match.
* This is expensive to do every block, so should only be done in development for debugging purposes.
*/
private async assertRootValid(blockHeight: bigint): Promise<void> {
const remoteRoot = await this.querier.cnidarium.fetchRemoteRoot(blockHeight);
const inMemoryRoot = this.viewServer.getSctRoot();

if (remoteRoot.equals(inMemoryRoot)) {
console.debug(
`Block height: ${blockHeight} root matches remote ✅ \n`,
`Hash: ${uint8ArrayToHex(inMemoryRoot.inner)}`,
);
} else {
console.warn(
`Block height: ${blockHeight} root does not match remote ❌ \n`,
`Local hash: ${uint8ArrayToHex(inMemoryRoot.inner)} \n`,
`Remote hash: ${uint8ArrayToHex(remoteRoot.inner)}`,
);
}
}

private async saveRecoveredCommitmentSources(recovered: (SpendableNoteRecord | SwapRecord)[]) {
for (const record of recovered)
if (record instanceof SpendableNoteRecord) await this.indexedDb.saveSpendableNote(record);
Expand Down
1 change: 0 additions & 1 deletion packages/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"build": "tsc --build",
"clean": "rm -rfv dist package penumbra-zone-*.tgz",
"lint": "eslint src",
"prepack": "$npm_execpath run build",
"test": "vitest run"
},
"files": [
Expand Down
1 change: 0 additions & 1 deletion packages/storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"build": "tsc --build",
"clean": "rm -rfv dist package penumbra-zone-transport-dom-*.tgz",
"lint": "eslint src",
"prepack": "$npm_execpath run build",
"test": "vitest run"
},
"files": [
Expand Down
18 changes: 2 additions & 16 deletions packages/tailwind-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,8 @@
"version": "2.0.1",
"private": true,
"license": "(MIT OR Apache-2.0)",
"type": "module",
"files": [
"dist"
],
"exports": {
".": "./index.ts"
},
"publishConfig": {
"exports": {
".": {
"default": "./dist/index.js",
"types": "./dist/index.d.ts"
}
}
},
"peerDependencies": {
"main": "index.ts",
"dependencies": {
"tailwindcss": "^3.4.3",
"tailwindcss-animate": "^1.0.7"
}
Expand Down
4 changes: 4 additions & 0 deletions packages/tailwind-config/resolved-tailwind-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import resolveConfig from 'tailwindcss/resolveConfig';
import tailwindConfig from '@repo/tailwind-config';

export const RESOLVED_TAILWIND_CONFIG = resolveConfig(tailwindConfig);
1 change: 0 additions & 1 deletion packages/transport-chrome/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"build": "tsc --build",
"clean": "rm -rfv dist package penumbra-zone-transport-dom-*.tgz",
"lint": "eslint src",
"prepack": "$npm_execpath run build",
"test": "vitest run"
},
"files": [
Expand Down
1 change: 0 additions & 1 deletion packages/transport-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"build": "tsc --build",
"clean": "rm -rfv dist package penumbra-zone-transport-dom-*.tgz",
"lint": "eslint src",
"prepack": "$npm_execpath run build",
"test": "vitest run"
},
"files": [
Expand Down
1 change: 0 additions & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"build": "tsc --build",
"clean": "rm -rfv dist package penumbra-zone-*.tgz",
"lint": "eslint src",
"prepack": "$npm_execpath run build",
"test": "vitest run"
},
"files": [
Expand Down
7 changes: 7 additions & 0 deletions packages/ui/components/ui/box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { cva, VariantProps } from 'class-variance-authority';
import { motion } from 'framer-motion';
import { PropsWithChildren, ReactNode } from 'react';
import { cn } from '../../lib/utils';
import { RESOLVED_TAILWIND_CONFIG } from '@repo/tailwind-config/resolved-tailwind-config';

const variants = cva('rounded-lg border bg-background', {
variants: {
Expand Down Expand Up @@ -50,6 +51,12 @@ export const Box = ({
layout={layout ?? !!layoutId}
layoutId={layoutId}
className={cn('flex flex-col gap-4', variants({ spacing, state, overflow }))}
/**
* Set the border radius via the style prop so it doesn't get distorted by framer-motion.
*
* @see https://www.framer.com/motion/layout-animations/##scale-correction
*/
style={{ borderRadius: RESOLVED_TAILWIND_CONFIG.theme.borderRadius.lg }}
>
{(label ?? headerContent) && (
<div className='flex items-center justify-between'>
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from '@repo/tailwind-config';
export { default } from '@repo/tailwind-config';
1 change: 0 additions & 1 deletion packages/wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"lint:rust": "cd crate && cargo fmt --all -- --check && cargo clippy -- -D warnings && cargo clippy --tests -- -D warnings",
"postcompile": "touch ./wasm/.npmignore",
"prebuild": "tsc --build --clean",
"prepack": "$npm_execpath run build",
"test": "vitest run",
"test:rust": "cd crate && wasm-pack test --headless --firefox -- --test build --target wasm32-unknown-unknown --release --features 'mock-database'"
},
Expand Down

0 comments on commit 8c43178

Please sign in to comment.