Skip to content

Commit

Permalink
build(deps): bump trim, @docusaurus/core and @docusaurus/preset-class…
Browse files Browse the repository at this point in the history
…ic in /docs (#5882)

* build(deps): bump trim, @docusaurus/core and @docusaurus/preset-classic

Removes [trim](https://github.com/Trott/trim). It's no longer used after updating ancestor dependencies [trim](https://github.com/Trott/trim), [@docusaurus/core](https://github.com/facebook/docusaurus/tree/HEAD/packages/docusaurus) and [@docusaurus/preset-classic](https://github.com/facebook/docusaurus/tree/HEAD/packages/docusaurus-preset-classic). These dependencies need to be updated together.


Removes `trim`

Updates `@docusaurus/core` from 2.4.1 to 3.0.0
- [Release notes](https://github.com/facebook/docusaurus/releases)
- [Changelog](https://github.com/facebook/docusaurus/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/docusaurus/commits/v3.0.0/packages/docusaurus)

Updates `@docusaurus/preset-classic` from 2.4.1 to 3.0.0
- [Release notes](https://github.com/facebook/docusaurus/releases)
- [Changelog](https://github.com/facebook/docusaurus/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/docusaurus/commits/v3.0.0/packages/docusaurus-preset-classic)

---
updated-dependencies:
- dependency-name: trim
  dependency-type: indirect
- dependency-name: "@docusaurus/core"
  dependency-type: direct:production
- dependency-name: "@docusaurus/preset-classic"
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* Fixup dependencies and build

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jon C <[email protected]>
  • Loading branch information
dependabot[bot] and joncinque authored Nov 22, 2023
1 parent e170ad9 commit 8dc332e
Show file tree
Hide file tree
Showing 8 changed files with 20,060 additions and 12,683 deletions.
6 changes: 6 additions & 0 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,10 @@ module.exports = {
},
],
],
scripts: [
'https://buttons.github.io/buttons.js',
'https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js',
'/js/code-block-buttons.js',
],
stylesheets: ['/css/code-block-buttons.css'],
};
32,657 changes: 20,010 additions & 12,647 deletions docs/package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"start": "docusaurus start",
"build": "docusaurus build",
"serve": "docusaurus serve",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"format": "prettier --check \"**/*.{js,jsx,json,md,scss}\"",
Expand All @@ -13,17 +14,17 @@
"lint:fix": "npm run lint -- --fix"
},
"dependencies": {
"@docusaurus/core": "^2.4.1",
"@docusaurus/preset-classic": "^2.4.1",
"@babel/eslint-parser": "^7.2.0",
"@docusaurus/core": "^3.0.0",
"@docusaurus/preset-classic": "^3.0.0",
"autocomplete.js": "^0.38.1",
"babel-eslint": "^10.1.0",
"clsx": "^1.1.1",
"docusaurus-lunr-search": "^2.3.2",
"docusaurus-lunr-search": "^3.3.0",
"eslint": "^7.3.1",
"eslint-plugin-react": "^7.28.0",
"prettier": "^2.0.5",
"react": "^16.8.4",
"react-dom": "^16.8.4"
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"browserslist": {
"production": [
Expand Down
6 changes: 0 additions & 6 deletions docs/siteConfig.js

This file was deleted.

40 changes: 24 additions & 16 deletions docs/src/account-compression/concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,79 @@ title: Core Concepts
---

## Concurrent Merkle Trees

To understand concurrent merkle trees we must first briefly understand merkle trees.

### Merkle Trees

A merkle tree is a hash based data structure that encodes data into a tree.
The tree has nodes that are hashes of its children and each leaf node is a hash of the data.

Each node has a 256 bit (32 byte) string represented by X<sub>i</sub> ∈ {0,1}^256 which is hashed using `H: {0, 1}^256 × {0, 1}^256 → {0, 1}^256`, meaning two child nodes with their 256 bit strings are hashed into one parent node with a 256 bit string. You can use any hash function that satisfies this property but we use SHA256.
Each node has a 256 bit (32 byte) string represented by X<sub>i</sub> ∈ \{0,1\}^256 which is hashed using `H: {0, 1}^256 × {0, 1}^256 → {0, 1}^256`, meaning two child nodes with their 256 bit strings are hashed into one parent node with a 256 bit string. You can use any hash function that satisfies this property but we use SHA256.

Important properties of merkle trees:
- The tree must be a fully balanced binary tree
- Each Node *X<sub>i</sub> = H(X<sub>2i</sub>, X<sub>2i+1</sub>) for all i < 2^D*
- Each Leaf Node *X<sub>i</sub> for all i <= 2^D*. X<sub>i</sub> is the hash of the data.

- The tree must be a fully balanced binary tree
- Each Node _X<sub>i</sub> = H(X<sub>2i</sub>, X<sub>2i+1</sub>) for all i < 2^D_
- Each Leaf Node _X<sub>i</sub> for all i {'<='} 2^D_. X<sub>i</sub> is the hash of the data.

Because of these properties we can verify if certain data exists in tree while compressing all the data into a single 256 bit string called the root hash.

Example of a merkle tree of depth 2:

```txt
X1
/ \
X2 X3
/ \ / \
X4 X5 X6 X7
```
You can verify that X5 computes to X1 by doing X1 = H(H(X4,X5),X3)) where {X4,X5,X3} are the proof.

You can verify that X5 computes to X1 by doing X1 = H(H(X4,X5),X3)) where \{X4,X5,X3\} are the proof.
If you change X5 to X5' then you will have to recompute the root hash in the following steps:
- X2' = H(X4,X5')
- X1' = H(X2',X3)

- X2' = H(X4,X5')
- X1' = H(X2',X3)

### Concurrent leaf replacement

We know that there can be multiple concurrent requests to write to the same state, however when the root changes while the first write is happening the second write will generate an invalid root, in other words every time a root is modified all modifications in progress will be invalid.

```txt
X1' X1''
/ \ / \
X2' X3 X2 X3''
/ \ / \ / \ / \
X4 X5' X6 X7 X4 X5 X6'' X7
```

In the above example let's say we try to modify `X5 -> X5'` and make another request to modify X6 -> X6''. For the first change we get root `X1'` computed using `X1' = H(H(X4,X5'),X3)`. For the second change we get root X1'' computed using `X1'' = H(H(X6'',X7),X2`). However `X1''` is not valid as `X1' != H(H(X6, X7), X2)` because the new root is actually `X1'`.

The reason this happens is because the change in the first trees path actually changes the proofs required by the second trees change. To circumvent this problem we maintain a changelog of updates that have been made to the tree, so when `X5 -> X5'` the second mutation can actually use X2' instead of X2 which would compute to the correct root.

To swap the nodes when adding a new leaf in the second tree we do the following:
- Take XOR of the leaf indices of the change log path and the new leaf in base 2
- The depth at which you have to make the swap is the number of leading zeroes in the result(we also add one to it because the swap node is one below the intersection node)
- At that depth change the node in the proof to the node in the changelog

- Take XOR of the leaf indices of the change log path and the new leaf in base 2
- The depth at which you have to make the swap is the number of leading zeroes in the result(we also add one to it because the swap node is one below the intersection node)
- At that depth change the node in the proof to the node in the changelog

Example with the previous trees:

```txt
2 1
Changelog: [X5',X2']
New Leaf: X6'' at leaf index 2
2 1
Old proof for new leaf: [X7,X2]
Old proof for new leaf: [X7,X2]
1 XOR 2 = 001 XOR 010 = 011 (no leading zeroes)
depth to swap at = 0 + 1 = 1
2 1
New proof for new leaf: [X7,X2']
```

**Note:** We use XOR here because changelogs can get large as there can be many concurrent writes so using XOR is more efficient than a simple array search algorithm.

**Note**: Solana imposes a transactions size restriction of 1232 bytes hence the program also provides the ability to cache the upper most part of the concurrent merkle tree called a "canopy" which is stored at the end of the account.



5 changes: 5 additions & 0 deletions docs/src/single-pool.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
title: Single-Validator Stake Pool
---

```mdx-code-block
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
```

Trustless liquid staking for all Solana validators.

| Information | Account Address |
Expand Down
6 changes: 3 additions & 3 deletions docs/src/theme/SearchBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, { useRef, useCallback } from "react";
import classnames from "classnames";
import { clsx } from "clsx";
import { useHistory } from "@docusaurus/router";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
const Search = props => {
Expand Down Expand Up @@ -76,7 +76,7 @@ const Search = props => {
<span
aria-label="expand searchbar"
role="button"
className={classnames("search-icon", {
className={clsx("search-icon", {
"search-icon-hidden": props.isSearchBarExpanded
})}
onClick={toggleSearchIconClick}
Expand All @@ -88,7 +88,7 @@ const Search = props => {
type="search"
placeholder="Search"
aria-label="Search"
className={classnames(
className={clsx(
"navbar__search-input",
{ "search-bar-expanded": props.isSearchBarExpanded },
{ "search-bar": !props.isSearchBarExpanded }
Expand Down
10 changes: 5 additions & 5 deletions docs/src/token.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ Signatures are then provided by the multisig signer-set members specified by the

Multisig accounts can be used for any authority on an SPL Token mint or token
account.
<ul>
{<ul>
<li>Mint account mint authority:
<code>spl-token mint ...</code>,
<code>spl-token authorize ... mint ...</code>
Expand All @@ -972,7 +972,7 @@ account.
<code>spl-token close ...</code>,
<code>spl-token authorize ... close ...</code>
</li>
</ul>
</ul>}

</TabItem>
<TabItem value="jsx" label="JS">
Expand All @@ -984,7 +984,7 @@ the multisig case the owner would be the multisig key.

Multisig accounts can be used for any authority on an SPL Token mint or token account.

<ul>
{<ul>
<li>Mint account mint authority:
<code>createMint(/* ... */, mintAuthority: multisigKey, /* ... */)</code>
</li>
Expand All @@ -997,7 +997,7 @@ Multisig accounts can be used for any authority on an SPL Token mint or token ac
<li>Token account close authority:
<code>closeAccount(/* ... */, authority: multisigKey, /* ... */)</code>
</li>
</ul>
</ul>}
</TabItem>
</Tabs>

Expand Down Expand Up @@ -1068,7 +1068,7 @@ will use a "2 of 3" multisig account. That is, two of the three allowed keypair
must sign all transactions.

NOTE: SPL Token Multisig accounts are limited to a signer-set of eleven signers
(1 <= `N` <= 11) and minimum signers must be no more than `N` (1 <= `M` <= `N`)
(1 {'<='} `N` {'<='} 11) and minimum signers must be no more than `N` (1 {'<='} `M` {'<='} `N`)

<Tabs className="unique-tabs" groupId="language-selection">
<TabItem value="cli" label="CLI" default>
Expand Down

0 comments on commit 8dc332e

Please sign in to comment.