Skip to content

Commit

Permalink
Merge pull request #60 from sei-protocol/feature/for-devs-docs-denys2
Browse files Browse the repository at this point in the history
Feature/for devs docs denys2
  • Loading branch information
codebycarson authored May 24, 2024
2 parents 8bc5617 + 0e3d8de commit 1e69b0d
Show file tree
Hide file tree
Showing 15 changed files with 163 additions and 185 deletions.
1 change: 0 additions & 1 deletion pages/dev-advanced-concepts/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
"hd-path-coin-types": "HD Path & Coin Types",
"proposals": "Proposals",
"evm-rpc-endpoints": "EVM RPC Endpoints",
"pointer-contracts": "EVM Pointer Contracts",
"interoperability": "Interoperability"
}
46 changes: 46 additions & 0 deletions pages/dev-advanced-concepts/interoperability/introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {ImageWithCaption} from "../../../components/ImageWithCaption";

import interoperability from '../../../public/assets/interoperability.png';

# EVM version
Shanghai

# EVM \<\> Wasm Interoperability
EVM and Cosmos based applications co-exist on Sei, but live in different execution environments.
This creates a challenge for users, who use wallets that typically only support a single execution environment.
Likewise for devlelopers, existing tooling and libraries can only interact with either EVM or Wasm (Think EthersJS vs CosmJS).

To bridge the gap between EVM and Wasm, Sei has introduced novel interoperability features, allowing for smooth and easy interactions between both environments.
These features will enable all contracts deployed to Sei to be accessible by tools and wallets from both environments.

<ImageWithCaption img={interoperability} alt="Interoperability" caption="Enabling seamless access to all tokens and contracts on Sei"/>

## Precompiled Contracts

Sei precompiles are smart contracts embedded directly within the Sei blockchain. They provide a gateway for users and developers to access native Sei functionalities through the EVM RPC interface.

### Sei Precompiles

The following is a list of precompiled contracts available on Sei:

- [Addr](./precompiles/addr.mdx)
- [Bank](./precompiles/bank.mdx)
- [CosmWasm](./precompiles/cosmwasm.mdx)
- [Staking](./precompiles/staking.mdx)
- [Distribution](./precompiles/distribution.mdx)
- [IBC](./precompiles/ibc.mdx)
- [JSON](./precompiles/json.mdx)
- [Oracle](./precompiles/oracle.mdx)
- [Pointer](./precompiles/pointer.mdx)
- [PointerView](./precompiles/pointerview.mdx)
- [Governance](./precompiles/governance.mdx)

For instructions on utilizing these precompiles, refer to the [Example Usage](./precompiles/example-usage.mdx) section.

## Pointer Contracts

Pointer Contracts are a unique feature introduced on Sei, designed to enhance interoperability between EVM and CosmWasm environments.
These contracts facilitate the creation of links between tokens across both EVM and CosmWasm.
This enables tokens to move smoothly and be used seamlessly in both environments.

Learn more about Pointer Contracts and how to deploy them [here](../../dev-tutorials/pointer-contracts.mdx ).
Empty file.
2 changes: 1 addition & 1 deletion pages/dev-node/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"node-configuration": "Node Configuration",
"configure-general-settings": "Configure General Settings",
"join-a-network": "Join a Network",
"running-seid": "Running seid CLI"
"running-seid": "Running Seid"
}
33 changes: 19 additions & 14 deletions pages/dev-node/join-a-network.mdx
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
Join a Network
## Join a Network
Follow this guide to join an existing network through statesync To quickly stand up a fresh full node and join in the network, it's recommended to sync through state sync. If you want to run a local instance of Sei, see Running a Local Node

Install Seid Binary
## Install Seid Binary
To stand up a sei node, the first step is to download and install seid on your machine. If you have not done so, follow the steps in Install Seid.

State Sync
### State Sync
State sync allows a new node to join a network by fetching a snapshot of the application state at a recent height instead of fetching and replaying all historical blocks. This can reduce the time needed to sync with the network from days to minutes.

Clean Up
### Clean Up
If you are not starting a node from fresh, then you need to do some backups and clean ups.

# Assuming your sei home directory is /root/.sei
# backup priv_validator_state.json
Assuming your sei home directory is `/root/.sei`, backup `priv_validator_state.json`
```bash
cp /root/.sei/data/priv_validator_state.json /root/priv_validator_state.json

# backup priv_validator_key.json
```
backup `priv_validator_key.json`
```bash
cp /root/.sei/config/priv_validator_key.json /root/priv_validator_key.json

# backup genesis.json
```
backup `genesis.json`
```bash
cp /root/.sei/config/genesis.json /root/genesis.json
rm -rf /root/.sei/data/*
rm -rf /root/.sei/wasm
rm -rf /root/.sei/config/priv_validator_key.json
rm -rf /root/.sei/config/genesis.json
Note: This step is not needed for fresh nodes.

Update Configurations
Set up rpc servers for primary and secondary endpoints. You can use one of the RPC endpoints from the Tools and Resources page.
```
### Update Configurations
Set up rpc servers for primary and secondary endpoints. You can use one of the RPC endpoints from the [RPC providers](../dev-ecosystem-providers/rpc-providers.mdx ) page.
Set up trust height and trust hash. Each snapshot is created at a certain block height, and best practice here is to set the trust height to be earlier than the latest snapshot block height to avoid backward verifications.
# Example: set trust height and hash to be the block height 10,000 earlier

#### Example: set trust height and hash to be the block height 10,000 earlier
```bash
PRIMARY_ENDPOINT=https://sei-testnet-rpc.polkachu.com:443
TRUST_HEIGHT_DELTA=10000

Expand Down Expand Up @@ -65,3 +69,4 @@ Once you finished the above steps, if you previously have done the clean up step
cp /root/priv_validator_state.json /root/.sei/data/priv_validator_state.json
cp /root/priv_validator_key.json /root/.sei/config/priv_validator_key.json
cp /root/genesis.json /root/.sei/config/genesis.json
```
24 changes: 14 additions & 10 deletions pages/dev-node/node-configuration.mdx
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
Node types
## Node types

There are a few node types that can be run on Sei network which serve a variety of purposes. These include:

rpc / full nodes: these nodes are generally used for querying data or interacting with the chain. They maintain some state but not since genesis. The default settings will run rpc / full nodes.
archive nodes: maintain full state of the blockchain from genesis. Generally requires large disks. To enable this type of node, set min-retain-blocks=0 and pruning="nothing" in your app.toml
state sync nodes: provide snapshot data for other nodes to use to bootstrap onto the chain. To enable this type of node, set enable=true under the [statesync] section in config.toml
validator nodes: provide security to the chain by proposing and signing blocks. To enable this type of node, set mode=validator in config.toml. Note that because Sei is proof-of-stake, you must have enough delegation to join the active set
- rpc / full nodes: these nodes are generally used for querying data or interacting with the chain. They maintain some state but not since genesis. The default settings will run rpc / full nodes.
- archive nodes: maintain full state of the blockchain from genesis. Generally requires large disks. To enable this type of node, set min-retain-blocks=0 and pruning="nothing" in your app.toml
- state sync nodes: provide snapshot data for other nodes to use to bootstrap onto the chain. To enable this type of node, set enable=true under the [statesync] section in config.toml
- validator nodes: provide security to the chain by proposing and signing blocks. To enable this type of node, set mode=validator in config.toml. Note that because Sei is proof-of-stake, you must have enough delegation to join the active set
Commonly Used Ports

Seid uses the following TCP ports. Toggle their settings to match your environment.

26656: The default port for the P2P protocol. This port is used to communicate with other nodes and must be open to join a network.
1317: The default port for interacting with the Seid API server for HTTP RESTful requests. This allows applications and services to interact with the seid instance through RPC.
26660: The default port for interacting with the Prometheus database, which can be used to monitor the environment. In the default configuration, this port is not open.
26657: The default port for the RPC protocol. Because this port is used for querying and sending transactions, it must be open for serving queries from seid.
- `26656`: The default port for the P2P protocol. This port is used to communicate with other nodes and must be open to join a network.
- `1317`: The default port for interacting with the Seid API server for HTTP RESTful requests. This allows applications and services to interact with the seid instance through RPC.
- `26660`: The default port for interacting with the Prometheus database, which can be used to monitor the environment. In the default configuration, this port is not open.
- `26657`: The default port for the RPC protocol. Because this port is used for querying and sending transactions, it must be open for serving queries from seid.
These ports are all customizable in $HOME/.sei/config/config.toml and $HOME/.sei/config/app/toml discussed in the later sections along with other fields.

Systemd File Template
### Systemd File Template
```bash
[Unit]
Description=Sei Node
After=network.target
Expand All @@ -36,3 +39,4 @@ LimitNOFILE=65535
[Install]
WantedBy=multi-user.target

```
160 changes: 62 additions & 98 deletions pages/dev-node/running-seid.mdx
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
Running Seid
## Running Seid
How to start and run seid on a full node

Prerequisites
### Prerequisites
This section assumes that you have set up a full node, configured all settings and joined a network.
Run Seid

### Run Seid
You may run seid with
```bash
seid start
```
If you want to see all the flags, you can use
> seid start --help
```bash
seid start --help
```
Run the full node application with Tendermint in or out of process. By
default, the application will run with Tendermint in process.

Pruning options can be provided via the '--pruning' flag or alternatively with '--pruning-keep-recent',
'pruning-keep-every', and 'pruning-interval' together.
Pruning options can be provided via the `--pruning` flag or alternatively with `--pruning-keep-recent`,
`--pruning-keep-every`, and `--pruning-interval` together.

For '--pruning' the options are as follows:
For `--pruning` the options are as follows:

default: the last 100 states are kept in addition to every 500th state; pruning at 10 block intervals
nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node)
everything: all saved states will be deleted, storing only the current and previous state; pruning at 10 block intervals
custom: allow pruning options to be manually specified through 'pruning-keep-recent', 'pruning-keep-every', and 'pruning-interval'
- default: the last 100 states are kept in addition to every 500th state; pruning at 10 block intervals
- nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node)
- everything: all saved states will be deleted, storing only the current and previous state; pruning at 10 block intervals
- custom: allow pruning options to be manually specified through `--pruning-keep-recent`, `--pruning-keep-every`, and `--pruning-interval`

Node halting configurations exist in the form of two flags: '--halt-height' and '--halt-time'. During
Node halting configurations exist in the form of two flags: `--halt-height` and `--halt-time`. During
the ABCI Commit phase, the node will check if the current block height is greater than or equal to
the halt-height or if the current block time is greater than or equal to the halt-time. If so, the
node will attempt to gracefully shutdown and the block will not be committed. In addition, the node
will not be able to commit subsequent blocks.

For profiling and benchmarking purposes, CPU profiling can be enabled via the '--cpu-profile' flag
For profiling and benchmarking purposes, CPU profiling can be enabled via the `--cpu-profile` flag
which accepts a path for the resulting pprof file.

The node may be started in a 'query only' mode where only the gRPC and JSON HTTP
API services are enabled via the 'grpc-only' flag. In this mode, Tendermint is
API services are enabled via the `--grpc-only` flag. In this mode, Tendermint is
bypassed and can be used when legacy queries are needed after an on-chain upgrade
is performed. Note, when enabled, gRPC will also be automatically enabled.

```bash
Usage:
seid start [flags]

Expand Down Expand Up @@ -101,10 +106,12 @@ Global Flags:
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--trace print out full stack trace on errors
Systemd
Seid should be running at all times, it's reccomended you register Seid as a systemd service so that it will be automatically restarted if your system reboots
```
### Systemd
Seid should be running at all times, it's recommended you register Seid as a systemd service so that it will be automatically restarted if your system reboots

Create a definition file in /etc/systemd/system/seid.service
Create a definition file in `/etc/systemd/system/seid.service`
```bash
[Unit]
Description=Sei Node
After=network.target
Expand All @@ -129,83 +136,40 @@ LimitNOFILE=65535
[Install]
WantedBy=multi-user.target

Modify the file with the proper path and Network.
<PATH_TO_SEID> - Enter the path to the Seid executable. <PATH_TO_SEID> is likely /home/<YOUR_USER>/go/bin/seid or /usr/go/bin. Confirm this with whereis seid.
<USER> Enter the user (likely your username or root, unless you created a user specifically for Seid).
<Network> the Chain that this seid binary runs on
Make sure you made the correct edits to /etc/security/limits.conf.
Run systemctl daemon-reload followed by systemctl enable seid. This will register seid as a system service and run the program upon startup.
Controlling the service
Use systemctl to start, stop and restart the service.

# Check health
systemctl status seid
# Start
systemctl start seid
# Stop
systemctl stop seid
# Restart
systemctl restart seid
Use journalctl -t to access entire logs, entire logs in reverse, and the latest and continuous log.

# Entire log reversed
journalctl -t seid -r
# Entire log
journalctl -t seid
# Latest and continuous
journalctl -t seid -f
# Since 30 minutes ago
journalctl -t seid --since -30m
(Optional) Cosmovisor
You may also want to use Cosmovisor such that it's easier to manage upgrades, it's a wrapper around the default seid binary, to install it:

curl -Ls https://github.com/cosmos/cosmos-sdk/releases/download/cosmovisor%2Fv1.3.0/cosmovisor-v1.3.0-linux-amd64.tar.gz | tar xz
chmod 755 cosmovisor
sudo mv cosmovisor /usr/bin/cosmovisor

sudo tee /etc/systemd/system/seid.service > /dev/null << EOF
[Unit]
Description=Sei Atlantic 2 Node Service
After=network-online.target

[Service]
User=$USER
ExecStart=/usr/bin/cosmovisor run start
Restart=always

# wait 30 seconds before restarting the service after it has failed.
RestartSec=30

# wait up to 30 seconds for the service to stop gracefully when it is being stopped.
TimeoutStopSec=30

# send the SIGINT signal (equivalent to pressing Ctrl-C) to the service process when it is being stopped
# giving it a chance to shut down gracefully.
KillSignal=SIGINT

LimitNOFILE=65535
Environment="DAEMON_HOME=$HOME/.sei"
Environment="DAEMON_NAME=seid"
Environment="UNSAFE_SKIP_BACKUP=true"

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable seid
The folder layout is expected to be

.
├── current -> genesis or upgrades/<name>
├── genesis
└── bin
└── $DAEMON_NAME
└── upgrades
└── <name>
└── bin
└── $DAEMON_NAME
The cosmovisor/ directory includes a subdirectory for each version of the application (i.e. genesis or upgrades/<name>). Within each subdirectory is the application binary (i.e. bin/$DAEMON_NAME) and any additional auxiliary files associated with each binary. current is a symbolic link to the currently active directory (i.e. genesis or upgrades/<name>). The name variable in upgrades/<name> is the URI-encoded name of the upgrade as specified in the upgrade module plan.

Please note that $DAEMON_HOME/cosmovisor only stores the application binaries. The cosmovisor binary itself can be stored in any typical location (e.g. /usr/local/bin). The application will continue to store its data in the default data directory (e.g. $HOME/.sei) or the data directory specified with the --home flag. $DAEMON_HOME is independent of the data directory and can be set to any location. If you set $DAEMON_HOME it to the same directory as the data directory, you will end up with a configuration like the following:
```
Modify the file with the proper path and network.

- `<PATH_TO_SEID>` - Enter the path to the Seid executable. `<PATH_TO_SEID>` is likely `/home/<YOUR_USER>/go/bin/seid` or `/usr/go/bin`. Confirm this with where is seid.
- `<USER>` Enter the user (likely your username or root, unless you created a user specifically for Seid).
- `<Network>` the Chain that this seid binary runs on

Make sure you made the correct edits to `/etc/security/limits.conf`.
Run systemctl daemon-reload followed by systemctl enable seid. This will register seid as a system service and run the program upon startup.

### Controlling the service
Use `systemctl` to start, stop and restart the service.
```bash
# Check health
systemctl status seid
# Start
systemctl start seid
# Stop
systemctl stop seid
# Restart
systemctl restart seid
```
Use `journalctl -t` to access entire logs, entire logs in reverse, and the latest and continuous log.
```bash
# Entire log reversed
journalctl -t seid -r
# Entire log
journalctl -t seid
# Latest and continuous
journalctl -t seid -f
# Since 30 minutes ago
journalctl -t seid --since -30m
```
### (Optional) Cosmovisor

You may also want to use Cosmovisor such that it's easier to manage upgrades, it's a wrapper around the default seid
binary, to install it follow [Cosmosvisor Quick Start](https://docs.cosmos.network/v0.45/run-node/cosmovisor.html)
2 changes: 1 addition & 1 deletion pages/dev-resources/_meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tools-and-resources": "Tools and Resources",
"precompiles": "EVM Precompile Contracts",
"resources": "Resources",
"differences-with-ethereum": "Differences from Ethereum"
}
5 changes: 2 additions & 3 deletions pages/dev-tutorials/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"building-a-frontend": "Building a frontend",
"cosmwasm-general": "CosmWasm (General)",
"evm-general": "EVM (General)",
"evm-cli": "EVM (CLI)",
"interoperability": "Interoperability",
"token-factory-tutorial": "Token Factory",
"evm-cli-tutorial": "EVM (CLI)",
"tokenfactory-tutorial": "Token Factory",
"nft-contract-tutorial": "NFT Contracts",
"pointer-contracts": "Pointer Contracts",
"multi-sig-accounts": "Multi-Sig Accounts",
Expand Down
Loading

0 comments on commit 1e69b0d

Please sign in to comment.