Skip to content

Commit

Permalink
Merge branch 'master' into new-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyeh committed Dec 4, 2023
2 parents ca30f6a + 5b61e2d commit f6de86c
Show file tree
Hide file tree
Showing 169 changed files with 13,874 additions and 22,526 deletions.
91 changes: 10 additions & 81 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,88 +1,17 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
"plugin:react/recommended",
"airbnb-typescript",
"plugin:import/typescript",
// @NOTE: Make sure this is always the last element in the array.
"plugin:prettier/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
project: ["./tsconfig.json"],
},
plugins: [
"react",
"react-hooks",
"jsx-a11y",
"import",
"prettier",
"@typescript-eslint",
"plugin:@docusaurus/recommended",
],
settings: {
react: {
pragma: "React", // Pragma to use, default to "React"
fragment: "Fragment", // Fragment to use (may be a property of <pragma>), default to "Fragment"
version: "detect", // React version. "detect" automatically picks the version you have installed.
// You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
// default to latest and warns if missing
// It will default to "detect" in the future
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
typescript: {},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
},
project: ["./tsconfig.json"]
},
rules: {
"import/prefer-default-export": 0,
"react/prop-types": 0,
"import/no-unresolved": [
"error",
{ ignore: ["^@theme", "^@docusaurus", "^@site"] },
],
"no-nested-ternary": 0,
"no-console": 0,
"no-unused-vars": 0,
"no-use-before-define": 0,
"arrow-body-style": 0,
"jsx-a11y/anchor-is-valid": 0,
"jsx-a11y/no-static-element-interactions": 0,
"jsx-a11y/click-events-have-key-events": 0,
"@typescript-eslint/no-unused-expressions": 0,
"@typescript-eslint/no-unused-vars": ["warn", { args: "none" }],
"@typescript-eslint/no-use-before-define": "warn",
"react/require-default-props": 0,
"react/jsx-props-no-spreading": 0,
"react/button-has-type": 0,
"jsx-a11y/label-has-associated-control": [
"error",
{
labelComponents: [],
labelAttributes: [],
controlComponents: [],
assert: "either",
depth: 2,
},
],
"@typescript-eslint/naming-convention": [
"error",
{
selector: "variableLike",
leadingUnderscore: "forbid",
trailingUnderscore: "forbid",
format: ["camelCase", "PascalCase", "UPPER_CASE"],
},
],
"import/extensions": 0,
'@docusaurus/no-untranslated-text': 0
},
};
};
11 changes: 0 additions & 11 deletions .prettierrc

This file was deleted.

24 changes: 8 additions & 16 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
module.exports = {
extends: ["stylelint-config-standard", "stylelint-config-prettier"],
rules: {
"selector-pseudo-class-no-unknown": [
true,
{
// :global is a CSS modules feature to escape from class name hashing
ignorePseudoClasses: ["global"],
},
],
"extends": "stylelint-config-standard",
"rules": {
"selector-class-pattern": null,
"custom-property-empty-line-before": null,
"selector-id-pattern": null,
"declaration-empty-line-before": null,
"comment-empty-line-before": null,
"value-keyword-case": ["lower", { camelCaseSvgKeywords: true }],
},
};
"comment-empty-line-before" : null,
"media-feature-range-notation": null,
"selector-anb-no-unmatchable": null,
"declaration-block-no-duplicate-properties": null
}
}
3 changes: 0 additions & 3 deletions babel.config.js

This file was deleted.

49 changes: 38 additions & 11 deletions docs/concepts/weak-subjectivity.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,58 @@ sidebar_position: 7

# Weak subjectivity

The weak subjectivity period refers to how far behind the chain head a node can be before 1/3 of validators may have exited since the node was last in sync.
The weak subjectivity period refers to how far behind the chain head a node can be before 1/3 of
validators may have exited since the node was last in sync.

For example, if 1/3 of validators withdraw their stake and continue signing blocks and attestations, they can form a chain which conflicts with the finalized state. If your node is far enough behind the chain head not to be aware that they've withdrawn their funds, these validators can act dishonestly and continue feeding you blocks to lead you down the wrong chain.
For example, if 1/3 of validators withdraw their stake and continue signing blocks and attestations,
they can form a chain which conflicts with the finalized state.
If your node is far enough behind the chain head not to be aware that they've withdrawn their funds,
these validators can act dishonestly and continue feeding you blocks to lead you down the wrong chain.

:::note

If a node is aware that a validator has withdrawn its funds, the node will reject the validator's attestations.

:::

## Safely sync your node
At a high-level, the weak subjectivity period is the period of time that a node can be behind the
chain and trust that it is following the correct chain.
In practice, the weak subjectivity mechanism tells Teku if the latest checkpoint is too old to
continue syncing from it (either when starting a new node or after your node has been offline for a while).

Teku provides two methods to safely sync a node that is new to the network or has been offline for an extended period.

1. Use [`--initial-state`](../reference/cli/index.md#initial-state) to supply an SSZ encoded state file from which to sync.
2. Use [`--ws-checkpoint`](../reference/cli/index.md#ws-checkpoint) to supply a weak subjectivity checkpoint by which a node can securely validate its view of the current state.
## Safely sync your node

We recommend using `--initial-state`. It provides the same security benefits as `--ws-checkpoint`, but syncs faster. The only exception is when syncing an archive node, in which case, use `--ws-checkpoint`.
Teku provides three methods to safely sync a node that is new to the network or has been offline for an extended period.

:::tip
1. Use [`--checkpoint-sync-url`](../reference/cli/index.md#checkpoint-sync-url) to supply a URL of a
checkpoint state endpoint from which to sync.
2. Use [`--initial-state`](../reference/cli/index.md#initial-state) to supply an SSZ encoded state
file from which to sync.

Use the [`/eth/v2/debug/beacon/states/<state_id>`](https://consensys.github.io/teku/#operation/getEthV2DebugBeaconStatesWithState_id) API on an updated node to download a recent finalized state as an SSZ encoded state file.
We recommend using `--checkpoint-sync-url` on Mainnet.

:::tip
Use the [`/eth/v2/debug/beacon/states/<state_id>`](https://consensys.github.io/teku/#operation/getEthV2DebugBeaconStatesWithState_id)
API on an updated node to download a recent finalized state as an SSZ encoded state file.
:::

Another option is to [reconstruct historical states](../how-to/reconstruct-historical-states.md).
This allows the creation of a full archive node, ensuring that once the node is
up-to-date, the concerns associated with weak subjectivity are cleared.

## Sync outside the weak subjectivity period

Originally, Teku's default behavior was to sync from any point in the chain without the weak
subjectivity check, including syncing all the way from the genesis of the chain.
However, this is considered unsafe.

If you want to allow Teku to sync outside the weak subjectivity period, you can use the
[`--ignore-weak-subjectivity-period-enabled`](../reference/cli/index.md#ignore-weak-subjectivity-period-enabled)
CLI option.

## Learn more

See the following resources to learn more about weak subjectivity:

- [Ethereum weak subjectivity documentation](https://ethereum.org/en/developers/docs/consensus-mechanisms/pos/weak-subjectivity/)
- [Proof of Stake: How I Learned to Love Weak Subjectivity](https://blog.ethereum.org/2014/11/25/proof-stake-learned-love-weak-subjectivity)
- [Exploring Ethereum 2: Weak Subjectivity Period](https://www.symphonious.net/2019/11/27/exploring-ethereum-2-weak-subjectivity-period/)
29 changes: 21 additions & 8 deletions docs/get-started/checkpoint-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ sidebar_position: 4

# Start Teku from a recent state

To get Teku up and running in only a few minutes, you can start Teku from a recent finalized checkpoint state rather than syncing from genesis.
To get Teku up and running in only a few minutes, start Teku from a recent finalized checkpoint
state rather than syncing from genesis.
Using a checkpoint state enables Teku to sync within the
[weak subjectivity](../concepts/weak-subjectivity.md) period.

When starting from a recent checkpoint, Teku downloads historic chain data in the background.

:::tip
You need access to a beacon node with [REST API enabled] (for example, Teku) to download the
finalized checkpoint state file.

You need access to a beacon node with [REST API enabled] (for example, Teku) to download the finalized checkpoint state file.

Alternatively, you can use a Checkpointz endpoint from [this community-maintained list of checkpoint state endpoints](https://eth-clients.github.io/checkpoint-sync-endpoints/).

Alternatively, you can use a Checkpointz endpoint from
[this community-maintained list of checkpoint state endpoints](https://eth-clients.github.io/checkpoint-sync-endpoints/).
:::

The following command downloads a recent finalized checkpoint state from a beacon node, and starts Teku:
Expand All @@ -26,11 +29,13 @@ teku --eth1-endpoint=http://localhost:8545 \
--checkpoint-sync-url=https://beaconstate.ethstaker.cc
```

The command uses the [`--checkpoint-sync-url`](../reference/cli/index.md#checkpoint-sync-url) option to download the finalized checkpoint state.
The command uses the [`--checkpoint-sync-url`](../reference/cli/index.md#checkpoint-sync-url) option
to download the finalized checkpoint state.

:::note

You can also download a finalized checkpoint state file, and specify the location using the [`--initial-state`](../reference/cli/index.md#initial-state) option. To download the file and name it `state.ssz` run:
You can also download a finalized checkpoint state file, and specify the location using the
[`--initial-state`](../reference/cli/index.md#initial-state) option.
To download the file and name it `state.ssz` run:

```bash
curl -o state.ssz -H 'Accept: application/octet-stream' http://other-node:5051/eth/v2/debug/beacon/states/finalized
Expand All @@ -44,6 +49,14 @@ teku --eth1-endpoint=http://localhost:8545 \
--initial-state=state.ssz
```

Another option is to use [`--initial-state`](../reference/cli/index.md#initial-state) with the URL
of the state you want to use:

```bash
teku --eth1-endpoint=http://localhost:8545 \
--validator-keys=/Users/me/mainnet/validator/keys:/Users/me/mainnet/validator/passwords \
--initial-state=http://other-node:5051/eth/v2/debug/beacon/states/finalized
```
:::

<!--links-->
Expand Down
13 changes: 11 additions & 2 deletions docs/get-started/connect/mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,16 @@ teku \
--ee-endpoint=http://localhost:8551 \
--ee-jwt-secret-file=<path to jwtsecret.hex> \
--metrics-enabled=true \
--rest-api-enabled=true
--rest-api-enabled=true \
--checkpoint-sync-url=<checkpoint sync URL>
```

Specify the path to the `jwtsecret.hex` file generated in [step 1] using the [`--ee-jwt-secret-file`](../../reference/cli/index.md#ee-jwt-secret-file) option.
Specify:

- The path to the `jwtsecret.hex` file generated in [step 1] using the
[`--ee-jwt-secret-file`](../../reference/cli/index.md#ee-jwt-secret-file) option.
- The URL of a checkpoint sync endpoint using the
[`--checkpoint-sync-url`](../../reference/cli/index.md#checkpoint-sync-url) option.

Also, in the command:

Expand Down Expand Up @@ -113,13 +119,16 @@ teku \
--ee-jwt-secret-file=<path to jwtsecret.hex> \
--metrics-enabled=true \
--rest-api-enabled=true \
--checkpoint-sync-url=<checkpoint sync URL> \
--validators-proposer-default-fee-recipient=<ETH address> \
--validator-keys=<path to key file>:<path to password file>[,<path to key file>:<path to password file>,...]
```

Specify:

- The path to the `jwtsecret.hex` file generated in [step 1] using the [`--ee-jwt-secret-file`](../../reference/cli/index.md#ee-jwt-secret-file) option.
- The URL of a checkpoint sync endpoint using the
[`--checkpoint-sync-url`](../../reference/cli/index.md#checkpoint-sync-url) option.
- An Ethereum address you own as the default fee recipient using the [`--validators-proposer-default-fee-recipient`](../../reference/cli/index.md#validators-proposer-default-fee-recipient) option.
- The paths to the keystore `.json` file and password `.txt` file created in [step 2](#create-a-password-file-for-each-validator-key) for each validator using the [`--validator-keys`](../../reference/cli/index.md#validator-keys) option. Separate the `.json` and `.txt` files with a colon, and separate entries for multiple validators with commas. Alternatively, specify paths to directories to load multiple keys and passwords from.

Expand Down
Loading

0 comments on commit f6de86c

Please sign in to comment.