以太坊 分片是什么

2023-05-16

Ethereum Sharding: An Introduction to Blockchain Sharding

Alchemy Team

May 18, 2022

For years, the question of blockchain scalability has been debated in developer communities. Public blockchain networks, like Ethereum, require several nodes to validate transactions, limiting their ability to scale.

Ethereum, for instance, can process around 10-13 transactions per second. This pales in comparison to centralized systems like VISA, capable of handling up to 24,000 TPS.

If blockchains—and decentralized applications running on them—are to enjoy mass adoption, population-level scalability is necessary.

In addition to layer 2 blockchains, sharding is a proposed solution for scaling Ethereum to support more users. The idea of sharding is to break up the main blockchain into separate segments, so nodes only need to verify a subset of transactions.

With nodes validating transactions in parallel, network throughput can increase, and dApps can scale to meet the needs of a growing number of users.

[Image source]

A common technique in centralized database management, database sharding, is the process of dividing a large database into smaller chunks ("shards") to improve efficiency and application scalability by distributing a database across several machines in parallel.

As the number of users or operations executed on a software increases, so does the data stored in a software's database. An overloaded database will affect app performance and harm user experience. Thus, sharding is necessary to relieve databases and improve load times.

Database Sharding Example

Here's an illustration to explain database sharding:

Imagine there's a database containing personal records for 100,000 residents in a city.

Finding information for an individual would require computing around 100,000 transactions—a costly and time-intensive undertaking.

But what happens if we partition this large database into smaller databases?

For example, by grouping all city residents with surnames starting with specific letters on a unique server, finding information requires less computational resources, tasks require less time to complete, and the database becomes easier to manage.

[image source]

What is a Shard?

A "shard" means a "small part of the whole." In database management, a shard is a subset of a large database hosted on a separate server. While each shard contains chunks of data, they all form one logical dataset.

Using our previous example, we could have on shard, "Shard 1," for city residents with surnames starting with 'A', "Shard 2," for those with surnames starting with 'B', and so on.

If you combine these logical shards, you'd get a single dataset of records for all city residents.

Sharding in blockchain networks follow the same process as with centralized databases, where a blockchain network can be “sharded” or split into distinct segments where each shard stores a portion of the blockchain’s data and processes a unique set of transactions.

With sharding, blockchain networks can improve network latency and scalability.

What problem is sharding in blockchain networks aiming to solve?

Because all nodes must reach consensus (i.e. agree) on transaction validity, blockchain networks can only process a small number of transactions at the same time.

Typically, every node stores the blockchain's entire history and processes every transaction. This is what makes blockchain networks like Ethereum and Bitcoin "decentralized."

With every full node owning a copy of the network's complete history, it becomes harder for malicious actors to hijack the network and potentially reverse or rewrite transactions.

Ensuring blockchain decentralization and security comes at the cost of scalability, though.

Sharded blockchains allow nodes to forgo downloading the full history of the blockchain or validate every transaction passing through the network, which increases network efficiency and enables blockchains to scale support for greater user demand.

[image source]

What is a shard chain?

In the context of blockchain networks, a shard chain would contain a portion of the data and handle a portion of the transaction processing responsibilities.

Shard chains are like a collection of mini-blockchains that operate independently, and to preserve security, each shard chain submits a record of transactions to the main chain (Beacon Chain) at regular intervals through the Validator Manager Contract (VMC).

Because each shard chain will have a unique transaction history and a set of nodes to validate new transactions, multiple shard chains can run simultaneously to bolster network latency and throughput through parallel processing.

[Image source]

Ethereum is planning to adopt sharding as a scaling solution after their Ethereum PoS upgrades, which are a series of upgrades designed to improve the functionality of Ethereum 1.0.

Why is sharding necessary?

There are two main problems that necessitate sharding on Ethereum: the ability to support an exponential increase in users, and the need to remain decentralized at scale.

1. Support an increasing number of users

Ethereum’s present structure makes it unable to handle exponential increases in usage.

Currently, all Ethereum nodes store the complete state of the Ethereum Virtual Machine (EVM), including smart contract code and account balances.

Moreover, transactions are executed linearly and require confirmation by the entire network.

Transacting linearly and requiring nodes to manage large sets of data slows do the network.

2. Maintain decentralization at scale

Requiring nodes to keep a full copy of the blockchain also creates centralization issues. Already, the Ethereum ledger takes up 10+ terabytes of storage space, which is 10x what the average computer can hold.

As the Ethereum blockchain keeps growing, running an Ethereum node may become difficult, leaving only a few nodes in charge of securing the network. This re-introduces centralization and single-point-of-failure problems Ethereum was designed to solve, reducing its value.

Sharding can solve both problems.

Sharding promotes better scalability since nodes can validate different transactions simultaneously, and dividing transactional data into smaller chunks makes it easier to run a full node, which decreases the risk of centralization.

[image source]

What is Ethereum's Casper protocol upgrade?

Casper is a protocol upgrade that will introduce proof-of-stake consensus to the Ethereum blockchain. Ethereum currently uses a proof-of-work consensus algorithm which requires nodes to solve cryptographic puzzles before adding new transactions to the chain.

While proof-of-work encourages decentralization and security, validating transactions requires a lot of energy and reduces processing speeds, which can have adverse effects on the environment and the web3 user experience.

With the Casper upgrade, Ethereum will switch from proof-of-work to proof-of-stake. Instead of competing to add new transactions, validators will stake ether in a smart contract for the right to propose new blocks.

In a PoS Ethereum, the main chain (Beacon Chain) will serve as the consensus and coordination layer for shard chains. All shard chains are tightly coupled with the main chain, strengthening the security of the system. Shard blocks can only be valid if approved by the main chain.

If sharding is adopted, validators (notaries) will be randomly assigned to individual shards to vote on the validity of collations. For a collation to get added to the main chain, it must receive confirmation from at least two-thirds of the notaries on the shard.

[Image source]

Before we explain how sharding works, here are some important definitions:

State

State refers to the information about a system at any point in time. In Ethereum, state is a description of the network at a particular time—contract code, accounts, address balances, etc. Every new transaction alters Ethereum's state.

Merkle Tree

A Merkle tree or root is a cryptographic mechanism that stores large amounts of information via hashes. Merkle trees/roots are essential for Ethereum's security, as they allow nodes to quickly verify if a piece of data is part of the larger structure.

Collation

A collation is a group of transactions conducted on a shard chain, similar to a block in proof-of-work (PoW). Collations are submitted to the main chain and linked together to form the blockchain.

Collation Header

The collation header is similar to a block header in proof-of-work consensus. A collation header contains metadata about the information inside the collation such as:

  • The single shard that the collation belongs to

  • The root hash of the parent collation

  • The Merkle root of all transactions in a collation

  • The pre-state root and post-state root

  • Signatures of notaries

[image source]

Notaries

Notaries are validators randomly assigned to a shard chain to vote on proposed collations. These votes are called "attestations" and prove collation validity. Every collation needs at least ⅔ of collators to sign off on it before being added to the consensus chain.

Proposers

A proposer is a collator (or validator) selected to create a collation and propose it for validation. The proposer has the same duties as a miner in PoW blockchains.

Committees

A committee is a collection of validators or notaries that attest the validity of shard blocks. These committees are randomly shuffled at intervals, so validators cannot predict which committee(s) they'll be in.

The Ethereum sharding upgrade will split the Ethereum blockchain into 64 shard chains. Every shard chain will have an independent state, meaning nodes will store a subset of account balances, smart contract code, and process a portion of the total transactions.

How might Ethereum PoS sharding work in practice?

Imagine Ethereum has 10,000 validators and 100 shard chains.

Through a pseudorandom protocol, eligible validators, who have deposited ETH in the Validator Manager Contract (VMC), and are assigned to shards 1-100.

In Shard 1, a validator (proposer) is selected to group new transactions into a collation.

Other validators (notaries) download the collation and verify the validity of transactions.

If two-thirds of notaries attest to the collation, it is submitted to the main chain via the VMC.

It's important to note that the entire collation isn't added to the Beacon Chain—it would be difficult and time-wasting to verify collations from every shard.

Instead, the validator nodes on the main chain simply check the attestations (signatures) for each collation to determine its validity.

Thanks to collation headers, anyone can verify the activity on each shard.

Collation headers function as "cross-links" and descriptions of the state and transactions on different shards. Thus, cross-shard communication makes it possible to have a top-level view of the Ethereum network without being part of every shard.

While ETH2 sharding promises many benefits, it introduces a new set of problems:

  • Less nodes running each shard, malicious activity, like a 51% attacks become easier.

  • More complex code, risk of smart contract security vulnerabilities increase.

  • Committee members can collude to submit malicious transactions to the main chain.

[Image source]

ETH2 Sharding Protocol Security Measures

Fortunately, the Ethereum sharding roadmap has several mechanisms to improve the security of sharding protocols.

The first of these security protocols involves using fraud proofs to verify transactions on shard chains. As Vitalik Buterin explains, fraud proofs can be used to prove the validity of transactions and punish dishonest activity.

The second mechanism uses random sampling to prevent collusion. If validators don't know which shard they'll end up in, then it becomes harder to coordinate an attack on the system. In this scenario, a 51% attack on a shard chain becomes impossible to execute.

Discussions around sharding have been ongoing in the Ethereum community since at least 2013, but developers have postponed implementing it—for good reason. Sharding is highly complex and introduces new risks, so rigorous testing is required to work out any kinks.

According to Ethereum.org, sharding will roll out on Ethereum after "The Merge" must have taken place. For context, the Merge refers to the event where the PoW Ethereum main network (mainnet) integrates with the Beacon Chain.

The Beacon Chain is an implementation of the Casper proof-of-stake system and produces the randomness required to create a functional sharding system. This chain went live on December 1, 2020.

In the next section, we give a brief overview of the implementation of sharding in Ethereum:

Discussions around sharding have been ongoing in the Ethereum community since 2013, but Ethereum developers have postponed implementing sharding because it is highly complex and introduces new risks, which requires rigorous testing to launch successfully.

Here is a brief overview of the Ethereum sharding timeline:

What is the ETH 2.0 sharding timeline?

According to Ethereum.org, sharding will be deployed on Ethereum after "The Merge," or when the PoW Ethereum main network (mainnet) integrates with the Beacon Chain, has taken place.

Sharding Phase 1

This phase is likely to kick off by 2023, Ethereum's planned upgrade timeline. However, there are no specific dates outlined for the sharding timeline yet.

Here’s an overview of what the first phase of Ethereum sharding may look like:

  • Validator Manager Contract (VMC) hosted on the Beacon Chain responsible for coordinating the sharding process

  • Prospective ETH2 validators are required to lock up 32 ETH into the smart contract before getting added to the pool of eligible validators

  • VMC assigns validators to shards at intervals to validate and process transaction collations to the consensus chain

  • Shards only serve as "data depots" to increase data processing abilities of the Ethereum network.

Sharding Phase 2

The second phase of the ETH PoS sharding upgrade is less defined, as developers debate some aspects. However, we can expect Ethereum sharding phase 2 to look like this in practice:

  • Shards move from being data layers to code execution layers—each shard has an independent “state”, (i.e. a unique set of smart contracts, account balances, and addresses.)

  • Each shard acts like the Ethereum Mainnet with full smart contract and dApp support

  • Cross-shard communication allows users on different shard chains to exchange value.

  • dApps running on different shard chains can "talk" and interact with each other using cross-shard communication, improving Ethereum's scalability functionality.

With multiple shard chains running simultaneously, nodes can increase their transaction processing capacity and are able to process greater amounts of data on-chain.

Continuing the previous example, if 100 shard chains are processing 100 transactions per second, then Ethereum 2.0 will be able to achieve 10,000 TPS.

The only information from shards published on the base layer chain are collation headers—cryptographic proofs of validity—so it becomes easier for validator nodes to confirm transactions and commit to the consensus layer chain.

The result is faster transaction finality and higher network latency.

While estimates vary, the introduction of sharding is expected to scale Ethereum to handle hundreds of thousands of transactions per second.

With higher TPS rates, Ethereum can provide the scalability that dApps need to handle spikes in usage and billions of users.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

以太坊 分片是什么 的相关文章

  • C++-关键字:extern “C”的用法和作用

    extern 34 C 34 的主要作用就是为了能够正确实现C 43 43 代码调用其他C语言代码 xff0c 实现C 43 43 与C及其它语言的混合编程 加上extern 34 C 34 后 xff0c 会指示编译器这部分代码按C语言的
  • docker 镜像源大全

    1 镜像源 网易 xff1a http hub mirror c 163 com 中科大镜像地址 xff1a http mirrors ustc edu cn 中科大github地址 xff1a https github com ustcl
  • docker降级操作

    我的场景 xff1a 安装rancher过程中 xff0c 提示报错 xff1a FATA 0001 Unsupported Docker version found 20 10 5 supported versions are 1 13
  • Docker容器--镜像、容器操作

    引言 一 Docker镜像操作 1 搜索镜像 格式 xff1a docker search 关键字 docker search nginx 2 获取镜像 格式 xff1a docker pull 仓库名称 标签 如果下载镜像时不指定标签 x
  • python实现excel数据导入mysql

    excel数据导入mysql excel数据格式 xff1a import pandas as pd import xlrd import xlwt import pymysql df 61 pd read excel 39 1 xlsx
  • Onvif客户端出现“SOAP 1.2 fault: SOAP-ENV:Sender [no subcode]”错误解释

    用Onvif test tool测试自己写的Onvif client时 xff0c Probe收到此信息 xff1a SOAP 1 2 fault SOAP ENV Sender no subcode 34 Stopped no respo
  • Cocos2d-x初入学堂(10)-->ParticleEditor粒子编辑器

    欢迎转载 xff01 转载时请注明出处 xff1a http write blog csdn net postedit 8126525 呵呵 上一讲 xff0c 只是将粒子系统的基础知识 xff0c 也有朋友问windows版的粒子编辑器
  • uni-app封装ajax请求方法

    位置项目根目录index js 定义了两种请求get和post span class token keyword import span baseconfig span class token keyword from span span
  • uni-app嵌套H5,H5向uniapp传值

    HTML xff1a span class token doctype lt DOCTYPE html gt span span class token tag span class token tag span class token p
  • uniapp接入微信分享iOS总是跳转两次

    配置了N遍 xff0c 依旧跳转两次 xff0c 最终倒在了打包签名的方式上面 先打越狱包 xff0c 然后再进行签名 xff0c 这样的包iOS可以微信分享 xff0c 但是每次都是两次 直接打包正式包或基座包 xff0c iOS微信分享
  • uniapp中使用renderjs(一)

    uniapp中使用renderjs xff0c 基础调用和data值渲染 span class token operator lt span template span class token operator gt span span c
  • uniapp中使用renderjs(二)引入高德地图

    span class token operator lt span template span class token operator gt span span class token operator lt span view span
  • uniapp安卓打包证书制作,亲测可直接使用

    平常证书制作直接使用的安卓证书在线制作 xff0c 最近这个工具不能使用了 xff0c 现分享下证书制作过程和打包流程 uniapp安卓打包证书制作 xff0c 亲测可直接使用 尝试多次 xff0c 证书文件不是有效的keystore文件出
  • PHP原生开发demo

    好久没有用到原生PHP进行页面的开发了 xff0c 昨天帮忙写了一个 xff0c 不过脑子 xff0c 也没有封装 xff0c 像流水一样 xff0c 哈哈哈哈 span class token operator lt span span
  • 手机端预览pdf,兼容安卓iOS和pc端

    手机端预览pdf 兼容安卓iOS和pc端 pdf web viewer html 官方下载 https github com mozilla pdf js releases download v2 15 349 pdfjs 2 15 349
  • fiddler抓包APP查看接口请求响应信息

    1 安装夜神模拟器 2 下载fiddler https www telerik com download fiddler first run 3 设置fiddler的Connection接口为8888 4 设置同台电脑的模拟器的wlan的手
  • 详解NRF24L01无线收发模块

    近日有粉丝朋友留言 xff0c 希望介绍一下nRF24L01这款无线收发芯片 xff0c 正巧前不久的电赛有些涉及 xff0c 因此将自己的一些经验写在这里 xff0c 希望能有所收获 前面我们介绍过单片机的几种通信协议 xff0c 并且初
  • 可以替代树莓派4(raspberry pi 4B)的tinker board 2

    近几年 xff0c 随着国产芯片的飞速发展 xff0c 一批基于国产SOC的 xff0c 性价比高 xff0c 能运行Android Linux的开发板在市场上出现 xff0c 此前 xff0c 如果要用到Android Linux的开发板
  • 全国大学生电子设计竞赛参赛分享

    在你想要放弃的那一刻 想想为什么当初走到了这里 努力走自己喜欢且有意义的路 xff0c 遇见以后不平凡的自己 时隔九年 xff0c 再次回想起大学时候参见电子设计竞赛的经历 xff0c 依然历历在目 大赛简介 全国大学生电子设计竞赛 xff
  • Turtlebot 3 rplidar bringup

    Turtlebot 3上安装rplidar A1驱动并配置相关的sh及launch文件 xff0c 实现SBC端的bringup xff0c 以及PC上的rviz Turtlebot 3默认的雷达是HLS Hitachi LG Sensor

随机推荐

  • LiDAR 1 基础

    激光的形成过程 xff1a 原子内的电子有低能量状态和高能量状态 xff0c 低能量电子吸收能量进入高能量活跃态 xff0c 恢复低能量时发射光子 通过高电压在谐振腔内触发激光 不同的介质可以触发不同频段的激光 激光雷达使用的是红外波段的非
  • LiDAR 4 固态激光雷达 (Flash LiDAR)

    固态激光雷达分为Flash LiDAR和OPA Optical Phased Array LiDAR xff0c Flash LiDAR是非扫描式的 xff0c OPA LiDAR 是扫描式的 Flash LiDAR的发射光源和接收部件都是
  • LiDAR 5 相控阵激光雷达 (OPA LiDAR)

    OPA LiDAR相控阵激光雷达的技术核心是OPA scanner Quanergy S3激光雷达Transmitter OPA xff1a Leddar Tech OPA LiDAR模块 xff1a 相控阵Phase array实现方式
  • LiDAR 6 FMCW

    FMCW是TOF之外的另一种方式 xff0c 利用光波的调频实现目标的探测 光的波粒二象性 多普勒效应 系统架构 当系统的复杂程度上升后 xff0c 能够采集到的信息也更多 xff0c 包括距离和速度 采用OPA扫描的FMCW激光雷达设计
  • LiDAR 7 消费电子3D应用

    消费电子3D应用 Depth Camera xff0c AR Glass xff0c 类似 Microsoft Azure Kinect xff0c Intel RealSense xff0c iPhone iPad 等产品 Microso
  • LiDAR 8 激光雷达行业

    激光雷达应用的领域特别广泛 xff0c 在无人驾驶上的应用受到很大的关注 全球汽车领域激光雷达的厂商 xff0c 生态链厂商 xff0c 相信激光雷达在产品和技术上的发展还会有很广阔的天地
  • FOC - SVPWM

    FOC vector control 电机矢量控制FOC通过转子坐标系的转换 xff0c 实现动态电流控制 实现的几个环节 xff0c 相电流phase current gt Park Ialpha Ibeta gt Clarke Iq I
  • STL- 容器特点总结

    关于 STL1 序列式容器2 关联式容器3 容器适配器 关于 STL STL即标准模板库 xff08 Standard Template Library xff09 STL包含 6大组件 43 13个头文件 六大组件 xff1a 容器 算法
  • C++ 迭代器失效 ++报错

    迭代器失效 xff0c 迭代器 43 43 报错 Program terminated with signal SIGSEGV Segmentation fault 0 0x00007f5a4be6ffb4 in std Rb tree i
  • 将.bib转换内容为bibitem(bbl)格式

    部分期刊要求使用一些小众的参考文献格式 xff0c 或者不允许使用biblatex包 xff08 不兼容 xff09 xff0c 这是就需要将 bib里的参考文献转成bibitemx并放在 tex文件的末尾 Latex排版引用问题 xff1
  • 杰卡德相似系数(Jaccardsimilarity coefficient)

    xff08 1 xff09 杰卡德相似系数 两个集合A和B交集元素的个数在A B并集中所占的比例 xff0c 称为这两个集合的杰卡德系数 xff0c 用符号 J A B 表示 杰卡德相似系数是衡量两个集合相似度的一种指标 xff08 余弦距
  • argmax()函数和max()函数区别

    是求f x 的最大值 是求x的最大值 举个列子 xff1a 设 当x 61 2时 xff0c f x 最大 xff0c argmax f x xff09 就是使f x 值最大的那个自变量
  • Python 优先级队列PriorityQueue 用法示例

    优先队列 xff08 PriorityQueue xff09 是队列的变体 xff0c 按优先级顺序 xff08 最低优先 xff09 检索打开的条目 条目通常是以下格式的元组 xff1a 插入格式 xff1a q put priority
  • Python 优先级字典SortedDict 用法实例

    安装 sudo pip install sortedcontainers 默认为增序 用法示例 coding utf 8 导入模块库 from sortedcontainers import SortedDict 初始化 sorted di
  • python SortedDict 遍历删除 不对

    topLevel 61 SortedDict neg 从大到小排序 for priority Id in topLevel items print 34 topLevel1 34 topLevel 将Id从topLevel中删除 topLe
  • Python字典遍历 未遍历所有元素

    不能在遍历的时候往字典中新增 删除元素 xff01 xff01 xff01 下面是我的python脚本 xff0c 它需要遍历所有具有逻辑路径和直接磁盘的物理磁盘 如果我们找到了任何逻辑路径 xff0c 那么我们得到了相应的物理磁盘 xff
  • 以太坊 事务ID txID transaction ID transaction hash怎么计算

    The transaction can then be sent to the network and will be tracked by a 256 bit transaction id This transaction can be
  • 比特币 事务ID txID transaction hash怎么计算

    A TXID Transaction ID is basically an identification number for a bitcoin transaction A TXID is always 32 bytes 64 chara
  • 使用Android studio开发jni,并实现单步调试c/c++代码

    一 环境搭建 本文讲解的是在一个现有的工程中增加JNI的支持 我们从新建一个工程说起 xff0c 本文假设你已经知道怎么设置sdk和ndk 新建工程的时候我们故意不勾选这个选项 xff0c 方便后面说明 一直默认点下一步 xff0c 直到工
  • 以太坊 分片是什么

    Ethereum Sharding An Introduction to Blockchain Sharding Alchemy Team May 18 2022 For years the question of blockchain s