Cointime

Download App
iOS & Android

LossyDAS: Lossy, Incremental, and Diagonal Sampling for Data Availability

By @cskiraly@leobago, and @dryajov from the Codex 1 team.

The aim of this post is to share some of our DAS related findings with the community. These have been shared with some of you already last year, and for reference we link the original documents 5. Here below we hope to provide a more digestible summary.

TL;DR

  • An important parameter of DAS is the sample size, i.e. the number of segments (or columns) a node downloads and verifies. It is sometimes better to allow a few missing segments and have a slightly larger sample size than to have a smaller sample size but try to retrieve all segments of the sample at all costs. We call this technique LossyDAS.
  • It is possible to gradually increase the sample size, extending the sample if the test fails (or does not conclude in, e.g. a given time). We call this strategy IncrementalDAS.
  • When selecting what to sample on a 2D Reed-Solomon encoded grid, the usual assumption is to use a uniform random choice. We show that choosing row and column distinct samples, which we call DiDAS (“distinct” or “diagonal” DAS), provides probabilistically better results. It is trivial to implement, while it doesn’t seem to have any disadvantages.

Intro

Sharding and DAS have been in the works for some time now. While the initial paper 5 and the Danksharding proposal 3 focused on a 2D Reed-Solomon (RS) encoding, some recent posts 1 are proposing a transitional one-dimensional encoding. In this post, we focus on some aspects of sampling and its probabilistic guarantees, and we propose three improvements to the system. The techniques described below have been developed for the case of the original 2D RS encoding, but to some extent apply also to the transitional proposals.

First, we introduce lossy sampling for data availability (LossyDAS), which provides the same probabilistic guarantees as random uniform sampling, adding error tolerance in exchange for slightly larger sample sizes.

Second, we discuss IncrementalDAS, which provides the basis for developing a dynamic sampling strategy with increasing sample sizes.

Finally, we introduce diagonal sampling for data availability (DiDAS), a method that improves sampling performance over this specific 2D erasure code, providing better performance than uniform random sampling for worst-case “adversarial” erasure patterns.

Sampling over the DAS encoding

das-structure960×720 62 KBFigure 1: Data Availability encoding structure

Figure 1 shows the 2D data availability encoding as proposed in Danksharding, using a square structure, using the same RS code with K=256 and N=512 in both dimensions. This means that any row or column can be fully recovered if at least K=256 segments of it are available.

In the baseline sampling process, a sampling node selects S segments uniformly random without replacement, and tries to download these from the network. If all S can be retrieved, it assumes the block is available. If at least one of these fails, it assumes the block is not available.

Sample Size and Erasure Patterns

An important parameter of DAS is the sample size S, i.e. the number of segments a node downloads and verifies. When evaluating how many samples are needed, it is important to note that, contrary to a simple RS code, a multi-dimensional code is non-MDS (maximum distance separable). With an MDS code, repairability only depends on the number of segments lost, but with a non-MDS code, it depends on the actual erasure pattern as well. This means that, with some probability, non-trivial erasure patterns will happen. Even more importantly, this potentially allows malicious actors to inject crafted (adversarial) erasure patterns in the system. Therefore, when analyzing the sampling as a test, we should differentiate between the cases of

  • random erasures,
  • adversarial (e.g. worst-case) erasure patterns.

Random Erasures

Random erasures are a plausible model when thinking of network and storage induced errors. The simplest model of random erasures is the case of uniform random erasures, which maps relatively well to the service provided by a DHT, as in the original proposal, when assuming honest actors. However, given the nature of the system, our main optimization target is not this, but worst-case or adversarial erasures.

Worst-case Erasures

When thinking of malicious actors, it is important to analyze worst-case scenarios. While the code is not an MDS code, we can describe what a worst-case (or minimal size) erasure pattern is. If we select any N-K+1 rows and N-K+1 columns, and remove all segments in the intersections of these selected rows and columns (i.e. 257 * 257 segments out of the 512 * 512 segments), we prevent any recovery from taking place. There are only full rows and unrecoverable rows, and similarly, there are only full and unrecoverable columns. No row or column can be recovered therefore, the data is lost.

It is easy to see that the above is the “worst-case”. First, observe that worst-case here means the least number of missing segments. In our context, this also means the minimum number of nodes/validators a malicious actor should control in order to perpetrate the attack. In the worst-case, there should be no possibility of repairing rows or columns. Assume there is a worst-case pattern that has less missing segments than (N-K+1) * (N-K+1). In that case, there would be at least one column or row that has less than N-K+1 missing segments. That column/row is repairable, which contradicts our assumption.

Note: The above proof assumes an interactive row/columns based repair process. Multi-dimensional RS codes can also be repaired using multivariate interpolation, as discussed here. The proof described in their paper also applies to our case, confirming these patterns as worst-case minimal size patterns.

Trivially, any erasure pattern that contains a worst-case erasure pattern, is also unrecoverable.

Setting the Sample Size

When setting the sample size, what we are interested in is to limit the probability of a not-available block passing the test, in other words the false positive (FP) rate, independent of the erasure pattern. Clearly, with uniform random sampling, assuming an erasure pattern that makes the block unrecoverable, the larger the pattern, the easier it is to detect. Therefore, it is enough to study the case of the smallest such patterns, i.e. the worst-case erasure pattern. This probability can be approximated by a binomial distribution or - even better - calculated exactly using a hypergeometric distribution with

  • population size: N∗N
  • number of failure states in the population: (K+1)∗(K+1)
  • Number of segments: S
  • Number of failures allowed: 0

Pr(X=0)=Hypergeom(0;N2,(N−K+1)2,S)

This probability obviously depends on S, the sample size. In fact, our real question is:How many segments do we need to reach a given level of assurance?

As shown on Fig. 2, if we have a 2D RS coding, K=256, N=512, and want this probability to be below 1e-9, we need S=73 segments. The figure also shows the theoretical cases of using a 1D RS code with the same number of segments and the same expansion factor, and the case of a 2D RS code with a smaller expansion factor.

das-uniform-sampling863×547 37.8 KBFigure 2: Performance of uniform random sampling over the DAS data structure, with different RS encodings, as a function of the sample size S

What about False Negatives?

As with all statistical tests, there are both cases of FP (false positives: the test passes even if the block is not available), and FN (false negative: the sampling fails even if the block is available). The ratio of false negative tests can be quantified using the survival function of the hypergeometric distribution as follows:

PFP=Pr({X>0})=Hypergeom.sf(0;N2,M,S)

Where M is the size of the erasure pattern.

das-false-negative846×552 26.3 KBFigure 3: False Negative Rate as a function of missing samples

As an example, if there is only 1 segment missing out of the 512*512 segments, the probability of an FN test result is 0.03%. If instead 1% of the segments (2621 segments) are missing, the probability of an FN test is 51.9%.

So, how can this system work when there can be a large number of FN tests due to the unavailability of a few segments? More specifically, there are at least two issues here leading to FN cases:

  • in a distributed setting with a large number of nodes, there are always transient errors, such as nodes being down, unreachable, or suffering network errors. Requiring all segments to be received means we should use reliable transport mechanisms (e.g. TCP connections, or other means of retransmission in case of failures) and even then, we need nodes to have relatively high availability and good network connectivity. Or, we need protocols that store data redundantly and retrieve it using multiple parallel lookups, like a typical DHT, and we still potentially need large redundancy and many retrievals.
  • As we have seen, requiring all segments to be received also means that we might have a large amount of false negatives in our test if not all segments are actually available. In other words, the test easily fails when the data has some losses in the distributed structure, but it is actually reconstructable as a whole. While we could aim to avoid some losses by replication, retry, and repair, this might be very costly if not impossible due to the previous point.

To understand what can be done, let’s carefully analyze our basic premise until this point, focusing on a few key parts:“When a node cannot retrieve all S of the selected segments, it cannot accept the block.”

  • “cannot retrieve”: what “cannot retrieve” actually means in this context is something that needs more attention. It means we tried, and re-tried, and it was not retrievable. How long and with what dynamics should a node try to retrieve a segment? Should it also try to retrieve it by reconstruction using the erasure code? We argue that these network-level reliability techniques can be costly, and there is a trade-off between making the network more reliable and selecting the correct sampling process.
  • “all”: do we really need to retrieve all segments? Wouldn’t it make sense to ask for more segments and allow some losses?
  • “S”: Can we dynamically change S, looking for more samples if our first attempt fails?

To answer what “cannot retrieve” means, we should delve into the details of the networking protocols. We leave this for a subsequent post. Here in what follows, we discuss the two other possibilities. LossyDAS addresses the question of whether “all” samples are needed, while IncrementalDAS focuses on making “S” dynamic. DiDAS, instead, focuses on achieving the same probabilistic guarantees with a smaller “S”,

LossyDAS: accept partial sampling

Do we really need all segments of the sample? What happens if we test more segments, and allow for some losses? It turns out that we can define the test with these assumptions.

In LossyDAS, just as in the original test, we set the target FP probability (i.e., cases when the test passes, we think the data has been released, but it is actually in a non-repairable state). We look for the minimal value of S (the sample size) as a function of

  • PFP: the target FP probability threshold, and
  • M: the number of missing segments we allow out of the S segments queried

In the calculation we use the percentage point function (PPF), which is the inverse of the CDF.

das-lossydas841×547 24.9 KBFigure 4: Number of failures that can be allowed is LossyDAS, respecting a given FP threshold

As we can see in Fig.4, we can sample slightly more and allow for losses while keeping the same FP threshold. For example, with a target FP of 1e-9, we can choose a sample size of 84 and allow 1 missing segment. Or we can go for 103 segments and allow up to 3 losses. In general, instead of sampling with n=73, approximately every 10 more segments allows us to tolerate one more missing segment.In practice, this means that nodes can try to download slightly more segments, already factoring in potential networking issues or other transient errors.

IncrementalDAS: dynamically increase the sample size

What happens when too many segments are actually missing? Should we wait for these to be repaired, repair them on our own, or can we do something else? One might try to argue that the test should fail until all tested segments are repaired, otherwise the block is not available, but our whole system of probabilistic guarantees is built on the principle that repairability (and not repair) is to be assured. Moreover, waiting for it to be repaired might be too long, while repairing on our own might be too costly. The question that naturally arises is whether we can re-test somehow with a different sample.

First of all, we should clarify that simply doing another test on another random sample with the same S is a bad idea. That would be the “toss a coin until you like the result” approach, which is clearly wrong. It breaks our assumptions on the FP threshold set previously. If we make another test, that should be based on the conditional probabilities of what we already know. This is what IncrementalDAS aims for.

In IncrementalDAS, our node selects a first target loss size L1, and the corresponding sample size S(L1) according to LossyDAS. It requests these segments, allowing for L1 losses. If it receives at least S(L1) - L1 segments, the test passes. Otherwise, it extends the sample, using some L2>L1, to size S(L2). By extending the sample, we mean that it selects the new sample such that it includes the old sample, it simply picks S(L2)-S(L1) new random segments. It is easy to see that we can do this, since we could have started with the larger sample right at the beginning, and that would have been fine from the point of view of probabilistic guarantees. The fact that we do the sampling in two steps does not change this. Clearly, the process can go on, extending the sample more and more. L2 (and further extensions) can be decided based on the actual number of losses observed in the previous step. Different strategies are possible, also based on all the other recovery mechanisms used, which we will not detail here.

DiDAS: steering away from uniform random sampling

Until this point, it was our assumption that uniform random sampling is used over the erasure coded block structure. However, the code is non-MDS, and thus some segment combinations seem to be more important than others.

In the base version of the test, we select segments uniformly at random without replacement over the whole square. Some of these might fall on the same row or column, which reduces the efficiency of the test. If, instead of the base version, we make sure to test with segments that are on distinct rows and distinct columns, we increase our chances of catching these worst-case erasures. We call this sampling distinct (or diagonal) sampling for data availability (DiDAS).

Note: What we define here is a 2D variant of sampling without replacement. The diagonal is clearly a row and column distinct selection of segments, but of course there are many other possible selections. From the theoretical point of view, the whole erasure code structure is invariant to row and column permutations in the case of worst-case erasure patterns. Thus, when studying parameters, we can assume a sample in the diagonal and permutations of the erasure pattern.

How much we improve with DiDAS

With the new sampling method, the probability of catching a worst-case erasure from S segments can be expressed as a combination of two hypergeometric distributions. See our original working document (Jupyter Notebook) 5 for the exact formulation. Fig. 5 shows the difference between the two sampling methods in the case of a worst-case erasure pattern.

das-didas870×547 30.1 KBFigure 5: Comparison of uniform random sampling with DiDAS, with N=256, K=512, and a worst-case erasure pattern

Intuitively, for small S the difference is negligible: even if we don’t enforce distinct rows and columns, the segments sampled will most probably be on distinct rows and columns. S=73 is still relatively small in this sense.

For larger S, the difference becomes significant on a logarithmic scale, as in Fig. 5. However, we are speaking of very small probabilities, and we admit that it is questionable how much this is of practical use with the currently proposed set of parameters.

Nevertheless, implementing DiDAS is trivial. If we use it in combination with IncrementalDAS, it could help reduce the size of the increments required.

Also note that DiDAS can’t go beyond S=N, since there are no more distinct rows or columns. When S=512, DiDAS always finds out about an unrecoverable worst-case erasure pattern, with probability 1. Is that possible? In fact, it is, but only for the “worst-case” pattern defined previously, which isn’t the worst-case for DiDAS. There are erasure patterns that are worse for DiDAS than the minimal-size erasure pattern. However, our preliminary results show that these are necessarily large patterns that are easily detectable anyway, and DiDAS still performs better than uniform random sampling on these.

Acknowledgements

This work is supported by grant FY22-0820 on Data Availability Sampling from the Ethereum Foundation. We would like to thank the EF for its support, and Dankrad Feist and Danny Ryan for the original proposal and the numerous discussions on the topics of the post.

Comments

All Comments

Recommended for you

  • Alphabet, Google's Parent, Plans to Raise Up to $25 Billion via Bond Issuance

    On August 6, Alphabet, Google's parent company, plans to raise up to $25 billion through bond issuance.

  • Warsh sticks to cautious market guidance, may consider September rate hike if inflation is strong

    August 6 - According to the Financial Times, Federal Reserve Chairman Warsh has maintained his typically concise communication style, even after triggering a significant sell-off in Treasuries by declining to reveal too many details about interest rate strategy. People close to Warsh said he acknowledged making some mistakes during his first 10 weeks at the helm of the world's most important central bank, including failing to reinforce his key message on price stability and causing confusion over whether his long-term plans to reform the Fed would affect near-term policy decisions. However, they insisted these errors were not enough to derail Warsh's plans for reforming the Fed. Insiders also revealed that if inflation data released in the coming weeks prove strong and market expectations for higher borrowing costs rise accordingly, Warsh is prepared to raise interest rates at the September meeting. Insiders added that although the Fed chairman has raised the possibility of shrinking the central bank's $6.7 trillion balance sheet to tighten monetary policy, interest rates remain the primary tool—and would be used at the upcoming meeting if needed.

  • SanDisk Tumbles Over 10% Pre-Market as Citigroup, Wells Fargo Cut Price Targets

    On August 6, SanDisk (SNDK.US) fell over 10% in pre-market trading. On the news front, Citigroup lowered its price target on SanDisk from $2,500 to $2,100. Meanwhile, on June 25, a month and a half earlier, Citigroup had raised its target from $2,025 to $2,500, citing improving NAND flash memory price outlook and initiating a 90-day short-term upside watch. Additionally, Wells Fargo cut its target from $1,620 to $1,400. However, just half a month earlier, on July 22, Wells Fargo had raised its target from $1,250 to $1,620.

  • Unitree Technology: Offering Price Set at RMB 150.80/Share, Online Subscription Date August 10

    On August 6, Unitree Technology (688836.SH) announced that its initial public offering of shares on the STAR Market has been priced at RMB 150.80 per share. The offering consists of 40,446,434 shares, representing 10% of the total post-offering share capital. The offering price-to-earnings ratio is 219.23 times, higher than the industry average P/E ratio of 38.56 times. The total funds expected to be raised are approximately RMB 6.099 billion, with net proceeds of approximately RMB 5.917 billion. Strategic placement subscribers were allocated 8,089,286 shares, including the Social Security Fund, DeepSeek, and China National Petroleum Corporation. The online subscription date is August 10, and the payment date is August 12.

  • Amazon Shares Surge 15.2%, Biggest Gain Since 2012

    On July 31, Amazon shares surged 15.2% to $271.255 per share, marking their biggest gain since 2012, with a total market value of $2.92 trillion.

  • US Treasury Secretary Bessent Vows to Track Down Iranian Assets Globally for Terror Victims

    US Treasury Secretary Bessent said the US will actively track down Iranian assets worldwide to ensure compensation funds for victims of Iran-backed terrorist activities. Bessent stated that the US government's military and economic blockade measures against the Iranian regime will continue and will not be relaxed. (Jinshi)

  • Apple Plunges Nearly 10%, Q4 Revenue Guidance Misses Expectations

    On July 31, Apple (AAPL.US) plunged nearly 10% to $300.33, marking its biggest drop since April 2025. In terms of fundamentals, Apple's third-fiscal-quarter revenue rose approximately 16% year-over-year to $109.42 billion, slightly above analyst expectations. Among the details, product revenue came in at $78.68 billion, beating the expected $77.25 billion. However, services revenue—a key driver of its valuation re-rating in recent years—totaled $30.74 billion, missing the consensus estimate of $31.36 billion. Additionally, Greater China revenue reached $18.82 billion, with year-over-year growth slowing to 22%, also below analysts' forecast of $19.58 billion. During the earnings call, Apple guided fourth-fiscal-quarter revenue growth in the range of 9% to 11%, overall below the 12.1% analysts had expected. CFO Parekh noted that component supply constraints would impact iPhone, Mac, and iPad businesses in the fourth fiscal quarter, with currency fluctuations also constraining growth.

  • Three Fed Officials Back Rate Hike, Hawkish Pressure Builds

    On July 31, three Federal Reserve policymakers said that dissenting votes in favor of a rate hike this week stemmed from stubborn inflationary pressures, highlighting rising internal pressure on Fed Chair Warsh to act. In statements released Friday morning, Hammack and Kashkari said they worry that although the current round of price increases may stem from short-term factors such as President Trump's tariff policies and the Iran war, the inflation situation already warrants Fed action. Logan also joined in, saying that even if inflation cools, if the Fed does not raise rates, inflation is unlikely to fully fall back to the Fed's 2% target; without any policy constraints, inflation could continue to run above target until an unexpected shock occurs. Kashkari said that if inflation remains persistently stubborn, he might support a series of rate hikes, not just a single increase, to prevent inflation from becoming further entrenched. He said: "A series of small policy adjustments may be preferable to waiting for developments to unfold and ultimately having to take more forceful action." Hammack said that if the Fed does not tighten policy, price increases could continue to accelerate. She said: "Inflation has been stubbornly above 2% for more than five years, and I have no confidence that it will return to our target on its own." (Jin Shi)

  • US 10-Year Treasury Yield Rises to 4.7388%, Highest Since January 2025

    On July 31, the US 10-year Treasury yield rose to 4.7388%, the highest level since January 2025.

  • Spot Gold Intraday Decline Widens to 2%, at $4,021.08 per Ounce

    On July 31, spot gold's intraday decline widened to 2%, reported at $4,021.08 per ounce.