Skip to content

Commit

Permalink
Merge pull request #1629 from starknet-io/enhancement/update-homwpage…
Browse files Browse the repository at this point in the history
…-videos

Update how it works section
  • Loading branch information
rafaelcruzazevedo authored Nov 15, 2023
2 parents 1c7f2e9 + b9e4f10 commit 0545461
Show file tree
Hide file tree
Showing 10 changed files with 512 additions and 28 deletions.
45 changes: 42 additions & 3 deletions _data/pages/what-is-starknet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,54 @@ blocks:
Given a sudoku puzzle, verifying a solution is easier than solving from scratch. If our goal is to convince people of the statement “this puzzle has been solved”, we can save a lot of computation by having one person compute a solution and then propagate it for others to verify. In this strategy, each computation of a solution becomes a one-time event which does not require replication by society. In a similar vein, Starknet scales Ethereum by replacing heavy L1 computation with lighter (hence cheaper!) L1 verification using STARK proofs computed off-chain.
- type: video_section
scaling-eth:
title: How Starknet Scales Ethereum
description: Chapter 1 explains how Starknet works at a high level
content: >-
### How Starknet Scales Ethereum
## How it works
Blockchains aim to achieve three core attributes: security, decentralization, and scalability. In the blockchain world, a well-known trilemma is that it's possible to achieve only two of these concurrently in a given system, inevitably requiring a compromise on the third. Ethereum places a higher emphasis on security and decentralization, impacting its scalability. Growth in the number of Ethereum users leads to slow transaction speeds and high gas prices, hindering Ethereum’s widespread adoption.
With the above analogy in mind, the time is ripe for some jargon. Starknet is a permissionless Validity-Rollup (also known as a “ZK-Rollup”) that supports general computation and currently operates in production as an L2 network over Ethereum. The eventual L1 security of Starknet is ensured by its use of the safest and most scalable cryptographic proof system – [STARK](https://starkware.co/stark/).
How can we make Ethereum scalable without undermining its security and decentralization? This is where the Starknet Validity Rollup comes in. Combining Ethereum and Starknet achieves massive scalability.
Starknet contracts are (for the most part) written in the Cairo language – A Turing complete programming language designed for STARK proofs.
Starknet achieves scale by shifting transaction processing off the Ethereum Mainnet (what we call off-chain) while retaining a summary of the transactions onchain. Transactions are grouped in batches into blocks, processed off-chain, and then summarized into a single onchain transaction. Since transactions occur off-chain, it's vital to ensure the integrity of the transactions and their execution without having to re-execute them. Starknet addresses this by employing [STARK](https://starkware.co/stark/) (Scalable, Transparent ARgument of Knowledge) proofs for verifiable computation. Starknet then transmits only essential information about the block and the proof to Ethereum, where it is verified with minimal computational effort.
sequencer:
title: The Starknet Sequencer
content: >-
### The Starknet Sequencer
The first core component of Starknet is the Starknet Sequencer. Sequencers take on the pivotal role of overseeing the validation and execution of transactions and proposing blocks. Their primary function involves grouping transactions and processing them as a collective entity. The unsuccessful transactions are flagged and held back by the Sequencer, allowing only the successful ones to move forward and get included in a block. Starknet’s sequencers can handle substantially more transactions per second than Ethereum nodes.
The next core component in Starknet is the Prover.
description: Chapter 2 explains about the Starknet Sequencer
prover:
title: The Starknet Prover
content: >-
### The Starknet Prover
The Prover establishes the mathematical validity of the block's transactions by generating a STARK proof, thus ensuring its integrity. Blocks are organized into groups and processed concurrently. During this phase, the Prover documents each step of transaction execution, creating what is known as the Execution Trace, along with tracking the resultant changes in the system's state, termed the State Diff.
An algorithm then meticulously blows up and mixes data from the Execution Trace. This step brings any issues to the forefront, as even a single instance of bad data contaminates the entire expanded dataset, making any issues unmissable. The Prover then selects a set of random samples from this blown-up data to create the STARK proof. This STARK proof asserts the validity of thousands of transactions.
description: Chapter 2 explains how the Starknet Prover works
eth-settlement:
content: >-
### Secure Settlement on Ethereum
The STARK proof and State Diff are transmitted to Ethereum as a transaction, where an Ethereum node accepts the transactions and unpacks the proof and the State Diff. These unpacked components are processed by two Ethereum smart contracts: the Verifier and Starknet Core. The Verifier contract breaks down the proof and analyzes samples within it. Any hint of problematic data in the samples of the proof leads to prompt rejection by the Verifier. Once the proof's validity is confirmed, it advances to the Starknet Core smart contract.
The Core contract verifies the proof's authenticity and confirms receiving the State Diff, subsequently updating the Starknet state on the Ethereum blockchain. This updated state is then added to an Ethereum block, distributed across the node network for validation and voting. When the block accumulates sufficient votes, it achieves "finalized" status, cementing its place as an immutable part of Ethereum.
title: Secure Settlement on Ethereum
description: Chapter 4 explains how to secure settlement on Ethereum
- type: link_list
heading: Further reading
listSize: lg
Expand Down
58 changes: 58 additions & 0 deletions workspaces/cms-config/src/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,30 @@ export const cardListItem = [
},
] satisfies CmsField[];

const videoChapterFields = [
{
crowdin: true,
label: 'Title',
name: 'title',
required: true,
widget: 'string'
},
{
crowdin: true,
label: 'Description',
name: 'description',
required: true,
widget: 'string'
},
{
crowdin: true,
label: 'Content',
name: 'content',
required: true,
widget: 'markdown'
}
] satisfies CmsField[];

export const blocks = [
{
name: "markdown",
Expand Down Expand Up @@ -663,6 +687,40 @@ export const blocks = [
],
},
],
}, {
name: "video_section",
label: "Education video section",
widget: "object",
fields: [
{
crowdin: true,
label: 'Chapter 1',
name: 'scaling-eth',
widget: 'object',
fields: videoChapterFields
},
{
crowdin: true,
label: 'Chapter 2',
name: 'sequencer',
widget: 'object',
fields: videoChapterFields
},
{
crowdin: true,
label: 'Chapter 3',
name: 'prover',
widget: 'object',
fields: videoChapterFields
},
{
crowdin: true,
label: 'Chapter 4',
name: 'eth-settlement',
widget: 'object',
fields: videoChapterFields
}
]
},
{
name: "ordered_block",
Expand Down
17 changes: 16 additions & 1 deletion workspaces/cms-data/src/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,20 @@ export interface OrderedBlock {
readonly blocks: readonly OrderedItem[];
}

export interface ChapterInfo {
content: MarkdownBlock['body'];
subtitle: string;
title: string;
};

export interface VideoSectionBlock {
readonly type: "video_section";
readonly 'scaling-eth': ChapterInfo;
readonly sequencer: ChapterInfo;
readonly prover: ChapterInfo;
readonly 'eth-settlement': ChapterInfo;
}

export type HeadingVariant = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";

export type Block =
Expand All @@ -160,7 +174,8 @@ export type Block =
| AccordionBlock
| OrderedBlock
| ListCardItemsBlock
| AmbassadorsListBlock;
| AmbassadorsListBlock
| VideoSectionBlock;

export interface Container {
readonly type: "container";
Expand Down
5 changes: 5 additions & 0 deletions workspaces/website/src/blocks/Block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { getHomeSEO } from "@starknet-io/cms-data/src/seo";
import { useAsync } from "react-streaming";
import { usePageContext } from "src/renderer/PageContextProvider";
import { HeadingContainer } from "./HeadingContainer";
import VideoSectionBlock from "./VideoSectionBlock";

interface Props {
readonly block: TopLevelBlock;
Expand Down Expand Up @@ -155,6 +156,10 @@ export function Block({ block, locale }: Props): JSX.Element | null {
}}
/>
);
} else if (block.type === "video_section") {
return (
<VideoSectionBlock {...block} />
)
} else {
// this will report type error if there is unhandled block.type
block satisfies never;
Expand Down
83 changes: 83 additions & 0 deletions workspaces/website/src/blocks/VideoSectionBlock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* Module dependencies
*/

import { Box } from "@chakra-ui/react";
import {
VideoSectionBlock as VideoSectionProps,
ChapterInfo
} from "@starknet-io/cms-data/src/pages";

import { CategoryTabs } from "@ui/CategoryTabs/CategoryTabs";
import { Heading } from "@ui/Typography/Heading";
import { Chapter, playlist } from "@ui/VideoPlayer/constants";
import { VideoPlayerWebsite } from "@ui/VideoPlayer/player-website/VideoPlayerWebsite";
import { useMemo, useState } from "react";
import { MarkdownBlock } from "./MarkdownBlock";

/**
* `ChapterType` type.
*/

type ChapterType = Chapter & ChapterInfo;

/**
* Export `VideoSectionBlock` component.
*/

export default function VideoSectionBlock(props: VideoSectionProps) {
const normalizedPlaylist = useMemo(() => {
return playlist.map((chapter) => {
const chapterInfo = props[chapter.id as keyof VideoSectionProps] as ChapterInfo;
return ({
...chapter,
...chapterInfo
}) as ChapterType;
});
}, [props, playlist])

const [currentChapter, setCurrentChapter] = useState<ChapterType>(normalizedPlaylist[0]);

return (
<Box>
<Heading
color="heading-navy-fg"
variant="h2"
fontSize={"32px"}
marginBottom={"24px"}
>
{currentChapter.title}
</Heading>

<VideoPlayerWebsite
chapters={normalizedPlaylist}
initialActiveChapter={normalizedPlaylist[0].id}
onChapterChange={(id) =>
setCurrentChapter(normalizedPlaylist.find((p) => p.id === id) ?? normalizedPlaylist[0])
}
playlistOnBottom
/>

<Box mt="md">
<CategoryTabs
activeItemId={currentChapter.id}
onTabClick={(id) =>
setCurrentChapter(normalizedPlaylist.find((p) => p.id === id) ?? normalizedPlaylist[0])
}
items={normalizedPlaylist.map((p) => ({
id: p.id,
label: p.subtitle,
}))}
/>

<Box
maxW="656px"
marginInline="auto"
marginTop={'32px'}
>
<MarkdownBlock body={currentChapter.content} />
</Box>
</Box>
</Box>
);
}
71 changes: 71 additions & 0 deletions workspaces/website/src/components/CategoryTabs/CategoryTabs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@

/**
* Module dependencies
*/

import { Box, Flex } from "@chakra-ui/react";
import { Button } from "@ui/Button";

/**
* Export `CategoryTabItem` type.
*/

export type CategoryTabItem = {
id: string;
label: string;
link?: string;
};

/**
* Export `CategoryTabProps` type.
*/

export type CategoryTabsProps = {
items: CategoryTabItem[];
activeItemId: string;
onTabClick?: (id: string) => void;
};

/**
* Export `CategoryTabs` component.
*/

export const CategoryTabs = ({
items,
activeItemId,
onTabClick,
}: CategoryTabsProps) => {
return (
<Box
borderTopWidth="1px"
borderBottomWidth="1px"
borderColor="border.divider"
width="100%"
>
<Flex
as="ul"
sx={{ overflowX: "auto" }}
gap="24px"
width="100%"
padding={'0 24px'}
>
{items.map((item) => {
return (
<Box>
<Button
as={item.link ? "a" : "button"}
href={item.link}
isActive={item.id === activeItemId}
onClick={() => onTabClick?.(item.id)}
variant="category"
padding={'24px 12px'}
>
{item.label}
</Button>
</Box>
);
})}
</Flex>
</Box>
);
};
Loading

0 comments on commit 0545461

Please sign in to comment.