Le livre blanc NEAR

Nightshade: Near Protocol Sharding Design

By Alex Skidanov and Illia Polosukhin · 2019

Sharding Basics

Sharding Basics

Let’s start with the simplest approach to sharding. In this approach instead of running one blockchain, we will run multiple, and call each such blockchain a “shard”. Each shard will have its own set of validators. Here and below we use a generic term “validator” to refer to participants that verify transactions and produce blocks, either by mining, such as in Proof of Work, or via a voting-based 1This section was previously published at https://near.ai/shard1. If you read it before, skip to the next section.

mechanism. For now let’s assume that the shards never communicate with each other. This design, though simple, is sufficient to outline some initial major challenges in sharding. 1.1 Validator partitioning and Beacon chains Say that the system comprises 10 shards. The first challenge is that with each shard having its own validators, each shard is now 10 times less secure than the entire chain. So if a non-sharded chain with X validators decides to hard-fork into a sharded chain, and splits X validators across 10 shards, each shard now only has X/10 validators, and corrupting one shard only requires corrupting 5.1% (51% / 10) of the total number of validators (see figure 1), Figure 1: Splitting the validators across shards which brings us to the second point: who chooses validators for each shard? Controlling 5.1% of validators is only damaging if all those 5.1% of validators are in the same shard. If validators can’t choose which shard they get to validate in, a participant controlling 5.1% of the validators is highly unlikely to get all their validators in the same shard, heavily reducing their ability to compromise the system. Almost all sharding designs today rely on some source of randomness to assign validators to shards. Randomness on blockchain on itself is a very challenging topic and is out of scope for this document. For now let’s assume there’s some source of randomness we can use. We will cover validators assignment in more detail in section 2.1. Both randomness and validator assignment require computation that is not specific to any particular shard. For that computation, practically all existing designs have a separate blockchain that is tasked with performing operations necessary for the maintenance of the entire network. Besides generating random

numbers and assigning validators to the shards, these operations often also include receiving updates from shards and taking snapshots of them, processing stakes and slashing in Proof-of-Stake systems, and rebalancing shards when that feature is supported. Such chain is called a Beacon chain in Ethereum, a Relay chain in PolkaDot, and the Cosmos Hub in Cosmos. Throughout this document we will refer to such chain as a Beacon chain. The existence of the Beacon chain brings us to the next interesting topic, the quadratic sharding. 1.2 Quadratic sharding Sharding is often advertised as a solution that scales infinitely with the number of nodes participating in the network operation. While it is in theory possible to design such a sharding solution, any solution that has the concept of a Beacon chain doesn’t have infinite scalability. To understand why, note that the Beacon chain has to do some bookkeeping computation, such as assigning validators to shards, or snapshotting shard chain blocks, that is proportional to the number of shards in the system. Since the Beacon chain is itself a single blockchain, with computation bounded by the computational capabilities of nodes operating it, the number of shards is naturally limited. However, the structure of a sharded network does bestow a multiplicative effect on any improvements to its nodes. Consider the case in which an arbitrary improvement is made to the efficiency of nodes in the network which will allow them faster transaction processing times. If the nodes operating the network, including the nodes in the Beacon chain, become four times faster, then each shard will be able to process four times more transactions, and the Beacon chain will be able to maintain 4 times more shards. The throughput across the system will increase by the factor of 4 × 4 = 16 — thus the name quadratic sharding. It is hard to provide an accurate measurement for how many shards are viable today, but it is unlikely that in any foreseeable future the throughput needs of blockchain users will outgrow the limitations of quadratic sharding. The sheer number of nodes necessary to operate such a volume of shards securely is likely orders of magnitude higher than the number of nodes operating all the blockchains combined today. 1.3 State sharding Up until now we haven’t defined very well what exactly is and is not separated when a network is divided into shards. Specifically, nodes in the blockchain perform three important tasks: not only do they 1) process transactions, they also 2) relay validated transactions and completed blocks to other nodes and 3) store the state and the history of the entire network ledger. Each of these three tasks imposes a growing requirement on the nodes operating the network:

  1. The necessity to process transactions requires more compute power with the increased number of transactions being processed;
  2. The necessity to relay transactions and blocks requires more network bandwidth with the increased number of transactions being relayed;
  3. The necessity to store data requires more storage as the state grows. Importantly, unlike the processing power and network, the storage requirement grows even if the transaction rate (number of transactions processed per second) remains constant. From the above list it might appear that the storage requirement would be the most pressing, since it is the only one that is being increased over time even if the number of transactions per second doesn’t change, but in practice the most pressing requirement today is the compute power. The entire state of Ethereum as of this writing is 100GB, easily manageable by most of the nodes. But the number of transactions Ethereum can process is around 20, orders of magnitude less than what is needed for many practical use cases. Zilliqa is the most well-known project that shards processing but not storage. Sharding of processing is an easier problem because each node has the entire state, meaning that contracts can freely invoke other contracts and read any data from the blockchain. Some careful engineering is needed to make sure updates from multiple shards updating the same parts of the state do not conflict. In those regards Zilliqa is taking a relatively simplistic approach2. While sharding of storage without sharding of processing was proposed, it is extremely uncommon. Thus in practice sharding of storage, or State Sharding, almost always implies sharding of processing and sharding of network. Practically, under State Sharding the nodes in each shard are building their own blockchain that contains transactions that affect only the local part of the global state that is assigned to that shard. Therefore, the validators in the shard only need to store their local part of the global state and only execute, and as such only relay, transactions that affect their part of the state. This partition linearly reduces the requirement on all compute power, storage, and network bandwidth, but introduces new problems, such as data availability and cross-shard transactions, both of which we will cover below. 1.4 Cross-shard transactions The sharding model we described so far is not a very useful, because if individual shards cannot communicate with each other, they are no better than multiple independent blockchains. Even today, when sharding is not available, there’s a huge demand for interoperability between various blockchains. Let’s for now only consider simple payment transactions, where each participant has account on exactly one shard. If one wishes to transfer money from 2Our analysis of their approach can be found here: https://medium.com/nearprotocol/ 8f9efae0ce3b

one account to another within the same shard, the transaction can be processed entirely by the validators in that shard. If, however, Alice that resides on shard

1 wants to send money to Bob who resides on shard #2, neither validators

on shard #1(they won’t be able to credit Bob’s account) nor the validators on shard #2 (they won’t be able to debit Alice’s account) can process the entire transaction. There are two families of approaches to cross-shard transactions: • Synchronous: whenever a cross-shard transaction needs to be executed, the blocks in multiple shards that contain state transition related to the transaction get all produced at the same time, and the validators of multiple shards collaborate on executing such transactions.3 • Asynchronous: a cross-shard transaction that affects multiple shards is executed in those shards asynchronously, the “Credit” shard executing its half once it has sufficient evidence that the “Debit” shard has executed its portion. This approach tends to be more prevalent due to its simplicity and ease of coordination. This system is today proposed in Cosmos, Ethereum Serenity, Near, Kadena, and others. A problem with this approach lies in that if blocks are produced independently, there’s a nonzero chance that one of the multiple blocks will be orphaned, thus making the transaction only partially applied. Consider figure 2 that depicts two shards both of which encountered a fork, and a cross-shard transaction that was recorded in blocks A and X’ correspondingly. If the chains A-B and V’-X’-Y’-Z’ end up being canonical in the corresponding shards, the transaction is fully finalized. If A’-B’-C’-D’ and V-X become canonical, then the transaction is fully abandoned, which is acceptable. But if, for example, A-B and V-X become canonical, then one part of the transaction is finalized and one is abandoned, creating an atomicity failure. We will cover how this problem is addressed in proposed protocols in the second part, when covering changes to the fork-choice rules and consensus algorithms proposed for sharded protocols. Note that communication between chains is useful outside of sharded blockchains too. Interoperability between chains is a complex problem that many projects are trying to solve. In sharded blockchains the problem is somewhat easier since the block structure and consensus are the same across shards, and there’s a beacon chain that can be used for coordination. In a sharded blockchain, however, all the shard chains are the same, while in the global blockchains ecosystem there are lots of different blockchains, with different target use cases, decentralization and privacy guarantees. Building a system in which a set of chains have different properties but use sufficiently similar consensus and block structure and have a common beacon chain could enable an ecosystem of heterogeneous blockchains that have a 3The most detailed proposal known to the authors of this document is Merge Blocks, described here: https://ethresear.ch/t/ merge-blocks-and-synchronous-cross-shard-state-execution/1240

Figure 2: Asynchronous cross-shard transactions working interoperability subsystem. Such system is unlikely to feature validator rotation, so some extra measures need to be taken to ensure security. Both Cosmos and PolkaDot are effectively such systems4 1.5 Malicious behavior In this section we will review what adversarial behavior can malicious validators exercise if they manage to corrupt a shard. We will review classic approaches to avoiding corrupting shards in section 2.1. 1.5.1 Malicious forks A set of malicious validators might attempt to create a fork. Note that it doesn’t matter if the underlying consensus is BFT or not, corrupting sufficient number of validators will always make it possible to create a fork. It is significantly more likely for more that 50% of a single shard to be corrupted, than for more than 50% of the entire network to be corrupted (we will dive deeper into these probabilities in section 2.1). As discussed in section 1.4, cross-shard transactions involve certain state changes in multiple shards, and the corresponding blocks in such shards that apply such state changes must either be all finalized (i.e. appear in the selected chains on their corresponding shards), or all be orphaned (i.e. not appear in the selected chains on their corresponding shards). Since generally the probability of shards being corrupted 4Refer to this writeup by Zaki Manian from Cosmos: https://forum.cosmos.network/ t/polkadot-vs-cosmos/1397/2 and this tweet-storm by the first author of this document: https://twitter.com/AlexSkidanov/status/1129511266660126720 for a detailed comparison of the two

is not negligible, we can’t assume that the forks won’t happen even if a byzantine consensus was reached among the shard validators, or many blocks were produced on top of the block with the state change. This problem has multiple solutions, the most common one being occasional cross-linking of the latest shard chain block to the beacon chain. The fork choice rule in the shard chains is then changed to always prefer the chain that is cross-linked, and only apply shard-specific fork-choice rule for blocks that were published since the last cross-link. 1.5.2 Approving invalid blocks A set of validators might attempt to create a block that applies the state transition function incorrectly. For example, starting with a state in which Alice has 10 tokens and Bob has 0 tokens, the block might contain a transaction that sends 10 tokens from Alice to Bob, but ends up with a state in which Alice has 0 tokens and Bob has 1000 tokens, as shown on figure 3. Figure 3: An example of an invalid block In a classic non-sharded blockchain such an attack is not possible, since all the participant in the network validate all the blocks, and the block with such an invalid state transition will be rejected by both other block producers, and the participants of the network that do not create blocks. Even if the malicious validators continue creating blocks on top of such an invalid block faster than honest validators build the correct chain, thus having the chain with the invalid block being longer, it doesn’t matter, since every participant that is using the blockchain for any purpose validates all the blocks, and discards all the blocks built on top of the invalid block. On the figure 4 there are five validators, three of whom are malicious. They created an invalid block A’, and then continued building new blocks on top of it. Two honest validators discarded A’ as invalid and were building on top

Figure 4: Attempt to create an invalid block in a non-sharded blockchain of the last valid block known to them, creating a fork. Since there are fewer validators in the honest fork, their chain is shorter. However, in classic nonsharded blockchain every participant that uses blockchain for any purpose is responsible for validating all the blocks they receive and recomputing the state. Thus any person who has any interest in the blockchain would observe that A’ is invalid, and thus also immediately discard B’, C’ and D’, as such taking the chain A-B as the current longest valid chain. In a sharded blockchain, however, no participant can validate all the transactions on all the shards, so they need to have some way to confirm that at no point in history of any shard of the blockchain no invalid block was included. Note that unlike with forks, cross-linking to the Beacon chain is not a sufficient solution, since the Beacon chain doesn’t have the capacity to validate the blocks. It can only validate that a sufficient number of validators in that shard signed the block (and as such attested to its correctness). We will discuss solutions to this problem in section 2.2 below.

Bases du partage

Commençons par l’approche la plus simple du partitionnement. Dans cette approche, au lieu de en exécutant un blockchain, nous en exécuterons plusieurs et appellerons chacun de ces blockchain un « éclat ». Chaque fragment aura son propre ensemble de validator. Ici et ci-dessous, nous utilisons un terme générique « validator » pour désigner les participants qui vérifient les transactions et produire des blocs, soit par minage, comme dans Proof of Work, soit via un système de vote 1Cette section a déjà été publiée à https://near.ai/shard1. Si vous l'avez déjà lue, passer à la section suivante.

mécanisme. Pour l'instant, supposons que les fragments ne communiquent jamais entre eux. autre. Cette conception, bien que simple, est suffisante pour décrire quelques premiers défis majeurs du sharding. 1.1 Partitionnement du validateur et chaînes Beacon Disons que le système comprend 10 fragments. Le premier défi est qu'avec chacun fragment ayant ses propres validator, chaque fragment est désormais 10 fois moins sécurisé que le fragment chaîne entière. Donc, si une chaîne non fragmentée avec X validators décide de faire un hard-fork en une chaîne fragmentée et divise X validator en 10 fragments, chaque fragment maintenant n'a que X/10 validators, et corrompre un fragment ne nécessite que la corruption 5,1% (51% / 10) du nombre total de validator (voir figure 1), Figure 1 : Diviser les validator entre les fragments ce qui nous amène au deuxième point : qui choisit les validator pour chaque fragment ? Contrôler 5,1 % des validator n'est dommageable que si tous ces 5,1 % des validator sont dans le même fragment. Si les validator ne peuvent pas choisir quelle partition ils doivent valider dans, il est très peu probable qu'un participant contrôlant 5,1 % des validator obtienne tous les leurs validator dans le même fragment, réduisant considérablement leur capacité à compromettre le système. Presque toutes les conceptions de partitionnement actuelles reposent sur une source aléatoire pour attribuez des validator aux fragments. Le caractère aléatoire sur blockchain en lui-même est un sujet très difficile et sort du cadre de ce document. Pour l'instant, supposons qu'il y ait une source de hasard que nous pouvons utiliser. Nous couvrirons la mission de validator dans plus de détails dans la section 2.1. Le caractère aléatoire et l'affectation validator nécessitent des calculs qui ne sont pas spécifique à un fragment particulier. Pour ce calcul, pratiquement tous les les conceptions ont un blockchain distinct chargé d'effectuer les opérations nécessaires à l’entretien de l’ensemble du réseau. En plus de générer desnuméros et en attribuant des validator aux fragments, ces opérations sont souvent également inclure la réception des mises à jour des fragments et la prise d'instantanés de ceux-ci, le traitement les enjeux et la réduction des systèmes de preuve d'enjeu, et le rééquilibrage des fragments lorsque cela la fonctionnalité est prise en charge. Une telle chaîne est appelée chaîne Beacon en Ethereum, un relais chaîne dans PolkaDot et le hub Cosmos dans Cosmos. Tout au long de ce document, nous ferons référence à une telle chaîne sous le nom de chaîne Beacon. L'existence de la chaîne Beacon nous amène au prochain sujet intéressant, le partitionnement quadratique. 1.2 Partitionnement quadratique Le partage est souvent présenté comme une solution évolutive à l'infini avec le nombre de de nœuds participant au fonctionnement du réseau. Même s'il est en théorie possible de concevoir une telle solution de sharding, toute solution qui a le concept de Beacon la chaîne n’a pas une évolutivité infinie. Pour comprendre pourquoi, notez que le Beacon La chaîne doit effectuer certains calculs comptables, comme attribuer des validator à fragments, ou capture instantanée de blocs de chaîne de fragments, proportionnels au nombre de fragments dans le système. Puisque la chaîne Beacon est elle-même un seul blockchain, avec calcul limité par les capacités de calcul des nœuds qui l'exploitent, le nombre de fragments est naturellement limité. Cependant, la structure d’un réseau fragmenté confère un effet multiplicatif effet sur toute amélioration de ses nœuds. Prenons le cas dans lequel une décision arbitraire une amélioration est apportée à l'efficacité des nœuds du réseau, ce qui permettra des temps de traitement des transactions plus rapides. Si les nœuds exploitant le réseau, y compris les nœuds de la chaîne Beacon, deviendra quatre fois plus rapide, alors chaque fragment pourra traiter quatre fois plus transactions, et la chaîne Beacon pourra conserver 4 fois plus de fragments. Le débit à travers le système augmentera du facteur 4 × 4 = 16 — d'où le nom de partitionnement quadratique. Il est difficile de fournir une mesure précise du nombre de fragments viable aujourd'hui, mais il est peu probable que dans un avenir prévisible, le débit Les besoins des utilisateurs de blockchain dépasseront les limites du partitionnement quadratique. Le grand nombre de nœuds nécessaires pour exploiter un tel volume de fragments en toute sécurité est probablement un ordre de grandeur supérieur au nombre de nœuds exécutant tous les blockchains combinés aujourd'hui. 1.3 Partage d'État Jusqu’à présent, nous n’avons pas très bien défini ce qui est exactement séparé de ce qui ne l’est pas. lorsqu'un réseau est divisé en fragments. Plus précisément, les nœuds du blockchain effectuent trois tâches importantes : non seulement 1) ils traitent les transactions, mais ils également 2) relayer les transactions validées et les blocs terminés vers d'autres nœuds et 3) stocker l'état et l'historique de l'ensemble du grand livre du réseau. Chacun de ces trois les tâches imposent une exigence croissante aux nœuds exploitant le réseau :1. La nécessité de traiter les transactions nécessite plus de puissance de calcul avec le nombre croissant de transactions en cours de traitement ; 2. La nécessité de relayer les transactions et les blocs nécessite plus de bande passante réseau avec l'augmentation du nombre de transactions relayées ; 3. La nécessité de stocker des données nécessite davantage de stockage à mesure que l’État se développe. Il est important de noter que contrairement à la puissance de traitement et au réseau, les besoins en stockage augmentent même si le taux de transaction (nombre de transactions traitées) par seconde) reste constante. D'après la liste ci-dessus, il pourrait sembler que les besoins en matière de stockage seraient le plus urgent, car c'est le seul qui augmente avec le temps même si le nombre de transactions par seconde ne change pas, mais en pratique L’exigence la plus pressante aujourd’hui est la puissance de calcul. L'ensemble de l'état de Ethereum au moment d'écrire ces lignes est de 100 Go, facilement gérable par la plupart des nœuds. Mais le nombre de transactions que Ethereum peut traiter est d'environ 20, les commandes de ampleur inférieure à ce qui est nécessaire pour de nombreux cas d’utilisation pratique. Zilliqa est le projet le plus connu qui traite les fragments mais pas le stockage. Le partage du traitement est un problème plus simple car chaque nœud possède l'intégralité de état, ce qui signifie que les contrats peuvent librement invoquer d'autres contrats et lire toutes les données du blockchain. Une ingénierie minutieuse est nécessaire pour garantir que les mises à jour à partir de plusieurs fragments mettant à jour les mêmes parties de l’état, il n’y a pas de conflit. Dans à cet égard, Zilliqa adopte une approche relativement simpliste2. Bien que le partitionnement du stockage sans partitionnement du traitement ait été proposé, il est extrêmement rare. Ainsi en pratique le sharding du stockage, ou State Sharding, implique presque toujours le partage du traitement et le partage du réseau. En pratique, dans le cadre du State Sharding, les nœuds de chaque fragment construisent leur propre blockchain qui contient des transactions qui affectent uniquement la partie locale du état global attribué à cette partition. Par conséquent, les validator dans le Le fragment n'a besoin que de stocker sa partie locale de l'état global et de s'exécuter uniquement, et en tant que tels ne font que relayer les transactions qui affectent leur part de l’État. Ceci la partition réduit linéairement les besoins en matière de puissance de calcul, de stockage et bande passante du réseau, mais introduit de nouveaux problèmes, tels que la disponibilité des données et transactions entre fragments, que nous aborderons toutes deux ci-dessous. 1.4 Transactions entre fragments Le modèle de partitionnement que nous avons décrit jusqu'à présent n'est pas très utile, car si un individu les fragments ne peuvent pas communiquer entre eux, ils ne valent pas mieux que plusieurs blockchain indépendants. Même aujourd'hui, lorsque le partage n'est pas disponible, il existe un énorme demande d’interopérabilité entre les différents blockchain. Considérons pour l’instant uniquement les transactions de paiement simples, où chaque participant possède un compte sur exactement un seul fragment. Si l'on souhaite transférer de l'argent de 2Notre analyse de leur approche est disponible ici : https://medium.com/nearprotocol/ 8f9efae0ce3bd'un compte à un autre au sein du même fragment, la transaction peut être traitée entièrement par les validator dans ce fragment. Cependant, si Alice qui réside sur le fragment

1 veut envoyer de l'argent à Bob qui réside sur le fragment #2, ni à validators

sur le fragment n°1 (ils ne pourront pas créditer le compte de Bob) ni les validator sur le fragment n°2 (ils ne pourront pas débiter le compte d'Alice) peut traiter l'intégralité de transaction. Il existe deux familles d’approches des transactions cross-shard : • Synchrone : chaque fois qu'une transaction entre fragments doit être exécutée, les blocs dans plusieurs fragments qui contiennent une transition d'état liée au les transactions sont toutes produites en même temps, et les validators de plusieurs fragments collaborent à l'exécution de ces transactions.3 • Asynchrone : une transaction entre fragments qui affecte plusieurs fragments est exécuté dans ces fragments de manière asynchrone, le fragment « Crédit » exécutant sa moitié une fois qu'il a suffisamment de preuves que le fragment « Débit » a exécuté sa partie. Cette approche a tendance à être plus répandue en raison de son simplicité et facilité de coordination. Ce système est aujourd'hui proposé dans Cosmos, Ethereum Serenity, Near, Kadena et autres. Un problème avec ça L’approche réside dans le fait que si les blocs sont produits indépendamment, il y a une chance non nulle que l’un des multiples blocs devienne orphelin, ce qui rend la transaction n’a été appliquée que partiellement. Considérons la figure 2 qui représente deux fragments qui ont tous deux rencontré un fork et une transaction entre fragments qui a été enregistré dans les blocs A et X' respectivement. Si les chaînes A-B et V’-X’-Y’-Z’ finissent par être canoniques dans les fragments correspondants, le la transaction est entièrement finalisée. Si A’-B’-C’-D’ et V-X deviennent canoniques, alors la transaction est totalement abandonnée, ce qui est acceptable. Mais si, pour Par exemple, A-B et V-X deviennent canoniques, puis une partie de la transaction est finalisée et une autre est abandonnée, créant un échec d'atomicité. Nous expliquera comment ce problème est abordé dans les protocoles proposés dans la deuxième partie, en traitant des changements apportés aux règles de choix de fourchette et au consensus algorithmes proposés pour les protocoles fragmentés. Notez que la communication entre les chaînes est utile en dehors des blockchain fragmentés aussi. L'interopérabilité entre les chaînes est un problème complexe que de nombreux projets tentent de résoudre. Dans les blockchain fragmentés, le problème est un peu plus simple puisque la structure des blocs et le consensus sont les mêmes sur tous les fragments, et il existe une chaîne de balises qui peut être utilisée pour la coordination. Cependant, dans un blockchain fragmenté, toutes les chaînes de fragments sont les mêmes, alors que dans l'écosystème mondial de blockchains, il y a existe de nombreux blockchain différents, avec différents cas d'utilisation cibles, la décentralisation et garanties de confidentialité. Construire un système dans lequel un ensemble de chaînes ont des propriétés différentes mais utiliser un consensus et une structure de bloc suffisamment similaires et avoir une chaîne de balises commune pourrait permettre un écosystème de blockchain hétérogènes qui ont un 3Le la plupart détaillé proposition connu à le auteurs de ceci documents est Fusionner Blocs, décrit ici : https://ethresear.ch/t/ fusion-blocs-et-synchrone-cross-shard-state-execution/1240Figure 2 : Transactions asynchrones entre fragments sous-système d’interopérabilité fonctionnel. Il est peu probable qu'un tel système comporte une rotation validator, des mesures supplémentaires doivent donc être prises pour garantir la sécurité. Les deux Cosmos et PolkaDot sont effectivement de tels systèmes4 1,5 Comportement malveillant Dans cette section, nous examinerons quels comportements contradictoires peuvent nuire aux validators. exercice s’ils parviennent à corrompre un fragment. Nous passerons en revue les approches classiques pour éviter de corrompre les fragments dans la section 2.1. 1.5.1 Fourchettes malveillantes Un ensemble de validator malveillants pourrait tenter de créer un fork. Notez que ce n’est pas le cas peu importe que le consensus sous-jacent soit BFT ou non, corrompant un nombre suffisant de de validators permettront toujours de créer un fork. Il est significativement plus probable que plus de 50 % d'un seul fragment soit corrompu, que plus de 50 % de l'ensemble du réseau (nous le verrons plus loin). approfondissez ces probabilités dans la section 2.1). Comme indiqué à la section 1.4, les transactions entre fragments impliquent certains changements d'état dans plusieurs fragments, et les blocs correspondants dans ces fragments qui appliquent de tels changements d'état doivent soit être tous finalisés (c'est-à-dire apparaître dans les chaînes sélectionnées sur leur fragments), ou tous être orphelins (c'est-à-dire ne pas apparaître dans les chaînes sélectionnées sur leurs fragments correspondants). Puisque généralement la probabilité que les fragments soient corrompus 4Référez-vous à cet article de Zaki Manian de Cosmos : https://forum.cosmos.network/ t/polkadot-vs-cosmos/1397/2 et cette tempête de tweets du premier auteur de ce document : https://twitter.com/AlexSkidanov/status/1129511266660126720 pour une comparaison détaillée des deux

n'est pas négligeable, nous ne pouvons pas supposer que les forks n'auront pas lieu même si un consensus byzantin était atteint parmi les fragments validator, ou si de nombreux blocs étaient produit au sommet du bloc avec le changement d'état. Ce problème a plusieurs solutions, la plus courante étant occasionnelle réticulation du dernier bloc de chaîne de fragments à la chaîne de balise. La fourchette La règle de choix dans les chaînes de fragments est ensuite modifiée pour toujours préférer la chaîne qui est réticulés, et n'appliquent la règle de choix de fork spécifique au fragment que pour les blocs qui ont été publié depuis le dernier lien croisé. 1.5.2 Approuver les blocs invalides Un ensemble de validator peut tenter de créer un bloc qui applique la fonction de transition d'état de manière incorrecte. Par exemple, en commençant par un état dans lequel Alice a 10 tokens et Bob a 0 tokens, le bloc peut contenir une transaction qui envoie 10 token d'Alice à Bob, mais se retrouve avec un état dans lequel Alice a 0 tokens et Bob a 1000 tokens, comme le montre la figure 3. Figure 3 : Un exemple de bloc invalide Dans un blockchain classique non fragmenté, une telle attaque n'est pas possible, puisque tous le participant au réseau valide tous les blocs, et le bloc avec tel une transition d'état invalide sera rejetée par les deux autres producteurs de blocs, et les participants du réseau qui ne créent pas de blocages. Même si le malveillant Les validator continuent de créer des blocs au-dessus d'un tel bloc invalide plus rapidement que les validator honnêtes construisent la bonne chaîne, ayant ainsi la chaîne avec l'invalide le bloc étant plus long, cela n'a pas d'importance, puisque chaque participant qui utilise le blockchain, à quelque fin que ce soit, valide tous les blocs et rejette tous les blocs construit au-dessus du bloc invalide. Sur la figure 4, il y a cinq validator, dont trois malveillants. Ils a créé un bloc A' invalide, puis a continué à construire de nouveaux blocs par-dessus de celui-ci. Deux validator honnêtes ont rejeté A' comme invalide et construisaient dessusFigure 4 : Tentative de création d'un bloc non valide dans un blockchain non fragmenté du dernier bloc valide connu d'eux, créant un fork. Puisqu'il y a moins validators dans la fourchette honnête, leur chaîne est plus courte. Cependant, dans le blockchain classique non fragmenté, chaque participant qui utilise blockchain à quelque fin que ce soit est chargé de valider tous les blocs qu’ils reçoivent et de recalculer l’état. Ainsi, toute personne ayant un intérêt dans le blockchain observerait que A' est invalide, et donc aussi éliminer immédiatement B', C' et D', en tant que tels en prenant le chaîne A-B comme chaîne valide la plus longue actuelle. Cependant, dans un blockchain fragmenté, aucun participant ne peut valider toutes les transactions sur toutes les fragments, ils doivent donc disposer d'un moyen de le confirmer à aucun moment. À aucun moment de l'histoire d'un fragment du blockchain, aucun bloc invalide n'a été inclus. A noter que contrairement aux forks, la réticulation à la chaîne Beacon n'est pas une solution suffisante, puisque la chaîne Beacon n'a pas la capacité de valider le blocs. Il peut uniquement valider qu'un nombre suffisant de validator dans cette partition signé le bloc (et en tant que tel attesté de son exactitude). Nous discuterons des solutions à ce problème dans la section 2.2 ci-dessous.

State Validity and Data Availability

State Validity and Data Availability

The core idea in sharded blockchains is that most participants operating or using the network cannot validate blocks in all the shards. As such, whenever any participant needs to interact with a particular shard they generally cannot download and validate the entire history of the shard. The partitioning aspect of sharding, however, raises a significant potential problem: without downloading and validating the entire history of a particular shard the participant cannot necessarily be certain that the state with which 5This section, except for subsection 2.5.3, was previously published at https://near.ai/ shard2. If you read it before, skip to the next section.

they interact is the result of some valid sequence of blocks and that such sequence of blocks is indeed the canonical chain in the shard. A problem that doesn’t exist in a non-sharded blockchain. We will first present a simple solution to this problem that has been proposed by many protocols and then analyze how this solution can break and what attempts have been made to address it. 2.1 Validators rotation The naive solution to state validity is shown on figure 5: let’s say we assume that the entire system has on the order of thousands validators, out of which no more than 20% are malicious or will otherwise fail (such as by failing to be online to produce a block). Then if we sample 200 validators, the probability of more than 1 3 failing for practical purposes can be assumed to be zero. Figure 5: Sampling validators 1 3 is an important threshold. There’s a family of consensus protocols, called BFT consensus protocols, that guarantees that for as long as fewer than 1 3 of participants fail, either by crashing or by acting in some way that violates the protocol, the consensus will be reached. With this assumption of honest validator percentage, if the current set of validators in a shard provides us with some block, the naive solution assumes that the block is valid and that it is built on what the validators believed to be the canonical chain for that shard when they started validating. The validators learned the canonical chain from the previous set of validators, who by the same assumption built on top of the block which was the head of the canonical chain before that. By induction the entire chain is valid, and since no set of validators at any point produced forks, the naive solution is also certain that the current chain is the only chain in the shard. See figure 6 for a visualization.

Figure 6: A blockchain with each block finalized via BFT consensus This simple solution doesn’t work if we assume that the validators can be corrupted adaptively, which is not an unreasonable assumption6. Adaptively corrupting a single shard in a system with 1000 shards is significantly cheaper than corrupting the entire system. Therefore, the security of the protocol decreases linearly with the number of shards. To have certainty in the validity of a block, we must know that at any point in history no shard in the system has a majority of validators colluding; with adaptive adversaries, we no longer have such certainty. As we discussed in section 1.5, colluding validators can exercise two basic malicious behaviors: create forks, and produce invalid blocks. Malicious forks can be addressed by blocks being cross-linked to the Beacon chain that is generally designed to have significantly higher security than the shard chains. Producing invalid blocks, however, is a significantly more challenging problem to tackle. 2.2 State Validity Consider figure 7 on which Shard #1 is corrupted and a malicious actor produces invalid block B. Suppose in this block B 1000 tokens were minted out of thin air on Alice’s account. The malicious actor then produces valid block C (in a sense that the transactions in C are applied correctly) on top of B, obfuscating the invalid block B, and initiates a cross-shard transaction to Shard #2 that transfers those 1000 tokens to Bob’s account. From this moment the improperly created tokens reside on an otherwise completely valid blockchain in Shard #2. Some simple approaches to tackle this problem are: 6Read this article for details on how adaptive corruption can be carried out: https://medium.com/nearprotocol/d859adb464c8. For more details on adaptive corruption, read https://github.com/ethereum/wiki/wiki/Sharding-FAQ# what-are-the-security-models-that-we-are-operating-under

Figure 7: A cross-shard transaction from a chain that has an invalid block 1. For validators of Shard #2 to validate the block from which the transaction is initiated. This won’t work even in the example above, since block C appears to be completely valid. 2. For validators in Shard #2 to validate some large number of blocks preceding the block from which the transaction is initiated. Naturally, for any number of blocks N validated by the receiving shard the malicious validators can create N+1 valid blocks on top of the invalid block they produced. A promising idea to resolve this issue would be to arrange shards into an undirected graph in which each shard is connected to several other shards, and only allow cross-shard transactions between neighboring shards (e.g. this is how Vlad Zamfir’s sharding essentially works7, and similar idea is used in Kadena’s Chainweb [1]). If a cross-shard transaction is needed between shards that are not neighbors, such transaction is routed through multiple shards. In this design a validator in each shard is expected to validate both all the blocks in their shard as well as all the blocks in all the neighboring shards. Consider a figure below with 10 shards, each having four neighbors, and no two shards requiring more than two hops for a cross-shard communication shown on figure 8. Shard #2 is not only validating its own blockchain, but also blockchains of all the neighbors, including Shard #1. So if a malicious actor on Shard #1 is attempting to create an invalid block B, then build block C on top of it and initiate a cross-shard transaction, such cross-shard transaction will not go through since Shard #2 will have validated the entire history of Shard #1 which will cause it to identify invalid block B. 7Read more about the design here: https://medium.com/nearprotocol/37e538177ed9

Figure 8: An invalid cross-shard transaction in chainweb-like system that will get detected While corrupting a single shard is no longer a viable attack, corrupting a few shards remains a problem. On figure 9 an adversary corrupting both Shard

1 and Shard #2 successfully executes a cross-shard transaction to Shard #3

with funds from an invalid block B: Figure 9: An invalid cross-shard transaction in chainweb-like system that will not get detected Shard #3 validates all the blocks in Shard #2, but not in Shard #1, and has no way to detect the malicious block. There are two major directions of properly solving state validity: fishermen

and cryptographic proofs of computation. 2.3 Fisherman The idea behind the first approach is the following: whenever a block header is communicated between chains for any purpose (such as cross-linking to the beacon chain, or a cross-shard transaction), there’s a period of time during which any honest validator can provide a proof that the block is invalid. There are various constructions that enable very succinct proofs that the blocks are invalid, so the communication overhead for the receiving nodes is way smaller than that of receiving a full block. With this approach for as long as there’s at least one honest validator in the shard, the system is secure. Figure 10: Fisherman This is the dominant approach (besides pretending the problem doesn’t exist) among the proposed protocols today. This approach, however, has two major disadvantages: 1. The challenge period needs to be sufficiently long for the honest validator to recognize a block was produced, download it, fully verify it, and prepare the challenge if the block is invalid. Introducing such a period would significantly slow down the cross-shard transactions. 2. The existence of the challenge protocol creates a new vector of attacks when malicious nodes spam with invalid challenges. An obvious solution to this problem is to make challengers deposit some amount of tokens that are returned if the challenge is valid. This is only a partial solution, as it might still be beneficial for the adversary to spam the system (and burn the deposits) with invalid challenges, for example to prevent the valid

challenge from a honest validator from going through. These attacks are called Grieving Attacks. See section 3.7.2 for a way to get around the latter point. 2.4 Succinct Non-interactive Arguments of Knowledge The second solution to multiple-shard corruption is to use some sort of cryptographic constructions that allow one to prove that a certain computation (such as computing a block from a set of transactions) was carried out correctly. Such constructions do exist, e.g. zk-SNARKs, zk-STARKs and a few others, and some are actively used in blockchain protocols today for private payments, most notably ZCash. The primary problem with such primitives is that they are notoriously slow to compute. E.g. Coda Protocol, that uses zk-SNARKs specifically to prove that all the blocks in the blockchain are valid, said in one of the interviews that it can take 30 seconds per transaction to create a proof (this number is probably smaller by now). Interestingly, a proof doesn’t need to be computed by a trusted party, since the proof not only attests to the validity of the computation it is built for, but to the validity of the proof itself. Thus, the computation of such proofs can be split among a set of participants with significantly less redundancy than would be necessary to perform some trustless computation. It also allows for participants who compute zk-SNARKs to run on special hardware without reducing the decentralization of the system. The challenges of zk-SNARKs, besides performance, are: 1. Dependency on less-researched and less-time-tested cryptographic primitives; 2. ”Toxic waste” — zk-SNARKs depend on a trusted setup in which a group of people performs some computation and then discards the intermediate values of that computation. If all the participants of the procedure collude and keep the intermediate values, fake proofs can be created; 3. Extra complexity introduced into the system design; 4. zk-SNARKs only work for a subset of possible computations, so a protocol with a Turing-complete smart contract language wouldn’t be able to use SNARKs to prove the validity of the chain. 2.5 Data Availability The second problem we will touch upon is data availability. Generally nodes operating a particular blockchain are separated into two groups: Full Nodes, those that download every full block and validate every transaction, and Light Nodes, those that only download block headers, and use Merkle proofs for parts of the state and transactions they are interested in, as shown on figure 11.

Figure 11: Merkle Tree Now if a majority of full nodes collude, they can produce a block, valid or invalid, and send its hash to the light nodes, but never disclose the full content of the block. There are various ways they can benefit from it. For example, consider figure 12: Figure 12: Data Availability problem There are three blocks: the previous, A, is produced by honest validators; the current, B, has validators colluding; and the next, C, will be also produced by honest validators (the blockchain is depicted in the bottom right corner). You are a merchant. The validators of the current block (B) received block A from the previous validators, computed a block in which you receive money,

and sent you a header of that block with a Merkle proof of the state in which you have money (or a Merkle proof of a valid transaction that sends the money to you). Confident the transaction is finalized, you provide the service. However, the validators never distribute the full content of the block B to anyone. As such, the honest validators of block C can’t retrieve the block, and are either forced to stall the system or to build on top of A, depriving you as a merchant of money. When we apply the same scenario to sharding, the definitions of full and light node generally apply per shard: validators in each shard download every block in that shard and validate every transaction in that shard, but other nodes in the system, including those that snapshot shard chains state into the beacon chain, only download the headers. Thus the validators in the shard are effectively full nodes for that shard, while other participants in the system, including the beacon chain, operate as light nodes. For the fisherman approach we discussed above to work, honest validators need to be able to download blocks that are cross-linked to the beacon chain. If malicious validators cross-linked a header of an invalid block (or used it to initiate a cross-shard transaction), but never distributed the block, the honest validators have no way to craft a challenge. We will cover three approaches to address this problem that complement each other. 2.5.1 Proofs of Custody The most immediate problem to be solved is whether a block is available once it is published. One proposed idea is to have so-called Notaries that rotate between shards more often than validators whose only job is to download a block and attest to the fact that they were able to download it. They can be rotated more frequently because they don’t need to download the entire state of the shard, unlike the validators who cannot be rotated frequently since they must download the state of the shard each time they rotate, as shown on figure 13. The problem with this naive approach is that it is impossible to prove later whether the Notary was or was not able to download the block, so a Notary can choose to always attest that they were able to download the block without even attempting to retrieve it. One solution to this is for Notaries to provide some evidence or to stake some amount of tokens attesting that the block was downloaded. One such solution is discussed here: https://ethresear.ch/t/ 1-bit-aggregation-friendly-custody-bonds/2236. 2.5.2 Erasure Codes When a particular light node receives a hash of a block, to increase the node’s confidence that the block is available it can attempt to download a few random pieces of the block. This is not a complete solution, since unless the light nodes collectively download the entire block the malicious block producers can choose

Figure 13: Validators need to download state and thus cannot be rotated frequently to withhold the parts of the block that were not downloaded by any light node, thus still making the block unavailable. One solution is to use a construction called Erasure Codes to make it possible to recover the full block even if only some part of the block is available, as shown on figure 14. Figure 14: Merkle tree built on top of erasure coded data Both Polkadot and Ethereum Serenity have designs around this idea that provide a way for light nodes to be reasonably confident the blocks are available. The Ethereum Serenity approach has a detailed description in [2].

2.5.3 Polkadot’s approach to data availability In Polkadot, like in most sharded solutions, each shard (called parachain) snapshots its blocks to the beacon chain (called relay chain). Say there are 2f + 1 validators on the relay chain. The block producers of the parachain blocks, called collators, once the parachain block is produced compute an erasure coded version of the block that consists of 2f +1 parts such that any f parts are sufficient to reconstruct the block. They then distribute one part to each validator on the relay chain. A particular relay chain validator would only sign on a relay chain block if they have their part for each parachain block that is snapshotted to such relay chain block. Thus, if a relay chain block has signatures from 2f + 1 validators, and for as long as no more than f of them violated the protocol, each parachain block can be reconstructed by fetching the parts from the validators that follow the protocol. See figure 15. Figure 15: Polkadot’s data availability 2.5.4 Long term data availability Note that all the approaches discussed above only attest to the fact that a block was published at all, and is available now. Blocks can later become unavailable for a variety of reasons: nodes going offline, nodes intentionally erasing historical data, and others. A whitepaper worth mentioning that addresses this issue is Polyshard [3], which uses erasure codes to make blocks available across shards even if several shards completely lose their data. Unfortunately their specific approach requires all the shards to download blocks from all other shards, which is prohibitively expensive. The long term availability is not as pressing of an issue: since no participant in the system is expected to be capable of validating all the chains in all the

shards, the security of the sharded protocol needs to be designed in such a way that the system is secure even if some old blocks in some shards become completely unavailable.

Validité de l’état et disponibilité des données

L'idée centrale des blockchain fragmentés est que la plupart des participants opérant ou l'utilisation du réseau ne peut pas valider les blocs dans tous les fragments. Ainsi, chaque fois tout participant doit interagir avec un fragment particulier qu'il ne peut généralement pas téléchargez et validez tout l’historique du fragment. L’aspect partitionnement du sharding soulève cependant un potentiel important. problème : sans télécharger et valider tout l'historique d'un particulier fragment, le participant ne peut pas nécessairement être certain que l'état avec lequel il 5Cette section, à l'exception de la sous-section 2.5.3, a été publiée précédemment à https://near.ai/ fragment2. Si vous l'avez déjà lu, passez à la section suivante.

ils interagissent est le résultat d’une séquence valide de blocs et que cette séquence de blocs est en effet la chaîne canonique du fragment. Un problème qui n'existe pas exister dans un blockchain non fragmenté. Nous présenterons dans un premier temps une solution simple à ce problème qui a été proposée par de nombreux protocoles, puis analyser comment cette solution peut échouer et ce qui des tentatives ont été faites pour y remédier. 2.1 Rotation des validateurs La solution naïve de la validité d’état est illustrée à la figure 5 : disons que nous supposons que l'ensemble du système possède de l'ordre de milliers de validator, parmi lesquels pas plus de 20 % sont malveillants ou échoueront autrement (par exemple en ne parvenant pas à être en ligne pour produire un bloc). Alors si nous échantillonnons 200 validators, la probabilité de plus de 1 3, pour des raisons pratiques, peut être considéré comme étant nul. Figure 5 : Échantillonnage de validators 1 3 est un seuil important. Il existe une famille de protocoles de consensus, appelés BFT protocoles de consensus, qui garantissent que pendant moins de 1 3 de les participants échouent, soit en s'écrasant, soit en agissant d'une manière qui viole le protocole, le consensus sera atteint. Avec cette hypothèse de pourcentage honnête de validator, si l'ensemble actuel de validators dans un fragment nous fournit un bloc, la solution naïve suppose que le bloc est valide et qu'il est construit sur ce que les validator pensaient être la chaîne canonique pour ce fragment lorsqu'ils ont commencé la validation. Les validator appris la chaîne canonique de l'ensemble précédent de validator, qui par la même hypothèse construite au sommet du bloc qui était la tête de la chaîne canonique avant ça. Par induction toute la chaîne est valide, et puisqu'aucun ensemble de validators à tout moment produit des fourches, la solution naïve est aussi certaine que le courant chain est la seule chaîne du fragment. Voir la figure 6 pour une visualisation.

Figure 6 : Un blockchain avec chaque bloc finalisé via le consensus BFT Cette solution simple ne fonctionne pas si nous supposons que les validator peuvent être corrompu de manière adaptative, ce qui n’est pas une hypothèse déraisonnable6. De manière adaptative corrompre un seul fragment dans un système comportant 1 000 fragments est beaucoup moins cher que de corrompre tout le système. Par conséquent, la sécurité du protocole diminue linéairement avec le nombre de fragments. Pour avoir la certitude de la validité de un bloc, nous devons savoir qu'à aucun moment de l'histoire aucun fragment du système n'a une majorité de validators sont de connivence ; avec des adversaires adaptatifs, nous n'avons plus une telle certitude. Comme nous l'avons vu dans la section 1.5, les validator de connivence peuvent exercer deux comportements malveillants de base : créer des forks et produire des blocs invalides. Les forks malveillants peuvent être résolus par des blocs réticulés à la chaîne Beacon qui est généralement conçue pour avoir une sécurité nettement supérieure à celle de Beacon. les chaînes d'éclats. Cependant, produire des blocs invalides est beaucoup plus compliqué. problème difficile à résoudre. 2.2 Validité de l'État Considérons la figure 7 sur laquelle le fragment n°1 est corrompu et un acteur malveillant produit bloc B invalide. Supposons que dans ce bloc B 1000 tokens aient été frappés à partir de minces diffusé sur le compte d’Alice. L'acteur malveillant produit alors un bloc C valide (dans un sens que les transactions en C sont appliquées correctement) au-dessus de B, obscurcissant le bloc B invalide et initie une transaction entre fragments vers le fragment n°2 qui transfère ces 1 000 token sur le compte de Bob. A partir de ce moment le mal Les token créés résident sur un blockchain par ailleurs entièrement valide dans le fragment n°2. Voici quelques approches simples pour résoudre ce problème : 6Lire ceci article pour détails sur comment adaptatif la corruption peut être porté dehors : https://medium.com/nearprotocol/d859adb464c8. Pour plus détails sur adaptatif la corruption, lire https://github.com/ethereum/wiki/wiki/Sharding-FAQ# quels-sont-les-modèles-de-sécurité-dans lesquels-nous-opérons-Figure 7 : Une transaction entre fragments d'une chaîne qui a un bloc invalide 1. Pour validators du Shard #2 pour valider le bloc à partir duquel la transaction est initiée. Cela ne fonctionnera pas même dans l'exemple ci-dessus, puisque le bloc C semble être tout à fait valable. 2. Pour les validator dans le fragment n°2 pour valider un grand nombre de blocs précédant le bloc à partir duquel la transaction est initiée. Naturellement, pour n'importe quel nombre de blocs N validés par le fragment récepteur du malware Les validator peuvent créer N+1 blocs valides au-dessus du bloc invalide qu'ils ont produit. Une idée prometteuse pour résoudre ce problème serait d'organiser les fragments dans un graphe non orienté dans lequel chaque fragment est connecté à plusieurs autres fragments, et autoriser uniquement les transactions entre fragments entre fragments voisins (par exemple, voici comment Le sharding de Vlad Zamfir fonctionne pour l’essentiel7, et une idée similaire est utilisée dans l’ouvrage de Kadena. Toile de chaîne [1]). Si une transaction entre fragments est nécessaire entre des fragments qui sont et non des voisins, une telle transaction est acheminée via plusieurs fragments. Dans cette conception un validator dans chaque fragment devrait valider à la fois tous les blocs de leur fragment ainsi que tous les blocs de tous les fragments voisins. Considérons une figure ci-dessous avec 10 fragments, chacun ayant quatre voisins, et pas deux fragments nécessitant plus plus de deux sauts pour une communication entre fragments illustrée à la figure 8. Le fragment n°2 valide non seulement ses propres blockchain, mais également les blockchain de tous les voisins, y compris Shard #1. Donc si un acteur malveillant sur le Shard #1 tente de créer un bloc B invalide, puis de construire le bloc C par-dessus et lancez une transaction entre fragments, une telle transaction entre fragments ne se déroulera pas puisque Shard #2 aura validé tout l'historique du Shard #1 qui le fera identifier le bloc B invalide. 7En savoir plus sur le design ici : https://medium.com/nearprotocol/37e538177ed9

Figure 8 : Une transaction entre fragments non valide dans un système de type chainweb qui être détecté Même si corrompre un seul fragment n'est plus une attaque viable, corrompre un seul fragment n'est plus une attaque viable. quelques fragments restent un problème. Sur la figure 9 un adversaire corrompt les deux Shard

1 et Shard #2 exécutent avec succès une transaction entre fragments avec Shard #3

avec des fonds provenant d'un bloc B invalide : Figure 9 : Une transaction entre fragments non valide dans un système de type chainweb qui ne pas être détecté Le fragment n°3 valide tous les blocs du fragment n°2, mais pas du fragment n°1, et n'a aucun moyen de détecter le bloc malveillant. Il existe deux directions principales pour résoudre correctement la validité d’état : les pêcheurs

et des preuves cryptographiques de calcul. 2.3 Pêcheur L'idée derrière la première approche est la suivante : chaque fois qu'un en-tête de bloc est communiqué entre les chaînes à quelque fin que ce soit (comme la réticulation avec le chaîne de balises, ou une transaction entre fragments), il y a une période de temps pendant lequel tout validator honnête peut fournir une preuve que le blocage est invalide. Là existe diverses constructions qui permettent des preuves très succinctes que les blocs sont invalide, donc la surcharge de communication pour les nœuds de réception est bien moindre que celui de recevoir un bloc complet. Avec cette approche tant qu’il y aura au moins un validator honnête dans le fragment, le système est sécurisé. Figure 10 : Pêcheur C’est l’approche dominante (en plus de prétendre que le problème n’existe pas) parmi les protocoles proposés aujourd’hui. Cette approche comporte cependant deux inconvénients majeurs : 1. La période de contestation doit être suffisamment longue pour l'honnête validator pour reconnaître qu'un bloc a été produit, le télécharger, le vérifier entièrement et préparer le défi si le bloc est invalide. L'introduction d'une telle période permettrait ralentir considérablement les transactions entre fragments. 2. L’existence du protocole de challenge crée un nouveau vecteur d’attaques lorsque des nœuds malveillants spamment avec des défis non valides. Une solution évidente à ce problème est d'obliger les challengers à déposer une certaine quantité de tokens qui sont rendus si le défi est valide. Il ne s'agit là que d'une solution partielle, car elle pourrait toujours être bénéfique pour l'adversaire de spammer le système (et de graver les dépôts) avec des défis invalides, par exemple pour empêcher ledéfi d'un honnête validator de passer à travers. Ces attaques sont appelés attaques de deuil. Voir la section 3.7.2 pour savoir comment contourner ce dernier point. 2.4 Arguments succincts et non interactifs de la connaissance La deuxième solution à la corruption de plusieurs fragments consiste à utiliser une sorte de construction cryptographique qui permet de prouver qu'un certain calcul (tel qu'un comme le calcul d'un bloc à partir d'un ensemble de transactions) a été effectué correctement. De telles constructions existent, par ex. zk-SNARK, zk-STARK et quelques autres, et certains sont aujourd'hui activement utilisés dans les protocoles blockchain pour les paiements privés, notamment ZCash. Le principal problème de ces primitives est qu’elles sont notoirement lents à calculer. Par ex. Protocole Coda, qui utilise zk-SNARK spécifiquement pour prouver que tous les blocs du blockchain sont valides, dit en un des entretiens que cela peut prendre 30 secondes par transaction pour créer une preuve (ce nombre est probablement plus petit maintenant). Il est intéressant de noter qu’une preuve n’a pas besoin d’être calculée par une partie de confiance, puisque la preuve atteste non seulement de la validité du calcul pour lequel elle est construite, mais aussi de la validité de la preuve elle-même. Ainsi, le calcul de ces preuves peut être divisé parmi un ensemble de participants avec une redondance significativement moindre qu'elle ne le serait nécessaire d'effectuer des calculs sans confiance. Il permet également aux participants qui calculent les zk-SNARK pour qu'ils fonctionnent sur du matériel spécial sans réduire le décentralisation du système. Les défis des zk-SNARK, outre les performances, sont : 1. Dépendance à des primitives cryptographiques moins recherchées et moins éprouvées ; 2. « Déchets toxiques » — les zk-SNARK dépendent d'une configuration fiable dans laquelle un groupe des personnes effectuent des calculs puis rejettent les calculs intermédiaires. valeurs de ce calcul. Si tous les participants à la procédure sont de connivence et conservez les valeurs intermédiaires, de fausses preuves peuvent être créées ; 3. Complexité supplémentaire introduite dans la conception du système ; 4. Les zk-SNARK ne fonctionnent que pour un sous-ensemble de calculs possibles, donc un protocole avec un langage smart contract Turing-complet ne serait pas en mesure d'utiliser SNARK pour prouver la validité de la chaîne. 2.5 Disponibilité des données Le deuxième problème que nous aborderons est la disponibilité des données. Généralement les nœuds exploitant un blockchain particulier sont séparés en deux groupes : les nœuds complets, ceux qui téléchargent chaque bloc complet et valident chaque transaction, et Light Les nœuds, ceux qui téléchargent uniquement les en-têtes de bloc et utilisent les preuves Merkle pour les pièces de l’État et des transactions qui les intéressent, comme le montre la figure 11.

Figure 11 : Arbre Merkle Désormais, si une majorité de nœuds complets s'entendent, ils peuvent produire un bloc, valide ou invalide, et envoie son hash aux nœuds légers, mais ne divulgue jamais le contenu complet du bloc. Ils peuvent en bénéficier de différentes manières. Par exemple, considérons la figure 12 : Figure 12 : Problème de disponibilité des données Il y a trois blocs : le précédent, A, est produit par des validator honnêtes ; le courant, B, a validators de connivence ; et le suivant, C, sera également produit par des validator honnêtes (le blockchain est représenté dans le coin inférieur droit). Vous êtes un commerçant. Les validators du bloc actuel (B) reçu A des validator précédents, calculé un bloc dans lequel vous recevez de l'argent,et vous a envoyé un en-tête de ce bloc avec une preuve Merkle de l'état dans lequel vous avez de l'argent (ou une preuve Merkle d'une transaction valide qui envoie l'argent à vous). Confiant que la transaction est finalisée, vous fournissez le service. Cependant, les validator ne distribuent jamais l'intégralité du contenu du bloc B à n'importe qui. En tant que tel, les validator honnêtes du bloc C ne peuvent pas récupérer le bloc, et sont obligés soit de bloquer le système, soit de construire au-dessus de A, vous privant en tant que marchand d'argent. Lorsque nous appliquons le même scénario au sharding, les définitions de full et le nœud léger s'applique généralement par fragment : validators dans chaque fragment téléchargé tous les bloquer ce fragment et valider chaque transaction dans ce fragment, mais d'autres nœuds du système, y compris ceux qui capturent l'état des chaînes de fragments dans le chaîne de balises, téléchargez uniquement les en-têtes. Ainsi, les validator dans la partition sont effectivement des nœuds complets pour cette partition, tandis que les autres participants du système, y compris la chaîne de balises, fonctionnent comme des nœuds lumineux. Pour que l’approche du pêcheur dont nous avons discuté ci-dessus fonctionne, des validator honnêtes doivent pouvoir télécharger des blocs qui sont réticulés à la chaîne de balises. Si des validator malveillants ont croisé l'en-tête d'un bloc invalide (ou l'ont utilisé pour lancer une transaction cross-shard), mais n'a jamais distribué le bloc, l'honnête Les validator n'ont aucun moyen de créer un défi. Nous aborderons trois approches pour résoudre ce problème qui complètent les uns les autres. 2.5.1 Preuves de garde Le problème le plus immédiat à résoudre est de savoir si un bloc est disponible une fois il est publié. Une idée proposée est d'avoir des notaires qui alternent entre les fragments plus souvent que les validator dont le seul travail est de télécharger un bloquer et attester du fait qu’ils ont pu le télécharger. Ils peuvent être tournés plus fréquemment car ils n'ont pas besoin de télécharger l'intégralité de l'état du fragment, contrairement aux validator qui ne peuvent pas être tournés fréquemment car ils doivent télécharger l'état du fragment à chaque rotation, comme indiqué sur la figure 13. Le problème de cette approche naïve est qu’il est impossible de prouver par la suite si le notaire a pu ou non télécharger le bloc, donc un notaire peuvent choisir de toujours attester qu'ils ont pu télécharger le bloc sans même en essayant de le récupérer. Une solution à ce problème est que les notaires fournissent des preuves ou de mettre en jeu une certaine quantité de tokens attestant que le bloc était téléchargé. Une de ces solutions est discutée ici : https://ethresear.ch/t/ Obligations de garde conviviales pour l'agrégation 1 bit/2236. 2.5.2 Codes d'effacement Lorsqu'un nœud léger particulier reçoit un hash d'un bloc, pour augmenter le nombre de nœuds sûr que le bloc est disponible, il peut tenter d'en télécharger quelques-uns au hasard. morceaux du bloc. Ce n'est pas une solution complète, car à moins que les nœuds légers téléchargez collectivement l'intégralité du bloc que les producteurs de blocs malveillants peuvent choisir

Figure 13 : Les validateurs doivent télécharger l'état et ne peuvent donc pas être pivotés fréquemment pour retenir les parties du bloc qui n'ont été téléchargées par aucun nœud léger, rendant ainsi toujours le bloc indisponible. Une solution consiste à utiliser une construction appelée Erasure Codes pour permettre pour récupérer le bloc complet même si seule une partie du bloc est disponible, comme indiqué sur la figure 14. Figure 14 : Merkle tree construit sur des données codées à effacement Polkadot et Ethereum Serenity ont tous deux des conceptions autour de cette idée qui fournir un moyen aux nœuds légers d'être raisonnablement sûrs que les blocs sont disponibles. L’approche Ethereum Sérénité a une description détaillée dans [2].2.5.3 L'approche de Polkadot en matière de disponibilité des données Dans Polkadot, comme dans la plupart des solutions fragmentées, chaque fragment (appelé parachain) capture ses blocs sur la chaîne de balises (appelée chaîne de relais). Disons qu'il y a 2f + 1 validators sur la chaîne de relais. Les producteurs de blocs de parachain, appelés les assembleurs, une fois le bloc parachain produit, calculent une version codée par effacement du bloc qui se compose de 2f +1 parties de telle sorte que toutes les parties f soient suffisantes pour reconstruire le bloc. Ils distribuent ensuite une part à chaque validator sur le chaîne de relais. Une chaîne de relais particulière validator ne signerait que sur une chaîne de relais bloquer s'ils ont leur part pour chaque bloc de parachain qui est instantané sur tel bloc de chaîne de relais. Ainsi, si un bloc de chaîne relais a des signatures de 2f + 1 validators, et tant que pas plus de f d'entre eux ont violé le protocole, chacun le bloc de parachain peut être reconstruit en récupérant les pièces des validators qui suivent le protocole. Voir la figure 15. Figure 15 : Disponibilité des données de Polkadot 2.5.4 Disponibilité des données à long terme Notez que toutes les approches évoquées ci-dessus attestent seulement du fait qu'un bloc a été publié et est disponible dès maintenant. Les blocs peuvent devenir indisponibles ultérieurement pour diverses raisons : nœuds mis hors ligne, nœuds effaçant intentionnellement l'historique. données, et autres. Un livre blanc digne de mention qui aborde ce problème est Polyshard [3], qui utilise des codes d'effacement pour rendre les blocs disponibles sur plusieurs fragments, même si plusieurs les fragments perdent complètement leurs données. Malheureusement, leur approche spécifique nécessite tous les fragments pour télécharger des blocs de tous les autres fragments, ce qui est prohibitif cher. La disponibilité à long terme n'est pas un problème aussi urgent : puisqu'aucun participant dans le système devrait être capable de valider toutes les chaînes dans tous les

fragments, la sécurité du protocole fragmenté doit être conçue de manière à manière dont le système est sécurisé même si certains anciens blocs de certains fragments deviennent totalement indisponible.

Nightshade

Nightshade

3.1 From shard chains to shard chunks The sharding model with shard chains and a beacon chain is very powerful but has certain complexities. In particular, the fork choice rule needs to be executed in each chain separately, the fork choice rule in the shard chains and the beacon chain must be built differently and tested separately. In Nightshade we model the system as a single blockchain, in which each block logically contains all the transactions for all the shards, and changes the whole state of all the shards. Physically, however, no participant downloads the full state or the full logical block. Instead, each participant of the network only maintains the state that corresponds to the shards that they validate transactions for, and the list of all the transactions in the block is split into physical chunks, one chunks per shard. Under ideal conditions each block contains exactly one chunk per shard per block, which roughly corresponds to the model with shard chains in which the shard chains produce blocks with the same speed as the beacon chain. However, due to network delays some chunks might be missing, so in practice each block contains either one or zero chunks per shard. See section 3.3 for details on how blocks are produced. Figure 16: A model with shard chains on the left and with one chain having blocks split into chunks on the right

3.2 Consensus The two dominant approaches to the consensus in the blockchains today are the longest (or heaviest) chain, in which the chain that has the most work or stake used to build it is considered canonical, and BFT, in which for each block some set of validators reach a BFT consensus. In the protocols proposed recently the latter is a more dominant approach, since it provides immediate finality, while in the longest chain more blocks need to be built on top of the block to ensure the finality. Often for a meaningful security the time it takes for sufficient number of blocks to be built takes on the order of hours. Using BFT consensus on each block also has disadvantages, such as: 1. BFT consensus involves considerable amount of communication. While recent advances allow the consensus to be reached in linear time in number of participants (see e.g. [4]), it is still noticeable overhead per block; 2. It is unfeasible for all the network participants to participate in the BFT consensus per block, thus usually only a randomly sampled subset of participants reach the consensus. A randomly sampled set can be, in principle, adaptively corrupted, and a fork in theory can be created. The system either needs to be modelled to be ready for such an event, and thus still have a fork-choice rule besides the BFT consensus, or be designed to shut down in such an event. It is worth mentioning that some designs, such as Algorand [5], significantly reduce the probability of adaptive corruption. 3. Most importantly, the system stalls if 1 3 or more of all the participants are offline. Thus, any temporary network glitch or a network split can completely stall the system. Ideally the system must be able to continue to operate for as long as at least half of the participants are online (heaviest chain-based protocols continue operating even if less than half of the participants are online, but the desirability of this property is more debatable within the community). A hybrid model in which the consensus used is some sort of the heaviest chain, but some blocks are periodically finalized using a BFT finality gadget maintain the advantages of both models. Such BFT finality gadgets are Casper FFG [6] used in Ethereum 2.0 8, Casper CBC (see https://vitalik. ca/general/2018/12/05/cbc_casper.html) and GRANDPA (see https:// medium.com/polkadot-network/d08a24a021b5) used in Polkadot. Nightshade uses the heaviest chain consensus. Specifically when a block producer produces a block (see section 3.3), they can collect signatures from other block producers and validators attesting to the previous block. See section 3.8 for details how such large number of signatures is aggregated. The weight 8Also see the whiteboard session with Justin Drake for an indepth overview of Casper FFG, and how it is integrated with the GHOST heaviest chain consensus here: https://www. youtube.com/watch?v=S262StTwkmo

of a block is then the cumulative stake of all the signers whose signatures are included in the block. The weight of a chain is the sum of the block weights. On top of the heaviest chain consensus we use a finality gadget that uses the attestations to finalize the blocks. To reduce the complexity of the system, we use a finality gadget that doesn’t influence the fork choice rule in any way, and instead only introduces extra slashing conditions, such that once a block is finalized by the finality gadget, a fork is impossible unless a very large percentage of the total stake is slashed. Casper CBC is such a finality gadget, and we presently model with Casper CBC in mind. We also work on a separate BFT protocol called TxFlow. At the time of writing this document it is unclear if TxFlow will be used instead of Casper CBC. We note, however, that the choice of the finality gadget is largely orthogonal to the rest of the design. 3.3 Block production In Nightshade there are two roles: block producers and validators. At any point the system contains w block producers, w = 100 in our models, and wv validators, in our model v = 100, wv = 10, 000. The system is Proof-of-Stake, meaning that both block producers and validators have some number of internal currency (referred to as ”tokens”) locked for a duration of time far exceeding the time they spend performing their duties of building and validating the chain. As with all the Proof of Stake systems, not all the w block producers and not all the wv validators are different entities, since that cannot be enforced. Each of the w block producers and the wv validators, however, do have a separate stake. The system contains n shards, n = 1000 in our model. As mentioned in section 3.1, in Nightshade there are no shard chains, instead all the block producers and validators are building a single blockchain, that we refer to as the main chain. The state of the main chain is split into n shards, and each block producer and validator at any moment only have downloaded locally a subset of the state that corresponds to some subset of the shards, and only process and validate transactions that affect those parts of the state. To become a block producer, a participant of the network locks some large amount of tokens (a stake). The maintenance of the network is done in epochs, where an epoch is a period of time on the order of days. The participants with the w largest stakes at the beginning of a particular epoch are the block producers for that epoch. Each block producer is assigned to sw shards, (say sw = 40, which would make sww/n = 4 block producers per shard). The block producer downloads the state of the shard they are assigned to before the epoch starts, and throughout the epoch collects transactions that affect that shard, and applies them to the state. For each block b on the main chain, and for every shards s, there’s one of the assigned block producers to s who is responsible to produce the part of b related to the shard. The part of b related to shard s is called a chunk, and contains the list of the transactions for the shard to be included in b, as well as the merkle

root of the resulting state. b will ultimately only contain a very small header of the chunk, namely the merkle root of all the applied transactions (see section 3.7.1 for exact details), and the merkle root of the final state. Throughout the rest of the document we often refer to the block producer that is responsible to produce a chunk at a particular time for a particular shard as a chunk producer. Chunk producer is always one of the block producers. The block producers and the chunk producers rotate each block according to a fixed schedule. The block producers have an order and repeatedly produce blocks in that order. E.g. if there are 100 block producers, the first block producers is responsible for producing blocks 1, 101, 201 etc, the second is responsible for producing 2, 102, 202 etc). Since chunk production, unlike the block production, requires maintaining the state, and for each shard only sww/n block producers maintain the state per shard, correspondingly only those sww/n block producers rotate to create chunks. E.g. with the constants above with four block producers assigned to each shard, each block producer will be creating chunks once every four blocks. 3.4 Ensuring data availability To ensure the data availability we use an approach similar to that of Polkadot described in section 2.5.3. Once a block producer produces a chunk, they create an erasure coded version of it with an optimal (w, ⌊w/6 + 1⌋) block code of the chunk. They then send one piece of the erasure coded chunk (we call such pieces chunk parts, or just parts) to each block producer. We compute a merkle tree that contains all the parts as the leaves, and the header of each chunk contains the merkle root of such tree. The parts are sent to the validators via onepart messages. Each such message contains the chunk header, the ordinal of the part and the part contents. The message also contains the signature of the block producer who produced the chunk and the merkle path to prove that the part corresponds to the header and is produced by the proper block producer. Once a block producer receives a main chain block, they first check if they have onepart messages for each chunk included in the block. If not, the block is not processed until the missing onepart messages are retrieved. Once all the onepart messages are received, the block producer fetches the remaining parts from the peers and reconstructs the chunks for which they hold the state. The block producer doesn’t process a main chain block if for at least one chunk included in the block they don’t have the corresponding onepart message, or if for at least one shard for which they maintain the state they cannot reconstruct the entire chunk. For a particular chunk to be available it is enough that ⌊w/6⌋+1 of the block producers have their parts and serve them. Thus, for as long as the number of malicious actors doesn’t exceed ⌊w/3⌋no chain that has more than half block producers building it can have unavailable chunks.

Figure 17: Each block contains one or zero chunks per shard, and each chunk is erasure coded. Each part of the erasure coded chunk is sent to a designated block producer via a special onepart message 3.4.1 Dealing with lazy block producers If a block producer has a block for which a onepart message is missing, they might choose to still sign on it, because if the block ends up being on chain it will maximize the reward for the block producer. There’s no risk for the block producer since it is impossible to prove later that the block producer didn’t have the onepart message. To address it we make each chunk producer when creating the chunk to choose a color (red or blue) for each part of the future encoded chunk, and store the bitmask of assigned color in the chunk before it is encoded. Each onepart message then contains the color assigned to the part, and the color is used when computing the merkle root of the encoded parts. If the chunk producer deviates from the protocol, it can be easily proven, since either the merkle root will not correspond to onepart messages, or the colors in the onepart messages that correspond to the merkle root will not match the mask in the chunk. When a block producer signs on a block, they include a bitmask of all the red parts they received for the chunks included in the block. Publishing an incorrect bitmask is a slashable behavior. If a block producer hasn’t received a onepart message, they have no way of knowing the color of the message, and thus have a 50% chance of being slashed if they attempt to blidnly sign the block. 3.5 State transition application The chunk producers only choose which transactions to include in the chunk but do not apply the state transition when they produce a chunk. Correspondingly,

the chunk header contains the merkle root of the merkelized state as of before the transactions in the chunk are applied. The transactions are only applied when a full block that includes the chunk is processed. A participant only processes a block if 1. The previous block was received and processed; 2. For each chunk the participant doesn’t maintain the state for they have seen the onepart message; 3. For each chunk the participant does maintain the state for they have the full chunk. Once the block is being processed, for each shard for which the participant maintains the state for, they apply the transactions and compute the new state as of after the transactions are applied, after which they are ready to produce the chunks for the next block, if they are assigned to any shard, since they have the merkle root of the new merkelized state. 3.6 Cross-shard transactions and receipts If a transaction needs to affect more than one shard, it needs to be consecutively executed in each shard separately. The full transaction is sent to the first shard affected, and once the transaction is included in the chunk for such shard, and is applied after the chunk is included in a block, it generates a so called receipt transaction, that is routed to the next shard in which the transaction need to be executed. If more steps are required, the execution of the receipt transaction generates a new receipt transaction and so on. 3.6.1 Receipt transaction lifetime It is desirable that the receipt transaction is applied in the block that immediately follows the block in which it was generated. The receipt transaction is only generated after the previous block was received and applied by block producers that maintain the originating shard, and needs to be known by the time the chunk for the next block is produced by the block producers of the destination shard. Thus, the receipt must be communicated from the source shard to the destination shard in the short time frame between those two events. Let A be the last produced block which contains a transaction t that generates a receipt r. Let B be the next produced block (i.e. a block that has A as its previous block) that we want to contain r. Let t be in the shard a and r be in the shard b. The lifetime of the receipt, also depicted on figure 18, is the following: Producing and storing the receipts. The chunk producer cpa for shard a receives the block A, applies the transaction t and generates the receipt r. cpa then stores all such produced receipts in its internal persistent storage indexed by the source shard id.

Distributing the receipts. Once cpa is ready to produce the chunk for shard a for block B, they fetch all the receipts generated by applying the transactions from block A for shard a, and included them into the chunk for shrad a in block B. Once such chunk is generated, cpa produces its erasure coded version and all the corresponding onepart messages. cpa knows what block producers maintain the full state for which shards. For a particular block producer bp cpa includes the receipts that resulted from applying transactions in block A for shard a that have any of the shards that bp cares about as their destination in the onepart message when they distributed the chunk for shard a in block B (see figure 17, that shows receipts included in the onepart message). Receiving the receipts. Remember that the participants (both block producers and validators) do not process blocks until they have onepart messages for each chunk included in the block. Thus, by the time any particular particpiant applies the block B, they have all the onepart messages that correspond to chunks in B, and thus they have all the incoming receipts that have the shards the participant maintains state for as their destination. When applying the state transition for a particular shard, the participant apply both the receipts that they have collected for the shard in the onepart messages, as well as all the transactions included in the chunk itself. Figure 18: The lifetime of a receipt transaction 3.6.2 Handling too many receipts It is possible that the number of receipts that target a particular shard in a particular block is too large to be processed. For example, consider figure 19, in which each transaction in each shard generates a receipt that targets shard 1. By the next block the number of receipts that shard 1 needs to process is comparable to the load that all the shards combined processed while handling the previous block.

Figure 19: If all the receipts target the same shard, the shard might not have the capacity to process them To address it we use a technique similar to that used in QuarkChain 9. Specifically, for each shard the last block B and the last shard s within that block from which the receipts were applied is recorded. When the new shard is created, the receipt are applied in order first from the remaining shards in B, and then in blocks that follow B, until the new chunk is full. Under normal circumstances with a balanced load it will generally result in all the receipts being applied (and thus the last shard of the last block will be recorded for each chunk), but during times when the load is not balanced, and a particular shard receives disproportionately many receipts, this technique allows them to be processed while respecting the limits on the number of transactions included. Note that if such unbalanced load remains for a long time, the delay from the receipt creation until application can continue growing indefinitely. One way to address it is to drop any transaction that creates a receipt targeting a shard that has a processing delay that exceeds some constant (e.g. one epoch). Consider figure 20. By block B the shard 4 cannot process all the receipts, so it only processes receipts origination from up to shard 3 in block A, and records it. In block C the receipts up to shard 5 in block B are included, and then by block D the shard catches up, processing all the remaining receipts in block B and all the receipts from block C. 3.7 Chunks validation A chunk produced for a particular shard (or a shard block produced for a particular shard chain in the model with shard chains) can only be validated by the 9See the whiteboard episode with QuarkChain here: https://www.youtube.com/watch? v=opEtG6NM4x4, in which the approach to cross-shard transactions is discussed, among other things

Figure 20: Delayed receipts processing participants that maintain the state. They can be block producers, validators, or just external witnesses that downloaded the state and validate the shard in which they store assets. In this document we assume that majority of the participants cannot store the state for a large fraction of the shards. It is worth mentioning, however, that there are sharded blockchains that are designed with the assumption that most participants do have capacity to store the state for and validate most of the shards, such as QuarkChain. Since only a fraction of the participants have the state to validate the shard chunks, it is possible to adaptive corrupt just the participants that have the state, and apply an invalid state transition. Multiple sharding designs were proposed that sample validators every few days, and within a day any block in the shard chain that has more than 2/3 of signatures of the validators assigned to such shard is immediately considered final. With such approach an adaptive adversary only needs to corrupt 2n/3+1 of the validators in a shard chain to apply an invalid state transition, which, while is likely hard to pull off, is not a level of security sufficient for a public blockchain. As discussed in section 2.3, the common approach is to allow a certain window of time after a block is created for any participant that has state (whether it’s a block producer, a validator, or an external observer) to challenge its validity. Such participants are called Fishermen. For a fisherman to be able to challenge an invalid block, it must be ensured that such a block is available to them. The data availability in Nightshade is discussed in section 3.4. In Nightshade once a block is produced, the chunks were not validated by anyone but the actual chunk producer. In particular, the block producer that suggested the block naturally didn’t have the state for most of the shards, and

was not able to validate the chunks. When the next block is produced, it contains attestations (see section 3.2) of multiple block producers and validators, but since the majority of block producers and validators do not maintain state for most shards as well, a block with just one invalid chunk will collect significantly more than half of the attestations and will continue being on the heaviest chain. To address this issue, we allow any participant that maintains the state of a shard to submit a challenge on-chain for any invalid chunk produced in that shard. 3.7.1 State validity challenge Once a participant detects that a particular chunk is invalid, they need to provide a proof that the chunk is invalid. Since the majority of the network participants do not maintain the state for the shard in which the invalid chunk is produced, the proof needs to have sufficient information to confirm the block is invalid without having the state. We set a limit Ls of the amount of state (in bytes) that a single transaction can cumulatively read or write. Any transaction that touches more than Ls state is considered to be invalid. Remember from the section 3.5 that the chunk in a particular block B only contains the transactions to be applied, but not the new state root. The state root included in the chunk in block B is the state root before applying such transactions, but after applying the transactions from the last chunk in the same shard before the block B. A malicious actor that wishes to apply an invalid state transition would include an incorrect state root in block B that doesn’t correspond to the state root that results from applying the transactions in the preceding chunk. We extend the information that a chunk producer includes in the chunk. Instead of just including the state after applying all the transactions, it instead includes a state root after applying each contiguous set of transactions that collectively read and write Ls bytes of state. With this information for the fisherman to create a challenge that a state transition is applied incorrectly it is sufficient to find the first such invalid state root, and include just Ls bytes of state that are affected by the transactions between the last state root (which was valid) and the current state root with the merkle proofs. Then any participant can validate the transactions in the segment and confirm that the chunk is invalid. Similarly, if the chunk producer attempted to include transactions that read and write more than Ls bytes of state, for the challenge it is enough to include the first Ls bytes it touches with the merkle proofs, which will be enough to apply the transactions and confirm that there’s a moment when an attempt to read or write content beyond Ls bytes is made.

3.7.2 Fishermen and fast cross-shard transactions As discussed in section 2.3, once we assume that the shard chunks (or shard blocks in the model with shard chains) can be invalid and introduce a challenge period, it negatively affects the finality, and thus cross-shard communication. In particular, the destination shard of any cross-shard transction cannot be certain the originating shard chunk or block is final until the challenge period is over (see figure 21). Figure 21: Waiting for the challenge period before applying a receipt The way to address it in a way that makes the cross-shard transactions instantenious is for the destination shard to not wait for the challenge period after the source shard transaction is published, and apply the receipt transaction immediately, but then roll back the destination shard together with the source shard if later the originating chunk or block was found to be invalid (see figure 22). This applies very naturally to the Nightshade design in which the shard chains are not independent, but instead the shard chunks are all published together in the same main chain block. If any chunk is found to be invalid, the entire block with that chunk is considered invalid, and all the blocks built on top of it. See figure 23. Both of the above approaches provide atomicity assuming that the challenge period is sufficiently long. We use the latter approach since providing fast crossshard transactions under normal circumstances outweights the inconvenience of the destination shard rolling back due to an invalid state transition in one of the source shards, which is an extremely rare event. 3.7.3 Hiding validators The existence of the challenges already significantly reduces the probability of adaptive corruption, since to finalize a chunk with an invalid state transition post

Figure 22: Applying receipts immediately and rolling back the destination chain if the source chain had an invalid block Figure 23: Fisherman challenge in Nightshade the challenge period the adaptive adversary needs to corrupt all the participants that maintain the state of the shard, including all the validators. Estimating the likelihood of such an event is extremely complex, since no sharded blockchain has been live sufficiently long for any such attack to be attempted. We argue that the probability, while extremely low, is still sufficiently large for a system that is expected to execute multi-million transactions and run a world-wide financial operations. There are two main reasons for this belief: 1. Most of the validators of the Proof-of-Stake chains and miners of the

Proof-of-Work chains are primarily incentivized by the financial upside. If an adaptive adversary offers them more money then the expected return from operating honestly, it is reasonable to expect that many validators will accept the offer. 2. Many entities do validation of Proof-of-Stake chains professionally, and it is expected that a large percentage of the stake in any chain will be from such entities. The number of such entities is sufficiently small for an adaptive adversary to get to know most of them personally and have a good understanding of their inclanation to be corrupted. We take one step further in reducing the probability of the adaptive corruption by hiding which validators are assigned to which shard. The idea is remotely similar to the way Algorand [5] conceals validators. It is critical to note that even if the validators are concealed, as in Algorand or as described below, the adaptive corruption is still in theory possible. While the adaptive adversary doesn’t know the participants that will create or validate a block or a chunk, the participants themselves do know that they will perform such a task and have a cryptographic proof of it. Thus, the adversary can broadcast their intent to corrupt, and pay to any participant that will provide such a cryptographic proof. We note however, that since the adversary doesn’t know the validators that are assigned to the shard they want to corrupt, they have no other choice but to broadcast their intent to corrupt a particular shard to the entire community. At that point it is economically beneficial for any honest participant to spin up a full node that validates that shard, since there’s a high chance of an invalid block appearing in that shard, which is an opportunity to create a challenge and collect associated reward. To not reveal the validators that are assigned to a particular shard, we do the following (see figure 24): Using VRF to get the assignment. At the beginning of each epoch each validator uses a VRF to get a bitmask of the shards the validator is assigned to. The bitmask of each validator will have Sw bits (see section 3.3 for the definition of Sw). The validator then fetches the state of the corresponding shards, and during the epoch for each block received validates the chunks that correspond to the shards that the validator is assigned to. Sign on blocks instead of chunks. Since the shards assignment is concealed, the validator cannot sign on chunks. Instead it always signs on the entire block, thus not revealing what shards it validates. Specifically, when the validator receives a block and validates all the chunks, it either creates a message that attests that all the chunks in all the shards the validator is assigned to are valid (without indicating in any way what those shards are), or a message that contains a proof of an invalid state transition if any chunk is invalid. See the section 3.8 for the details on how such messages are aggregated, section 3.7.4 for the details on how to prevent validators from piggy-backing on messages from other validators, and section 3.7.5 for the details how to reward and punish validators should a successful invalid state transition challenge actually happen.

Figure 24: Concealing the validators in Nightshade 3.7.4 Commit-Reveal One of the common problems with validators is that a validator can skip downloading the state and actually validating the chunks and blocks, and instead observe the network, see what the other validators submit and repeat their messages. A validator that follows such a strategy doesn’t provide any extra security for the network, but collects rewards. A common solution for this problem is for each validator to provide a proof that they actually validated the block, for example by providing a unique trace of applying the state transition, but such proofs significantly increase the cost of validation. Figure 25: Commit-reveal

Instead we make the validators first commit to the validation result (either the message that attests to the validity of the chunks, or the proof of an invalid state transition), wait for a certain period, and only then reveal the actual validation result, as shown on figure 25. The commit period doesn’t intersect with the reveal period, and thus a lazy validator cannot copycat honest validators. Moreover, if a dishonest validator committed to a message that attests to the validity of the assigned chunks, and at least one chunk was invalid, once it is shown that the chunk is invalid the validator cannot avoid the slashing, since, as we show in section 3.7.5, the only way to not get slashed in such a situation is to present a message that contains a proof of the invalid state transition that matches the commit. 3.7.5 Handling challenges As discussed above, once a validator receives a block with an invalid chunk, they first prepare a proof of the invalid state transition (see section 3.7.1), then commit to such a proof (see 3.7.4), and after some period reveal the challenge. Once the revealed challenge is included in a block, the following happens: 1. All the state transitions that happened from the block containing the invalid chunk until the block in which the revealed challenge is included get nullyfied. The state before the block that includes the revealed challenge is considered to be the same as the state before the block that contained the invalid chunk. 2. Within a certain period of time each validator must reveal their bitmask of the shards they validate. Since the bitmask is created via a VRF, if they were assigned to the shard that had the invalid state transition, they cannot avoid revealing it. Any validator that fails to reveal the bitmask is assumed to be assigned to the shard. 3. Each validator that after such period is found to be assigned to the shard, that did commit to some validation result for the block containing the invalid chunk and that didn’t reveal the proof of invalid state transition that corresponds to their commit is slashed. 4. Each validator gets a new shards assignment, and a new epoch is scheduled to start after some time sufficient for all the validators to download the state, as shown on figure 26. Note that from the moment the validators reveal the shards they are assigned to until the new epoch starts the security of the system is reduced since the shards assignment is revealed. The participants of the network need to keep it in mind while using the network during such period. 3.8 Signature Aggregation For a system with hudreds of shards to operate securely, we want to have on the order of 10, 000 or more validators. As discussed in section 3.7, we want each

Figure 26: Handling the challenge validator to publish a commit to a certain message and a signature on average once per block. Even if the commit messages were the same, aggregating such a BLS-signature and validating it would have been prohibitively expensive. But naturally the commit and reveal messages are not the same across validators, and thus we need some way to aggregate such messages and the signatures in a way that allows for fast validation later. The specific approach we use is the following: Validators joining block producers. The block producers are known some time before the epoch starts, since they need some time to download the state before the epoch starts, and unlike the validators the block producers are not concealed. Each block producer has v validator slots. Validators submit off-chain proposals to the block producers to get included as one of their v validators. If a block producer wishes to include a validator, they submit a transaction that contains the initial off-chainrequest from the validator, and the block producer’s signature that makes the validator join the block producer. Note that the validators assigned to the block producers do not necessarily validate the same shards that the block producer produces chunks for. If a validator applied to join multiple block producers, only the transaction from the first block producer will succeed. Block producers collect commits. The block producer constantly collects the commit and reveal messages from the validators. Once a certain number of such messages are accumulated, the block producer computes a merkle tree of these messages, and sends to each validator the merkle root and the merkle path to their message. The validator validates the path and signs on the merkle root. The block producer then accumulates a BLS signature on the merkle root from the validators, and publishes only the merkle root and the accumulated signature. The block producer also signs on the validity of the multisignature using a cheap ECDSA signature. If the multisignature doesn’t match the merkle root submitted or the bitmask of the validators participating, it is a slashable behavior. When synchronizing the chain, a participant can choose to validate all the BLS signatures from the validators (which is extremely expensive since it involves aggregating validators public keys), or only

the ECDMA signatures from the block producers and rely on the fact that the block producer was not challenged and slashed. Using on-chain transactions and merkle proofs for challenges. It can be noted that there’s no value in revealing messages from validators if no invalid state transition was detected. Only the messages that contain the actual proofs of invalid state transition need to be revealed, and only for such messages it needs to be shown that they match the prior commit. The message needs to be revealed for two purposes: 1. To actually initiate the rollback of the chain to the moment before the invalid state transition (see section 3.7.5). 2. To prove that the validator didn’t attempt to attest to the validity of the invalid chunk. In either case we need to address two issues: 1. The actual commit was not included on chain, only the merkle root of the commit aggregated with other messages. The validator needs to use the merkle path provided by the block producer and their original commit to prove that they committed to the challenge. 2. It is possible that all the validators assigned to the shard with the invalid state transition happen to be assigned to corrupted block producers that are censoring them. To get around it we allow them to submit their reveals as a regular transaction on-chain and bypass the aggregation. The latter is only allowed for the proofs of invalid state transition, which are extremely rare, and thus should not result in spamming the blocks. The final issue that needs to be addressed is that the block producers can choose not to participate in messages aggregation or intentionally censor particular validators. We make it economically disadvantageous, by making the block producer reward proportional to the number of validators assigned to them. We also note that since the block producers between epochs largely intersect (since it’s always the top w participants with the highest stake), the validators can largely stick to working with the same block producers, and thus reduce the risk of getting assigned to a block producer that censored them in the past. 3.9 Snapshots Chain Since the blocks on the main chain are produced very frequently, downloading the full history might become expensive very quickly. Moreover, since every block contains a BLS signature of a large number of participants, just the aggregation of the public keys to check the signature might become prohibitively expensive as well. Finally, since in any foreseeable future Ethereum 1.0 will likely remain one of the most used blockchains, having a meaningful way to transfer assets from

Near to Ethereum is a requirement, and today verifying BLS signatures to ensure Near blocks validity on Ethereum’s side is not possible. Each block in the Nightshade main chain can optionally contain a Schnorr multisignature on the header of the last block that included such a Schnorr multisignature. We call such blocks snapshot blocks. The very first block of every epoch must be a snapshot block. While working on such a multisignature, the block producers must also accumulate the BLS signatures of the validators on the last snapshot block, and aggregate them the same way as described in section 3.8. Since the block producers set is constant throughout the epoch, validating only the first snapshot blocks in each epoch is sufficient assuming that at no point a large percentage of block producers and validators colluded and created a fork. The first block of the epoch must contain information sufficient to compute the block producers and validators for the epoch. We call the subchain of the main chain that only contains the snapshot blocks a snapshot chain. Creating a Schnorr multisignature is an interactive process, but since we only need to perform it infrequently, any, no matter how inefficient, process will suffice. The Schnorr multisignatures can be easily validated on Ethereum, thus providing crucial primitives for a secure way of performing cross-blockchain communication. To sync with the Near chain one only needs to download all the snapshot blocks and confirm that the Schnorr signatures are correct (optionally also verifying the individual BLS signatures of the validators), and then only syncing main chain blocks from the last snapshot block.

Nightshade

3.1 Des chaînes de fragments aux fragments de fragments Le modèle de partage avec des chaînes de fragments et une chaîne de balises est très puissant mais présente certaines complexités. En particulier, la règle de choix de fork doit être exécutée dans chaque chaîne séparément, la règle de choix des fourches dans les chaînes de fragments et la balise La chaîne doit être construite différemment et testée séparément. Dans Nightshade, nous modélisons le système comme un seul blockchain, dans lequel chaque Le bloc contient logiquement toutes les transactions pour tous les fragments et modifie le état complet de tous les fragments. Mais physiquement, aucun participant ne télécharge le état complet ou le bloc logique complet. Au lieu de cela, chaque participant du réseau uniquement maintient l'état qui correspond aux fragments pour lesquels ils valident les transactions, et la liste de toutes les transactions du bloc est divisée en transactions physiques morceaux, un morceau par fragment. Dans des conditions idéales, chaque bloc contient exactement un morceau par fragment et par bloc, ce qui correspond à peu près au modèle avec des chaînes de fragments dans lequel le les chaînes de fragments produisent des blocs à la même vitesse que la chaîne de balise. Cependant, en raison des retards du réseau, certains morceaux peuvent manquer, donc en pratique, chaque bloc contient un ou zéro fragment par fragment. Voir la section 3.3 pour plus de détails sur la façon des blocs sont produits. Figure 16 : Un modèle avec des chaînes d'éclats à gauche et avec une chaîne ayant blocs divisés en morceaux à droite

3.2 Consensus Les deux approches dominantes du consensus dans les blockchain aujourd'hui sont la chaîne la plus longue (ou la plus lourde), dans laquelle la chaîne qui a le plus de travail ou d'enjeux utilisé pour le construire est considéré comme canonique, et BFT, dans lequel pour chaque bloc certains un ensemble de validator parviennent à un consensus BFT. Dans les protocoles proposés récemment, cette dernière approche est plus dominante, car il fournit une finalité immédiate, alors que dans la chaîne la plus longue, davantage de blocs ont besoin à construire au sommet du bloc pour assurer la finalité. Souvent pour un but significatif sécurité, le temps nécessaire pour construire un nombre suffisant de blocs prend le temps ordre des heures. L'utilisation du consensus BFT sur chaque bloc présente également des inconvénients, tels que : 1. Le consensus BFT implique une quantité considérable de communication. Tandis que les avancées récentes permettent d’atteindre le consensus dans un temps linéaire en nombre des participants (voir par exemple [4]), la surcharge par bloc est toujours perceptible ; 2. Il n'est pas possible que tous les participants du réseau participent au BFT consensus par bloc, donc généralement seul un sous-ensemble de participants échantillonné au hasard atteint le consensus. Un ensemble échantillonné aléatoirement peut, en principe, être corrompu de manière adaptative, et un fork peut en théorie être créé. Le système l'un ou l'autre doit être modélisé pour être prêt à un tel événement, et donc toujours avoir une règle de choix de fourchette en plus du consensus BFT, ou être conçu pour fermer dans un tel événement. Il convient de mentionner que certains modèles, tels que Algorand [5], réduisent considérablement la probabilité de corruption adaptative. 3. Plus important encore, le système se bloque si 1 3 ou plus de tous les participants sont hors ligne. Ainsi, tout problème de réseau temporaire ou division du réseau peut complètement bloquer le système. Idéalement, le système doit pouvoir continuer à fonctionner tant qu’au moins la moitié des participants sont en ligne (le plus lourd les protocoles basés sur des chaînes continuent de fonctionner même si moins de la moitié des participants sont en ligne, mais l'opportunité de cette propriété est plus discutable au sein de la communauté). Un modèle hybride dans lequel le consensus utilisé est en quelque sorte le plus lourd chaîne, mais certains blocs sont périodiquement finalisés à l'aide d'un gadget de finalité BFT pour conserver les avantages des deux modèles. De tels gadgets BFT finalités sont Casper FFG [6] utilisé dans Ethereum 2.0 8, Casper CBC (voir https://vitalik. ca/general/2018/12/05/cbc_casper.html) et GRANDPA (voir https:// medium.com/polkadot-network/d08a24a021b5) utilisé dans Polkadot. Nightshade utilise le consensus de chaîne le plus lourd. Plus précisément lorsqu'un bloc producteur produit un bloc (voir section 3.3), il peut recueillir les signatures de d'autres producteurs de blocs et des validator attestant du bloc précédent. Voir la rubrique 3.8 pour plus de détails sur la manière dont un si grand nombre de signatures est regroupé. Le poids 8Voir également la séance sur tableau blanc avec Justin Drake pour un aperçu approfondi de Casper FFG, et comment il est intégré au consensus de la chaîne la plus lourde GHOST ici : https://www. youtube.com/watch?v=S262StTwkmod'un bloc est alors la mise cumulée de tous les signataires dont les signatures sont inclus dans le bloc. Le poids d'une chaîne est la somme des poids des blocs. En plus du consensus en chaîne le plus lourd, nous utilisons un gadget de finalité qui utilise les attestations pour finaliser les blocs. Pour réduire la complexité du système, nous utilisons un gadget de finalité qui n’influence en rien la règle de choix du fork, et à la place, il n'introduit que des conditions de réduction supplémentaires, telles qu'une fois qu'un bloc est finalisé par le gadget de finalité, un fork est impossible à moins qu'un très grand pourcentage de la mise totale est réduite. Casper CBC est un gadget tellement définitif, et nous modèle actuellement avec Casper CBC à l’esprit. Nous travaillons également sur un protocole BFT distinct appelé TxFlow. Au moment de en écrivant ce document, il n'est pas clair si TxFlow sera utilisé à la place de Casper Radio-Canada. On constate cependant que le choix de la finalité du gadget est largement orthogonal au reste du design. 3.3 Production de blocs Dans Nightshade, il y a deux rôles : les producteurs de blocs et les validator. À tout moment point où le système contient w producteurs de blocs, w = 100 dans nos modèles, et wv validators, dans notre modèle v = 100, wv = 10 000. Le système est une preuve de participation, ce qui signifie que les producteurs de blocs et les validator ont un certain nombre de monnaie (appelée « tokens ») verrouillée pendant une durée dépassant largement la durée le temps qu'ils passent à accomplir leurs tâches de construction et de validation de la chaîne. Comme pour tous les systèmes Proof of Stake, tous les producteurs de blocs w et non tous les wv validator sont des entités différentes, puisque cela ne peut pas être appliqué. Chacun des producteurs de blocs w et des wv validators, cependant, ont un enjeu. Le système contient n fragments, n = 1000 dans notre modèle. Comme mentionné dans section 3.1, dans Nightshade, il n'y a pas de chaînes de fragments, à la place, tous les producteurs de blocs et validator construisent un seul blockchain, que nous appelons le chaîne principale. L'état de la chaîne principale est divisé en n fragments, et chaque bloc producteur et validator à tout moment n'ont téléchargé localement qu'un sous-ensemble de l'état qui correspond à un sous-ensemble de fragments, et uniquement le processus et valider les transactions qui affectent ces parties de l’État. Pour devenir producteur de blocs, un participant du réseau verrouille de gros montant de tokens (une mise). La maintenance du réseau se fait par époques, où une époque est une période de temps de l’ordre des jours. Les participants avec les enjeux les plus importants au début d'une époque particulière sont le bloc producteurs pour cette époque. Chaque producteur de blocs est affecté à des fragments sw (par exemple sw = 40, ce qui ferait sww/n = 4 producteurs de blocs par fragment). Le bloc le producteur télécharge l'état du fragment auquel il est affecté avant l'époque commence et, tout au long de l'époque, collecte les transactions qui affectent ce fragment, et les applique à l'État. Pour chaque bloc b de la chaîne principale et pour chaque fragment s, il y a l'un des assigné des producteurs de blocs à s qui est responsable de produire la partie de b liée au tesson. La partie de b liée au fragment s est appelée un morceau et contient le liste des transactions pour le fragment à inclure dans b, ainsi que le merkleracine de l’état résultant. b ne contiendra finalement qu'un tout petit en-tête de le chunk, à savoir la racine merkle de toutes les transactions appliquées (voir section 3.7.1 pour les détails exacts), et la racine Merkle de l’état final. Dans le reste du document, nous faisons souvent référence au producteur de blocs. qui est chargé de produire un morceau à un moment donné pour un fragment particulier en tant que producteur de morceaux. Le producteur de morceaux est toujours l'un des producteurs de blocs. Les producteurs de blocs et les producteurs de morceaux font tourner chaque bloc en fonction à un horaire fixe. Les producteurs de blocs ont une commande et produisent à plusieurs reprises blocs dans cet ordre. Par ex. s'il y a 100 producteurs de blocs, le premier bloc les producteurs sont responsables de la production des blocs 1, 101, 201 etc, le second est responsable de la production 2, 102, 202 etc.). Puisque la production de morceaux, contrairement à la production de blocs, nécessite le maintien l'état, et pour chaque fragment, seuls les producteurs de blocs sww/n maintiennent l'état par fragment, en conséquence, seuls les producteurs de blocs sww/n tournent pour créer morceaux. Par ex. avec les constantes ci-dessus avec quatre producteurs de blocs affectés à chaque fragment, chaque producteur de blocs créera des morceaux une fois tous les quatre blocs. 3.4 Assurer la disponibilité des données Pour garantir la disponibilité des données, nous utilisons une approche similaire à celle de Polkadot décrit à la section 2.5.3. Une fois qu'un producteur de blocs produit un morceau, il crée une version codée par effacement avec un code de bloc optimal (w, ⌊w/6 + 1⌋) du morceau. Ils envoient ensuite un morceau du morceau codé à effacement (nous appelons ces morceaux morceaux, ou juste des pièces) à chaque producteur de blocs. Nous calculons un arbre Merkle qui contient toutes les parties comme les feuilles, et le l'en-tête de chaque morceau contient la racine merkle de cet arbre. Les pièces sont envoyées aux validator via des messages onepart. Chacun de ces messages contient l'en-tête du bloc, l'ordinal de la partie et le contenu de la partie. Le Le message contient également la signature du producteur du bloc qui a produit le chunk et le chemin merkle pour prouver que la pièce correspond à l'en-tête et est produit par le producteur de blocs approprié. Une fois qu'un producteur de blocs reçoit un bloc de chaîne principale, il vérifie d'abord s'il avoir des messages en une partie pour chaque morceau inclus dans le bloc. Sinon, le bloc n'est pas traité tant que les messages en une partie manquants n'ont pas été récupérés. Une fois tous les messages en une partie reçus, le producteur de blocs récupère le parties restantes des pairs et reconstruit les morceaux pour lesquels ils détiennent l'État. Le producteur de blocs ne traite pas un bloc de la chaîne principale si pour au moins un morceau inclus dans le bloc, ils n'ont pas le message en une partie correspondant, ou si pour au moins un fragment pour lequel ils maintiennent l'état, ils ne peuvent pas reconstruire le morceau entier. Pour qu'un morceau particulier soit disponible, il suffit que ⌊w/6⌋+1 du bloc les producteurs ont leurs pièces et les servent. Ainsi, aussi longtemps que le nombre de les acteurs malveillants ne dépassent pas ⌊w/3⌋aucune chaîne comportant plus de la moitié du bloc les producteurs qui le construisent peuvent avoir des morceaux indisponibles.Figure 17 : Chaque bloc contient un ou zéro fragment par fragment, et chaque fragment est codé par effacement. Chaque partie du morceau codé d'effacement est envoyée à un producteur de blocs via un message spécial en une seule partie 3.4.1 Faire face aux producteurs de blocs paresseux Si un producteur de blocs possède un bloc pour lequel un message en une seule partie manque, il pourrait choisir de continuer à le signer, car si le bloc finit par être en chaîne, il maximisera la récompense pour le producteur de blocs. Il n'y a aucun risque pour le blocage producteur puisqu’il est impossible de prouver par la suite que le producteur du bloc n’avait pas le message en une partie. Pour résoudre ce problème, nous faisons en sorte que chaque morceau soit producteur lors de la création du morceau. choisissez une couleur (rouge ou bleu) pour chaque partie du futur morceau encodé, et stockez le masque de bits de la couleur attribuée dans le bloc avant qu'il ne soit codé. Chaque partie Le message contient alors la couleur attribuée à la pièce, et la couleur est utilisée lorsque calculer la racine merkle des parties codées. Si le producteur de morceaux s'écarte du protocole, cela peut être facilement prouvé, puisque soit la racine merkle ne sera pas correspondent aux messages en une partie, ou aux couleurs des messages en une partie qui correspondre à la racine merkle ne correspondra pas au masque dans le morceau. Lorsqu'un producteur de blocs signe sur un bloc, il inclut un masque de bits de tous les pièces rouges qu'ils ont reçues pour les morceaux inclus dans le bloc. Publier un un masque de bits incorrect est un comportement slashable. Si un producteur de blocs n'a pas reçu de message en une seule partie, ils n'ont aucun moyen de connaître la couleur du message, et ils ont donc 50% de chances d'être sabrés s'ils tentent de signer aveuglément le bloquer. 3.5 Demande de transition d'état Les producteurs de fragments choisissent uniquement les transactions à inclure dans le fragment, mais n'appliquez pas la transition d'état lorsqu'ils produisent un morceau. En conséquence,

l'en-tête du bloc contient la racine merkle de l'état merkelisé comme avant les transactions du bloc sont appliquées. Les transactions ne sont appliquées que lorsqu'un bloc complet incluant le morceau est traité. Un participant ne traite un blocage que si 1. Le bloc précédent a été reçu et traité ; 2. Pour chaque morceau, le participant ne conserve pas l'état car il l'a vu le message en une partie ; 3. Pour chaque morceau, le participant conserve l'état car il a le morceau complet. Une fois le bloc traité, pour chaque fragment pour lequel le participant maintient l'état pendant, ils appliquent les transactions et calculent le nouvel état dès que les transactions sont appliquées, après quoi elles sont prêtes à produire les morceaux du bloc suivant, s'ils sont affectés à un fragment, car ils ont la racine merkle du nouvel État merkelisé. 3.6 Transactions et reçus entre fragments Si une transaction doit affecter plusieurs fragments, elle doit être consécutivement exécuté dans chaque fragment séparément. La transaction complète est envoyée au premier fragment affecté, et une fois que la transaction est incluse dans le bloc pour ce fragment, et est appliqué une fois que le morceau est inclus dans un bloc, il génère ce qu'on appelle un reçu transaction, qui est acheminée vers le fragment suivant dans lequel la transaction doit être exécuté. Si plusieurs étapes sont nécessaires, l'exécution de la transaction de réception génère une nouvelle transaction de réception et ainsi de suite. 3.6.1 Durée de vie de la transaction de réception Il est souhaitable que la transaction de réception soit appliquée dans le bloc qui suit immédiatement le bloc dans lequel elle a été générée. La transaction de réception est uniquement généré après que le bloc précédent a été reçu et appliqué par les producteurs de blocs qui maintiennent le fragment d'origine et doit être connu au moment où le le morceau du bloc suivant est produit par les producteurs de blocs de la destination éclat. Ainsi, le reçu doit être communiqué du fragment source au fragment de destination dans le court laps de temps entre ces deux événements. Soit A le dernier bloc produit contenant une transaction t générant un reçu r. Soit B le prochain bloc produit (c'est-à-dire un bloc qui a A comme son bloc précédent) que nous voulons contenir r. Que ce soit dans le fragment a et r dans le fragment b. La durée de vie du reçu, également représentée sur la figure 18, est la suivante : Produire et conserver les reçus. Le CPA du producteur de morceaux pour le fragment a reçoit le bloc A, applique la transaction t et génère le reçu r. cpa stocke ensuite tous ces reçus produits dans son stockage persistant interne indexé par l'identifiant du fragment source.Distribution des reçus. Une fois que cpa est prêt à produire le morceau pour fragment a pour le bloc B, ils récupèrent tous les reçus générés en appliquant les transactions du bloc A pour le fragment a et les incluent dans le fragment pour shrad a dans le bloc B. Une fois ce morceau généré, cpa produit son code d'effacement version et tous les messages onepart correspondants. cpa sait quels blocs les producteurs maintiennent l'état complet pour quels fragments. Pour un producteur de blocs particulier bp cpa inclut les recettes résultant de l'application des transactions dans le bloc A pour le fragment a qui a l'un des fragments qui intéressent bp comme destination dans le message en une partie lorsqu'ils ont distribué le morceau pour le fragment a dans le bloc B (voir la figure 17, qui montre les reçus inclus dans le message en une partie). Réception des reçus. N'oubliez pas que les participants (les producteurs de blocs et les validator) ne traitent pas les blocs tant qu'ils n'ont pas reçu de messages en une seule partie. pour chaque morceau inclus dans le bloc. Ainsi, au moment où un participant particulier applique le bloc B, il dispose de tous les messages en une seule partie qui correspondent à morceaux en B, et ils ont donc tous les reçus entrants qui contiennent les fragments le participant conserve l'état comme destination. Lors de l'application du transition d'état pour un fragment particulier, le participant applique à la fois les reçus qu'ils ont collectés pour le fragment dans les messages en une seule partie, ainsi que tous les transactions incluses dans le morceau lui-même. Figure 18 : La durée de vie d'une transaction de réception 3.6.2 Gérer trop de reçus Il est possible que le nombre de reçus ciblant une partition particulière dans un un bloc particulier est trop volumineux pour être traité. Par exemple, considérons la figure 19, dans dont chaque transaction dans chaque fragment génère un reçu qui cible le fragment 1. Au bloc suivant, le nombre de reçus que le fragment 1 doit traiter est égal à comparable à la charge que tous les fragments combinés ont traitée lors de la manipulation le bloc précédent.

Figure 19 : Si tous les reçus ciblent la même partition, celle-ci n'aura peut-être pas la capacité de les traiter Pour résoudre ce problème, nous utilisons une technique similaire à celle utilisée dans QuarkChain 9. Plus précisément, pour chaque fragment, le dernier bloc B et le dernier fragment à l'intérieur de celui-ci. le bloc à partir duquel les recettes ont été appliquées est enregistré. Lorsque le nouveau fragment est créés, les reçus sont appliqués dans l'ordre en premier à partir des fragments restants en B, puis dans les blocs qui suivent B, jusqu'à ce que le nouveau morceau soit plein. Sous la normale Dans des circonstances avec une charge équilibrée, cela donnera généralement lieu à toutes les recettes étant appliqué (et donc le dernier fragment du dernier bloc sera enregistré pour chaque morceau), mais pendant les périodes où la charge n'est pas équilibrée, et un particulier Shard reçoit un nombre disproportionné de reçus, cette technique leur permet de être traitées en respectant les limites du nombre de transactions incluses. Notez que si une telle charge déséquilibrée persiste pendant une longue période, le délai entre la création du reçu jusqu'à ce que l'application puisse continuer à croître indéfiniment. Un La meilleure façon de résoudre ce problème est d'abandonner toute transaction qui crée un reçu ciblant un fragment qui a un délai de traitement qui dépasse une certaine constante (par exemple, une époque). Considérons la figure 20. Par le bloc B, le fragment 4 ne peut pas traiter tous les reçus, il ne traite donc que l'origine des reçus jusqu'au fragment 3 dans le bloc A, et l'enregistre. Dans le bloc C, les reçus jusqu'au fragment 5 dans le bloc B sont inclus, et puis par le bloc D, le fragment rattrape son retard, traitant tous les reçus restants dans le bloc B et toutes les recettes du bloc C. 3.7 Validation des fragments Un morceau produit pour une partition particulière (ou un bloc de partitions produit pour une chaîne de partitions particulière dans le modèle avec chaînes de partitions) ne peut être validé que par le 9Voir l'épisode du tableau blanc avec QuarkChain ici : https://www.youtube.com/watch? v=opEtG6NM4x4, dans lequel l'approche des transactions entre fragments est discutée, entre autres des chosesFigure 20 : Traitement des reçus en retard participants qui maintiennent l’État. Ils peuvent être des producteurs de blocs, des validator, ou simplement des témoins externes qui ont téléchargé l'état et validé le fragment dans dans lesquels ils stockent des actifs. Dans ce document, nous supposons que la majorité des participants ne peuvent pas stocker l’État pour une grande partie des fragments. Il convient cependant de mentionner qu'il existe des blockchain fragmentés conçus avec l'hypothèse que la plupart des participants ont la capacité de stocker l'état et de valider la plupart des les fragments, tels que QuarkChain. Puisque seule une fraction des participants dispose de l’état nécessaire pour valider le fragment morceaux, il est possible de corrompre de manière adaptative uniquement les participants qui ont le état et appliquez une transition d’état non valide. Plusieurs conceptions de partitionnement ont été proposées pour échantillonner les validator à intervalles de quelques jours, et dans la journée, tout bloc de la chaîne de fragments qui contient plus de 2/3 des signatures des validator attribués à ce fragment est immédiatement prise en compte finale. Avec une telle approche, un adversaire adaptatif n’a qu’à corrompre 2n/3+1 des validators dans une chaîne de fragments pour appliquer une transition d'état non valide, ce qui, bien qu'il soit probablement difficile à réaliser, le niveau de sécurité n'est-il pas suffisant pour un public blockchain. Comme indiqué dans la section 2.3, l'approche courante consiste à accorder un certain laps de temps après la création d'un bloc pour tout participant ayant un état (que ce soit c'est un producteur de blocs, un validator ou un observateur externe) pour contester sa validité. Ces participants sont appelés pêcheurs. Pour qu'un pêcheur puisse contester un blocage invalide, il faut s'assurer qu'un tel blocage est disponible pour eux. La disponibilité des données dans Nightshade est discutée à la section 3.4. Dans Nightshade, une fois qu'un bloc est produit, les morceaux n'étaient pas validés par n'importe qui sauf le véritable producteur de morceaux. En particulier, le producteur de blocs qui a suggéré que le bloc n'avait naturellement pas l'état pour la plupart des fragments, etn'a pas pu valider les morceaux. Lorsque le bloc suivant est produit, il contient les attestations (voir section 3.2) de plusieurs producteurs de blocs et validator, mais comme la majorité des producteurs de blocs et des validator ne maintiennent pas l'état pour la plupart des fragments également, un bloc avec un seul morceau invalide collectera significativement plus de la moitié des attestations et continuera à être sur le plus lourd. chaîne. Pour résoudre ce problème, nous autorisons tout participant qui maintient l'état de un fragment pour soumettre un défi en chaîne pour tout morceau non valide produit dans ce fragment éclat. 3.7.1 Défi de validité d’état Une fois qu'un participant détecte qu'un morceau particulier n'est pas valide, il doit fournir une preuve que ce morceau est invalide. Étant donné que la majorité des participants au réseau ne conservent pas l'état du fragment dans lequel se trouve le fragment invalide, produite, la preuve doit avoir suffisamment d’informations pour confirmer que le bloc est invalide sans avoir l'état. Nous fixons une limite Ls de la quantité d'état (en octets) qu'une seule transaction peuvent cumulativement lire ou écrire. Toute transaction qui touche plus de Ls l’état est considéré comme invalide. Rappelez-vous de la section 3.5 que le morceau dans un bloc B particulier ne contient que les transactions à appliquer, mais pas la nouvelle racine d'état. La racine d'état incluse dans le bloc du bloc B est l'état racine avant d'appliquer de telles transactions, mais après avoir appliqué les transactions de le dernier morceau du même fragment avant le bloc B. Un acteur malveillant qui souhaite appliquer une transition d'état invalide inclurait une racine d'état incorrecte dans le bloc B qui ne correspond pas à la racine d’état résultant de l’application les transactions du bloc précédent. Nous étendons les informations qu'un producteur de chunk inclut dans le chunk. Au lieu d'inclure simplement l'état après avoir appliqué toutes les transactions, il inclut une racine d'état après avoir appliqué chaque ensemble contigu de transactions qui lire et écrire collectivement Ls octets d’état. Avec ces informations pour le pêcheur pour créer un défi selon lequel une transition d'état est mal appliquée est suffisant pour trouver la première racine d’état non valide, et inclure seulement Ls octets de état qui sont affectés par les transactions entre la dernière racine d’état (qui était valide) et la racine de l'état actuel avec les preuves Merkle. Alors tout participant peut valider les transactions dans le segment et confirmer que le fragment est invalide. De même, si le producteur du bloc tentait d'inclure des transactions qui lisent et écrire plus de Ls octets d'état, pour le défi il suffit d'inclure les premiers Ls octets qu'il touche avec les preuves merkle, ce qui suffira à appliquer les transactions et confirmer qu'il y a un moment où une tentative de la lecture ou l'écriture de contenu au-delà de Ls octets est effectuée.

3.7.2 Pêcheurs et transactions rapides entre fragments Comme indiqué dans la section 2.3, une fois que nous supposons que les fragments (ou fragments) blocs dans le modèle avec des chaînes de fragments) peuvent être invalides et introduire un défi période, cela affecte négativement la finalité, et donc la communication entre fragments. Dans en particulier, le fragment de destination de toute transaction entre fragments ne peut pas être certain le morceau ou le bloc de fragments d'origine est définitif jusqu'à la fin de la période de défi (voir figure 21). Figure 21 : Attendre la période de contestation avant d'appliquer un récépissé La façon de résoudre ce problème de manière à ce que les transactions entre fragments soient effectuées Il est instantané que le fragment de destination n'attende pas la période de défi après la publication de la transaction du fragment source, et appliquez la transaction de réception immédiatement, puis restaurez le fragment de destination avec la source fragment si plus tard le morceau ou le bloc d'origine s'est avéré invalide (voir la figure 22). Cela s'applique très naturellement au design Nightshade dans lequel le fragment les chaînes ne sont pas indépendantes, mais les fragments de fragments sont tous publiés ensemble dans le même bloc de chaîne principal. Si un morceau s'avère invalide, le le bloc entier avec ce morceau est considéré comme invalide, et tous les blocs construits sur en haut. Voir la figure 23. Les deux approches ci-dessus fournissent une atomicité en supposant que le défi la période est suffisamment longue. Nous utilisons cette dernière approche car la fourniture de transactions cross-shard rapides dans des circonstances normales dépasse les inconvénients de la partition de destination est annulée en raison d'une transition d'état non valide dans l'un des les fragments sources, ce qui est un événement extrêmement rare. 3.7.3 Masquage des validator L’existence de défis réduit déjà considérablement la probabilité de corruption adaptative, puisque pour finaliser un morceau avec un post de transition d'état invalideFigure 22 : Appliquer immédiatement les reçus et annuler la destination chaîne si la chaîne source avait un bloc invalide Figure 23 : Défi pêcheur à Nightshade la période de défi dont l'adversaire adaptatif a besoin pour corrompre tous les participants qui maintiennent l'état du fragment, y compris tous les validator. L'estimation de la probabilité d'un tel événement est extrêmement complexe, car aucun le fragment blockchain est actif depuis suffisamment longtemps pour qu'une telle attaque puisse être tentée. Nous affirmons que la probabilité, bien qu’extrêmement faible, est néanmoins suffisamment important pour un système censé exécuter plusieurs millions de transactions et diriger des opérations financières à l’échelle mondiale. Il y a deux raisons principales à cette croyance : 1. La plupart des validator des chaînes Proof-of-Stake et des mineurs du

Les chaînes de preuve de travail sont principalement motivées par les avantages financiers. Si un adversaire adaptatif leur offre plus d’argent que le rendement attendu de fonctionner honnêtement, il est raisonnable de s'attendre à ce que de nombreux validator acceptera l'offre. 2. De nombreuses entités effectuent la validation des chaînes de preuve de participation de manière professionnelle, et on s'attend à ce qu'un pourcentage important des parts dans n'importe quelle chaîne soit de ces entités. Le nombre de ces entités est suffisamment petit pour une adversaire adaptatif pour apprendre à connaître la plupart d'entre eux personnellement et avoir une bonne compréhension de leur penchant à la corruption. Nous allons encore plus loin en réduisant la probabilité de corruption adaptative en masquant quels validator sont attribués à quelle partition. L'idée est un peu similaire à la façon dont Algorand [5] dissimule les validator. Il est essentiel de noter que même si les validator sont cachés, comme dans Algorand ou comme décrit ci-dessous, la corruption adaptative est toujours en théorie possible. Tandis que l'adversaire adaptatif ne connaît pas les participants qui vont créer ou valider un bloc ou un morceau, les participants eux-mêmes savent qu'ils joueront une telle tâche et en avoir une preuve cryptographique. Ainsi, l'adversaire peut diffuser leur intention de corrompre et payer tout participant qui fournira une telle preuve cryptographique. Notons cependant que puisque l’adversaire ne le fait pas connaissent les validator attribués au fragment qu'ils souhaitent corrompre, ils n'ont pas d'autre choix que de diffuser leur intention de corrompre un fragment particulier à la communauté entière. À ce stade, il est économiquement bénéfique pour tout honnête participant à lancer un nœud complet qui valide ce fragment, car il y a un niveau élevé chance qu'un bloc invalide apparaisse dans ce fragment, ce qui est une opportunité de créez un défi et collectez la récompense associée. Pour ne pas révéler les validator attribués à un fragment particulier, nous le faisons ce qui suit (voir figure 24) : Utiliser VRF pour obtenir la mission. Au début de chaque époque chacun validator utilise un VRF pour obtenir un masque de bits des fragments auxquels validator est affecté. Le masque de bits de chaque validator aura des bits Sw (voir la section 3.3 pour la définition de Sw). Le validator récupère ensuite l'état des fragments correspondants, et pendant l'époque pour chaque bloc reçu valide les morceaux qui correspondent aux fragments auxquels le validator est affecté. Connectez-vous sur des blocs plutôt que sur des morceaux. Étant donné que l'affectation des fragments est masquée, le validator ne peut pas signer sur les fragments. Au lieu de cela, il signe toujours sur l'ensemble bloquer, ne révélant ainsi pas quels fragments il valide. Plus précisément, lorsque le validator reçoit un bloc et valide tous les morceaux, soit il crée un message qui atteste que tous les morceaux de toutes les partitions auxquelles le validator est attribué sont valide (sans indiquer de quelque manière que ce soit quels sont ces fragments), ou un message qui contient une preuve d'une transition d'état invalide si un morceau est invalide. Voir le section 3.8 pour plus de détails sur la façon dont ces messages sont regroupés, section 3.7.4 pour les détails sur la façon d'empêcher les validator de s'appuyer sur les messages de autres validator, et la section 3.7.5 pour plus de détails sur la façon de récompenser et de punir validators si un défi de transition d'état invalide réussi se produit réellement.Figure 24 : Dissimulation des validator dans Nightshade 3.7.4 Commit-Révéler L'un des problèmes courants avec les validator est qu'un validator peut ignorer le téléchargement de l'état et valider réellement les morceaux et les blocs, et à la place observez le réseau, voyez ce que les autres validator soumettent et répétez leur messages. Un validator qui suit une telle stratégie n'apporte aucun supplément sécurité du réseau, mais collecte des récompenses. Une solution courante à ce problème consiste pour chaque validator à fournir une preuve qu'ils ont effectivement validé le blocage, par exemple en fournissant une trace unique d'appliquer la transition d'état, mais de telles preuves augmentent considérablement le coût de validation. Figure 25 : Révélation de validation

Au lieu de cela, nous faisons en sorte que les validator s'engagent d'abord sur le résultat de la validation (soit le message qui atteste de la validité des chunks, ou la preuve d'un invalide transition d'état), attendez une certaine période, et révélez ensuite seulement le résultat réel de la validation, comme le montre la figure 25. La période de validation ne croise pas la période de validation. la période de révélation, et donc un validator paresseux ne peut pas copier des validator honnêtes. De plus, si un validator malhonnête s'engageait dans un message attestant du validité des morceaux attribués, et au moins un morceau était invalide, une fois qu'il est montré que le morceau n'est pas valide, le validator ne peut pas éviter la coupure, car, comme nous le montrons dans la section 3.7.5, le seul moyen de ne pas se faire tailler dans une telle situation est de présenter un message contenant une preuve de la transition d'état invalide qui correspond au commit. 3.7.5 Relever les défis Comme indiqué ci-dessus, une fois qu'un validator reçoit un bloc avec un morceau invalide, ils préparent d’abord une preuve de la transition d’état invalide (voir section 3.7.1), puis s'engager sur une telle preuve (voir 3.7.4), et après un certain temps révéler le défi. Une fois le défi révélé inclus dans un bloc, voici ce qui se passe : 1. Toutes les transitions d'état survenues à partir du bloc contenant le morceau invalide jusqu'à ce que le bloc dans lequel le défi révélé est inclus soit obtenu nul. L'état avant le bloc qui inclut le défi révélé est considéré comme étant le même que l'état avant le bloc qui contenait le morceau invalide. 2. Dans un certain laps de temps, chaque validator doit révéler son masque de bits des fragments qu'ils valident. Puisque le masque de bits est créé via un VRF, si ils ont été affectés au fragment qui avait la transition d'état invalide, ils ne peut éviter de le révéler. Tout validator qui ne parvient pas à révéler le masque de bits est supposé être affecté au fragment. 3. Chaque validator qui, après cette période, est affecté au fragment, qui s'est engagé sur un résultat de validation pour le bloc contenant le morceau invalide et qui n'a pas révélé la preuve d'une transition d'état invalide qui correspond à leur commit est réduit. 4. Chaque validator reçoit une nouvelle affectation de fragments et une nouvelle époque est programmée pour démarrer après un certain temps suffisant pour que tous les validator téléchargent le état, comme le montre la figure 26. Notez qu'à partir du moment où les validator révèlent les fragments qui leur sont attribués jusqu'au début de la nouvelle époque, la sécurité du système est réduite puisque le L'affectation des fragments est révélée. Les participants du réseau doivent le conserver à l'esprit lors de l'utilisation du réseau pendant cette période. 3.8 Agrégation de signatures Pour qu'un système comportant des centaines de fragments fonctionne en toute sécurité, nous souhaitons disposer d'un commande de 10 000 validator ou plus. Comme indiqué dans la section 3.7, nous voulons que chaqueFigure 26 : Relever le défi validator pour publier un commit sur un certain message et une signature en moyenne une fois par bloc. Même si les messages de validation étaient les mêmes, l'agrégation d'un tel La signature BLS et sa validation auraient été d'un coût prohibitif. Mais naturellement, les messages de validation et de révélation ne sont pas les mêmes d'un validator à l'autre, et nous avons donc besoin d'un moyen de regrouper ces messages et les signatures dans un manière qui permet une validation rapide plus tard. L’approche spécifique que nous utilisons est la suivante : Les validateurs rejoignent les producteurs de blocs. Les producteurs de blocs sont connus quelque temps avant le début de l'époque, car ils ont besoin d'un certain temps pour télécharger le état avant le début de l'époque, et contrairement aux validator, les producteurs de blocs sont pas caché. Chaque producteur de blocs dispose de v validator emplacements. Les validateurs soumettent propositions hors chaîne aux producteurs de blocs pour être inclus comme l'un de leurs v validators. Si un producteur de blocs souhaite inclure un validator, il soumet un transaction qui contient la demande initiale hors chaîne du validator et le signature du producteur de blocs qui permet au validator de rejoindre le producteur de blocs. Notez que les validator attribués aux producteurs de blocs ne correspondent pas nécessairement valider les mêmes fragments pour lesquels le producteur de blocs produit des morceaux. Si un validator a demandé à rejoindre plusieurs producteurs de blocs, seule la transaction de le premier producteur de blocs réussira. Les producteurs de blocs collectent les commits. Le producteur de blocs collecte constamment les messages de validation et de révélation des validator. Une fois qu'un certain nombre de ces messages sont accumulés, le producteur de blocs calcule un merkle arbre de ces messages, et envoie à chaque validator la racine merkle et le chemin merkle vers leur message. Le validator valide le chemin et signalise la racine de merkle. Le producteur de blocs accumule ensuite une signature BLS sur le racine merkle des validators, et publie uniquement la racine merkle et le signature accumulée. Le producteur de blocs signe également la validité du multisignature utilisant une signature ECDSA bon marché. Si la multisignature ne fonctionne pas correspond à la racine merkle soumise ou au masque de bits des validators participants, c'est un comportement slashable. Lors de la synchronisation de la chaîne, un participant peut choisir de valider toutes les signatures BLS des validator (ce qui est extrêmement coûteux car cela implique d'agréger les clés publiques de validator), ou seulementles signatures ECDMA des producteurs de blocs et s'appuient sur le fait que le Le producteur de blocs n’a pas été contesté ni réduit. Utiliser des transactions en chaîne et des preuves Merkle pour les défis. Il On peut noter qu'il n'y a aucune valeur à révéler les messages des validator si aucun Une transition d'état invalide a été détectée. Seuls les messages contenant le contenu réel les preuves de transition d'état invalide doivent être révélées, et uniquement pour de tels messages il faut montrer qu'ils correspondent au commit précédent. Le message doit être révélé à deux fins : 1. Pour lancer réellement le rollback de la chaîne au moment précédant le transition d'état invalide (voir section 3.7.5). 2. Pour prouver que le validator n'a pas tenté d'attester de la validité du morceau invalide. Dans les deux cas, nous devons résoudre deux problèmes : 1. Le commit réel n'était pas inclus dans la chaîne, seule la racine merkle du commit agrégé avec d’autres messages. Le validator doit utiliser le chemin merkle fourni par le producteur de blocs et leur engagement initial à prouver qu'ils se sont engagés à relever le défi. 2. Il est possible que tous les validator attribués au fragment avec le code invalide la transition d'état est attribuée à des producteurs de blocs corrompus qui les censurent. Pour contourner ce problème, nous leur permettons de soumettre leurs révélations comme une transaction régulière sur la chaîne et contourner l'agrégation. Cette dernière n'est autorisée que pour les preuves de transition d'état invalide, qui sont extrêmement rare, et ne devrait donc pas entraîner le spam des blocs. Le dernier problème à résoudre est que les producteurs de blocs peuvent choisissez de ne pas participer à l’agrégation de messages ou de censurer intentionnellement des validator particuliers. Nous le rendons économiquement désavantageux, en faisant en sorte que le bloc récompense du producteur proportionnelle au nombre de validator qui leur est attribué. Nous notons également que puisque les producteurs de blocs entre les époques se croisent largement (puisque c'est toujours le top avec les participants avec l'enjeu le plus élevé), les validator peuvent s'en tenir en grande partie à travailler avec les mêmes producteurs de blocs, et ainsi réduire le risque d'être assigné à un producteur de blocs qui les a censurés dans le passé. 3.9 Chaîne d'instantanés Étant donné que les blocs de la chaîne principale sont produits très fréquemment, le téléchargement l’histoire complète pourrait devenir coûteuse très rapidement. De plus, puisque chaque le bloc contient une signature BLS d'un grand nombre de participants, la seule agrégation des clés publiques pour vérifier la signature pourrait devenir prohibitive cher aussi. Enfin, puisque dans un avenir prévisible, Ethereum 1.0 restera probablement un des blockchain les plus utilisés, offrant un moyen significatif de transférer des actifs de

Près de Ethereum est une exigence, et aujourd'hui, la vérification des signatures BLS pour garantir La validité des blocs proches du côté de Ethereum n’est pas possible. Chaque bloc de la chaîne principale Nightshade peut éventuellement contenir un Schnorr multisignature sur l'en-tête du dernier bloc contenant un tel Schnorr multisignature. Nous appelons ces blocs des blocs instantanés. Le tout premier bloc de chaque époque doit être un bloc d'instantané. En travaillant sur une telle multisignature, les producteurs de blocs doivent également cumuler les signatures BLS des validator sur le dernier bloc d'instantané et agrégez-les de la même manière que décrit dans paragraphe 3.8. Puisque l’ensemble des producteurs de blocs est constant tout au long de l’époque, valider seuls les premiers blocs d’instantanés de chaque époque suffisent en supposant qu’à aucun moment point un grand pourcentage de producteurs de blocs et de validators se sont entendus et ont créé une fourchette. Le premier bloc de l’époque doit contenir des informations suffisantes pour calculer les producteurs de blocs et les validator pour l'époque. Nous appelons la sous-chaîne de la chaîne principale qui contient uniquement l'instantané bloque une chaîne d'instantanés. La création d'une multisignature Schnorr est un processus interactif, mais puisque nous il suffit de l'exécuter rarement, quel que soit le processus, aussi inefficace soit-il. suffira. Les multisignatures Schnorr peuvent être facilement validées sur Ethereum, fournissant ainsi des primitives cruciales pour un moyen sécurisé d'effectuer des cross-blockchain communications. Pour synchroniser avec la chaîne Near, il suffit de télécharger tous les instantanés bloque et confirme que les signatures Schnorr sont correctes (éventuellement en vérifiant également les signatures BLS individuelles des validator), puis en synchronisant uniquement blocs de chaîne principaux du dernier bloc d’instantané.

Conclusion

Conclusion

In this document we discussed approaches to building sharded blockchains and covered two major challenges with existing approaches, namely state validity and data availability. We then presented Nightshade, a sharding design that powers NEAR Protocol. The design is work in progress, if you have comments, questions or feedback on this document, please go to https://near.chat.

Conclusion

Dans ce document, nous avons discuté des approches pour créer des blockchain fragmentés et a couvert deux défis majeurs des approches existantes, à savoir la validité d'état et la disponibilité des données. Nous avons ensuite présenté Nightshade, un design de sharding qui pouvoirs NEAR Protocole. La conception est en cours de réalisation, si vous avez des commentaires, des questions ou des retours sur ce document, veuillez vous rendre à https://near.chat.