Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: compress state witness #10715

Merged
merged 7 commits into from
Apr 15, 2024
Merged

feat: compress state witness #10715

merged 7 commits into from
Apr 15, 2024

Conversation

pugachAG
Copy link
Contributor

@pugachAG pugachAG commented Mar 6, 2024

This PR adds state witness compression as well as metrics around it. See #10780 for the big picture analysis.

We explicitly limit the size of the decompressed state witness to 64MB to handle Zip bomb attack. This is implemented by using BufMut and Limit along with zstd::stream::copy_decode, so it fails when attempting to write data beyond the limit.

Compression reduces state witness size particularly well for large state witnesses (containing many ContractCode values), which makes it worthwhile. For cases when compression doesn't yield much improvements the latency overhead is not significant.

In practice shadow validation was used to verify the statements above with the current mainnet traffic:

  • overall traffic reduction (dashboard) is about 16% which is not great. That makes sense considering that after resharding to 6 shards the size of state witnesses per shard dropped significantly which makes compression less effective.
  • max state witness size (uncompressed and compressed dashboards) reduced a lot for large state witnesses. We didn't observe any witnesses larger than 2.5MB in compressed state while uncompressed ones were as big as 6.6MB.
  • additional latency (avg and distribution dashboards) is mostly comes from encoding and is in a 10-20ms range for the most busy shard 2.

This PR also includes the following changes:

  • reduce state witness size histogram step
  • bump actix-http version to avoid bringing multiple version of zstd dependency (zulip thread)

Copy link

codecov bot commented Mar 6, 2024

Codecov Report

Attention: Patch coverage is 77.09924% with 30 lines in your changes are missing coverage. Please review.

Project coverage is 71.08%. Comparing base (4c0aa98) to head (2b40576).
Report is 33 commits behind head on master.

Files Patch % Lines
...client/src/stateless_validation/shadow_validate.rs 0.00% 22 Missing ⚠️
core/primitives/src/stateless_validation.rs 90.90% 0 Missing and 4 partials ⚠️
...nt/src/stateless_validation/chunk_validator/mod.rs 83.33% 0 Missing and 2 partials ⚠️
...src/stateless_validation/state_witness_producer.rs 91.30% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10715      +/-   ##
==========================================
- Coverage   71.33%   71.08%   -0.26%     
==========================================
  Files         760      761       +1     
  Lines      152288   153042     +754     
  Branches   152288   153042     +754     
==========================================
+ Hits       108640   108790     +150     
- Misses      39176    39814     +638     
+ Partials     4472     4438      -34     
Flag Coverage Δ
backward-compatibility 0.24% <0.00%> (-0.01%) ⬇️
db-migration 0.24% <0.00%> (-0.01%) ⬇️
genesis-check 1.43% <0.00%> (-0.01%) ⬇️
integration-tests 36.79% <54.19%> (-0.18%) ⬇️
linux 69.52% <26.71%> (-0.29%) ⬇️
linux-nightly 70.56% <77.09%> (-0.24%) ⬇️
macos 54.26% <26.71%> (-0.04%) ⬇️
pytests 1.66% <0.00%> (-0.01%) ⬇️
sanity-checks 1.44% <0.00%> (-0.01%) ⬇️
unittests 66.79% <62.59%> (-0.19%) ⬇️
upgradability 0.29% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

jakmeier pushed a commit to jakmeier/nearcore that referenced this pull request Mar 7, 2024
<p>This PR was automatically created by Snyk using the credentials of a
real user.</p><br /><h3>Snyk has created this PR to upgrade
react-router-dom from 6.4.4 to 6.16.0.</h3>

:information_source: Keep your dependencies up-to-date. This makes it
easier to fix existing vulnerabilities and to more quickly identify and
fix newly disclosed vulnerabilities when they affect your project.
<hr/>

- The recommended version is **68 versions** ahead of your current
version.
- The recommended version was released **a month ago**, on 2023-09-13.


<details>
<summary><b>Release notes</b></summary>
<br/>
  <details>
    <summary>Package name: <b>react-router-dom</b></summary>
    <ul>
      <li>
<b>6.16.0</b> - <a
href="https://snyk.io/redirect/github/remix-run/react-router/releases/tag/react-router-native%406.16.0">2023-09-13</a></br><p>react-router-native@6.16.0</p>
      </li>
      <li>
<b>6.16.0-pre.2</b> - <a
href="https://snyk.io/redirect/github/remix-run/react-router/releases/tag/react-router-native%406.16.0-pre.2">2023-09-06</a></br><p>react-router-native@6.16.0-pre.2</p>
      </li>
      <li>
        <b>6.16.0-pre.1</b> - 2023-09-05
      </li>
      <li>
        <b>6.16.0-pre.0</b> - 2023-08-28
      </li>
      <li>
        <b>6.15.0</b> - 2023-08-10
      </li>
      <li>
        <b>6.15.0-pre.0</b> - 2023-08-09
      </li>
      <li>
        <b>6.14.2</b> - 2023-07-17
      </li>
      <li>
        <b>6.14.2-pre.1</b> - 2023-07-17
      </li>
      <li>
        <b>6.14.2-pre.0</b> - 2023-07-11
      </li>
      <li>
        <b>6.14.1</b> - 2023-06-30
      </li>
      <li>
        <b>6.14.1-pre.1</b> - 2023-06-30
      </li>
      <li>
        <b>6.14.1-pre.0</b> - 2023-06-29
      </li>
      <li>
        <b>6.14.0</b> - 2023-06-23
      </li>
      <li>
        <b>6.14.0-pre.1</b> - 2023-06-21
      </li>
      <li>
        <b>6.14.0-pre.0</b> - 2023-06-21
      </li>
      <li>
        <b>6.13.0</b> - 2023-06-14
      </li>
      <li>
        <b>6.13.0-pre.1</b> - 2023-06-13
      </li>
      <li>
        <b>6.12.2-pre.0</b> - 2023-06-12
      </li>
      <li>
        <b>6.12.1</b> - 2023-06-08
      </li>
      <li>
        <b>6.12.1-pre.0</b> - 2023-06-08
      </li>
      <li>
        <b>6.12.0</b> - 2023-06-06
      </li>
      <li>
        <b>6.12.0-pre.1</b> - 2023-06-01
      </li>
      <li>
        <b>6.12.0-pre.0</b> - 2023-06-01
      </li>
      <li>
        <b>6.11.2</b> - 2023-05-17
      </li>
      <li>
        <b>6.11.2-pre.0</b> - 2023-05-16
      </li>
      <li>
        <b>6.11.1</b> - 2023-05-03
      </li>
      <li>
        <b>6.11.1-pre.0</b> - 2023-05-02
      </li>
      <li>
        <b>6.11.0</b> - 2023-04-28
      </li>
      <li>
        <b>6.11.0-pre.2</b> - 2023-04-27
      </li>
      <li>
        <b>6.11.0-pre.1</b> - 2023-04-26
      </li>
      <li>
        <b>6.11.0-pre.0</b> - 2023-04-26
      </li>
      <li>
        <b>6.10.0</b> - 2023-03-29
      </li>
      <li>
        <b>6.10.0-pre.2</b> - 2023-03-24
      </li>
      <li>
        <b>6.10.0-pre.1</b> - 2023-03-22
      </li>
      <li>
        <b>6.10.0-pre.0</b> - 2023-03-21
      </li>
      <li>
        <b>6.9.0</b> - 2023-03-10
      </li>
      <li>
        <b>6.9.0-pre.0</b> - 2023-03-08
      </li>
      <li>
        <b>6.8.2</b> - 2023-02-27
      </li>
      <li>
        <b>6.8.2-pre.3</b> - 2023-02-23
      </li>
      <li>
        <b>6.8.2-pre.2</b> - 2023-02-22
      </li>
      <li>
        <b>6.8.2-pre.1</b> - 2023-02-22
      </li>
      <li>
        <b>6.8.2-pre.0</b> - 2023-02-21
      </li>
      <li>
        <b>6.8.1</b> - 2023-02-06
      </li>
      <li>
        <b>6.8.1-pre.0</b> - 2023-02-02
      </li>
      <li>
        <b>6.8.0</b> - 2023-01-26
      </li>
      <li>
        <b>6.8.0-pre.1</b> - 2023-01-24
      </li>
      <li>
        <b>6.7.1-pre.0</b> - 2023-01-24
      </li>
      <li>
        <b>6.7.0</b> - 2023-01-18
      </li>
      <li>
        <b>6.7.0-pre.5</b> - 2023-01-18
      </li>
      <li>
        <b>6.7.0-pre.4</b> - 2023-01-17
      </li>
      <li>
        <b>6.7.0-pre.3</b> - 2023-01-13
      </li>
      <li>
        <b>6.7.0-pre.2</b> - 2023-01-13
      </li>
      <li>
        <b>6.7.0-pre.1</b> - 2023-01-11
      </li>
      <li>
        <b>6.6.3-pre.0</b> - 2023-01-11
      </li>
      <li>
        <b>6.6.2</b> - 2023-01-09
      </li>
      <li>
        <b>6.6.2-pre.0</b> - 2023-01-04
      </li>
      <li>
        <b>6.6.1</b> - 2022-12-23
      </li>
      <li>
        <b>6.6.1-pre.1</b> - 2022-12-22
      </li>
      <li>
        <b>6.6.1-pre.0</b> - 2022-12-22
      </li>
      <li>
        <b>6.6.0</b> - 2022-12-21
      </li>
      <li>
        <b>6.6.0-pre.0</b> - 2022-12-16
      </li>
      <li>
        <b>6.5.0</b> - 2022-12-16
      </li>
      <li>
        <b>6.5.0-pre.1</b> - 2022-12-14
      </li>
      <li>
        <b>6.5.0-pre.0</b> - 2022-12-13
      </li>
      <li>
        <b>6.4.5</b> - 2022-12-07
      </li>
      <li>
        <b>6.4.5-pre.2</b> - 2022-12-06
      </li>
      <li>
        <b>6.4.5-pre.1</b> - 2022-12-06
      </li>
      <li>
        <b>6.4.5-pre.0</b> - 2022-12-05
      </li>
      <li>
        <b>6.4.4</b> - 2022-11-30
      </li>
    </ul>
from <a
href="https://snyk.io/redirect/github/remix-run/react-router/releases">react-router-dom
GitHub release notes</a>
  </details>
</details>


<details>
  <summary><b>Commit messages</b></summary>
  </br>
  <details>
    <summary>Package name: <b>react-router-dom</b></summary>
    <ul>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/13fb25a51184f66192e023e2e18be5ff00f37827">13fb25a</a>
chore: Update version for release (near#10866)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/d5b9a18abe0077f5829be05aa2a1abce4611c44c">d5b9a18</a>
Exit prerelease mode</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/6bd6fb9d07e6ef9636659beb6b2660cae2a67529">6bd6fb9</a>
chore: Update version for release (pre) (near#10849)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/37c5f3c610d429439c5d79bf9f789451a1caa024">37c5f3c</a>
chore(router): update generic names (near#10845)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/9b1d1843d27d3bc2c749b99740ff4743af64c88e">9b1d184</a>
chore: Update version for release (pre) (near#10844)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/b6614b0e9452708c0880fef46c52fb0e1805eeaf">b6614b0</a>
Add generics for Remix type enhancements (near#10843)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/3069e526d24514e368640ee7ef7e4557b1b323e2">3069e52</a>
chore: Update version for release (pre) (near#10828)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/2dfc178a255ea58f6d83f63e589d0ecb18e8747c">2dfc178</a>
Enter prerelease mode</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/90289d5f02eb2efc8167faf2a0314f14af0a70fb">90289d5</a>
Update changesets files for Remix v2 release</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/c06984dd09d5d861c745877d80d71088f3afdc5b">c06984d</a>
Merge branch &#x27;main&#x27; into release-next</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/c265a42401d6057e400da2446c9eca45d3c93366">c265a42</a>
Prepare for Remix v2 (near#10715)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/9852bb069e385682f58c0cd8eb6732e3f427a39e">9852bb0</a>
name change (near#10812)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/a4495dee75166546dd92a4072fedab30abce84cf">a4495de</a>
Export proper ErrorResponse type (near#10811)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/4cc8eec22867edae7237e49020595e0be5e06334">4cc8eec</a>
Add some redirect unit tests from Remix (near#10810)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/4b494b935d62cd1244fe5c091db920d3f0315e9e">4b494b9</a>
Update route.lazy docs</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/ae75cdc922485988bb21f5b7b450d787204b0787">ae75cdc</a>
Export ShouldRevalidateFunctionArgs interface (near#10797)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/2208703a3fc77673578d7833774cd4c9e029f2ea">2208703</a>
Add method and URL to aborted query/queryRoute error message
(near#10793)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/496b1fe8253643171ecca6e6a945d98386c4eb00">496b1fe</a>
README&#x27;s fixes (near#10775)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/2709b844a6fcb69820ce47cb8df98376692bace4">2709b84</a>
Fix a race-condition with loader/action-thrown errors on route.lazy
routes (near#10778)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/8b3559a50de61a29972ca161a2fccd007441ac58">8b3559a</a>
Encode URIs during server rendering of &lt;a href&gt;/&lt;form
action&gt; to avoi… (near#10769)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/e11af30e806a3921d4ddc654b29e874a9dd6613c">e11af30</a>
Fix actionResult type on shouldRevalidate args (near#10779)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/e254133b3f1daa9247d1b39ed46f77a7ffba5cdc">e254133</a>
[Docs] Fix typo in &#x60;Navigate&#x60; docs (near#10782)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/6a0875773fb09f651f039522195426b0b9cd8910">6a08757</a>
Organize imports (near#10777)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/a0da745ca0379af456f88a19f5abe1d95e101ad4">a0da745</a>
Update examples to latest version</li>
    </ul>

<a
href="https://snyk.io/redirect/github/remix-run/react-router/compare/12e7c2896e5c7cd150e69e8d56d62cc9ed2285dd...13fb25a51184f66192e023e2e18be5ff00f37827">Compare</a>
  </details>
</details>
<hr/>

**Note:** *You are seeing this because you or someone else with access
to this repository has authorized Snyk to open upgrade PRs.*

For more information: <img
src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiIxMDc4MTA3My0zYTMwLTQ5ODAtYTRkZi1jN2MxMDliYWYxNGMiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6IjEwNzgxMDczLTNhMzAtNDk4MC1hNGRmLWM3YzEwOWJhZjE0YyJ9fQ=="
width="0" height="0"/>

🧐 [View latest project
report](https://app.snyk.io/org/pagoda-pilot/project/12e75fec-70e5-4998-8926-9b5a6351ba5f?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)

🛠 [Adjust upgrade PR
settings](https://app.snyk.io/org/pagoda-pilot/project/12e75fec-70e5-4998-8926-9b5a6351ba5f/settings/integration?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)

🔕 [Ignore this dependency or unsubscribe from future upgrade
PRs](https://app.snyk.io/org/pagoda-pilot/project/12e75fec-70e5-4998-8926-9b5a6351ba5f/settings/integration?pkg&#x3D;react-router-dom&amp;utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr#auto-dep-upgrades)

<!---
(snyk:metadata:{"prId":"10781073-3a30-4980-a4df-c7c109baf14c","prPublicId":"10781073-3a30-4980-a4df-c7c109baf14c","dependencies":[{"name":"react-router-dom","from":"6.4.4","to":"6.16.0"}],"packageManager":"npm","type":"auto","projectUrl":"https://app.snyk.io/org/pagoda-pilot/project/12e75fec-70e5-4998-8926-9b5a6351ba5f?utm_source=github&utm_medium=referral&page=upgrade-pr","projectPublicId":"12e75fec-70e5-4998-8926-9b5a6351ba5f","env":"prod","prType":"upgrade","vulns":[],"issuesToFix":[],"upgrade":[],"upgradeInfo":{"versionsDiff":68,"publishedDate":"2023-09-13T16:37:49.610Z"},"templateVariants":[],"hasFixes":false,"isMajorUpgrade":false,"isBreakingChange":false,"priorityScoreList":[]})
--->

Co-authored-by: snyk-bot <snyk-bot@snyk.io>
jakmeier pushed a commit to jakmeier/nearcore that referenced this pull request Mar 7, 2024
<p>This PR was automatically created by Snyk using the credentials of a
real user.</p><br /><h3>Snyk has created this PR to upgrade
react-router-dom from 6.4.4 to 6.16.0.</h3>

:information_source: Keep your dependencies up-to-date. This makes it
easier to fix existing vulnerabilities and to more quickly identify and
fix newly disclosed vulnerabilities when they affect your project.
<hr/>

- The recommended version is **68 versions** ahead of your current
version.
- The recommended version was released **a month ago**, on 2023-09-13.


<details>
<summary><b>Release notes</b></summary>
<br/>
  <details>
    <summary>Package name: <b>react-router-dom</b></summary>
    <ul>
      <li>
<b>6.16.0</b> - <a
href="https://snyk.io/redirect/github/remix-run/react-router/releases/tag/react-router-native%406.16.0">2023-09-13</a></br><p>react-router-native@6.16.0</p>
      </li>
      <li>
<b>6.16.0-pre.2</b> - <a
href="https://snyk.io/redirect/github/remix-run/react-router/releases/tag/react-router-native%406.16.0-pre.2">2023-09-06</a></br><p>react-router-native@6.16.0-pre.2</p>
      </li>
      <li>
        <b>6.16.0-pre.1</b> - 2023-09-05
      </li>
      <li>
        <b>6.16.0-pre.0</b> - 2023-08-28
      </li>
      <li>
        <b>6.15.0</b> - 2023-08-10
      </li>
      <li>
        <b>6.15.0-pre.0</b> - 2023-08-09
      </li>
      <li>
        <b>6.14.2</b> - 2023-07-17
      </li>
      <li>
        <b>6.14.2-pre.1</b> - 2023-07-17
      </li>
      <li>
        <b>6.14.2-pre.0</b> - 2023-07-11
      </li>
      <li>
        <b>6.14.1</b> - 2023-06-30
      </li>
      <li>
        <b>6.14.1-pre.1</b> - 2023-06-30
      </li>
      <li>
        <b>6.14.1-pre.0</b> - 2023-06-29
      </li>
      <li>
        <b>6.14.0</b> - 2023-06-23
      </li>
      <li>
        <b>6.14.0-pre.1</b> - 2023-06-21
      </li>
      <li>
        <b>6.14.0-pre.0</b> - 2023-06-21
      </li>
      <li>
        <b>6.13.0</b> - 2023-06-14
      </li>
      <li>
        <b>6.13.0-pre.1</b> - 2023-06-13
      </li>
      <li>
        <b>6.12.2-pre.0</b> - 2023-06-12
      </li>
      <li>
        <b>6.12.1</b> - 2023-06-08
      </li>
      <li>
        <b>6.12.1-pre.0</b> - 2023-06-08
      </li>
      <li>
        <b>6.12.0</b> - 2023-06-06
      </li>
      <li>
        <b>6.12.0-pre.1</b> - 2023-06-01
      </li>
      <li>
        <b>6.12.0-pre.0</b> - 2023-06-01
      </li>
      <li>
        <b>6.11.2</b> - 2023-05-17
      </li>
      <li>
        <b>6.11.2-pre.0</b> - 2023-05-16
      </li>
      <li>
        <b>6.11.1</b> - 2023-05-03
      </li>
      <li>
        <b>6.11.1-pre.0</b> - 2023-05-02
      </li>
      <li>
        <b>6.11.0</b> - 2023-04-28
      </li>
      <li>
        <b>6.11.0-pre.2</b> - 2023-04-27
      </li>
      <li>
        <b>6.11.0-pre.1</b> - 2023-04-26
      </li>
      <li>
        <b>6.11.0-pre.0</b> - 2023-04-26
      </li>
      <li>
        <b>6.10.0</b> - 2023-03-29
      </li>
      <li>
        <b>6.10.0-pre.2</b> - 2023-03-24
      </li>
      <li>
        <b>6.10.0-pre.1</b> - 2023-03-22
      </li>
      <li>
        <b>6.10.0-pre.0</b> - 2023-03-21
      </li>
      <li>
        <b>6.9.0</b> - 2023-03-10
      </li>
      <li>
        <b>6.9.0-pre.0</b> - 2023-03-08
      </li>
      <li>
        <b>6.8.2</b> - 2023-02-27
      </li>
      <li>
        <b>6.8.2-pre.3</b> - 2023-02-23
      </li>
      <li>
        <b>6.8.2-pre.2</b> - 2023-02-22
      </li>
      <li>
        <b>6.8.2-pre.1</b> - 2023-02-22
      </li>
      <li>
        <b>6.8.2-pre.0</b> - 2023-02-21
      </li>
      <li>
        <b>6.8.1</b> - 2023-02-06
      </li>
      <li>
        <b>6.8.1-pre.0</b> - 2023-02-02
      </li>
      <li>
        <b>6.8.0</b> - 2023-01-26
      </li>
      <li>
        <b>6.8.0-pre.1</b> - 2023-01-24
      </li>
      <li>
        <b>6.7.1-pre.0</b> - 2023-01-24
      </li>
      <li>
        <b>6.7.0</b> - 2023-01-18
      </li>
      <li>
        <b>6.7.0-pre.5</b> - 2023-01-18
      </li>
      <li>
        <b>6.7.0-pre.4</b> - 2023-01-17
      </li>
      <li>
        <b>6.7.0-pre.3</b> - 2023-01-13
      </li>
      <li>
        <b>6.7.0-pre.2</b> - 2023-01-13
      </li>
      <li>
        <b>6.7.0-pre.1</b> - 2023-01-11
      </li>
      <li>
        <b>6.6.3-pre.0</b> - 2023-01-11
      </li>
      <li>
        <b>6.6.2</b> - 2023-01-09
      </li>
      <li>
        <b>6.6.2-pre.0</b> - 2023-01-04
      </li>
      <li>
        <b>6.6.1</b> - 2022-12-23
      </li>
      <li>
        <b>6.6.1-pre.1</b> - 2022-12-22
      </li>
      <li>
        <b>6.6.1-pre.0</b> - 2022-12-22
      </li>
      <li>
        <b>6.6.0</b> - 2022-12-21
      </li>
      <li>
        <b>6.6.0-pre.0</b> - 2022-12-16
      </li>
      <li>
        <b>6.5.0</b> - 2022-12-16
      </li>
      <li>
        <b>6.5.0-pre.1</b> - 2022-12-14
      </li>
      <li>
        <b>6.5.0-pre.0</b> - 2022-12-13
      </li>
      <li>
        <b>6.4.5</b> - 2022-12-07
      </li>
      <li>
        <b>6.4.5-pre.2</b> - 2022-12-06
      </li>
      <li>
        <b>6.4.5-pre.1</b> - 2022-12-06
      </li>
      <li>
        <b>6.4.5-pre.0</b> - 2022-12-05
      </li>
      <li>
        <b>6.4.4</b> - 2022-11-30
      </li>
    </ul>
from <a
href="https://snyk.io/redirect/github/remix-run/react-router/releases">react-router-dom
GitHub release notes</a>
  </details>
</details>


<details>
  <summary><b>Commit messages</b></summary>
  </br>
  <details>
    <summary>Package name: <b>react-router-dom</b></summary>
    <ul>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/13fb25a51184f66192e023e2e18be5ff00f37827">13fb25a</a>
chore: Update version for release (near#10866)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/d5b9a18abe0077f5829be05aa2a1abce4611c44c">d5b9a18</a>
Exit prerelease mode</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/6bd6fb9d07e6ef9636659beb6b2660cae2a67529">6bd6fb9</a>
chore: Update version for release (pre) (near#10849)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/37c5f3c610d429439c5d79bf9f789451a1caa024">37c5f3c</a>
chore(router): update generic names (near#10845)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/9b1d1843d27d3bc2c749b99740ff4743af64c88e">9b1d184</a>
chore: Update version for release (pre) (near#10844)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/b6614b0e9452708c0880fef46c52fb0e1805eeaf">b6614b0</a>
Add generics for Remix type enhancements (near#10843)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/3069e526d24514e368640ee7ef7e4557b1b323e2">3069e52</a>
chore: Update version for release (pre) (near#10828)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/2dfc178a255ea58f6d83f63e589d0ecb18e8747c">2dfc178</a>
Enter prerelease mode</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/90289d5f02eb2efc8167faf2a0314f14af0a70fb">90289d5</a>
Update changesets files for Remix v2 release</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/c06984dd09d5d861c745877d80d71088f3afdc5b">c06984d</a>
Merge branch &#x27;main&#x27; into release-next</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/c265a42401d6057e400da2446c9eca45d3c93366">c265a42</a>
Prepare for Remix v2 (near#10715)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/9852bb069e385682f58c0cd8eb6732e3f427a39e">9852bb0</a>
name change (near#10812)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/a4495dee75166546dd92a4072fedab30abce84cf">a4495de</a>
Export proper ErrorResponse type (near#10811)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/4cc8eec22867edae7237e49020595e0be5e06334">4cc8eec</a>
Add some redirect unit tests from Remix (near#10810)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/4b494b935d62cd1244fe5c091db920d3f0315e9e">4b494b9</a>
Update route.lazy docs</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/ae75cdc922485988bb21f5b7b450d787204b0787">ae75cdc</a>
Export ShouldRevalidateFunctionArgs interface (near#10797)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/2208703a3fc77673578d7833774cd4c9e029f2ea">2208703</a>
Add method and URL to aborted query/queryRoute error message
(near#10793)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/496b1fe8253643171ecca6e6a945d98386c4eb00">496b1fe</a>
README&#x27;s fixes (near#10775)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/2709b844a6fcb69820ce47cb8df98376692bace4">2709b84</a>
Fix a race-condition with loader/action-thrown errors on route.lazy
routes (near#10778)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/8b3559a50de61a29972ca161a2fccd007441ac58">8b3559a</a>
Encode URIs during server rendering of &lt;a href&gt;/&lt;form
action&gt; to avoi… (near#10769)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/e11af30e806a3921d4ddc654b29e874a9dd6613c">e11af30</a>
Fix actionResult type on shouldRevalidate args (near#10779)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/e254133b3f1daa9247d1b39ed46f77a7ffba5cdc">e254133</a>
[Docs] Fix typo in &#x60;Navigate&#x60; docs (near#10782)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/6a0875773fb09f651f039522195426b0b9cd8910">6a08757</a>
Organize imports (near#10777)</li>
<li><a
href="https://snyk.io/redirect/github/remix-run/react-router/commit/a0da745ca0379af456f88a19f5abe1d95e101ad4">a0da745</a>
Update examples to latest version</li>
    </ul>

<a
href="https://snyk.io/redirect/github/remix-run/react-router/compare/12e7c2896e5c7cd150e69e8d56d62cc9ed2285dd...13fb25a51184f66192e023e2e18be5ff00f37827">Compare</a>
  </details>
</details>
<hr/>

**Note:** *You are seeing this because you or someone else with access
to this repository has authorized Snyk to open upgrade PRs.*

For more information: <img
src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiIxMDc4MTA3My0zYTMwLTQ5ODAtYTRkZi1jN2MxMDliYWYxNGMiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6IjEwNzgxMDczLTNhMzAtNDk4MC1hNGRmLWM3YzEwOWJhZjE0YyJ9fQ=="
width="0" height="0"/>

🧐 [View latest project
report](https://app.snyk.io/org/pagoda-pilot/project/12e75fec-70e5-4998-8926-9b5a6351ba5f?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)

🛠 [Adjust upgrade PR
settings](https://app.snyk.io/org/pagoda-pilot/project/12e75fec-70e5-4998-8926-9b5a6351ba5f/settings/integration?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)

🔕 [Ignore this dependency or unsubscribe from future upgrade
PRs](https://app.snyk.io/org/pagoda-pilot/project/12e75fec-70e5-4998-8926-9b5a6351ba5f/settings/integration?pkg&#x3D;react-router-dom&amp;utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr#auto-dep-upgrades)

<!---
(snyk:metadata:{"prId":"10781073-3a30-4980-a4df-c7c109baf14c","prPublicId":"10781073-3a30-4980-a4df-c7c109baf14c","dependencies":[{"name":"react-router-dom","from":"6.4.4","to":"6.16.0"}],"packageManager":"npm","type":"auto","projectUrl":"https://app.snyk.io/org/pagoda-pilot/project/12e75fec-70e5-4998-8926-9b5a6351ba5f?utm_source=github&utm_medium=referral&page=upgrade-pr","projectPublicId":"12e75fec-70e5-4998-8926-9b5a6351ba5f","env":"prod","prType":"upgrade","vulns":[],"issuesToFix":[],"upgrade":[],"upgradeInfo":{"versionsDiff":68,"publishedDate":"2023-09-13T16:37:49.610Z"},"templateVariants":[],"hasFixes":false,"isMajorUpgrade":false,"isBreakingChange":false,"priorityScoreList":[]})
--->

Co-authored-by: snyk-bot <snyk-bot@snyk.io>
@walnut-the-cat walnut-the-cat added the A-stateless-validation Area: stateless validation label Mar 15, 2024
@pugachAG pugachAG force-pushed the compress-witness branch 3 times, most recently from 01281b8 to ffd866a Compare April 9, 2024 19:23
@pugachAG pugachAG marked this pull request as ready for review April 10, 2024 18:54
@pugachAG pugachAG requested a review from a team as a code owner April 10, 2024 18:54
Copy link
Contributor

@shreyan-gupta shreyan-gupta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 😄

Cargo.lock Outdated
@@ -94,7 +94,7 @@ dependencies = [
"tokio",
"tokio-util 0.7.2",
"tracing",
"zstd",
"zstd 0.12.3+zstd.1.5.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq: why do we need two versions of zstd, 0.12.3 and 1.5.2? Is that how I read it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not idea, Cargo.lock is automatically generated 🤷‍♂️
@nagisa can you please help here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think it matters too much. We good!

Copy link
Collaborator

@nagisa nagisa Apr 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one version is the Rust crate, the other is the bundled libzstd. And this now shows up because we have duplicate dependency (one of other crates that we depend on still depends on the older version.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 41 to 47
/// Decompress and borsh-deserialize encoded witness bytes.
/// Returns decoded witness along with the raw (uncompressed) witness size.
pub fn decode(&self) -> std::io::Result<(ChunkStateWitness, ChunkStateWitnessSize)> {
let borsh_bytes = zstd::decode_all(self.0.as_ref())?;
let witness = ChunkStateWitness::try_from_slice(&borsh_bytes)?;
Ok((witness, borsh_bytes.len()))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to construct Zip bombs with zstd? I'm worried that someone might be able to send something that would decompress to multiple terabytes in size, which would crash the node.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting.... I'm working on dividing witness into parts and sending over network and I would probably require some sort of header + body type setup. We can consider using the header for basic validation and only then using the body for unzip + full validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jancionear this is a very good point, thanks a lot for highlighting that! I will look into this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in 9ad0851

Copy link
Contributor

@jancionear jancionear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

/// Returns decoded witness along with the raw (uncompressed) witness size.
pub fn decode(&self) -> std::io::Result<(ChunkStateWitness, ChunkStateWitnessSize)> {
// We want to limit the size of decompressed data to address "Zip bomb" attack.
const MAX_WITNESS_SIZE: usize = 64_000_000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit risky to limit state witness size to 64MB, what if there's some corner case that would blow up the size above that? I have flashbacks from #10615 x.x

AFAIK we have a 500MB limit for incoming network messages, maybe that'd be a bit safer? But at the end of the day we have to choose some value, so maybe 64MB is okay.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I will change that to match the network message size limit.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the network messages are limited to 500M, aren't these witnesses already limited to that amount?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compressed state witness is indeed limited by the network message size, but at this point we haven't verified that data yet, so it can be malicious which could result in large memory usage when decompressed and crash the node. That is why we also need to explicitly limit the size of decompressed data here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jancionear the limit was updated in 94a406b

@@ -24,16 +25,31 @@ type SignatureDifferentiator = String;
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct EncodedChunkStateWitness(Box<[u8]>);

pub type ChunkStateWitnessSize = usize;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our past use of plain type aliases has proven to result in a not-great experience: as the codebase expanded, there have been cases of type mixups that had led to bugs.

On the other hand, this is currently used as a return type only where an usize would otherwise be perfectly adequate, so I think this is probably alright to leave as-is.

/// Returns encoded witness along with the raw (uncompressed) witness size.
pub fn encode(witness: &ChunkStateWitness) -> std::io::Result<(Self, ChunkStateWitnessSize)> {
const STATE_WITNESS_COMPRESSION_LEVEL: i32 = 3;
let borsh_bytes = borsh::to_vec(witness)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How large are these witnesses? If they are of appreciable size, I would recommend streaming this data instead (https://docs.rs/borsh/latest/borsh/fn.to_writer.html and https://docs.rs/zstd/latest/zstd/stream/write/struct.Encoder.html seem relevant.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be as large as max network message size which is 500MB :(
Streaming is a great idea, I've tried implementing it and counting written bytes appeared to somewhat non-trivial.
I think it is not critical for MVP, so I'm merging it as it is for now as agreed here. Also I've created #11064 to address this in the future.

/// Returns decoded witness along with the raw (uncompressed) witness size.
pub fn decode(&self) -> std::io::Result<(ChunkStateWitness, ChunkStateWitnessSize)> {
// We want to limit the size of decompressed data to address "Zip bomb" attack.
const MAX_WITNESS_SIZE: usize = 64_000_000;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the network messages are limited to 500M, aren't these witnesses already limited to that amount?

// We want to limit the size of decompressed data to address "Zip bomb" attack.
const MAX_WITNESS_SIZE: usize = 64_000_000;
let borsh_bytes = decompress_with_limit(self.0.as_ref(), MAX_WITNESS_SIZE)?;
let witness = ChunkStateWitness::try_from_slice(&borsh_bytes)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, I would opt for a reader interface here, to avoid having 3 full copies of the data (although one of them is compressed, but still) in memory at the same time. You can still limit the amount of data decompressed by having a layer of Read implementation that counts the bytes and passes the data along to the outer reader up to the limit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as this.

@pugachAG pugachAG enabled auto-merge April 15, 2024 09:22
@pugachAG pugachAG disabled auto-merge April 15, 2024 14:13
@pugachAG pugachAG enabled auto-merge April 15, 2024 14:14
@pugachAG pugachAG added this pull request to the merge queue Apr 15, 2024
Merged via the queue into master with commit dea7a10 Apr 15, 2024
26 of 29 checks passed
@pugachAG pugachAG deleted the compress-witness branch April 15, 2024 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-stateless-validation Area: stateless validation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants