Skip to content

Commit

Permalink
Subnet 9000 Replacement (#1885)
Browse files Browse the repository at this point in the history
* initial replacement

* meta changes

* change few other mentions

* moarrrrr changes

* ai changes

* Update x-chain-migration.mdx

Signed-off-by: Owen <[email protected]>

* some changes

* PoA fix

* Update api.mdx

Signed-off-by: Owen <[email protected]>

* small fixes

* add: linkChecker, fix: majority of broken links

* add cheerio as dev depend

* fix gcp terraform link

* fix hamburger subnet link

* fix few commands

* fix couple more commands

* some fixes

* add assets.website-files.com to whitelist

* Update content/docs/api-reference/p-chain/api.mdx

Co-authored-by: Meaghan FitzGerald <[email protected]>
Signed-off-by: Ashutosh Tripathi <[email protected]>

---------

Signed-off-by: Owen <[email protected]>
Signed-off-by: Ashutosh Tripathi <[email protected]>
Co-authored-by: owenwahlgren <[email protected]>
Co-authored-by: Meaghan FitzGerald <[email protected]>
  • Loading branch information
3 people authored Sep 25, 2024
1 parent 6d42a36 commit e9e7919
Show file tree
Hide file tree
Showing 231 changed files with 2,770 additions and 2,826 deletions.
135 changes: 135 additions & 0 deletions .github/linkChecker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import get from 'axios';
import { readFileSync } from 'fs';
import { load } from 'cheerio';
import { sync as globSync } from 'glob';

const baseUrl = 'http://localhost:3000'; // base url of the website

const whitelist = ["crates.io", "softwaretestinghelp.com", "coinbase.com", "assets.website-files.com"] // some websites return 404 for head requests, so we need to whitelist them, (fix: pass header -H 'Accept: text/html' and parse text/html)
// see https://github.com/rust-lang/crates.io/issues/788

interface LinkCheckResult {
file: string;
link: string;
line: number;
isValid: boolean;
}

function isValidURLOrPath(url: string): boolean {
try {
new URL(url)
return true
} catch {
if (url.startsWith("{") && url.endsWith("}")) { // is a a JSX component, ignore
return false;
}
else if (url.indexOf('.') > -1) { // is a url or misconfigured path
return true;
}
// where all our content lives
return url.startsWith("/");
}
}

async function checkLink(url: string): Promise<boolean> {
try {
const response = await get(url, {
timeout: 20000, // timeout to 20 seconds
maxRedirects: 5, // handle up to 5 redirects
validateStatus: function (status) {
return status >= 200 && status < 400; // resolve only if the status code is less than 400
},
headers: {
'User-Agent': 'Mozilla/5.0 (compatible; LinkChecker/1.0)', // Custom User-Agent
}
});
return response.status === 200;
} catch {
return false;
}
}

function extractLinksWithLineNumbers(mdxContent: string): { link: string; line: number }[] {
const lines = mdxContent.split('\n');
const links: { link: string; line: number }[] = [];

lines.forEach((line, index) => {
const $ = load(`<div>${line}</div>`);
$('a').each((i, elem) => {
const href = $(elem).attr('href');
if (href && isValidURLOrPath(href)) {
links.push({ link: href, line: index + 1 });
}
});

const markdownLinkRegex = /\[.*?\]\((.*?)\)/g;
let match;
while ((match = markdownLinkRegex.exec(line)) !== null) {
const link = match[1];
if (isValidURLOrPath(link)) {
links.push({ link, line: index + 1 });
}
}
});

return links;
}

async function checkAllMdxFiles(): Promise<void> {
const files = globSync('content/**/*.mdx');
console.log(`Found ${files.length} MDX files.`);

const results: LinkCheckResult[] = [];

for (const file of files) {
console.log(`Processing file: ${file}`);

const content = readFileSync(file, 'utf-8');
const links = extractLinksWithLineNumbers(content);

const cache: { [link: string]: boolean } = {};
let isValid: boolean;

for (const { link, line } of links) {
console.log(`Checking link: ${link} in file: ${file} (line ${line})`);

if (cache[link]) {
isValid = cache[link];
} else {
isValid = await checkLink(link); // check the link
if (!isValid) {
isValid = await checkLink(baseUrl + link); // if link failed check first time, try adding the base url (for internal relative links)
}
for (const wl of whitelist) {
if (link.includes(wl)) {
isValid = true;
break;
}
}
cache[link] = isValid;
}
results.push({ file, link, line, isValid });

if (!isValid) {
console.error(`\x1b[31mBroken link found\x1b[0m in ${file} (line ${line}): \x1b[33m${link}\x1b[0m`);
}
}
}


const brokenLinks = results.filter(result => !result.isValid);
if (brokenLinks.length > 0) {
console.error(`\n\x1b[31mSummary of broken links:\x1b[0m`);
brokenLinks.forEach(result => {
console.error(`File: \x1b[36m${result.file}\x1b[0m, Line: \x1b[33m${result.line}\x1b[0m, Link: \x1b[31m${result.link}\x1b[0m`);
});
process.exit(1);
} else {
console.log(`\x1b[32mAll links are valid.\x1b[0m`);
}
}

checkAllMdxFiles().catch(error => {
console.error('\x1b[31mError checking links:\x1b[0m', error);
process.exit(1);
});
30 changes: 30 additions & 0 deletions .github/workflows/checklinks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Check MDX Links

on:
pull_request:
paths:
- '**/*.mdx'
branches: [master]

jobs:
check-links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '19'
- name: Install dependencies
run: |
yarn install --frozen-lockfile
yarn global add tsx wait-on
- name: Start Dev Server in Background
run: |
yarn dev &
- name: Wait for Dev Server to be Ready
run: |
wait-on http://localhost:3000
- name: Check links
run: yarn check-links
- name: Stop Dev Server
run: kill $(jobs -p) || true
2 changes: 1 addition & 1 deletion app/(home)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function Highlights(): React.ReactElement {
<Highlight icon={SquareGanttChart} heading="Smart Contracts" link="/dapps">
Your one stop shop to deploy smart contracts on the Avalanche C-Chain.
</Highlight>
<Highlight icon={Layers} heading="Avalanche L1s" link="/subnets">
<Highlight icon={Layers} heading="Avalanche L1s" link="/avalanche-l1s">
Utilize the Avalanche tech stack to build your own L1 blockchain.
</Highlight>
<Highlight icon={IndentDecrease} heading="Virtual Machines" link="/virtual-machines">
Expand Down
2 changes: 1 addition & 1 deletion app/layout.config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const docsOptions: DocsLayoutProps = {
title: 'Avalanche L1s',
description: 'Build Your L1 Blockchain',
icon: <Layers />,
url: '/subnets',
url: '/avalanche-l1s',
},
{
title: 'Virtual Machines',
Expand Down
3 changes: 2 additions & 1 deletion content/docs/api-reference/admin-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Give a blockchain an alias, a different name that can be used any place the bloc
<Callout title="Note">
Aliasing a chain can also be done via the [Node API](/nodes/configure/configs-flags#--chain-aliases-file-string).

Note that the alias is set for each chain on each node individually. In a multi-node Subnet, the same alias should be configured on each node to use an alias across a Subnet successfully. Setting an alias for a chain on one node does not register that alias with other nodes automatically.
Note that the alias is set for each chain on each node individually. In a multi-node Avalanche L1, the same alias should be configured on each node to use an alias across an Avalanche L1 successfully. Setting an alias for a chain on one node does not register that alias with other nodes automatically.
</Callout>

**Signature**:
Expand Down Expand Up @@ -428,3 +428,4 @@ curl -X POST --data '{
}
```

46 changes: 23 additions & 23 deletions content/docs/api-reference/avalanche-go-configs-flags.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ The chain configs are passed in from the location `chain-config-dir`/`blockchain

Full reference for all configuration options for some standard chains can be found in a separate [chain config flags](/nodes/configure/configs-flags) document.

Full reference for `subnet-evm` upgrade configuration can be found in a separate [Customize a Subnet](/subnets/upgrade/customize-subnet) document.
Full reference for `subnet-evm` upgrade configuration can be found in a separate [Customize an Avalanche L1](/avalanche-l1s/upgrade/customize-avalanche-l1) document.

#### `--chain-config-content` (string)[](#--chain-config-content-string "Direct link to heading")

Expand All @@ -177,7 +177,7 @@ Path to JSON file that defines aliases for Blockchain IDs. Defaults to `~/.avala
}
```

The above example aliases the Blockchain whose ID is `"q2aTwKuyzgs8pynF7UXBZCU7DejbZbZ6EUyHr3JQzYgwNPUPi"` to `"DFK"`. Chain aliases are added after adding primary network aliases and before any changes to the aliases via the admin API. This means that the first alias included for a Blockchain on a Subnet will be treated as the `"Primary Alias"` instead of the full blockchainID. The Primary Alias is used in all metrics and logs.
The above example aliases the Blockchain whose ID is `"q2aTwKuyzgs8pynF7UXBZCU7DejbZbZ6EUyHr3JQzYgwNPUPi"` to `"DFK"`. Chain aliases are added after adding primary network aliases and before any changes to the aliases via the admin API. This means that the first alias included for a Blockchain on an Avalanche L1 will be treated as the `"Primary Alias"` instead of the full blockchainID. The Primary Alias is used in all metrics and logs.

#### `--chain-aliases-file-content` (string)[](#--chain-aliases-file-content-string "Direct link to heading")

Expand Down Expand Up @@ -566,26 +566,26 @@ Avalanche uses two-way authenticated TLS connections to securely connect nodes.

As an alternative to `--staking-tls-key-file`, it allows specifying base64 encoded content of the TLS private key used by the node. Note that full private key content, with the leading and trailing header, must be base64 encoded.

Subnets[](#subnets "Direct link to heading")
Avalanche L1s[](#avalanche-l1s "Direct link to heading")
---------------------------------------------

### Subnet Tracking[](#subnet-tracking "Direct link to heading")
### Avalanche L1 Tracking[](#avalanche-l1-tracking "Direct link to heading")

#### `--track-subnets` (string)[](#--track-subnets-string "Direct link to heading")
#### `--track-subnets` (string)[](#--track-avalanche-l1s-string "Direct link to heading")

Comma separated list of Subnet IDs that this node would track if added to. Defaults to empty (will only validate the Primary Network).
Comma separated list of Avalanche L1 `SubnetID`s that this node would track if added to. Defaults to empty (will only validate the Primary Network).

### Subnet Configs[](#subnet-configs "Direct link to heading")
### Avalanche L1 Configs[](#avalanche-l1-configs "Direct link to heading")

It is possible to provide parameters for Subnets. Parameters here apply to all chains in the specified Subnets. Parameters must be specified with a `{subnetID}.json` config file under `--subnet-config-dir`. AvalancheGo loads configs for Subnets specified in `--track-subnets` parameter.
It is possible to provide parameters for Avalanche L1s. Parameters here apply to all chains in the specified Avalanche L1s. Parameters must be specified with a `{subnetID}.json` config file under `--subnet-config-dir`. AvalancheGo loads configs for Avalanche L1s specified in `--track-subnets` parameter.

Full reference for all configuration options for a Subnet can be found in a separate [Subnet Configs](/nodes/configure/subnet-configs) document.
Full reference for all configuration options for an Avalanche L1 can be found in a separate [Avalanche L1 Configs](/nodes/configure/avalanche-l1-configs) document.

#### `--subnet-config-dir` (`string`)[](#--subnet-config-dir-string "Direct link to heading")
#### `--subnet-config-dir` (`string`)[](#--avalanche-l1-config-dir-string "Direct link to heading")

Specifies the directory that contains Subnet configs, as described above. Defaults to `$HOME/.avalanchego/configs/subnets`. If the flag is set explicitly, the specified folder must exist, or AvalancheGo will exit with an error. This flag is ignored if `--subnet-config-content` is specified.
Specifies the directory that contains Avalanche L1 configs, as described above. Defaults to `$HOME/.avalanchego/configs/subnets`. If the flag is set explicitly, the specified folder must exist, or AvalancheGo will exit with an error. This flag is ignored if `--subnet-config-content` is specified.

Example: Let's say we have a Subnet with ID `p4jUwqZsA2LuSftroCd3zb4ytH8W99oXKuKVZdsty7eQ3rXD6`. We can create a config file under the default `subnet-config-dir` at `$HOME/.avalanchego/configs/subnets/p4jUwqZsA2LuSftroCd3zb4ytH8W99oXKuKVZdsty7eQ3rXD6.json`. An example config file is:
Example: Let's say we have an Avalanche L1 with ID `p4jUwqZsA2LuSftroCd3zb4ytH8W99oXKuKVZdsty7eQ3rXD6`. We can create a config file under the default `subnet-config-dir` at `$HOME/.avalanchego/configs/subnets/p4jUwqZsA2LuSftroCd3zb4ytH8W99oXKuKVZdsty7eQ3rXD6.json`. An example config file is:

```
{
Expand All @@ -601,9 +601,9 @@ Example: Let's say we have a Subnet with ID `p4jUwqZsA2LuSftroCd3zb4ytH8W99oXKuK
<Callout title="Tip" icon = {<BadgeCheck className="size-5 text-card" fill="green" />} >
By default, none of these directories and/or files exist. You would need to create them manually if needed.
</Callout>
#### `--subnet-config-content` (string)[](#--subnet-config-content-string "Direct link to heading")
#### `--subnet-config-content` (string)[](#--avalanche-l1-config-content-string "Direct link to heading")

As an alternative to `--subnet-config-dir`, it allows specifying base64 encoded parameters for a Subnet.
As an alternative to `--subnet-config-dir`, it allows specifying base64 encoded parameters for an Avalanche L1.

Version[](#version "Direct link to heading")
---------------------------------------------
Expand Down Expand Up @@ -676,17 +676,17 @@ Timeout before killing an unresponsive chain. Defaults to `5s`.

Transaction fee, in nAVAX, for transactions that create new assets. Defaults to `10000000` nAVAX (.01 AVAX) per transaction. This can only be changed on a local network.

#### `--create-subnet-tx-fee` (int)[](#--create-subnet-tx-fee-int "Direct link to heading")
#### `--create-subnet-tx-fee` (int)[](#--create-avalanche-l1-tx-fee-int "Direct link to heading")

Transaction fee, in nAVAX, for transactions that create new Subnets. Defaults to `1000000000` nAVAX (1 AVAX) per transaction. This can only be changed on a local network.
Transaction fee, in nAVAX, for transactions that create new Avalanche L1s. Defaults to `1000000000` nAVAX (1 AVAX) per transaction. This can only be changed on a local network.

#### `--create-blockchain-tx-fee` (int)[](#--create-blockchain-tx-fee-int "Direct link to heading")

Transaction fee, in nAVAX, for transactions that create new blockchains. Defaults to `1000000000` nAVAX (1 AVAX) per transaction. This can only be changed on a local network.

#### `--transform-subnet-tx-fee` (int)[](#--transform-subnet-tx-fee-int "Direct link to heading")
#### `--transform-subnet-tx-fee` (int)[](#--transform-avalanche-l1-tx-fee-int "Direct link to heading")

Transaction fee, in nAVAX, for transactions that transform Subnets. Defaults to `1000000000` nAVAX (1 AVAX) per transaction. This can only be changed on a local network.
Transaction fee, in nAVAX, for transactions that transform Avalanche L1s. Defaults to `1000000000` nAVAX (1 AVAX) per transaction. This can only be changed on a local network.

#### `--add-primary-network-validator-fee` (int)[](#--add-primary-network-validator-fee-int "Direct link to heading")

Expand All @@ -696,13 +696,13 @@ Transaction fee, in nAVAX, for transactions that add new primary network validat

Transaction fee, in nAVAX, for transactions that add new primary network delegators. Defaults to 0. This can only be changed on a local network.

#### `--add-subnet-validator-fee` (int)[](#--add-subnet-validator-fee-int "Direct link to heading")
#### `--add-subnet-validator-fee` (int)[](#--add-avalanche-l1-validator-fee-int "Direct link to heading")

Transaction fee, in nAVAX, for transactions that add new Subnet validators. Defaults to `10000000` nAVAX (.01 AVAX).
Transaction fee, in nAVAX, for transactions that add new Avalanche L1 validators. Defaults to `10000000` nAVAX (.01 AVAX).

#### `--add-subnet-delegator-fee` (int)[](#--add-subnet-delegator-fee-int "Direct link to heading")
#### `--add-subnet-delegator-fee` (int)[](#--add-avalanche-l1-delegator-fee-int "Direct link to heading")

Transaction fee, in nAVAX, for transactions that add new Subnet delegators. Defaults to `10000000` nAVAX (.01 AVAX).
Transaction fee, in nAVAX, for transactions that add new Avalanche L1 delegators. Defaults to `10000000` nAVAX (.01 AVAX).

#### `--min-delegator-stake` (int)[](#--min-delegator-stake-int "Direct link to heading")

Expand Down Expand Up @@ -1139,4 +1139,4 @@ Node reports unhealthy if the router drops more than this portion of messages. D

#### `--router-health-max-outstanding-requests` (uint)[](#--router-health-max-outstanding-requests-uint "Direct link to heading")

Node reports unhealthy if there are more than this many outstanding consensus requests (Get, PullQuery, etc.) over all chains. Defaults to `1024`.
Node reports unhealthy if there are more than this many outstanding consensus requests (Get, PullQuery, etc.) over all chains. Defaults to `1024`.
12 changes: 6 additions & 6 deletions content/docs/api-reference/c-chain/api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ where `blockchainID` is the ID of the blockchain running the EVM.
#### WebSocket Endpoints

<Callout title="info">
On the [public API node](/tooling/rpc-providers#supported-apis), it only supports C-Chain
On the [public API node](/tooling/rpc-providers), it only supports C-Chain
websocket API calls for API methods that don't exist on the C-Chain's HTTP API
</Callout>

Expand Down Expand Up @@ -290,7 +290,7 @@ Not recommended for use on Mainnet. See warning notice in [Keystore API](/api-re
</Callout>

Export an asset from the C-Chain to X-Chain or P-Chain. If exporting to the X-Chain, you must call the
X-Chain's [`avm.import`](/api-reference/x-chain/api.md#avmimport).
X-Chain's [`avm.import`](/api-reference/x-chain/api#avmimport).

**Signature:**

Expand Down Expand Up @@ -348,10 +348,10 @@ curl -X POST --data '{
Not recommended for use on Mainnet. See warning notice in [Keystore API](/api-reference/keystore-api).
</Callout>

**DEPRECATED—instead use** [`avax.export`](/api-reference/c-chain/api.md#avaxexport).
**DEPRECATED—instead use** [`avax.export`](/api-reference/c-chain/api#avaxexport).

Send AVAX from the C-Chain to X-Chain or P-Chain. If exporting to the X-Chain, you must call the
X-Chain's [`avm.import`](/api-reference/x-chain/api.md#avmimport) with assetID `AVAX`
X-Chain's [`avm.import`](/api-reference/x-chain/api#avmimport) with assetID `AVAX`
on the X-Chain to complete the transfer.

**Signature:**
Expand Down Expand Up @@ -727,7 +727,7 @@ curl -X POST --data '{
Not recommended for use on Mainnet. See warning notice in [Keystore API](/api-reference/keystore-api).
</Callout>

**DEPRECATED—instead use** [`avax.import`](/api-reference/c-chain/api.md#avaximport)
**DEPRECATED—instead use** [`avax.import`](/api-reference/c-chain/api#avaximport)

Finalize a transfer of AVAX from the X-Chain or P-Chain to the C-Chain.

Expand Down Expand Up @@ -1049,4 +1049,4 @@ curl -X POST --data '{
"id": 1,
"result": {}
}
```
```
4 changes: 2 additions & 2 deletions content/docs/api-reference/c-chain/configs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ by deleting old trie nodes. **While performing offline pruning, your node will
not be able to process blocks and will be considered offline.** While ongoing,
the pruning process consumes a small amount of additional disk space (for
deletion markers and the bloom filter). For more information see
[here.](/nodes/maintain/run-offline-pruning.md#disk-space-considerations)
[here.](/nodes/maintain/reduce-disk-usage#running-offline-pruning)

Since offline pruning deletes old state data, this should not be run on nodes
that need to support archival API requests.
Expand Down Expand Up @@ -850,4 +850,4 @@ _Boolean_
If set to `true`, the chain will skip verifying that all expected network
upgrades have taken place before the last accepted block on startup. This allows
node operators to recover if their node has accepted blocks after a network
upgrade with a version of the code prior to the upgrade. Defaults to `false`.
upgrade with a version of the code prior to the upgrade. Defaults to `false`.
1 change: 1 addition & 0 deletions content/docs/api-reference/c-chain/txn-format.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,4 @@ Let's make a UTXO from the signed transaction created above:
0x24, 0x25, 0x26, 0x27,
]
```

Loading

0 comments on commit e9e7919

Please sign in to comment.