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

Bundle mainnet genesis state #165

Merged
merged 6 commits into from
Aug 20, 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
16 changes: 8 additions & 8 deletions apps/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
"@penumbra-labs/registry": "11.0.0",
"@penumbra-zone/bech32m": "^7.0.0",
"@penumbra-zone/client": "^18.0.0",
"@penumbra-zone/crypto-web": "^21.0.0",
"@penumbra-zone/getters": "^15.0.0",
"@penumbra-zone/crypto-web": "^22.0.0",
"@penumbra-zone/getters": "^16.0.0",
"@penumbra-zone/keys": "^4.2.1",
"@penumbra-zone/perspective": "^25.0.0",
"@penumbra-zone/perspective": "^26.0.0",
"@penumbra-zone/protobuf": "^6.0.0",
"@penumbra-zone/query": "^26.0.0",
"@penumbra-zone/services": "^29.0.0",
"@penumbra-zone/storage": "^25.0.0",
"@penumbra-zone/query": "^27.0.0",
"@penumbra-zone/services": "^30.0.0",
"@penumbra-zone/storage": "^26.0.0",
"@penumbra-zone/transport-chrome": "^8.0.1",
"@penumbra-zone/transport-dom": "^7.5.0",
"@penumbra-zone/types": "^20.0.0",
"@penumbra-zone/wasm": "^25.0.0",
"@penumbra-zone/types": "^21.0.0",
"@penumbra-zone/wasm": "^26.0.0",
"@radix-ui/react-icons": "^1.3.0",
"@repo/context": "workspace:*",
"@repo/ui": "workspace:*",
Expand Down
Binary file added apps/extension/public/penumbra-1-genesis.bin
Binary file not shown.
19 changes: 10 additions & 9 deletions packages/context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"license": "(MIT OR Apache-2.0)",
"type": "module",
"scripts": {
"lint": "eslint \"**/*.ts*\""
"lint": "eslint \"**/*.ts*\"",
"test": "vitest run"
},
"files": [
"src/",
Expand All @@ -18,17 +19,17 @@
"@bufbuild/protobuf": "^1.10.0",
"@penumbra-labs/registry": "11.0.0",
"@penumbra-zone/bech32m": "^7.0.0",
"@penumbra-zone/crypto-web": "^21.0.0",
"@penumbra-zone/getters": "^15.0.0",
"@penumbra-zone/perspective": "^25.0.0",
"@penumbra-zone/crypto-web": "^22.0.0",
"@penumbra-zone/getters": "^16.0.0",
"@penumbra-zone/perspective": "^26.0.0",
"@penumbra-zone/protobuf": "^6.0.0",
"@penumbra-zone/query": "^26.0.0",
"@penumbra-zone/services": "^29.0.0",
"@penumbra-zone/storage": "^25.0.0",
"@penumbra-zone/query": "^27.0.0",
"@penumbra-zone/services": "^30.0.0",
"@penumbra-zone/storage": "^26.0.0",
"@penumbra-zone/transport-chrome": "^8.0.1",
"@penumbra-zone/transport-dom": "^7.5.0",
"@penumbra-zone/types": "^20.0.0",
"@penumbra-zone/wasm": "^25.0.0",
"@penumbra-zone/types": "^21.0.0",
"@penumbra-zone/wasm": "^26.0.0",
"exponential-backoff": "^3.1.1"
}
}
12 changes: 12 additions & 0 deletions packages/context/src/genesis.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { describe, test, expect } from 'vitest';
import { CompactBlock } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/compact_block/v1/compact_block_pb';
import { join } from 'path';
import { readFileSync } from 'fs';

describe('Genesis block type conversion', () => {
test('penumbra-1 deserializes correctly', () => {
const filePath = join(__dirname, '../../../apps/extension/public/penumbra-1-genesis.bin');
const genesisBinaryData = readFileSync(filePath);
expect(() => CompactBlock.fromBinary(new Uint8Array(genesisBinaryData))).not.toThrow();
});
});
9 changes: 9 additions & 0 deletions packages/context/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { FullViewingKey, WalletId } from '@penumbra-zone/protobuf/penumbra/core/
import { ChainRegistryClient } from '@penumbra-labs/registry';
import { AppParameters } from '@penumbra-zone/protobuf/penumbra/core/app/v1/app_pb';
import { AssetId } from '@penumbra-zone/protobuf/penumbra/core/asset/v1/asset_pb';
import { CompactBlock } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/compact_block/v1/compact_block_pb';

export interface ServicesConfig {
readonly chainId: string;
Expand Down Expand Up @@ -103,7 +104,15 @@ export class Services implements ServicesInterface {
idbConstants: indexedDb.constants(),
});

// Dynamically fetch binary file for genesis compact block
Copy link
Contributor

@TalDerei TalDerei Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetch api goes through the browser's network stack for local files, and there seems to be overhead in setting up the request, but latency is negligible

Screenshot 2024-08-20 at 8 18 39 AM

const response = await fetch('./penumbra-1-genesis.bin');
const genesisBinaryData = await response.arrayBuffer();

const blockProcessor = new BlockProcessor({
genesisBlock:
chainId === 'penumbra-1'
? CompactBlock.fromBinary(new Uint8Array(genesisBinaryData))
: undefined,
viewServer,
querier,
indexedDb,
Expand Down
8 changes: 4 additions & 4 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
"@emotion/styled": "^11.11.5",
"@penumbra-labs/registry": "11.0.0",
"@penumbra-zone/bech32m": "^7.0.0",
"@penumbra-zone/getters": "^15.0.0",
"@penumbra-zone/perspective": "^25.0.0",
"@penumbra-zone/getters": "^16.0.0",
"@penumbra-zone/perspective": "^26.0.0",
"@penumbra-zone/protobuf": "^6.0.0",
"@penumbra-zone/types": "^20.0.0",
"@penumbra-zone/wasm": "^25.0.0",
"@penumbra-zone/types": "^21.0.0",
"@penumbra-zone/wasm": "^26.0.0",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "1.0.5",
Expand Down
Loading
Loading