Skip to content
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
2 changes: 1 addition & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.3.11/schema.json",
"$schema": "https://biomejs.dev/schemas/2.4.8/schema.json",
"files": {
"includes": ["**", "!**/dist", "!**/graypaper-archive", "!**/public", "!**/tools/matrix-bot/messages.json"]
},
Expand Down
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>JAM Codec</title>

<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400;1,600&family=Inconsolata:wght@400;500;600;700&display=swap"
rel="stylesheet"
/>
</head>
<body>
<div id="root"></div>
Expand Down
3,339 changes: 1,290 additions & 2,049 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
"test": "vitest"
},
"dependencies": {
"@biomejs/biome": "^2.3.11",
"@fluffylabs/shared-ui": "^0.4.5",
"@tailwindcss/vite": "^4.1.17",
"@typeberry/lib": "^0.5.1-1534485f",
"lucide-react": "^0.562.0",
"react": "^19.0.0",
"react-dom": "^19.2.3",
"react-router-dom": "^7.9.5",
"@biomejs/biome": "^2.4.8",
"@fluffylabs/shared-ui": "^0.6.3",
"@tailwindcss/vite": "^4.2.2",
"@typeberry/lib": "^0.5.10",
"lucide-react": "^0.577.0",
"react": "^19.2.4",
"react-dom": "^19.2.4",
"react-router-dom": "^7.13.1",
"react-tooltip": "^5.30.0",
"tailwindcss": "^4.1.17"
"tailwindcss": "^4.2.2"
},
"devDependencies": {
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.0",
"@testing-library/react": "^16.3.2",
"@testing-library/user-event": "^14.6.1",
"@types/react": "^19.2.7",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react-swc": "^4.2.2",
"jsdom": "^27.4.0",
"typescript": "^5.2.2",
"vite": "^7.3.0",
"vitest": "^4.0.16"
"@vitejs/plugin-react-swc": "^4.3.0",
"jsdom": "^29.0.1",
"typescript": "^5.9.3",
"vite": "^8.0.1",
"vitest": "^4.1.0"
}
}
56 changes: 24 additions & 32 deletions src/components/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,52 +89,44 @@ const extrinsicKind = newKind("Extrinsic", block.Extrinsic.Codec, extrinsicExamp
const epochMarkerKind = newKind("EpochMarker", block.EpochMarker.Codec, epochMarkerExample);
const availabilityAssuranceKind = newKind(
"AvailabilityAssurance",
block.assurances.AvailabilityAssurance.Codec,
block.AvailabilityAssurance.Codec,
availabilityAssuranceExample,
);
const assurancesExtrinsicKind = newKind(
"AssurancesExtrinsic",
block.assurances.assurancesExtrinsicCodec,
block.assurancesExtrinsicCodec,
assurancesExtrinsicExample,
);
const culpritKind = newKind("Culprit", block.disputes.Culprit.Codec, culpritExample);
const faultKind = newKind("Fault", block.disputes.Fault.Codec, faultExample);
const judgementKind = newKind("Judgement", block.disputes.Judgement.Codec, judgementExample);
const verdictKind = newKind("Verdict", block.disputes.Verdict.Codec, verdictExample);
const disputesExtrinsicKind = newKind(
"DisputesExtrinsic",
block.disputes.DisputesExtrinsic.Codec,
disputesExtrinsicExample,
);
const credentialKind = newKind("Credential", block.guarantees.Credential.Codec, credentialExample);
const reportGuaranteeKind = newKind("ReportGuarantee", block.guarantees.ReportGuarantee.Codec, reportGuaranteeExample);
const culpritKind = newKind("Culprit", block.Culprit.Codec, culpritExample);
const faultKind = newKind("Fault", block.Fault.Codec, faultExample);
const judgementKind = newKind("Judgement", block.Judgement.Codec, judgementExample);
const verdictKind = newKind("Verdict", block.Verdict.Codec, verdictExample);
const disputesExtrinsicKind = newKind("DisputesExtrinsic", block.DisputesExtrinsic.Codec, disputesExtrinsicExample);
const credentialKind = newKind("Credential", block.Credential.Codec, credentialExample);
const reportGuaranteeKind = newKind("ReportGuarantee", block.ReportGuarantee.Codec, reportGuaranteeExample);
const guaranteesExtrinsicKind = newKind(
"GuaranteesExtrinsic",
block.guarantees.guaranteesExtrinsicCodec,
block.guaranteesExtrinsicCodec,
guaranteesExtrinsicExample,
);
const preimageKind = newKind("Preimage", block.preimage.Preimage.Codec, preimageExample);
const preimageExtrinsicKind = newKind(
"PreimageExtrinsic",
block.preimage.preimagesExtrinsicCodec,
preimageExtrinsicExample,
);
const refineContextKind = newKind("RefineContext", block.refineContext.RefineContext.Codec, refineContextExample);
const signedTicketKind = newKind("SignedTicket", block.tickets.SignedTicket.Codec, signedTicketExample);
const ticketKind = newKind("Ticket", block.tickets.Ticket.Codec, ticketExample);
const ticketExtrinsicKind = newKind("TicketExtrinsic", block.tickets.ticketsExtrinsicCodec, ticketExtrinsicExample);
const importSpecKind = newKind("ImportSpec", block.workItem.ImportSpec.Codec, importSpecExample);
const workItemKind = newKind("WorkItem", block.workItem.WorkItem.Codec, workItemExample);
const preimageKind = newKind("Preimage", block.Preimage.Codec, preimageExample);
const preimageExtrinsicKind = newKind("PreimageExtrinsic", block.preimagesExtrinsicCodec, preimageExtrinsicExample);
const refineContextKind = newKind("RefineContext", block.RefineContext.Codec, refineContextExample);
const signedTicketKind = newKind("SignedTicket", block.SignedTicket.Codec, signedTicketExample);
const ticketKind = newKind("Ticket", block.Ticket.Codec, ticketExample);
const ticketExtrinsicKind = newKind("TicketExtrinsic", block.ticketsExtrinsicCodec, ticketExtrinsicExample);
const importSpecKind = newKind("ImportSpec", block.ImportSpec.Codec, importSpecExample);
const workItemKind = newKind("WorkItem", block.WorkItem.Codec, workItemExample);
const workItemExtrinsicSpecKind = newKind(
"WorkItemExtrinsicSpec",
block.workItem.WorkItemExtrinsicSpec.Codec,
block.WorkItemExtrinsicSpec.Codec,
workItemExtrinsicSpecExample,
);
const workPackageKind = newKind("WorkPackage", block.workPackage.WorkPackage.Codec, workPackageExample);
const workPackageSpecKind = newKind("WorkPackageSpec", block.workReport.WorkPackageSpec.Codec, workPackageSpecExample);
const workReportKind = newKind("WorkReport", block.workReport.WorkReport.Codec, workReportExample);
const workExecResultKind = newKind("WorkExecResult", block.workResult.WorkExecResult.Codec, workExecResultExample);
const workResultKind = newKind("WorkResult", block.workResult.WorkResult.Codec, workResultExample);
const workPackageKind = newKind("WorkPackage", block.WorkPackage.Codec, workPackageExample);
const workPackageSpecKind = newKind("WorkPackageSpec", block.WorkPackageSpec.Codec, workPackageSpecExample);
const workReportKind = newKind("WorkReport", block.WorkReport.Codec, workReportExample);
const workExecResultKind = newKind("WorkExecResult", block.WorkExecResult.Codec, workExecResultExample);
const workResultKind = newKind("WorkResult", block.WorkResult.Codec, workResultExample);
const u8Kind = newKind("u8", codec.codec.u8, numericExamples.u8);
const u16Kind = newKind("u16", codec.codec.u16, numericExamples.u16);
const u24Kind = newKind("u24", codec.codec.u24, numericExamples.u24);
Expand Down
4 changes: 2 additions & 2 deletions src/components/examples/objects/availabilityAssurance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { bitVecFrom, ed25519Signature, resolveExampleSpec, validatorIndex, zeroH

export const availabilityAssuranceExample = (
spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.assurances.AvailabilityAssurance> =>
block.assurances.AvailabilityAssurance.create({
): ClassInstance<typeof block.AvailabilityAssurance> =>
block.AvailabilityAssurance.create({
anchor: zeroHash(),
bitfield: bitVecFrom(Number(resolveExampleSpec(spec).coresCount), [0]),
validatorIndex: validatorIndex(2),
Expand Down
4 changes: 2 additions & 2 deletions src/components/examples/objects/credential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { ed25519Signature, validatorIndex } from "./helpers";

export const credentialExample = (
_spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.guarantees.Credential> =>
block.guarantees.Credential.create({
): ClassInstance<typeof block.Credential> =>
block.Credential.create({
validatorIndex: validatorIndex(0),
signature: ed25519Signature(12),
});
6 changes: 2 additions & 4 deletions src/components/examples/objects/culprit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import * as config from "@typeberry/lib/config";
import type { ClassInstance } from "../types";
import { ed25519Key, ed25519Signature, filledHash } from "./helpers";

export const culpritExample = (
_spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.disputes.Culprit> =>
block.disputes.Culprit.create({
export const culpritExample = (_spec: config.ChainSpec = config.tinyChainSpec): ClassInstance<typeof block.Culprit> =>
block.Culprit.create({
workReportHash: filledHash(61),
key: ed25519Key(14),
signature: ed25519Signature(52),
Expand Down
4 changes: 2 additions & 2 deletions src/components/examples/objects/disputesExtrinsic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { verdictExample } from "./verdict";

export const disputesExtrinsicExample = (
spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.disputes.DisputesExtrinsic> =>
block.disputes.DisputesExtrinsic.create({
): ClassInstance<typeof block.DisputesExtrinsic> =>
block.DisputesExtrinsic.create({
verdicts: [verdictExample(spec)],
culprits: [culpritExample(spec)],
faults: [faultExample(spec)],
Expand Down
6 changes: 2 additions & 4 deletions src/components/examples/objects/fault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import * as config from "@typeberry/lib/config";
import type { ClassInstance } from "../types";
import { ed25519Key, ed25519Signature, filledHash } from "./helpers";

export const faultExample = (
_spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.disputes.Fault> =>
block.disputes.Fault.create({
export const faultExample = (_spec: config.ChainSpec = config.tinyChainSpec): ClassInstance<typeof block.Fault> =>
block.Fault.create({
workReportHash: filledHash(60),
wasConsideredValid: false,
key: ed25519Key(13),
Expand Down
4 changes: 2 additions & 2 deletions src/components/examples/objects/importSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { filledHash } from "./helpers";

export const importSpecExample = (
_spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.workItem.ImportSpec> =>
block.workItem.ImportSpec.create({
): ClassInstance<typeof block.ImportSpec> =>
block.ImportSpec.create({
treeRoot: filledHash(32),
index: block.tryAsSegmentIndex(1),
});
4 changes: 2 additions & 2 deletions src/components/examples/objects/judgement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { ed25519Signature, validatorIndex } from "./helpers";

export const judgementExample = (
_spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.disputes.Judgement> =>
block.disputes.Judgement.create({
): ClassInstance<typeof block.Judgement> =>
block.Judgement.create({
isWorkReportValid: true,
index: validatorIndex(0),
signature: ed25519Signature(50),
Expand Down
6 changes: 2 additions & 4 deletions src/components/examples/objects/preimage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import * as config from "@typeberry/lib/config";
import type { ClassInstance } from "../types";
import { bytesBlobFrom, serviceId } from "./helpers";

export const preimageExample = (
_spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.preimage.Preimage> =>
block.preimage.Preimage.create({
export const preimageExample = (_spec: config.ChainSpec = config.tinyChainSpec): ClassInstance<typeof block.Preimage> =>
block.Preimage.create({
requester: serviceId(7),
blob: bytesBlobFrom("demo preimage payload"),
});
4 changes: 2 additions & 2 deletions src/components/examples/objects/refineContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { filledHash, timeSlot } from "./helpers";

export const refineContextExample = (
_spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.refineContext.RefineContext> =>
block.refineContext.RefineContext.create({
): ClassInstance<typeof block.RefineContext> =>
block.RefineContext.create({
anchor: filledHash(20),
stateRoot: filledHash(21),
beefyRoot: filledHash(22),
Expand Down
6 changes: 3 additions & 3 deletions src/components/examples/objects/reportGuarantee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { workReportExample } from "./workReport";

export const reportGuaranteeExample = (
spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.guarantees.ReportGuarantee> => {
const secondaryCredential = block.guarantees.Credential.create({
): ClassInstance<typeof block.ReportGuarantee> => {
const secondaryCredential = block.Credential.create({
validatorIndex: validatorIndex(1),
signature: ed25519Signature(44),
});

return block.guarantees.ReportGuarantee.create({
return block.ReportGuarantee.create({
report: workReportExample(spec),
slot: timeSlot(20),
credentials: asKnownSize([credentialExample(spec), secondaryCredential]),
Expand Down
6 changes: 3 additions & 3 deletions src/components/examples/objects/signedTicket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { bandersnatchProof } from "./helpers";

export const signedTicketExample = (
_spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.tickets.SignedTicket> =>
block.tickets.SignedTicket.create({
attempt: block.tickets.tryAsTicketAttempt(1),
): ClassInstance<typeof block.SignedTicket> =>
block.SignedTicket.create({
attempt: block.tryAsTicketAttempt(1),
signature: bandersnatchProof(3),
});
8 changes: 3 additions & 5 deletions src/components/examples/objects/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import * as config from "@typeberry/lib/config";

import type { ClassInstance } from "../types";

export const ticketExample = (
_spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.tickets.Ticket> =>
block.tickets.Ticket.create({
export const ticketExample = (_spec: config.ChainSpec = config.tinyChainSpec): ClassInstance<typeof block.Ticket> =>
block.Ticket.create({
id: bytes.Bytes.fill(32, 4),
attempt: block.tickets.tryAsTicketAttempt(0),
attempt: block.tryAsTicketAttempt(0),
});
8 changes: 3 additions & 5 deletions src/components/examples/objects/verdict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,21 @@ import * as config from "@typeberry/lib/config";
import type { ClassInstance } from "../types";
import { asKnownSize, ed25519Signature, filledHash, resolveExampleSpec, validatorIndex } from "./helpers";

export const verdictExample = (
spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.disputes.Verdict> => {
export const verdictExample = (spec: config.ChainSpec = config.tinyChainSpec): ClassInstance<typeof block.Verdict> => {
const resolvedSpec = resolveExampleSpec(spec);
const votesCount = Number(resolvedSpec.validatorsSuperMajority);

const votes = asKnownSize(
Array.from({ length: votesCount }, (_, idx) =>
block.disputes.Judgement.create({
block.Judgement.create({
isWorkReportValid: idx % 2 === 0,
index: validatorIndex(idx),
signature: ed25519Signature(60 + idx),
}),
),
);

return block.disputes.Verdict.create({
return block.Verdict.create({
workReportHash: filledHash(62),
votesEpoch: block.tryAsEpoch(1),
votes,
Expand Down
3 changes: 1 addition & 2 deletions src/components/examples/objects/workExecResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ import { bytesBlobFrom } from "./helpers";

export const workExecResultExample = (
_spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.workResult.WorkExecResult> =>
new block.workResult.WorkExecResult(block.workResult.WorkExecResultKind.ok, bytesBlobFrom("work result"));
): ClassInstance<typeof block.WorkExecResult> => block.WorkExecResult.ok(bytesBlobFrom("work result"));
6 changes: 2 additions & 4 deletions src/components/examples/objects/workItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import { asKnownSize, bytesBlobFrom, filledHash, serviceGas, serviceId, u16 } fr
import { importSpecExample } from "./importSpec";
import { workItemExtrinsicSpecExample } from "./workItemExtrinsicSpec";

export const workItemExample = (
spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.workItem.WorkItem> =>
block.workItem.WorkItem.create({
export const workItemExample = (spec: config.ChainSpec = config.tinyChainSpec): ClassInstance<typeof block.WorkItem> =>
block.WorkItem.create({
service: serviceId(10),
codeHash: filledHash(34),
payload: bytesBlobFrom("work item payload"),
Expand Down
4 changes: 2 additions & 2 deletions src/components/examples/objects/workItemExtrinsicSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { filledHash, u32 } from "./helpers";

export const workItemExtrinsicSpecExample = (
_spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.workItem.WorkItemExtrinsicSpec> =>
block.workItem.WorkItemExtrinsicSpec.create({
): ClassInstance<typeof block.WorkItemExtrinsicSpec> =>
block.WorkItemExtrinsicSpec.create({
hash: filledHash(33),
len: u32(32),
});
6 changes: 3 additions & 3 deletions src/components/examples/objects/workPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { workItemExample } from "./workItem";

export const workPackageExample = (
spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.workPackage.WorkPackage> =>
block.workPackage.WorkPackage.create({
): ClassInstance<typeof block.WorkPackage> =>
block.WorkPackage.create({
authorization: bytesBlobFrom("authorization"),
authCodeHost: block.tryAsServiceId(99),
authCodeHash: filledHash(40),
parametrization: bytesBlobFrom("params"),
context: refineContextExample(spec),
items: FixedSizeArray.new([workItemExample(spec)], block.workPackage.tryAsWorkItemsCount(1)),
items: FixedSizeArray.new([workItemExample(spec)], block.tryAsWorkItemsCount(1)),
});
4 changes: 2 additions & 2 deletions src/components/examples/objects/workPackageSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { filledHash, u16, u32 } from "./helpers";

export const workPackageSpecExample = (
_spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.workReport.WorkPackageSpec> =>
block.workReport.WorkPackageSpec.create({
): ClassInstance<typeof block.WorkPackageSpec> =>
block.WorkPackageSpec.create({
hash: filledHash(30),
length: u32(4),
erasureRoot: bytes.Bytes.fill(32, 9),
Expand Down
8 changes: 4 additions & 4 deletions src/components/examples/objects/workReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ import { workResultExample } from "./workResult";

export const workReportExample = (
spec: config.ChainSpec = config.tinyChainSpec,
): ClassInstance<typeof block.workReport.WorkReport> => {
): ClassInstance<typeof block.WorkReport> => {
const workPackageSpec = workPackageSpecExample(spec);
const segmentInfo = block.refineContext.WorkPackageInfo.create({
const segmentInfo = block.WorkPackageInfo.create({
workPackageHash: workPackageSpec.hash,
segmentTreeRoot: workPackageSpec.exportsRoot,
});

return block.workReport.WorkReport.create({
return block.WorkReport.create({
workPackageSpec,
context: refineContextExample(spec),
coreIndex: coreIndex(3),
authorizerHash: filledHash(42),
authorizationOutput: bytesBlobFrom("auth output"),
segmentRootLookup: [segmentInfo],
results: FixedSizeArray.new([workResultExample(spec)], block.workPackage.tryAsWorkItemsCount(1)),
results: FixedSizeArray.new([workResultExample(spec)], block.tryAsWorkItemsCount(1)),
authorizationGasUsed: serviceGas(7_500n),
});
};
Loading
Loading